Remove UndoManager's undoscope content attribute
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 01:42:43 +0000 (01:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 01:42:43 +0000 (01:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94637

Patch by Sukolsak Sakshuwong <sukolsak@google.com> on 2012-08-21
Reviewed by Ryosuke Niwa.

Source/WebCore:

No new tests. Covered by existing tests.

* bindings/v8/DOMTransaction.cpp:
(WebCore::DOMTransaction::callFunction):
* dom/Document.cpp:
(WebCore::Document::undoManager):
* dom/Element.cpp:
(WebCore::Element::~Element):
(WebCore):
* dom/Element.h:
(Element):
* dom/Element.idl:
* dom/ElementRareData.h:
(ElementRareData):
* editing/UndoManager.cpp:
(WebCore::UndoManager::create):
(WebCore::UndoManager::UndoManager):
(WebCore::UndoManager::disconnect):
(WebCore::UndoManager::transact):
(WebCore::UndoManager::undo):
(WebCore::UndoManager::redo):
(WebCore::UndoManager::clearUndo):
(WebCore::UndoManager::clearRedo):
(WebCore):
* editing/UndoManager.h:
(WebCore):
(UndoManager):
(WebCore::UndoManager::document):
(WebCore::UndoManager::ownerNode):
* html/HTMLAttributeNames.in:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::parseAttribute):
(WebCore::HTMLElement::setContentEditable):

LayoutTests:

* editing/undomanager/undomanager-reenter-expected.txt: Copied from LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt.
* editing/undomanager/undomanager-reenter.html: Copied from LayoutTests/editing/undomanager/undomanager-use-after-free.html.
* editing/undomanager/undomanager-use-after-free-expected.txt: Removed.
* editing/undomanager/undomanager-use-after-free.html: Removed.
* editing/undomanager/undoscope-attribute-expected.txt: Removed.
* editing/undomanager/undoscope-attribute.html: Removed.
* editing/undomanager/undoscopehost-use-after-free.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126245 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/undomanager/undomanager-reenter-expected.txt [moved from LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt with 54% similarity]
LayoutTests/editing/undomanager/undomanager-reenter.html [new file with mode: 0644]
LayoutTests/editing/undomanager/undomanager-use-after-free.html [deleted file]
LayoutTests/editing/undomanager/undoscope-attribute-expected.txt [deleted file]
LayoutTests/editing/undomanager/undoscope-attribute.html [deleted file]
LayoutTests/editing/undomanager/undoscopehost-use-after-free.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/DOMTransaction.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/dom/ElementRareData.h
Source/WebCore/editing/UndoManager.cpp
Source/WebCore/editing/UndoManager.h
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/html/HTMLElement.cpp

index 58a9d58..b95e3e6 100644 (file)
@@ -1,3 +1,18 @@
+2012-08-21  Sukolsak Sakshuwong  <sukolsak@google.com>
+
+        Remove UndoManager's undoscope content attribute
+        https://bugs.webkit.org/show_bug.cgi?id=94637
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/undomanager/undomanager-reenter-expected.txt: Copied from LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt.
+        * editing/undomanager/undomanager-reenter.html: Copied from LayoutTests/editing/undomanager/undomanager-use-after-free.html.
+        * editing/undomanager/undomanager-use-after-free-expected.txt: Removed.
+        * editing/undomanager/undomanager-use-after-free.html: Removed.
+        * editing/undomanager/undoscope-attribute-expected.txt: Removed.
+        * editing/undomanager/undoscope-attribute.html: Removed.
+        * editing/undomanager/undoscopehost-use-after-free.html:
+
 2012-08-21  Mark Lam  <mark.lam@apple.com>
 
         Skipping http/tests/inspector/console-resource-errors.html.
@@ -1,4 +1,4 @@
-Ensure that undoManager doesn't have use-after-free vulnerabilities.
+Ensure that undoManager throws an exception when we re-enter it by calling undoManager functions during callbacks.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
@@ -9,15 +9,6 @@ call undoManager.undo() during the undo callback
 PASS undoManager.undo() threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
 call undoManager.clearRedo() during the redo callback
 PASS undoManager.redo() threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
-call undoManager.transact() with a transaction that disconnects the undoManager when undoing
-PASS result is "execute "
-call undoManager.undo()
-PASS result is "execute undo "
-PASS edit.undoManager is null
-PASS undoManager.length is 0
-call undoManager.redo() when the undoManager is disconnected
-PASS undoManager.redo() threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
-PASS result is "execute undo "
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/editing/undomanager/undomanager-reenter.html b/LayoutTests/editing/undomanager/undomanager-reenter.html
new file mode 100644 (file)
index 0000000..98f1f7e
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Ensure that undoManager throws an exception when we re-enter it by calling "
+    + "undoManager functions during callbacks.");
+
+var undoManager = document.undoManager;
+
+var transaction = {
+    "execute": function() {
+        undoManager.transact({
+            "execute": function() { },
+            "undo": function() { },
+            "redo": function() { }
+        });
+    },
+    "undo": function() {
+        undoManager.undo();
+    },
+    "redo": function() {
+        undoManager.clearRedo();
+    }
+};
+
+debug("call undoManager.transact() during the execute callback");
+shouldThrow("undoManager.transact(transaction)", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
+
+debug("call undoManager.undo() during the undo callback");
+shouldThrow("undoManager.undo()", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
+
+debug("call undoManager.clearRedo() during the redo callback");
+shouldThrow("undoManager.redo()", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
+
+var successfullyParsed = true;
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/undomanager/undomanager-use-after-free.html b/LayoutTests/editing/undomanager/undomanager-use-after-free.html
deleted file mode 100644 (file)
index 5c33856..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src="../../fast/js/resources/js-test-pre.js"></script>
-</head>
-<body>
-<div id="edit" contentEditable="true" undoscope></div>
-<script>
-description("Ensure that undoManager doesn't have use-after-free vulnerabilities.");
-
-var edit = document.getElementById("edit");
-var undoManager = edit.undoManager;
-
-var transaction = {
-    "execute": function() {
-        undoManager.transact({
-            "execute": function() { },
-            "undo": function() { },
-            "redo": function() { }
-        });
-    },
-    "undo": function() {
-        undoManager.undo();
-    },
-    "redo": function() {
-        undoManager.clearRedo();
-    }
-};
-
-debug("call undoManager.transact() during the execute callback");
-shouldThrow("undoManager.transact(transaction)", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
-
-debug("call undoManager.undo() during the undo callback");
-shouldThrow("undoManager.undo()", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
-
-debug("call undoManager.clearRedo() during the redo callback");
-shouldThrow("undoManager.redo()", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
-
-var result = "";
-undoManager.clearUndo();
-undoManager.clearRedo();
-
-debug("call undoManager.transact() with a transaction that disconnects the undoManager when undoing");
-undoManager.transact({
-    "execute": function() {
-        result += "execute ";
-    },
-    "undo": function() {
-        result += "undo ";
-        edit.undoScope = false;
-        gc();
-    },
-    "redo": function() {
-        result += "redo ";
-    }
-});
-shouldBeEqualToString("result", "execute ");
-
-debug("call undoManager.undo()");
-undoManager.undo();
-shouldBeEqualToString("result", "execute undo ");
-shouldBeNull("edit.undoManager");
-shouldBe("undoManager.length", "0");
-
-debug("call undoManager.redo() when the undoManager is disconnected");
-shouldThrow("undoManager.redo()", "'Error: INVALID_ACCESS_ERR: DOM Exception 15'");
-shouldBeEqualToString("result", "execute undo ");
-
-var successfullyParsed = true;
-</script>
-<script src="../../fast/js/resources/js-test-post.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/editing/undomanager/undoscope-attribute-expected.txt b/LayoutTests/editing/undomanager/undoscope-attribute-expected.txt
deleted file mode 100644 (file)
index c5de45c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-This tests element's undoscope attribute.
-
-PASS An element has the undoscope attribute set to true. 
-PASS element.undoManager returns an UndoManager object. 
-PASS After element.undoScope = false, element.undoManager returns null. 
-PASS After element.undoScope = true, element.undoManager returns an UndoManager object. 
-PASS After element.removeAttribute('undoscope'), element.undoManager returns null. 
-PASS After element.setAttribute('undoscope', ''), element.undoManager returns an UndoManager object. 
-PASS After element.setAttribute('undoscope', 'undoscope'), element.undoManager returns an UndoManager object. 
-PASS After element.setAttribute('undoscope', ''); element.undoScope = false;, element.undoManager returns null. 
-PASS After element.removeAttribute('undoscope'); element.undoScope = true;, element.undoManager returns an UndoManager object. 
-PASS After element.undoScope = true; element.removeAttribute('undoscope');, element.undoManager returns null. 
-PASS After element.undoScope = false; element.setAttribute('undoscope', '');, element.undoManager returns an UndoManager object. 
-PASS After the parant of element becomes editable, element.undoManager returns null. 
-PASS After the parant of element becomes non-editable, element.undoManager returns an UndoManager object. 
-PASS After the parant of element becomes editable through inheritance, element.undoManager returns null. 
-PASS After the parant of element becomes non-editable and element becomes editable, element.undoManager returns an UndoManager object. 
-PASS element.undoManager is disconnected when element.undoScope = false. 
-PASS element.undoManager is disconnected when its parent becomes editable. 
-PASS Setting contentEditable of an ancestor of element to true doesn't disconnect element.undoManager if element is still an editing host. 
-
diff --git a/LayoutTests/editing/undomanager/undoscope-attribute.html b/LayoutTests/editing/undomanager/undoscope-attribute.html
deleted file mode 100644 (file)
index c7342c4..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<title>undoscope attribute</title>
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-</head>
-<body>
-This tests element's undoscope attribute.
-
-<div id="outerContainer">
-    <div id="innerContainer">
-        <div id="element" undoscope></div>
-    </div>
-</div>
-
-<script>
-var outerContainer = document.getElementById("outerContainer");
-var innerContainer = document.getElementById("innerContainer");
-var element = document.getElementById("element");
-
-function assert_element_has_undomanager() {
-    assert_equals(element.undoManager.toString(), "[object UndoManager]");
-}
-
-function assert_element_not_have_undomanager() {
-    assert_equals(element.undoManager, null);
-}
-
-test(function() {
-    assert_own_property(element, "undoScope");
-    assert_equals(element.undoScope, true);
-}, "An element has the undoscope attribute set to true.");
-
-test(function() {
-    assert_element_has_undomanager();
-}, "element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.undoScope = false;
-
-    assert_element_not_have_undomanager();
-}, "After element.undoScope = false, element.undoManager returns null.");
-
-test(function() {
-    element.undoScope = true;
-
-    assert_element_has_undomanager();
-}, "After element.undoScope = true, element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.setAttribute('undoscope', '');
-    element.removeAttribute('undoscope');
-
-    assert_element_not_have_undomanager();
-}, "After element.removeAttribute('undoscope'), element.undoManager returns null.");
-
-test(function() {
-    element.setAttribute('undoscope', '');
-
-    assert_element_has_undomanager();
-}, "After element.setAttribute('undoscope', ''), element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.setAttribute('undoscope', 'undoscope');
-
-    assert_element_has_undomanager();
-}, "After element.setAttribute('undoscope', 'undoscope'), element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.setAttribute('undoscope', '');
-    element.undoScope = false;
-
-    assert_element_not_have_undomanager();
-}, "After element.setAttribute('undoscope', ''); element.undoScope = false;, element.undoManager returns null.");
-
-test(function() {
-    element.removeAttribute('undoscope');
-    element.undoScope = true;
-
-    assert_element_has_undomanager();
-}, "After element.removeAttribute('undoscope'); element.undoScope = true;, element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.undoScope = true;
-    element.removeAttribute('undoscope');
-
-    assert_element_not_have_undomanager();
-}, "After element.undoScope = true; element.removeAttribute('undoscope');, element.undoManager returns null.");
-
-test(function() {
-    element.undoScope = false;
-    element.setAttribute('undoscope', '');
-
-    assert_element_has_undomanager();
-}, "After element.undoScope = false; element.setAttribute('undoscope', '');, element.undoManager returns an UndoManager object.");
-
-test(function() {
-    innerContainer.contentEditable = "true";
-
-    assert_element_not_have_undomanager();
-}, "After the parant of element becomes editable, element.undoManager returns null.");
-
-test(function() {
-    innerContainer.contentEditable = "false";
-
-    assert_element_has_undomanager();
-}, "After the parant of element becomes non-editable, element.undoManager returns an UndoManager object.");
-
-test(function() {
-    outerContainer.contentEditable = "true";
-    innerContainer.contentEditable = "inherit";
-
-    assert_element_not_have_undomanager();
-}, "After the parant of element becomes editable through inheritance, element.undoManager returns null.");
-
-test(function() {
-    innerContainer.contentEditable = "false";
-    element.contentEdiable = "true";
-
-    assert_element_has_undomanager();
-}, "After the parant of element becomes non-editable and element becomes editable, element.undoManager returns an UndoManager object.");
-
-test(function() {
-    element.undoManager.transact({"execute": function () { }}, false);
-    
-    assert_equals(element.undoManager.length, 1);
-
-    element.undoScope = false;
-    element.undoScope = true;
-
-    assert_equals(element.undoManager.length, 0);
-}, "element.undoManager is disconnected when element.undoScope = false.");
-
-test(function() {
-    element.undoManager.transact({"execute": function () { }}, false);
-    
-    assert_equals(element.undoManager.length, 1);
-
-    innerContainer.contentEditable = "true";
-    innerContainer.contentEditable = "false";
-
-    assert_equals(element.undoManager.length, 0);
-}, "element.undoManager is disconnected when its parent becomes editable.");
-
-test(function() {
-    outerContainer.contentEditable = "false";
-    innerContainer.contentEditable = "false";
-    element.undoManager.transact({"execute": function () { }}, false);
-
-    assert_equals(element.undoManager.length, 1);
-
-    outerContainer.contentEditable = "true";
-
-    assert_equals(element.undoManager.length, 1);
-}, "Setting contentEditable of an ancestor of element to true doesn't disconnect element.undoManager if element is still an editing host.");
-</script>
-</body>
-</html>
index 6e14fd1..3d07fba 100644 (file)
@@ -4,16 +4,16 @@
 <script src="../../fast/js/resources/js-test-pre.js"></script>
 </head>
 <body>
-<div id="div" undoscope></div>
+<iframe id="frame"></iframe>
 <script>
 description("This tests that undoManager doesn't have use-after-free vulnerabilities "
     + "after its undoScopeHost has been reclaimed by GC.");
 
-var div = document.getElementById("div");
-var undoManager = div.undoManager;
+var frame = document.getElementById("frame");
+var undoManager = frame.contentDocument.undoManager;
 
-div.parentNode.removeChild(div);
-div = null;
+frame.parentNode.removeChild(frame);
+frame = null;
 gc();
 
 var transaction = {
index 599ef74..7f70868 100644 (file)
@@ -1,3 +1,44 @@
+2012-08-21  Sukolsak Sakshuwong  <sukolsak@google.com>
+
+        Remove UndoManager's undoscope content attribute
+        https://bugs.webkit.org/show_bug.cgi?id=94637
+
+        Reviewed by Ryosuke Niwa.
+
+        No new tests. Covered by existing tests.
+
+        * bindings/v8/DOMTransaction.cpp:
+        (WebCore::DOMTransaction::callFunction):
+        * dom/Document.cpp:
+        (WebCore::Document::undoManager):
+        * dom/Element.cpp:
+        (WebCore::Element::~Element):
+        (WebCore):
+        * dom/Element.h:
+        (Element):
+        * dom/Element.idl:
+        * dom/ElementRareData.h:
+        (ElementRareData):
+        * editing/UndoManager.cpp:
+        (WebCore::UndoManager::create):
+        (WebCore::UndoManager::UndoManager):
+        (WebCore::UndoManager::disconnect):
+        (WebCore::UndoManager::transact):
+        (WebCore::UndoManager::undo):
+        (WebCore::UndoManager::redo):
+        (WebCore::UndoManager::clearUndo):
+        (WebCore::UndoManager::clearRedo):
+        (WebCore):
+        * editing/UndoManager.h:
+        (WebCore):
+        (UndoManager):
+        (WebCore::UndoManager::document):
+        (WebCore::UndoManager::ownerNode):
+        * html/HTMLAttributeNames.in:
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::parseAttribute):
+        (WebCore::HTMLElement::setContentEditable):
+
 2012-08-21  Joanmarie Diggs  <jdiggs@igalia.com>
 
         [Gtk] No accessible caret-moved events found in certain content
index 08919c2..d0b4d4e 100644 (file)
@@ -90,14 +90,10 @@ v8::Handle<v8::Function> DOMTransaction::getFunction(const char* propertyName)
 
 void DOMTransaction::callFunction(const char* propertyName)
 {
-    if (!m_undoManager || !m_undoManager->undoScopeHost())
+    if (!m_undoManager || !m_undoManager->document())
         return;
 
-    Document* document = m_undoManager->undoScopeHost()->document();
-    if (!document)
-        return;
-
-    Frame* frame = document->frame();
+    Frame* frame = m_undoManager->document()->frame();
     if (!frame || !frame->script()->canExecuteScripts(AboutToExecuteScript))
         return;
 
index d97bd34..b495e22 100644 (file)
@@ -6155,7 +6155,7 @@ void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 PassRefPtr<UndoManager> Document::undoManager()
 {
     if (!m_undoManager)
-        m_undoManager = UndoManager::create(this, this);
+        m_undoManager = UndoManager::create(this);
     return m_undoManager;
 }
 #endif
index 53d6a29..123d82f 100644 (file)
@@ -146,13 +146,6 @@ Element::~Element()
         ASSERT(m_attributeData);
         m_attributeData->detachAttrObjectsFromElement(this);
     }
-
-#if ENABLE(UNDO_MANAGER)
-    if (hasRareData() && elementRareData()->m_undoManager) {
-        elementRareData()->m_undoManager->disconnect();
-        elementRareData()->m_undoManager.clear();
-    }
-#endif
 }
 
 inline ElementRareData* Element::elementRareData() const
