Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2017 18:01:04 +0000 (18:01 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2017 18:01:04 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167853
<rdar://problem/30367302>

Reviewed by Simon Fraser.

Source/WebCore:

Apparently RenderText::canUseSimpleFontCodePath() only checks if the string is qualified for
the simple font code path. However certain css properties could still force us to use the complex
path.
In most cases, we still do only one string traversal thanks to TextRun::setCharacterScanForCodePath().

Test: fast/text/simple-line-layout-simple-text-but-complex-font-path.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseForFontAndText):

LayoutTests:

* fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html: Added.
* fast/text/simple-line-layout-simple-text-but-complex-font-path.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html [new file with mode: 0644]
LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/SimpleLineLayout.cpp

index 453675b..2d05a5a 100644 (file)
@@ -1,5 +1,16 @@
 2017-02-05  Zalan Bujtas  <zalan@apple.com>
 
+        Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
+        https://bugs.webkit.org/show_bug.cgi?id=167853
+        <rdar://problem/30367302>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html: Added.
+        * fast/text/simple-line-layout-simple-text-but-complex-font-path.html: Added.
+
+2017-02-05  Zalan Bujtas  <zalan@apple.com>
+
         Simple line layout: Bail out from Simple Line Layout on surrogate pairs.
         https://bugs.webkit.org/show_bug.cgi?id=167840
         <rdar://problem/30364784>
diff --git a/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html b/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html
new file mode 100644 (file)
index 0000000..4bceb04
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we don't try to use simple line layout for simple text but complex font path related properties.</title>
+</head>
+<body></body>
+</html>
diff --git a/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path.html b/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path.html
new file mode 100644 (file)
index 0000000..5097288
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we don't try to use simple line layout for simple text but complex font path related properties.</title>
+<style>
+div {
+    color: white;      
+}
+.common-ligatures-disabled {
+    font-variant-ligatures: no-common-ligatures;
+}
+
+.common-ligatures-enabled {
+    font-variant-ligatures: common-ligatures;
+}
+</style>
+<script>
+if (window.internals) {
+    internals.settings.setSimpleLineLayoutDebugBordersEnabled(true);
+    internals.settings.setSimpleLineLayoutEnabled(true);
+}
+</script>
+</head>
+<body>
+    <div>
+        <div class="common-ligatures-disabled">file</div>
+        <div class="common-ligatures-enabled">file</div>
+    </div>
+    <div style="text-rendering: optimizelegibility">
+        <div class="common-ligatures-disabled">file</div>
+        <div class="common-ligatures-enabled">file</div>
+    </div>
+</body>
+</html>
index 103481a..b7f343a 100644 (file)
@@ -1,3 +1,21 @@
+2017-02-05  Zalan Bujtas  <zalan@apple.com>
+
+        Simple line layout: Use RenderText::canUseSimpleFontCodePath() only as a hint.
+        https://bugs.webkit.org/show_bug.cgi?id=167853
+        <rdar://problem/30367302>
+
+        Reviewed by Simon Fraser.
+
+        Apparently RenderText::canUseSimpleFontCodePath() only checks if the string is qualified for
+        the simple font code path. However certain css properties could still force us to use the complex
+        path.
+        In most cases, we still do only one string traversal thanks to TextRun::setCharacterScanForCodePath(). 
+
+        Test: fast/text/simple-line-layout-simple-text-but-complex-font-path.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForFontAndText):
+
 2017-02-05  Zan Dobersek  <zdobersek@igalia.com>
 
         Move TextureMapper-specific logic out of GraphicsContext3DPrivate
index 0ca557e..721d75c 100644 (file)
@@ -230,8 +230,15 @@ static AvoidanceReasonFlags canUseForFontAndText(const RenderBlockFlow& flow, In
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextIsTextFragment, reasons, includeReasons);
         if (textRenderer.isSVGInlineText())
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextIsSVGInlineText, reasons, includeReasons);
-        if (!textRenderer.canUseSimpleFontCodePath())
+        if (!textRenderer.canUseSimpleFontCodePath()) {
+            // No need to check the code path at this point. We already know it can't be simple.
             SET_REASON_AND_RETURN_IF_NEEDED(FlowHasComplexFontCodePath, reasons, includeReasons);
+        } else {
+            TextRun run(textRenderer.text());
+            run.setCharacterScanForCodePath(false);
+            if (style.fontCascade().codePath(run) != FontCascade::Simple)
+                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasComplexFontCodePath, reasons, includeReasons);
+        }
 
         auto textReasons = canUseForText(textRenderer.stringView(), fontCascade, lineHeightConstraint, flowIsJustified, includeReasons);
         if (textReasons != NoReason)