undomanager.html
author Ryosuke Niwa <rniwa@webkit.org>
Tue, 27 Mar 2012 21:44:44 -0700
changeset 0 2f3551c872b8
child 1 56ac42b37fdf
permissions -rwxr-xr-x
Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     1
<!DOCTYPE html><head>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     2
<meta content="text/html; charset=utf-8" http-equiv=content-type>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     3
<title>UndoManager and DOM Transaction</title>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     4
<link href=http://www.whatwg.org/style/specification rel=stylesheet type=text/css>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     5
</head>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     6
<body class=draft>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     7
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     8
<div class=head>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     9
<h1>UndoManager and DOM Transaction</h1>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    10
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    11
<h2 class="no-num no-toc" id="editor's-proposal-&mdash;-5-december-2011">Editor's proposal &mdash; 5 December 2011</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    12
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    13
<dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    14
<dt>Editor:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    15
<dd>Ryosuke Niwa &lt;<a href=mailto:rniwa@webkit.org>rniwa@webkit.org</a>&gt;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    16
</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    17
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    18
<dt>Acknowledgements</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    19
<dd>Anne van Kesteren, Annie Sullivan, Alex Russell, Aryeh Gregor, Ehsan Akhgari, Eric Uhrhane,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    20
Frederico Caldeira Knabben, Ian Hickson, Johan "Spocke" S&ouml;rlin, Jonas Sicking, Ojan Vafai</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    21
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    22
<dt>Latest version:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    23
<dd><a href=http://rniwa.com/editing/undomanager.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    24
http://rniwa.com/editing/undomanager.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    25
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    26
<dt>Previous versions:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    27
<dd><a href=http://rniwa.com/editing/undomanager-2011-12-01.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    28
http://rniwa.com/editing/undomanager-2011-12-01.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    29
<dd><a href=http://rniwa.com/editing/undomanager-2011-11-29.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    30
http://rniwa.com/editing/undomanager-2011-11-29.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    31
<dd><a href=http://rniwa.com/editing/undomanager-2011-10-27.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    32
http://rniwa.com/editing/undomanager-2011-10-27.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    33
<dd><a href=http://rniwa.com/editing/undomanager-2011-10-20.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    34
http://rniwa.com/editing/undomanager-2011-10-20.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    35
<dd><a href=http://rniwa.com/editing/undomanager-2011-10-09.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    36
http://rniwa.com/editing/undomanager-2011-10-09.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    37
<dd><a href=http://rniwa.com/editing/undomanager-2011-09-11.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    38
http://rniwa.com/editing/undomanager-2011-09-11.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    39
<dd><a href=http://rniwa.com/editing/undomanager-2011-08-30.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    40
http://rniwa.com/editing/undomanager-2011-08-30.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    41
<dd><a href=http://rniwa.com/editing/undomanager-2011-08-09.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    42
http://rniwa.com/editing/undomanager-2011-08-09.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    43
<dd><a href=http://rniwa.com/editing/undomanager-2011-08-08.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    44
http://rniwa.com/editing/undomanager-2011-08-08.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    45
<dd><a href=http://rniwa.com/editing/undomanager-2011-07-26.html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    46
http://rniwa.com/editing/undomanager-2011-07-26.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    47
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    48
<dt>Use cases:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    49
<dd><a href=http://wiki.whatwg.org/wiki/UndoManager_Problem_Descriptions>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    50
http://wiki.whatwg.org/wiki/UndoManager_Problem_Descriptions</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    51
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    52
</dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    53
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    54
</div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    55
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    56
<h2 class="no-num no-toc" id=status>Status</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    57
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    58
<p>This document is an early proposal of the specification for Undo Manager and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    59
DOM transaction. This specification will replace the <a href=http://www.whatwg.org/specs/web-apps/current-work/#undomanager>UndoManager</a> section
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    60
of the main <a href=http://www.whatwg.org/html>HTML</a> specification.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    61
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    62
<h2 class="no-num no-toc" id=table-of-contents>Table of Contents</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    63
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    64
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    65
<!--begin-toc-->
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    66
<ol class=toc>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    67
 <li><a href=#introduction><span class=secno>1 </span>Introduction</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    68
 <li><a href=#undo-scope-and-undo-manager><span class=secno>2 </span>Undo Scope and Undo Manager</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    69
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    70
   <li><a href=#definitions><span class=secno>2.1 </span>Definitions</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    71
   <li><a href=#scoping-undo-transaction-history><span class=secno>2.2 </span>Scoping Undo Transaction History</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    72
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    73
     <li><a href=#undo-scope-and-contenteditable><span class=secno>2.2.1 </span>Undo scope and contenteditable</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    74
     <li><a href=#undoscope-idl-attribute><span class=secno>2.2.2 </span>undoScope IDL attribute</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    75
   <li><a href=#the-undomanager-interface><span class=secno>2.3 </span>The <code>UndoManager</code> interface</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    76
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    77
     <li><a href=#undomanager-idl-attribute><span class=secno>2.3.1 </span>undoManager IDL attribute</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    78
   <li><a href=#undo:-moving-forward-in-the-undo-transaction-history><span class=secno>2.4 </span>Undo: moving forward in the undo transaction history</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    79
   <li><a href=#redo:-moving-backward-in-the-undo-transaction-history><span class=secno>2.5 </span>Redo: moving backward in the undo transaction history</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    80
 <li><a href=#dom-transaction-and-dom-changes><span class=secno>3 </span>DOM Transaction and DOM changes</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    81
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    82
   <li><a href=#mutations-of-dom><span class=secno>3.1 </span>Mutations of DOM</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    83
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    84
     <li><a href=#reverting-dom-changes><span class=secno>3.1.1 </span>Reverting DOM changes</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    85
     <li><a href=#reapplying-dom-changes><span class=secno>3.1.2 </span>Reapplying DOM changes</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    86
   <li><a href=#the-domtransaction-interface><span class=secno>3.2 </span>The <code>DOMTransaction</code> interface</a></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    87
   <li><a href=#automatic-dom-transactions><span class=secno>3.3 </span>Automatic DOM transactions</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    88
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    89
     <li><a href=#automatic-transactions-and-manual-dom-changes><span class=secno>3.3.1 </span>Automatic transactions and manual DOM changes</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    90
   <li><a href=#manual-dom-transactions><span class=secno>3.4 </span>Manual DOM transactions</a></ol></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    91
 <li><a href=#transaction,-undo,-and-redo-events><span class=secno>4 </span>Transaction, Undo, and Redo Events</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    92
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    93
   <li><a href=#the-domtransactionevent-interface><span class=secno>4.1 </span>The <code>DOMTransactionEvent</code> interface</a></ol></ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    94
