Changeset 245838 in webkit


Ignore:
Timestamp:
May 28, 2019 7:27:20 PM (5 years ago)
Author:
mmaxfield@apple.com
Message:

Move idempotent text autosizing to StyleTreeResolver
https://bugs.webkit.org/show_bug.cgi?id=197808
<rdar://problem/50283983>

Reviewed by Antti Koivisto.

Source/WebCore:

This patch migrates the idempotent text autosizing code to live inside style resolution. This is almost
the same as the algorithm that uses the result of layout to calculate autosizing, but this version only
operates on style (and thus doesn't require double layouts). Because it is being run in an environment
with less information, autosizing is occurring in more places, so the curves have been adjusted to make
autosizing not boost as much as the previous implementation did. The new algorithm is modelled after
text-decorations-in-effect. I've claimed 4 of the unused bits in RenderStyle to contain the state of the
autosizing algorithm. StyleResolver::adjustRenderStyle() is where the algorithm is implemented:

  • Look at the inherited bits
  • Interogate the element's RenderStyle
  • Compute new bits for the element, and set them in its RenderStyle
  • Based on the newly computed bits, determine whether we should increase the text size
  • If so, determine how much using the specified font size, and apply the result to the computed font size

This works because StyleBuilderCustom::applyInheritFontSize() inherits from the specified font size, not
the computed font size.

This patch also will disable autosizing using the other methods (so there aren't two methods of autosizing
fighting each other) and will honor text-size-adjust:none. However, it won't honor text-size-adjust:100%.
If content says text-size-adjust:100%, we will disregard it and take this code path.

Tests: fast/text-autosizing/ios/idempotentmode/css-exposure.html

fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip.html
fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-identity.html
fast/text-autosizing/ios/idempotentmode/idempotent-autosizing.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::valueForPropertyinStyle):

  • css/CSSProperties.json:
  • css/StyleBuilderCustom.h:

(WebCore::computeBaseSpecifiedFontSize):
(WebCore::computeLineHeightMultiplierDueToFontSize):

  • css/StyleResolver.cpp:

(WebCore::idempotentTextSize):
(WebCore::hasTextChildren):
(WebCore::StyleResolver::adjustRenderStyle):
(WebCore::StyleResolver::checkForTextSizeAdjust):

  • page/FrameViewLayoutContext.cpp:

(WebCore::FrameViewLayoutContext::applyTextSizingIfNeeded):

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::adjustComputedFontSizes):
(WebCore::idempotentTextSize): Deleted.

  • rendering/RenderBlockFlow.h:
  • rendering/RenderElement.cpp:

(WebCore::includeNonFixedHeight):
(WebCore::RenderElement::adjustComputedFontSizesOnBlocks):
(WebCore::RenderElement::resetTextAutosizing):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::RenderStyle):
(WebCore::RenderStyle::autosizeStatus const):
(WebCore::RenderStyle::setAutosizeStatus):

  • rendering/style/RenderStyle.h:
  • rendering/style/TextSizeAdjustment.cpp: Added.

(WebCore::AutosizeStatus::AutosizeStatus):
(WebCore::AutosizeStatus::contains const):
(WebCore::AutosizeStatus::modifiedStatus const):
(WebCore::AutosizeStatus::shouldSkipSubtree const):

  • rendering/style/TextSizeAdjustment.h:

LayoutTests:

  • fast/text-autosizing/ios/idempotentmode/css-exposure-expected.txt: Added.
  • fast/text-autosizing/ios/idempotentmode/css-exposure.html: Added.
  • fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip-expected.html: Added.
  • fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip.html: Added.
  • platform/ipad/fast/text-autosizing/text-size-adjust-inline-style-expected.html: Removed.
  • platform/ipad/fast/text-autosizing/text-size-adjust-inline-style.html: Removed.

We're intentionally not honoring percentages, because this is the most common way that
text autosizing is disabled (by setting it to 100%) on the Web today. However, Web authors
that have done this did it without knowing the full extent of the behavior change, and
the new idempotent text autosizing code path seems to be a progression in most cases
we've seen.

Location:
trunk
Files:
5 added
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245837 r245838  
     12019-05-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Move idempotent text autosizing to StyleTreeResolver
     4        https://bugs.webkit.org/show_bug.cgi?id=197808
     5        <rdar://problem/50283983>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * fast/text-autosizing/ios/idempotentmode/css-exposure-expected.txt: Added.
     10        * fast/text-autosizing/ios/idempotentmode/css-exposure.html: Added.
     11        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip-expected.html: Added.
     12        * fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip.html: Added.
     13        * platform/ipad/fast/text-autosizing/text-size-adjust-inline-style-expected.html: Removed.
     14        * platform/ipad/fast/text-autosizing/text-size-adjust-inline-style.html: Removed.
     15        We're intentionally not honoring percentages, because this is the most common way that
     16        text autosizing is disabled (by setting it to 100%) on the Web today. However, Web authors
     17        that have done this did it without knowing the full extent of the behavior change, and
     18        the new idempotent text autosizing code path seems to be a progression in most cases
     19        we've seen.
     20
    1212019-05-28  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r245837 r245838  
     12019-05-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Move idempotent text autosizing to StyleTreeResolver
     4        https://bugs.webkit.org/show_bug.cgi?id=197808
     5        <rdar://problem/50283983>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This patch migrates the idempotent text autosizing code to live inside style resolution. This is almost
     10        the same as the algorithm that uses the result of layout to calculate autosizing, but this version only
     11        operates on style (and thus doesn't require double layouts). Because it is being run in an environment
     12        with less information, autosizing is occurring in more places, so the curves have been adjusted to make
     13        autosizing not boost as much as the previous implementation did. The new algorithm is modelled after
     14        text-decorations-in-effect. I've claimed 4 of the unused bits in RenderStyle to contain the state of the
     15        autosizing algorithm. StyleResolver::adjustRenderStyle() is where the algorithm is implemented:
     16        - Look at the inherited bits
     17        - Interogate the element's RenderStyle
     18        - Compute new bits for the element, and set them in its RenderStyle
     19        - Based on the newly computed bits, determine whether we should increase the text size
     20        - If so, determine how much using the specified font size, and apply the result to the computed font size
     21
     22        This works because StyleBuilderCustom::applyInheritFontSize() inherits from the specified font size, not
     23        the computed font size.
     24
     25        This patch also will disable autosizing using the other methods (so there aren't two methods of autosizing
     26        fighting each other) and will honor text-size-adjust:none. However, it won't honor text-size-adjust:100%.
     27        If content says text-size-adjust:100%, we will disregard it and take this code path.
     28
     29        Tests: fast/text-autosizing/ios/idempotentmode/css-exposure.html
     30               fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-skip.html
     31               fast/text-autosizing/ios/idempotentmode/idempotent-autosizing-identity.html
     32               fast/text-autosizing/ios/idempotentmode/idempotent-autosizing.html
     33
     34        * Sources.txt:
     35        * WebCore.xcodeproj/project.pbxproj:
     36        * css/CSSComputedStyleDeclaration.cpp:
     37        (WebCore::ComputedStyleExtractor::valueForPropertyinStyle):
     38        * css/CSSProperties.json:
     39        * css/StyleBuilderCustom.h:
     40        (WebCore::computeBaseSpecifiedFontSize):
     41        (WebCore::computeLineHeightMultiplierDueToFontSize):
     42        * css/StyleResolver.cpp:
     43        (WebCore::idempotentTextSize):
     44        (WebCore::hasTextChildren):
     45        (WebCore::StyleResolver::adjustRenderStyle):
     46        (WebCore::StyleResolver::checkForTextSizeAdjust):
     47        * page/FrameViewLayoutContext.cpp:
     48        (WebCore::FrameViewLayoutContext::applyTextSizingIfNeeded):
     49        * rendering/RenderBlockFlow.cpp:
     50        (WebCore::RenderBlockFlow::adjustComputedFontSizes):
     51        (WebCore::idempotentTextSize): Deleted.
     52        * rendering/RenderBlockFlow.h:
     53        * rendering/RenderElement.cpp:
     54        (WebCore::includeNonFixedHeight):
     55        (WebCore::RenderElement::adjustComputedFontSizesOnBlocks):
     56        (WebCore::RenderElement::resetTextAutosizing):
     57        * rendering/style/RenderStyle.cpp:
     58        (WebCore::RenderStyle::RenderStyle):
     59        (WebCore::RenderStyle::autosizeStatus const):
     60        (WebCore::RenderStyle::setAutosizeStatus):
     61        * rendering/style/RenderStyle.h:
     62        * rendering/style/TextSizeAdjustment.cpp: Added.
     63        (WebCore::AutosizeStatus::AutosizeStatus):
     64        (WebCore::AutosizeStatus::contains const):
     65        (WebCore::AutosizeStatus::modifiedStatus const):
     66        (WebCore::AutosizeStatus::shouldSkipSubtree const):
     67        * rendering/style/TextSizeAdjustment.h:
     68
    1692019-05-28  Simon Fraser  <simon.fraser@apple.com>
    270
  • trunk/Source/WebCore/Sources.txt

    r245798 r245838  
    21452145rendering/style/StyleTransformData.cpp
    21462146rendering/style/StyleVisualData.cpp
     2147rendering/style/TextSizeAdjustment.cpp
    21472148rendering/style/WillChangeData.cpp
    21482149
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r245798 r245838  
    64386438                1CECB3C621F59C8700F44542 /* WHLSLNativeTypeWriter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WHLSLNativeTypeWriter.cpp; sourceTree = "<group>"; };
    64396439                1CECB3C721F59C8700F44542 /* WHLSLNativeTypeWriter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLNativeTypeWriter.h; sourceTree = "<group>"; };
     6440                1CF0BFD42298706800ED2074 /* TextSizeAdjustment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextSizeAdjustment.cpp; sourceTree = "<group>"; };
    64406441                1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
    64416442                1DC553FD211BA12A004B780E /* NavigatorShare.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorShare.idl; sourceTree = "<group>"; };
     
    2493124932                                BC2274770E8366E200E7F975 /* SVGRenderStyleDefs.h */,
    2493224933                                1CB6B4F8217B83930093B9CD /* TextDecorationThickness.h */,
     24934                                1CF0BFD42298706800ED2074 /* TextSizeAdjustment.cpp */,
    2493324935                                448B1B780F3A2F9B0047A9E2 /* TextSizeAdjustment.h */,
    2493424936                                1CB6B4FB217B83940093B9CD /* TextUnderlineOffset.h */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r245823 r245838  
    27862786    switch (propertyID) {
    27872787        case CSSPropertyInvalid:
     2788#if ENABLE(TEXT_AUTOSIZING)
     2789        case CSSPropertyInternalTextAutosizingStatus:
     2790#endif
    27882791            break;
    27892792
  • trunk/Source/WebCore/css/CSSProperties.json

    r245276 r245838  
    62296229            "status": "non-standard"
    62306230        },
     6231        "-internal-text-autosizing-status": {
     6232            "inherited": true,
     6233            "codegen-properties": {
     6234                "skip-builder": true,
     6235                "enable-if": "ENABLE_TEXT_AUTOSIZING"
     6236            },
     6237            "status": "non-standard"
     6238        },
    62316239        "-webkit-text-emphasis": {
    62326240            "inherited": true,
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r244408 r245838  
    670670        result *= frame->textZoomFactor();
    671671    result *= style.effectiveZoom();
    672     if (percentageAutosizingEnabled)
     672    if (percentageAutosizingEnabled && !document.settings().textAutosizingUsesIdempotentMode())
    673673        result *= style.textSizeAdjust().multiplier();
    674674    return result;
     
    702702    }
    703703
    704     if (percentageAutosizingEnabled)
     704    if (percentageAutosizingEnabled && !document.settings().textAutosizingUsesIdempotentMode())
    705705        return style.textSizeAdjust().multiplier();
    706706    return 1;
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r245494 r245838  
    875875#endif
    876876
     877#if ENABLE(TEXT_AUTOSIZING)
     878static bool hasTextChildren(const Element& element)
     879{
     880    for (auto* child = element.firstChild(); child; child = child->nextSibling()) {
     881        if (is<Text>(child))
     882            return true;
     883    }
     884    return false;
     885}
     886
     887void StyleResolver::adjustRenderStyleForTextAutosizing(RenderStyle& style, const Element* element)
     888{
     889    auto newAutosizeStatus = AutosizeStatus::updateStatus(style);
     890    auto pageScale = document().page() ? document().page()->initialScale() : 1.0f;
     891    if (settings().textAutosizingEnabled() && settings().textAutosizingUsesIdempotentMode() && element && !newAutosizeStatus.shouldSkipSubtree() && !style.textSizeAdjust().isNone() && hasTextChildren(*element) && pageScale != 1.0f) {
     892        auto fontDescription = style.fontDescription();
     893        fontDescription.setComputedSize(AutosizeStatus::idempotentTextSize(fontDescription.specifiedSize(), pageScale));
     894        style.setFontDescription(WTFMove(fontDescription));
     895        style.fontCascade().update(&document().fontSelector());
     896    }
     897}
     898#endif
     899
    877900void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* element)
    878901{
     
    11231146#if ENABLE(POINTER_EVENTS)
    11241147    style.setEffectiveTouchActions(computeEffectiveTouchActions(style, parentStyle.effectiveTouchActions()));
     1148#endif
     1149
     1150#if ENABLE(TEXT_AUTOSIZING)
     1151    adjustRenderStyleForTextAutosizing(style, element);
    11251152#endif
    11261153
     
    18211848void StyleResolver::checkForTextSizeAdjust(RenderStyle* style)
    18221849{
    1823     if (style->textSizeAdjust().isAuto())
     1850    ASSERT(style);
     1851    if (style->textSizeAdjust().isAuto() || (settings().textAutosizingUsesIdempotentMode() && !style->textSizeAdjust().isNone()))
    18241852        return;
    18251853
  • trunk/Source/WebCore/css/StyleResolver.h

    r244904 r245838  
    501501    void sweepMatchedPropertiesCache();
    502502
     503    void adjustRenderStyleForTextAutosizing(RenderStyle&, const Element*);
     504
    503505    typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
    504506    MatchedPropertiesCache m_matchedPropertiesCache;
  • trunk/Source/WebCore/page/FrameViewLayoutContext.cpp

    r245716 r245838  
    492492{
    493493    auto& settings = layoutRoot.settings();
    494     if (!settings.textAutosizingEnabled() || renderView()->printing())
    495         return;
    496494    bool idempotentMode = settings.textAutosizingUsesIdempotentMode();
     495    if (!settings.textAutosizingEnabled() || idempotentMode || renderView()->printing())
     496        return;
    497497    auto minimumZoomFontSize = settings.minimumZoomFontSize();
    498498    if (!idempotentMode && !minimumZoomFontSize)
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r245543 r245838  
    37243724}
    37253725
    3726 static inline float idempotentTextSize(float specifiedSize, float pageScale)
    3727 {
    3728     // This describes a piecewise curve when the page scale is 2/3.
    3729     FloatPoint points[] = { {0.0f, 0.0f}, {6.0f, 12.0f}, {12.0f, 18.0f} };
    3730 
    3731     // When the page scale is 1, the curve should be the identity.
    3732     // Linearly interpolate between the curve above and identity based on the page scale.
    3733     // Beware that depending on the specific values picked in the curve, this interpolation might change the shape of the curve for very small pageScales.
    3734     pageScale = std::min(std::max(pageScale, 0.5f), 1.0f);
    3735     auto scalePoint = [&](FloatPoint point) {
    3736         float fraction = 3.0f - 3.0f * pageScale;
    3737         point.setY(point.x() + (point.y() - point.x()) * fraction);
    3738         return point;
    3739     };
    3740 
    3741     if (specifiedSize <= 0)
    3742         return 0;
    3743 
    3744     float result = scalePoint(points[WTF_ARRAY_LENGTH(points) - 1]).y();
    3745     for (size_t i = 1; i < WTF_ARRAY_LENGTH(points); ++i) {
    3746         if (points[i].x() < specifiedSize)
    3747             continue;
    3748         auto leftPoint = scalePoint(points[i - 1]);
    3749         auto rightPoint = scalePoint(points[i]);
    3750         float fraction = (specifiedSize - leftPoint.x()) / (rightPoint.x() - leftPoint.x());
    3751         result = leftPoint.y() + fraction * (rightPoint.y() - leftPoint.y());
    3752         break;
    3753     }
    3754 
    3755     return std::max(result, specifiedSize);
    3756 }
    3757 
    3758 void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth, float pageScale, bool idempotentMode)
     3726void RenderBlockFlow::adjustComputedFontSizes(float size, float visibleWidth)
    37593727{
    37603728    LOG(TextAutosizing, "RenderBlockFlow %p adjustComputedFontSizes, size=%f visibleWidth=%f, width()=%f. Bailing: %d", this, size, visibleWidth, width().toFloat(), visibleWidth >= width());
    37613729
    37623730    // Don't do any work if the block is smaller than the visible area.
    3763     if (!idempotentMode && visibleWidth >= width())
     3731    if (visibleWidth >= width())
    37643732        return;
    37653733   
     
    37993767        float specifiedSize = fontDescription.specifiedSize();
    38003768        float scaledSize = roundf(specifiedSize * scale);
    3801         if (idempotentMode || (scaledSize > 0 && scaledSize < minFontSize)) {
     3769        if (scaledSize > 0 && scaledSize < minFontSize) {
    38023770            // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing.
    38033771            // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915).
     
    38073775                m_widthForTextAutosizing = actualWidth;
    38083776
    3809             float candidateNewSize;
    3810             if (idempotentMode) {
    3811                 float lineTextSize = idempotentTextSize(specifiedSize, pageScale);
    3812                 candidateNewSize = roundf(lineTextSize);
    3813             } else {
    3814                 float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(text, specifiedSize) : textMultiplier(text, specifiedSize);
    3815                 candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
    3816             }
     3777            float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(text, specifiedSize) : textMultiplier(text, specifiedSize);
     3778            float candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
    38173779
    38183780            if (candidateNewSize > specifiedSize && candidateNewSize != fontDescription.computedSize() && text.textNode() && oldStyle.textSizeAdjust().isAuto())
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r244682 r245838  
    605605#if ENABLE(TEXT_AUTOSIZING)
    606606    int lineCountForTextAutosizing();
    607     void adjustComputedFontSizes(float size, float visibleWidth, float pageScale, bool idempotentMode);
     607    void adjustComputedFontSizes(float size, float visibleWidth);
    608608    void resetComputedFontSize()
    609609    {
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r245543 r245838  
    21262126        return RenderObject::FixedHeight;
    21272127    }
    2128     if (renderer.document().settings().textAutosizingUsesIdempotentMode() && style.maxHeight().type() == Fixed && is<RenderBlock>(renderer) && style.maxHeight().value() <= downcast<RenderBlock>(renderer).layoutOverflowRect().maxY())
    2129         return RenderObject::FixedHeight;
    21302128    return RenderObject::FlexibleHeight;
    21312129}
     
    21362134    if (!document)
    21372135        return;
    2138 
    2139     auto pageScale = document->page() ? document->page()->initialScale() : 1.0f;
    21402136
    21412137    Vector<int> depthStack;
    21422138    int currentDepth = 0;
    21432139    int newFixedDepth = 0;
    2144     auto idempotentMode = document->settings().textAutosizingUsesIdempotentMode();
    21452140
    21462141    // We don't apply autosizing to nodes with fixed height normally.
     
    21552150
    21562151        int stackSize = depthStack.size();
    2157         if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (idempotentMode || !stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
    2158             downcast<RenderBlockFlow>(*descendent).adjustComputedFontSizes(size, visibleWidth, pageScale, idempotentMode);
     2152        if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
     2153            downcast<RenderBlockFlow>(*descendent).adjustComputedFontSizes(size, visibleWidth);
    21592154        newFixedDepth = 0;
    21602155    }
     
    21772172    int currentDepth = 0;
    21782173    int newFixedDepth = 0;
    2179     auto idempotentMode = document->settings().textAutosizingUsesIdempotentMode();
    21802174
    21812175    for (RenderObject* descendent = traverseNext(this, includeNonFixedHeight, currentDepth, newFixedDepth); descendent; descendent = descendent->traverseNext(this, includeNonFixedHeight, currentDepth, newFixedDepth)) {
     
    21862180
    21872181        int stackSize = depthStack.size();
    2188         if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (idempotentMode || !stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
     2182        if (is<RenderBlockFlow>(*descendent) && !descendent->isListItem() && (!stackSize || currentDepth - depthStack[stackSize - 1] > TextAutoSizingFixedHeightDepth))
    21892183            downcast<RenderBlockFlow>(*descendent).resetComputedFontSize();
    21902184        newFixedDepth = 0;
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r245543 r245838  
    166166    m_inheritedFlags.insideDefaultButton = false;
    167167    m_inheritedFlags.writingMode = initialWritingMode();
     168#if ENABLE(TEXT_AUTOSIZING)
     169    m_inheritedFlags.autosizeStatus = 0;
     170#endif
    168171
    169172    m_nonInheritedFlags.effectiveDisplay = static_cast<unsigned>(initialDisplay());
     
    490493}
    491494
     495AutosizeStatus RenderStyle::autosizeStatus() const
     496{
     497    return OptionSet<AutosizeStatus::Fields>::fromRaw(m_inheritedFlags.autosizeStatus);
     498}
     499
     500void RenderStyle::setAutosizeStatus(AutosizeStatus autosizeStatus)
     501{
     502    m_inheritedFlags.autosizeStatus = autosizeStatus.fields().toRaw();
     503}
     504
    492505#endif // ENABLE(TEXT_AUTOSIZING)
    493506
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r245543 r245838  
    745745#if ENABLE(TEXT_AUTOSIZING)
    746746    TextSizeAdjustment textSizeAdjust() const { return m_rareInheritedData->textSizeAdjust; }
     747    AutosizeStatus autosizeStatus() const;
    747748#endif
    748749
     
    12591260#if ENABLE(TEXT_AUTOSIZING)
    12601261    void setTextSizeAdjust(TextSizeAdjustment adjustment) { SET_VAR(m_rareInheritedData, textSizeAdjust, adjustment); }
     1262    void setAutosizeStatus(AutosizeStatus);
    12611263#endif
    12621264
     
    18461848        unsigned writingMode : 2; // WritingMode
    18471849        // 48 bits
     1850
     1851#if ENABLE(TEXT_AUTOSIZING)
     1852        unsigned autosizeStatus : 4;
     1853#endif
     1854        // 52 bits
    18481855    };
    18491856
  • trunk/Source/WebCore/rendering/style/TextSizeAdjustment.h

    r208668 r245838  
    2323#if ENABLE(TEXT_AUTOSIZING)
    2424
     25#include <wtf/OptionSet.h>
     26
    2527namespace WebCore {
     28
     29class RenderStyle;
    2630
    2731enum TextSizeAdjustmentType { AutoTextSizeAdjustment = -1, NoTextSizeAdjustment = -2 };
     
    4650};
    4751
     52class AutosizeStatus {
     53public:
     54    enum class Fields : uint8_t {
     55        FoundOutOfFlowPosition = 1 << 0,
     56        FoundInlineBlock = 1 << 1,
     57        FoundFixedHeight = 1 << 2,
     58        FoundDisplayNone = 1 << 3
     59        // Adding new values requires giving RenderStyle::InheritedFlags::autosizeStatus additional bits.
     60    };
     61
     62    AutosizeStatus(OptionSet<Fields>);
     63    OptionSet<Fields> fields() const { return m_fields; }
     64
     65    bool contains(Fields) const;
     66    bool shouldSkipSubtree() const;
     67
     68    static float idempotentTextSize(float specifiedSize, float pageScale);
     69    static AutosizeStatus updateStatus(RenderStyle&);
     70
     71private:
     72    OptionSet<Fields> m_fields;
     73};
     74
     75
    4876} // namespace WebCore
    4977
Note: See TracChangeset for help on using the changeset viewer.