Title: [211292] trunk
Revision
211292
Author
[email protected]
Date
2017-01-27 11:24:26 -0800 (Fri, 27 Jan 2017)

Log Message

Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
https://bugs.webkit.org/show_bug.cgi?id=167481
<rdar://problem/30180150>

Reviewed by Antti Koivisto.

Source/WebCore:

Since -webkit-line-box-contain: glyphs requires variable line height support, we can use simple line layout
only when each line happen to have the same height ('block' property value is set, glyphs do not overflow the block line height).

Test: fast/text/simple-line-layout-line-box-contain-glyphs.html

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

LayoutTests:

* fast/text/simple-line-layout-line-box-contain-glyphs-expected.html: Added.
* fast/text/simple-line-layout-line-box-contain-glyphs.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211291 => 211292)


--- trunk/LayoutTests/ChangeLog	2017-01-27 19:14:57 UTC (rev 211291)
+++ trunk/LayoutTests/ChangeLog	2017-01-27 19:24:26 UTC (rev 211292)
@@ -1,3 +1,14 @@
+2017-01-27  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
+        https://bugs.webkit.org/show_bug.cgi?id=167481
+        <rdar://problem/30180150>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/text/simple-line-layout-line-box-contain-glyphs-expected.html: Added.
+        * fast/text/simple-line-layout-line-box-contain-glyphs.html: Added.
+
 2017-01-27  Devin Rousso  <[email protected]>
 
         Styles should not show background-repeat-x/y, or -webkit-mask-repeat-x/y

Added: trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs-expected.html (0 => 211292)


--- trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs-expected.html	2017-01-27 19:24:26 UTC (rev 211292)
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+<head>
+<title>This tests that we don't use simple line layout when webkit-line-box-contain: glyphs is set and the glyphs overflow the line vertically.</title>
+<style>
+div {
+  -webkit-line-box-contain: glyphs;
+  line-height: 10px;
+}
+</style>
+<script>
+  if (window.internals)
+    internals.settings.setSimpleLineLayoutDebugBordersEnabled(false);
+</script>
+</head>
+<body>
+<div>foobar</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs.html (0 => 211292)


--- trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/simple-line-layout-line-box-contain-glyphs.html	2017-01-27 19:24:26 UTC (rev 211292)
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+<head>
+<title>This tests that we don't use simple line layout when webkit-line-box-contain: glyphs is set and the glyphs overflow the line vertically.</title>
+<style>
+div {
+  -webkit-line-box-contain: glyphs;
+  line-height: 10px;
+}
+</style>
+<script>
+  if (window.internals)
+    internals.settings.setSimpleLineLayoutDebugBordersEnabled(true);
+</script>
+</head>
+<body>
+<div>foobar</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (211291 => 211292)


--- trunk/Source/WebCore/ChangeLog	2017-01-27 19:14:57 UTC (rev 211291)
+++ trunk/Source/WebCore/ChangeLog	2017-01-27 19:24:26 UTC (rev 211292)
@@ -1,3 +1,22 @@
+2017-01-27  Zalan Bujtas  <[email protected]>
+
+        Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
+        https://bugs.webkit.org/show_bug.cgi?id=167481
+        <rdar://problem/30180150>
+
+        Reviewed by Antti Koivisto.
+
+        Since -webkit-line-box-contain: glyphs requires variable line height support, we can use simple line layout
+        only when each line happen to have the same height ('block' property value is set, glyphs do not overflow the block line height).  
+
+        Test: fast/text/simple-line-layout-line-box-contain-glyphs.html
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseForText):
+        (WebCore::SimpleLineLayout::canUseForFontAndText):
+        (WebCore::SimpleLineLayout::canUseForStyle):
+        (WebCore::SimpleLineLayout::printReason):
+
 2017-01-27  Chris Dumez  <[email protected]>
 
         Fix PageCache diagnostic logging

Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (211291 => 211292)


--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-27 19:14:57 UTC (rev 211291)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp	2017-01-27 19:24:26 UTC (rev 211292)
@@ -112,7 +112,8 @@
     FlowHasNoChild                        = 1LLU  << 46,
     FlowChildIsSelected                   = 1LLU  << 47,
     FlowHasHangingPunctuation             = 1LLU  << 48,