<!--end-toc-->
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    95
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    96
<h2 id=introduction><span class=secno>1 </span>Introduction</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    97
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    98
    <p>This specification defines the API to manage user agent's <a href=#undo-transaction-history>undo transaction history</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    99
    (also known as <dfn id=undo-stack>undo stack</dfn>) and make objects that can be managed by
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   100
    the <a href=#undo-transaction-history>undo transaction history</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   101
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   102
    <p>Many rich text editors on the Web add editing operations that are not natively supported by execCommand and other Web APIs.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   103
    For example, many editors make modifications to DOM after an user agent executed user editing actions to work-around user agent bugs
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   104
    and to customize for their use.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   105
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   106
    <p>However, doing so breaks user agent's native undo and redo because the user agent cannot undo DOM modifications made by scripts.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   107
    This forces the editors to re-implement undo and redo entirely from scratch, and many editors, indeed, store innerHTML as string and recreate
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   108
    the entire editable region whenever a user tires to undo and redo. This is very inefficient and has limited the depth of their <a href=#undo-stack>undo stack</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   109
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   110
    <p>Also, any Web app that tries to mix contenteditable region or text fields with canvas or other non-text editable regions will have to
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   111
    reimplement undo and redo of contenteditable regions as well because the user agent typically has one <a href=#undo-transaction-history>undo transaction history</a> per document,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   112
    and there is no easy way to add new undo entry to the user agent's native <a href=#undo-transaction-history>undo transaction history</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   113
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   114
    <p>This specification tries to address above issues by providing ways to define <a href=#undo-scope>undo scopes</a>, add items to user agent's native
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   115
    <a href=#undo-transaction-history>undo transaction history</a>, and create a sequence of <a href=#dom-changes>DOM changes</a> that can be automatically undone or redone
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   116
    by user agents.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   117
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   118
<h2 id=undo-scope-and-undo-manager><span class=secno>2 </span>Undo Scope and Undo Manager</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   119
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   120
<h3 id=definitions><span class=secno>2.1 </span>Definitions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   121
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   122
    <p>The user agent must associate an <dfn id=undo-transaction-history>undo transaction history</dfn>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   123
    a list of sequences of <a href=#dom-transaction>DOM transactions</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   124
    with each <code><a href=#undomanager>UndoManager</a></code> object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   125
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   126
    <p>The <a href=#undo-transaction-history>undo transaction history</a> has an <dfn id=undo-position>undo position</dfn>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   127
    This is the position between two entries in the <a href=#undo-transaction-history>undo transaction history</a>'s list where the next
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   128
    entry represents what needs to happen when <a href=#undo>undo</a> is done,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   129
    and the previous entry represents what needs to happen when <a href=#redo>redo</a> is done.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   130
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   131
    <p>The <dfn id=undo-scope title=undo-scope>undo scope</dfn> is the collection of DOM nodes that are managed by the same <code><a href=#undomanager>UndoManager</a></code>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   132
    A document node or an element with <code><a href=#attr-undoscope>undoscope</a></code> attribute that is either an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   133
    or not <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> defines a new <a href=#undo-scope>undo scope</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   134
    and all descendent nodes of the element, excluding elements with and descendent nodes of elements with <code><a href=#attr-undoscope>undoscope</a></code> attribute,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   135
    will be managed by a new <code><a href=#undomanager>UndoManager</a></code>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   136
    An <dfn id=undo-scope-host>undo scope host</dfn> is a document, or an element with <code><a href=#attr-undoscope>undoscope</a></code> attribute that is either
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   137
    an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   138
    or not <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   139
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   140
<h3 id=scoping-undo-transaction-history><span class=secno>2.2 </span>Scoping Undo Transaction History</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   141
    <p>The <dfn id=attr-undoscope title=attr-undoscope><code>undoscope</code></dfn> attribute is a
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   142
    <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attribute>boolean attribute</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   143
    that controls the default <a href=#undo-scope>undo scope</a> of an element. It is to separate <a href=#undo-transaction-history>undo transaction histories</a> of multiple editable regions without scripts.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   144
    Using <code><a href=#attr-undoscope>undoscope</a></code> content attribute, authors can easily set text fields in a widget to have a separate <a href=#undo-transaction-history>undo transaction histories</a> for example.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   145
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   146
    <p>When the <code><a href=#attr-undoscope>undoscope</a></code> content attribute is added to an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   147
    or an element that is not <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a>, the user agent must define new <a href=#undo-scope>undo scope</a> for the element,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   148
    and create a new <code><a href=#undomanager>UndoManager</a></code> to manage any <a href=#dom-changes>DOM changes</a> made to all descendent nodes of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   149
    the element excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   150
    
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   151
    <p>When the <code><a href=#attr-undoscope>undoscope</a></code> content attribute is removed from an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   152
    or an element that is not <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a>, the user agent must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   153
    of the corresponding <a href=#undo-scope>undo scope</a> without <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> them and destroy the corresponding <code><a href=#undomanager>UndoManager</a></code> for the scope.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   154
    After the removal, the node from which the content attribute is removed and their descendent nodes, excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   155
    belong to the <a href=#undo-scope>undo scope</a> of the closest ancestor with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   156
    the <code><a href=#attr-undoscope>undoscope</a></code> content attribute or of the document.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   157
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   158
<h4 id=undo-scope-and-contenteditable><span class=secno>2.2.1 </span>Undo scope and contenteditable</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   159
    <p><code><a href=http://www.whatwg.org/specs/web-apps/current-work/#attr-contenteditable>contenteditable</a></code> content attribute does not define a new <a href=#undo-scope>undo scope</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   160
    and all <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing hosts</a> share the same <code><a href=#undomanager>UndoManager</a></code> by default.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   161
    And the <code><a href=#attr-undoscope>undoscope</a></code> content attribute on an <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> element is ignored.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   162
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   163
    <p>When the <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable>contenteditable</a></code> content attribute is added to an element,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   164
    the user agent must remove all entries in the <a href=#undo-transaction-history>undo transaction histories</a> of the editable <a href=#undo-scope>undo scope hosts</a> that are descendent of the element
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   165
    and have become <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> without <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> the entries
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   166
    and destroy the corresponding <code><a href=#undomanager>UndoManager</a></code>s as if the <code><a href=#attr-undoscope>undoscope</a></code> content attribute was removed from all descendent nodes
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   167
    excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   168
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   169
    <p>Conversely, when the <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable>contenteditable</a></code> content attribute is removed from an element,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   170
    the user agent must define new <a href=#undo-scope>undo scope</a> for each descendent element with the <code><a href=#attr-undoscope>undoscope</a></code> content attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   171
    and create a new <code><a href=#undomanager>UndoManager</a></code> to manage any <a href=#dom-changes>DOM changes</a> made to descendents of each element,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   172
    excluding <a href=#undo-scope-host>undo scope hosts</a> and their descendents, as if the <code><a href=#attr-undoscope>undoscope</a></code> content attribute was re-added to descendent elements with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   173
    the <code><a href=#attr-undoscope>undoscope</a></code> content attribute.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   174
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   175
<h4 id=undoscope-idl-attribute><span class=secno>2.2.2 </span>undoScope IDL attribute</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   176
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   177
    <pre class=idl>partial interface <a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614>Element</a> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   178
    attribute boolean <a href=#dom-undoscope>undoScope</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   179
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   180
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   181
        <dt><var title="">element</var> . <code title=dom-undoScope><a href=#dom-undoscope>undoScope</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   182
        <dd><p>Returns <code>true</code> if the element is an undo scope host and <code>false</code> otherwise.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   183
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   184
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   185
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   186
        <p>The <dfn id=dom-undoscope><code>undoScope</code></dfn> IDL attribute of <code><a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614>Element</a></code> interfaces must <a href=http://www.whatwg.org/specs/web-apps/current-work/complete/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes>reflect</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   187
        the <code><a href=#attr-undoscope>undoscope</a></code> content attribute.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   188
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   189
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   190
<h3 id=the-undomanager-interface><span class=secno>2.3 </span>The <code><a href=#undomanager>UndoManager</a></code> interface</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   191
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   192
    <p>To manage transaction entries in the undo transaction history, the <code><a href=#undomanager>UndoManager</a></code> interface can be used:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   193
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   194
    <pre class=idl>interface <dfn id=undomanager>UndoManager</dfn> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   195
    void <a href=#dom-undomanager-transact title=dom-UndoManager-transact>transact</a>(in Object transaction, in boolean merge);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   196
    void <a href=#dom-undomanager-undo title=dom-UndoManager-undo>undo</a>();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   197
    void <a href=#dom-undomanager-redo title=dom-UndoManager-redo>redo</a>();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   198
    getter DOMTransaction[] <a href=#dom-undomanager-item title=dom-UndoManager-item>item</a>(in unsigned long index);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   199
    readonly attribute unsigned long <a href=#dom-undomanager-length title=dom-UndoManager-length>length</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   200
    readonly attribute unsigned long <a href=#dom-undomanager-position title=dom-UndoManager-position>position</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   201
    void <a href=#dom-undomanager-clearUndo title=dom-UndoManager-clearUndo>clearUndo</a>();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   202
    void <a href=#dom-undomanager-clearRedo title=dom-UndoManager-clearRedo>clearRedo</a>();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   203
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   204
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   205
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   206
        <dt><var title="">document</var> . <code title=dom-undoManager><a href=#dom-undomanager>undoManager</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   207
        <dd><p>Returns the <code><a href=#undomanager>UndoManager</a></code> object.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   208
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   209
        <dt><var title="">element</var> . <code title=dom-undoManager><a href=#dom-undomanager>undoManager</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   210
        <dd><p>Returns the <code><a href=#undomanager>UndoManager</a></code> object.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   211
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   212
        <dt><var title="">undoManager</var> . <code title=dom-UndoManager-transact><a href=#dom-undomanager-transact>transact</a>(<var title="">transaction</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   213
            <var title="">merge</var>)</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   214
        <dd><p>Clears entries above the current undo position, and <a href=#dom-transaction-apply>applies</a> <var title="">transaction</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   215
            and pushes it to the <a href=#undo-transaction-history>undo transaction history</a><a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   216
            It also forms a </a><a href=#dom-transaction-group>DOM transaction group</a> if <var title="">merge</var> is set to true.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   217
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   218
        <dt><var title="">undoManager</var> . <code title=dom-UndoManager-undo><a href=#dom-undomanager-undo>undo</a>()</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   219
        <dd><p>Unapplies all <a href=#dom-transaction>DOM transactions</a> in the entry immediately after
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   220
            the current position in the reverse order and increments
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   221
            <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> by 1
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   222
            if <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &lt;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   223
            <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code>.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   224
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   225
        <dt><var title="">undoManager</var> . <code title=dom-UndoManager-redo><a href=#dom-undomanager-redo>redo</a>()</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   226
        <dd><p>Reapplies all <a href=#dom-transaction>DOM transactions</a> in the entry immediately before
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   227
            the current position and decrements <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> by 1
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   228
            if <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &gt; 0</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   229
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   230
        <dt><var title="">undoManager</var> . <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   231
        <dd><p>Returns the number of the current entry in the <a href=#undo-transaction-history>undo transaction history</a><a>. (Entries at and past this point are redo entries.)</a></dd><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   232
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   233
        </a><dt><a><var title="">undoManager</var> . <code title=dom-UndoManager-length></code></a><code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   234
        <dd><p>Returns the number of entries in the <a href=#undo-transaction-history>undo transaction history</a><a>.</a></dd><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   235
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   236
        </a><dt><a><var title="">data</var> = <var title="">undoManager</var> . <code title=dom-UndoManager-item></code></a><code title=dom-UndoManager-item><a href=#dom-undomanager-item>item</a></code>(<var title="">index</var>)</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   237
        <dt><var title="">undoManager</var>[<var title="">index</var>]</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   238
        <dd><p>Returns the entry with index <var title="">index</var> in the <a href=#undo-transaction-history>undo transaction history</a><a>.</a></p><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   239
            <p>Returns null if <var title="">index</var> is out of range.</a></dd><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   240
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   241
        </a><dt><a><var title="">undoManager</var> . <code title=dom-UndoManager-clearundo></code></a><code title=dom-UndoManager-clearundo><a href=#dom-undomanager-clearundo>clearUndo</a>()</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   242
        <dd><p>Removes entries in the <a href=#undo-transaction-history>undo transaction history</a><a> before
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   243
            <code title=dom-UndoManager-position></code></a><code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   244
            resets <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> to 0.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   245
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   246
        <dt><var title="">undoManager</var> . <code title=dom-UndoManager-clearredo><a href=#dom-undomanager-clearredo>clearRedo</a>()</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   247
        <dd><p>Removes entries in the <a href=#undo-transaction-history>undo transaction history</a><a> after
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   248
            <code title=dom-UndoManager-position></code></a><code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code>.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   249
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   250
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   251
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   252
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   253
        <p><code><a href=#undomanager>UndoManager</a></code> objects represent and manage their node's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   254
        <a href=#undo-transaction-history>undo transaction history</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   255
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   256
        <p>The object's <a href=http://www.whatwg.org/specs/web-apps/current-work/#supported-property-indices>supported property indices</a> are the
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   257
        numbers in the range zero to <span title=""><var title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></var>-1</span>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   258
        unless the <var title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></var> is zero, in which
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   259
        case there are no <a href=http://www.whatwg.org/specs/web-apps/current-work/#supported-property-indices>supported property indices</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   260
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   261
        <p>The <dfn id=dom-undomanager-transact title=dom-UndoManager-transact><code>transact(<var title="">transaction</var>, <var title="">merge</var>)</code></dfn> will</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   262
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   263
            <li>If this <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>, <a href=#dom-transaction-unapply>unapplying</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   264
                or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>, then throw
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   265
                <code class=external><a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-INVALID_ACCESS_ERR>INVALID_ACCESS_ERR</a></code> and stop.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   266
            <li>Clear all entries between before the current <a href=#undo-position>undo position</a> without <a href=#dom-transaction-unapply>unapplying</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   267
            or <a href=#dom-transaction-reapply>reapplying</a> the <a href=#dom-transaction>transactions</a> in the entires.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   268
            <li><a href=#dom-transaction-apply>Apply</a> the <var title="">transaction</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   269
            <li>If <var title="">merge</var> is not set to true or there are no entries in the <a href=#undo-transaction-history>undo transaction history</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   270
            create a new entry with exactly one transaction <var title="">transaction</var> and add it to the top of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   271
            the <a href=#undo-transaction-history>undo transaction history</a> and go to step 6.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   272
            <li>Otherwise, add <var title="">transaction</var> to the first entry in the <a href=#undo-transaction-history>undo transaction history</a>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   273
            <li><a href=#fire-a-dom-transaction-event>Fire a DOM transaction event</a> for the transaction applied in step 3 at the <a href=#undo-scope-host>undo scope host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   274
            of this <code><a href=#undomanager>UndoManager</a></code> if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   275
            had not already been destroyed.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   276
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   277
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   278
        <p>The <dfn id=dom-undomanager-undo title=dom-UndoManager-undo><code>undo()</code></dfn> will</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   279
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   280
            <li>If <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>, <a href=#dom-transaction-unapply>unapplying</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   281
            or <a href=dom-transaction-reapply>reapplying</a>, then throw <code class=external><a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-INVALID_ACCESS_ERR>INVALID_ACCESS_ERR</a></code> and stop.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   282
            <li>If <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &le; <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code>, stop.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   283
            <li>Otherwise, <a href=#dom-transaction-unapply>unapply</a> transactions t<sub>n</sub>, t<sub>n-1</sub>, ... t<sub>1</sub> where
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   284
            t<sub>1</sub>, t<sub>2</sub>, ... t<sub>n</sub> is the sequence of <a href=#dom-transaction>DOM transactions</a> for the entry immediately after
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   285
            the <a href=#undo-position>undo position</a> and increment <a href=#dom-undomanager-position>position</a> by 1.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   286
            <li><a href=#fire-an-undo-event>Fire an undo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a> of this <code><a href=#undomanager>UndoManager</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   287
            if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code> had not already been destroyed.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   288
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   289
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   290
        <p>The <dfn id=dom-undomanager-redo title=dom-UndoManager-redo><code>redo()</code></dfn> will</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   291
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   292
            <li>If <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>, <a href=#dom-transaction-unapply>unapplying</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   293
            or <a href=dom-transaction-reapply>reapplying</a>, then throw <code class=external><a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMException-INVALID_ACCESS_ERR>INVALID_ACCESS_ERR</a></code> and stop.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   294
            <li>If <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &le; 0, stop.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   295
            <li>Otherwise, <a href=#dom-transaction-reapply>reapply</a> transactions t<sub>1</sub>, t<sub>2</sub>, ... t<sub>n</sub> where
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   296
            t<sub>1</sub>, t<sub>2</sub>, ... t<sub>n</sub> is the sequence of <a href=#dom-transaction>DOM transactions</a> for the entry immediately before
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   297
            the <a href=#undo-position>undo position</a> and decrement <a href=#dom-undomanager-position>position</a> by 1.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   298
            <li><a href=#fire-a-redo-event>Fire a redo event</a> for the transaction unapplied in step 3 at the <a href=#undo-scope-host>undo scope host</a> of this <code><a href=#undomanager>UndoManager</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   299
            if <a href=#undo-scope-host>undo scope host</a> is still in the document and <code><a href=#undomanager>UndoManager</a></code> had not already been destroyed.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   300
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   301
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   302
        <p>The <dfn id=dom-undomanager-item title=dom-UndoManager-item><code>item(<var title="">n</var>)</code></dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   303
        method must return a new array representing the <var title="">n</var>th entry in the <a href=#undo-transaction-history>undo transaction history</a> if
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   304
        0 &le; <var>n</var> &le; <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code>, or null otherwise.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   305
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   306
        <p class=note>Being able to access an arbitrary element in the <a href=#undo-transaction-history>undo transaction history</a> is needed to allow scripts to determine
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   307
        whether new DOM transaction and the last DOM transaction should form a <a href=#dom-transaction-group>DOM transaction group</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   308
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   309
        <p>The <dfn id=dom-undomanager-position title=dom-UndoManager-position><code>position</code></dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   310
        attribute must return the index of the <a href=#undo-position>undo position</a> in the <a href=#undo-transaction-history>undo transaction history</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   311
        If there are no <a href=#dom-transaction>DOM transaction</a>s to undo, then the value must be same as
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   312
        <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code> attribute.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   313
        If there are no <a href=#dom-transaction>DOM transaction</a>s to redo, then the value must be zero.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   314
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   315
        <p>The <dfn id=dom-undomanager-length title=dom-UndoManager-length><code>length</code></dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   316
        attribute must return the number of entries in the <a href=#undo-transaction-history>undo transaction history</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   317
        This is the <var title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></var>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   318
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   319
        <p>The <dfn id=dom-undomanager-clearundo title=dom-UndoManager-clearUndo><code>clearUndo()</code></dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   320
        method must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> after the <a href=#undo-position>undo position</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   321
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   322
        <p>The <dfn id=dom-undomanager-clearredo title=dom-UndoManager-clearRedo><code>clearRedo()</code></dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   323
        method must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> before the <a href=#undo-position>undo position</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   324
        and move the <a href=#undo-position>undo position</a> to the top (set <a href=#dom-undomanager-position>position</a> to zero).</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   325
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   326
        <p><dfn id=the-active-undo-manager>The active undo manager</dfn> is the <code><a href=#undomanager>UndoManager</a></code> of the focused node in the document.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   327
        If no node has focus, then it's assumed to be of the document.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   328
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   329
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   330
    <p>Each entry in the <a href=#undo-manager>UndoManager</a> consists of one or more <a href=#dom-transaction>DOM transactions</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   331
    all of which are <a href=#dom-transaction-unapply>unapplied</a> and <a href=#dom-transaction-reapply>reapplied</a> togehter in one
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   332
    <a href=#undo>undo</a> or <a href=#redo>redo</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   333
    </p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   334
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   335
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   336
        <p>Because <code><a href=#dom-undomanager-item>item()</a></code> returns new array on each call,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   337
        modifying the array does not have any effect on the sequence of <a href=#dom-transaction>DOM transactions</a> of the entry,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   338
        and two return values of <code><a href=#dom-undomanager-item>item()</a></code> are alwys different objects.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   339
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   340
        <pre>document.undoManager.transact(...);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   341
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   342
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   343
alert(document.undoManager.item(0).length); // Alerts 3
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   344
document.undoManager.item(0).pop();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   345
alert(document.undoManager.item(0).length); // Still alerts 3
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   346
alert(document.undoManager.item(0) === document.undoManager.item(0)); // Alerts false
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   347
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   348
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   349
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   350
    <p class=note>A typical use case for having multiple <a href=#dom-transaction>DOM transactions</a> in one entry is for typing
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   351
    multiple letters, spaces, and new lines that must be undone or redone in one step.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   352
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   353
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   354
        <p>In the following example, letters "o" and "k" are inserted by two <a href=#automatic-dom-transaction>automatic DOM transactions</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   355
        that form one entry in the <a href=#undo-transaction-history>undo transaction history</a> of the <a href=#undo-manager>UndoManager</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   356
        A br element and string "hi" are then inserted by another two <a href=#automatic-dom-transaction>automatic DOM transactions</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   357
        to form entry in the <a href=#undo-transaction-history>undo transaction history</a>. All transactions have the label "Typing".</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   358
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   359
        <pre>// Assume myEditor is some element that has undoscope attribute, and insert(node) is a function that inserts the specified node at where the caret is.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   360
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   361
    insert(document.createTextNode('o')); }, label: 'Typing'});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   362
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   363
    insert(document.createTextNode('k')); }, label: 'Typing'}, true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   364
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   365
    insert(document.createElement('br')); }, label: 'Typing'});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   366
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   367
    insert(document.createTextNode('hi')); }, label: 'Typing'}), true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   368
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   369
        <p>When the first <a href=#undo>undo</a> is executed immediately after this code is ran, the last two transactions are <a href=#dom-transaction-unapply>unapplied</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   370
        and the br element and string "hi" will be removed from the DOM. The second <a href=#undo>undo</a> will <a href=#dom-transaction-unapply>unapply</a> the first two transactions and remove "o" and "k".</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   371
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   372
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   373
    <p class=note>Because Mac OS X and other frameworks expect applications to provide an array of undo items, simply dispatching undo and redo events
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   374
    and having scripts manage <a href=#undo-transaction-history>undo transaction history</a> would not let the user agent populate the native UI properly.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   375
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   376
<h4 id=undomanager-idl-attribute><span class=secno>2.3.1 </span>undoManager IDL attribute</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   377
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   378
    <pre class=idl>partial interface <a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-745549614>Element</a> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   379
    attribute <a href=#undomanager>UndoManager</a> <a href=#dom-undomanager>undoManager</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   380
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   381
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   382
        <dt><var title="">element</var> . <code title=dom-undoManager><a href=#dom-undomanager>undoManager</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   383
        <dd><p>Returns the <code><a href=#undomanager>UndoManager</a></code> object associated with the element's <a href=#undo-scope>undo scope</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   384
        if the element is an <a href=#undo-scope-host>undo scope host</a>, or <code>null</code> otherwise.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   385
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   386
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   387
    <pre class=idl>partial interface <a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document>Document</a> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   388
    attribute <a href=#undomanager>UndoManager</a> <a href=#dom-undomanager>undoManager</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   389
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   390
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   391
        <dt><var title="">document</var> . <code title=dom-undoManager><a href=#dom-undomanager>undoManager</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   392
        <dd><p>Returns the <code><a href=#undomanager>UndoManager</a></code> object associated with the document.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   393
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   394
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   395
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   396
        <p>The <dfn id=dom-undomanager title=dom-undoManager><code>undoManager</code></dfn> IDL attribute of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   397
        <code class=external><a href=http://www.whatwg.org/specs/web-apps/current-work/#document>Document</a></code> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   398
        <code class=external><a href=http://www.whatwg.org/specs/web-apps/current-work/#element>Element</a></code> interfaces must return the object implementing
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   399
        the <code><a href=#undomanager>UndoManager</a></code> interface for the <a href=#undo-scope>undo scope</a> if the node is an <a href=#undo-scope-host>undo scope host</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   400
        If the node is not an <a href=#undo-scope-host>undo scope host</a>, it must return <code>null</code>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   401
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   402
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   403
<h3 id=undo:-moving-forward-in-the-undo-transaction-history><span class=secno>2.4 </span>Undo: moving forward in the undo transaction history</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   404
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   405
    <p>When the user invokes an undo operation, or when the
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   406
    <code class=external><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#execCommand>execCommand()</a></code> method is called with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   407
    the undo command, the user agent must perform an <dfn id=undo>undo</dfn> operation on <a href=#the-active-undo-manager>the active undo manager</a> by calling
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   408
    the <code><a href=#dom-undomanager-undo>undo</a>()</code> method.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   409
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   410
<h3 id=redo:-moving-backward-in-the-undo-transaction-history><span class=secno>2.5 </span>Redo: moving backward in the undo transaction history</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   411
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   412
    <p>When the user invokes a redo operation, or when the
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   413
    <code class=external><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#execCommand>execCommand()</a></code> method is called with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   414
    the redo command, the user agent must perform an <dfn id=redo>redo</dfn> operation on <a href=#the-active-undo-manager>the active undo manager</a> by calling
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   415
    the <code><a href=#dom-undomanager-redo>redo</a>()</code> method.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   416
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   417
<h2 id=dom-transaction-and-dom-changes><span class=secno>3 </span>DOM Transaction and DOM changes</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   418
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   419
    <p>A <dfn id=dom-transaction>DOM transaction</dfn> is an ordered set of <a href=#dom-changes>DOM changes</a> associated with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   420
    a unique <a href=#undo-scope-host>undo scope host</a> that can be <a href=#dom-transaction-apply>applied</a>, <a href=#dom-transaction-unapply>unapplied</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   421
    or <a href=#dom-transaction-reapply>reapplied</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   422
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   423
    <p>To <dfn id=dom-transaction-apply title=dom-transaction-apply>apply</dfn> a <a href=#dom-transaction>DOM transaction</a> means to make the associated <a href=#dom-changes>DOM changes</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   424
    under the associated <a href=#undo-scope-host>undo scope host</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   425
    And to <dfn id=dom-transaction-unapply title=dom-transaction-unapply>unapply</dfn> and to <dfn id=dom-transaction-reapply title=dom-transaction-reapply>reapply</dfn>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   426
    a <a href=#dom-transaction>DOM transaction</a> means, respectively, to revert and to remake the associated <a href=#dom-changes>DOM changes</a> under the associated <a href=#undo-scope-host>undo scope host</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   427
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   428
    <p>A <a href=#dom-transaction>DOM transaction</a> can be <a href=#dom-transaction-unapply>unapplied</a> or <a href=#dom-transaction-reapply>reapplied</a> if it appears, respectively, immediately after or immediately before
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   429
    the <a href=#undo-position>undo position</a> in the associated <code><a href=#undomanager>UndoManager</a></code>'s <a href=#undo-transaction-history>undo transaction history</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   430
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   431
<h3 id=mutations-of-dom><span class=secno>3.1 </span>Mutations of DOM</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   432
    <p><dfn id=dom-changes>DOM changes</dfn> of a node is a sequence s<sub>1</sub>, s<sub>2</sub>, ... s<sub>n</sub> where each s<sub>i</sub> with 1 &le; i &le; n is either one of:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   433
    <ul>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   434
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-insert>Inserting</a> or <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-remove>removing</a> a node under the element.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   435
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>Replacement of character data</a>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   436
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-append>Appending</a>, <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-remove>removing</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   437
        or <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attribute-change>changing</a> a content attribute of the element or descendent nodes of the element.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   438
        <li>Setting <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-textarea-element>textarea</a></code> element's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   439
        <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#dom-textarea-value>value</a></code> IDL attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   440
        or <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element>input</a></code> elment's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   441
        <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#dom-input-value>value</a></code> IDL attribute.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   442
    </ul>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   443
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   444
    <p>The <dfn id=dom-state>DOM state</dfn> of a node is the state of all descendent nodes and their attributes that are affected by <a href=#dom-changes>DOM changes</a> of the element.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   445
    If two <a href=#dom-states>DOM states</a> of a node are equal, then the node and all its descendent nodes must be identical.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   446
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   447
<h4 id=reverting-dom-changes><span class=secno>3.1.1 </span>Reverting DOM changes</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   448
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   449
    <p>To <dfn id=revert-dom-changes>revert DOM changes</dfn> of the sequence s<sub>1</sub>, s<sub>2</sub>, ... s<sub>n</sub>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   450
    revert each s<sub>i</sub> with 1 &le; i &le; n in the reverse order s<sub>n</sub>, s<sub>n-1</sub>, ... s<sub>1</sub> as specified below:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   451
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   452
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-insert>inserting</a> a <var>node</var> into a <var>parent</var> before a <var>child</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   453
    run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   454
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   455
        <li>If <var>node</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   456
        <li>If <var>child</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   457
        <li>If <var>child</var> is not null and its previous sibling is not <var>node</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   458
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-pre-remove>Pre-remove</a> <var>node</var> from <var>parent</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   459
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   460
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   461
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-remove>removing</a> a <var>node</var> from a <var>parent</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   462
    let <var>child</var> be the next sibling of <var>node</var> before the removal, and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   463
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   464
        <li>If <var>node</var> is not null and its parent is not null, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   465
        <li>If <var>child</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   466
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-pre-insert>Pre-insert</a> <var>child</var> into <var>parent</var> before <var>child</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   467
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   468
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   469
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>replacing</a> data of a <var>node</var> with an <var>offset</var>, <var>count</var>, and <var>data</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   470
    let <var>replacedData</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>substringed data</a> with <var>node</var>, <var>offset</var>, and <var>count</var> before the replacement,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   471
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   472
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   473
        <li>If node's <code><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-length>length</a></code> attribute is less than <var>offset</var>, terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   474
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>Replace data</a> of <var>node</var> with <var>offset</var>, the length of data, and <var>replacedData</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   475
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   476
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   477
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-change>changing</a> an attribute whose
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   478
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   479
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var> to <var>value</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   480
    let <var>oldValue</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-value>content attribute value</a> before the change,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   481
    <var>oldPrefix</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a> before the change,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   482
    and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-change>change</a> the attribute to <var>oldValue</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   483
    and set the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a> to <var>oldPrefix</var>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   484
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   485
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-append>appending</a> an attribute whose
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   486
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   487
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var> to a node
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   488
    and setting the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a> to <var>prefix</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   489
    run these steps.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   490
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   491
        <li>If a content attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   492
        is <var>namespace</var> and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   493
        is <var>localName</var> doesn't exist on the node, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   494
        <li>Otherwise, <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-remove>remove</a> the attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   495
        whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   496
        <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   497
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   498
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   499
    <p>To revert <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-remove>removing</a> an attribute whose
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   500
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   501
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var> from a node,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   502
    let <var>oldValue</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-value>content attribute value</a> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   503
    <var>oldPrefix</var> be the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   504
    both before the removal, and run these steps.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   505
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   506
        <li>If a content attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   507
        is <var>namespace</var> and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   508
        is <var>localName</var> exists on the node, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   509
        <li>Otherwise, create and append the attribute whose
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   510
        <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   511
        <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   512
        with <var>oldValue</var> as the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-value>content attribute value</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   513
        and set the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   514
        to <var>oldPrefix</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   515
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   516
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   517
    <p>To revert setting <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-textarea-element>textarea</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   518
    element's <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#dom-textarea-value>value</a></code> IDL attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   519
    and <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element>input</a></code> element's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   520
    <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#dom-input-value>value</a></code> IDL attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   521
    to <var>value</var>, set element's <code>value</code> IDL attribute to
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   522
    the <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#concept-textarea-raw-value>raw value</a> of the textarea element
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   523
    and the <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#concept-fe-value>value</a> of the input element
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   524
    before the setting respectively.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   525
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   526
<h4 id=reapplying-dom-changes><span class=secno>3.1.2 </span>Reapplying DOM changes</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   527
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   528
    <p>To <dfn id=reapply-dom-changes>reapply DOM changes</dfn> of the sequence s<sub>1</sub>, s<sub>2</sub>, ... s<sub>n</sub>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   529
    reapply each s<sub>i</sub> with 1 &le; i &le; n in the same order s<sub>1</sub>, s<sub>2</sub>, ... s<sub>n</sub> as specified below:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   530
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   531
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-insert>inserting</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   532
    a <var>node</var> into a <var>parent</var> before a <var>child</var>, run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   533
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   534
        <li>If <var>node</var> is not null and its parent is not null, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   535
        <li>If <var>child</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   536
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-pre-insert>Pre-insert</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   537
        <var>child</var> into <var>parent</var> before <var>child</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   538
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   539
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   540
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-remove>removing</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   541
    a <var>node</var> from a <var>parent</var>, let <var>child</var> be the next sibling of <var>node</var> before the removal,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   542
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   543
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   544
        <li>If <var>node</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   545
        <li>If <var>child</var> is not null and its parent is not <var>parent</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   546
        <li>If <var>child</var> is not null and its previous sibling is not <var>node</var>, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   547
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-pre-remove>Pre-remove</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   548
        <var>node</var> from <var>parent</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   549
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   550
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   551
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>replacing</a> data
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   552
    of a <var>node</var> with an <var>offset</var>, <var>count</var>, and <var>data</var>, and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   553
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   554
        <li>If node's <code><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-characterdata-length>length</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   555
        attribute is less than <var>offset</var>, terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   556
        <li><a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-cd-replace>Replace data</a> of <var>node</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   557
        with <var>offset</var>, <var>count</var>, and <var>replacedData</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   558
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   559
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   560
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-change>changing</a> an attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   561
    whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   562
    and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   563
    to <var>value</var>, let <var>prefix</var> be the
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   564
    <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a> after the change,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   565
    and change the attribute to <var>value</var> and set
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   566
    the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a> to <var>prefix</var>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   567
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   568
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-append>appending</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   569
    an attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   570
    and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   571
    with <var>value</var> as the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-value>content attribute value</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   572
    to a node and setting the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   573
    to <var>prefix</var>, run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   574
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   575
        <li>If a content attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   576
        is <var>namespace</var> and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   577
        <var>localName</var> exists on the node, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   578
        <li>Otherwise, <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-append>append</a> the attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   579
        whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   580
        <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   581
        with <var>value</var> as the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-value>content attribute value</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   582
        to the node, and set <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace-prefix>namespace prefix</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   583
        to <var>prefix</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   584
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   585
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   586
    <p>To reapply <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-remove>removing</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   587
    an attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   588
    and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   589
    from a node, run these steps.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   590
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   591
        <li>If a content attribute whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   592
        <var>namespace</var> and <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   593
        <var>localName</var> doesn't exist on the node, then terminate these steps.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   594
        <li>Otherwise, <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-element-attributes-remove>remove</a> the attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   595
        whose <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace>namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   596
        <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name>local name</a> is <var>localName</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   597
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   598
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   599
    <p>To reapply setting <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#the-textarea-element>textarea</a></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   600
    element's <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#dom-textarea-value>value</a></code> IDL attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   601
    or <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element>input</a></code> elment's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   602
    <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#dom-input-value>value</a></code> IDL attribute
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   603
    to <var>value</var>, set element's <code>value</code> IDL attribute to <var>value</var>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   604
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   605
<h3 id=the-domtransaction-interface><span class=secno>3.2 </span>The <code><a href=#dom-domtransaction>DOMTransaction</a></code> interface</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   606
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   607
    <pre class=idl>[NoInterfaceObject]
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   608
interface <dfn id=dom-domtransaction>DOMTransaction</dfn> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   609
    attribute DOMString <a href=#dom-domtransaction-label>label</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   610
    attribute <a href=http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#function>Function</a>? <a href=#dom-domtransaction-executeautomatic>executeAutomatic</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   611
    attribute <a href=http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#function>Function</a>? <a href=#dom-domtransaction-execute>execute</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   612
    attribute <a href=http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#function>Function</a>? <a href=#dom-domtransaction-undo>undo</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   613
    attribute <a href=http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#function>Function</a>? <a href=#dom-domtransaction-redo>redo</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   614
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   615
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   616
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   617
        <p>The <code><a href=#dom-domtransaction>DOMTransaction</a></code> interface is to be implemented by content scripts that implement a <a href=#dom-transaction>DOM transaction</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   618
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   619
        <p><dfn id=dom-domtransaction-label><code>label</code></dfn> attribute must return <code>null</code> or a string that
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   620
        describes the semantics of the transaction such as "Inserting text" or "Deleting selection".
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   621
        The user agent may expose this string or a part of this string through its native UI such as menu bar or context menu.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   622
        When there are multiple <a href=#dom-transaction>transactions</a> in a single entry of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   623
        the <a href=#undo-transaction-history>undo transaction history</a>, the user agent that doesn't support displaying
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   624
        multiple labels for each entry must use the label of the first transaction in the sequence of the entry.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   625
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   626
        <p><dfn id=dom-domtransaction-executeautomatic><code>executeAutomatic()</code></dfn>, <dfn id=dom-domtransaction-execute><code>execute()</code></dfn>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   627
        <dfn id=dom-domtransaction-undo><code>undo()</code></dfn>, and <dfn id=dom-domtransaction-redo><code>redo()</code></dfn> are attributes that must be supported,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   628
        as IDL attributes, by objects implementing the <code><a href=#dom-domtransaction>DOMTransaction</a></code> interface.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   629
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   630
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   631
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   632
        <p>Any changes made to the value of <code><a href=#dom-domtransaction-executeautomatic>executeAutomatic</a></code>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   633
        <code><a href=#dom-domtransaction-execute>execute</a></code>, <code><a href=#dom-domtransaction-undo>undo</a></code>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   634
        or <code><a href=#dom-domtransaction-redo>redo</a></code> attributes will take effect immediately. In the following example,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   635
        <code><a href=#dom-domtransaction-execute>execute</a></code> and <code><a href=#dom-domtransaction-undo>undo</a></code> attributes are modified:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   636
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   637
        <pre>document.undoManager.transact({ executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   638
    this.executeAutomatic = function () { alert('foo'); }
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   639
    alert('bar');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   640
}, undo: function () { alert('baz'); } }); // alerts 'bar'
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   641
document.undoManager.item(0)[0].undo = function() { alert('foobar'); }
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   642
docuemnt.undoManager.undo(); // alerts 'foobar'
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   643
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   644
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   645
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   646
        <p><dfn id=dom-domtransaction-executeautomatic><code>executeAutomatic</code></dfn> attribute must return a valid function if the transaction is a <a href=#automatic-dom-transaction>automatic DOM transaction</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   647
        and <code>undefined</code> if it is a <a href=#manual-dom-transaction>manual DOM transaction</a> immediately before the transaction is <a href=#dom-transaction-apply>applied</a>.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   648
        Any changes made to the value of the <code><a href=#dom-domtransaction-executeautomatic>executeAutomatic</a></code> attribute while the transaction is being <a href=#dom-transaction-apply>applied</a> or after the transaction had been <a href=#dom-transaction-apply>applied</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   649
        should not change the type of the <a href=#dom-transaction>DOM transaction</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   650
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   651
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   652
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   653
        <p>All <a href=#dom-changes>DOM changes</a> made in <code><a href=#dom-domtransaction-execute>execute</a></code> or
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   654
        <code><a id=dom-domtransaction-executeautomatic>executeAutomatic</a></code> take effect immediately.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   655
        Sometimes, this destroys the undoManager to which it belongs.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   656
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   657
        <pre>var scope = document.createElement('div');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   658
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   659
document.body.appendChild(scope);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   660
scope.undoManager.transact({execute: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   661
    scope.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   662
    alert(scope.textContent); // "foo"
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   663
    scope.undoScope = false;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   664
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   665
scope.undoManager.undo(); // Throws an error because undoManager returns null.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   666
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   667
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   668
<h3 id=automatic-dom-transactions><span class=secno>3.3 </span>Automatic DOM transactions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   669
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   670
    <p>An <dfn id=automatic-dom-transaction>automatic DOM transaction</dfn> is a <a href=#dom-transaction>DOM transaction</a> where <a href=#dom-changes>DOM changes</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   671
    are tracked by the user agent and the logic to <a href=#dom-transaction-unapply>unapply</a> or <a href=#dom-transaction-reapply>reapply</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   672
    the transaction is implicitly created by the user agent. </p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   673
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   674
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   675
        <p>When an <a href=#automatic-dom-transaction>automatic DOM transaction</a> is <a href=#dom-transaction-apply>applied</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   676
        the user agent must call the function returned by the <code><a id=dom-domtransaction-executeautomatic>executeAutomatic</a></code> attribute if the attribute returns a valid function object.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   677
        All <a href=#dom-changes>DOM changes</a> made by the method in the corresponding <a href=#undo-scope>undo scope</a> of the <code><a href=#undomanager>UndoManager</a><a></a></code><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   678
        must be tracked by the user agent.</a></p><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   679
    </a></div><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   680
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   681
    </a><div class=example><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   682
        </a><p><a>All </a><a href=#dom-changes>DOM changes</a> made outside of the <a href=#undo-scope>undo scope</a> is ignored.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   683
        In the following example, <code><a href=#dom-undomanager-undo>undo</a>()</code> will only remove "bar" and "foo"
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   684
        remains in the body.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   685
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   686
        <pre>var scope = document.createElement('div');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   687
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   688
document.body.appendChild(scope);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   689
scope.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   690
    document.body.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   691
    scope.appendChild("bar");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   692
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   693
scope.undoManager.undo();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   694
alert(document.body.textContent); // Alerts "bar".
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   695
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   696
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   697
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   698
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   699
        <p>When an <a href=#automatic-dom-transaction>automatic DOM transaction</a> is <a href=#dom-transaction-unapply>unapplied</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   700
        the user agent must <a href=#revert-dom-changes>revert DOM changes</a> made inside the <a href=#undo-scope>undo scope</a> of the the <code><a href=#undomanager>UndoManager</a><a></a></code><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   701
        while </a><a href=#dom-transaction-apply>applying</a> the transaction, and call the function returned by the <code><a id=dom-domtransaction-undo>undo</a></code> attribute if the attribute returns a valid function object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   702
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   703
        <p>When an <a href=#automatic-dom-transaction>automatic DOM transaction</a> is <a href=#dom-transaction-reapply>reapplied</a>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   704
        the user agent must <a href=#unrevert-dom-changes>reapply DOM changes</a> made inside the <a href=#undo-scope>undo scope</a> of the the <code><a href=#undomanager>UndoManager</a><a></a></code><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   705
        while </a><a href=#dom-transaction-apply>applying</a> the transaction.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   706
        The user agent must then call the function returned by the <code><a id=dom-domtransaction-redo>redo</a></code> attribute if the attribute returns a valid function object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   707
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   708
        <p>The user agent must also restore <a href=https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#concept-selection>selection</a> after
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   709
        <a href=#dom-transaction-unapply>unapplying</a> or <a href=#dom-transaction-reapply>reapplying</a> an <a href=#automatic-dom-transaction>automatic DOM transaction</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   710
        in accordance to user agent's platform convention.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   711
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   712
        <p>The user agent must implement <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#user-editing-actions>user editing actions</a> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   713
        <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dnd>drag and drop</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   714
        as <a href=#automatic-dom-transaction>automatic DOM transactions</a>, and any application defined <a href=#automatic-dom-transactions>automatic DOM transactions</a> must be compatible with
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   715
        <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#user-editing-actions>user editing actions</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   716
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   717
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   718
    <p>In an <a href=#automatic-dom-transaction>automatic DOM transaction</a>, <code><a id=dom-domtransaction-execute>execute</a></code> attribute is ignored.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   719
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   720
<h4 id=automatic-transactions-and-manual-dom-changes><span class=secno>3.3.1 </span>Automatic transactions and manual DOM changes</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   721
    <p>Authors should not modify nodes that are used by <a href=#automatic-dom-transaction>automatic DOM transactions</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   722
    in <a href=#revert-dom-changes>reverting</a> or <a href=#unrevert-dom-changes>reapplying</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   723
    <a href=#dom-changes>DOM changes</a> as it will interfere with the user agent's attempt to <a href=#transaction-unapply>unapply</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   724
    or <a href=#transaction-reapply>reapply</a> automatic DOM transactions.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   725
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   726
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   727
        <p>In the following example, the user agent terminates steps early while reverting
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   728
        the <a href=http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-insert>insertion</a> of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   729
        the text node <code>" world"</code> in the first call to <code><a href=#dom-undomanager-undo>undo</a>()</code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   730
        and doesn't make any <a href=#dom-changes>DOM changes</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   731
        <pre>var b = document.createTextNode("b");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   732
b.appendChild(document.createTextNode("hello"));
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   733
document.body.appendChild(b);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   734
document.undoManager.transact({ executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   735
    document.body.appendChild(document.createTextNode(" world")); }});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   736
b.appendChild(document.body.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   737
document.undoManager.undo(); // No-op.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   738
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   739
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   740
        <p>On the other hand, if we store the <a href=#dom-state>DOM state</a> as done below, then the call to
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   741
        <code><a href=#dom-undomanager-undo>undo</a>()</code> will successfully remove the the text node from the body.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   742
<pre>document.undoManager.redo(); // No-op.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   743
document.body.appendChild(b.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   744
document.undoManager.undo(); // " world" is removed from document.body
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   745
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   746
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   747
<h3 id=manual-dom-transactions><span class=secno>3.4 </span>Manual DOM transactions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   748
    <p>A <dfn id=manual-dom-transaction>manual DOM transaction</dfn> is a <a href=#dom-transaction>DOM transaction</a> where the logic to
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   749
    <a href=#dom-transaction-unapply>apply</a>, <a href=#dom-transaction-unapply>unapply</a>, or <a href=#dom-transaction-reapply>reapply</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   750
    the transaction is explicitly defined by an application.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   751
    It provides a way to communicate with user agent's <a href=#undo-transaction-history>undo transaction history</a>, e.g. to populate user agent's undo menu.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   752
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   753
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   754
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-apply>applied</a>, the user agnet must call
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   755
        the function returned by the <code><a id=dom-domtransaction-execute>execute</a></code> if the attribute returns a valid function object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   756
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   757
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-unapply>unapplied</a>, the user agnet must call
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   758
        the function returned by the <code><a id=dom-domtransaction-undo>undo</a></code> attribute if the attribute returns a valid function object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   759
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   760
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-reapply>reapplied</a>, the user agnet must call
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   761
        the function returned by the <code><a id=dom-domtransaction-redo>redo</a></code> attribute if the attribute returns a valid function object.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   762
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   763
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   764
    <p>In a <a href=#manual-dom-transaction>manual DOM transaction</a>, <code><a id=dom-domtransaction-executeautomatic>executeAutomatic</a></code> attribute is ignored.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   765
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   766
    <p class=note>Manual DOM transactions may be incompatible with automatic DOM transactions, in particular,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   767
    with <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#user-editing-actions>user editing actions</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   768
    if manual DOM transaction mutates nodes that are dependent on by <a href=#automatic-dom-transaction>automatic DOM transactions</a>.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   769
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   770
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   771
        <p><a href=#manual-dom-transaction>Manual DOM transactions</a> will let authors populate items
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   772
        in the <a href=#undo-transaction-history>undo transaction history</a>. In particular, this will let
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   773
        the user agent to fill native UIs such as menu bars to display undoable actions.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   774
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   775
        <pre>function drawLine(start, end, style) {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   776
    document.undoManager.transact({ execute: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   777
            // Draw a line on canvas
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   778
        }, undo: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   779
            // Undraw a line
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   780
        }, redo: function () { this.execute(); },
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   781
        'Draw a line'
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   782
    });
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   783
}
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   784
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   785
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   786
        <p>In this example, <var>drawLine()</var> will add a new entry to the document's
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   787
        <a href=#undo-transaction-history>undo transaction history</a> and the user agent can communicate the existence
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   788
        of this undoable action via UIs such as context menu and menubars.</div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   789
    
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   790
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   791
<h2 id=transaction,-undo,-and-redo-events><span class=secno>4 </span>Transaction, Undo, and Redo Events</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   792
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   793
    <p>When a new <a href=#dom-transaction>DOM transaction</a> is <a href=#dom-transaction-apply>applied</a> by <code><a href=#dom-undomanager-transact>transact</a>()</code> method to an <a href=#undo-transaction-history>undo transaction history</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   794
    of a <code><a href=#undomanager>UndoManager</a></code>, the user agent must fire a <dfn id=dom-transaction-event>DOM transaction event</dfn> using
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   795
    the <code><dfn id=dom-transactionevent title=dom-transactionEvent>TransactionEvent</dfn></code> interface.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   796
    When a <a href=#dom-transaction>DOM transaction</a> is <a href=#dom-transaction-unapply>unapplied</a> or <a href=#dom-transaction-reapply>reapplied</a> though <code><a href=#dom-undomanager-undo>undo</a>()</code> method or
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   797
    <code><a href=#dom-undomanager-redo>redo</a>()</code> method, of a <code><a href=#undomanager>UndoManager</a></code>, the user agent must fire
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   798
    an <dfn id=undo-event>undo event</dfn> and a <dfn id=redo-event>redo event</dfn> respectively.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   799
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   800
<h3 id=the-domtransactionevent-interface><span class=secno>4.1 </span>The <code><a href=#domtransactionevent>DOMTransactionEvent</a></code> interface</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   801
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   802
    <pre class=idl>[Constructor(DOMString type, optional EventInit eventInitDict)]
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   803
interface <dfn id=domtransactionevent>DOMTransactionEvent</dfn> : <a href=http://www.whatwg.org/specs/web-apps/current-work/#event>Event</a> {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   804
    readonly attribute Object <a href=#dom-domtransactionevent-transaction>transaction</a>;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   805
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   806
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   807
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   808
        <dt><var title="">DOMTransactionEvent</var> . <code title=dom-domtransactionevent-transaction><a href=#dom-domtransactionevent-transaction>transaction</a></code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   809
        <dd><p>Returns the transaction object that triggered this event.</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   810
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   811
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   812
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   813
        <p>The <dfn id=dom-domtransactionevent-transaction title=dom-DOMTransactionEvent-transaction><code>transaction</code></dfn> attribute of
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   814
        the <code><a href=#dom-domtransactionevent>DOMTransactionEvent</a></code> interface must return the object that implements
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   815
        the <code><a href=#dom-domtransaction>DOMTransactionEvent</a></code> interface that triggered the event.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   816
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   817
        <p>When the user agent is required to <dfn id=fire-a-dom-transaction-event>fire a DOM transaction event</dfn> for a <a href=#dom-transaction>DOM transaction</a> <var>t</var> at
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   818
        an <a href=#undo-scope-host>undo scope host</a> <var>h</var>, the user agent must run the following steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   819
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   820
            <li>Create a <code><a href=#dom-domtransactionevent>DOMTransactionEvent</a></code> object and initialize it to have the name "<code><a href=#dom-domtransaction>DOMTransaction</a></code>",
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   821
            to bubble, to not cancelable, and to have the <code>transaction</code> attribute initialized to <var>t</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   822
            <li>Dispatch the newly created <code><a href=#dom-domtransactionevent>DOMTransactionEvent</a></code> object at the node <var>h</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   823
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   824
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   825
        <p>When the user agent is required to <dfn id=fire-an-undo-event>fire an undo event</dfn> and <dfn id=fire-a-redo-event>fire a redo event</dfn> for a <a href=#dom-transaction>DOM transaction</a> <var>t</var> at
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   826
        an <a href=#undo-scope-host>undo scope host</a> <var>h</var>, the user agent must run the following steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   827
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   828
            <li>Create a <code><a href=#dom-domtransactionevent>DOMTransactionEvent</a></code> object and initialize it to have the name "<code><a href=#undo>undo</a></code>" and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   829
            "<code><a href=#redo>redo</a></code>" respectively, to bubble, to not cancelable, and to have the <code>transaction</code> attribute initialized to <var>t</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   830
            <li>Dispatch the newly created <code><a href=#dom-domtransactionevent>TransactionEvent</a></code> object at the node <var>h</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   831
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   832
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   833
        <p class=note>The target node is always set to a <a href=#undo-scope-host>undo scope host</a> or a node that was a <a href=#undo-scope-host>undo scope host</a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   834
        immediately before <var>t</var> was applied, unapplied, or reapplied.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   835
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   836
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   837
<script src=http://www.whatwg.org/specs/web-apps/current-work/dfn.js></script>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   838
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   839