Changeset 205660 in webkit


Ignore:
Timestamp:
Sep 8, 2016 2:09:04 PM (8 years ago)
Author:
hyatt@apple.com
Message:

[CSS Parser] Add support for new CSS selector parsing
https://bugs.webkit.org/show_bug.cgi?id=161749

Reviewed by Dean Jackson.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::isValidSelector):

  • css/CSSDefaultStyleSheets.cpp:

(WebCore::parseUASheet):

  • css/CSSFontFaceSet.cpp:

(WebCore::CSSFontFaceSet::matchingFaces):

  • css/CSSGrammar.y.in:
  • css/CSSSelector.cpp:

(WebCore::CSSSelector::selectorText):

  • css/CSSSelector.h:
  • css/DOMCSSNamespace.cpp:

(WebCore::DOMCSSNamespace::supports):

  • css/FontFace.cpp:

(WebCore::FontFace::parseString):
(WebCore::FontFace::setVariant):

  • css/MediaList.cpp:

(WebCore::MediaQuerySet::internalParse):
(WebCore::MediaQuerySet::parse):

  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::matchRecursively):

  • css/SelectorFilter.cpp:

(WebCore::SelectorFilter::collectIdentifierHashes):

  • css/SelectorPseudoClassAndCompatibilityElementMap.in:
  • css/SelectorPseudoTypeMap.h:
  • css/SourceSizeList.cpp:

(WebCore::parseSizesAttribute):

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::MutableStyleProperties):

  • css/StyleProperties.h:
  • css/StyleRuleImport.cpp:

(WebCore::StyleRuleImport::setCSSStyleSheet):

  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::StyleSheetContents):
(WebCore::StyleSheetContents::parserAddNamespace):
(WebCore::StyleSheetContents::namespaceURIFromPrefix):
(WebCore::StyleSheetContents::determineNamespace): Deleted.

  • css/StyleSheetContents.h:
  • css/WebKitCSSMatrix.cpp:

(WebCore::WebKitCSSMatrix::setMatrixValue):

  • css/makeSelectorPseudoClassAndCompatibilityElementMap.py:
  • css/parser/CSSParser.cpp:

(WebCore::strictCSSParserContext):
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::CSSParser::parseColor):
(WebCore::CSSParser::shouldAcceptUnitLessValues):
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseColumnWidth):
(WebCore::CSSParser::parseColumnCount):
(WebCore::CSSParser::parseFontWeight):
(WebCore::CSSParser::parseColorParameters):
(WebCore::CSSParser::parseHSLParameters):
(WebCore::CSSParser::parseShadow):
(WebCore::CSSParser::parseBorderImageSlice):
(WebCore::CSSParser::parseBorderImageQuad):
(WebCore::CSSParser::parseDeprecatedLinearGradient):
(WebCore::CSSParser::parseLinearGradient):
(WebCore::CSSParser::parseTransformValue):
(WebCore::CSSParser::parseBuiltinFilterArguments):
(WebCore::CSSParser::determineNameInNamespace):

  • css/parser/CSSParser.h:

(WebCore::CSSParser::inStrictMode):
(WebCore::CSSParser::inQuirksMode):

  • css/parser/CSSParserMode.h:

(WebCore::isQuirksModeBehavior):
(WebCore::isUASheetBehavior):
(WebCore::isUnitLessLengthParsingEnabledForMode):
(WebCore::isCSSViewportParsingEnabledForMode):
(WebCore::strictToCSSParserMode):
(WebCore::isStrictParserMode):

  • css/parser/CSSParserValues.cpp:

(WebCore::CSSParserSelector::parsePseudoElementSelectorFromStringView):
(WebCore::CSSParserSelector::parsePseudoClassSelectorFromStringView):
(WebCore::CSSParserSelector::setSelectorList):
(WebCore::CSSParserSelector::appendTagHistory):
(WebCore::CSSParserSelector::releaseTagHistory):
(WebCore::CSSParserSelector::isHostPseudoSelector):

  • css/parser/CSSParserValues.h:

(WebCore::CSSParserSelector::match):
(WebCore::CSSParserSelector::pseudoElementType):
(WebCore::CSSParserSelector::selectorList):
(WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching):

  • css/parser/CSSPropertyParser.h:

(WebCore::CSSPropertyParser::inQuirksMode):

  • css/parser/CSSSelectorParser.cpp: Added.

(WebCore::CSSSelectorParser::parseSelector):
(WebCore::CSSSelectorParser::CSSSelectorParser):
(WebCore::CSSSelectorParser::consumeComplexSelectorList):
(WebCore::CSSSelectorParser::consumeCompoundSelectorList):
(WebCore::CSSSelectorParser::consumeComplexSelector):
(WebCore::CSSSelectorParser::consumeCompoundSelector):
(WebCore::CSSSelectorParser::consumeSimpleSelector):
(WebCore::CSSSelectorParser::consumeName):
(WebCore::CSSSelectorParser::consumeId):
(WebCore::CSSSelectorParser::consumeClass):
(WebCore::CSSSelectorParser::consumeAttribute):
(WebCore::CSSSelectorParser::consumePseudo):
(WebCore::CSSSelectorParser::consumeCombinator):
(WebCore::CSSSelectorParser::consumeAttributeMatch):
(WebCore::CSSSelectorParser::consumeAttributeFlags):
(WebCore::CSSSelectorParser::consumeANPlusB):
(WebCore::CSSSelectorParser::defaultNamespace):
(WebCore::CSSSelectorParser::determineNamespace):
(WebCore::CSSSelectorParser::prependTypeSelectorIfNeeded):
(WebCore::CSSSelectorParser::addSimpleSelectorToCompound):
(WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):

  • css/parser/CSSSelectorParser.h: Added.

(WebCore::CSSSelectorParser::DisallowPseudoElementsScope::DisallowPseudoElementsScope):
(WebCore::CSSSelectorParser::DisallowPseudoElementsScope::~DisallowPseudoElementsScope):

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):

  • dom/StyledElement.cpp:

(WebCore::StyledElement::rebuildPresentationAttributeStyle):

  • svg/SVGFontFaceElement.cpp:

(WebCore::SVGFontFaceElement::SVGFontFaceElement):