-    EndOfReasons                          = 1LLU  << 49
+    FlowFontHasOverflowGlyph              = 1LLU  << 49,
+    EndOfReasons                          = 1LLU  << 50
 };
 const unsigned NoReason = 0;
 
@@ -136,7 +137,8 @@
 #endif
 
 template <typename CharacterType>
-static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
+static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, std::optional<float> lineHeightConstraint,
+    bool textIsJustified, IncludeReasons includeReasons)
 {
     AvoidanceReasonFlags reasons = { };
     // FIXME: <textarea maxlength=0> generates empty text node.
@@ -166,17 +168,20 @@
             || direction == U_POP_DIRECTIONAL_FORMAT || direction == U_BOUNDARY_NEUTRAL)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasDirectionCharacter, reasons, includeReasons);
 
-        if (!font.glyphForCharacter(character))
+        auto glyph = font.glyphForCharacter(character);
+        if (!glyph)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowFontIsMissingGlyph, reasons, includeReasons);
+        if (lineHeightConstraint && font.boundsForGlyph(glyph).height() > *lineHeightConstraint)
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowFontHasOverflowGlyph, reasons, includeReasons);
     }
     return reasons;
 }
 
-static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
+static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, std::optional<float> lineHeightConstraint, bool textIsJustified, IncludeReasons includeReasons)
 {
     if (textRenderer.is8Bit())
-        return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, false, includeReasons);
-    return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, textIsJustified, includeReasons);
+        return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, lineHeightConstraint, false, includeReasons);
+    return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, lineHeightConstraint, textIsJustified, includeReasons);
 }
 
 static AvoidanceReasonFlags canUseForFontAndText(const RenderBlockFlow& flow, IncludeReasons includeReasons)
@@ -187,7 +192,9 @@
     auto& primaryFont = style.fontCascade().primaryFont();
     if (primaryFont.isLoading())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsMissingPrimaryFont, reasons, includeReasons);
-
+    std::optional<float> lineHeightConstraint;
+    if (style.lineBoxContain() & LineBoxContainGlyphs)
+        lineHeightConstraint = lineHeightFromFlow(flow).toFloat();
     bool flowIsJustified = style.textAlign() == JUSTIFY;
     for (const auto& textRenderer : childrenOfType<RenderText>(flow)) {
         if (textRenderer.isCombineText())
@@ -203,7 +210,7 @@
         if (style.fontCascade().codePath(TextRun(textRenderer.text())) != FontCascade::Simple)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowFontIsNotSimple, reasons, includeReasons);
 
-        auto textReasons = canUseForText(textRenderer, primaryFont, flowIsJustified, includeReasons);
+        auto textReasons = canUseForText(textRenderer, primaryFont, lineHeightConstraint, flowIsJustified, includeReasons);
         if (textReasons != NoReason)
             SET_REASON_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     }
@@ -222,7 +229,7 @@
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasOverflowVisible, reasons, includeReasons);
     if (!style.isLeftToRightDirection())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsNotLTR, reasons, includeReasons);
-    if (style.lineBoxContain() != RenderStyle::initialLineBoxContain())
+    if (!(style.lineBoxContain() & LineBoxContainBlock))
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
     if (style.writingMode() != TopToBottomWritingMode)
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsNotTopToBottom, reasons, includeReasons);
@@ -977,7 +984,7 @@
         stream << "dir is not LTR";
         break;
     case FlowHasLineBoxContainProperty:
-        stream << "line-box-contain property";
+        stream << "line-box-contain value indicates variable line height";
         break;
     case FlowIsNotTopToBottom:
         stream << "non top-to-bottom flow";
@@ -1060,6 +1067,9 @@
     case FlowChildIsSelected:
         stream << "selected content";
         break;
+    case FlowFontHasOverflowGlyph:
+        stream << "-webkit-line-box-contain: glyphs with overflowing text.";
+        break;
     case FlowTextIsEmpty:
     case FlowHasNoChild:
     case FlowHasNoParent:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to