@@ -2222,61 +2215,4 @@ void Element::createMutableAttributeData()
         m_attributeData = m_attributeData->makeMutable();
 }
 
-#if ENABLE(UNDO_MANAGER)
-bool Element::undoScope() const
-{
-    return hasRareData() && elementRareData()->m_undoScope;
-}
-
-void Element::setUndoScope(bool undoScope)
-{
-    ElementRareData* data = ensureElementRareData();
-    data->m_undoScope = undoScope;
-    if (!undoScope)
-        disconnectUndoManager();
-}
-
-PassRefPtr<UndoManager> Element::undoManager()
-{
-    if (!undoScope() || (isContentEditable() && !isRootEditableElement())) {
-        disconnectUndoManager();
-        return 0;
-    }
-    ElementRareData* data = ensureElementRareData();
-    if (!data->m_undoManager)
-        data->m_undoManager = UndoManager::create(document(), this);
-    return data->m_undoManager;
-}
-
-void Element::disconnectUndoManager()
-{
-    if (!hasRareData())
-        return;
-    ElementRareData* data = elementRareData();
-    UndoManager* undoManager = data->m_undoManager.get();
-    if (!undoManager)
-        return;
-    undoManager->disconnect();
-    data->m_undoManager.clear();
-}
-
-void Element::disconnectUndoManagersInSubtree()
-{
-    Node* node = firstChild();
-    while (node) {
-        if (node->isElementNode()) {
-            Element* element = toElement(node);
-            if (element->hasRareData() && element->elementRareData()->m_undoManager) {
-                if (!node->isContentEditable()) {
-                    node = node->traverseNextSibling(this);
-                    continue;
-                }
-                element->disconnectUndoManager();
-            }
-        }
-        node = node->traverseNextNode(this);
-    }
-}
-#endif
-
 } // namespace WebCore
