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.
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: http://svn.webkit.org/repository/webkit/trunk@211682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 453675b..2d05a5a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -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
index 0000000..4bceb04
--- /dev/null
+++ b/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path-expected.html
@@ -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
index 0000000..5097288
--- /dev/null
+++ b/LayoutTests/fast/text/simple-line-layout-simple-text-but-complex-font-path.html
@@ -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>
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 103481a..b7f343a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -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
diff --git a/Source/WebCore/rendering/SimpleLineLayout.cpp b/Source/WebCore/rendering/SimpleLineLayout.cpp
index 0ca557e..721d75c 100644
--- a/Source/WebCore/rendering/SimpleLineLayout.cpp
+++ b/Source/WebCore/rendering/SimpleLineLayout.cpp
@@ -230,8 +230,15 @@
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)