Changeset 191252 in webkit


Ignore:
Timestamp:
Oct 17, 2015 4:13:43 PM (8 years ago)
Author:
hyatt@apple.com
Message:

Implement the CSS4 'revert' keyword.
https://bugs.webkit.org/show_bug.cgi?id=149702

Reviewed by Simon Fraser.

Source/WebCore:

Added new tests in fast/css and fast/css/variables.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:

Add CSSRevertValue to the project and makefiles.

  • css/CSSParser.cpp:

(WebCore::parseKeywordValue):
Make sure to handle "revert" in the keyword parsing path (along with inherit/initial/unset).

(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseCustomPropertyDeclaration):
At the parser level, "revert" is just like inherit/initial/unset and gets its own special
singleton value, CSSRevertValue.

  • css/CSSRevertValue.cpp: Added.

(WebCore::CSSRevertValue::customCSSText):

  • css/CSSRevertValue.h: Added.

(WebCore::CSSRevertValue::create):
(WebCore::CSSRevertValue::equals):
(WebCore::CSSRevertValue::CSSRevertValue):
This value is identical to the inherit/initial/unset values, i.e., its own special value
that can be used to indicate a revert when doing style resolution.

  • css/CSSValue.cpp:

(WebCore::CSSValue::cssValueType):
(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isInheritedValue):
(WebCore::CSSValue::isInitialValue):
(WebCore::CSSValue::isUnsetValue):
(WebCore::CSSValue::isRevertValue):
Add the RevertClass to CSSValue and make sure it is handled in all the appropriate methods.

  • css/CSSValueKeywords.in:

Add the "revert" keyword to the list of allowed CSS keywords.

  • css/CSSValuePool.cpp:

(WebCore::CSSValuePool::CSSValuePool):

  • css/CSSValuePool.h:

(WebCore::CSSValuePool::createRevertValue):
Add support for a CSSRevertValue singleton, just like inherit/unset/initial.

  • css/FontLoader.cpp:

(WebCore::FontLoader::resolveFontStyle):
Add "unset" and "revert" as special keywords to be ignored. This code seems to be turned off,
but patching it anyway.

  • css/SelectorChecker.h:

Add a MatchDefault value of 0 to the LinkMatchMask. This enables it to be used as an index
to the correct value in Property (in the style resolution code).

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::State::initForStyleResolve):
Delete any lingering old CascadedProperty rollbacks for UA/user rules.

(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::applyMatchedProperties):
Pass along the MatchResult as an additional parameter, since we need it to lazily compute
the cascade rollbacks if the "revert" keyword is encountered.

(WebCore::StyleResolver::cascadedPropertiesForRollback):
This method will lazily create and return a new CascadedProperties pointer that is cached
in the StyleResolver's state. This will contain only UA rules (for user reverts) and UA/user
rules (for author reverts). These will only be computed at most once for a given element
when doing a reversion, and they will be computed lazily, i.e., only if a revert is
requested.

(WebCore::StyleResolver::applyProperty):
Pass along the LinkMatchMask and the MatchResult to applyProperty. This way we know specifically
which link type we were computing if we have to revert (so that we roll back and look at the
same index in the reverted version). The MatchResult is passed along because it is needed
to build the CascadedProperties rollbacks.

The basic idea is that if a revert is encountered, the level that the rule came from is
checked. If it is UA level, just treat as "unset." If it is author or user level, get
the correct CascadedProperties rollback and repeat the applyProperty using the property
found in the rollback. If the property is not present in the cascade rollback, then the
revert becomes an unset.

(WebCore::StyleResolver::CascadedProperties::hasCustomProperty):
(WebCore::StyleResolver::CascadedProperties::customProperty):
Helpers used by applyProperty to check on custom properties, since they can revert too
just like a regular property can.

(WebCore::StyleResolver::CascadedProperties::setPropertyInternal):
(WebCore::StyleResolver::CascadedProperties::set):
(WebCore::StyleResolver::CascadedProperties::setDeferred):
Passing along the CascadeLevel (UA, User, Author) so that it can be stored in the Property.
This way when we do property application, we always know where the rule came from so
that the reversion can be handled properly.

(WebCore::StyleResolver::CascadedProperties::addStyleProperties):
(WebCore::cascadeLevelForIndex):
(WebCore::StyleResolver::CascadedProperties::addMatches):
When style properties are added, also figure out the CascadeLevel and pass it along to be
stored in the Property. We use the MatchResult's ranges to know where a property comes from.

(WebCore::StyleResolver::CascadedProperties::applyDeferredProperties):
(WebCore::StyleResolver::CascadedProperties::Property::apply):
(WebCore::StyleResolver::applyCascadedProperties):
Pass along the MatchResult so we know how to build the rollback.

  • css/StyleResolver.h:

(WebCore::StyleResolver::State::cascadeLevel):
(WebCore::StyleResolver::State::setCascadeLevel):
(WebCore::StyleResolver::State::authorRollback):
(WebCore::StyleResolver::State::userRollback):
(WebCore::StyleResolver::State::setAuthorRollback):
(WebCore::StyleResolver::State::setUserRollback):
(WebCore::StyleResolver::state):
(WebCore::StyleResolver::cascadeLevel):
(WebCore::StyleResolver::setCascadeLevel):
Move CascadedProperties into the header. Add CascadeLevel to Property. Add the level and
rollbacks to the resolver's state.

LayoutTests:

  • fast/css/all-keyword-revert-expected.html: Added.
  • fast/css/all-keyword-revert.html: Added.
  • fast/css/revert-color-expected.html: Added.
  • fast/css/revert-color.html: Added.
  • fast/css/revert-margins-expected.html: Added.
  • fast/css/revert-margins.html: Added.
  • fast/css/variables/all-keyword-revert-expected.html: Added.
  • fast/css/variables/all-keyword-revert.html: Added.
  • fast/css/variables/revert-inheritance-expected.html: Added.
  • fast/css/variables/revert-inheritance.html: Added.
  • fast/css/variables/revert-no-inheritance-expected.html: Added.
  • fast/css/variables/revert-no-inheritance.html: Added.
  • fast/css/variables/revert-variable-reference-expected.html: Added.
  • fast/css/variables/revert-variable-reference.html: Added.
