Title: [229695] trunk
Revision
229695
Author
[email protected]
Date
2018-03-16 23:44:40 -0700 (Fri, 16 Mar 2018)

Log Message

Correct debug assertion in Range::borderAndTextRects
https://bugs.webkit.org/show_bug.cgi?id=183710
<rdar://problem/38466976>

Reviewed by Ryosuke Niwa.

Source/WebCore:

A debug assertion will fire if Range::borderAndTextRects is asked to evaluate a set of selected elements, where one of the elements does not have a parent.

We should consider a nullptr parent as satisfying the condition of a parent not being present in the selection set.

Tests: fast/dom/range/range-selection-empty-body.html

* dom/Range.cpp:
(WebCore::Range::borderAndTextRects const):

LayoutTests:

* fast/dom/Range/range-selection-empty-body-expected.txt: Added.
* fast/dom/Range/range-selection-empty-body.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (229694 => 229695)


--- trunk/LayoutTests/ChangeLog	2018-03-17 06:11:00 UTC (rev 229694)
+++ trunk/LayoutTests/ChangeLog	2018-03-17 06:44:40 UTC (rev 229695)
@@ -1,3 +1,14 @@
+2018-03-16  Brent Fulgham  <[email protected]>
+
+        Correct debug assertion in Range::borderAndTextRects
+        https://bugs.webkit.org/show_bug.cgi?id=183710
+        <rdar://problem/38466976>
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/dom/Range/range-selection-empty-body-expected.txt: Added.
+        * fast/dom/Range/range-selection-empty-body.html: Added.
+
 2018-03-16  Youenn Fablet  <[email protected]>
 
         Add a test verifying that an AppCache manifest request includes credentials

Added: trunk/LayoutTests/fast/dom/Range/range-selection-empty-body-expected.txt (0 => 229695)


--- trunk/LayoutTests/fast/dom/Range/range-selection-empty-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/range-selection-empty-body-expected.txt	2018-03-17 06:44:40 UTC (rev 229695)
@@ -0,0 +1 @@
+Test passes if it does not ASSERT.

Added: trunk/LayoutTests/fast/dom/Range/range-selection-empty-body.html (0 => 229695)


--- trunk/LayoutTests/fast/dom/Range/range-selection-empty-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Range/range-selection-empty-body.html	2018-03-17 06:44:40 UTC (rev 229695)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function runTest()
+{
+    var newBody = document.createElement("body");
+    var docRange = document.createRange();
+    docRange.selectNodeContents(newBody);
+    var boundingRect = docRange.getBoundingClientRect();
+}
+</script>
+</head>
+<body _onload_=runTest()>
+Test passes if it does not ASSERT.
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (229694 => 229695)


--- trunk/Source/WebCore/ChangeLog	2018-03-17 06:11:00 UTC (rev 229694)
+++ trunk/Source/WebCore/ChangeLog	2018-03-17 06:44:40 UTC (rev 229695)
@@ -1,3 +1,20 @@
+2018-03-16  Brent Fulgham  <[email protected]>
+
+        Correct debug assertion in Range::borderAndTextRects
+        https://bugs.webkit.org/show_bug.cgi?id=183710
+        <rdar://problem/38466976>
+
+        Reviewed by Ryosuke Niwa.
+
+        A debug assertion will fire if Range::borderAndTextRects is asked to evaluate a set of selected elements, where one of the elements does not have a parent.
+
+        We should consider a nullptr parent as satisfying the condition of a parent not being present in the selection set.
+
+        Tests: fast/dom/range/range-selection-empty-body.html
+
+        * dom/Range.cpp:
+        (WebCore::Range::borderAndTextRects const):
+
 2018-03-15  Filip Pizlo  <[email protected]>
 
         Put the DOM in IsoHeaps

Modified: trunk/Source/WebCore/dom/Range.cpp (229694 => 229695)


--- trunk/Source/WebCore/dom/Range.cpp	2018-03-17 06:11:00 UTC (rev 229694)
+++ trunk/Source/WebCore/dom/Range.cpp	2018-03-17 06:44:40 UTC (rev 229695)
@@ -1823,7 +1823,7 @@
         selectedElementsSet.remove(parent);
 
     for (Node* node = firstNode(); node != stopNode; node = NodeTraversal::next(*node)) {
-        if (is<Element>(*node) && selectedElementsSet.contains(node) && !selectedElementsSet.contains(node->parentNode())) {
+        if (is<Element>(*node) && selectedElementsSet.contains(node) && (!node->parentNode() || !selectedElementsSet.contains(node->parentNode()))) {
             if (auto* renderer = downcast<Element>(*node).renderBoxModelObject()) {
                 Vector<FloatQuad> elementQuads;
                 renderer->absoluteQuads(elementQuads);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to