undomanager.html
author Ryosuke Niwa <rniwa@webkit.org>
Mon, 20 Aug 2012 23:11:11 -0700
changeset 19 e0d51f4b3b45
parent 18 bd3820a27e2d
child 20 9db51ae75f47
permissions -rwxr-xr-x
Disallow nested transactions as we have previously discussed
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
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
    11
<h2 class="no-num no-toc" id="editor's-draft-&mdash;-20-august-2012">Editor's draft &mdash; 20 August 2012</h2>
0
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>
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
    19
<dd>Anne van Kesteren, Annie Sullivan, Alex Russell, Alex Vincent, Aryeh Gregor, Caio Marcelo de Oliveira Filho, Ehsan Akhgari, Eric Uhrhane,
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
    20
Frederico Caldeira Knabben, Ian Hickson, Johan "Spocke" S&ouml;rlin, Jonas Sicking, Ojan Vafai, Olli Pettay, Rakesh Chaitanya KN, Sukolsak Sakshuwong</dd>
0
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>
3
7b82412b9af9 Changed the latest version's URL to http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html.
Ryosuke Niwa <rniwa@webkit.org>
parents: 2
diff changeset
    23
<dd><a href=http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html>
7b82412b9af9 Changed the latest version's URL to http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html.
Ryosuke Niwa <rniwa@webkit.org>
parents: 2
diff changeset
    24
http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html</a></dd>
0
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>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
    27
<dd><a href=http://dvcs.w3.org/hg/undomanager/raw-file/77b8999a67d6/undomanager.html>
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
    28
http://dvcs.w3.org/hg/undomanager/raw-file/77b8999a67d6/undomanager.html</a> (20 August 2012)</dd>
16
77b8999a67d6 Update the date.
Ryosuke Niwa <rniwa@webkit.org>
parents: 15
diff changeset
    29
<dd><a href=http://dvcs.w3.org/hg/undomanager/raw-file/3fbf142909a7/undomanager.html>
77b8999a67d6 Update the date.
Ryosuke Niwa <rniwa@webkit.org>
parents: 15
diff changeset
    30
http://dvcs.w3.org/hg/undomanager/raw-file/3fbf142909a7/undomanager.html</a> (8 June 2012)</dd>
11
3fbf142909a7 Update the date.
Ryosuke Niwa <rniwa@webkit.org>
parents: 10
diff changeset
    31
<dd><a href=http://dvcs.w3.org/hg/undomanager/raw-file/17a725399127/undomanager.html>
3fbf142909a7 Update the date.
Ryosuke Niwa <rniwa@webkit.org>
parents: 10
diff changeset
    32
http://dvcs.w3.org/hg/undomanager/raw-file/17a725399127/undomanager.html</a> (29 May 2012)</dd>
2
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
    33
<dd><a href=http://rniwa.com/editing/undomanager-2011-03-27.html>
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
    34
http://rniwa.com/editing/undomanager-2011-03-27.html</a></dd>
8
17a725399127 Add the missing link to http://rniwa.com/editing/undomanager-2011-12-05.html
Ryosuke Niwa <rniwa@webkit.org>
parents: 7
diff changeset
    35
<dd><a href=http://rniwa.com/editing/undomanager-2011-12-05.html>
17a725399127 Add the missing link to http://rniwa.com/editing/undomanager-2011-12-05.html
Ryosuke Niwa <rniwa@webkit.org>
parents: 7
diff changeset
    36
http://rniwa.com/editing/undomanager-2011-12-05.html</a></dd>
0
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-12-01.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-12-01.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-11-29.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-11-29.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-10-27.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-10-27.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-10-20.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-10-20.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-10-09.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-10-09.html</a></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    47
<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
    48
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
    49
<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
    50
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
    51
<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
    52
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
    53
<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
    54
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
    55
<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
    56
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
    57
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    58
<dt>Use cases:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    59
<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
    60
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
    61
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    62
</dl>
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
</div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    65
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    66
<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
    67
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    68
<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
    69
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
    70
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
    71
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    72
<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
    73
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    74
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    75
<!--begin-toc-->
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    76
<ol class=toc>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    77
 <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
    78
 <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
    79
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    80
   <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
    81
   <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
    82
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    83
     <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
    84
     <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
    85
   <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
    86
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    87
     <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
    88
   <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
    89
   <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
    90
 <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
    91
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    92
   <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
    93
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    94
     <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
    95
     <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
    96
   <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
    97
   <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
    98
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    99
     <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
   100
   <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
   101
 <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
   102
  <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   103
   <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
   104