Location:
trunk
Files:
16 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191251 r191252  
     12015-10-17  David Hyatt  <hyatt@apple.com>
     2
     3        Implement the CSS4 'revert' keyword.
     4        https://bugs.webkit.org/show_bug.cgi?id=149702
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css/all-keyword-revert-expected.html: Added.
     9        * fast/css/all-keyword-revert.html: Added.
     10        * fast/css/revert-color-expected.html: Added.
     11        * fast/css/revert-color.html: Added.
     12        * fast/css/revert-margins-expected.html: Added.
     13        * fast/css/revert-margins.html: Added.
     14        * fast/css/variables/all-keyword-revert-expected.html: Added.
     15        * fast/css/variables/all-keyword-revert.html: Added.
     16        * fast/css/variables/revert-inheritance-expected.html: Added.
     17        * fast/css/variables/revert-inheritance.html: Added.
     18        * fast/css/variables/revert-no-inheritance-expected.html: Added.
     19        * fast/css/variables/revert-no-inheritance.html: Added.
     20        * fast/css/variables/revert-variable-reference-expected.html: Added.
     21        * fast/css/variables/revert-variable-reference.html: Added.
     22
    1232015-10-17  Myles C. Maxfield  <mmaxfield@apple.com>
    224
  • trunk/Source/WebCore/CMakeLists.txt

    r191247 r191252  
    13391339    css/CSSPropertySourceData.cpp
    13401340    css/CSSReflectValue.cpp
     1341    css/CSSRevertValue.cpp
    13411342    css/CSSRule.cpp
    13421343    css/CSSRuleList.cpp
  • trunk/Source/WebCore/ChangeLog

    r191251 r191252  
     12015-10-17  David Hyatt  <hyatt@apple.com>
     2
     3        Implement the CSS4 'revert' keyword.
     4        https://bugs.webkit.org/show_bug.cgi?id=149702
     5
     6        Reviewed by Simon Fraser.
     7
     8        Added new tests in fast/css and fast/css/variables.
     9
     10        * CMakeLists.txt:
     11        * WebCore.xcodeproj/project.pbxproj:
     12        Add CSSRevertValue to the project and makefiles.
     13
     14        * css/CSSParser.cpp:
     15        (WebCore::parseKeywordValue):
     16        Make sure to handle "revert" in the keyword parsing path (along with inherit/initial/unset).
     17
     18        (WebCore::CSSParser::parseValue):
     19        (WebCore::CSSParser::parseCustomPropertyDeclaration):
     20        At the parser level, "revert" is just like inherit/initial/unset and gets its own special
     21        singleton value, CSSRevertValue.
     22
     23        * css/CSSRevertValue.cpp: Added.
     24        (WebCore::CSSRevertValue::customCSSText):
     25        * css/CSSRevertValue.h: Added.
     26        (WebCore::CSSRevertValue::create):
     27        (WebCore::CSSRevertValue::equals):
     28        (WebCore::CSSRevertValue::CSSRevertValue):
     29        This value is identical to the inherit/initial/unset values, i.e., its own special value
     30        that can be used to indicate a revert when doing style resolution.
     31
     32        * css/CSSValue.cpp:
     33        (WebCore::CSSValue::cssValueType):
     34        (WebCore::CSSValue::equals):
     35        (WebCore::CSSValue::cssText):
     36        (WebCore::CSSValue::destroy):
     37        * css/CSSValue.h:
     38        (WebCore::CSSValue::isInheritedValue):
     39        (WebCore::CSSValue::isInitialValue):
     40        (WebCore::CSSValue::isUnsetValue):
     41        (WebCore::CSSValue::isRevertValue):
     42        Add the RevertClass to CSSValue and make sure it is handled in all the appropriate methods.
     43
     44        * css/CSSValueKeywords.in:
     45        Add the "revert" keyword to the list of allowed CSS keywords.
     46
     47        * css/CSSValuePool.cpp:
     48        (WebCore::CSSValuePool::CSSValuePool):
     49        * css/CSSValuePool.h:
     50        (WebCore::CSSValuePool::createRevertValue):
     51        Add support for a CSSRevertValue singleton, just like inherit/unset/initial.
     52
     53        * css/FontLoader.cpp:
     54        (WebCore::FontLoader::resolveFontStyle):
     55        Add "unset" and "revert" as special keywords to be ignored. This code seems to be turned off,
     56        but patching it anyway.
     57
     58        * css/SelectorChecker.h:
     59        Add a MatchDefault value of 0 to the LinkMatchMask. This enables it to be used as an index
     60        to the correct value in Property (in the style resolution code).
     61
     62        * css/StyleResolver.cpp:
     63        (WebCore::StyleResolver::State::initForStyleResolve):
     64        Delete any lingering old CascadedProperty rollbacks for UA/user rules.
     65
     66        (WebCore::StyleResolver::styleForKeyframe):
     67        (WebCore::StyleResolver::styleForPage):
     68        (WebCore::StyleResolver::applyMatchedProperties):
     69        Pass along the MatchResult as an additional parameter, since we need it to lazily compute
     70        the cascade rollbacks if the "revert" keyword is encountered.
     71
     72        (WebCore::StyleResolver::cascadedPropertiesForRollback):
     73        This method will lazily create and return a new CascadedProperties pointer that is cached
     74        in the StyleResolver's state. This will contain only UA rules (for user reverts) and UA/user
     75        rules (for author reverts). These will only be computed at most once for a given element
     76        when doing a reversion, and they will be computed lazily, i.e., only if a revert is
     77        requested.
     78
     79        (WebCore::StyleResolver::applyProperty):
     80        Pass along the LinkMatchMask and the MatchResult to applyProperty. This way we know specifically
     81        which link type we were computing if we have to revert (so that we roll back and look at the
     82        same index in the reverted version). The MatchResult is passed along because it is needed
     83        to build the CascadedProperties rollbacks.
     84
     85        The basic idea is that if a revert is encountered, the level that the rule came from is
     86        checked. If it is UA level, just treat as "unset." If it is author or user level, get
     87        the correct CascadedProperties rollback and repeat the applyProperty using the property
     88        found in the rollback. If the property is not present in the cascade rollback, then the
     89        revert becomes an unset.
     90
     91        (WebCore::StyleResolver::CascadedProperties::hasCustomProperty):
     92        (WebCore::StyleResolver::CascadedProperties::customProperty):
     93        Helpers used by applyProperty to check on custom properties, since they can revert too
     94        just like a regular property can.
     95
     96        (WebCore::StyleResolver::CascadedProperties::setPropertyInternal):
     97        (WebCore::StyleResolver::CascadedProperties::set):
     98        (WebCore::StyleResolver::CascadedProperties::setDeferred):
     99        Passing along the CascadeLevel (UA, User, Author) so that it can be stored in the Property.
     100        This way when we do property application, we always know where the rule came from so
     101        that the reversion can be handled properly.
     102
     103        (WebCore::StyleResolver::CascadedProperties::addStyleProperties):
     104        (WebCore::cascadeLevelForIndex):
     105        (WebCore::StyleResolver::CascadedProperties::addMatches):
     106        When style properties are added, also figure out the CascadeLevel and pass it along to be
     107        stored in the Property. We use the MatchResult's ranges to know where a property comes from.
     108
     109        (WebCore::StyleResolver::CascadedProperties::applyDeferredProperties):
     110        (WebCore::StyleResolver::CascadedProperties::Property::apply):
     111        (WebCore::StyleResolver::applyCascadedProperties):
     112        Pass along the MatchResult so we know how to build the rollback.
     113
     114        * css/StyleResolver.h:
     115        (WebCore::StyleResolver::State::cascadeLevel):
     116        (WebCore::StyleResolver::State::setCascadeLevel):
     117        (WebCore::StyleResolver::State::authorRollback):
     118        (WebCore::StyleResolver::State::userRollback):
     119        (WebCore::StyleResolver::State::setAuthorRollback):
     120        (WebCore::StyleResolver::State::setUserRollback):
     121        (WebCore::StyleResolver::state):
     122        (WebCore::StyleResolver::cascadeLevel):
     123        (WebCore::StyleResolver::setCascadeLevel):
     124        Move CascadedProperties into the header. Add CascadeLevel to Property. Add the level and
     125        rollbacks to the resolver's state.
     126
    11272015-10-17  Myles C. Maxfield  <mmaxfield@apple.com>
    2128
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r191247 r191252  
    55005500                BC7D8FEF1BD03B6400FFE540 /* CSSUnsetValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7D8FED1BD03B6400FFE540 /* CSSUnsetValue.cpp */; };
    55015501                BC7D8FF01BD03B6400FFE540 /* CSSUnsetValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7D8FEE1BD03B6400FFE540 /* CSSUnsetValue.h */; };
     5502                BC7D8FF31BD1A47900FFE540 /* CSSRevertValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7D8FF11BD1A47900FFE540 /* CSSRevertValue.cpp */; settings = {ASSET_TAGS = (); }; };
     5503                BC7D8FF41BD1A47900FFE540 /* CSSRevertValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7D8FF21BD1A47900FFE540 /* CSSRevertValue.h */; settings = {ASSET_TAGS = (); }; };
    55025504                BC7F44A80B9E324E00A9D081 /* ImageObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F44A70B9E324E00A9D081 /* ImageObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    55035505                BC7FA6200D1F0CBD00DB22A9 /* LiveNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7FA61E0D1F0CBD00DB22A9 /* LiveNodeList.cpp */; };
     
    1322013222                BC7D8FED1BD03B6400FFE540 /* CSSUnsetValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSUnsetValue.cpp; sourceTree = "<group>"; };
    1322113223                BC7D8FEE1BD03B6400FFE540 /* CSSUnsetValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSUnsetValue.h; sourceTree = "<group>"; };
     13224                BC7D8FF11BD1A47900FFE540 /* CSSRevertValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSRevertValue.cpp; sourceTree = "<group>"; };
     13225                BC7D8FF21BD1A47900FFE540 /* CSSRevertValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSRevertValue.h; sourceTree = "<group>"; };
    1322213226                BC7F44A70B9E324E00A9D081 /* ImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageObserver.h; sourceTree = "<group>"; };
    1322313227                BC7FA61E0D1F0CBD00DB22A9 /* LiveNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiveNodeList.cpp; sourceTree = "<group>"; };
     
    2308223086                                BC5A12DD0DC0414800C9AFAD /* CSSReflectValue.cpp */,
    2308323087                                BC5A12DE0DC0414800C9AFAD /* CSSReflectValue.h */,
     23088                                BC7D8FF11BD1A47900FFE540 /* CSSRevertValue.cpp */,
     23089                                BC7D8FF21BD1A47900FFE540 /* CSSRevertValue.h */,
    2308423090                                A80E6CDC0A1989CA007FB8C5 /* CSSRule.cpp */,
    2308523091                                A80E6CE30A1989CA007FB8C5 /* CSSRule.h */,
     
    2470224708                                E19AC3EF1824DC7900349426 /* CryptoAlgorithmSHA224.h in Headers */,
    2470324709                                E19AC3F11824DC7900349426 /* CryptoAlgorithmSHA256.h in Headers */,
    24704                                 836CB1F81BD1E41800AF1591 /* JSHTMLTableDataCellElement.h in Headers */,
    2470524710                                E19AC3F31824DC7900349426 /* CryptoAlgorithmSHA384.h in Headers */,
    2470624711                                E19AC3F51824DC7900349426 /* CryptoAlgorithmSHA512.h in Headers */,
     
    2477424779                                9362640B0DE1137D009D5A00 /* CSSReflectionDirection.h in Headers */,
    2477524780                                BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */,
     24781                                BC7D8FF41BD1A47900FFE540 /* CSSRevertValue.h in Headers */,
    2477624782                                A80E6D0D0A1989CA007FB8C5 /* CSSRule.h in Headers */,
    2477724783                                A80E6CF20A1989CA007FB8C5 /* CSSRuleList.h in Headers */,
     
    2559025596                                A871DB2A0A150BD600B12A68 /* HTMLTableCellElement.h in Headers */,
    2559125597                                A871DB2F0A150BD600B12A68 /* HTMLTableColElement.h in Headers */,
     25598                                836BAD221BD1CA670037356A /* HTMLTableDataCellElement.h in Headers */,
    2559225599                                A871DB270A150BD600B12A68 /* HTMLTableElement.h in Headers */,
     25600                                836BAD211BD1CA670037356A /* HTMLTableHeaderCellElement.h in Headers */,
    2559325601                                A871DB2C0A150BD600B12A68 /* HTMLTablePartElement.h in Headers */,
    2559425602                                A871DB310A150BD600B12A68 /* HTMLTableRowElement.h in Headers */,
     
    2599326001                                BC06EDE40BFD6D0D00856E9D /* JSHTMLTableCellElement.h in Headers */,
    2599426002                                BC06ED9E0BFD660600856E9D /* JSHTMLTableColElement.h in Headers */,
     26003                                836CB1F81BD1E41800AF1591 /* JSHTMLTableDataCellElement.h in Headers */,
    2599526004                                BC06EE050BFD71AA00856E9D /* JSHTMLTableElement.h in Headers */,
     26005                                836CB1F61BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.h in Headers */,
    2599626006                                BC06EDA00BFD660600856E9D /* JSHTMLTableRowElement.h in Headers */,
    2599726007                                BC06ED070BFD5BAE00856E9D /* JSHTMLTableSectionElement.h in Headers */,
     
    2626226272                                B2FA3DEE0AB75A6F000E5AC4 /* JSSVGRectElement.h in Headers */,
    2626326273                                B2FA3DF10AB75A6F000E5AC4 /* JSSVGRenderingIntent.h in Headers */,
    26264                                 836CB1F61BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.h in Headers */,
    2626526274                                B2FA3DF30AB75A6F000E5AC4 /* JSSVGScriptElement.h in Headers */,
    2626626275                                B2FA3DF50AB75A6F000E5AC4 /* JSSVGSetElement.h in Headers */,
     
    2726627275                                9DAC7C571AF2CB6400437C44 /* StyleContentAlignmentData.h in Headers */,
    2726727276                                BC779E171BB227CA00CAA8BF /* StyleCustomPropertyData.h in Headers */,
    27268                                 836BAD211BD1CA670037356A /* HTMLTableHeaderCellElement.h in Headers */,
    2726927277                                BC5EB67F0E81D4A700B25965 /* StyleDashboardRegion.h in Headers */,
    2727027278                                A8C4A7FD09D563270003AC8D /* StyledElement.h in Headers */,
     
    2732527333                                08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */,
    2732627334                                71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */,
    27327                                 836BAD221BD1CA670037356A /* HTMLTableDataCellElement.h in Headers */,
    2732827335                                0823D159127AD6AC000EBC95 /* SVGAnimatedInteger.h in Headers */,
    2732927336                                71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */,
     
    2860028607                                82E3D8DE122EA0D1003AE5BC /* CSSPropertySourceData.cpp in Sources */,
    2860128608                                BC5A12DF0DC0414800C9AFAD /* CSSReflectValue.cpp in Sources */,
     28609                                BC7D8FF31BD1A47900FFE540 /* CSSRevertValue.cpp in Sources */,
    2860228610                                A80E6D060A1989CA007FB8C5 /* CSSRule.cpp in Sources */,
    2860328611                                A80E6D090A1989CA007FB8C5 /* CSSRuleList.cpp in Sources */,
     
    2961829626                                BC06EDE30BFD6D0D00856E9D /* JSHTMLTableCellElement.cpp in Sources */,
    2961929627                                BC06ED9D0BFD660600856E9D /* JSHTMLTableColElement.cpp in Sources */,
     29628                                836CB1F91BD1E41800AF1591 /* JSHTMLTableDataCellElement.cpp in Sources */,
    2962029629                                BC06EE040BFD71AA00856E9D /* JSHTMLTableElement.cpp in Sources */,
     29630                                836CB1F71BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.cpp in Sources */,
    2962129631                                BC06ED9F0BFD660600856E9D /* JSHTMLTableRowElement.cpp in Sources */,
    2962229632                                BC06ED060BFD5BAE00856E9D /* JSHTMLTableSectionElement.cpp in Sources */,
     
    3052130531                                E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
    3052230532                                BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
    30523                                 836CB1F71BD1E41800AF1591 /* JSHTMLTableHeaderCellElement.cpp in Sources */,
    3052430533                                BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
    3052530534                                A871DFE50A15376B00B12A68 /* RenderWidget.cpp in Sources */,
     
    3129731306                                BCDFD48F0E305290009D10AD /* XMLHttpRequestUpload.cpp in Sources */,
    3129831307                                A833C80C0A2CF25600D57664 /* XMLNames.cpp in Sources */,
    31299                                 836CB1F91BD1E41800AF1591 /* JSHTMLTableDataCellElement.cpp in Sources */,
    3130031308                                E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */,
    3130131309                                1ACE53EA0A8D18E70022947D /* XMLSerializer.cpp in Sources */,
  • trunk/Source/WebCore/bindings/objc/DOMCSS.mm

    r191151 r191252  
    126126        case WebCore::CSSValue::CSS_INITIAL:
    127127        case WebCore::CSSValue::CSS_UNSET:
     128        case WebCore::CSSValue::CSS_REVERT:
    128129            return [DOMCSSValue class];
    129130        case WebCore::CSSValue::CSS_CUSTOM:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r191178 r191252  
    5858#include "CSSPropertySourceData.h"
    5959#include "CSSReflectValue.h"
     60#include "CSSRevertValue.h"
    6061#include "CSSSelector.h"
    6162#include "CSSShadowValue.h"
     
    11981199        // All properties accept the values of "initial" and "inherit".
    11991200        String lowerCaseString = string.lower();
    1200         if (lowerCaseString != "initial" && lowerCaseString != "inherit" && lowerCaseString != "unset")
     1201        if (lowerCaseString != "initial" && lowerCaseString != "inherit" && lowerCaseString != "unset" && lowerCaseString != "revert")
    12011202            return CSSParser::ParseResult::Error;
    12021203
    1203         // Parse initial/inherit/unset shorthands using the CSSParser.
     1204        // Parse initial/inherit/unset/revert shorthands using the CSSParser.
    12041205        if (shorthandForProperty(propertyId).length())
    12051206            return CSSParser::ParseResult::Error;
     
    12201221    else if (valueID == CSSValueUnset)
    12211222        value = CSSValuePool::singleton().createUnsetValue();
     1223    else if (valueID == CSSValueRevert)
     1224        value = CSSValuePool::singleton().createRevertValue();
    12221225    else if (isValidKeywordPropertyAndValue(propertyId, valueID, parserContext, styleSheetContents))
    12231226        value = CSSValuePool::singleton().createIdentifierValue(valueID);
     
    19651968            return false;
    19661969        addExpandedPropertyForValue(propId, cssValuePool.createUnsetValue(), important);
     1970        return true;
     1971    } else if (id == CSSValueRevert) {
     1972        if (num != 1)
     1973            return false;
     1974        addExpandedPropertyForValue(propId, cssValuePool.createRevertValue(), important);
    19671975        return true;
    19681976    }
     
    42144222    else if (id == CSSValueUnset)
    42154223        value = cssValuePool.createUnsetValue();
     4224    else if (id == CSSValueRevert)
     4225        value = cssValuePool.createRevertValue();
    42164226    else {
    42174227        RefPtr<CSSValueList> valueList = CSSValueList::createFromParserValueList(*m_valueList);
  • trunk/Source/WebCore/css/CSSValue.cpp

    r191201 r191252  
    115115    if (isUnsetValue())
    116116        return CSS_UNSET;
     117    if (isRevertValue())
     118        return CSS_REVERT;
    117119    return CSS_CUSTOM;
    118120}
     
    204206        case UnsetClass:
    205207            return compareCSSValues<CSSUnsetValue>(*this, other);
     208        case RevertClass:
     209            return compareCSSValues<CSSRevertValue>(*this, other);
    206210#if ENABLE(CSS_GRID_LAYOUT)
    207211        case GridLineNamesClass:
     
    306310    case UnsetClass:
    307311        return downcast<CSSUnsetValue>(*this).customCSSText();
     312    case RevertClass:
     313        return downcast<CSSRevertValue>(*this).customCSSText();
    308314#if ENABLE(CSS_GRID_LAYOUT)
    309315    case GridLineNamesClass:
     
    418424        delete downcast<CSSUnsetValue>(this);
    419425        return;
     426    case RevertClass:
     427        delete downcast<CSSRevertValue>(this);
     428        return;
    420429#if ENABLE(CSS_GRID_LAYOUT)
    421430    case GridLineNamesClass:
  • trunk/Source/WebCore/css/CSSValue.h

    r191151 r191252  
    4848        CSS_CUSTOM = 3,
    4949        CSS_INITIAL = 4,
    50         CSS_UNSET = 5
     50        CSS_UNSET = 5,
     51        CSS_REVERT = 6
    5152    };
    5253
     
    9596    bool isInitialValue() const { return m_classType == InitialClass; }
    9697    bool isUnsetValue() const { return m_classType == UnsetClass; }
     98    bool isRevertValue() const { return m_classType == RevertClass; }
    9799    bool treatAsInitialValue(CSSPropertyID) const;
    98100    bool treatAsInheritedValue(CSSPropertyID) const;
     
    170172        InitialClass,
    171173        UnsetClass,
     174        RevertClass,
    172175
    173176        ReflectClass,
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r191151 r191252  
    55initial
    66unset
     7revert
    78
    89//
  • trunk/Source/WebCore/css/CSSValuePool.cpp

    r191151 r191252  
    4646    , m_explicitInitialValue(CSSInitialValue::createExplicit())
    4747    , m_unsetValue(CSSUnsetValue::create())
     48    , m_revertValue(CSSRevertValue::create())
    4849    , m_colorTransparent(CSSPrimitiveValue::createColor(Color::transparent))
    4950    , m_colorWhite(CSSPrimitiveValue::createColor(Color::white))
  • trunk/Source/WebCore/css/CSSValuePool.h

    r191151 r191252  
    3232#include "CSSPrimitiveValue.h"
    3333#include "CSSPropertyNames.h"
     34#include "CSSRevertValue.h"
    3435#include "CSSUnsetValue.h"
    3536#include "CSSValueKeywords.h"
     
    5758    Ref<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.copyRef(); }
    5859    Ref<CSSUnsetValue> createUnsetValue() { return m_unsetValue.copyRef(); }
     60    Ref<CSSRevertValue> createRevertValue() { return m_revertValue.copyRef(); }
    5961    Ref<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier);
    6062    Ref<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier);
     
    7577    Ref<CSSInitialValue> m_explicitInitialValue;
    7678    Ref<CSSUnsetValue> m_unsetValue;
     79    Ref<CSSRevertValue> m_revertValue;
    7780
    7881    RefPtr<CSSPrimitiveValue> m_identifierValueCache[numCSSValueKeywords];
  • trunk/Source/WebCore/css/FontLoader.cpp

    r187706 r191252  
    301301   
    302302    String fontValue = parsedStyle->getPropertyValue(CSSPropertyFont);
    303     if (fontValue == "inherit" || fontValue == "initial")
     303    if (fontValue == "inherit" || fontValue == "initial" || fontValue == "unset" || fontValue == "revert")
    304304        return false;
    305305
  • trunk/Source/WebCore/css/SelectorChecker.h

    r182129 r191252  
    103103    static bool checkExactAttribute(const Element*, const CSSSelector*, const QualifiedName& selectorAttributeName, const AtomicStringImpl* value);
    104104
    105     enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
     105    enum LinkMatchMask { MatchDefault = 0, MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink | MatchVisited };
    106106    static unsigned determineLinkMatchType(const CSSSelector*);
    107107
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r191151 r191252  
    174174static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1);
    175175
    176 class StyleResolver::CascadedProperties {
    177 public:
    178     CascadedProperties(TextDirection, WritingMode);
    179 
    180     struct Property {
    181         void apply(StyleResolver&);
    182 
    183         CSSPropertyID id;
    184         CSSValue* cssValue[3];
    185     };
    186 
    187     bool hasProperty(CSSPropertyID id) const;
    188     Property& property(CSSPropertyID);
    189     void addMatches(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly = false);
    190 
    191     void set(CSSPropertyID, CSSValue&, unsigned linkMatchType);
    192     void setDeferred(CSSPropertyID, CSSValue&, unsigned linkMatchType);
    193 
    194     void applyDeferredProperties(StyleResolver&);
    195 
    196     HashMap<AtomicString, Property>& customProperties() { return m_customProperties; }
    197    
    198 private:
    199     void addStyleProperties(const StyleProperties&, StyleRule&, bool isImportant, bool inheritedOnly, PropertyWhitelistType, unsigned linkMatchType);
    200     static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, unsigned linkMatchType);
    201 
    202     Property m_properties[numCSSProperties + 2];
    203     std::bitset<numCSSProperties + 2> m_propertyIsPresent;
    204 
    205     Vector<Property, 8> m_deferredProperties;
    206     HashMap<AtomicString, Property> m_customProperties;
    207 
    208     TextDirection m_direction;
    209     WritingMode m_writingMode;
    210 };
    211 
    212176static void extractDirectionAndWritingMode(const RenderStyle&, const StyleResolver::MatchResult&, TextDirection&, WritingMode&);
    213177
     
    441405    m_pendingImageProperties.clear();
    442406    m_fontDirty = false;
     407   
     408    m_authorRollback = nullptr;
     409    m_userRollback = nullptr;
    443410
    444411    updateConversionData();
     
    855822   
    856823    // Resolve custom properties first.
    857     applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom);
    858 
    859     applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty);
     824    applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom, &result);
     825
     826    applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty, &result);
    860827
    861828    // If our font got dirtied, update it now.
     
    863830
    864831    // Now do rest of the properties.
    865     applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty);
     832    applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty, &result);
    866833
    867834    // If our font got dirtied by one of the non-essential font props, update it a second time.
    868835    updateFont();
    869836
    870     cascade.applyDeferredProperties(*this);
     837    cascade.applyDeferredProperties(*this, &result);
    871838
    872839    // Start loading resources referenced by this style.
     
    1023990
    1024991    // Resolve custom properties first.
    1025     applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom);
    1026 
    1027     applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty);
     992    applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom, &result);
     993
     994    applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty, &result);
    1028995
    1029996    // If our font got dirtied, update it now.
    1030997    updateFont();
    1031998
    1032     applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty);
    1033 
    1034     cascade.applyDeferredProperties(*this);
     999    applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty, &result);
     1000
     1001    cascade.applyDeferredProperties(*this, &result);
    10351002
    10361003    // Start loading resources referenced by this style.
     
    16981665        cascade.addMatches(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
    16991666
    1700         applyCascadedProperties(cascade, CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition);
     1667        applyCascadedProperties(cascade, CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition, &matchResult);
    17011668        adjustStyleForInterCharacterRuby();
    17021669   
    17031670        // Resolve custom variables first.
    1704         applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom);
     1671        applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom, &matchResult);
    17051672
    17061673        // Start by applying properties that other properties may depend on.
    1707         applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty);
     1674        applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty, &matchResult);
    17081675   
    17091676        updateFont();
    1710         applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty);
     1677        applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty, &matchResult);
    17111678
    17121679        state.cacheBorderAndBackground();
     
    17201687   
    17211688    // Resolve custom properties first.
    1722     applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom);
    1723 
    1724     applyCascadedProperties(cascade, CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition);
     1689    applyCascadedProperties(cascade, CSSPropertyCustom, CSSPropertyCustom, &matchResult);
     1690
     1691    applyCascadedProperties(cascade, CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition, &matchResult);
    17251692   
    17261693    // Adjust the font size to be smaller if ruby-position is inter-character.
     
    17281695
    17291696    // Start by applying properties that other properties may depend on.
    1730     applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty);
     1697    applyCascadedProperties(cascade, firstCSSProperty, lastHighPriorityProperty, &matchResult);
    17311698
    17321699    // If the effective zoom value changes, we can't use the matched properties cache. Start over.
     
    17421709
    17431710    // Apply properties that no other properties depend on.
    1744     applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty);
     1711    applyCascadedProperties(cascade, firstLowPriorityProperty, lastCSSProperty, &matchResult);
    17451712
    17461713    // Finally, some properties must be applied in the order they were parsed.
    17471714    // There are some CSS properties that affect the same RenderStyle values,
    17481715    // so to preserve behavior, we queue them up during cascade and flush here.
    1749     cascade.applyDeferredProperties(*this);
     1716    cascade.applyDeferredProperties(*this, &matchResult);
    17501717
    17511718    // Start loading resources referenced by this style.
     
    18771844}
    18781845
    1879 void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value)
     1846StyleResolver::CascadedProperties* StyleResolver::cascadedPropertiesForRollback(const MatchResult& matchResult)
     1847{
     1848    ASSERT(cascadeLevel() != UserAgentLevel);
     1849   
     1850    TextDirection direction;
     1851    WritingMode writingMode;
     1852    extractDirectionAndWritingMode(*state().style(), matchResult, direction, writingMode);
     1853
     1854    if (cascadeLevel() == AuthorLevel) {
     1855        CascadedProperties* authorRollback = state().authorRollback();
     1856        if (authorRollback)
     1857            return authorRollback;
     1858       
     1859        auto newAuthorRollback(std::make_unique<CascadedProperties>(direction, writingMode));
     1860       
     1861        // This special rollback cascade contains UA rules and user rules but no author rules.
     1862        newAuthorRollback->addMatches(matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, false);
     1863        newAuthorRollback->addMatches(matchResult, false, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, false);
     1864        newAuthorRollback->addMatches(matchResult, true, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, false);
     1865        newAuthorRollback->addMatches(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, false);
     1866   
     1867        state().setAuthorRollback(newAuthorRollback);
     1868        return state().authorRollback();
     1869    }
     1870   
     1871    if (cascadeLevel() == UserLevel) {
     1872        CascadedProperties* userRollback = state().userRollback();
     1873        if (userRollback)
     1874            return userRollback;
     1875       
     1876        auto newUserRollback(std::make_unique<CascadedProperties>(direction, writingMode));
     1877       
     1878        // This special rollback cascade contains only UA rules.
     1879        newUserRollback->addMatches(matchResult, false, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, false);
     1880        newUserRollback->addMatches(matchResult, true, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, false);
     1881   
     1882        state().setUserRollback(newUserRollback);
     1883        return state().userRollback();
     1884    }
     1885   
     1886    return nullptr;
     1887}
     1888
     1889void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value, SelectorChecker::LinkMatchMask linkMatchMask, const MatchResult* matchResult)
    18801890{
    18811891    ASSERT_WITH_MESSAGE(!isShorthandCSSProperty(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
     
    18971907        CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, state.style()->direction(), state.style()->writingMode());
    18981908        ASSERT(newId != id);
    1899         return applyProperty(newId, valueToApply.get());
     1909        return applyProperty(newId, valueToApply.get(), linkMatchMask, matchResult);
    19001910    }
    19011911   
    19021912    CSSValue* valueToCheckForInheritInitial = valueToApply.get();
     1913    CSSCustomPropertyValue* customPropertyValue = nullptr;
     1914   
    19031915    if (id == CSSPropertyCustom) {
    1904         CSSCustomPropertyValue* customProperty = &downcast<CSSCustomPropertyValue>(*valueToApply);
    1905         valueToCheckForInheritInitial = customProperty->value().get();
     1916        customPropertyValue = &downcast<CSSCustomPropertyValue>(*valueToApply);
     1917        valueToCheckForInheritInitial = customPropertyValue->value().get();
    19061918    }
    19071919
     
    19091921    bool isInitial = valueToCheckForInheritInitial->isInitialValue() || (!state.parentStyle() && valueToCheckForInheritInitial->isInheritedValue());
    19101922   
    1911     if (valueToCheckForInheritInitial->isUnsetValue()) {
     1923    bool isUnset = valueToCheckForInheritInitial->isUnsetValue();
     1924    bool isRevert = valueToCheckForInheritInitial->isRevertValue();
     1925
     1926    if (isRevert) {
     1927        if (cascadeLevel() == UserAgentLevel || !matchResult)
     1928            isUnset = true;
     1929        else {
     1930            // Fetch the correct rollback object from the state, building it if necessary.
     1931            // This requires having the original MatchResult available.
     1932            auto* rollback = cascadedPropertiesForRollback(*matchResult);
     1933            ASSERT(rollback);
     1934
     1935            // With the cascade built, we need to obtain the property and apply it. If the property is
     1936            // not present, then we behave like "unset." Otherwise we apply the property instead of
     1937            // our own.
     1938            if (customPropertyValue) {
     1939                if (rollback->hasCustomProperty(customPropertyValue->name())) {
     1940                    auto property = rollback->customProperty(customPropertyValue->name());
     1941                    if (property.cssValue[linkMatchMask])
     1942                        applyProperty(property.id, property.cssValue[linkMatchMask], linkMatchMask, matchResult);
     1943                    return;
     1944                }
     1945            } else if (rollback->hasProperty(id)) {
     1946                auto& property = rollback->property(id);
     1947                if (property.cssValue[linkMatchMask])
     1948                    applyProperty(property.id, property.cssValue[linkMatchMask], linkMatchMask, matchResult);
     1949                return;
     1950            }
     1951       
     1952            isUnset = true;
     1953        }
     1954    }
     1955   
     1956    if (isUnset) {
    19121957        if (CSSProperty::isInheritedProperty(id))
    19131958            isInherit = true;
     
    19151960            isInitial = true;
    19161961    }
    1917    
     1962
    19181963    ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
    19191964
     
    25692614}
    25702615
    2571 void StyleResolver::CascadedProperties::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType)
     2616inline bool StyleResolver::CascadedProperties::hasCustomProperty(const String& name) const
     2617{
     2618    return m_customProperties.contains(name);
     2619}
     2620
     2621inline StyleResolver::CascadedProperties::Property StyleResolver::CascadedProperties::customProperty(const String& name) const
     2622{
     2623    return m_customProperties.get(name);
     2624}
     2625
     2626void StyleResolver::CascadedProperties::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel)
    25722627{
    25732628    ASSERT(linkMatchType <= SelectorChecker::MatchAll);
    25742629    property.id = id;
     2630    property.level = cascadeLevel;
    25752631    if (linkMatchType == SelectorChecker::MatchAll) {
    25762632        property.cssValue[0] = &cssValue;
     
    25812637}
    25822638
    2583 void StyleResolver::CascadedProperties::set(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType)
     2639void StyleResolver::CascadedProperties::set(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel)
    25842640{
    25852641    if (CSSProperty::isDirectionAwareProperty(id))
     
    25982654            property.id = id;
    25992655            memset(property.cssValue, 0, sizeof(property.cssValue));
    2600             setPropertyInternal(property, id, cssValue, linkMatchType);
     2656            setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel);
    26012657            customProperties().set(customValue.name(), property);
    26022658        } else {
    26032659            Property property = customProperties().get(customValue.name());
    2604             setPropertyInternal(property, id, cssValue, linkMatchType);
     2660            setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel);
    26052661            customProperties().set(customValue.name(), property);
    26062662        }
     
    26112667        memset(property.cssValue, 0, sizeof(property.cssValue));
    26122668    m_propertyIsPresent.set(id);
    2613     setPropertyInternal(property, id, cssValue, linkMatchType);
    2614 }
    2615 
    2616 void StyleResolver::CascadedProperties::setDeferred(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType)
     2669    setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel);
     2670}
     2671
     2672void StyleResolver::CascadedProperties::setDeferred(CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel)
    26172673{
    26182674    ASSERT(!CSSProperty::isDirectionAwareProperty(id));
     
    26212677    Property property;
    26222678    memset(property.cssValue, 0, sizeof(property.cssValue));
    2623     setPropertyInternal(property, id, cssValue, linkMatchType);
     2679    setPropertyInternal(property, id, cssValue, linkMatchType, cascadeLevel);
    26242680    m_deferredProperties.append(property);
    26252681}
    26262682
    2627 void StyleResolver::CascadedProperties::addStyleProperties(const StyleProperties& properties, StyleRule&, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType, unsigned linkMatchType)
     2683void StyleResolver::CascadedProperties::addStyleProperties(const StyleProperties& properties, StyleRule&, bool isImportant, bool inheritedOnly, PropertyWhitelistType propertyWhitelistType, unsigned linkMatchType, CascadeLevel cascadeLevel)
    26282684{
    26292685    for (unsigned i = 0, count = properties.propertyCount(); i < count; ++i) {
     
    26472703
    26482704        if (shouldApplyPropertyInParseOrder(propertyID))
    2649             setDeferred(propertyID, *current.value(), linkMatchType);
     2705            setDeferred(propertyID, *current.value(), linkMatchType, cascadeLevel);
    26502706        else
    2651             set(propertyID, *current.value(), linkMatchType);
    2652     }
     2707            set(propertyID, *current.value(), linkMatchType, cascadeLevel);
     2708    }
     2709}
     2710
     2711static CascadeLevel cascadeLevelForIndex(const StyleResolver::MatchResult& matchResult, int index)
     2712{
     2713    if (index >= matchResult.ranges.firstUARule && index <= matchResult.ranges.lastUARule)
     2714        return UserAgentLevel;
     2715    if (index >= matchResult.ranges.firstUserRule && index <= matchResult.ranges.lastUserRule)
     2716        return UserLevel;
     2717    return AuthorLevel;
    26532718}
    26542719
     
    26602725    for (int i = startIndex; i <= endIndex; ++i) {
    26612726        const MatchedProperties& matchedProperties = matchResult.matchedProperties()[i];
    2662         addStyleProperties(*matchedProperties.properties, *matchResult.matchedRules[i], important, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType), matchedProperties.linkMatchType);
    2663     }
    2664 }
    2665 
    2666 void StyleResolver::CascadedProperties::applyDeferredProperties(StyleResolver& resolver)
     2727        addStyleProperties(*matchedProperties.properties, *matchResult.matchedRules[i], important, inheritedOnly, static_cast<PropertyWhitelistType>(matchedProperties.whitelistType), matchedProperties.linkMatchType,
     2728            cascadeLevelForIndex(matchResult, i));
     2729    }
     2730}
     2731
     2732void StyleResolver::CascadedProperties::applyDeferredProperties(StyleResolver& resolver, const MatchResult* matchResult)
    26672733{
    26682734    for (auto& property : m_deferredProperties)
    2669         property.apply(resolver);
    2670 }
    2671 
    2672 void StyleResolver::CascadedProperties::Property::apply(StyleResolver& resolver)
     2735        property.apply(resolver, matchResult);
     2736}
     2737
     2738void StyleResolver::CascadedProperties::Property::apply(StyleResolver& resolver, const MatchResult* matchResult)
    26732739{
    26742740    State& state = resolver.state();
    2675 
    2676     if (cssValue[0]) {
     2741    state.setCascadeLevel(level);
     2742
     2743    if (cssValue[SelectorChecker::MatchDefault]) {
    26772744        state.setApplyPropertyToRegularStyle(true);
    26782745        state.setApplyPropertyToVisitedLinkStyle(false);
    2679         resolver.applyProperty(id, cssValue[0]);
     2746        resolver.applyProperty(id, cssValue[SelectorChecker::MatchDefault], SelectorChecker::MatchDefault, matchResult);
    26802747    }
    26812748
     
    26862753        state.setApplyPropertyToRegularStyle(true);
    26872754        state.setApplyPropertyToVisitedLinkStyle(false);
    2688         resolver.applyProperty(id, cssValue[SelectorChecker::MatchLink]);
     2755        resolver.applyProperty(id, cssValue[SelectorChecker::MatchLink], SelectorChecker::MatchLink, matchResult);
    26892756    }
    26902757
     
    26922759        state.setApplyPropertyToRegularStyle(false);
    26932760        state.setApplyPropertyToVisitedLinkStyle(true);
    2694         resolver.applyProperty(id, cssValue[SelectorChecker::MatchVisited]);
     2761        resolver.applyProperty(id, cssValue[SelectorChecker::MatchVisited], SelectorChecker::MatchVisited, matchResult);
    26952762    }
    26962763
     
    26992766}
    27002767
    2701 void StyleResolver::applyCascadedProperties(CascadedProperties& cascade, int firstProperty, int lastProperty)
     2768void StyleResolver::applyCascadedProperties(CascadedProperties& cascade, int firstProperty, int lastProperty, const MatchResult* matchResult)
    27022769{
    27032770    for (int id = firstProperty; id <= lastProperty; ++id) {
     
    27082775            HashMap<AtomicString, CascadedProperties::Property>::iterator end = cascade.customProperties().end();
    27092776            for (HashMap<AtomicString, CascadedProperties::Property>::iterator it = cascade.customProperties().begin(); it != end; ++it)
    2710                 it->value.apply(*this);
     2777                it->value.apply(*this, matchResult);
    27112778            continue;
    27122779        }
    27132780        auto& property = cascade.property(propertyID);
    27142781        ASSERT(!shouldApplyPropertyInParseOrder(propertyID));
    2715         property.apply(*this);
     2782        property.apply(*this, matchResult);
    27162783    }
    27172784   
  • trunk/Source/WebCore/css/StyleResolver.h

    r191128 r191252  
    3939#include "StyleInheritedData.h"
    4040#include "ViewportStyleResolver.h"
     41#include <bitset>
    4142#include <memory>
    4243#include <wtf/HashMap.h>
     
    121122};
    122123
     124enum CascadeLevel {
     125    UserAgentLevel,
     126    AuthorLevel,
     127    UserLevel
     128};
     129
    123130class PseudoStyleRequest {
    124131public:
     
    195202
    196203public:
     204    struct MatchResult;
     205
    197206    void applyPropertyToStyle(CSSPropertyID, CSSValue*, RenderStyle*);
    198207
     
    285294        Vector<MatchedProperties, 64> m_matchedProperties;
    286295    };
     296   
     297    class CascadedProperties {
     298    public:
     299        CascadedProperties(TextDirection, WritingMode);
     300
     301        struct Property {
     302            void apply(StyleResolver&, const MatchResult*);
     303
     304            CSSPropertyID id;
     305            CascadeLevel level;
     306            CSSValue* cssValue[3];
     307        };
     308
     309        bool hasProperty(CSSPropertyID) const;
     310        Property& property(CSSPropertyID);
     311        void addMatches(const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly = false);
     312
     313        void set(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel);
     314        void setDeferred(CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel);
     315
     316        void applyDeferredProperties(StyleResolver&, const MatchResult*);
     317
     318        HashMap<AtomicString, Property>& customProperties() { return m_customProperties; }
     319        bool hasCustomProperty(const String&) const;
     320        Property customProperty(const String&) const;
     321       
     322    private:
     323        void addStyleProperties(const StyleProperties&, StyleRule&, bool isImportant, bool inheritedOnly, PropertyWhitelistType, unsigned linkMatchType, CascadeLevel);
     324        static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, unsigned linkMatchType, CascadeLevel);
     325
     326        Property m_properties[numCSSProperties + 2];
     327        std::bitset<numCSSProperties + 2> m_propertyIsPresent;
     328
     329        Vector<Property, 8> m_deferredProperties;
     330        HashMap<AtomicString, Property> m_customProperties;
     331
     332        TextDirection m_direction;
     333        WritingMode m_writingMode;
     334    };
    287335
    288336private:
     
    306354    void applyMatchedProperties(const MatchResult&, const Element*, ShouldUseMatchedPropertiesCache = UseMatchedPropertiesCache);
    307355
    308     class CascadedProperties;
    309 
    310     void applyCascadedProperties(CascadedProperties&, int firstProperty, int lastProperty);
     356    void applyCascadedProperties(CascadedProperties&, int firstProperty, int lastProperty, const MatchResult*);
    311357    void cascadeMatches(CascadedProperties&, const MatchResult&, bool important, int startIndex, int endIndex, bool inheritedOnly);
    312358
     
    377423        bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
    378424        PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; }
    379 
     425       
    380426        Vector<RefPtr<ReferenceFilterOperation>>& filtersWithPendingSVGDocuments() { return m_filtersWithPendingSVGDocuments; }
    381427
     
    403449        CSSToLengthConversionData cssToLengthConversionData() const { return m_cssToLengthConversionData; }
    404450
     451        CascadeLevel cascadeLevel() const { return m_cascadeLevel; }
     452        void setCascadeLevel(CascadeLevel level) { m_cascadeLevel = level; }
     453       
     454        CascadedProperties* authorRollback() const { return m_authorRollback.get(); }
     455        CascadedProperties* userRollback() const { return m_userRollback.get(); }
     456       
     457        void setAuthorRollback(std::unique_ptr<CascadedProperties>& rollback) { m_authorRollback = WTF::move(rollback); }
     458        void setUserRollback(std::unique_ptr<CascadedProperties>& rollback) { m_userRollback = WTF::move(rollback); }
     459       
    405460    private:
    406461        void updateConversionData();
     
    435490
    436491        CSSToLengthConversionData m_cssToLengthConversionData;
     492       
     493        CascadeLevel m_cascadeLevel { UserAgentLevel };
     494        std::unique_ptr<CascadedProperties> m_authorRollback;
     495        std::unique_ptr<CascadedProperties> m_userRollback;
    437496    };
    438497
     
    451510    bool applyPropertyToRegularStyle() const { return m_state.applyPropertyToRegularStyle(); }
    452511    bool applyPropertyToVisitedLinkStyle() const { return m_state.applyPropertyToVisitedLinkStyle(); }
     512
     513    CascadeLevel cascadeLevel() const { return m_state.cascadeLevel(); }
     514    void setCascadeLevel(CascadeLevel level) { m_state.setCascadeLevel(level); }
     515   
     516    CascadedProperties* cascadedPropertiesForRollback(const MatchResult&);
    453517
    454518    CSSToStyleMap* styleMap() { return &m_styleMap; }
     
    469533    bool canShareStyleWithControl(StyledElement*) const;
    470534
    471     void applyProperty(CSSPropertyID, CSSValue*);
     535    void applyProperty(CSSPropertyID, CSSValue*, SelectorChecker::LinkMatchMask = SelectorChecker::MatchDefault, const MatchResult* = nullptr);
    472536    RefPtr<CSSValue> resolvedVariableValue(CSSPropertyID, const CSSVariableDependentValue&);
    473537
Note: See TracChangeset for help on using the changeset viewer.