REGRESSION (r167652): SelectionState is not set properly for non leaf objects in...
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2014 08:05:58 +0000 (08:05 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 May 2014 08:05:58 +0000 (08:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132493

Reviewed by David Hyatt.

Source/WebCore:
Non selection leaf elements were not included in the selection ranges,
that was causing that their selection state was not set properly and
when one of the element was removed as it was marked as SelectionNone
current selection was not removed.

Due to this fix, the regression detected in bug #131982 arose again.
Reverted changes from r167675 and reopened bug as previous fix was not
right. Updated TestExpectations accordingly.

Test: fast/regions/selection/crash-select-all.html

* rendering/RenderView.cpp:
(WebCore::RenderView::splitSelectionBetweenSubtrees): We need to include
non selection leafs in the range, otherwise we won't be marking
selection state of some elements properly.

LayoutTests:
* TestExpectations: Marked
fast/regions/cssom/region-range-for-box-crash.html as crashing on
debug due to regression detected in bug #131982.
* fast/regions/selection/crash-select-all-expected.txt: Added.
* fast/regions/selection/crash-select-all.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/regions/selection/crash-select-all-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/selection/crash-select-all.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderView.cpp

index 3987607..252bfcf 100644 (file)
@@ -1,3 +1,16 @@
+2014-05-08  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        REGRESSION (r167652): SelectionState is not set properly for non leaf objects in pages with regions
+        https://bugs.webkit.org/show_bug.cgi?id=132493
+
+        Reviewed by David Hyatt.
+
+        * TestExpectations: Marked
+        fast/regions/cssom/region-range-for-box-crash.html as crashing on
+        debug due to regression detected in bug #131982.
+        * fast/regions/selection/crash-select-all-expected.txt: Added.
+        * fast/regions/selection/crash-select-all.html: Added.
+
 2014-05-08  Zoltan Horvath  <zoltan@webkit.org>
 
         [CSS Shapes] Can't select content within the area of the floating box when clip-path is applied
index 530330c..a4991ad 100644 (file)
@@ -114,3 +114,6 @@ webkit.org/b/132421 fast/multicol/fixed-stack.html [ ImageOnlyFailure ]
 # These tests are incorrect in the CSS test suite and should be fixed there first.
 css2.1/20110323/replaced-intrinsic-001.htm [ Failure ]
 css2.1/20110323/replaced-intrinsic-002.htm [ Failure ]
+
+# Regression from r167652:
+webkit.org/b/131982 [ Debug ] fast/regions/cssom/region-range-for-box-crash.html [ Crash ]
diff --git a/LayoutTests/fast/regions/selection/crash-select-all-expected.txt b/LayoutTests/fast/regions/selection/crash-select-all-expected.txt
new file mode 100644 (file)
index 0000000..f7450bd
--- /dev/null
@@ -0,0 +1,3 @@
+Bug 132493: REGRESSION (r167652): SelectionState is not set properly for non leaf objects in pages with regions
+
+This test has PASSED if it doesn't CRASH in debug.
diff --git a/LayoutTests/fast/regions/selection/crash-select-all.html b/LayoutTests/fast/regions/selection/crash-select-all.html
new file mode 100644 (file)
index 0000000..32c58b9
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<head>
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+</script>
+<style>
+    .region { -webkit-flow-from: no-flow; }
+    .border { border: solid; }
+</style>
+</head>
+<body>
+    <div id="div" class="region border"></div>
+    <div class="region border"></div>
+    <p><a href="https://bugs.webkit.org/show_bug.cgi?id=132493">Bug 132493</a>: REGRESSION (r167652): SelectionState is not set properly for non leaf objects in pages with regions</p>
+    <p>This test has PASSED if it doesn't CRASH in debug.</p>
+    <script>
+        document.execCommand("SelectAll");
+        var elem = document.getElementById("div");
+        elem.removeAttribute("class");
+    </script>
+</body>
+</html>
index c1e1442..54ccbcc 100644 (file)
@@ -1,3 +1,26 @@
+2014-05-08  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        REGRESSION (r167652): SelectionState is not set properly for non leaf objects in pages with regions
+        https://bugs.webkit.org/show_bug.cgi?id=132493
+
+        Reviewed by David Hyatt.
+
+        Non selection leaf elements were not included in the selection ranges,
+        that was causing that their selection state was not set properly and
+        when one of the element was removed as it was marked as SelectionNone
+        current selection was not removed.
+
+        Due to this fix, the regression detected in bug #131982 arose again.
+        Reverted changes from r167675 and reopened bug as previous fix was not
+        right. Updated TestExpectations accordingly.
+
+        Test: fast/regions/selection/crash-select-all.html
+
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::splitSelectionBetweenSubtrees): We need to include
+        non selection leafs in the range, otherwise we won't be marking
+        selection state of some elements properly.
+
 2014-05-08  Zoltan Horvath  <zoltan@webkit.org>
 
         [CSS Shapes] Can't select content within the area of the floating box when clip-path is applied
index 99bdd53..71bcb59 100644 (file)
@@ -844,7 +844,7 @@ void RenderView::splitSelectionBetweenSubtrees(RenderObject* start, int startPos
         renderSubtreesMap.set(namedFlowThread, nullptr);
 
     if (start && end) {
-        RefPtr<Range> initialRange = Range::create(document(), start->node(), 0, end->node(), 0);
+        RefPtr<Range> initialRange = Range::create(document(), start->node(), startPos, end->node(), endPos);
 
         Node* startNode = initialRange->startContainer();
         Node* endNode = initialRange->endContainer();
@@ -852,7 +852,7 @@ void RenderView::splitSelectionBetweenSubtrees(RenderObject* start, int startPos
 
         for (Node* node = startNode; node != stopNode; node = NodeTraversal::next(node)) {
             RenderObject* renderer = node->renderer();
-            if (!renderer || !renderer->canBeSelectionLeaf())
+            if (!renderer)
                 continue;
 
             SelectionSubtreeRoot& root = renderer->selectionRoot();