Title: [126245] trunk
Revision
126245
Author
[email protected]
Date
2012-08-21 18:42:43 -0700 (Tue, 21 Aug 2012)

Log Message

Remove UndoManager's undoscope content attribute
https://bugs.webkit.org/show_bug.cgi?id=94637

Patch by Sukolsak Sakshuwong <[email protected]> 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:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126244 => 126245)


--- trunk/LayoutTests/ChangeLog	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/ChangeLog	2012-08-22 01:42:43 UTC (rev 126245)
@@ -1,3 +1,18 @@
+2012-08-21  Sukolsak Sakshuwong  <[email protected]>
+
+        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  <[email protected]>
 
         Skipping http/tests/inspector/console-resource-errors.html.

Added: trunk/LayoutTests/editing/undomanager/undomanager-reenter-expected.txt (0 => 126245)


--- trunk/LayoutTests/editing/undomanager/undomanager-reenter-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/undomanager/undomanager-reenter-expected.txt	2012-08-22 01:42:43 UTC (rev 126245)
@@ -0,0 +1,15 @@
+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".
+
+
+call undoManager.transact() during the execute callback
+PASS undoManager.transact(transaction) threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
+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.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/undomanager/undomanager-reenter.html (0 => 126245)


--- trunk/LayoutTests/editing/undomanager/undomanager-reenter.html	                        (rev 0)
+++ trunk/LayoutTests/editing/undomanager/undomanager-reenter.html	2012-08-22 01:42:43 UTC (rev 126245)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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=""
+</body>
+</html>

Deleted: trunk/LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt (126244 => 126245)


--- trunk/LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/editing/undomanager/undomanager-use-after-free-expected.txt	2012-08-22 01:42:43 UTC (rev 126245)
@@ -1,24 +0,0 @@
-Ensure that undoManager doesn't have use-after-free vulnerabilities.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-call undoManager.transact() during the execute callback
-PASS undoManager.transact(transaction) threw exception Error: INVALID_ACCESS_ERR: DOM Exception 15.
-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
-

Deleted: trunk/LayoutTests/editing/undomanager/undomanager-use-after-free.html (126244 => 126245)


--- trunk/LayoutTests/editing/undomanager/undomanager-use-after-free.html	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/editing/undomanager/undomanager-use-after-free.html	2012-08-22 01:42:43 UTC (rev 126245)
@@ -1,73 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-</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=""
-</body>
-</html>

Deleted: trunk/LayoutTests/editing/undomanager/undoscope-attribute-expected.txt (126244 => 126245)


--- trunk/LayoutTests/editing/undomanager/undoscope-attribute-expected.txt	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/editing/undomanager/undoscope-attribute-expected.txt	2012-08-22 01:42:43 UTC (rev 126245)
@@ -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. 
-

Deleted: trunk/LayoutTests/editing/undomanager/undoscope-attribute.html (126244 => 126245)


--- trunk/LayoutTests/editing/undomanager/undoscope-attribute.html	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/editing/undomanager/undoscope-attribute.html	2012-08-22 01:42:43 UTC (rev 126245)
@@ -1,159 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<title>undoscope attribute</title>
-<script src=""
-<script src=""
-</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>

Modified: trunk/LayoutTests/editing/undomanager/undoscopehost-use-after-free.html (126244 => 126245)


--- trunk/LayoutTests/editing/undomanager/undoscopehost-use-after-free.html	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/LayoutTests/editing/undomanager/undoscopehost-use-after-free.html	2012-08-22 01:42:43 UTC (rev 126245)
@@ -4,16 +4,16 @@
 <script src=""
 </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 = {

Modified: trunk/Source/WebCore/ChangeLog (126244 => 126245)


--- trunk/Source/WebCore/ChangeLog	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/ChangeLog	2012-08-22 01:42:43 UTC (rev 126245)
@@ -1,3 +1,44 @@
+2012-08-21  Sukolsak Sakshuwong  <[email protected]>
+
+        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  <[email protected]>
 
         [Gtk] No accessible caret-moved events found in certain content

Modified: trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp (126244 => 126245)


--- trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-22 01:42:43 UTC (rev 126245)
@@ -90,14 +90,10 @@
 
 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;
 

Modified: trunk/Source/WebCore/dom/Document.cpp (126244 => 126245)


--- trunk/Source/WebCore/dom/Document.cpp	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-08-22 01:42:43 UTC (rev 126245)
@@ -6155,7 +6155,7 @@
 PassRefPtr<UndoManager> Document::undoManager()
 {
     if (!m_undoManager)
-        m_undoManager = UndoManager::create(this, this);
+        m_undoManager = UndoManager::create(this);
     return m_undoManager;
 }
 #endif

Modified: trunk/Source/WebCore/dom/Element.cpp (126244 => 126245)


--- trunk/Source/WebCore/dom/Element.cpp	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-08-22 01:42:43 UTC (rev 126245)
@@ -146,13 +146,6 @@
         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 @@
         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 = ""
-    data->m_undoScope = undoScope;
-    if (!undoScope)
-        disconnectUndoManager();
-}
-
-PassRefPtr<UndoManager> Element::undoManager()
-{
-    if (!undoScope() || (isContentEditable() && !isRootEditableElement())) {
-        disconnectUndoManager();
-        return 0;
-    }
-    ElementRareData* data = ""
-    if (!data->m_undoManager)
-        data->m_undoManager = UndoManager::create(document(), this);
-    return data->m_undoManager;
-}
-
-void Element::disconnectUndoManager()
-{
-    if (!hasRareData())
-        return;
-    ElementRareData* data = ""
-    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

Modified: trunk/Source/WebCore/dom/Element.h (126244 => 126245)


--- trunk/Source/WebCore/dom/Element.h	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/dom/Element.h	2012-08-22 01:42:43 UTC (rev 126245)
@@ -440,14 +440,6 @@
         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)

