ASSERTION FAILED: !simpleLineLayout() in WebCore::RenderText::collectSelectionRectsFo...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 07:31:28 +0000 (07:31 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Dec 2015 07:31:28 +0000 (07:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152115

Reviewed by Simon Fraser.

document.execCommand("indent") generates a blockquote wrapper and moves the indented content inside.
If the indented content is already inside a selection, we need to make sure that newly created flow uses
normal line layout.
This patch fixes the generic case as re-parenting an already selected renderer is not specific to document.execCommand("indent").

Source/WebCore:

Test: fast/block/selection-inside-simple-line-layout.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForWithReason):
(WebCore::SimpleLineLayout::printReason):

LayoutTests:

* fast/block/selection-inside-simple-line-layout-expected.txt: Added.
* fast/block/selection-inside-simple-line-layout.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/selection-inside-simple-line-layout-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/selection-inside-simple-line-layout.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayout.cpp

index 99d5af8..ddb85b7 100644 (file)
@@ -1,3 +1,18 @@
+2015-12-10  Zalan Bujtas  <zalan@apple.com>
+
+        ASSERTION FAILED: !simpleLineLayout() in WebCore::RenderText::collectSelectionRectsForLineBoxes
+        https://bugs.webkit.org/show_bug.cgi?id=152115
+
+        Reviewed by Simon Fraser.
+
+        document.execCommand("indent") generates a blockquote wrapper and moves the indented content inside.
+        If the indented content is already inside a selection, we need to make sure that newly created flow uses
+        normal line layout.
+        This patch fixes the generic case as re-parenting an already selected renderer is not specific to document.execCommand("indent").
+
+        * fast/block/selection-inside-simple-line-layout-expected.txt: Added.
+        * fast/block/selection-inside-simple-line-layout.html: Added.
+
 2015-12-10  Brady Eidson  <beidson@apple.com>
 
         Unreviewed TestExpectations gardening.
diff --git a/LayoutTests/fast/block/selection-inside-simple-line-layout-expected.txt b/LayoutTests/fast/block/selection-inside-simple-line-layout-expected.txt
new file mode 100644 (file)
index 0000000..e7b5867
--- /dev/null
@@ -0,0 +1,2 @@
+Pass if no assert in debug.
+b
diff --git a/LayoutTests/fast/block/selection-inside-simple-line-layout.html b/LayoutTests/fast/block/selection-inside-simple-line-layout.html
new file mode 100644 (file)
index 0000000..401f865
--- /dev/null
@@ -0,0 +1,10 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+window.onload = function() {
+    document.designMode = 'on';
+    document.execCommand('selectAll');
+    document.execCommand('indent');
+}
+</script>
+<ol><li></li></ol>Pass if no assert in debug.<div>b</div>
index 5d16a10..98f21b4 100644 (file)
@@ -1,3 +1,21 @@
+2015-12-10  Zalan Bujtas  <zalan@apple.com>
+
+        ASSERTION FAILED: !simpleLineLayout() in WebCore::RenderText::collectSelectionRectsForLineBoxes
+        https://bugs.webkit.org/show_bug.cgi?id=152115
+
+        Reviewed by Simon Fraser.
+
+        document.execCommand("indent") generates a blockquote wrapper and moves the indented content inside.
+        If the indented content is already inside a selection, we need to make sure that newly created flow uses
+        normal line layout.
+        This patch fixes the generic case as re-parenting an already selected renderer is not specific to document.execCommand("indent").
+
+        Test: fast/block/selection-inside-simple-line-layout.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForWithReason):
+        (WebCore::SimpleLineLayout::printReason):
+
 2015-12-10  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Expose media capture devices persistent permissions to WebCore
index af699e3..7daa65d 100644 (file)
@@ -110,7 +110,8 @@ enum AvoidanceReason_ : uint64_t {
     FeatureIsDisabled                   = 1LLU  << 46,
     FlowHasNoParent                     = 1LLU  << 47,
     FlowHasNoChild                      = 1LLU  << 48,
-    EndOfReasons                        = 1LLU  << 49
+    FlowChildIsSelected                 = 1LLU  << 49,
+    EndOfReasons                        = 1LLU  << 50
 };
 const unsigned NoReason = 0;
 
@@ -301,6 +302,8 @@ static AvoidanceReasonFlags canUseForWithReason(const RenderBlockFlow& flow, Inc
     // This currently covers <blockflow>#text</blockflow>, <blockflow>#text<br></blockflow> and mutiple (sibling) RenderText cases.
     // The <blockflow><inline>#text</inline></blockflow> case is also popular and should be relatively easy to cover.
     for (const auto* child = flow.firstChild(); child;) {
+        if (child->selectionState() != RenderObject::SelectionNone)
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
         if (is<RenderText>(*child)) {
             child = child->nextSibling();
             continue;
@@ -917,6 +920,9 @@ static void printReason(AvoidanceReason reason, TextStream& stream)
     case FlowHasTextShadow:
         stream << "text-shadow";
         break;
+    case FlowChildIsSelected:
+        stream << "selected content";
+        break;
     case FlowTextIsEmpty:
     case FlowHasNoChild:
     case FlowHasNoParent: