Changeset 211292 in webkit


Ignore:
Timestamp:
Jan 27, 2017 11:24:26 AM (7 years ago)
Author:
Alan Bujtas
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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211289 r211292  
     12017-01-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
     4        https://bugs.webkit.org/show_bug.cgi?id=167481
     5        <rdar://problem/30180150>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * fast/text/simple-line-layout-line-box-contain-glyphs-expected.html: Added.
     10        * fast/text/simple-line-layout-line-box-contain-glyphs.html: Added.
     11
    1122017-01-27  Devin Rousso  <dcrousso+webkit@gmail.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r211291 r211292  
     12017-01-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        Simple line layout: Do not bail out on -webkit-line-box-contain: block glyphs unless text overflows vertically.
     4        https://bugs.webkit.org/show_bug.cgi?id=167481
     5        <rdar://problem/30180150>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Since -webkit-line-box-contain: glyphs requires variable line height support, we can use simple line layout
     10        only when each line happen to have the same height ('block' property value is set, glyphs do not overflow the block line height). 
     11
     12        Test: fast/text/simple-line-layout-line-box-contain-glyphs.html
     13
     14        * rendering/SimpleLineLayout.cpp:
     15        (WebCore::SimpleLineLayout::canUseForText):
     16        (WebCore::SimpleLineLayout::canUseForFontAndText):
     17        (WebCore::SimpleLineLayout::canUseForStyle):
     18        (WebCore::SimpleLineLayout::printReason):
     19
    1202017-01-27  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r211228 r211292  
    113113    FlowChildIsSelected                   = 1LLU  << 47,
    114114    FlowHasHangingPunctuation             = 1LLU  << 48,
    115     EndOfReasons                          = 1LLU  << 49
     115    FlowFontHasOverflowGlyph              = 1LLU  << 49,
     116    EndOfReasons                          = 1LLU  << 50
    116117};
    117118const unsigned NoReason = 0;
     
    137138
    138139template <typename CharacterType>
    139 static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
     140static AvoidanceReasonFlags canUseForText(const CharacterType* text, unsigned length, const Font& font, std::optional<float> lineHeightConstraint,
     141    bool textIsJustified, IncludeReasons includeReasons)
    140142{
    141143    AvoidanceReasonFlags reasons = { };
     
    167169            SET_REASON_AND_RETURN_IF_NEEDED(FlowTextHasDirectionCharacter, reasons, includeReasons);
    168170
    169         if (!font.glyphForCharacter(character))
     171        auto glyph = font.glyphForCharacter(character);
     172        if (!glyph)
    170173            SET_REASON_AND_RETURN_IF_NEEDED(FlowFontIsMissingGlyph, reasons, includeReasons);
     174        if (lineHeightConstraint && font.boundsForGlyph(glyph).height() > *lineHeightConstraint)
     175            SET_REASON_AND_RETURN_IF_NEEDED(FlowFontHasOverflowGlyph, reasons, includeReasons);
    171176    }
    172177    return reasons;
    173178}
    174179
    175 static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, bool textIsJustified, IncludeReasons includeReasons)
     180static AvoidanceReasonFlags canUseForText(const RenderText& textRenderer, const Font& font, std::optional<float> lineHeightConstraint, bool textIsJustified, IncludeReasons includeReasons)
    176181{
    177182    if (textRenderer.is8Bit())
    178         return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, false, includeReasons);
    179     return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, textIsJustified, includeReasons);
     183        return canUseForText(textRenderer.characters8(), textRenderer.textLength(), font, lineHeightConstraint, false, includeReasons);
     184    return canUseForText(textRenderer.characters16(), textRenderer.textLength(), font, lineHeightConstraint, textIsJustified, includeReasons);
    180185}
    181186
     
    188193    if (primaryFont.isLoading())
    189194        SET_REASON_AND_RETURN_IF_NEEDED(FlowIsMissingPrimaryFont, reasons, includeReasons);
    190 
     195    std::optional<float> lineHeightConstraint;
     196    if (style.lineBoxContain() & LineBoxContainGlyphs)
     197        lineHeightConstraint = lineHeightFromFlow(flow).toFloat();
    191198    bool flowIsJustified = style.textAlign() == JUSTIFY;
    192199    for (const auto& textRenderer : childrenOfType<RenderText>(flow)) {
     
    204211            SET_REASON_AND_RETURN_IF_NEEDED(FlowFontIsNotSimple, reasons, includeReasons);
    205212
    206         auto textReasons = canUseForText(textRenderer, primaryFont, flowIsJustified, includeReasons);
     213        auto textReasons = canUseForText(textRenderer, primaryFont, lineHeightConstraint, flowIsJustified, includeReasons);
    207214        if (textReasons != NoReason)
    208215            SET_REASON_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     
    223230    if (!style.isLeftToRightDirection())
    224231        SET_REASON_AND_RETURN_IF_NEEDED(FlowIsNotLTR, reasons, includeReasons);
    225     if (style.lineBoxContain() != RenderStyle::initialLineBoxContain())
     232    if (!(style.lineBoxContain() & LineBoxContainBlock))
    226233        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainProperty, reasons, includeReasons);
    227234    if (style.writingMode() != TopToBottomWritingMode)
     
    978985        break;
    979986    case FlowHasLineBoxContainProperty:
    980         stream << "line-box-contain property";
     987        stream << "line-box-contain value indicates variable line height";
    981988        break;
    982989    case FlowIsNotTopToBottom:
     
    10601067    case FlowChildIsSelected:
    10611068        stream << "selected content";
     1069        break;
     1070    case FlowFontHasOverflowGlyph:
     1071        stream << "-webkit-line-box-contain: glyphs with overflowing text.";
    10621072        break;
    10631073    case FlowTextIsEmpty:
Note: See TracChangeset for help on using the changeset viewer.