Modified: trunk/Source/WebCore/dom/Element.idl (126244 => 126245)


--- trunk/Source/WebCore/dom/Element.idl	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/dom/Element.idl	2012-08-22 01:42:43 UTC (rev 126245)
@@ -145,11 +145,6 @@
         // 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;

Modified: trunk/Source/WebCore/dom/ElementRareData.h (126244 => 126245)


--- trunk/Source/WebCore/dom/ElementRareData.h	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/dom/ElementRareData.h	2012-08-22 01:42:43 UTC (rev 126245)
@@ -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 @@
 #if ENABLE(FULLSCREEN_API)
     bool m_containsFullScreenElement;
 #endif
-
-#if ENABLE(UNDO_MANAGER)
-    RefPtr<UndoManager> m_undoManager;
-    bool m_undoScope;
-#endif
 };
 
 inline IntSize defaultMinimumSizeForResizing()

Modified: trunk/Source/WebCore/editing/UndoManager.cpp (126244 => 126245)


--- trunk/Source/WebCore/editing/UndoManager.cpp	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/editing/UndoManager.cpp	2012-08-22 01:42:43 UTC (rev 126245)
@@ -29,25 +29,26 @@
  */
 
 #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 @@
 
 void UndoManager::disconnect()
 {
-    m_undoScopeHost = 0;
+    m_document = 0;
     clearStack(m_undoStack);
     clearStack(m_redoStack);
 }
@@ -89,7 +90,7 @@
 
 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 @@
     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::undo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -125,7 +126,7 @@
         entry[i - 1]->unapply();
     m_isInProgress = false;
 
-    if (!m_undoScopeHost) {
+    if (!m_document) {
         m_inProgressEntry.clear();
         return;
     }
@@ -135,7 +136,7 @@
 
 void UndoManager::redo(ExceptionCode& ec)
 {
-    if (m_isInProgress || !isConnected()) {
+    if (m_isInProgress || !m_document) {
         ec = INVALID_ACCESS_ERR;
         return;
     }
@@ -150,7 +151,7 @@
         entry[i - 1]->reapply();
     m_isInProgress = false;
 
-    if (!m_undoScopeHost) {
+    if (!m_document) {
         m_inProgressEntry.clear();
         return;
     }
@@ -182,7 +183,7 @@
 
 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::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

Modified: trunk/Source/WebCore/editing/UndoManager.h (126244 => 126245)


--- trunk/Source/WebCore/editing/UndoManager.h	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/editing/UndoManager.h	2012-08-22 01:42:43 UTC (rev 126245)
@@ -34,6 +34,7 @@
 #if ENABLE(UNDO_MANAGER)
 
 #include "ActiveDOMObject.h"
+#include "Document.h"
 #include "ExceptionCodePlaceholder.h"
 #include "UndoStep.h"
 #include <wtf/OwnPtr.h>
@@ -46,14 +47,13 @@
 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 @@
     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;

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (126244 => 126245)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2012-08-22 01:42:43 UTC (rev 126245)
@@ -319,7 +319,6 @@
 translate
 truespeed
 type
-undoscope
 usemap
 valign
 value

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (126244 => 126245)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2012-08-22 01:40:27 UTC (rev 126244)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2012-08-22 01:42:43 UTC (rev 126245)
@@ -235,10 +235,6 @@
     } 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 @@
         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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to