index d938548..97a16f6 100644 (file)
@@ -440,14 +440,6 @@ public:
         info.addInstrumentedMember(m_attributeData);
     }
 
-#if ENABLE(UNDO_MANAGER)
-    bool undoScope() const;
-    void setUndoScope(bool);
-    PassRefPtr<UndoManager> undoManager();
-    void disconnectUndoManager();
-    void disconnectUndoManagersInSubtree();
-#endif
-
 protected:
     Element(const QualifiedName& tagName, Document* document, ConstructionType type)
         : ContainerNode(document, type)
index 3bdd03b..fb60c73 100644 (file)
@@ -145,11 +145,6 @@ module core {
         // CSS Regions API
         readonly attribute DOMString webkitRegionOverset;
 
-#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
-        readonly attribute [Conditional=UNDO_MANAGER] UndoManager undoManager;
-        attribute [Conditional=UNDO_MANAGER, Reflect] boolean undoScope;
-#endif
-
 #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
         // Event handler DOM attributes
         attribute [NotEnumerable] EventListener onabort;
index 666cc46..07394eb 100644 (file)
@@ -29,7 +29,6 @@
 #include "HTMLCollection.h"
 #include "NamedNodeMap.h"
 #include "NodeRareData.h"
-#include "UndoManager.h"
 #include <wtf/OwnPtr.h>
 
 namespace WebCore {
@@ -119,11 +118,6 @@ public:
 #if ENABLE(FULLSCREEN_API)
     bool m_containsFullScreenElement;
 #endif
-
-#if ENABLE(UNDO_MANAGER)
-    RefPtr<UndoManager> m_undoManager;
-    bool m_undoScope;
-#endif
 };
 
 inline IntSize defaultMinimumSizeForResizing()
index 49106fd..084ab29 100644 (file)
  */
 
 #include "config.h"
-#include "UndoManager.h"
 
 #if ENABLE(UNDO_MANAGER)
 
+#include "UndoManager.h"
+
 #include "DOMTransaction.h"
-#include "Element.h"
+#include "ExceptionCode.h"
 
 namespace WebCore {
 
-PassRefPtr<UndoManager> UndoManager::create(ScriptExecutionContext* context, Node* host)
+PassRefPtr<UndoManager> UndoManager::create(Document* document)
 {
-    RefPtr<UndoManager> undoManager = adoptRef(new UndoManager(context, host));
+    RefPtr<UndoManager> undoManager = adoptRef(new UndoManager(document));
     undoManager->suspendIfNeeded();
     return undoManager.release();
 }
 
-UndoManager::UndoManager(ScriptExecutionContext* context, Node* host)
-    : ActiveDOMObject(context, this)
-    , m_undoScopeHost(host)
+UndoManager::UndoManager(Document* document)
+    : ActiveDOMObject(document, this)
+    , m_document(document)
     , m_isInProgress(false)
 {
 }
@@ -67,7 +68,7 @@ static void clearStack(UndoManagerStack& stack)
 
 void UndoManager::disconnect()
 {
-    m_undoScopeHost = 0;
+    m_document = 0;
     clearStack(m_undoStack);
     clearStack(m_redoStack);
 }
@@ -89,7 +90,7 @@ static inline PassOwnPtr<UndoManagerEntry> createUndoManagerEntry()
 
 void UndoManager::transact(PassRefPtr<DOMTransaction> transaction, bool merge, ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -101,7 +102,7 @@ void UndoManager::transact(PassRefPtr<DOMTransaction> transaction, bool merge, E
     transaction->apply();
     m_isInProgress = false;
 
-    if (!m_undoScopeHost)
+    if (!m_document)
         return;
     if (!merge || m_undoStack.isEmpty())
         m_undoStack.append(createUndoManagerEntry());
@@ -110,7 +111,7 @@ void UndoManager::transact(PassRefPtr<DOMTransaction> transaction, bool merge, E
 
 void UndoManager::undo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -125,7 +126,7 @@ void UndoManager::undo(ExceptionCode& ec)
         entry[i - 1]->unapply();
     m_isInProgress = false;
 
-    if (!m_undoScopeHost) {
+    if (!m_document) {
         m_inProgressEntry.clear();
         return;
     }
@@ -135,7 +136,7 @@ void UndoManager::undo(ExceptionCode& ec)
 
 void UndoManager::redo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -150,7 +151,7 @@ void UndoManager::redo(ExceptionCode& ec)
         entry[i - 1]->reapply();
     m_isInProgress = false;
 
-    if (!m_undoScopeHost) {
+    if (!m_document) {
         m_inProgressEntry.clear();
         return;
     }
@@ -182,7 +183,7 @@ void UndoManager::registerRedoStep(PassRefPtr<UndoStep> step)
 
 void UndoManager::clearUndo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -191,28 +192,13 @@ void UndoManager::clearUndo(ExceptionCode& ec)
 
 void UndoManager::clearRedo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
     clearStack(m_redoStack);
 }
 
-bool UndoManager::isConnected()
-{
-    if (!m_undoScopeHost)
-        return false;
-    if (!m_undoScopeHost->isElementNode())
-        return true;
-    Element* element = toElement(m_undoScopeHost);
-    ASSERT(element->undoScope());
-    if (element->isContentEditable() && !element->isRootEditableElement()) {
-        element->disconnectUndoManager();
-        return false;
-    }
-    return true;
-}
-
 }
 
 #endif
index abb9930..18341e9 100644 (file)
@@ -34,6 +34,7 @@
 #if ENABLE(UNDO_MANAGER)
 
 #include "ActiveDOMObject.h"
+#include "Document.h"
 #include "ExceptionCodePlaceholder.h"
 #include "UndoStep.h"
 #include <wtf/OwnPtr.h>
 namespace WebCore {
 
 class DOMTransaction;
-class Node;
 
 typedef Vector<RefPtr<UndoStep> > UndoManagerEntry;
 typedef Vector<OwnPtr<UndoManagerEntry> > UndoManagerStack;
 
 class UndoManager : public RefCounted<UndoManager>, public ActiveDOMObject {
 public:
-    static PassRefPtr<UndoManager> create(ScriptExecutionContext*, Node* host);
+    static PassRefPtr<UndoManager> create(Document*);
     void disconnect();
     virtual void stop() OVERRIDE;
     virtual ~UndoManager();
@@ -75,14 +75,13 @@ public:
     void registerUndoStep(PassRefPtr<UndoStep>);
     void registerRedoStep(PassRefPtr<UndoStep>);
     
-    Node* undoScopeHost() const { return m_undoScopeHost; }
-    Node* ownerNode() const { return m_undoScopeHost; }
+    Document* document() const { return m_document; }
+    Node* ownerNode() const { return m_document; }
 
 private:
-    explicit UndoManager(ScriptExecutionContext*, Node* host);
-    bool isConnected();
+    explicit UndoManager(Document*);
     
-    Node* m_undoScopeHost;
+    Document* m_document;
     UndoManagerStack m_undoStack;
     UndoManagerStack m_redoStack;
     bool m_isInProgress;
index 9bc1fa4..459078f 100644 (file)
@@ -319,7 +319,6 @@ topmargin
 translate
 truespeed
 type
-undoscope
 usemap
 valign
 value
index b707ef2..f67abc3 100644 (file)
@@ -235,10 +235,6 @@ void HTMLElement::parseAttribute(const Attribute& attribute)
     } else if (attribute.name() == itemtypeAttr) {
         setItemType(attribute.value());
 #endif
-#if ENABLE(UNDO_MANAGER)
-    } else if (attribute.name() == undoscopeAttr) {
-        setUndoScope(!attribute.isNull());
-#endif
     }
 // standard events
     else if (attribute.name() == onclickAttr) {
@@ -663,14 +659,8 @@ void HTMLElement::setContentEditable(const String& enabled, ExceptionCode& ec)
         setAttribute(contenteditableAttr, "plaintext-only");
     else if (equalIgnoringCase(enabled, "inherit"))
         removeAttribute(contenteditableAttr);
-    else {
+    else
         ec = SYNTAX_ERR;
-        return;
-    }
-#if ENABLE(UNDO_MANAGER)
-    if (isContentEditable())
-        disconnectUndoManagersInSubtree();
-#endif
 }
 
 bool HTMLElement::draggable() const