source.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>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     2
<html>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     3
<head>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     4
<meta http-equiv="content-type" content="text/html; charset=utf-8">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     5
<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
     6
<link rel="stylesheet" type="text/css" href="http://www.whatwg.org/style/specification">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     7
</head>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     8
<body class="draft">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
     9
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    10
<div class="head">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    11
<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
    12
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
    13
<h2 class="no-num no-toc">Editor's draft — 20 August 2012</h2>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    14
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    15
<dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    16
<dt>Editor:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    17
<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
    18
</dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    19
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    20
<dt>Acknowledgements</dt>
13
884298731636 Add Caio Marcelo de Oliveira Filho to the list of acknowledgements
Ryosuke Niwa <rniwa@webkit.org>
parents: 12
diff changeset
    21
<dd>Anne van Kesteren, Annie Sullivan, Alex Russell, Alex Vincent, Aryeh Gregor, Caio Marcelo de Oliveira Filho, Ehsan Akhgari, Eric Uhrhane,
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 13
diff changeset
    22
Frederico Caldeira Knabben, Ian Hickson, Johan "Spocke" Sö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
    23
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    24
<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
    25
<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
    26
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
    27
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    28
<dt>Previous versions:</dt>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
    29
<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
    30
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
    31
<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
    32
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
    33
<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
    34
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
    35
<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
    36
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
    37
<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
    38
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
    39
<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
    40
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
    41
<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
    42
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
    43
<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
    44
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
    45
<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
    46
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
    47
<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
    48
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
    49
<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
    50
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
    51
<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
    52
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
    53
<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
    54
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
    55
<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
    56
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
    57
