⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285801 in webkit


Ignore:
Timestamp:
Nov 15, 2021, 3:12:32 AM (5 years ago)
Author:
Antti Koivisto
Message:

Stack overflow with revert-layer
https://bugs.webkit.org/show_bug.cgi?id=233119
rdar://85342210

Reviewed by Antoine Quint.

Source/WebCore:

We would decrement the cascade layer priority by one after finding 'revert-layer' value and then try
to apply again. If both the default layer and a cascade layer contained 'revert-layer' we would
enter a very deep recursion as the default layer priority is 64k and the cascade layer priorities
start from zero.

Test: fast/css/revert-layer-stack-overflow-2.html

  • style/StyleBuilder.cpp:

(WebCore::Style::Builder::applyRollbackCascadeProperty):

Fix by getting the new cascade layer priority from the actual property rather than the cascade
minimum value.

Factor into a function.

(WebCore::Style::Builder::applyProperty):

  • style/StyleBuilder.h:

LayoutTests:

  • fast/css/revert-layer-stack-overflow-2-expected.txt: Added.
  • fast/css/revert-layer-stack-overflow-2.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285797 r285801  
     12021-11-15  Antti Koivisto  <antti@apple.com>
     2
     3        Stack overflow with revert-layer
     4        https://bugs.webkit.org/show_bug.cgi?id=233119
     5        rdar://85342210
     6
     7        Reviewed by Antoine Quint.
     8
     9        * fast/css/revert-layer-stack-overflow-2-expected.txt: Added.
     10        * fast/css/revert-layer-stack-overflow-2.html: Added.
     11
    1122021-11-14  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r285800 r285801  
     12021-11-15  Antti Koivisto  <antti@apple.com>
     2
     3        Stack overflow with revert-layer
     4        https://bugs.webkit.org/show_bug.cgi?id=233119
     5        rdar://85342210
     6
     7        Reviewed by Antoine Quint.
     8
     9        We would decrement the cascade layer priority by one after finding 'revert-layer' value and then try
     10        to apply again. If both the default layer and a cascade layer contained 'revert-layer' we would
     11        enter a very deep recursion as the default layer priority is 64k and the cascade layer priorities
     12        start from zero.
     13
     14        Test: fast/css/revert-layer-stack-overflow-2.html
     15
     16        * style/StyleBuilder.cpp:
     17        (WebCore::Style::Builder::applyRollbackCascadeProperty):
     18
     19        Fix by getting the new cascade layer priority from the actual property rather than the cascade
     20        minimum value.
     21
     22        Factor into a function.
     23
     24        (WebCore::Style::Builder::applyProperty):
     25        * style/StyleBuilder.h:
     26
    1272021-11-15  Patrick Griffis  <pgriffis@igalia.com>
    228
  • trunk/Source/WebCore/style/StyleBuilder.cpp

    r285713 r285801  
    256256}
    257257
     258void Builder::applyRollbackCascadeProperty(const PropertyCascade::Property& property, SelectorChecker::LinkMatchMask linkMatchMask)
     259{
     260    auto* value = property.cssValue[linkMatchMask];
     261    if (!value)
     262        return;
     263
     264    SetForScope levelScope(m_state.m_cascadeLevel, property.level);
     265    SetForScope scopeScope(m_state.m_styleScopeOrdinal, property.styleScopeOrdinal);
     266    SetForScope layerScope(m_state.m_cascadeLayerPriority, property.cascadeLayerPriority);
     267
     268    applyProperty(property.id, *value, linkMatchMask);
     269}
     270
    258271void Builder::applyProperty(CSSPropertyID id, CSSValue& value, SelectorChecker::LinkMatchMask linkMatchMask)
    259272{
     
    297310            // With the rollback cascade built, we need to obtain the property and apply it. If the property is
    298311            // not present, then we behave like "unset." Otherwise we apply the property instead of our own.
    299             SetForScope cascadeLevelScope(m_state.m_cascadeLevel, rollbackCascade->maximumCascadeLevel());
    300             SetForScope cascadeLayerPriorityScope(m_state.m_cascadeLayerPriority, rollbackCascade->maximumCascadeLayerPriority());
    301312            if (customPropertyValue) {
    302313                if (customPropertyRegistered && customPropertyRegistered->inherits && rollbackCascade->hasCustomProperty(customPropertyValue->name())) {
    303314                    auto property = rollbackCascade->customProperty(customPropertyValue->name());
    304                     if (property.cssValue[linkMatchMask])
    305                         applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask);
     315                    applyRollbackCascadeProperty(property, linkMatchMask);
    306316                    return;
    307317                }
    308318            } else if (rollbackCascade->hasProperty(id)) {
    309319                auto& property = rollbackCascade->property(id);
    310                 if (property.cssValue[linkMatchMask])
    311                     applyProperty(property.id, *property.cssValue[linkMatchMask], linkMatchMask);
     320                applyRollbackCascadeProperty(property, linkMatchMask);
    312321                return;
    313322            }
  • trunk/Source/WebCore/style/StyleBuilder.h

    r285624 r285801  
    5757    void applyPropertiesImpl(int firstProperty, int lastProperty);
    5858    void applyCascadeProperty(const PropertyCascade::Property&);
     59    void applyRollbackCascadeProperty(const PropertyCascade::Property&, SelectorChecker::LinkMatchMask);
    5960    void applyProperty(CSSPropertyID, CSSValue&, SelectorChecker::LinkMatchMask);
    6061
Note: See TracChangeset for help on using the changeset viewer.