Location:
trunk/Source/WebCore
Files:
2 added
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r205581 r205660  
    13601360    css/parser/CSSPropertyParser.cpp
    13611361    css/parser/CSSPropertyParserHelpers.cpp
     1362    css/parser/CSSSelectorParser.cpp
    13621363    css/parser/CSSTokenizer.cpp
    13631364    css/parser/CSSTokenizerInputStream.cpp
  • trunk/Source/WebCore/ChangeLog

    r205659 r205660  
     12016-09-08  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Add support for new CSS selector parsing
     4        https://bugs.webkit.org/show_bug.cgi?id=161749
     5
     6        Reviewed by Dean Jackson.
     7
     8        * CMakeLists.txt:
     9        * WebCore.xcodeproj/project.pbxproj:
     10        * contentextensions/ContentExtensionParser.cpp:
     11        (WebCore::ContentExtensions::isValidSelector):
     12        * css/CSSDefaultStyleSheets.cpp:
     13        (WebCore::parseUASheet):
     14        * css/CSSFontFaceSet.cpp:
     15        (WebCore::CSSFontFaceSet::matchingFaces):
     16        * css/CSSGrammar.y.in:
     17        * css/CSSSelector.cpp:
     18        (WebCore::CSSSelector::selectorText):
     19        * css/CSSSelector.h:
     20        * css/DOMCSSNamespace.cpp:
     21        (WebCore::DOMCSSNamespace::supports):
     22        * css/FontFace.cpp:
     23        (WebCore::FontFace::parseString):
     24        (WebCore::FontFace::setVariant):
     25        * css/MediaList.cpp:
     26        (WebCore::MediaQuerySet::internalParse):
     27        (WebCore::MediaQuerySet::parse):
     28        * css/SelectorChecker.cpp:
     29        (WebCore::SelectorChecker::matchRecursively):
     30        * css/SelectorFilter.cpp:
     31        (WebCore::SelectorFilter::collectIdentifierHashes):
     32        * css/SelectorPseudoClassAndCompatibilityElementMap.in:
     33        * css/SelectorPseudoTypeMap.h:
     34        * css/SourceSizeList.cpp:
     35        (WebCore::parseSizesAttribute):
     36        * css/StyleProperties.cpp:
     37        (WebCore::MutableStyleProperties::MutableStyleProperties):
     38        * css/StyleProperties.h:
     39        * css/StyleRuleImport.cpp:
     40        (WebCore::StyleRuleImport::setCSSStyleSheet):
     41        * css/StyleSheetContents.cpp:
     42        (WebCore::StyleSheetContents::StyleSheetContents):
     43        (WebCore::StyleSheetContents::parserAddNamespace):
     44        (WebCore::StyleSheetContents::namespaceURIFromPrefix):
     45        (WebCore::StyleSheetContents::determineNamespace): Deleted.
     46        * css/StyleSheetContents.h:
     47        * css/WebKitCSSMatrix.cpp:
     48        (WebCore::WebKitCSSMatrix::setMatrixValue):
     49        * css/makeSelectorPseudoClassAndCompatibilityElementMap.py:
     50        * css/parser/CSSParser.cpp:
     51        (WebCore::strictCSSParserContext):
     52        (WebCore::CSSParserContext::CSSParserContext):
     53        (WebCore::CSSParser::parseColor):
     54        (WebCore::CSSParser::shouldAcceptUnitLessValues):
     55        (WebCore::CSSParser::parseValue):
     56        (WebCore::CSSParser::parseColumnWidth):
     57        (WebCore::CSSParser::parseColumnCount):
     58        (WebCore::CSSParser::parseFontWeight):
     59        (WebCore::CSSParser::parseColorParameters):
     60        (WebCore::CSSParser::parseHSLParameters):
     61        (WebCore::CSSParser::parseShadow):
     62        (WebCore::CSSParser::parseBorderImageSlice):
     63        (WebCore::CSSParser::parseBorderImageQuad):
     64        (WebCore::CSSParser::parseDeprecatedLinearGradient):
     65        (WebCore::CSSParser::parseLinearGradient):
     66        (WebCore::CSSParser::parseTransformValue):
     67        (WebCore::CSSParser::parseBuiltinFilterArguments):
     68        (WebCore::CSSParser::determineNameInNamespace):
     69        * css/parser/CSSParser.h:
     70        (WebCore::CSSParser::inStrictMode):
     71        (WebCore::CSSParser::inQuirksMode):
     72        * css/parser/CSSParserMode.h:
     73        (WebCore::isQuirksModeBehavior):
     74        (WebCore::isUASheetBehavior):
     75        (WebCore::isUnitLessLengthParsingEnabledForMode):
     76        (WebCore::isCSSViewportParsingEnabledForMode):
     77        (WebCore::strictToCSSParserMode):
     78        (WebCore::isStrictParserMode):
     79        * css/parser/CSSParserValues.cpp:
     80        (WebCore::CSSParserSelector::parsePseudoElementSelectorFromStringView):
     81        (WebCore::CSSParserSelector::parsePseudoClassSelectorFromStringView):
     82        (WebCore::CSSParserSelector::setSelectorList):
     83        (WebCore::CSSParserSelector::appendTagHistory):
     84        (WebCore::CSSParserSelector::releaseTagHistory):
     85        (WebCore::CSSParserSelector::isHostPseudoSelector):
     86        * css/parser/CSSParserValues.h:
     87        (WebCore::CSSParserSelector::match):
     88        (WebCore::CSSParserSelector::pseudoElementType):
     89        (WebCore::CSSParserSelector::selectorList):
     90        (WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching):
     91        * css/parser/CSSPropertyParser.h:
     92        (WebCore::CSSPropertyParser::inQuirksMode):
     93        * css/parser/CSSSelectorParser.cpp: Added.
     94        (WebCore::CSSSelectorParser::parseSelector):
     95        (WebCore::CSSSelectorParser::CSSSelectorParser):
     96        (WebCore::CSSSelectorParser::consumeComplexSelectorList):
     97        (WebCore::CSSSelectorParser::consumeCompoundSelectorList):
     98        (WebCore::CSSSelectorParser::consumeComplexSelector):
     99        (WebCore::CSSSelectorParser::consumeCompoundSelector):
     100        (WebCore::CSSSelectorParser::consumeSimpleSelector):
     101        (WebCore::CSSSelectorParser::consumeName):
     102        (WebCore::CSSSelectorParser::consumeId):
     103        (WebCore::CSSSelectorParser::consumeClass):
     104        (WebCore::CSSSelectorParser::consumeAttribute):
     105        (WebCore::CSSSelectorParser::consumePseudo):
     106        (WebCore::CSSSelectorParser::consumeCombinator):
     107        (WebCore::CSSSelectorParser::consumeAttributeMatch):
     108        (WebCore::CSSSelectorParser::consumeAttributeFlags):
     109        (WebCore::CSSSelectorParser::consumeANPlusB):
     110        (WebCore::CSSSelectorParser::defaultNamespace):
     111        (WebCore::CSSSelectorParser::determineNamespace):
     112        (WebCore::CSSSelectorParser::prependTypeSelectorIfNeeded):
     113        (WebCore::CSSSelectorParser::addSimpleSelectorToCompound):
     114        (WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):
     115        * css/parser/CSSSelectorParser.h: Added.
     116        (WebCore::CSSSelectorParser::DisallowPseudoElementsScope::DisallowPseudoElementsScope):
     117        (WebCore::CSSSelectorParser::DisallowPseudoElementsScope::~DisallowPseudoElementsScope):
     118        * cssjit/SelectorCompiler.cpp:
     119        (WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):
     120        * dom/StyledElement.cpp:
     121        (WebCore::StyledElement::rebuildPresentationAttributeStyle):
     122        * svg/SVGFontFaceElement.cpp:
     123        (WebCore::SVGFontFaceElement::SVGFontFaceElement):
     124
    11252016-09-08  Simon Fraser  <simon.fraser@apple.com>
    2126
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r205581 r205660  
    33753375                94DE5C811D7F3A1400164F2A /* CSSAtRuleID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94DE5C7F1D7F39D000164F2A /* CSSAtRuleID.cpp */; };
    33763376                94DE5C821D7F3A1400164F2A /* CSSAtRuleID.h in Headers */ = {isa = PBXBuildFile; fileRef = 94DE5C801D7F39D000164F2A /* CSSAtRuleID.h */; };
     3377                94DE5C8D1D80802700164F2A /* CSSSelectorParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94DE5C8B1D80801500164F2A /* CSSSelectorParser.cpp */; };
     3378                94DE5C8E1D80802700164F2A /* CSSSelectorParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 94DE5C8C1D80801500164F2A /* CSSSelectorParser.h */; };
    33773379                96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */; };
    33783380                9703E1BF15DC4E37001F24C8 /* JSVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97E9EC8B15DC492F004F2E71 /* JSVoidCallback.cpp */; };
     
    1052610528                94DE5C7F1D7F39D000164F2A /* CSSAtRuleID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSAtRuleID.cpp; path = parser/CSSAtRuleID.cpp; sourceTree = "<group>"; };
    1052710529                94DE5C801D7F39D000164F2A /* CSSAtRuleID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSAtRuleID.h; path = parser/CSSAtRuleID.h; sourceTree = "<group>"; };
     10530                94DE5C8B1D80801500164F2A /* CSSSelectorParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSSSelectorParser.cpp; path = parser/CSSSelectorParser.cpp; sourceTree = "<group>"; };
     10531                94DE5C8C1D80801500164F2A /* CSSSelectorParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelectorParser.h; path = parser/CSSSelectorParser.h; sourceTree = "<group>"; };
    1052810532                950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGGraphicsElement.h; sourceTree = "<group>"; };
    1052910533                96ABA42214BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DOpenGLCommon.cpp; sourceTree = "<group>"; };
     
    1818518189                                949C77021D6E393500C0DE4F /* CSSPropertyParserHelpers.cpp */,
    1818618190                                949C77031D6E393500C0DE4F /* CSSPropertyParserHelpers.h */,
     18191                                94DE5C8B1D80801500164F2A /* CSSSelectorParser.cpp */,
     18192                                94DE5C8C1D80801500164F2A /* CSSSelectorParser.h */,
    1818718193                                946D37341D6CDF980077084F /* CSSTokenizer.cpp */,
    1818818194                                946D37371D6CDF980077084F /* CSSTokenizer.h */,
     
    2665226658                                B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */,
    2665326659                                088A0E0A126EF1DB00978F7A /* SVGProperty.h in Headers */,
     26660                                94DE5C8E1D80802700164F2A /* CSSSelectorParser.h in Headers */,
    2665426661                                081DD49C13BA1A6000DC7627 /* SVGPropertyInfo.h in Headers */,
    2665526662                                088A0E0B126EF1DB00978F7A /* SVGPropertyTearOff.h in Headers */,
     
    2893028937                                BC98A27D0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp in Sources */,
    2893128938                                A84EBD840CB8C97700079609 /* JSStyleSheetList.cpp in Sources */,
     28939                                94DE5C8D1D80802700164F2A /* CSSSelectorParser.cpp in Sources */,
    2893228940                                A84EBD780CB8C89200079609 /* JSStyleSheetListCustom.cpp in Sources */,
    2893328941                                B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */,
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r205569 r205660  
    187187static bool isValidSelector(const String& selector)
    188188{
    189     CSSParserContext context(CSSQuirksMode);
     189    CSSParserContext context(HTMLQuirksMode);
    190190    CSSParser parser(context);
    191191    CSSSelectorList selectorList;
  • trunk/Source/WebCore/css/CSSDefaultStyleSheets.cpp

    r201205 r205660  
    9696static StyleSheetContents* parseUASheet(const String& str)
    9797{
    98     StyleSheetContents& sheet = StyleSheetContents::create().leakRef(); // leak the sheet on purpose
     98    StyleSheetContents& sheet = StyleSheetContents::create(CSSParserContext(UASheetMode)).leakRef(); // leak the sheet on purpose
    9999    sheet.parseString(str);
    100100    return &sheet;
  • trunk/Source/WebCore/css/CSSFontFaceSet.cpp

    r203092 r205660  
    329329    Vector<std::reference_wrapper<CSSFontFace>> result;
    330330    auto style = MutableStyleProperties::create();
    331     auto parseResult = CSSParser::parseValue(style, CSSPropertyFont, font, true, CSSStrictMode, nullptr);
     331    auto parseResult = CSSParser::parseValue(style, CSSPropertyFont, font, true, HTMLStandardMode, nullptr);
    332332    if (parseResult == CSSParser::ParseResult::Error) {
    333333        ec = SYNTAX_ERR;
  • trunk/Source/WebCore/css/CSSGrammar.y.in

    r204591 r205660  
    12571257        $$ = new CSSParserSelector;
    12581258        $$->setMatch(CSSSelector::Id);
    1259         if (parser->m_context.mode == CSSQuirksMode)
     1259        if (parser->m_context.mode == HTMLQuirksMode)
    12601260            $1.convertToASCIILowercaseInPlace();
    12611261        $$->setValue($1);
     
    12671267            $$ = new CSSParserSelector;
    12681268            $$->setMatch(CSSSelector::Id);
    1269             if (parser->m_context.mode == CSSQuirksMode)
     1269            if (parser->m_context.mode == HTMLQuirksMode)
    12701270                $1.convertToASCIILowercaseInPlace();
    12711271            $$->setValue($1);
     
    12811281        $$ = new CSSParserSelector;
    12821282        $$->setMatch(CSSSelector::Class);
    1283         if (parser->m_context.mode == CSSQuirksMode)
     1283        if (parser->m_context.mode == HTMLQuirksMode)
    12841284            $2.convertToASCIILowercaseInPlace();
    12851285        $$->setValue($2);
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r205103 r205660  
    736736        case CSSSelector::Child:
    737737            return tagHistory->selectorText(" > " + str.toString() + rightSide);
     738        case CSSSelector::ShadowDeep:
     739            return tagHistory->selectorText(" /deep/ " + str.toString() + rightSide);
    738740        case CSSSelector::DirectAdjacent:
    739741            return tagHistory->selectorText(" + " + str.toString() + rightSide);
     
    746748#endif
    747749        case CSSSelector::ShadowDescendant:
     750        case CSSSelector::ShadowPseudo:
     751        case CSSSelector::ShadowSlot:
    748752            return tagHistory->selectorText(str.toString() + rightSide);
    749753        }
  • trunk/Source/WebCore/css/CSSSelector.h

    r203250 r205660  
    8888            IndirectAdjacent,
    8989            SubSelector,
    90             ShadowDescendant,
     90            ShadowDescendant, // FIXME-NEWPARSER: Remove this in favor of the new shadow values below.
     91            ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pseudo element
     92            ShadowDeep, // /deep/ combinator
     93            ShadowSlot // slotted to <slot> e
    9194        };
    9295
     
    218221        };
    219222
     223        enum AttributeMatchType {
     224            CaseSensitive,
     225            CaseInsensitive,
     226        };
     227
    220228        static PseudoElementType parsePseudoElementType(const String&);
    221229        static PseudoId pseudoId(PseudoElementType);
  • trunk/Source/WebCore/css/DOMCSSNamespace.cpp

    r205103 r205660  
    7070
    7171    auto dummyStyle = MutableStyleProperties::create();
    72     return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error;
     72    return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, HTMLStandardMode, nullptr) != CSSParser::ParseResult::Error;
    7373}
    7474
    7575bool DOMCSSNamespace::supports(const String& conditionText)
    7676{
    77     CSSParserContext context(CSSStrictMode);
     77    CSSParserContext context(HTMLStandardMode);
    7878    CSSParser parser(context);
    7979    return parser.parseSupportsCondition(conditionText);
  • trunk/Source/WebCore/css/FontFace.cpp

    r205405 r205660  
    131131{
    132132    auto style = MutableStyleProperties::create();
    133     if (CSSParser::parseValue(style, propertyID, string, true, CSSStrictMode, nullptr) == CSSParser::ParseResult::Error)
     133    if (CSSParser::parseValue(style, propertyID, string, true, HTMLStandardMode, nullptr) == CSSParser::ParseResult::Error)
    134134        return nullptr;
    135135    return style->getPropertyCSSValue(propertyID);
     
    205205
    206206    auto style = MutableStyleProperties::create();
    207     auto result = CSSParser::parseValue(style, CSSPropertyFontVariant, variant, true, CSSStrictMode, nullptr);
     207    auto result = CSSParser::parseValue(style, CSSPropertyFontVariant, variant, true, HTMLStandardMode, nullptr);
    208208    if (result == CSSParser::ParseResult::Error) {
    209209        ec = SYNTAX_ERR;
  • trunk/Source/WebCore/css/MediaList.cpp

    r204006 r205660  
    130130Optional<MediaQuery> MediaQuerySet::internalParse(const String& queryString)
    131131{
    132     CSSParser parser(CSSStrictMode);
     132    CSSParser parser(HTMLStandardMode);
    133133    return internalParse(parser, queryString);
    134134}
     
    136136bool MediaQuerySet::parse(const String& mediaString)
    137137{
    138     CSSParser parser(CSSStrictMode);
     138    CSSParser parser(HTMLStandardMode);
    139139   
    140140    Vector<MediaQuery> result;
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r205050 r205660  
    453453            return MatchResult::updateWithMatchType(result, matchType);
    454454        }
    455     }
     455   
     456    case CSSSelector::ShadowPseudo:
     457    case CSSSelector::ShadowDeep:
     458    case CSSSelector::ShadowSlot:
     459        // FIXME-NEWPARSER: Have to implement these.
     460        ASSERT_NOT_REACHED();
     461        return MatchResult::fails(Match::SelectorFailsCompletely);
     462    }
     463
    456464
    457465    ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/css/SelectorFilter.cpp

    r199844 r205660  
    139139            skipOverSubselectors = true;
    140140            break;
     141        case CSSSelector::ShadowSlot:
     142            // Disable fastRejectSelector.
     143            *identifierHashes = 0;
     144            return;
    141145        case CSSSelector::Descendant:
    142146        case CSSSelector::Child:
     147        case CSSSelector::ShadowPseudo:
     148        case CSSSelector::ShadowDeep:
    143149            skipOverSubselectors = false;
    144150            collectDescendantSelectorIdentifierHashes(selector, hash);
  • trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in

    r202358 r205660  
    2828focus-within
    2929horizontal
    30 host
     30host, PseudoClassHost, PseudoElementUnknown
    3131hover
    3232in-range
  • trunk/Source/WebCore/css/SelectorPseudoTypeMap.h

    r195452 r205660  
    3939
    4040PseudoClassOrCompatibilityPseudoElement parsePseudoClassAndCompatibilityElementString(const CSSParserString& pseudoTypeString);
     41PseudoClassOrCompatibilityPseudoElement parsePseudoClassAndCompatibilityElementString(const StringView& pseudoTypeString);
    4142CSSSelector::PseudoElementType parsePseudoElementString(const StringImpl& pseudoTypeString);
    4243
  • trunk/Source/WebCore/css/SourceSizeList.cpp

    r201799 r205660  
    7575        return 0;
    7676    auto& style = renderer->style();
    77     for (auto& sourceSize : CSSParser(CSSStrictMode).parseSizesAttribute(sizesAttribute)) {
     77    for (auto& sourceSize : CSSParser(HTMLStandardMode).parseSizesAttribute(sizesAttribute)) {
    7878        if (match(sourceSize.expression, style, document))
    7979            return computeLength(sourceSize.length.get(), style, *renderer);
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r204052 r205660  
    7777
    7878MutableStyleProperties::MutableStyleProperties(const CSSProperty* properties, unsigned length)
    79     : StyleProperties(CSSStrictMode)
     79    : StyleProperties(HTMLStandardMode)
    8080{
    8181    m_propertyVector.reserveInitialCapacity(length);
  • trunk/Source/WebCore/css/StyleProperties.h

    r205093 r205660  
    135135    int findCustomPropertyIndex(const String& propertyName) const;
    136136   
    137     unsigned m_cssParserMode : 2;
     137    unsigned m_cssParserMode : 3;
    138138    mutable unsigned m_isMutable : 1;
    139     unsigned m_arraySize : 29;
     139    unsigned m_arraySize : 28;
    140140   
    141141private:
     
    187187class MutableStyleProperties final : public StyleProperties {
    188188public:
    189     WEBCORE_EXPORT static Ref<MutableStyleProperties> create(CSSParserMode = CSSQuirksMode);
     189    WEBCORE_EXPORT static Ref<MutableStyleProperties> create(CSSParserMode = HTMLQuirksMode);
    190190    static Ref<MutableStyleProperties> create(const CSSProperty* properties, unsigned count);
    191191
  • trunk/Source/WebCore/css/StyleRuleImport.cpp

    r201318 r205660  
    6767        m_styleSheet->clearOwnerRule();
    6868
    69     CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode;
     69    CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : HTMLStandardMode;
    7070    context.charset = charset;
    7171    if (!baseURL.isNull())
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r204591 r205660  
    6363    : m_ownerRule(ownerRule)
    6464    , m_originalURL(originalURL)
     65    , m_defaultNamespace(starAtom)
    6566    , m_loadCompleted(false)
    6667    , m_isUserStyleSheet(ownerRule && ownerRule->parentStyleSheet() && ownerRule->parentStyleSheet()->isUserStyleSheet())
     
    8384    , m_childRules(o.m_childRules.size())
    8485    , m_namespaces(o.m_namespaces)
     86    , m_defaultNamespace(o.m_defaultNamespace)
    8587    , m_loadCompleted(true)
    8688    , m_isUserStyleSheet(o.m_isUserStyleSheet)
     
    270272void StyleSheetContents::parserAddNamespace(const AtomicString& prefix, const AtomicString& uri)
    271273{
    272     if (uri.isNull() || prefix.isNull())
    273         return;
     274    ASSERT(!uri.isNull());
     275    if (prefix.isNull()) {
     276        m_defaultNamespace = uri;
     277        return;
     278    }
    274279    PrefixNamespaceURIMap::AddResult result = m_namespaces.add(prefix, uri);
    275280    if (result.isNewEntry)
     
    278283}
    279284
    280 const AtomicString& StyleSheetContents::determineNamespace(const AtomicString& prefix)
     285const AtomicString& StyleSheetContents::namespaceURIFromPrefix(const AtomicString& prefix)
    281286{
    282287    PrefixNamespaceURIMap::const_iterator it = m_namespaces.find(prefix);
  • trunk/Source/WebCore/css/StyleSheetContents.h

    r205093 r205660  
    4545class StyleSheetContents final : public RefCounted<StyleSheetContents> {
    4646public:
    47     static Ref<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(CSSStrictMode))
     47    static Ref<StyleSheetContents> create(const CSSParserContext& context = CSSParserContext(HTMLStandardMode))
    4848    {
    4949        return adoptRef(*new StyleSheetContents(0, String(), context));
     
    6161   
    6262    const CSSParserContext& parserContext() const { return m_parserContext; }
    63 
    64     const AtomicString& determineNamespace(const AtomicString& prefix);
     63   
     64    const AtomicString& defaultNamespace() { return m_defaultNamespace; }
     65    const AtomicString& namespaceURIFromPrefix(const AtomicString& prefix);
    6566
    6667    void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
     
    161162    typedef HashMap<AtomicString, AtomicString> PrefixNamespaceURIMap;
    162163    PrefixNamespaceURIMap m_namespaces;
     164    AtomicString m_defaultNamespace;
    163165
    164166    bool m_loadCompleted : 1;
  • trunk/Source/WebCore/css/WebKitCSSMatrix.cpp

    r201290 r205660  
    5858
    5959    auto styleDeclaration = MutableStyleProperties::create();
    60     if (CSSParser::parseValue(styleDeclaration, CSSPropertyTransform, string, true, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error) {
     60    if (CSSParser::parseValue(styleDeclaration, CSSPropertyTransform, string, true, HTMLStandardMode, nullptr) != CSSParser::ParseResult::Error) {
    6161        // Convert to TransformOperations. This can fail if a property
    6262        // requires style (i.e., param uses 'ems' or 'exs')
  • trunk/Source/WebCore/css/makeSelectorPseudoClassAndCompatibilityElementMap.py

    r195582 r205660  
    6363%{
    6464/*
    65  * Copyright (C) 2014 Apple Inc. All rights reserved.
     65 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    6666 *
    6767 * Redistribution and use in source and binary forms, with or without
     
    199199}
    200200
     201PseudoClassOrCompatibilityPseudoElement parsePseudoClassAndCompatibilityElementString(const StringView& pseudoTypeString)
     202{
     203    const SelectorPseudoClassOrCompatibilityPseudoElementEntry* entry;
     204    if (pseudoTypeString.is8Bit())
     205        entry = parsePseudoClassAndCompatibilityElementString(pseudoTypeString.characters8(), pseudoTypeString.length());
     206    else
     207        entry = parsePseudoClassAndCompatibilityElementString(pseudoTypeString.characters16(), pseudoTypeString.length());
     208
     209    if (entry)
     210        return entry->pseudoTypes;
     211    return { CSSSelector::PseudoClassUnknown, CSSSelector::PseudoElementUnknown };
     212}
     213
    201214} // namespace WebCore
    202215
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r205292 r205660  
    233233const CSSParserContext& strictCSSParserContext()
    234234{
    235     static NeverDestroyed<CSSParserContext> strictContext(CSSStrictMode);
     235    static NeverDestroyed<CSSParserContext> strictContext(HTMLStandardMode);
    236236    return strictContext;
    237237}
     
    255255    : baseURL(baseURL.isNull() ? document.baseURL() : baseURL)
    256256    , charset(charset)
    257     , mode(document.inQuirksMode() ? CSSQuirksMode : CSSStrictMode)
     257    , mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode)
    258258    , isHTMLDocument(document.isHTMLDocument())
    259259#if ENABLE(CSS_GRID_LAYOUT)
     
    13931393        return true;
    13941394
    1395     CSSParser parser(CSSStrictMode);
     1395    CSSParser parser(HTMLStandardMode);
    13961396
    13971397    // In case the fast-path parser didn't understand the color, try the full parser.
     
    17201720{
    17211721    // Qirks mode and svg presentation attributes accept unit less values.
    1722     return (unitFlags & (FLength | FAngle | FTime)) && (!value.fValue || cssParserMode == CSSQuirksMode || cssParserMode == SVGAttributeMode);
     1722    return (unitFlags & (FLength | FAngle | FTime)) && (!value.fValue || cssParserMode == HTMLQuirksMode || cssParserMode == SVGAttributeMode);
    17231723}
    17241724
     
    23572357            validPrimitive = true;
    23582358        else
    2359             validPrimitive = (!id && validateUnit(valueWithCalculation, FInteger, CSSQuirksMode));
     2359            validPrimitive = (!id && validateUnit(valueWithCalculation, FInteger, HTMLQuirksMode));
    23602360        break;
    23612361
     
    23652365            validPrimitive = true;
    23662366        else
    2367             validPrimitive = (!id && validateUnit(valueWithCalculation, FPositiveInteger, CSSQuirksMode));
     2367            validPrimitive = (!id && validateUnit(valueWithCalculation, FPositiveInteger, HTMLQuirksMode));
    23682368        break;
    23692369
     
    24162416            validPrimitive = true;
    24172417        else
    2418             validPrimitive = (!id && validateUnit(valueWithCalculation, FNumber | FPercent | FNonNeg, CSSStrictMode));
     2418            validPrimitive = (!id && validateUnit(valueWithCalculation, FNumber | FPercent | FNonNeg, HTMLStandardMode));
    24192419        break;
    24202420   
     
    25682568        break;
    25692569    case CSSPropertyWebkitBoxFlexGroup:
    2570         validPrimitive = validateUnit(valueWithCalculation, FInteger | FNonNeg, CSSStrictMode);
     2570        validPrimitive = validateUnit(valueWithCalculation, FInteger | FNonNeg, HTMLStandardMode);
    25712571        break;
    25722572    case CSSPropertyWebkitBoxOrdinalGroup:
    2573         validPrimitive = validateUnit(valueWithCalculation, FInteger | FNonNeg, CSSStrictMode) && valueWithCalculation.value().fValue;
     2573        validPrimitive = validateUnit(valueWithCalculation, FInteger | FNonNeg, HTMLStandardMode) && valueWithCalculation.value().fValue;
    25742574        break;
    25752575    case CSSPropertyFilter:
     
    26172617        break;
    26182618    case CSSPropertyOrder:
    2619         if (validateUnit(valueWithCalculation, FInteger, CSSStrictMode)) {
     2619        if (validateUnit(valueWithCalculation, FInteger, HTMLStandardMode)) {
    26202620            // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set.
    26212621            double result = std::max<double>(std::numeric_limits<int>::min() + 2, parsedDouble(valueWithCalculation));
     
    28992899        // When specifying number of lines, don't allow 0 as a valid value
    29002900        // When specifying either type of unit, require non-negative integers
    2901         validPrimitive = (!id && (valueWithCalculation.value().unit == CSSPrimitiveValue::CSS_PERCENTAGE || valueWithCalculation.value().fValue) && validateUnit(valueWithCalculation, FInteger | FPercent | FNonNeg, CSSQuirksMode));
     2901        validPrimitive = (!id && (valueWithCalculation.value().unit == CSSPrimitiveValue::CSS_PERCENTAGE || valueWithCalculation.value().fValue) && validateUnit(valueWithCalculation, FInteger | FPercent | FNonNeg, HTMLQuirksMode));
    29022902        break;
    29032903#if ENABLE(IOS_TEXT_AUTOSIZING)
     
    29102910        else {
    29112911            // FIXME: Handle multilength case where we allow relative units.
    2912             validPrimitive = (!id && validateUnit(valueWithCalculation, FPercent | FNonNeg, CSSStrictMode));
     2912            validPrimitive = (!id && validateUnit(valueWithCalculation, FPercent | FNonNeg, HTMLStandardMode));
    29132913        }
    29142914        break;
     
    29262926    case CSSPropertyWebkitHyphenateLimitBefore:
    29272927    case CSSPropertyWebkitHyphenateLimitAfter:
    2928         if (id == CSSValueAuto || validateUnit(valueWithCalculation, FInteger | FNonNeg, CSSStrictMode))
     2928        if (id == CSSValueAuto || validateUnit(valueWithCalculation, FInteger | FNonNeg, HTMLStandardMode))
    29292929            validPrimitive = true;
    29302930        break;
    29312931
    29322932    case CSSPropertyWebkitHyphenateLimitLines:
    2933         if (id == CSSValueNoLimit || validateUnit(valueWithCalculation, FInteger | FNonNeg, CSSStrictMode))
     2933        if (id == CSSValueNoLimit || validateUnit(valueWithCalculation, FInteger | FNonNeg, HTMLStandardMode))
    29342934            validPrimitive = true;
    29352935        break;
     
    38753875    CSSValueID id = valueWithCalculation.value().id;
    38763876    // Always parse this property in strict mode, since it would be ambiguous otherwise when used in the 'columns' shorthand property.
    3877     if (id != CSSValueAuto && !(validateUnit(valueWithCalculation, FLength | FNonNeg, CSSStrictMode) && parsedDouble(valueWithCalculation)))
     3877    if (id != CSSValueAuto && !(validateUnit(valueWithCalculation, FLength | FNonNeg, HTMLStandardMode) && parsedDouble(valueWithCalculation)))
    38783878        return nullptr;
    38793879
     
    38883888    CSSValueID id = valueWithCalculation.value().id;
    38893889
    3890     if (id != CSSValueAuto && !validateUnit(valueWithCalculation, FPositiveInteger, CSSQuirksMode))
     3890    if (id != CSSValueAuto && !validateUnit(valueWithCalculation, FPositiveInteger, HTMLQuirksMode))
    38913891        return nullptr;
    38923892
     
    72387238    }
    72397239    ValueWithCalculation valueWithCalculation(value);
    7240     if (validateUnit(valueWithCalculation, FInteger | FNonNeg, CSSQuirksMode)) {
     7240    if (validateUnit(valueWithCalculation, FInteger | FNonNeg, HTMLQuirksMode)) {
    72417241        int weight = static_cast<int>(parsedDouble(valueWithCalculation));
    72427242        if (!(weight % 100) && weight >= 100 && weight <= 900) {
     
    78137813    Units unitType = FUnknown;
    78147814    // Get the first value and its type
    7815     if (validateUnit(firstArgumentWithCalculation, FInteger, CSSStrictMode))
     7815    if (validateUnit(firstArgumentWithCalculation, FInteger, HTMLStandardMode))
    78167816        unitType = FInteger;
    7817     else if (validateUnit(firstArgumentWithCalculation, FPercent, CSSStrictMode))
     7817    else if (validateUnit(firstArgumentWithCalculation, FPercent, HTMLStandardMode))
    78187818        unitType = FPercent;
    78197819    else
     
    78267826            return false;
    78277827        ValueWithCalculation argumentWithCalculation(*args->next());
    7828         if (!validateUnit(argumentWithCalculation, unitType, CSSStrictMode))
     7828        if (!validateUnit(argumentWithCalculation, unitType, HTMLStandardMode))
    78297829            return false;
    78307830        colorArray[i] = colorIntFromValue(argumentWithCalculation);
     
    78357835            return false;
    78367836        ValueWithCalculation argumentWithCalculation(*args->next());
    7837         if (!validateUnit(argumentWithCalculation, FNumber, CSSStrictMode))
     7837        if (!validateUnit(argumentWithCalculation, FNumber, HTMLStandardMode))
    78387838            return false;
    78397839        double doubleValue = parsedDouble(argumentWithCalculation);
     
    78557855    ValueWithCalculation firstArgumentWithCalculation(*args->current());
    78567856    // Get the first value
    7857     if (!validateUnit(firstArgumentWithCalculation, FNumber, CSSStrictMode))
     7857    if (!validateUnit(firstArgumentWithCalculation, FNumber, HTMLStandardMode))
    78587858        return false;
    78597859    // normalize the Hue value and change it to be between 0 and 1.0
     
    78647864            return false;
    78657865        ValueWithCalculation argumentWithCalculation(*args->next());
    7866         if (!validateUnit(argumentWithCalculation, FPercent, CSSStrictMode))
     7866        if (!validateUnit(argumentWithCalculation, FPercent, HTMLStandardMode))
    78677867            return false;
    78687868        colorArray[i] = std::max<double>(0, std::min<double>(100, parsedDouble(argumentWithCalculation))) / 100.0; // needs to be value between 0 and 1.0
     
    78737873            return false;
    78747874        ValueWithCalculation argumentWithCalculation(*args->next());
    7875         if (!validateUnit(argumentWithCalculation, FNumber, CSSStrictMode))
     7875        if (!validateUnit(argumentWithCalculation, FNumber, HTMLStandardMode))
    78767876            return false;
    78777877        colorArray[3] = std::max<double>(0, std::min<double>(1, parsedDouble(argumentWithCalculation)));
     
    80808080            // The value is good.  Commit it.
    80818081            context.commitValue();
    8082         } else if (validateUnit(valueWithCalculation, FLength, CSSStrictMode)) {
     8082        } else if (validateUnit(valueWithCalculation, FLength, HTMLStandardMode)) {
    80838083            // We required a length and didn't get one. Invalid.
    80848084            if (!context.allowLength())
     
    80868086
    80878087            // Blur radius must be non-negative.
    8088             if (context.allowBlur && !validateUnit(valueWithCalculation, FLength | FNonNeg, CSSStrictMode))
     8088            if (context.allowBlur && !validateUnit(valueWithCalculation, FLength | FNonNeg, HTMLStandardMode))
    80898089                return nullptr;
    80908090
     
    85348534        ValueWithCalculation valueWithCalculation(*value);
    85358535        // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values are not created yet.
    8536         if (context.allowNumber() && !isCalculation(valueWithCalculation) && validateUnit(valueWithCalculation, FInteger | FNonNeg | FPercent, CSSStrictMode)) {
     8536        if (context.allowNumber() && !isCalculation(valueWithCalculation) && validateUnit(valueWithCalculation, FInteger | FNonNeg | FPercent, HTMLStandardMode)) {
    85378537            context.commitNumber(valueWithCalculation);
    85388538        } else if (context.allowFill() && value->id == CSSValueFill)
     
    86488648    while ((value = m_valueList->current())) {
    86498649        ValueWithCalculation valueWithCalculation(*value);
    8650         if (context.allowNumber() && (validateUnit(valueWithCalculation, validUnits, CSSStrictMode) || value->id == CSSValueAuto)) {
     8650        if (context.allowNumber() && (validateUnit(valueWithCalculation, validUnits, HTMLStandardMode) || value->id == CSSValueAuto)) {
    86518651            context.commitNumber(valueWithCalculation);
    86528652        } else if (!inShorthand()) {
     
    90789078    bool expectComma = false;
    90799079    // Look for angle.
    9080     if (validateUnit(argumentWithCalculation, FAngle, CSSStrictMode)) {
     9080    if (validateUnit(argumentWithCalculation, FAngle, HTMLStandardMode)) {
    90819081        result->setAngle(createPrimitiveNumericValue(argumentWithCalculation));
    90829082
     
    92649264    bool expectComma = false;
    92659265    // Look for angle.
    9266     if (validateUnit(firstArgumentWithCalculation, FAngle, CSSStrictMode)) {
     9266    if (validateUnit(firstArgumentWithCalculation, FAngle, HTMLStandardMode)) {
    92679267        result->setAngle(createPrimitiveNumericValue(firstArgumentWithCalculation));
    92689268
     
    1007910079        if (info.type() == WebKitCSSTransformValue::Rotate3DTransformOperation && argNumber == 3) {
    1008010080            // 4th param of rotate3d() is an angle rather than a bare number, validate it as such
    10081             if (!validateUnit(argumentWithCalculation, FAngle, CSSStrictMode))
     10081            if (!validateUnit(argumentWithCalculation, FAngle, HTMLStandardMode))
    1008210082                return nullptr;
    1008310083        } else if (info.type() == WebKitCSSTransformValue::Translate3DTransformOperation && argNumber == 2) {
    1008410084            // 3rd param of translate3d() cannot be a percentage
    10085             if (!validateUnit(argumentWithCalculation, FLength, CSSStrictMode))
     10085            if (!validateUnit(argumentWithCalculation, FLength, HTMLStandardMode))
    1008610086                return nullptr;
    1008710087        } else if (info.type() == WebKitCSSTransformValue::TranslateZTransformOperation && !argNumber) {
    1008810088            // 1st param of translateZ() cannot be a percentage
    10089             if (!validateUnit(argumentWithCalculation, FLength, CSSStrictMode))
     10089            if (!validateUnit(argumentWithCalculation, FLength, HTMLStandardMode))
    1009010090                return nullptr;
    1009110091        } else if (info.type() == WebKitCSSTransformValue::PerspectiveTransformOperation && !argNumber) {
    1009210092            // 1st param of perspective() must be a non-negative number (deprecated) or length.
    10093             if (!validateUnit(argumentWithCalculation, FNumber | FLength | FNonNeg, CSSStrictMode))
     10093            if (!validateUnit(argumentWithCalculation, FNumber | FLength | FNonNeg, HTMLStandardMode))
    1009410094                return nullptr;
    10095         } else if (!validateUnit(argumentWithCalculation, unit, CSSStrictMode))
     10095        } else if (!validateUnit(argumentWithCalculation, unit, HTMLStandardMode))
    1009610096            return nullptr;
    1009710097
     
    1016810168        if (args.size()) {
    1016910169            ValueWithCalculation argumentWithCalculation(*args.current());
    10170             if (!validateUnit(argumentWithCalculation, FNumber | FPercent | FNonNeg, CSSStrictMode))
     10170            if (!validateUnit(argumentWithCalculation, FNumber | FPercent | FNonNeg, HTMLStandardMode))
    1017110171                return nullptr;
    1017210172
     
    1019210192        if (args.size()) {
    1019310193            ValueWithCalculation argumentWithCalculation(*args.current());
    10194             if (!validateUnit(argumentWithCalculation, FNumber | FPercent, CSSStrictMode))
     10194            if (!validateUnit(argumentWithCalculation, FNumber | FPercent, HTMLStandardMode))
    1019510195                return nullptr;
    1019610196
     
    1020610206        if (args.size()) {
    1020710207            ValueWithCalculation argumentWithCalculation(*args.current());
    10208             if (!validateUnit(argumentWithCalculation, FAngle, CSSStrictMode))
     10208            if (!validateUnit(argumentWithCalculation, FAngle, HTMLStandardMode))
    1020910209                return nullptr;
    1021010210       
     
    1022010220        if (args.size()) {
    1022110221            ValueWithCalculation argumentWithCalculation(*args.current());
    10222             if (!validateUnit(argumentWithCalculation, FLength | FNonNeg, CSSStrictMode))
     10222            if (!validateUnit(argumentWithCalculation, FLength | FNonNeg, HTMLStandardMode))
    1022310223                return nullptr;
    1022410224
     
    1312613126    if (!m_styleSheet)
    1312713127        return QualifiedName(prefix, localName, m_defaultNamespace);
    13128     return QualifiedName(prefix, localName, m_styleSheet->determineNamespace(prefix));
     13128    return QualifiedName(prefix, localName, m_styleSheet->namespaceURIFromPrefix(prefix));
    1312913129}
    1313013130
  • trunk/Source/WebCore/css/parser/CSSParser.h

    r204852 r205660  
    572572    void setStyleSheet(StyleSheetContents* styleSheet) { m_styleSheet = styleSheet; }
    573573
    574     inline bool inStrictMode() const { return m_context.mode == CSSStrictMode || m_context.mode == SVGAttributeMode; }
    575     inline bool inQuirksMode() const { return m_context.mode == CSSQuirksMode; }
     574    inline bool inStrictMode() const { return m_context.mode == UASheetMode || m_context.mode == HTMLStandardMode || m_context.mode == SVGAttributeMode; }
     575    inline bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; }
    576576   
    577577    URL completeURL(const String& url) const;
  • trunk/Source/WebCore/css/parser/CSSParserMode.h

    r204852 r205660  
    3838class Document;
    3939
     40// Must not grow beyond 3 bits, due to packing in StyleProperties.
    4041enum CSSParserMode {
    41     CSSQuirksMode,
    42     CSSStrictMode,
    43     // SVG should always be in strict mode. For SVG attributes, the rules differ to strict sometimes.
    44     SVGAttributeMode
     42    HTMLStandardMode,
     43    HTMLQuirksMode,
     44    // HTML attributes are parsed in quirks mode but also allows internal properties and values.
     45    HTMLAttributeMode,
     46    // SVG attributes are parsed in quirks mode but rules differ slightly.
     47    SVGAttributeMode,
     48    // @viewport rules are parsed in standards mode but CSSOM modifications (via StylePropertySet)
     49    // must call parseViewportProperties so needs a special mode.
     50    CSSViewportRuleMode,
     51    // User agent stylesheets are parsed in standards mode but also allows internal properties and values.
     52    UASheetMode
    4553};
    4654
     55inline bool isQuirksModeBehavior(CSSParserMode mode)
     56{
     57    return mode == HTMLQuirksMode || mode == HTMLAttributeMode;
     58}
     59
     60inline bool isUASheetBehavior(CSSParserMode mode)
     61{
     62    return mode == UASheetMode;
     63}
     64
     65inline bool isUnitLessLengthParsingEnabledForMode(CSSParserMode mode)
     66{
     67    return mode == HTMLAttributeMode || mode == SVGAttributeMode;
     68}
     69
     70inline bool isCSSViewportParsingEnabledForMode(CSSParserMode mode)
     71{
     72    return mode == CSSViewportRuleMode;
     73}
     74
     75// FIXME-NEWPARSER: Next two functions should be removed eventually.
    4776inline CSSParserMode strictToCSSParserMode(bool inStrictMode)
    4877{
    49     return inStrictMode ? CSSStrictMode : CSSQuirksMode;
     78    return inStrictMode ? HTMLStandardMode : HTMLQuirksMode;
    5079}
    5180
    5281inline bool isStrictParserMode(CSSParserMode cssParserMode)
    5382{
    54     return cssParserMode == CSSStrictMode || cssParserMode == SVGAttributeMode;
     83    return cssParserMode == UASheetMode || cssParserMode == HTMLStandardMode || cssParserMode == SVGAttributeMode;
    5584}
    5685
     
    6392    URL baseURL;
    6493    String charset;
    65     CSSParserMode mode { CSSStrictMode };
     94    CSSParserMode mode { HTMLStandardMode };
    6695    bool isHTMLDocument { false };
    6796#if ENABLE(CSS_GRID_LAYOUT)
  • trunk/Source/WebCore/css/parser/CSSParserValues.cpp

    r205025 r205660  
    2323
    2424#include "CSSCustomPropertyValue.h"
     25#include "CSSParserIdioms.h"
    2526#include "CSSPrimitiveValue.h"
    2627#include "CSSFunctionValue.h"
     
    220221}
    221222
     223CSSParserSelector* CSSParserSelector::parsePseudoElementSelectorFromStringView(StringView& pseudoTypeString)
     224{
     225    convertToASCIILowercaseInPlace(pseudoTypeString);
     226    AtomicString name = pseudoTypeString.toAtomicString();
     227   
     228    CSSSelector::PseudoElementType pseudoType = CSSSelector::parsePseudoElementType(name);
     229    if (pseudoType == CSSSelector::PseudoElementUnknown)
     230        return nullptr;
     231   
     232    auto selector = std::make_unique<CSSParserSelector>();
     233    selector->m_selector->setMatch(CSSSelector::PseudoElement);
     234    selector->m_selector->setPseudoElementType(pseudoType);
     235    if (pseudoType == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed) {
     236        ASSERT_WITH_MESSAGE(name == "-webkit-input-placeholder", "-webkit-input-placeholder is the only LegacyPrefix pseudo type.");
     237        if (name == "-webkit-input-placeholder")
     238            name = AtomicString("placeholder", AtomicString::ConstructFromLiteral);
     239    }
     240    selector->m_selector->setValue(name);
     241    return selector.release();
     242}
     243
    222244#if ENABLE(VIDEO_TRACK)
    223245CSSParserSelector* CSSParserSelector::parsePseudoElementCueFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* parsedSelectorVector)
     
    303325        selector->m_selector->setPseudoElementType(pseudoType.compatibilityPseudoElement);
    304326        AtomicString name = pseudoTypeString;
     327        selector->m_selector->setValue(name);
     328        return selector.release();
     329    }
     330    return nullptr;
     331}
     332
     333CSSParserSelector* CSSParserSelector::parsePseudoClassSelectorFromStringView(StringView& pseudoTypeString)
     334{
     335    if (pseudoTypeString.length() && pseudoTypeString[pseudoTypeString.length() - 1] == '(')
     336        return nullptr;
     337   
     338    PseudoClassOrCompatibilityPseudoElement pseudoType = parsePseudoClassAndCompatibilityElementString(pseudoTypeString);
     339    if (pseudoType.pseudoClass != CSSSelector::PseudoClassUnknown) {
     340        auto selector = std::make_unique<CSSParserSelector>();
     341        selector->m_selector->setMatch(CSSSelector::PseudoClass);
     342        selector->m_selector->setPseudoClassType(pseudoType.pseudoClass);
     343        return selector.release();
     344    }
     345    if (pseudoType.compatibilityPseudoElement != CSSSelector::PseudoElementUnknown) {
     346        auto selector = std::make_unique<CSSParserSelector>();
     347        selector->m_selector->setMatch(CSSSelector::PseudoElement);
     348        selector->m_selector->setPseudoElementType(pseudoType.compatibilityPseudoElement);
     349        AtomicString name = pseudoTypeString.toAtomicString();
    305350        selector->m_selector->setValue(name);
    306351        return selector.release();
     
    350395    m_selector->setLangArgumentList(WTFMove(argumentList));
    351396}
    352 
     397   
     398void CSSParserSelector::setSelectorList(std::unique_ptr<CSSSelectorList> selectorList)
     399{
     400    m_selector->setSelectorList(WTFMove(selectorList));
     401}
     402   
    353403void CSSParserSelector::setPseudoClassValue(const CSSParserString& pseudoClassString)
    354404{
     
    426476        selectorRelation = CSSSelector::IndirectAdjacent;
    427477        break;
     478    case CSSParserSelectorCombinator::ShadowDeep:
     479        selectorRelation = CSSSelector::ShadowDeep;
     480        break;
     481    case CSSParserSelectorCombinator::ShadowPseudo:
     482        selectorRelation = CSSSelector::ShadowPseudo;
     483        break;
     484    case CSSParserSelectorCombinator::ShadowSlot:
     485        selectorRelation = CSSSelector::ShadowSlot;
     486        break;
    428487    }
    429488    end->setRelation(selectorRelation);
     
    448507}
    449508
    450 }
    451 
     509std::unique_ptr<CSSParserSelector> CSSParserSelector::releaseTagHistory()
     510{
     511    setRelation(CSSSelector::SubSelector);
     512    return WTFMove(m_tagHistory);
     513}
     514
     515// FIXME-NEWPARSER: Add support for :host-context
     516bool CSSParserSelector::isHostPseudoSelector() const
     517{
     518    return pseudoClassType() == CSSSelector::PseudoClassHost;
     519}
     520
     521}
     522
  • trunk/Source/WebCore/css/parser/CSSParserValues.h

    r204852 r205660  
    194194#endif
    195195    DirectAdjacent,
    196     IndirectAdjacent
     196    IndirectAdjacent,
     197    ShadowPseudo, // Special case of shadow DOM pseudo elements / shadow pseudo element
     198    ShadowDeep, // /deep/ combinator
     199    ShadowSlot // slotted to <slot> e
    197200};
    198201
     
    207210    static CSSParserSelector* parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString);
    208211
     212    static CSSParserSelector* parsePseudoClassSelectorFromStringView(StringView&);
     213    static CSSParserSelector* parsePseudoElementSelectorFromStringView(StringView&);
     214   
    209215    CSSParserSelector();
    210216    explicit CSSParserSelector(const QualifiedName&);
     
    221227    void setForPage() { m_selector->setForPage(); }
    222228
     229    CSSSelector::Match match() const { return m_selector->match(); }
     230    CSSSelector::PseudoElementType pseudoElementType() const { return m_selector->pseudoElementType(); }
     231    const CSSSelectorList* selectorList() const { return m_selector->selectorList(); }
     232
    223233    void adoptSelectorVector(Vector<std::unique_ptr<CSSParserSelector>>& selectorVector);
    224234    void setLangArgumentList(const Vector<CSSParserString>& stringVector);
     235    void setSelectorList(std::unique_ptr<CSSSelectorList>);
    225236
    226237    void setPseudoClassValue(const CSSParserString& pseudoClassString);
     
    239250    bool hasShadowDescendant() const;
    240251    bool matchesPseudoElement() const;
     252
     253    bool isHostPseudoSelector() const;
     254
     255    // FIXME-NEWPARSER: Missing "shadow"
     256    bool needsImplicitShadowCombinatorForMatching() const { return pseudoElementType() == CSSSelector::PseudoElementWebKitCustom || pseudoElementType() == CSSSelector::PseudoElementUserAgentCustom || pseudoElementType() == CSSSelector::PseudoElementWebKitCustomLegacyPrefixed || pseudoElementType() == CSSSelector::PseudoElementCue || pseudoElementType() == CSSSelector::PseudoElementSlotted; }
    241257
    242258    CSSParserSelector* tagHistory() const { return m_tagHistory.get(); }
     
    247263    void appendTagHistory(CSSParserSelectorCombinator, std::unique_ptr<CSSParserSelector>);
    248264    void prependTagSelector(const QualifiedName&, bool tagIsForNamespaceRule = false);
     265    std::unique_ptr<CSSParserSelector> releaseTagHistory();
    249266
    250267private:
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.h

    r205103 r205660  
    5656    const CSSValue* parseSingleValue(CSSPropertyID, CSSPropertyID = CSSPropertyInvalid);
    5757
    58     bool inQuirksMode() const { return m_context.mode == CSSQuirksMode; }
     58    bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; }
    5959
    6060    bool parseViewportDescriptor(CSSPropertyID propId, bool important);
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r205050 r205660  
    412412    case CSSSelector::SubSelector:
    413413    case CSSSelector::ShadowDescendant:
     414    case CSSSelector::ShadowPseudo:
     415    case CSSSelector::ShadowDeep:
     416    case CSSSelector::ShadowSlot:
    414417        ASSERT_NOT_REACHED();
    415418    }
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r200626 r205660  
    332332        presentationAttributeCacheCleaner().didHitPresentationAttributeCache();
    333333    } else {
    334         style = MutableStyleProperties::create(isSVGElement() ? SVGAttributeMode : CSSQuirksMode);
     334        style = MutableStyleProperties::create(isSVGElement() ? SVGAttributeMode : HTMLQuirksMode);
    335335        for (const Attribute& attribute : attributesIterator())
    336336            collectStyleForPresentationAttribute(attribute.name(), attribute.value(), static_cast<MutableStyleProperties&>(*style));
  • trunk/Source/WebCore/svg/SVGFontFaceElement.cpp

    r204858 r205660  
    5050inline SVGFontFaceElement::SVGFontFaceElement(const QualifiedName& tagName, Document& document)
    5151    : SVGElement(tagName, document)
    52     , m_fontFaceRule(StyleRuleFontFace::create(MutableStyleProperties::create(CSSStrictMode)))
     52    , m_fontFaceRule(StyleRuleFontFace::create(MutableStyleProperties::create(HTMLStandardMode)))
    5353    , m_fontElement(nullptr)
    5454{
Note: See TracChangeset for help on using the changeset viewer.