Diff
Modified: branches/safari-537.75-branch/LayoutTests/ChangeLog (163900 => 163901)
--- branches/safari-537.75-branch/LayoutTests/ChangeLog 2014-02-11 21:01:20 UTC (rev 163900)
+++ branches/safari-537.75-branch/LayoutTests/ChangeLog 2014-02-11 21:12:48 UTC (rev 163901)
@@ -1,5 +1,23 @@
-2014-01-11 Matthew Hanson <[email protected]>
+2014-02-11 Matthew Hanson <[email protected]>
+ Merge r158739.
+
+ 2013-11-06 Ryosuke Niwa <[email protected]>
+
+ Notify nodes removal to Range/Selection after dispatching blur and mutation event
+ https://bugs.webkit.org/show_bug.cgi?id=123880
+
+ Reviewed by Andreas Kling.
+
+ * editing/selection/selection-change-in-blur-event-by-remove-children-expected.txt: Added.
+ * editing/selection/selection-change-in-blur-event-by-remove-children.html: Added.
+ * editing/selection/selection-change-in-mutation-event-by-remove-children-expected.txt: Added.
+ * editing/selection/selection-change-in-mutation-event-by-remove-children.html: Added.
+ * fast/dom/Range/range-created-during-remove-children-expected.txt: Added.
+ * fast/dom/Range/range-created-during-remove-children.html: Added.
+
+2014-02-11 Matthew Hanson <[email protected]>
+
Merge r158447.
2013-10-31 Mark Lam <[email protected]>
Copied: branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children-expected.txt (from rev 158739, trunk/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children-expected.txt) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children-expected.txt (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children-expected.txt 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,6 @@
+PASS selection.anchorOffset is 0
+PASS selection.focusOffset is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children.html (from rev 158739, trunk/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children.html) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children.html (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-blur-event-by-remove-children.html 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,26 @@
+<div id="container">
+<p id="description"></p>
+<div id="sample"><span contenteditable="true">foobar</span></div>
+</div>
+<div id="console"></div>
+<script src=""
+<script>
+description('Selection should be updated after set innerHTML.');
+
+var sample = document.getElementById('sample');
+var selection = window.getSelection();
+document.addEventListener('blur', function () {
+ selection.selectAllChildren(sample.firstChild);
+}, true);
+
+selection.selectAllChildren(sample.firstChild);
+sample.firstChild.focus();
+sample.innerHTML = '';
+
+shouldBe('selection.anchorOffset', '0');
+shouldBe('selection.focusOffset', '0');
+
+if (window.testRunner)
+ document.getElementById('container').outerHTML = '';
+</script>
+<script src=""
Copied: branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children-expected.txt (from rev 158739, trunk/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children-expected.txt) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children-expected.txt (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children-expected.txt 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,8 @@
+PASS selection.anchorNode is sample
+PASS selection.anchorOffset is 0
+PASS selection.focusNode is sample
+PASS selection.focusOffset is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children.html (from rev 158739, trunk/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children.html) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children.html (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/editing/selection/selection-change-in-mutation-event-by-remove-children.html 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,28 @@
+<div id="container">
+<p id="description"></p>
+<div id="sample">foobar</div>
+</div>
+<div id="console"></div>
+<script src=""
+<script>
+description('Selection should be updated after set innerHTML.');
+
+var sample = document.getElementById('sample');
+
+var selection = window.getSelection();
+document.addEventListener('DOMNodeRemovedFromDocument', function () {
+ selection.selectAllChildren(sample);
+}, true);
+
+selection.selectAllChildren(sample);
+sample.innerHTML = '';
+
+shouldBe('selection.anchorNode', 'sample');
+shouldBe('selection.anchorOffset', '0');
+shouldBe('selection.focusNode', 'sample');
+shouldBe('selection.focusOffset', '0');
+
+if (window.testRunner)
+ document.getElementById('container').outerHTML = '';
+</script>
+<script src=""
Copied: branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children-expected.txt (from rev 158739, trunk/LayoutTests/fast/dom/Range/range-created-during-remove-children-expected.txt) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children-expected.txt (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children-expected.txt 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,12 @@
+PASS ranges["blur"].startContainer is sample
+PASS ranges["blur"].endContainer is sample
+PASS ranges["blur"].startOffset is 0
+PASS ranges["blur"].endOffset is 0
+PASS ranges["DOMNodeRemovedFromDocument"].startContainer is sample
+PASS ranges["DOMNodeRemovedFromDocument"].endContainer is sample
+PASS ranges["DOMNodeRemovedFromDocument"].startOffset is 0
+PASS ranges["DOMNodeRemovedFromDocument"].endOffset is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Copied: branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children.html (from rev 158739, trunk/LayoutTests/fast/dom/Range/range-created-during-remove-children.html) (0 => 163901)
--- branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children.html (rev 0)
+++ branches/safari-537.75-branch/LayoutTests/fast/dom/Range/range-created-during-remove-children.html 2014-02-11 21:12:48 UTC (rev 163901)
@@ -0,0 +1,37 @@
+<div id="container">
+<p id="description"></p>
+<div id="sample"><span contenteditable="true">foobar</span></div>
+</div>
+<div id="console"></div>
+<script src=""
+<script>
+description('Range objects should be updated after set innerHTML.');
+
+var ranges = {};
+var sample = document.getElementById('sample');
+function eventHandler(event) {
+ if (ranges[event.type])
+ return;
+ ranges[event.type] = document.createRange();
+ ranges[event.type].selectNodeContents(sample.firstChild.firstChild);
+}
+
+document.addEventListener('blur', eventHandler, true);
+document.addEventListener('DOMNodeRemovedFromDocument', eventHandler, true);
+
+sample.firstChild.focus();
+sample.innerHTML = '';
+
+shouldBe('ranges["blur"].startContainer', 'sample');
+shouldBe('ranges["blur"].endContainer', 'sample');
+shouldBe('ranges["blur"].startOffset', '0');
+shouldBe('ranges["blur"].endOffset', '0');
+shouldBe('ranges["DOMNodeRemovedFromDocument"].startContainer', 'sample');
+shouldBe('ranges["DOMNodeRemovedFromDocument"].endContainer', 'sample');
+shouldBe('ranges["DOMNodeRemovedFromDocument"].startOffset', '0');
+shouldBe('ranges["DOMNodeRemovedFromDocument"].endOffset', '0');
+
+if (window.testRunner)
+ document.getElementById('container').outerHTML = '';
+</script>
+<script src=""
Modified: branches/safari-537.75-branch/Source/WebCore/ChangeLog (163900 => 163901)
--- branches/safari-537.75-branch/Source/WebCore/ChangeLog 2014-02-11 21:01:20 UTC (rev 163900)
+++ branches/safari-537.75-branch/Source/WebCore/ChangeLog 2014-02-11 21:12:48 UTC (rev 163901)
@@ -1,5 +1,29 @@
2014-02-11 Matthew Hanson <[email protected]>
+ Merge r158739.
+
+ 2013-11-06 Ryosuke Niwa <[email protected]>
+
+ Notify nodes removal to Range/Selection after dispatching blur and mutation event
+ https://bugs.webkit.org/show_bug.cgi?id=123880
+
+ Reviewed by Andreas Kling.
+
+ Merge https://chromium.googlesource.com/chromium/blink/+/b60576a0560d14f8757e58d55d37b7cefa48a6ac
+
+ In willRemoveChildren in ContainerNode.cpp, call Document::nodeChildrenWillBeRemoved after instead of
+ before dispatching mutation events because we need to update ranges created by those mutation event
+ listeners. willRemoveChild was fixed in r115686.
+
+ Tests: editing/selection/selection-change-in-blur-event-by-remove-children.html
+ editing/selection/selection-change-in-mutation-event-by-remove-children.html
+ fast/dom/Range/range-created-during-remove-children.html
+
+ * dom/ContainerNode.cpp:
+ (WebCore::willRemoveChildren):
+
+2014-02-11 Matthew Hanson <[email protected]>
+
Merge r158719.
2013-11-05 Ryosuke Niwa <[email protected]>
Modified: branches/safari-537.75-branch/Source/WebCore/dom/ContainerNode.cpp (163900 => 163901)
--- branches/safari-537.75-branch/Source/WebCore/dom/ContainerNode.cpp 2014-02-11 21:01:20 UTC (rev 163900)
+++ branches/safari-537.75-branch/Source/WebCore/dom/ContainerNode.cpp 2014-02-11 21:12:48 UTC (rev 163901)
@@ -460,8 +460,6 @@
NodeVector children;
getChildNodes(container, children);
- container->document()->nodeChildrenWillBeRemoved(container);
-
ChildListMutationScope mutation(container);
for (NodeVector::const_iterator it = children.begin(); it != children.end(); ++it) {
Node* child = it->get();
@@ -472,6 +470,8 @@
dispatchChildRemovalEvents(child);
}
+ container->document()->nodeChildrenWillBeRemoved(container);
+
ChildFrameDisconnector(container).disconnect(ChildFrameDisconnector::DescendantsOnly);
}