<!--end-toc-->
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
<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
   107
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   108
    <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
   109
    (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
   110
    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
   111
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   112
    <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
   113
    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
   114
    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
   115
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   116
    <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
   117
    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
   118
    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
   119
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   120
    <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
   121
    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
   122
    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
   123
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   124
    <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
   125
    <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
   126
    by user agents.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   127
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   128
<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
   129
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   130
<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
   131
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   132
    <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
   133
    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
   134
    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
   135
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   136
    <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
   137
    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
   138
    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
   139
    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
   140
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   141
    <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
   142
    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
   143
    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
   144
    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
   145
    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
   146
    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
   147
    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
   148
    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
   149
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   150
<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
   151
    <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
   152
    <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
   153
    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
   154
    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
   155
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   156
    <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
   157
    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
   158
    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
   159
    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
   160
    
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   161
    <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
   162
    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>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   163
    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
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   164
    <a href=#disconnect-undomanager>disconnect</a> the corresponding <code><a href=#undomanager>UndoManager</a></code> for the scope.
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   165
    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
   166
    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
   167
    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
   168
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   169
<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
   170
    <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
   171
    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.
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   172
    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
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   173
    except on <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editing-host>editing hosts</a>.</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   174
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   175
    <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 set to <code>true</code> on an element,
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   176
    the user agent must <a href=#disconnect-undomanager>disconnect</a> the <code><a href=#undomanager>UndoManager</a></code>s
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   177
    of all descendent <a href=#undo-scope>undo scope hosts</a> of the element that have become
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   178
    <a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> due to the change
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   179
    as if the <code><a href=#attr-undoscope>undoscope</a></code> content attribute was removed from those nodes.</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   180
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   181
    <p>Conversely, when the <code><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#contenteditable>contenteditable</a></code>
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   182
    content attribute is removed from an element or set to <code>false</code>, the user agent must behave as if
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   183
    <code><a href=#attr-undoscope>undoscope</a></code> content attribute is removed and added back to all descendent nodes of the element that have become
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
   184
    non-<a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#editable>editable</a> due to the change.</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   185
15
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   186
    <div class=example>
18
bd3820a27e2d Update the description in the example for section 2.2.1
Ryosuke Niwa <rniwa@webkit.org>
parents: 17
diff changeset
   187
        <p>In the following example, the first child element of the container becomes editable when the container's
bd3820a27e2d Update the description in the example for section 2.2.1
Ryosuke Niwa <rniwa@webkit.org>
parents: 17
diff changeset
   188
        <code>contentEditable</code> IDL is set to true, resulting in the first child element's <code><a href=#undomanager>UndoManager</a></code>
bd3820a27e2d Update the description in the example for section 2.2.1
Ryosuke Niwa <rniwa@webkit.org>
parents: 17
diff changeset
   189
        to be <a href=#disconnect-undomanager>disconnected</a>.
bd3820a27e2d Update the description in the example for section 2.2.1
Ryosuke Niwa <rniwa@webkit.org>
parents: 17
diff changeset
   190
        The second child element's <code><a href=#undomanager>UndoManager</a></code> isn't <a href=#disconnect-undomanager>disconnected</a>
bd3820a27e2d Update the description in the example for section 2.2.1
Ryosuke Niwa <rniwa@webkit.org>
parents: 17
diff changeset
   191
        because the second child did not become editable as a result of the assignment.</p>
15
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   192
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   193
        <pre>&lt;div id="container"&gt;
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   194
    &lt;div undoscope&gt;This will be editable&lt;/div&gt;
17
f2ae34aef445 Fix typos. UndoManager.transact() should take DOMTransaction and the example in section 2.2.1 should have =false on contenteditable attribute, not undoscope attribute
Ryosuke Niwa <rniwa@webkit.org>
parents: 16
diff changeset
   195
    &lt;div contenteditable="false" undoscope&gt;This will remain not editable.&lt;/div&gt;
15
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   196
&lt;/div&gt;
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   197
&lt;script&gt;
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   198
var container = document.getElementById('container');
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   199
var children = container.getElementsByTagName('*');
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   200
children[0].undoManager.transact({executeAutomatic: function () {}});
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   201
children[1].undoManager.transact({executeAutomatic: function () {}});
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   202
container.contentEditable = true;
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   203
alert(children[0].undoManager); // Alerts null
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   204
alert(children[1].undoManager.length); // Alerts 1
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   205
&lt;/script&gt;
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   206
</pre>
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   207
    </div>
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   208
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   209
<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
   210
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   211
    <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
   212
    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
   213
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   214
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   215
        <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
   216
        <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
   217
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   218
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   219
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   220
        <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
   221
        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
   222
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   223
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   224
<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
   225
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   226
    <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
   227
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   228
    <pre class=idl>interface <dfn id=undomanager>UndoManager</dfn> {
17
f2ae34aef445 Fix typos. UndoManager.transact() should take DOMTransaction and the example in section 2.2.1 should have =false on contenteditable attribute, not undoscope attribute
Ryosuke Niwa <rniwa@webkit.org>
parents: 16
diff changeset
   229
    void <a href=#dom-undomanager-transact title=dom-UndoManager-transact>transact</a>(in DOMTransaction transaction, in boolean merge);
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   230
    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
   231
    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
   232
    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
   233
    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
   234
    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
   235
    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
   236
    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
   237
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   238
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   239
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   240
        <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
   241
        <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
   242
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   243
        <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
   244
        <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
   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-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
   247
            <var title="">merge</var>)</code></dt>
2
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
   248
        <dd><p>Clears entries above the current undo position, <a href=#dom-transaction-apply>applies</a> <var title="">transaction</var>,
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
   249
            and adds it to the beginning of the first entry in <a href=#undo-transaction-history>undo transaction history</a><a>,
10
53943e40f7a0 Fix another typo. undoManager.item() should return the entry when 0 <= n < length, not when n is length.
Ryosuke Niwa <rniwa@webkit.org>
parents: 8
diff changeset
   250
            or of a new </a><a href=#undo-transaction-history>undo transaction history</a><a> if <var title="">merge</var> is set to false.</a></dd><a>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   251
2
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
   252
        </a><dt><a><var title="">undoManager</var> . <code title=dom-UndoManager-undo></code></a><code title=dom-UndoManager-undo><a href=#dom-undomanager-undo>undo</a>()</code></dt>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   253
        <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
   254
            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
   255
            <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
   256
            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
   257
            <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
   258
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   259
        <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
   260
        <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
   261
            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
   262
            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
   263
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   264
        <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
   265
        <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
   266
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   267
        </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
   268
        <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
   269
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   270
        </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
   271
        <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
   272
        <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
   273
            <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
   274
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   275
        </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
   276
        <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
   277
            <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
   278
            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
   279
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   280
        <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
   281
        <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
   282
            <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
   283
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   284
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   285
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   286
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   287
        <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
   288
        <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
   289
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   290
        <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
   291
        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
   292
        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
   293
        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
   294
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   295
        <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
   296
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   297
            <li>If any <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>,
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   298
                <a href=#dom-transaction-unapply>unapplying</a>, or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   299
                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then throw
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   300
                <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
   301
            <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
   302
            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
   303
            <li><a href=#dom-transaction-apply>Apply</a> the <var title="">transaction</var>.</li>
10
53943e40f7a0 Fix another typo. undoManager.item() should return the entry when 0 <= n < length, not when n is length.
Ryosuke Niwa <rniwa@webkit.org>
parents: 8
diff changeset
   304
            <li>If <var title="">merge</var> is set to false, add an empty entry to the beginning of the <a href=#undo-transaction-history>undo transaction history</a>.</li>
4
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   305
            <li>Add the applied transaction to the beginning of the first entry in the <a href=#undo-transaction-history>undo transaction history</a>.</li>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   306
            <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>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   307
            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   308
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   309
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   310
        <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
   311
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   312
            <li>If any <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>,
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   313
                <a href=#dom-transaction-unapply>unapplying</a>, or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   314
                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then throw
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   315
                <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>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   316
            <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>
4
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   317
            <li>Otherwise, <a href=#dom-transaction-unapply>unapply</a> <a href=#dom-transaction>DOM transactions</a> in the entry immediately after
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   318
            the <a href=#undo-position>undo position</a> in the order and increment <a href=#dom-undomanager-position>position</a> by 1.</li>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   319
            <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>
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   320
            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   321
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   322
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   323
        <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
   324
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   325
            <li>If any <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>,
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   326
                <a href=#dom-transaction-unapply>unapplying</a>, or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   327
                or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, then throw
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   328
                <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>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   329
            <li>If <code title=dom-UndoManager-position><a href=#dom-undomanager-position>position</a></code> &le; 0, stop.</li>
4
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   330
            <li>Otherwise, <a href=#dom-transaction-reapply>reapply</a> <a href=#dom-transaction>DOM transactions</a> in the entry immediately before
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   331
            the <a href=#undo-position>undo position</a> in the reverse order and decrement <a href=#dom-undomanager-position>position</a> by 1.</li>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   332
            <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>
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   333
            of this <code><a href=#undomanager>UndoManager</a></code> if the <code><a href=#undomanager>UndoManager</a></code> had not already been <a href=#disconnect-undomanager>disconnected</a>.</li>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   334
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   335
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   336
        <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
   337
        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
10
53943e40f7a0 Fix another typo. undoManager.item() should return the entry when 0 <= n < length, not when n is length.
Ryosuke Niwa <rniwa@webkit.org>
parents: 8
diff changeset
   338
        0 &le; <var>n</var> &lt; <code title=dom-UndoManager-length><a href=#dom-undomanager-length>length</a></code>, or null otherwise.</p>
0
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
        <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
2
2b10939e6831 Remove references to transaction groups per Alex & Olli's comments.
Ryosuke Niwa <rniwa@webkit.org>
parents: 1
diff changeset
   341
        whether new DOM transaction and the last DOM transaction should being to the same entry or not.</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   342
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   343
        <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
   344
        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
   345
        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
   346
        <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
   347
        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
   348
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   349
        <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
   350
        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
   351
        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
   352
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   353
        <p>The <dfn id=dom-undomanager-clearundo title=dom-UndoManager-clearUndo><code>clearUndo()</code></dfn>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   354
        method must 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>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   355
        if any <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>,
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   356
        <a href=#dom-transaction-unapply>unapplying</a>, or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   357
        or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, 
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   358
        otherwise it must remove all entries in the <a href=#undo-transaction-history>undo transaction history</a> before the <a href=#undo-position>undo position</a>,
4
df99f18b2937 Revise the way an entry (a.k.a. "transaction group") in the undo transaction history is added.
Ryosuke Niwa <rniwa@webkit.org>
parents: 3
diff changeset
   359
        and move the <a href=#undo-position>undo position</a> to the top (set <a href=#dom-undomanager-position>position</a> to zero).</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   360
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   361
        <p>The <dfn id=dom-undomanager-clearredo title=dom-UndoManager-clearRedo><code>clearRedo()</code></dfn>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   362
        method must 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>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   363
        if any <code><a href=#undomanager>UndoManager</a></code> is already in the process of <a href=#dom-transaction-apply>applying</a>,
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   364
        <a href=#dom-transaction-unapply>unapplying</a>, or <a href=#dom-transaction-reapply>reapplying</a> a <a href=#dom-transaction>DOM transaction</a>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   365
        or the <code><a href=#undomanager>UndoManager</a></code> had been <a href=#disconnect-undomanager>disconnected</a>, 
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   366
        otherwise it 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>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   367
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   368
        <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
   369
        If no node has focus, then it's assumed to be of the document.</p>
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   370
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   371
        <p>To <dfn id=disconnect-undomanager>disconnect an UndoManager</dfn> means to deprive the ability to add or remove entries in
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   372
        the <a href=#undo-transaction-history>undo transaction history</a> of the <code><a href=#undomanager>UndoManager</a></code>.
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   373
        Once the <code><a href=#undomanager>UndoManager</a></code> is disconnected, <code><a href=#dom-undomanager-transact>transact</a>()</code>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   374
        <code><a href=#dom-undomanager-undo>undo</a>()</code>, <code><a href=#dom-undomanager-redo>redo</a>()</code>, <code><a href=#dom-undomanager-clearundo>clearUndo</a>()</code>,
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   375
        and <code><a href=#dom-undomanager-clearundo>clearRedo</a>()</code> will all throw
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   376
        <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>.<p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   377
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   378
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   379
    <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
   380
    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
   381
    <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
   382
    </p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   383
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   384
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   385
        <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
   386
        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
   387
        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
   388
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   389
        <pre>document.undoManager.transact(...);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   390
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   391
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   392
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
   393
document.undoManager.item(0).pop();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   394
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
   395
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
   396
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   397
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   398
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   399
    <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
   400
    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
   401
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   402
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   403
        <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
   404
        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
   405
        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
   406
        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
   407
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   408
        <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
   409
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   410
    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
   411
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   412
    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
   413
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   414
    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
   415
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   416
    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
   417
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   418
        <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
   419
        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
   420
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   421
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   422
    <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
   423
    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
   424
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   425
<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
   426
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   427
    <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
   428
    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
   429
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   430
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   431
        <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
   432
        <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
   433
        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
   434
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   435
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   436
    <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
   437
    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
   438
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   439
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   440
        <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
   441
        <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
   442
    </dl>
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
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   445
        <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
   446
        <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
   447
        <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
   448
        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
   449
        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
   450
    </div>
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
<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
   453
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   454
    <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
   455
    <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
   456
    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
   457
    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
   458
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   459
<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
   460
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   461
    <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
   462
    <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
   463
    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
   464
    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
   465
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   466
<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
   467
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   468
    <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
   469
    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
   470
    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
   471
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   472
    <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
   473
    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
   474
    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
   475
    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
   476
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   477
    <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
   478
    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
   479
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   480
<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
   481
    <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
   482
    <ul>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   483
        <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
   484
        <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
   485
        <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
   486
        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
   487
        <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
   488
        <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
   489
        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
   490
        <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
   491
    </ul>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   492
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   493
    <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
   494
    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
   495
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   496
<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
   497
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   498
    <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
   499
    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
   500
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   501
    <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
   502
    run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   503
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   504
        <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
   505
        <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
   506
        <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
   507
        <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
   508
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   509
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   510
    <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
   511
    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
   512
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   513
        <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
   514
        <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
   515
        <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
   516
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   517
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   518
    <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
   519
    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
   520
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   521
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   522
        <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
   523
        <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
   524
    </ol>
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
    <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
   527
    <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
   528
    <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
   529
    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
   530
    <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
   531
    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
   532
    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
   533
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   534
    <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
   535
    <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
   536
    <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
   537
    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
   538
    run these steps.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   539
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   540
        <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
   541
        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
   542
        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
   543
        <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
   544
        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
   545
        <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
   546
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   547
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   548
    <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
   549
    <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
   550
    <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
   551
    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
   552
    <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
   553
    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
   554
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   555
        <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
   556
        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
   557
        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
   558
        <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
   559
        <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
   560
        <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
   561
        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
   562
        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
   563
        to <var>oldPrefix</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   564
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   565
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   566
    <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
   567
    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
   568
    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
   569
    <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
   570
    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
   571
    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
   572
    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
   573
    before the setting respectively.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   574
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   575
<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
   576
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   577
    <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
   578
    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
   579
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   580
    <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
   581
    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
   582
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   583
        <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
   584
        <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
   585
        <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
   586
        <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
   587
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   588
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   589
    <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
   590
    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
   591
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   592
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   593
        <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
   594
        <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
   595
        <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
   596
        <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
   597
        <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
   598
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   599
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   600
    <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
   601
    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
   602
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   603
        <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
   604
        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
   605
        <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
   606
        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
   607
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   608
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   609
    <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
   610
    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
   611
    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
   612
    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
   613
    <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
   614
    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
   615
    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
   616
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   617
    <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
   618
    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
   619
    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
   620
    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
   621
    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
   622
    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
   623
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   624
        <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
   625
        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
   626
        <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
   627
        <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
   628
        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
   629
        <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
   630
        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
   631
        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
   632
        to <var>prefix</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   633
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   634
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   635
    <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
   636
    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
   637
    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
   638
    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
   639
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   640
        <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
   641
        <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
   642
        <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
   643
        <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
   644
        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
   645
        <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
   646
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   647
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   648
    <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
   649
    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
   650
    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
   651
    <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
   652
    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
   653
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   654
<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
   655
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   656
    <pre class=idl>[NoInterfaceObject]
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   657
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
   658
    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
   659
    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
   660
    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
   661
    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
   662
    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
   663
};</pre>
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
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   666
        <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
   667
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   668
        <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
   669
        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
   670
        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
   671
        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
   672
        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
   673
        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
   674
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   675
        <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
   676
        <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
   677
        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
   678
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   679
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   680
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   681
        <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
   682
        <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
   683
        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
   684
        <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
   685
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   686
        <pre>document.undoManager.transact({ execute: function () {
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   687
    this.execute = function () { alert('foo'); }
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   688
    alert('bar');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   689
}, 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
   690
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
   691
docuemnt.undoManager.undo(); // alerts 'foobar'
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   692
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   693
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   694
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   695
        <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
   696
        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
   697
        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
   698
        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
   699
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   700
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   701
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   702
        <p>All <a href=#dom-changes>DOM changes</a> made in <code><a href=#dom-domtransaction-execute>execute</a></code> or
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   703
        <code><a href=#dom-domtransaction-executeautomatic>executeAutomatic</a></code> take effect immediately.
7
44f10659a665 Introduce the concept to disconnect an undo manager to replace the concept of destroying an undo manager per Olli's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 6
diff changeset
   704
        Sometimes, this <a href=#disconnect-undomanager>disconnects</a> the undoManager to which it belongs.</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   705
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   706
        <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
   707
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   708
document.body.appendChild(scope);
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   709
scope.undoManager.transact({executeAutomatic: function () {
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   710
    scope.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   711
    alert(scope.textContent); // "foo"
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   712
    scope.undoScope = false;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   713
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   714
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
   715
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   716
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   717
<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
   718
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   719
    <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
   720
    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
   721
    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
   722
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   723
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   724
        <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
   725
        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
   726
        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
   727
        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
   728
    </a></div><a>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   729
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   730
    </a><div class=example><a>
6
ac6ab5cf2890 Add the forgotten undomanager.html change
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   731
        </a><p><a>All </a><a href=#dom-changes>DOM changes</a> made outside of the <a href=#undo-scope>undo scope</a> take effect immediately
ac6ab5cf2890 Add the forgotten undomanager.html change
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   732
        but are ignored for the purpose of undo and redo.
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   733
        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
   734
        remains in the body.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   735
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   736
        <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
   737
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   738
document.body.appendChild(scope);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   739
scope.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   740
    document.body.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   741
    scope.appendChild("bar");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   742
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   743
scope.undoManager.undo();
6
ac6ab5cf2890 Add the forgotten undomanager.html change
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   744
alert(document.body.textContent); // Alerts "foo".
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   745
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   746
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   747
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   748
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   749
        <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
   750
        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
   751
        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
   752
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   753
        <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
   754
        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
   755
        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
   756
        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
   757
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   758
        <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
   759
        <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
   760
        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
   761
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   762
        <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
   763
        <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
   764
        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
   765
        <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
   766
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   767
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   768
    <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
   769
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   770
<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
   771
    <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
   772
    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
   773
    <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
   774
    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
   775
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   776
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   777
        <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
   778
        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
   779
        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
   780
        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
   781
        <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
   782
b.appendChild(document.createTextNode("hello"));
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   783
document.body.appendChild(b);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   784
document.undoManager.transact({ executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   785
    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
   786
b.appendChild(document.body.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   787
document.undoManager.undo(); // No-op.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   788
</pre>
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
        <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
   791
        <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
   792
<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
   793
document.body.appendChild(b.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   794
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
   795
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   796
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   797
<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
   798
    <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
   799
    <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
   800
    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
   801
    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
   802
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   803
    <div class=impl>
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   804
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-apply>applied</a>, the user agent must call
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   805
        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
   806
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   807
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-unapply>unapplied</a>, the user agent must call
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   808
        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
   809
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   810
        <p>When a <a href=#manual-dom-transaction>manual DOM transaction</a> is <a href=#dom-transaction-reapply>reapplied</a>, the user agent must call
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   811
        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
   812
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   813
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   814
    <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
   815
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   816
    <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
   817
    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
   818
    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
   819
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   820
    <div class=example>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   821
        <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
   822
        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
   823
        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
   824
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   825
        <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
   826
    document.undoManager.transact({ execute: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   827
            // Draw a line on canvas
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   828
        }, undo: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   829
            // Undraw a line
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   830
        }, redo: function () { this.execute(); },
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   831
        'Draw a line'
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
}
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   834
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   835
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   836
        <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
   837
        <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
   838
        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
   839
    
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   840
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   841
<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
   842
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   843
    <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
   844
    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
   845
    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
   846
    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
   847
    <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
   848
    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
   849
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   850
<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
   851
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   852
    <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
   853
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
   854
    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
   855
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   856
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   857
    <dl class=domintro>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   858
        <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
   859
        <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
   860
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   861
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   862
    <div class=impl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   863
        <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
   864
        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
   865
        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
   866
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   867
        <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
   868
        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
   869
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   870
            <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
   871
            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
   872
            <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
   873
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   874
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   875
        <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
   876
        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
   877
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   878
            <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
   879
            "<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
   880
            <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
   881
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   882
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   883
        <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
   884
        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
   885
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   886
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   887
<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
   888
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   889