<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
    58
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
    59
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    60
<dt>Use cases:</dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    61
<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
    62
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
    63
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    64
</dl>
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
</div>
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
<h2 class="no-num no-toc">Status</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    69
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    70
<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
    71
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
    72
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
    73
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    74
<h2 class="no-num no-toc">Table of Contents</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    75
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    76
<!--toc-->
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    77
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    78
<h2>Introduction</h2>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    79
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    80
    <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
    81
    (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
    82
    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
    83
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    84
    <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
    85
    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
    86
    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
    87
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    88
    <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
    89
    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
    90
    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
    91
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    92
    <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
    93
    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
    94
    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
    95
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    96
    <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
    97
    <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
    98
    by user agents.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
    99
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   100
<h2>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
   101
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   102
<h3>Definitions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   103
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   104
    <p>The user agent must associate an <dfn>undo transaction history</dfn>,
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   105
    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
   106
    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
   107
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   108
    <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
   109
    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
   110
    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
   111
    and the previous entry represents what needs to happen when <a href="#redo">redo</a></code> is done.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   112
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   113
    <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
   114
    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
   115
    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
   116
    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
   117
    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
   118
    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
   119
    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
   120
    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
   121
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   122
<h3>Scoping Undo Transaction History</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   123
    <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
   124
    <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
   125
    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
   126
    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
   127
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   128
    <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
   129
    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
   130
    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
   131
    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
   132
    
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   133
    <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
   134
    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: 5
diff changeset
   135
    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: 5
diff changeset
   136
    <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
   137
    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
   138
    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
   139
    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
   140
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   141
<h4>Undo scope and contenteditable</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   142
    <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
   143
    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: 13
diff changeset
   144
    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: 13
diff changeset
   145
    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
   146
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 13
diff changeset
   147
    <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: 13
diff changeset
   148
    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: 13
diff changeset
   149
    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: 13
diff changeset
   150
    <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: 13
diff changeset
   151
    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
   152
14
9cae0e0c55cb Revise section 2.1.1 per Rakesh Chaitanya KN's post
Ryosuke Niwa <rniwa@webkit.org>
parents: 13
diff changeset
   153
    <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: 13
diff changeset
   154
    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: 13
diff changeset
   155
    <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: 13
diff changeset
   156
    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
   157
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
   158
    <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
   159
        <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
   160
        <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
   161
        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
   162
        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
   163
        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
   164
f9b794dcc21f Add an example to 2.2.1 suggested by Caio Marcelo de Oliveira Filho
Ryosuke Niwa <rniwa@webkit.org>
parents: 14
diff changeset
   165
        <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
   166
&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
   167
    &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
   168
    &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
   169
&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
   170
&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
   171
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
   172
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
   173
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
   174
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
   175
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
   176
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
   177
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
   178
&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
   179
</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
   180
    </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
   181
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   182
<h4>undoScope IDL attribute</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   183
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   184
    <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
   185
    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
   186
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   187
    <dl class="domintro">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   188
        <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
   189
        <dd><p>Returns <code>true</code> if the element is an undo scope host and <code>false</code> otherwise.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   190
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   191
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   192
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   193
        <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
   194
        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
   195
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   196
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   197
<h3>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
   198
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   199
    <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
   200
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   201
    <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
   202
    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
   203
    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
   204
    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
   205
    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
   206
    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
   207
    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
   208
    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
   209
    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
   210
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   211
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   212
    <dl class="domintro">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   213
        <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
   214
        <dd><p>Returns the <code><a href="#undomanager">UndoManager</a></code> object.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   215
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   216
        <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
   217
        <dd><p>Returns the <code><a href="#undomanager">UndoManager</a></code> object.</p></dd>
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
        <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
   220
            <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
   221
        <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
   222
            and adds it to the beginning of the first entry in <a href="#undo-transaction-history">undo transaction history<a>,
9
64708ca6aeca Fix a typo in the definition of undoManager.transact. We insert a new entry in the undo transaction history only if merge is set to false, not true.
Ryosuke Niwa <rniwa@webkit.org>
parents: 8
diff changeset
   223
            or of a new <a href="#undo-transaction-history">undo transaction history<a> if <var title="">merge</var> is set to false.</p></dd>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   224
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   225
        <dt><var title="">undoManager</var> . <code title="dom-UndoManager-undo"><a href="#dom-undomanager-undo">undo</a>()</code></dt>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   226
        <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
   227
            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
   228
            <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
   229
            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
   230
            <code title="dom-UndoManager-length"><a href="#dom-undomanager-length">length</a></code>.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   231
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   232
        <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
   233
        <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
   234
            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
   235
            if <code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> &gt; 0</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   236
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   237
        <dt><var title="">undoManager</var> . <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
   238
        <dd><p>Returns the number of the current entry in the <a href="#undo-transaction-history">undo transaction history<a>. (Entries at and past this point are redo entries.)</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   239
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   240
        <dt><var title="">undoManager</var> . <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
   241
        <dd><p>Returns the number of entries in the <a href="#undo-transaction-history">undo transaction history<a>.</p></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="">data</var> = <var title="">undoManager</var> . <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
   244
        <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
   245
        <dd><p>Returns the entry with index <var title="">index</var> in 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
   246
            <p>Returns null if <var title="">index</var> is out of range.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   247
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   248
        <dt><var title="">undoManager</var> . <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
   249
        <dd><p>Removes entries in the <a href="#undo-transaction-history">undo transaction history<a> before
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   250
            <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
   251
            resets <code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> to 0.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   252
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   253
        <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
   254
        <dd><p>Removes entries in the <a href="#undo-transaction-history">undo transaction history<a> after
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>.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   256
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   257
    </dl>
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
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   260
        <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
   261
        <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
   262
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   263
        <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
   264
        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
   265
        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
   266
        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
   267
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   268
        <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
   269
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   270
            <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: 5
diff changeset
   271
                <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: 5
diff changeset
   272
                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
   273
                <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
   274
            <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
   275
            or <a href="#dom-transaction-reapply">reapplying</a> the <a href="#dom-transaction">transactions</a> in the entires.</code></li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   276
            <li><a href="#dom-transaction-apply">Apply</a> the <var title="">transaction</var>.</li>
9
64708ca6aeca Fix a typo in the definition of undoManager.transact. We insert a new entry in the undo transaction history only if merge is set to false, not true.
Ryosuke Niwa <rniwa@webkit.org>
parents: 8
diff changeset
   277
            <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
   278
            <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
   279
            <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: 5
diff changeset
   280
            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
   281
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   282
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   283
        <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
   284
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   285
            <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: 5
diff changeset
   286
                <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: 5
diff changeset
   287
                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: 5
diff changeset
   288
                <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
   289
            <li>If <code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> &#8804; <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
   290
            <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
   291
            the <a href="#undo-position">undo position</a> in the order and increment <a href="#dom-undomanager-position">position</a></code> 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: 5
diff changeset
   292
            <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: 5
diff changeset
   293
            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
   294
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   295
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   296
        <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
   297
        <ol>
19
e0d51f4b3b45 Disallow nested transactions as we have previously discussed
Ryosuke Niwa <rniwa@webkit.org>
parents: 18
diff changeset
   298
            <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: 5
diff changeset
   299
                <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: 5
diff changeset
   300
                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: 5
diff changeset
   301
                <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
   302
            <li>If <code title="dom-UndoManager-position"><a href="#dom-undomanager-position">position</a></code> &#8804; 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
   303
            <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
   304
            the <a href="#undo-position">undo position</a> in the reverse order and decrement <a href="#dom-undomanager-position">position</a></code> 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: 5
diff changeset
   305
            <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: 5
diff changeset
   306
            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
   307
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   308
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   309
        <p>The <dfn id="dom-undomanager-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
   310
        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: 9
diff changeset
   311
        0 &#8804; <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
   312
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   313
        <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
   314
        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
   315
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   316
        <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
   317
        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
   318
        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
   319
        <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
   320
        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
   321
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   322
        <p>The <dfn id="dom-undomanager-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
   323
        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
   324
        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
   325
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   326
        <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: 5
diff changeset
   327
        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
   328
        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: 5
diff changeset
   329
        <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: 5
diff changeset
   330
        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: 5
diff changeset
   331
        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
   332
        and move the <a href="#undo-position">undo position</a> to the top (set <a href="#dom-undomanager-position">position</a></code> to zero).</p>
0
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   333
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   334
        <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: 5
diff changeset
   335
        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
   336
        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: 5
diff changeset
   337
        <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: 5
diff changeset
   338
        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: 5
diff changeset
   339
        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
   340
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   341
        <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
   342
        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: 5
diff changeset
   343
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: 5
diff changeset
   344
        <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: 5
diff changeset
   345
        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: 5
diff changeset
   346
        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: 5
diff changeset
   347
        <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: 5
diff changeset
   348
        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: 5
diff changeset
   349
        <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
   350
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   351
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   352
    <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
   353
    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
   354
    <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
   355
    </p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   356
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   357
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   358
        <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
   359
        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
   360
        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
   361
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   362
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   363
document.undoManager.transact(...);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   364
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   365
document.undoManager.transact(..., true);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   366
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
   367
document.undoManager.item(0).pop();
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   368
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
   369
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
   370
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   371
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   372
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   373
    <p class="note">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
   374
    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
   375
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   376
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   377
        <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
   378
        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
   379
        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
   380
        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
   381
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   382
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   383
// 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
   384
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   385
    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
   386
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   387
    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
   388
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   389
    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
   390
myEditor.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   391
    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
   392
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   393
        <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
   394
        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
   395
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   396
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   397
    <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
   398
    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
   399
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   400
<h4>undoManager IDL attribute</h4>
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
    <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
   403
    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
   404
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   405
    <dl class="domintro">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   406
        <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
   407
        <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
   408
        if the element is an <a href="#undo-scope-host">undo scope host</a>, or <code>null</code> otherwise.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   409
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   410
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   411
    <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
   412
    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
   413
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   414
    <dl class="domintro">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   415
        <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
   416
        <dd><p>Returns the <code><a href="#undomanager">UndoManager</a></code> object associated with the document.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   417
    </dl>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   418
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   419
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   420
        <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
   421
        <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
   422
        <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
   423
        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
   424
        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
   425
    </div>
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
<h3>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
   428
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   429
    <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
   430
    <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
   431
    the undo command, the user agent must perform an <dfn>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
   432
    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
   433
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   434
<h3>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
   435
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   436
    <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
   437
    <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
   438
    the redo command, the user agent must perform an <dfn>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
   439
    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
   440
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   441
<h2>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
   442
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   443
    <p>A <dfn>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
   444
    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
   445
    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
   446
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   447
    <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
   448
    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
   449
    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
   450
    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
   451
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   452
    <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
   453
    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
   454
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   455
<h3>Mutations of DOM</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   456
    <p><dfn>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 &#8804; i &#8804; 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
   457
    <ul>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   458
        <li><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-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
   459
        <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
   460
        <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
   461
        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
   462
        <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
   463
        <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
   464
        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
   465
        <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
   466
    </ul>
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>The <dfn>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
   469
    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
   470
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   471
<h4>Reverting DOM changes</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   472
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   473
    <p>To <dfn>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
   474
    revert each s<sub>i</sub> with 1 &#8804; i &#8804; 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
   475
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   476
    <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
   477
    run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   478
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   479
        <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
   480
        <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
   481
        <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
   482
        <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
   483
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   484
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   485
    <p>To revert <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-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
   486
    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
   487
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   488
        <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
   489
        <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
   490
        <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
   491
    </ol>
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>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
   494
    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
   495
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   496
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   497
        <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
   498
        <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
   499
    </ol>
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-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
   502
    <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
   503
    <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
   504
    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
   505
    <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
   506
    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
   507
    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
   508
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   509
    <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
   510
    <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-namespace">namespace</a> is <var>namespace</var> and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   511
    <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-attribute-local-name">local name</a> is <var>localName</var> to a node
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   512
    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
   513
    run these steps.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   514
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   515
        <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
   516
        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
   517
        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
   518
        <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
   519
        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
   520
        <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
   521
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   522
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   523
    <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
   524
    <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
   525
    <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
   526
    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
   527
    <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
   528
    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
   529
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   530
        <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
   531
        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
   532
        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
   533
        <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
   534
        <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
   535
        <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
   536
        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
   537
        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
   538
        to <var>oldPrefix</var>.</li>
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
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   541
    <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
   542
    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
   543
    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
   544
    <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
   545
    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
   546
    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
   547
    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
   548
    before the setting respectively.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   549
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   550
<h4>Reapplying DOM changes</h4>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   551
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   552
    <p>To <dfn>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
   553
    reapply each s<sub>i</sub> with 1 &#8804; i &#8804; 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
   554
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   555
    <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
   556
    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
   557
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   558
        <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
   559
        <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
   560
        <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
   561
        <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
   562
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   563
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   564
    <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
   565
    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
   566
    and run these steps:</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   567
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   568
        <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
   569
        <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
   570
        <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
   571
        <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
   572
        <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
   573
    </ol>
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
    <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
   576
    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
   577
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   578
        <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
   579
        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
   580
        <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
   581
        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
   582
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   583
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   584
    <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
   585
    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
   586
    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
   587
    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
   588
    <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
   589
    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
   590
    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
   591
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   592
    <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
   593
    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
   594
    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
   595
    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
   596
    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
   597
    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
   598
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   599
        <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
   600
        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
   601
        <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
   602
        <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
   603
        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
   604
        <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
   605
        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
   606
        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
   607
        to <var>prefix</var>.</li>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   608
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   609
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   610
    <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
   611
    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
   612
    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
   613
    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
   614
    <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   615
        <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
   616
        <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
   617
        <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
   618
        <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
   619
        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
   620
        <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
   621
    </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   622
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   623
    <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
   624
    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
   625
    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
   626
    <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
   627
    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
   628
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   629
<h3>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
   630
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   631
    <pre class="idl">[NoInterfaceObject]
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   632
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
   633
    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
   634
    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
   635
    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
   636
    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
   637
    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
   638
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   639
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   640
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   641
        <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
   642
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   643
        <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
   644
        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
   645
        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
   646
        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
   647
        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
   648
        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
   649
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   650
        <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
   651
        <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
   652
        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
   653
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   654
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   655
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   656
        <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
   657
        <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
   658
        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
   659
        <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
   660
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   661
        <pre>
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   662
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
   663
    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
   664
    alert('bar');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   665
}, 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
   666
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
   667
