[Simple line layout] Turn off inline boxtree generation for multiline content
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 20:26:49 +0000 (20:26 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 20:26:49 +0000 (20:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196404
<rdar://problem/49234033>

Reviewed by Simon Fraser.

Source/WebCore:

Currently simple line layout can't provide the correct line breaking context to the inline tree when the boxtree is
generated using the simple line runs. This patch limits the generation of such trees to single lines. Multiline content will
go through the "let's layout this content again" codepath.
This patch fixes disappearing content on Questar.

Test: fast/text/simple-line-layout-and-multiline-inlineboxtree.html

* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::canUseForLineBoxTree):

LayoutTests:

* fast/text/simple-line-layout-and-multiline-inlineboxtree-expected.html: Added.
* fast/text/simple-line-layout-and-multiline-inlineboxtree.html: Added.

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

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

index 5571aaa..31dab5c 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-29  Zalan Bujtas  <zalan@apple.com>
+
+        [Simple line layout] Turn off inline boxtree generation for multiline content
+        https://bugs.webkit.org/show_bug.cgi?id=196404
+        <rdar://problem/49234033>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/simple-line-layout-and-multiline-inlineboxtree-expected.html: Added.
+        * fast/text/simple-line-layout-and-multiline-inlineboxtree.html: Added.
+
 2019-03-29  Shawn Roberts  <sroberts@apple.com>
 
         imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html is a flaky failure
diff --git a/LayoutTests/fast/text/simple-line-layout-and-multiline-inlineboxtree-expected.html b/LayoutTests/fast/text/simple-line-layout-and-multiline-inlineboxtree-expected.html
new file mode 100644 (file)
index 0000000..1c69bd9
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we can reconstruct the line tree when a dynamic change is triggered on the block after switching out of simple line layout.</title>
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(true);
+</script>
+</head>
+<body>
+<div id=container style="width: 200px;">
+This long long long long long text should not get cut off after "extra text" is added to the end. extra text
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/simple-line-layout-and-multiline-inlineboxtree.html b/LayoutTests/fast/text/simple-line-layout-and-multiline-inlineboxtree.html
new file mode 100644 (file)
index 0000000..50dba35
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we can reconstruct the line tree when a dynamic change is triggered on the block after switching out of simple line layout.</title>
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(true);
+</script>
+</head>
+<body>
+<div id=container style="width: 200px;">
+This long long long long long text should not get cut off after "extra text" is added to the end.
+</div>
+<script>
+const selection = window.getSelection();
+const range = document.createRange();
+range.selectNodeContents(container);
+selection.addRange(range);
+document.body.offsetHeight;
+selection.removeAllRanges();
+document.body.offsetHeight;
+
+let span = document.createElement("span");
+span.innerText = "extra text";
+container.appendChild(span);
+</script>
+</body>
+</html>
index 00d5884..60bdf0b 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-29  Zalan Bujtas  <zalan@apple.com>
+
+        [Simple line layout] Turn off inline boxtree generation for multiline content
+        https://bugs.webkit.org/show_bug.cgi?id=196404
+        <rdar://problem/49234033>
+
+        Reviewed by Simon Fraser.
+
+        Currently simple line layout can't provide the correct line breaking context to the inline tree when the boxtree is
+        generated using the simple line runs. This patch limits the generation of such trees to single lines. Multiline content will
+        go through the "let's layout this content again" codepath.
+        This patch fixes disappearing content on Questar.
+
+        Test: fast/text/simple-line-layout-and-multiline-inlineboxtree.html
+
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::canUseForLineBoxTree):
+
 2019-03-29  Justin Fan  <justin_fan@apple.com>
 
         [Web GPU] Replace unsigned longs in WebGPU with uint64_t
index 66e9502..1848e58 100644 (file)
@@ -285,6 +285,10 @@ void simpleLineLayoutWillBeDeleted(const Layout& layout)
 
 bool canUseForLineBoxTree(RenderBlockFlow& flow, const Layout& layout)
 {
+    // Line breaking requires some context that SLL can't provide at the moment (see RootInlineBox::setLineBreakInfo).
+    if (layout.lineCount() > 1)
+        return false;
+
     if (layout.isPaginated())
         return false;