Title: [210948] trunk
Revision
210948
Author
[email protected]
Date
2017-01-19 18:52:34 -0800 (Thu, 19 Jan 2017)

Log Message

Simple line layout: Extend coverage for justified content.
https://bugs.webkit.org/show_bug.cgi?id=167219
<rdar://problem/30108391>

Reviewed by Antti Koivisto.

Source/WebCore:

Add support for general punctuation characters (0x2010, 0x2027) and latin characters including Extended-B.

Test: fast/text/simple-line-layout-with-justified-punctuation.html

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

LayoutTests:

* fast/text/simple-line-layout-with-justified-punctuation-expected.html: Added.
* fast/text/simple-line-layout-with-justified-punctuation.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210947 => 210948)


--- trunk/LayoutTests/ChangeLog	2017-01-20 02:38:45 UTC (rev 210947)
+++ trunk/LayoutTests/ChangeLog	2017-01-20 02:52:34 UTC (rev 210948)
@@ -1,3 +1,14 @@
+2017-01-19  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Extend coverage for justified content.
+        https://bugs.webkit.org/show_bug.cgi?id=167219
+        <rdar://problem/30108391>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/simple-line-layout-with-justified-punctuation-expected.html: Added.
+        * fast/text/simple-line-layout-with-justified-punctuation.html: Added.
+
 2017-01-19  Jer Noble  <[email protected]>
 
         CRASH at WebCore::TrackListBase::remove

Added: trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation-expected.html (0 => 210948)


--- trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation-expected.html	2017-01-20 02:52:34 UTC (rev 210948)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>This tests that we renderer justified punctuation content correctly with simple line layout</title>
+<style>
+div {
+    text-align: justify;
+    width: 200px;
+}
+</style>
+<script>
+if (window.internals)
+    internals.settings.setSimpleLineLayoutEnabled(false);
+</script>
+</head>
+<body>
+<div>foobar &#x2010; foobar &#x2011; foobar &#x2012; foobar &#x2013;</div>
+<div>foobar &#x2014; foobar &#x2015; foobar &#x2016; foobar &#x2017;</div>
+<div>foobar &#x2018; foobar &#x2019; foobar &#x201A; foobar &#x201B;</div>
+<div>foobar &#x201C; foobar &#x201D; foobar &#x201E; foobar &#x201F;</div>
+<div>foobar &#x2020; foobar &#x2021; foobar &#x2022; foobar &#x2023;</div>
+<div>foobar &#x2024; foobar &#x2025; foobar &#x2026; foobar &#x2027;</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation.html (0 => 210948)


--- trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-with-justified-punctuation.html	2017-01-20 02:52:34 UTC (rev 210948)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>This tests that we renderer justified punctuation content correctly with simple line layout</title>
+<style>
+div {
+    text-align: justify;
+    width: 200px;
+} 
+</style>
+</head>
+<body>
+<div>foobar &#x2010; foobar &#x2011; foobar &#x2012; foobar &#x2013;</div>
+<div>foobar &#x2014; foobar &#x2015; foobar &#x2016; foobar &#x2017;</div>
+<div>foobar &#x2018; foobar &#x2019; foobar &#x201A; foobar &#x201B;</div>
+<div>foobar &#x201C; foobar &#x201D; foobar &#x201E; foobar &#x201F;</div>
+<div>foobar &#x2020; foobar &#x2021; foobar &#x2022; foobar &#x2023;</div>
+<div>foobar &#x2024; foobar &#x2025; foobar &#x2026; foobar &#x2027;</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (210947 => 210948)


--- trunk/Source/WebCore/ChangeLog	2017-01-20 02:38:45 UTC (rev 210947)
+++ trunk/Source/WebCore/ChangeLog	2017-01-20 02:52:34 UTC (rev 210948)
@@ -1,3 +1,19 @@
+2017-01-19  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Extend coverage for justified content.
+        https://bugs.webkit.org/show_bug.cgi?id=167219
+        <rdar://problem/30108391>
+
+        Reviewed by Antti Koivisto.
+
+        Add support for general punctuation characters (0x2010, 0x2027) and latin characters including Extended-B.
+
+        Test: fast/text/simple-line-layout-with-justified-punctuation.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForText):
+        (WebCore::SimpleLineLayout::canUseForFontAndText):
+
 2017-01-19  Alex Christensen  <[email protected]>
 
         Construct URLSearchParams from array or object

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (210947 => 210948)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-20 02:38:45 UTC (rev 210947)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-20 02:52:34 UTC (rev 210948)
@@ -136,7 +136,7 @@
 #endif
 
 template <typename CharacterType>
-static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, IncludeReasons includeReasons)
+static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
 {
     AvoidanceReasonFlags reasons = { };
     // FIXME: <textarea maxlength=0> generates empty text node.
@@ -148,6 +148,14 @@
         if (character == ' ')
             continue;
 
+        if (textIsJustified) {
+            // Include characters up to Latin Extended-B and some punctuation range when text is justified.
+            bool isLatinIncludingExtendedB = character <= 0x01FF;
+            bool isPunctuationRange = character >= 0x2010 && character <= 0x2027;
+            if (!(isLatinIncludingExtendedB || isPunctuationRange))
+                SET_REASON_AND_RETURN_IF_NEEDED(FlowHasJustifiedNonLatinText, reasons, includeReasons);
+        }
+
         // These would be easy to support.
         if (character == noBreakSpace)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasNoBreakSpace, reasons, includeReasons);
@@ -167,11 +175,11 @@
     return reasons;
 }
 
-static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, IncludeReasons includeReasons)
+static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
 {
     if (textRenderer.is8Bit())
-        return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, includeReasons);
-    return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, includeReasons);
+        return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, false, includeReasons);
+    return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, textIsJustified, includeReasons);
 }
 
 static AvoidanceReasonFlags canUseForFontAndText(const RenderBlockFlow& flow, IncludeReasons includeReasons)
@@ -183,9 +191,8 @@
     if (primaryFont.isLoading())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsMissingPrimaryFont, reasons, includeReasons);
 
+    bool flowIsJustified = style.textAlign() == JUSTIFY;
     for (const auto& textRenderer : childrenOfType<RenderText>(flow)) {
-        if (style.textAlign() == JUSTIFY && !textRenderer.originalText().containsOnlyLatin1())
-            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasJustifiedNonLatinText, reasons, includeReasons);
         if (textRenderer.isCombineText())
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextIsCombineText, reasons, includeReasons);
         if (textRenderer.isCounter())
@@ -199,7 +206,7 @@
         if (style.fontCascade().codePath(TextRun(textRenderer.text())) != FontCascade::Simple)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowFontIsNotSimple, reasons, includeReasons);
 
-        auto textReasons = canUseForText(textRenderer, primaryFont, includeReasons);
+        auto textReasons = canUseForText(textRenderer, primaryFont, flowIsJustified, includeReasons);
         if (textReasons != NoReason)
             SET_REASON_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to