REGRESSION(r230914) Selecting text on this apple.com page makes it vanish
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Apr 2018 23:16:42 +0000 (23:16 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Apr 2018 23:16:42 +0000 (23:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185142
<rdar://problem/39821446>

Reviewed by Simon Fraser.

Source/WebCore:

Set the overflow rect on the inline textbox when needed.

Test: fast/text/simple-line-layout-selection-with-overflow.html

* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::initializeInlineTextBox):
(WebCore::SimpleLineLayout::generateLineBoxTree):
(WebCore::SimpleLineLayout::initializeInlineBox): Deleted.

LayoutTests:

* fast/text/simple-line-layout-selection-with-overflow-expected.html: Added.
* fast/text/simple-line-layout-selection-with-overflow.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/simple-line-layout-selection-with-overflow-expected.html [new file with mode: 0644]
LayoutTests/fast/text/simple-line-layout-selection-with-overflow.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp

index 455af94cb667739e26b782487f1f55abba485a64..b7a5131bd9eaad88c9feed07568d92bb25cc93ab 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-30  Zalan Bujtas  <zalan@apple.com>
+
+        REGRESSION(r230914) Selecting text on this apple.com page makes it vanish
+        https://bugs.webkit.org/show_bug.cgi?id=185142
+        <rdar://problem/39821446>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/simple-line-layout-selection-with-overflow-expected.html: Added.
+        * fast/text/simple-line-layout-selection-with-overflow.html: Added.
+
 2018-04-30  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Extra zoom mode] Respect the existing shrink-to-fit attribute instead of using min-device-width
diff --git a/LayoutTests/fast/text/simple-line-layout-selection-with-overflow-expected.html b/LayoutTests/fast/text/simple-line-layout-selection-with-overflow-expected.html
new file mode 100644 (file)
index 0000000..8cf4514
--- /dev/null
@@ -0,0 +1,17 @@
+<style>
+body{
+    letter-spacing: -1px;
+    font-height: 10px;
+}
+</style>
+<div id=textWithLetterSpacing>Pass if text does not disappear after the range selection.</div>
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+document.body.offsetHeight;
+
+var range = document.createRange();
+range.setStart(textWithLetterSpacing.firstChild, 0);
+range.setEnd(textWithLetterSpacing.firstChild, 5);
+window.getSelection().addRange(range);
+</script>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/simple-line-layout-selection-with-overflow.html b/LayoutTests/fast/text/simple-line-layout-selection-with-overflow.html
new file mode 100644 (file)
index 0000000..0256204
--- /dev/null
@@ -0,0 +1,15 @@
+<style>
+div {
+    letter-spacing: -1px;
+    font-height: 10px;
+}
+</style>
+<div id=textWithLetterSpacing>Pass if text does not disappear after the range selection.</div>
+<script>
+document.body.offsetHeight;
+
+var range = document.createRange();
+range.setStart(textWithLetterSpacing.firstChild, 0);
+range.setEnd(textWithLetterSpacing.firstChild, 5);
+window.getSelection().addRange(range);
+</script>
\ No newline at end of file
index 895e2ef9312b218c2c6b621c7208ec1646ab2b6b..2612b06ae8f6c0aa0fc774fe4baf3cada756058d 100644 (file)
@@ -1,3 +1,20 @@
+2018-04-30  Zalan Bujtas  <zalan@apple.com>
+
+        REGRESSION(r230914) Selecting text on this apple.com page makes it vanish
+        https://bugs.webkit.org/show_bug.cgi?id=185142
+        <rdar://problem/39821446>
+
+        Reviewed by Simon Fraser.
+
+        Set the overflow rect on the inline textbox when needed.
+
+        Test: fast/text/simple-line-layout-selection-with-overflow.html
+
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::initializeInlineTextBox):
+        (WebCore::SimpleLineLayout::generateLineBoxTree):
+        (WebCore::SimpleLineLayout::initializeInlineBox): Deleted.
+
 2018-04-30  JF Bastien  <jfbastien@apple.com>
 
         Use some C++17 features
index 83321b08f65a2d0fbb756de349e85ba3e832736f..faf46ccb641e4180f53db1783e3f8ae6f8ad11c4 100644 (file)
@@ -292,22 +292,25 @@ bool canUseForLineBoxTree(RenderBlockFlow& flow, const Layout& layout)
     return true;
 }
 
-static void initializeInlineBox(InlineBox& inlineBox, const RunResolver::Run& run)
+static void initializeInlineTextBox(RenderBlockFlow& flow, InlineTextBox& inlineTextBox, const RunResolver::Run& run)
 {
-    inlineBox.setLogicalLeft(run.logicalLeft());
-    inlineBox.setLogicalTop(run.rect().y());
-    inlineBox.setLogicalWidth(run.logicalRight() - run.logicalLeft());
+    inlineTextBox.setLogicalLeft(run.logicalLeft());
+    inlineTextBox.setLogicalTop(run.rect().y());
+    inlineTextBox.setLogicalWidth(run.logicalRight() - run.logicalLeft());
+    auto overflowRect = computeOverflow(const_cast<RenderBlockFlow&>(flow), run.rect());
+    if (overflowRect != run.rect())
+        inlineTextBox.setLogicalOverflowRect(LayoutRect(overflowRect));
 
-    inlineBox.setHasHyphen(run.hasHyphen());
-    inlineBox.setExpansionWithoutGrowing(run.expansion());
+    inlineTextBox.setHasHyphen(run.hasHyphen());
+    inlineTextBox.setExpansionWithoutGrowing(run.expansion());
 
     auto expansionBehavior = run.expansionBehavior();
-    inlineBox.setCanHaveLeadingExpansion(expansionBehavior & AllowLeadingExpansion);
-    inlineBox.setCanHaveTrailingExpansion(expansionBehavior & AllowTrailingExpansion);
+    inlineTextBox.setCanHaveLeadingExpansion(expansionBehavior & AllowLeadingExpansion);
+    inlineTextBox.setCanHaveTrailingExpansion(expansionBehavior & AllowTrailingExpansion);
     if (expansionBehavior & ForceTrailingExpansion)
-        inlineBox.setForceTrailingExpansion();
+        inlineTextBox.setForceTrailingExpansion();
     if (expansionBehavior & ForceLeadingExpansion)
-        inlineBox.setForceLeadingExpansion();
+        inlineTextBox.setForceLeadingExpansion();
 }
 
 void generateLineBoxTree(RenderBlockFlow& flow, const Layout& layout)
@@ -348,7 +351,7 @@ void generateLineBoxTree(RenderBlockFlow& flow, const Layout& layout)
         // Set the geometry for the inlineboxes.
         for (auto* inlineBox = rootLineBox.firstChild(); inlineBox && it != range.end(); inlineBox = inlineBox->nextOnLine(), ++it) {
             auto run = *it;
-            initializeInlineBox(*inlineBox, run);
+            initializeInlineTextBox(flow, downcast<InlineTextBox>(*inlineBox), run);
             lineWidth += inlineBox->logicalWidth();
         }