docuemnt.undoManager.undo(); // alerts 'foobar'
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   668
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   669
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   670
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   671
        <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
   672
        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
   673
        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
   674
        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
   675
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   676
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   677
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   678
        <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
   679
        <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: 5
diff changeset
   680
        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
   681
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   682
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   683
var scope = document.createElement('div');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   684
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   685
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
   686
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
   687
    scope.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   688
    alert(scope.textContent); // "foo"
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   689
    scope.undoScope = false;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   690
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   691
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
   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
<h3>Automatic DOM transactions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   695
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   696
    <p>An <dfn>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
   697
    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
   698
    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
   699
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   700
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   701
        <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
   702
        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
   703
        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></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   704
        must be tracked by the user agent.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   705
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   706
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   707
    <div class="example">
5
9590e5006d15 Fix a bug in the example for explianing automatic DOM transactions ignores DOM changes made
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   708
        <p>All <a href="#dom-changes">DOM changes</a> made outside of the <a href="#undo-scope">undo scope</a> take effect immediately
9590e5006d15 Fix a bug in the example for explianing automatic DOM transactions ignores DOM changes made
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   709
        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
   710
        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
   711
        remains in the body.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   712
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   713
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   714
var scope = document.createElement('div');
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   715
scope.undoScope = true;
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   716
document.body.appendChild(scope);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   717
scope.undoManager.transact({executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   718
    document.body.appendChild("foo");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   719
    scope.appendChild("bar");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   720
}});
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   721
scope.undoManager.undo();
5
9590e5006d15 Fix a bug in the example for explianing automatic DOM transactions ignores DOM changes made
Ryosuke Niwa <rniwa@webkit.org>
parents: 4
diff changeset
   722
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
   723
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   724
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   725
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   726
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   727
        <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
   728
        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></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   729
        while <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
   730
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   731
        <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
   732
        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></code>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   733
        while <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
   734
        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
   735
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   736
        <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
   737
        <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
   738
        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
   739
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   740
        <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
   741
        <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
   742
        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
   743
        <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
   744
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   745
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   746
    <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
   747
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   748
<h4>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
   749
    <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
   750
    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
   751
    <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
   752
    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
   753
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   754
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   755
        <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
   756
        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
   757
        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
   758
        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
   759
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   760
var b = document.createTextNode("b");
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   761
b.appendChild(document.createTextNode("hello"));
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   762
document.body.appendChild(b);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   763
document.undoManager.transact({ executeAutomatic: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   764
    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
   765
b.appendChild(document.body.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   766
document.undoManager.undo(); // No-op.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   767
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   768
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   769
        <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
   770
        <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
   771
<pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   772
document.undoManager.redo(); // No-op.
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   773
document.body.appendChild(b.lastChild);
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   774
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
   775
</pre></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   776
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   777
<h3>Manual DOM transactions</h3>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   778
    <p>A <dfn>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
   779
    <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
   780
    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
   781
    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
   782
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   783
    <div class="impl">
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   784
        <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
   785
        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
   786
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   787
        <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
   788
        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
   789
12
46189be9cb28 Fix typos per Caio Marcelo de Oliveira Filho's comment.
Ryosuke Niwa <rniwa@webkit.org>
parents: 11
diff changeset
   790
        <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
   791
        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
   792
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   793
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   794
    <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
   795
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   796
    <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
   797
    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
   798
    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
   799
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   800
    <div class="example">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   801
        <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
   802
        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
   803
        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
   804
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   805
        <pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   806
function drawLine(start, end, style) {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   807
    document.undoManager.transact({ execute: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   808
            // Draw a line on canvas
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   809
        }, undo: function () {
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   810
            // Undraw a line
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   811
        }, redo: function () { this.execute(); },
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   812
        'Draw a line'
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
}
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   815
</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   816
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   817
        <p>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
   818
        <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
   819
        of this undoable action via UIs such as context menu and menubars.</p></div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   820
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   821
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   822
<h2>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
   823
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   824
    <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
   825
    of a <code><a href="#undomanager">UndoManager</a></code>, the user agent must fire a <dfn>DOM transaction event</dfn> using
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   826
    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
   827
    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
   828
    <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
   829
    an <dfn>undo event</dfn> and a <dfn>redo event</dfn> respectively.</p>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   830
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   831
<h3>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
   832
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   833
    <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
   834
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
   835
    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
   836
};</pre>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   837
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   838
    <dl class="domintro">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   839
        <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
   840
        <dd><p>Returns the transaction object that triggered this event.</p></dd>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   841
    </dl>
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
    <div class="impl">
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   844
        <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
   845
        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
   846
        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
   847
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   848
        <p>When the user agent is required to <dfn>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
   849
        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
   850
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   851
            <li>Create a <code><a href="#dom-domtransactionevent">DOMTransactionEvent</a></code> object and initialize it to have the name "<code>DOMTransaction</code>",
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   852
            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
   853
            <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
   854
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   855
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   856
        <p>When the user agent is required to <dfn>fire an undo event</dfn> and <dfn>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
   857
        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
   858
        <ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   859
            <li>Create a <code><a href="#dom-domtransactionevent">DOMTransactionEvent</a></code> object and initialize it to have the name "<code>undo</code>" and
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   860
            "<code>redo</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
   861
            <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
   862
        </ol>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   863
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   864
        <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
   865
        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
   866
    </div>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   867
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   868
<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
   869
</body>
2f3551c872b8 Import files from https://github.com/rniwa/undomanager/commit/a2fb3b2096105bb0506f41edddde0e155a14ba4b
Ryosuke Niwa <rniwa@webkit.org>
parents:
diff changeset
   870
</html>