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

Changeset 251655 in webkit


Ignore:
Timestamp:
Oct 28, 2019, 9:02:53 AM (7 years ago)
Author:
Simon Fraser
Message:

Can't change @font-face descriptors from fontFaceRule.style.setProperty()
https://bugs.webkit.org/show_bug.cgi?id=177975
<rdar://problem/56648761>

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

More passing subtests.

  • web-platform-tests/css/css-syntax/urange-parsing-expected.txt:

Source/WebCore:

When parsing properties via PropertySetCSSStyleDeclaration::setProperty() (called from
script as rule.style.setProperty()), CSSPropertyParser::parseValue() needs to know if
we're parsing properties in a @font-face or @viewport rule, since some properties are
only allowed in these contexts.

Achieve this by adding to CSSParserContext an Optional<enclosingRuleType>, which gets set
for font-face and viewport rules. This gets set by StyleRuleCSSStyleDeclaration::cssParserContext()
based on the type of the parent rule.

Moved StyleRule::Type to its own header so CSSParserContext can use it. Added compile-time asserts
that the values match CSSRule::Type (fixing one of them).

Also fix <urange> serialization when start and end values are the same.

Test: web-platform-tests/css/css-syntax/urange-parsing.html

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSKeyframeRule.cpp:

(WebCore::StyleRuleKeyframe::StyleRuleKeyframe):

  • css/CSSKeyframesRule.cpp:

(WebCore::StyleRuleKeyframes::StyleRuleKeyframes):

  • css/CSSPropertySourceData.h:

(WebCore::CSSRuleSourceData::create):
(WebCore::CSSRuleSourceData::createUnknown):
(WebCore::CSSRuleSourceData::CSSRuleSourceData):

  • css/CSSRule.cpp:
  • css/CSSUnicodeRangeValue.cpp:

(WebCore::CSSUnicodeRangeValue::customCSSText const):

  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::StyleRuleCSSStyleDeclaration::cssParserContext const):

  • css/StyleRule.cpp:

(WebCore::StyleRuleBase::destroy):
(WebCore::StyleRuleBase::copy const):
(WebCore::StyleRuleBase::createCSSOMWrapper const):
(WebCore::StyleRule::StyleRule):
(WebCore::StyleRulePage::StyleRulePage):
(WebCore::StyleRuleFontFace::StyleRuleFontFace):
(WebCore::StyleRuleGroup::StyleRuleGroup):
(WebCore::StyleRuleMedia::StyleRuleMedia):
(WebCore::StyleRuleSupports::StyleRuleSupports):
(WebCore::StyleRuleViewport::StyleRuleViewport):
(WebCore::StyleRuleCharset::StyleRuleCharset):
(WebCore::StyleRuleNamespace::StyleRuleNamespace):

  • css/StyleRule.h:

(WebCore::StyleRuleBase::type const):
(WebCore::StyleRuleBase::isCharsetRule const):
(WebCore::StyleRuleBase::isFontFaceRule const):
(WebCore::StyleRuleBase::isKeyframesRule const):
(WebCore::StyleRuleBase::isKeyframeRule const):
(WebCore::StyleRuleBase::isNamespaceRule const):
(WebCore::StyleRuleBase::isMediaRule const):
(WebCore::StyleRuleBase::isPageRule const):
(WebCore::StyleRuleBase::isStyleRule const):
(WebCore::StyleRuleBase::isSupportsRule const):
(WebCore::StyleRuleBase::isViewportRule const):
(WebCore::StyleRuleBase::isImportRule const):
(WebCore::StyleRuleBase::StyleRuleBase):

  • css/StyleRuleImport.cpp:

(WebCore::StyleRuleImport::StyleRuleImport):

  • css/StyleRuleImport.h:
  • css/StyleRuleType.h: Copied from Source/WebCore/css/CSSUnicodeRangeValue.cpp.
  • css/StyleSheetContents.cpp:

(WebCore::traverseRulesInVector):
(WebCore::StyleSheetContents::traverseSubresources const):

  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseValueWithVariableReferences):

  • css/parser/CSSParserContext.h:
  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::parseValue):
(WebCore::CSSParserImpl::parseInlineStyleDeclaration):
(WebCore::CSSParserImpl::parseDeferredDeclaration):
(WebCore::CSSParserImpl::parseDeclarationList):
(WebCore::CSSParserImpl::supportsDeclaration):
(WebCore::CSSParserImpl::parseDeclarationListForInspector):
(WebCore::CSSParserImpl::consumeImportRule):
(WebCore::CSSParserImpl::consumeMediaRule):
(WebCore::CSSParserImpl::consumeSupportsRule):
(WebCore::CSSParserImpl::consumeViewportRule):
(WebCore::CSSParserImpl::consumeFontFaceRule):
(WebCore::CSSParserImpl::consumeKeyframesRule):
(WebCore::CSSParserImpl::consumePageRule):
(WebCore::CSSParserImpl::consumeKeyframeStyleRule):
(WebCore::observeSelectors):
(WebCore::CSSParserImpl::consumeStyleRule):
(WebCore::CSSParserImpl::consumeDeclarationList):
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::consumeDeclarationValue):

  • css/parser/CSSParserImpl.h:
  • css/parser/CSSParserObserver.h:
  • css/parser/CSSPropertyParser.cpp:

(WebCore::CSSPropertyParser::parseValue):

  • css/parser/CSSPropertyParser.h:
  • css/parser/CSSTokenizer.cpp:

(WebCore::CSSTokenizer::letterU):

  • inspector/InspectorStyleSheet.cpp:

(flattenSourceData):
(WebCore::StyleSheetHandler::startRuleHeader):
(WebCore::InspectorStyleSheetForInlineStyle::ruleSourceData const):

LayoutTests:

Fix tests for the urange serialization fix.

  • fast/text/font-face-javascript-expected.txt:
  • fast/text/font-face-javascript.html:
  • fast/text/unicode-range-javascript-expected.txt:
  • fast/text/unicode-range-javascript.html:
Location:
trunk
Files:
30 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r251648 r251655  
     12019-10-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Can't change @font-face descriptors from fontFaceRule.style.setProperty()
     4        https://bugs.webkit.org/show_bug.cgi?id=177975
     5        <rdar://problem/56648761>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Fix tests for the urange serialization fix.
     10
     11        * fast/text/font-face-javascript-expected.txt:
     12        * fast/text/font-face-javascript.html:
     13        * fast/text/unicode-range-javascript-expected.txt:
     14        * fast/text/unicode-range-javascript.html:
     15
    1162019-10-28  Antoine Quint  <graouts@apple.com>
    217
  • trunk/LayoutTests/fast/text/font-face-javascript-expected.txt

    r230838 r251655  
    1818PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'inherit'}).weight threw exception SyntaxError: The string did not match the expected pattern..
    1919PASS new FontFace('family_name', 'url(\'asdf\')', {'stretch': 'ultra-expanded'}).stretch is "ultra-expanded"
    20 PASS new FontFace('family_name', 'url(\'asdf\')', {'unicodeRange': 'U+26'}).unicodeRange is "U+26-26"
     20PASS new FontFace('family_name', 'url(\'asdf\')', {'unicodeRange': 'U+26'}).unicodeRange is "U+26"
    2121PASS new FontFace('family_name', 'url(\'asdf\')', {'unicodeRange': 'U+0-7F'}).unicodeRange is "U+0-7f"
    2222PASS new FontFace('family_name', 'url(\'asdf\')', {'variant': 'variant_name'}).variant threw exception SyntaxError: The string did not match the expected pattern..
     
    2727PASS everything.weight is "bold"
    2828PASS everything.stretch is "extra-expanded"
    29 PASS everything.unicodeRange is "U+26-26"
     29PASS everything.unicodeRange is "U+26"
    3030PASS everything.variant is "small-caps"
    3131PASS everything.featureSettings is "\"titl\""
  • trunk/LayoutTests/fast/text/font-face-javascript.html

    r230838 r251655  
    2626shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'inherit'}).weight");
    2727shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'stretch': 'ultra-expanded'}).stretch", "ultra-expanded");
    28 shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'unicodeRange': 'U+26'}).unicodeRange", "U+26-26");
     28shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'unicodeRange': 'U+26'}).unicodeRange", "U+26");
    2929shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'unicodeRange': 'U+0-7F'}).unicodeRange", "U+0-7f");
    3030shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'variant': 'variant_name'}).variant");
     
    3737shouldBeEqualToString("everything.weight", "bold");
    3838shouldBeEqualToString("everything.stretch", "extra-expanded");
    39 shouldBeEqualToString("everything.unicodeRange", "U+26-26");
     39shouldBeEqualToString("everything.unicodeRange", "U+26");
    4040shouldBeEqualToString("everything.variant", "small-caps");
    4141shouldBeEqualToString("everything.featureSettings", "\"titl\"");
  • trunk/LayoutTests/fast/text/unicode-range-javascript-expected.txt

    r203092 r251655  
    55
    66PASS faces.length is 1
    7 PASS faces[0].unicodeRange is "U+41-41"
     7PASS faces[0].unicodeRange is "U+41"
    88PASS document.fonts.check('14px WebFont', 'A') is true
    99PASS faces.length is 1
    1010PASS faces[0].family is "WebFont"
    11 PASS faces[0].unicodeRange is "U+41-41"
     11PASS faces[0].unicodeRange is "U+41"
    1212PASS document.fonts.check('14px WebFont3', 'A') is false
    1313PASS document.fonts.check('14px WebFont3', 'A') is true
  • trunk/LayoutTests/fast/text/unicode-range-javascript.html

    r203092 r251655  
    5454    faces = facesArgument;
    5555    shouldBe("faces.length", "1");
    56     shouldBeEqualToString("faces[0].unicodeRange", "U+41-41");
     56    shouldBeEqualToString("faces[0].unicodeRange", "U+41");
    5757    shouldBeTrue("document.fonts.check('14px WebFont', 'A')");
    5858    return document.fonts.load("14px WebFont, WebFont2", "A");
     
    6161    shouldBe("faces.length", "1");
    6262    shouldBeEqualToString("faces[0].family", "WebFont");
    63     shouldBeEqualToString("faces[0].unicodeRange", "U+41-41");
     63    shouldBeEqualToString("faces[0].unicodeRange", "U+41");
    6464    shouldBeFalse("document.fonts.check('14px WebFont3', 'A')");
    6565    for (let f of document.fonts) {
    66         if (f.family == "WebFont3" && f.unicodeRange == "U+41-41")
     66        if (f.family == "WebFont3" && f.unicodeRange == "U+41")
    6767            return f.load();
    6868    }
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r251649 r251655  
     12019-10-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Can't change @font-face descriptors from fontFaceRule.style.setProperty()
     4        https://bugs.webkit.org/show_bug.cgi?id=177975
     5        <rdar://problem/56648761>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        More passing subtests.
     10
     11        * web-platform-tests/css/css-syntax/urange-parsing-expected.txt:
     12
    1132019-10-27  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/urange-parsing-expected.txt

    r251635 r251655  
    11
    2 FAIL "u/**/+/**/a/**/?" => "U+A0-AF" assert_equals: expected "U+A0-AF" but got ""
    3 FAIL "u+abc" => "U+ABC" assert_equals: expected "U+ABC" but got ""
    4 FAIL "U+abc" => "U+ABC" assert_equals: expected "U+ABC" but got ""
    5 FAIL "u+ABC" => "U+ABC" assert_equals: expected "U+ABC" but got ""
    6 FAIL "U+ABC" => "U+ABC" assert_equals: expected "U+ABC" but got ""
    7 FAIL "u+AbC" => "U+ABC" assert_equals: expected "U+ABC" but got ""
    8 FAIL "u+efg" is invalid assert_equals: expected "U+1357" but got ""
    9 FAIL "u+ abc" is invalid assert_equals: expected "U+1357" but got ""
    10 FAIL "u +abc" is invalid assert_equals: expected "U+1357" but got ""
    11 FAIL "u + abc" is invalid assert_equals: expected "U+1357" but got ""
    12 FAIL "U + a b c" is invalid assert_equals: expected "U+1357" but got ""
    13 FAIL "u+a" => "U+A" assert_equals: expected "U+A" but got ""
    14 FAIL "u+aa" => "U+AA" assert_equals: expected "U+AA" but got ""
    15 FAIL "u+aaa" => "U+AAA" assert_equals: expected "U+AAA" but got ""
    16 FAIL "u+aaaa" => "U+AAAA" assert_equals: expected "U+AAAA" but got ""
    17 FAIL "u+aaaaa" => "U+AAAAA" assert_equals: expected "U+AAAAA" but got ""
    18 FAIL "u+aaaaaaa" is invalid assert_equals: expected "U+1357" but got ""
    19 FAIL "u+a?" => "U+A0-AF" assert_equals: expected "U+A0-AF" but got ""
    20 FAIL "u+a??" => "U+A00-AFF" assert_equals: expected "U+A00-AFF" but got ""
    21 FAIL "u+a???" => "U+A000-AFFF" assert_equals: expected "U+A000-AFFF" but got ""
    22 FAIL "u+a????" => "U+A0000-AFFFF" assert_equals: expected "U+A0000-AFFFF" but got ""
    23 FAIL "u+aaaaaa?" is invalid assert_equals: expected "U+1357" but got ""
    24 FAIL "u+aaaaa??" is invalid assert_equals: expected "U+1357" but got ""
    25 FAIL "u+aaaa???" is invalid assert_equals: expected "U+1357" but got ""
    26 FAIL "u+aaa????" is invalid assert_equals: expected "U+1357" but got ""
    27 FAIL "u+aa?????" is invalid assert_equals: expected "U+1357" but got ""
    28 FAIL "u+a??????" is invalid assert_equals: expected "U+1357" but got ""
    29 FAIL "u+a?a" is invalid assert_equals: expected "U+1357" but got ""
    30 FAIL "u+aaaaaa" is invalid assert_equals: expected "U+1357" but got ""
    31 FAIL "u+a?????" is invalid assert_equals: expected "U+1357" but got ""
    32 FAIL "u/**/+0a/**/?" => "U+A0-AF" assert_equals: expected "U+A0-AF" but got ""
    33 FAIL "u+0a" => "U+A" assert_equals: expected "U+A" but got ""
    34 FAIL "U+0a0" => "U+A0" assert_equals: expected "U+A0" but got ""
    35 FAIL "u+0aaaaa" => "U+AAAAA" assert_equals: expected "U+AAAAA" but got ""
    36 FAIL "u+0aaaaaa" is invalid assert_equals: expected "U+1357" but got ""
    37 FAIL "u+0a0000" => "U+A0000" assert_equals: expected "U+A0000" but got ""
    38 FAIL "u+0a00000" is invalid assert_equals: expected "U+1357" but got ""
    39 FAIL "u+0aaaaa0" is invalid assert_equals: expected "U+1357" but got ""
    40 FAIL "u+00000a" => "U+A" assert_equals: expected "U+A" but got ""
    41 FAIL "u+00000aa" is invalid assert_equals: expected "U+1357" but got ""
    42 FAIL "u+00000a0" is invalid assert_equals: expected "U+1357" but got ""
    43 FAIL "u+000000a" is invalid assert_equals: expected "U+1357" but got ""
    44 FAIL "u+0a????" => "U+A0000-AFFFF" assert_equals: expected "U+A0000-AFFFF" but got ""
    45 FAIL "u+0a?????" is invalid assert_equals: expected "U+1357" but got ""
    46 FAIL "u+00a????" is invalid assert_equals: expected "U+1357" but got ""
    47 FAIL "u+22222a" is invalid assert_equals: expected "U+1357" but got ""
    48 FAIL "u+1e9a" => "U+1E9A" assert_equals: expected "U+1E9A" but got ""
    49 FAIL "u/**/+0/**/?" => "U+0-F" assert_equals: expected "U+0-F" but got ""
    50 FAIL "u/**/0" is invalid assert_equals: expected "U+1357" but got ""
    51 FAIL "u+0" => "U+0" assert_equals: expected "U+0" but got ""
    52 FAIL "u+00" => "U+0" assert_equals: expected "U+0" but got ""
    53 FAIL "u+000" => "U+0" assert_equals: expected "U+0" but got ""
    54 FAIL "u+0000" => "U+0" assert_equals: expected "U+0" but got ""
    55 FAIL "u+00000" => "U+0" assert_equals: expected "U+0" but got ""
    56 FAIL "u+000000" => "U+0" assert_equals: expected "U+0" but got ""
    57 FAIL "u+0000000" is invalid assert_equals: expected "U+1357" but got ""
    58 FAIL "u+00000?" => "U+0-F" assert_equals: expected "U+0-F" but got ""
    59 FAIL "u+0?????" => "U+0-FFFFF" assert_equals: expected "U+0-FFFFF" but got ""
    60 FAIL "u+0?a" is invalid assert_equals: expected "U+1357" but got ""
    61 FAIL "u+000000?" is invalid assert_equals: expected "U+1357" but got ""
    62 FAIL "u+00000??" is invalid assert_equals: expected "U+1357" but got ""
    63 FAIL "u+0??????" is invalid assert_equals: expected "U+1357" but got ""
    64 FAIL "u+1e3" => "U+1E3" assert_equals: expected "U+1E3" but got ""
    65 FAIL "u+1e-20" => "U+1E-20" assert_equals: expected "U+1E-20" but got ""
    66 FAIL "u+222222" is invalid assert_equals: expected "U+1357" but got ""
    67 FAIL "u+2?????" is invalid assert_equals: expected "U+1357" but got ""
    68 FAIL "u/**/+0/**/-0a" => "U+0-A" assert_equals: expected "U+0-A" but got ""
    69 FAIL "u+0-0a" => "U+0-A" assert_equals: expected "U+0-A" but got ""
    70 FAIL "u+000000-0aaaaa" => "U+0-AAAAA" assert_equals: expected "U+0-AAAAA" but got ""
    71 FAIL "u+0000000-0a" is invalid assert_equals: expected "U+1357" but got ""
    72 FAIL "u+0-0aaaaaa" is invalid assert_equals: expected "U+1357" but got ""
    73 FAIL "u+0-000000a" is invalid assert_equals: expected "U+1357" but got ""
    74 FAIL "u+0+0a" is invalid assert_equals: expected "U+1357" but got ""
    75 FAIL "u+0?-0a" is invalid assert_equals: expected "U+1357" but got ""
    76 FAIL "u+0-0a?" is invalid assert_equals: expected "U+1357" but got ""
    77 FAIL "u+222222-22222a" is invalid assert_equals: expected "U+1357" but got ""
    78 FAIL "u/**/+0/**/-1" => "U+0-1" assert_equals: expected "U+0-1" but got ""
    79 FAIL "u+0-1" => "U+0-1" assert_equals: expected "U+0-1" but got ""
    80 FAIL "u-0-1" is invalid assert_equals: expected "U+1357" but got ""
    81 FAIL "u-0+1" is invalid assert_equals: expected "U+1357" but got ""
    82 FAIL "u+0+1" is invalid assert_equals: expected "U+1357" but got ""
    83 FAIL "u+000000-000001" => "U+0-1" assert_equals: expected "U+0-1" but got ""
    84 FAIL "u+0000000-1" is invalid assert_equals: expected "U+1357" but got ""
    85 FAIL "u+0-0000001" is invalid assert_equals: expected "U+1357" but got ""
    86 FAIL "u+0-222222" is invalid assert_equals: expected "U+1357" but got ""
    87 FAIL "u/**/+/**/?" => "U+0-F" assert_equals: expected "U+0-F" but got ""
    88 FAIL "u+?" => "U+0-F" assert_equals: expected "U+0-F" but got ""
    89 FAIL "u+?????" => "u+0-FFFFF" assert_equals: expected "U+0-FFFFF" but got ""
    90 FAIL "u+???????" is invalid assert_equals: expected "U+1357" but got ""
    91 FAIL "u+?a" is invalid assert_equals: expected "U+1357" but got ""
    92 FAIL "u+??????" is invalid assert_equals: expected "U+1357" but got ""
     2FAIL "u/**/+/**/a/**/?" => "U+A0-AF" assert_equals: expected "U+A0-AF" but got "U+1357"
     3PASS "u+abc" => "U+ABC"
     4PASS "U+abc" => "U+ABC"
     5PASS "u+ABC" => "U+ABC"
     6PASS "U+ABC" => "U+ABC"
     7PASS "u+AbC" => "U+ABC"
     8PASS "u+efg" is invalid
     9PASS "u+ abc" is invalid
     10PASS "u +abc" is invalid
     11PASS "u + abc" is invalid
     12PASS "U + a b c" is invalid
     13PASS "u+a" => "U+A"
     14PASS "u+aa" => "U+AA"
     15PASS "u+aaa" => "U+AAA"
     16PASS "u+aaaa" => "U+AAAA"
     17PASS "u+aaaaa" => "U+AAAAA"
     18PASS "u+aaaaaaa" is invalid
     19PASS "u+a?" => "U+A0-AF"
     20PASS "u+a??" => "U+A00-AFF"
     21PASS "u+a???" => "U+A000-AFFF"
     22PASS "u+a????" => "U+A0000-AFFFF"
     23PASS "u+aaaaaa?" is invalid
     24PASS "u+aaaaa??" is invalid
     25PASS "u+aaaa???" is invalid
     26PASS "u+aaa????" is invalid
     27PASS "u+aa?????" is invalid
     28PASS "u+a??????" is invalid
     29PASS "u+a?a" is invalid
     30FAIL "u+aaaaaa" is invalid assert_equals: expected "U+1357" but got "U+AAAAAA"
     31FAIL "u+a?????" is invalid assert_equals: expected "U+1357" but got "U+A00000-AFFFFF"
     32FAIL "u/**/+0a/**/?" => "U+A0-AF" assert_equals: expected "U+A0-AF" but got "U+1357"
     33PASS "u+0a" => "U+A"
     34PASS "U+0a0" => "U+A0"
     35PASS "u+0aaaaa" => "U+AAAAA"
     36PASS "u+0aaaaaa" is invalid
     37PASS "u+0a0000" => "U+A0000"
     38PASS "u+0a00000" is invalid
     39PASS "u+0aaaaa0" is invalid
     40PASS "u+00000a" => "U+A"
     41PASS "u+00000aa" is invalid
     42PASS "u+00000a0" is invalid
     43PASS "u+000000a" is invalid
     44PASS "u+0a????" => "U+A0000-AFFFF"
     45PASS "u+0a?????" is invalid
     46PASS "u+00a????" is invalid
     47FAIL "u+22222a" is invalid assert_equals: expected "U+1357" but got "U+22222A"
     48PASS "u+1e9a" => "U+1E9A"
     49FAIL "u/**/+0/**/?" => "U+0-F" assert_equals: expected "U+0-F" but got "U+1357"
     50PASS "u/**/0" is invalid
     51PASS "u+0" => "U+0"
     52PASS "u+00" => "U+0"
     53PASS "u+000" => "U+0"
     54PASS "u+0000" => "U+0"
     55PASS "u+00000" => "U+0"
     56PASS "u+000000" => "U+0"
     57PASS "u+0000000" is invalid
     58PASS "u+00000?" => "U+0-F"
     59PASS "u+0?????" => "U+0-FFFFF"
     60PASS "u+0?a" is invalid
     61PASS "u+000000?" is invalid
     62PASS "u+00000??" is invalid
     63PASS "u+0??????" is invalid
     64PASS "u+1e3" => "U+1E3"
     65PASS "u+1e-20" => "U+1E-20"
     66FAIL "u+222222" is invalid assert_equals: expected "U+1357" but got "U+222222"
     67FAIL "u+2?????" is invalid assert_equals: expected "U+1357" but got "U+200000-2FFFFF"
     68FAIL "u/**/+0/**/-0a" => "U+0-A" assert_equals: expected "U+0-A" but got "U+1357"
     69PASS "u+0-0a" => "U+0-A"
     70PASS "u+000000-0aaaaa" => "U+0-AAAAA"
     71PASS "u+0000000-0a" is invalid
     72PASS "u+0-0aaaaaa" is invalid
     73PASS "u+0-000000a" is invalid
     74PASS "u+0+0a" is invalid
     75PASS "u+0?-0a" is invalid
     76PASS "u+0-0a?" is invalid
     77FAIL "u+222222-22222a" is invalid assert_equals: expected "U+1357" but got "U+222222-22222A"
     78FAIL "u/**/+0/**/-1" => "U+0-1" assert_equals: expected "U+0-1" but got "U+1357"
     79PASS "u+0-1" => "U+0-1"
     80PASS "u-0-1" is invalid
     81PASS "u-0+1" is invalid
     82PASS "u+0+1" is invalid
     83PASS "u+000000-000001" => "U+0-1"
     84PASS "u+0000000-1" is invalid
     85PASS "u+0-0000001" is invalid
     86FAIL "u+0-222222" is invalid assert_equals: expected "U+1357" but got "U+0-222222"
     87FAIL "u/**/+/**/?" => "U+0-F" assert_equals: expected "U+0-F" but got "U+1357"
     88PASS "u+?" => "U+0-F"
     89PASS "u+?????" => "u+0-FFFFF"
     90PASS "u+???????" is invalid
     91PASS "u+?a" is invalid
     92FAIL "u+??????" is invalid assert_equals: expected "U+1357" but got "U+0-FFFFFF"
    9393FAIL u+a is a valid selector assert_equals: expected "u + a" but got ".error"
    9494
  • trunk/Source/WebCore/ChangeLog

    r251654 r251655  
     12019-10-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Can't change @font-face descriptors from fontFaceRule.style.setProperty()
     4        https://bugs.webkit.org/show_bug.cgi?id=177975
     5        <rdar://problem/56648761>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        When parsing properties via PropertySetCSSStyleDeclaration::setProperty() (called from
     10        script as rule.style.setProperty()), CSSPropertyParser::parseValue() needs to know if
     11        we're parsing properties in a @font-face or @viewport rule, since some properties are
     12        only allowed in these contexts.
     13
     14        Achieve this by adding to CSSParserContext an Optional<enclosingRuleType>, which gets set
     15        for font-face and viewport rules. This gets set by StyleRuleCSSStyleDeclaration::cssParserContext()
     16        based on the type of the parent rule.
     17
     18        Moved StyleRule::Type to its own header so CSSParserContext can use it. Added compile-time asserts
     19        that the values match CSSRule::Type (fixing one of them).
     20
     21        Also fix <urange> serialization when start and end values are the same.
     22
     23        Test: web-platform-tests/css/css-syntax/urange-parsing.html
     24
     25        * Headers.cmake:
     26        * WebCore.xcodeproj/project.pbxproj:
     27        * css/CSSKeyframeRule.cpp:
     28        (WebCore::StyleRuleKeyframe::StyleRuleKeyframe):
     29        * css/CSSKeyframesRule.cpp:
     30        (WebCore::StyleRuleKeyframes::StyleRuleKeyframes):
     31        * css/CSSPropertySourceData.h:
     32        (WebCore::CSSRuleSourceData::create):
     33        (WebCore::CSSRuleSourceData::createUnknown):
     34        (WebCore::CSSRuleSourceData::CSSRuleSourceData):
     35        * css/CSSRule.cpp:
     36        * css/CSSUnicodeRangeValue.cpp:
     37        (WebCore::CSSUnicodeRangeValue::customCSSText const):
     38        * css/PropertySetCSSStyleDeclaration.cpp:
     39        (WebCore::StyleRuleCSSStyleDeclaration::cssParserContext const):
     40        * css/StyleRule.cpp:
     41        (WebCore::StyleRuleBase::destroy):
     42        (WebCore::StyleRuleBase::copy const):
     43        (WebCore::StyleRuleBase::createCSSOMWrapper const):
     44        (WebCore::StyleRule::StyleRule):
     45        (WebCore::StyleRulePage::StyleRulePage):
     46        (WebCore::StyleRuleFontFace::StyleRuleFontFace):
     47        (WebCore::StyleRuleGroup::StyleRuleGroup):
     48        (WebCore::StyleRuleMedia::StyleRuleMedia):
     49        (WebCore::StyleRuleSupports::StyleRuleSupports):
     50        (WebCore::StyleRuleViewport::StyleRuleViewport):
     51        (WebCore::StyleRuleCharset::StyleRuleCharset):
     52        (WebCore::StyleRuleNamespace::StyleRuleNamespace):
     53        * css/StyleRule.h:
     54        (WebCore::StyleRuleBase::type const):
     55        (WebCore::StyleRuleBase::isCharsetRule const):
     56        (WebCore::StyleRuleBase::isFontFaceRule const):
     57        (WebCore::StyleRuleBase::isKeyframesRule const):
     58        (WebCore::StyleRuleBase::isKeyframeRule const):
     59        (WebCore::StyleRuleBase::isNamespaceRule const):
     60        (WebCore::StyleRuleBase::isMediaRule const):
     61        (WebCore::StyleRuleBase::isPageRule const):
     62        (WebCore::StyleRuleBase::isStyleRule const):
     63        (WebCore::StyleRuleBase::isSupportsRule const):
     64        (WebCore::StyleRuleBase::isViewportRule const):
     65        (WebCore::StyleRuleBase::isImportRule const):
     66        (WebCore::StyleRuleBase::StyleRuleBase):
     67        * css/StyleRuleImport.cpp:
     68        (WebCore::StyleRuleImport::StyleRuleImport):
     69        * css/StyleRuleImport.h:
     70        * css/StyleRuleType.h: Copied from Source/WebCore/css/CSSUnicodeRangeValue.cpp.
     71        * css/StyleSheetContents.cpp:
     72        (WebCore::traverseRulesInVector):
     73        (WebCore::StyleSheetContents::traverseSubresources const):
     74        * css/parser/CSSParser.cpp:
     75        (WebCore::CSSParser::parseValueWithVariableReferences):
     76        * css/parser/CSSParserContext.h:
     77        * css/parser/CSSParserImpl.cpp:
     78        (WebCore::CSSParserImpl::parseValue):
     79        (WebCore::CSSParserImpl::parseInlineStyleDeclaration):
     80        (WebCore::CSSParserImpl::parseDeferredDeclaration):
     81        (WebCore::CSSParserImpl::parseDeclarationList):
     82        (WebCore::CSSParserImpl::supportsDeclaration):
     83        (WebCore::CSSParserImpl::parseDeclarationListForInspector):
     84        (WebCore::CSSParserImpl::consumeImportRule):
     85        (WebCore::CSSParserImpl::consumeMediaRule):
     86        (WebCore::CSSParserImpl::consumeSupportsRule):
     87        (WebCore::CSSParserImpl::consumeViewportRule):
     88        (WebCore::CSSParserImpl::consumeFontFaceRule):
     89        (WebCore::CSSParserImpl::consumeKeyframesRule):
     90        (WebCore::CSSParserImpl::consumePageRule):
     91        (WebCore::CSSParserImpl::consumeKeyframeStyleRule):
     92        (WebCore::observeSelectors):
     93        (WebCore::CSSParserImpl::consumeStyleRule):
     94        (WebCore::CSSParserImpl::consumeDeclarationList):
     95        (WebCore::CSSParserImpl::consumeDeclaration):
     96        (WebCore::CSSParserImpl::consumeDeclarationValue):
     97        * css/parser/CSSParserImpl.h:
     98        * css/parser/CSSParserObserver.h:
     99        * css/parser/CSSPropertyParser.cpp:
     100        (WebCore::CSSPropertyParser::parseValue):
     101        * css/parser/CSSPropertyParser.h:
     102        * css/parser/CSSTokenizer.cpp:
     103        (WebCore::CSSTokenizer::letterU):
     104        * inspector/InspectorStyleSheet.cpp:
     105        (flattenSourceData):
     106        (WebCore::StyleSheetHandler::startRuleHeader):
     107        (WebCore::InspectorStyleSheetForInlineStyle::ruleSourceData const):
     108
    11092019-10-28  Commit Queue  <commit-queue@webkit.org>
    2110
  • trunk/Source/WebCore/Headers.cmake

    r251574 r251655  
    336336    css/StyleColor.h
    337337    css/StyleProperties.h
     338    css/StyleRuleType.h
    338339    css/StyleSheet.h
    339340    css/StyleSheetContents.h
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r251637 r251655  
    332332                0F94B6522209150600157014 /* ScrollingStatePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B651220914FF00157014 /* ScrollingStatePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
    333333                0F94B655220931E400157014 /* ScrollingTreePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     334                0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94F37C23661131003AA5C7 /* StyleRuleType.h */; settings = {ATTRIBUTES = (Private, ); }; };
    334335                0F9DAA0F1FD1C66A0079C5B2 /* DOMGCOutputConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9DAA0E1FD1C6640079C5B2 /* DOMGCOutputConstraint.h */; };
    335336                0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    57385739                0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreePositionedNode.h; sourceTree = "<group>"; };
    57395740                0F94B6542209156C00157014 /* ScrollingTreePositionedNode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreePositionedNode.mm; sourceTree = "<group>"; };
     5741                0F94F37C23661131003AA5C7 /* StyleRuleType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StyleRuleType.h; sourceTree = "<group>"; };
    57405742                0F97A657155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DisplayRefreshMonitorIOS.mm; sourceTree = "<group>"; };
    57415743                0F9B547522B4A772007B5E8A /* ScrollingStateOverflowScrollProxyNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingStateOverflowScrollProxyNode.h; sourceTree = "<group>"; };
     
    91369138                697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; };
    91379139                697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; };
    9138                 AAD9D0B121DFA80C001B11C7 /* LazyLoadImageObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LazyLoadImageObserver.cpp; sourceTree = "<group>"; };
    9139                 AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LazyLoadImageObserver.h; sourceTree = "<group>"; };
    91409140                6A22E86F1F10418600F546C3 /* InspectorCanvas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InspectorCanvas.h; sourceTree = "<group>"; };
    91419141                6A22E8721F1042C400F546C3 /* InspectorCanvas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvas.cpp; sourceTree = "<group>"; };
     
    1213712137                AACC83D72316576A00EB6BF5 /* JSHTMLOrForeignElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSHTMLOrForeignElement.h; sourceTree = "<group>"; };
    1213812138                AACC83D82316576B00EB6BF5 /* JSHTMLOrForeignElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOrForeignElement.cpp; sourceTree = "<group>"; };
     12139                AAD9D0B121DFA80C001B11C7 /* LazyLoadImageObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LazyLoadImageObserver.cpp; sourceTree = "<group>"; };
     12140                AAD9D0B321DFA80E001B11C7 /* LazyLoadImageObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LazyLoadImageObserver.h; sourceTree = "<group>"; };
    1213912141                AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesizerMock.cpp; sourceTree = "<group>"; };
    1214012142                AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizerMock.h; sourceTree = "<group>"; };
     
    2733127333                                E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */,
    2733227334                                E4946EAD156E64DD00D3297F /* StyleRuleImport.h */,
     27335                                0F94F37C23661131003AA5C7 /* StyleRuleType.h */,
    2733327336                                A8EA80050A19516E00A8EF5F /* StyleSheet.cpp */,
    2733427337                                A8EA80040A19516E00A8EF5F /* StyleSheet.h */,
     
    3211732120                                E4BBED4D14FCDBA1003F0B98 /* StyleRule.h in Headers */,
    3211832121                                E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */,
     32122                                0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */,
    3211932123                                E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */,
    3212032124                                F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */,
  • trunk/Source/WebCore/css/CSSKeyframeRule.cpp

    r242713 r251655  
    3636
    3737StyleRuleKeyframe::StyleRuleKeyframe(Ref<StyleProperties>&& properties)
    38     : StyleRuleBase(Keyframe)
     38    : StyleRuleBase(StyleRuleType::Keyframe)
    3939    , m_properties(WTFMove(properties))
    4040{
     
    4242
    4343StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, Ref<StyleProperties>&& properties)
    44     : StyleRuleBase(Keyframe)
     44    : StyleRuleBase(StyleRuleType::Keyframe)
    4545    , m_properties(WTFMove(properties))
    4646    , m_keys(*keys)
  • trunk/Source/WebCore/css/CSSKeyframesRule.cpp

    r248846 r251655  
    3838
    3939StyleRuleKeyframes::StyleRuleKeyframes(const AtomString& name)
    40     : StyleRuleBase(Keyframes)
     40    : StyleRuleBase(StyleRuleType::Keyframes)
    4141    , m_name(name)
    4242{
     
    4444
    4545StyleRuleKeyframes::StyleRuleKeyframes(const AtomString& name, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    46     : StyleRuleBase(Keyframes)
     46    : StyleRuleBase(StyleRuleType::Keyframes)
    4747    , m_name(name)
    4848    , m_deferredRules(WTFMove(deferredRules))
  • trunk/Source/WebCore/css/CSSPropertySourceData.h

    r249013 r251655  
    8181
    8282struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> {
    83     static Ref<CSSRuleSourceData> create(StyleRule::Type type)
     83    static Ref<CSSRuleSourceData> create(StyleRuleType type)
    8484    {
    8585        return adoptRef(*new CSSRuleSourceData(type));
     
    8888    static Ref<CSSRuleSourceData> createUnknown()
    8989    {
    90         return adoptRef(*new CSSRuleSourceData(StyleRule::Unknown));
     90        return adoptRef(*new CSSRuleSourceData(StyleRuleType::Unknown));
    9191    }
    9292
    93     CSSRuleSourceData(StyleRule::Type type)
     93    CSSRuleSourceData(StyleRuleType type)
    9494        : type(type)
    9595    {
    96         if (type == StyleRule::Style || type == StyleRule::FontFace || type == StyleRule::Page)
     96        if (type == StyleRuleType::Style || type == StyleRuleType::FontFace || type == StyleRuleType::Page)
    9797            styleSourceData = CSSStyleSourceData::create();
    9898    }
    9999
    100     StyleRule::Type type;
     100    StyleRuleType type;
    101101
    102102    // Range of the selector list in the enclosing source.
  • trunk/Source/WebCore/css/CSSRule.cpp

    r222259 r251655  
    3737COMPILE_ASSERT(sizeof(CSSRule) == sizeof(SameSizeAsCSSRule), CSSRule_should_stay_small);
    3838
     39COMPILE_ASSERT(StyleRuleType::Unknown == static_cast<StyleRuleType>(CSSRule::Type::UNKNOWN_RULE), enums_should_match);
     40COMPILE_ASSERT(StyleRuleType::Style == static_cast<StyleRuleType>(CSSRule::Type::STYLE_RULE), enums_should_match);
     41COMPILE_ASSERT(StyleRuleType::Charset == static_cast<StyleRuleType>(CSSRule::Type::CHARSET_RULE), enums_should_match);
     42COMPILE_ASSERT(StyleRuleType::Import == static_cast<StyleRuleType>(CSSRule::Type::IMPORT_RULE), enums_should_match);
     43COMPILE_ASSERT(StyleRuleType::Media == static_cast<StyleRuleType>(CSSRule::Type::MEDIA_RULE), enums_should_match);
     44COMPILE_ASSERT(StyleRuleType::FontFace == static_cast<StyleRuleType>(CSSRule::Type::FONT_FACE_RULE), enums_should_match);
     45COMPILE_ASSERT(StyleRuleType::Page == static_cast<StyleRuleType>(CSSRule::Type::PAGE_RULE), enums_should_match);
     46COMPILE_ASSERT(StyleRuleType::Keyframes == static_cast<StyleRuleType>(CSSRule::Type::KEYFRAMES_RULE), enums_should_match);
     47COMPILE_ASSERT(StyleRuleType::Keyframe == static_cast<StyleRuleType>(CSSRule::Type::KEYFRAME_RULE), enums_should_match);
     48COMPILE_ASSERT(StyleRuleType::Namespace == static_cast<StyleRuleType>(CSSRule::Type::NAMESPACE_RULE), enums_should_match);
     49COMPILE_ASSERT(StyleRuleType::Supports == static_cast<StyleRuleType>(CSSRule::Type::SUPPORTS_RULE), enums_should_match);
    3950#if ENABLE(CSS_DEVICE_ADAPTATION)
    40 COMPILE_ASSERT(StyleRuleBase::Viewport == static_cast<StyleRuleBase::Type>(CSSRule::WEBKIT_VIEWPORT_RULE), enums_should_match);
     51COMPILE_ASSERT(StyleRuleBase::Viewport == static_cast<StyleRuleType>(CSSRule::WEBKIT_VIEWPORT_RULE), enums_should_match);
    4152#endif
    4253
  • trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp

    r241751 r251655  
    3333String CSSUnicodeRangeValue::customCSSText() const
    3434{
     35    if (m_from == m_to)
     36        return makeString("U+", hex(m_from, Lowercase));
     37
    3538    return makeString("U+", hex(m_from, Lowercase), '-', hex(m_to, Lowercase));
    3639}
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r248846 r251655  
    413413        return PropertySetCSSStyleDeclaration::cssParserContext();
    414414
    415     return styleSheet->parserContext();
     415    auto context = styleSheet->parserContext();
     416    if (m_parentRule)
     417        context.enclosingRuleType = static_cast<StyleRuleType>(m_parentRule->type());
     418   
     419    return context;
    416420}
    417421
  • trunk/Source/WebCore/css/StyleRule.cpp

    r246490 r251655  
    5959{
    6060    switch (type()) {
    61     case Style:
     61    case StyleRuleType::Style:
    6262        delete downcast<StyleRule>(this);
    6363        return;
    64     case Page:
     64    case StyleRuleType::Page:
    6565        delete downcast<StyleRulePage>(this);
    6666        return;
    67     case FontFace:
     67    case StyleRuleType::FontFace:
    6868        delete downcast<StyleRuleFontFace>(this);
    6969        return;
    70     case Media:
     70    case StyleRuleType::Media:
    7171        delete downcast<StyleRuleMedia>(this);
    7272        return;
    73     case Supports:
     73    case StyleRuleType::Supports:
    7474        delete downcast<StyleRuleSupports>(this);
    7575        return;
    76     case Import:
     76    case StyleRuleType::Import:
    7777        delete downcast<StyleRuleImport>(this);
    7878        return;
    79     case Keyframes:
     79    case StyleRuleType::Keyframes:
    8080        delete downcast<StyleRuleKeyframes>(this);
    8181        return;
    8282#if ENABLE(CSS_DEVICE_ADAPTATION)
    83     case Viewport:
     83    case StyleRuleType::Viewport:
    8484        delete downcast<StyleRuleViewport>(this);
    8585        return;
    8686#endif
    87     case Namespace:
     87    case StyleRuleType::Namespace:
    8888        delete downcast<StyleRuleNamespace>(this);
    8989        return;
    90     case Keyframe:
     90    case StyleRuleType::Keyframe:
    9191        delete downcast<StyleRuleKeyframe>(this);
    9292        return;
    93     case Charset:
     93    case StyleRuleType::Charset:
    9494        delete downcast<StyleRuleCharset>(this);
    9595        return;
    96     case Unknown:
     96    case StyleRuleType::Unknown:
    9797        ASSERT_NOT_REACHED();
    9898        return;
     
    104104{
    105105    switch (type()) {
    106     case Style:
     106    case StyleRuleType::Style:
    107107        return downcast<StyleRule>(*this).copy();
    108     case Page:
     108    case StyleRuleType::Page:
    109109        return downcast<StyleRulePage>(*this).copy();
    110     case FontFace:
     110    case StyleRuleType::FontFace:
    111111        return downcast<StyleRuleFontFace>(*this).copy();
    112     case Media:
     112    case StyleRuleType::Media:
    113113        return downcast<StyleRuleMedia>(*this).copy();
    114     case Supports:
     114    case StyleRuleType::Supports:
    115115        return downcast<StyleRuleSupports>(*this).copy();
    116     case Keyframes:
     116    case StyleRuleType::Keyframes:
    117117        return downcast<StyleRuleKeyframes>(*this).copy();
    118118#if ENABLE(CSS_DEVICE_ADAPTATION)
    119     case Viewport:
     119    case StyleRuleType::Viewport:
    120120        return downcast<StyleRuleViewport>(*this).copy();
    121121#endif
    122     case Import:
    123     case Namespace:
     122    case StyleRuleType::Import:
     123    case StyleRuleType::Namespace:
    124124        // FIXME: Copy import and namespace rules.
    125125        break;
    126     case Unknown:
    127     case Charset:
    128     case Keyframe:
     126    case StyleRuleType::Unknown:
     127    case StyleRuleType::Charset:
     128    case StyleRuleType::Keyframe:
    129129        break;
    130130    }
     
    137137    StyleRuleBase& self = const_cast<StyleRuleBase&>(*this);
    138138    switch (type()) {
    139     case Style:
     139    case StyleRuleType::Style:
    140140        rule = CSSStyleRule::create(downcast<StyleRule>(self), parentSheet);
    141141        break;
    142     case Page:
     142    case StyleRuleType::Page:
    143143        rule = CSSPageRule::create(downcast<StyleRulePage>(self), parentSheet);
    144144        break;
    145     case FontFace:
     145    case StyleRuleType::FontFace:
    146146        rule = CSSFontFaceRule::create(downcast<StyleRuleFontFace>(self), parentSheet);
    147147        break;
    148     case Media:
     148    case StyleRuleType::Media:
    149149        rule = CSSMediaRule::create(downcast<StyleRuleMedia>(self), parentSheet);
    150150        break;
    151     case Supports:
     151    case StyleRuleType::Supports:
    152152        rule = CSSSupportsRule::create(downcast<StyleRuleSupports>(self), parentSheet);
    153153        break;
    154     case Import:
     154    case StyleRuleType::Import:
    155155        rule = CSSImportRule::create(downcast<StyleRuleImport>(self), parentSheet);
    156156        break;
    157     case Keyframes:
     157    case StyleRuleType::Keyframes:
    158158        rule = CSSKeyframesRule::create(downcast<StyleRuleKeyframes>(self), parentSheet);
    159159        break;
    160160#if ENABLE(CSS_DEVICE_ADAPTATION)
    161     case Viewport:
     161    case StyleRuleType::Viewport:
    162162        rule = WebKitCSSViewportRule::create(downcast<StyleRuleViewport>(self), parentSheet);
    163163        break;
    164164#endif
    165     case Namespace:
     165    case StyleRuleType::Namespace:
    166166        rule = CSSNamespaceRule::create(downcast<StyleRuleNamespace>(self), parentSheet);
    167167        break;
    168     case Unknown:
    169     case Charset:
    170     case Keyframe:
     168    case StyleRuleType::Unknown:
     169    case StyleRuleType::Charset:
     170    case StyleRuleType::Keyframe:
    171171        ASSERT_NOT_REACHED();
    172172        break;
     
    185185
    186186StyleRule::StyleRule(Ref<StylePropertiesBase>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors)
    187     : StyleRuleBase(Style, hasDocumentSecurityOrigin)
     187    : StyleRuleBase(StyleRuleType::Style, hasDocumentSecurityOrigin)
    188188    , m_properties(WTFMove(properties))
    189189    , m_selectorList(WTFMove(selectors))
     
    251251
    252252StyleRulePage::StyleRulePage(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors)
    253     : StyleRuleBase(Page)
     253    : StyleRuleBase(StyleRuleType::Page)
    254254    , m_properties(WTFMove(properties))
    255255    , m_selectorList(WTFMove(selectors))
     
    274274
    275275StyleRuleFontFace::StyleRuleFontFace(Ref<StyleProperties>&& properties)
    276     : StyleRuleBase(FontFace)
     276    : StyleRuleBase(StyleRuleType::FontFace)
    277277    , m_properties(WTFMove(properties))
    278278{
     
    312312}
    313313   
    314 StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase>>& adoptRule)
     314StyleRuleGroup::StyleRuleGroup(StyleRuleType type, Vector<RefPtr<StyleRuleBase>>& adoptRule)
    315315    : StyleRuleBase(type)
    316316{
     
    318318}
    319319
    320 StyleRuleGroup::StyleRuleGroup(Type type, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
     320StyleRuleGroup::StyleRuleGroup(StyleRuleType type, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    321321    : StyleRuleBase(type)
    322322    , m_deferredRules(WTFMove(deferredRules))
     
    360360   
    361361StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    362     : StyleRuleGroup(Media, adoptRules)
     362    : StyleRuleGroup(StyleRuleType::Media, adoptRules)
    363363    , m_mediaQueries(WTFMove(media))
    364364{
     
    366366
    367367StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    368     : StyleRuleGroup(Media, WTFMove(deferredRules))
     368    : StyleRuleGroup(StyleRuleType::Media, WTFMove(deferredRules))
    369369    , m_mediaQueries(WTFMove(media))
    370370{
     
    380380
    381381StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules)
    382     : StyleRuleGroup(Supports, adoptRules)
     382    : StyleRuleGroup(StyleRuleType::Supports, adoptRules)
    383383    , m_conditionText(conditionText)
    384384    , m_conditionIsSupported(conditionIsSupported)
     
    387387
    388388StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported,  std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
    389     : StyleRuleGroup(Supports, WTFMove(deferredRules))
     389    : StyleRuleGroup(StyleRuleType::Supports, WTFMove(deferredRules))
    390390    , m_conditionText(conditionText)
    391391    , m_conditionIsSupported(conditionIsSupported)
     
    402402#if ENABLE(CSS_DEVICE_ADAPTATION)
    403403StyleRuleViewport::StyleRuleViewport(Ref<StyleProperties>&& properties)
    404     : StyleRuleBase(Viewport)
     404    : StyleRuleBase(StyleRuleType::Viewport)
    405405    , m_properties(WTFMove(properties))
    406406{
     
    424424
    425425StyleRuleCharset::StyleRuleCharset()
    426     : StyleRuleBase(Charset)
     426    : StyleRuleBase(StyleRuleType::Charset)
    427427{
    428428}
     
    436436
    437437StyleRuleNamespace::StyleRuleNamespace(AtomString prefix, AtomString uri)
    438     : StyleRuleBase(Namespace)
     438    : StyleRuleBase(StyleRuleType::Namespace)
    439439    , m_prefix(prefix)
    440440    , m_uri(uri)
  • trunk/Source/WebCore/css/StyleRule.h

    r246490 r251655  
    2525#include "CompiledSelector.h"
    2626#include "StyleProperties.h"
     27#include "StyleRuleType.h"
    2728#include <wtf/RefPtr.h>
    2829#include <wtf/TypeCasts.h>
     
    4344    WTF_MAKE_FAST_ALLOCATED;
    4445public:
    45     enum Type {
    46         Unknown, // Not used.
    47         Style,
    48         Charset, // Not used. These are internally strings owned by the style sheet.
    49         Import,
    50         Media,
    51         FontFace,
    52         Page,
    53         Keyframes,
    54         Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
    55         Namespace,
    56         Supports = 12,
     46    StyleRuleType type() const { return static_cast<StyleRuleType>(m_type); }
     47   
     48    bool isCharsetRule() const { return type() == StyleRuleType::Charset; }
     49    bool isFontFaceRule() const { return type() == StyleRuleType::FontFace; }
     50    bool isKeyframesRule() const { return type() == StyleRuleType::Keyframes; }
     51    bool isKeyframeRule() const { return type() == StyleRuleType::Keyframe; }
     52    bool isNamespaceRule() const { return type() == StyleRuleType::Namespace; }
     53    bool isMediaRule() const { return type() == StyleRuleType::Media; }
     54    bool isPageRule() const { return type() == StyleRuleType::Page; }
     55    bool isStyleRule() const { return type() == StyleRuleType::Style; }
     56    bool isSupportsRule() const { return type() == StyleRuleType::Supports; }
    5757#if ENABLE(CSS_DEVICE_ADAPTATION)
    58         Viewport = 15,
     58    bool isViewportRule() const { return type() == StyleRuleType::Viewport; }
    5959#endif
    60     };
    61 
    62     Type type() const { return static_cast<Type>(m_type); }
    63    
    64     bool isCharsetRule() const { return type() == Charset; }
    65     bool isFontFaceRule() const { return type() == FontFace; }
    66     bool isKeyframesRule() const { return type() == Keyframes; }
    67     bool isKeyframeRule() const { return type() == Keyframe; }
    68     bool isNamespaceRule() const { return type() == Namespace; }
    69     bool isMediaRule() const { return type() == Media; }
    70     bool isPageRule() const { return type() == Page; }
    71     bool isStyleRule() const { return type() == Style; }
    72     bool isSupportsRule() const { return type() == Supports; }
    73 #if ENABLE(CSS_DEVICE_ADAPTATION)
    74     bool isViewportRule() const { return type() == Viewport; }
    75 #endif
    76     bool isImportRule() const { return type() == Import; }
     60    bool isImportRule() const { return type() == StyleRuleType::Import; }
    7761
    7862    Ref<StyleRuleBase> copy() const;
     
    8973
    9074protected:
    91     StyleRuleBase(Type type, bool hasDocumentSecurityOrigin = false)
    92         : m_type(type)
     75    StyleRuleBase(StyleRuleType type, bool hasDocumentSecurityOrigin = false)
     76        : m_type(static_cast<unsigned>(type))
    9377        , m_hasDocumentSecurityOrigin(hasDocumentSecurityOrigin)
    9478    {
     
    11195    Ref<CSSRule> createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const;
    11296
    113     unsigned m_type : 5;
     97    unsigned m_type : 5; // StyleRuleType
    11498    // This is only needed to support getMatchedCSSRules.
    11599    unsigned m_hasDocumentSecurityOrigin : 1;
     
    242226   
    243227protected:
    244     StyleRuleGroup(Type, Vector<RefPtr<StyleRuleBase>>&);
    245     StyleRuleGroup(Type, std::unique_ptr<DeferredStyleGroupRuleList>&&);
     228    StyleRuleGroup(StyleRuleType, Vector<RefPtr<StyleRuleBase>>&);
     229    StyleRuleGroup(StyleRuleType, std::unique_ptr<DeferredStyleGroupRuleList>&&);
    246230    StyleRuleGroup(const StyleRuleGroup&);
    247231   
  • trunk/Source/WebCore/css/StyleRuleImport.cpp

    r240014 r251655  
    4343
    4444StyleRuleImport::StyleRuleImport(const String& href, Ref<MediaQuerySet>&& media)
    45     : StyleRuleBase(Import)
    46     , m_parentStyleSheet(0)
     45    : StyleRuleBase(StyleRuleType::Import)
    4746    , m_styleSheetClient(this)
    4847    , m_strHref(href)
    4948    , m_mediaQueries(WTFMove(media))
    50     , m_cachedSheet(0)
    51     , m_loading(false)
    5249{
    5350    if (!m_mediaQueries)
  • trunk/Source/WebCore/css/StyleRuleImport.h

    r223728 r251655  
    7373    StyleRuleImport(const String& href, Ref<MediaQuerySet>&&);
    7474
    75     StyleSheetContents* m_parentStyleSheet;
     75    StyleSheetContents* m_parentStyleSheet { nullptr };
    7676
    7777    ImportedStyleSheetClient m_styleSheetClient;
     
    8080    RefPtr<StyleSheetContents> m_styleSheet;
    8181    CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
    82     bool m_loading;
     82    bool m_loading { false };
    8383};
    8484
  • trunk/Source/WebCore/css/StyleRuleType.h

    r251654 r251655  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "CSSUnicodeRangeValue.h"
    28 
    29 #include <wtf/HexNumber.h>
     26#pragma once
    3027
    3128namespace WebCore {
    3229
    33 String CSSUnicodeRangeValue::customCSSText() const
    34 {
    35     return makeString("U+", hex(m_from, Lowercase), '-', hex(m_to, Lowercase));
    36 }
     30enum class StyleRuleType : uint8_t {
     31    Unknown, // Not used.
     32    Style,
     33    Charset, // Not used. These are internally strings owned by the style sheet.
     34    Import,
     35    Media,
     36    FontFace,
     37    Page,
     38    Keyframes,
     39    Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
     40    Namespace = 10,
     41    Supports = 12,
     42#if ENABLE(CSS_DEVICE_ADAPTATION)
     43    Viewport = 15,
     44#endif
     45};
    3746
    38 bool CSSUnicodeRangeValue::equals(const CSSUnicodeRangeValue& other) const
    39 {
    40     return m_from == other.m_from && m_to == other.m_to;
    41 }
    42 
    43 }
     47} // namespace WebCore
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r246490 r251655  
    427427            return true;
    428428        switch (rule->type()) {
    429         case StyleRuleBase::Media: {
     429        case StyleRuleType::Media: {
    430430            auto* childRules = downcast<StyleRuleMedia>(*rule).childRulesWithoutDeferredParsing();
    431431            if (childRules && traverseRulesInVector(*childRules, handler))
     
    433433            break;
    434434        }
    435         case StyleRuleBase::Import:
     435        case StyleRuleType::Import:
    436436            ASSERT_NOT_REACHED();
    437437            break;
    438         case StyleRuleBase::Style:
    439         case StyleRuleBase::FontFace:
    440         case StyleRuleBase::Page:
    441         case StyleRuleBase::Keyframes:
    442         case StyleRuleBase::Namespace:
    443         case StyleRuleBase::Unknown:
    444         case StyleRuleBase::Charset:
    445         case StyleRuleBase::Keyframe:
    446         case StyleRuleBase::Supports:
     438        case StyleRuleType::Style:
     439        case StyleRuleType::FontFace:
     440        case StyleRuleType::Page:
     441        case StyleRuleType::Keyframes:
     442        case StyleRuleType::Namespace:
     443        case StyleRuleType::Unknown:
     444        case StyleRuleType::Charset:
     445        case StyleRuleType::Keyframe:
     446        case StyleRuleType::Supports:
    447447#if ENABLE(CSS_DEVICE_ADAPTATION)
    448         case StyleRuleBase::Viewport:
     448        case StyleRuleType::Viewport:
    449449#endif
    450450            break;
     
    470470    return traverseRules([&] (const StyleRuleBase& rule) {
    471471        switch (rule.type()) {
    472         case StyleRuleBase::Style: {
     472        case StyleRuleType::Style: {
    473473            auto* properties = downcast<StyleRule>(rule).propertiesWithoutDeferredParsing();
    474474            return properties && properties->traverseSubresources(handler);
    475475        }
    476         case StyleRuleBase::FontFace:
     476        case StyleRuleType::FontFace:
    477477            return downcast<StyleRuleFontFace>(rule).properties().traverseSubresources(handler);
    478         case StyleRuleBase::Import:
     478        case StyleRuleType::Import:
    479479            if (auto* cachedResource = downcast<StyleRuleImport>(rule).cachedCSSStyleSheet())
    480480                return handler(*cachedResource);
    481481            return false;
    482         case StyleRuleBase::Media:
    483         case StyleRuleBase::Page:
    484         case StyleRuleBase::Keyframes:
    485         case StyleRuleBase::Namespace:
    486         case StyleRuleBase::Unknown:
    487         case StyleRuleBase::Charset:
    488         case StyleRuleBase::Keyframe:
    489         case StyleRuleBase::Supports:
     482        case StyleRuleType::Media:
     483        case StyleRuleType::Page:
     484        case StyleRuleType::Keyframes:
     485        case StyleRuleType::Namespace:
     486        case StyleRuleType::Unknown:
     487        case StyleRuleType::Charset:
     488        case StyleRuleType::Keyframe:
     489        case StyleRuleType::Supports:
    490490#if ENABLE(CSS_DEVICE_ADAPTATION)
    491         case StyleRuleBase::Viewport:
     491        case StyleRuleType::Viewport:
    492492#endif
    493493            return false;
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r251611 r251655  
    200200       
    201201        ParsedPropertyVector parsedProperties;
    202         if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedTokens, m_context, parsedProperties, StyleRule::Style))
     202        if (!CSSPropertyParser::parseValue(shorthandID, false, resolvedTokens, m_context, parsedProperties, StyleRuleType::Style))
    203203            return nullptr;
    204204       
  • trunk/Source/WebCore/css/parser/CSSParserContext.h

    r247050 r251655  
    2727
    2828#include "CSSParserMode.h"
     29#include "StyleRuleType.h"
    2930#include "TextEncoding.h"
    3031#include <wtf/HashFunctions.h>
     32#include <wtf/Optional.h>
    3133#include <wtf/URL.h>
    3234#include <wtf/URLHash.h>
     
    4042    WTF_MAKE_FAST_ALLOCATED;
    4143public:
     44
    4245    CSSParserContext(CSSParserMode, const URL& baseURL = URL());
    4346    WEBCORE_EXPORT CSSParserContext(const Document&, const URL& baseURL = URL(), const String& charset = emptyString());
     
    4649    String charset;
    4750    CSSParserMode mode { HTMLStandardMode };
     51    Optional<StyleRuleType> enclosingRuleType;
    4852    bool isHTMLDocument { false };
    4953#if ENABLE(TEXT_AUTOSIZING)
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r248846 r251655  
    8686{
    8787    CSSParserImpl parser(context, string);
    88     StyleRule::Type ruleType = StyleRule::Style;
    89 #if ENABLE(CSS_DEVICE_ADAPTATION)
    90     if (declaration->cssParserMode() == CSSViewportRuleMode)
    91         ruleType = StyleRule::Viewport;
    92 #endif
     88    auto ruleType = context.enclosingRuleType.valueOr(StyleRuleType::Style);
    9389    parser.consumeDeclarationValue(parser.tokenizer()->tokenRange(), propertyID, important, ruleType);
    9490    if (parser.m_parsedProperties.isEmpty())
     
    163159
    164160    CSSParserImpl parser(context, string);
    165     parser.consumeDeclarationList(parser.tokenizer()->tokenRange(), StyleRule::Style);
     161    parser.consumeDeclarationList(parser.tokenizer()->tokenRange(), StyleRuleType::Style);
    166162    return createStyleProperties(parser.m_parsedProperties, context.mode);
    167163}
     
    174170    }
    175171    CSSParserImpl parser(context, styleSheet);
    176     parser.consumeDeclarationList(tokenRange, StyleRule::Style);
     172    parser.consumeDeclarationList(tokenRange, StyleRuleType::Style);
    177173    return createStyleProperties(parser.m_parsedProperties, context.mode);
    178174}
     
    202198{
    203199    CSSParserImpl parser(context, string);
    204     StyleRule::Type ruleType = StyleRule::Style;
    205 #if ENABLE(CSS_DEVICE_ADAPTATION)
    206     if (declaration->cssParserMode() == CSSViewportRuleMode)
    207         ruleType = StyleRule::Viewport;
    208 #endif
     200    auto ruleType = context.enclosingRuleType.valueOr(StyleRuleType::Style);
    209201    parser.consumeDeclarationList(parser.tokenizer()->tokenRange(), ruleType);
    210202    if (parser.m_parsedProperties.isEmpty())
     
    307299{
    308300    ASSERT(m_parsedProperties.isEmpty());
    309     consumeDeclaration(range, StyleRule::Style);
     301    consumeDeclaration(range, StyleRuleType::Style);
    310302    bool result = !m_parsedProperties.isEmpty();
    311303    m_parsedProperties.clear();
     
    317309    CSSParserObserverWrapper wrapper(observer);
    318310    CSSParserImpl parser(context, declaration, nullptr, &wrapper);
    319     observer.startRuleHeader(StyleRule::Style, 0);
     311    observer.startRuleHeader(StyleRuleType::Style, 0);
    320312    observer.endRuleHeader(1);
    321     parser.consumeDeclarationList(parser.tokenizer()->tokenRange(), StyleRule::Style);
     313    parser.consumeDeclarationList(parser.tokenizer()->tokenRange(), StyleRuleType::Style);
    322314}
    323315
     
    511503    if (m_observerWrapper) {
    512504        unsigned endOffset = m_observerWrapper->endOffset(prelude);
    513         m_observerWrapper->observer().startRuleHeader(StyleRule::Import, m_observerWrapper->startOffset(prelude));
     505        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Import, m_observerWrapper->startOffset(prelude));
    514506        m_observerWrapper->observer().endRuleHeader(endOffset);
    515507        m_observerWrapper->observer().startRuleBody(endOffset);
     
    541533
    542534    if (m_observerWrapper) {
    543         m_observerWrapper->observer().startRuleHeader(StyleRule::Media, m_observerWrapper->startOffset(prelude));
     535        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Media, m_observerWrapper->startOffset(prelude));
    544536        m_observerWrapper->observer().endRuleHeader(m_observerWrapper->endOffset(prelude));
    545537        m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousTokenStartOffset(block));
     
    567559
    568560    if (m_observerWrapper) {
    569         m_observerWrapper->observer().startRuleHeader(StyleRule::Supports, m_observerWrapper->startOffset(prelude));
     561        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Supports, m_observerWrapper->startOffset(prelude));
    570562        m_observerWrapper->observer().endRuleHeader(m_observerWrapper->endOffset(prelude));
    571563        m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousTokenStartOffset(block));
     
    592584    if (m_observerWrapper) {
    593585        unsigned endOffset = m_observerWrapper->endOffset(prelude);
    594         m_observerWrapper->observer().startRuleHeader(StyleRule::Viewport, m_observerWrapper->startOffset(prelude));
     586        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Viewport, m_observerWrapper->startOffset(prelude));
    595587        m_observerWrapper->observer().endRuleHeader(endOffset);
    596588        m_observerWrapper->observer().startRuleBody(endOffset);
     
    610602    if (m_observerWrapper) {
    611603        unsigned endOffset = m_observerWrapper->endOffset(prelude);
    612         m_observerWrapper->observer().startRuleHeader(StyleRule::FontFace, m_observerWrapper->startOffset(prelude));
     604        m_observerWrapper->observer().startRuleHeader(StyleRuleType::FontFace, m_observerWrapper->startOffset(prelude));
    613605        m_observerWrapper->observer().endRuleHeader(endOffset);
    614606        m_observerWrapper->observer().startRuleBody(endOffset);
     
    616608    }
    617609
    618     consumeDeclarationList(block, StyleRule::FontFace);
     610    consumeDeclarationList(block, StyleRuleType::FontFace);
    619611    return StyleRuleFontFace::create(createStyleProperties(m_parsedProperties, m_context.mode));
    620612}
     
    639631
    640632    if (m_observerWrapper) {
    641         m_observerWrapper->observer().startRuleHeader(StyleRule::Keyframes, m_observerWrapper->startOffset(rangeCopy));
     633        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Keyframes, m_observerWrapper->startOffset(rangeCopy));
    642634        m_observerWrapper->observer().endRuleHeader(m_observerWrapper->endOffset(prelude));
    643635        m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousTokenStartOffset(block));
     
    663655    if (m_observerWrapper) {
    664656        unsigned endOffset = m_observerWrapper->endOffset(prelude);
    665         m_observerWrapper->observer().startRuleHeader(StyleRule::Page, m_observerWrapper->startOffset(prelude));
     657        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Page, m_observerWrapper->startOffset(prelude));
    666658        m_observerWrapper->observer().endRuleHeader(endOffset);
    667659    }
    668660
    669     consumeDeclarationList(block, StyleRule::Style);
     661    consumeDeclarationList(block, StyleRuleType::Style);
    670662   
    671663    return StyleRulePage::create(createStyleProperties(m_parsedProperties, m_context.mode), WTFMove(selectorList));
     
    691683
    692684    if (m_observerWrapper) {
    693         m_observerWrapper->observer().startRuleHeader(StyleRule::Keyframe, m_observerWrapper->startOffset(prelude));
     685        m_observerWrapper->observer().startRuleHeader(StyleRuleType::Keyframe, m_observerWrapper->startOffset(prelude));
    694686        m_observerWrapper->observer().endRuleHeader(m_observerWrapper->endOffset(prelude));
    695687    }
    696688
    697     consumeDeclarationList(block, StyleRule::Keyframe);
     689    consumeDeclarationList(block, StyleRuleType::Keyframe);
    698690    return StyleRuleKeyframe::create(WTFMove(keyList), createStyleProperties(m_parsedProperties, m_context.mode));
    699691}
     
    704696    selectors.consumeWhitespace();
    705697    CSSParserTokenRange originalRange = selectors;
    706     wrapper.observer().startRuleHeader(StyleRule::Style, wrapper.startOffset(originalRange));
     698    wrapper.observer().startRuleHeader(StyleRuleType::Style, wrapper.startOffset(originalRange));
    707699
    708700    while (!selectors.atEnd()) {
     
    740732    }
    741733
    742     consumeDeclarationList(block, StyleRule::Style);
     734    consumeDeclarationList(block, StyleRuleType::Style);
    743735    return StyleRule::create(createStyleProperties(m_parsedProperties, m_context.mode), m_context.hasDocumentSecurityOrigin, WTFMove(selectorList));
    744736}
    745737
    746 void CSSParserImpl::consumeDeclarationList(CSSParserTokenRange range, StyleRule::Type ruleType)
     738void CSSParserImpl::consumeDeclarationList(CSSParserTokenRange range, StyleRuleType ruleType)
    747739{
    748740    ASSERT(m_parsedProperties.isEmpty());
    749741
    750     bool useObserver = m_observerWrapper && (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe);
     742    bool useObserver = m_observerWrapper && (ruleType == StyleRuleType::Style || ruleType == StyleRuleType::Keyframe);
    751743    if (useObserver) {
    752744        m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousTokenStartOffset(range));
     
    777769        case AtKeywordToken: {
    778770            // FIXME-NEWPARSER: Support apply
    779             AllowedRulesType allowedRules = /* ruleType == StyleRule::Style && RuntimeEnabledFeatures::cssApplyAtRulesEnabled() ? ApplyRules :*/ NoRules;
     771            AllowedRulesType allowedRules = /* ruleType == StyleRuleType::Style && RuntimeEnabledFeatures::cssApplyAtRulesEnabled() ? ApplyRules :*/ NoRules;
    780772            RefPtr<StyleRuleBase> rule = consumeAtRule(range, allowedRules);
    781773            ASSERT_UNUSED(rule, !rule);
     
    796788}
    797789
    798 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Type ruleType)
     790void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRuleType ruleType)
    799791{
    800792    CSSParserTokenRange rangeCopy = range; // For inspector callbacks
     
    827819    }
    828820
    829     if (important && (ruleType == StyleRule::FontFace || ruleType == StyleRule::Keyframe))
     821    if (important && (ruleType == StyleRuleType::FontFace || ruleType == StyleRuleType::Keyframe))
    830822        return;
    831823
     
    833825        consumeDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), propertyID, important, ruleType);
    834826
    835     if (m_observerWrapper && (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) {
     827    if (m_observerWrapper && (ruleType == StyleRuleType::Style || ruleType == StyleRuleType::Keyframe)) {
    836828        m_observerWrapper->observer().observeProperty(
    837829            m_observerWrapper->startOffset(rangeCopy), m_observerWrapper->endOffset(rangeCopy),
     
    846838}
    847839
    848 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID propertyID, bool important, StyleRule::Type ruleType)
     840void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID propertyID, bool important, StyleRuleType ruleType)
    849841{
    850842    CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_parsedProperties, ruleType);
  • trunk/Source/WebCore/css/parser/CSSParserImpl.h

    r246490 r251655  
    139139    RefPtr<StyleRule> consumeStyleRule(CSSParserTokenRange prelude, CSSParserTokenRange block);
    140140
    141     void consumeDeclarationList(CSSParserTokenRange, StyleRule::Type);
    142     void consumeDeclaration(CSSParserTokenRange, StyleRule::Type);
    143     void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool important, StyleRule::Type);
     141    void consumeDeclarationList(CSSParserTokenRange, StyleRuleType);
     142    void consumeDeclaration(CSSParserTokenRange, StyleRuleType);
     143    void consumeDeclarationValue(CSSParserTokenRange, CSSPropertyID, bool important, StyleRuleType);
    144144    void consumeCustomPropertyValue(CSSParserTokenRange, const AtomString& propertyName, bool important);
    145145
  • trunk/Source/WebCore/css/parser/CSSParserObserver.h

    r218588 r251655  
    3434public:
    3535    virtual ~CSSParserObserver() { };
    36     virtual void startRuleHeader(StyleRule::Type, unsigned offset) = 0;
     36    virtual void startRuleHeader(StyleRuleType, unsigned offset) = 0;
    3737    virtual void endRuleHeader(unsigned offset) = 0;
    3838    virtual void observeSelector(unsigned startOffset, unsigned endOffset) = 0;
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r251252 r251655  
    260260}
    261261
    262 bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important, const CSSParserTokenRange& range, const CSSParserContext& context, ParsedPropertyVector& parsedProperties, StyleRule::Type ruleType)
     262bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important, const CSSParserTokenRange& range, const CSSParserContext& context, ParsedPropertyVector& parsedProperties, StyleRuleType ruleType)
    263263{
    264264    int parsedPropertiesSize = parsedProperties.size();
     
    268268
    269269#if ENABLE(CSS_DEVICE_ADAPTATION)
    270     if (ruleType == StyleRule::Viewport)
     270    if (ruleType == StyleRuleType::Viewport)
    271271        parseSuccess = parser.parseViewportDescriptor(propertyID, important);
    272272    else
    273273#endif
    274     if (ruleType == StyleRule::FontFace)
     274    if (ruleType == StyleRuleType::FontFace)
    275275        parseSuccess = parser.parseFontFaceDescriptor(propertyID);
    276276    else
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.h

    r250849 r251655  
    4343    static bool parseValue(CSSPropertyID, bool important,
    4444        const CSSParserTokenRange&, const CSSParserContext&,
    45         Vector<CSSProperty, 256>&, StyleRule::Type);
     45        Vector<CSSProperty, 256>&, StyleRuleType);
    4646
    4747    // Parses a non-shorthand CSS property
  • trunk/Source/WebCore/css/parser/CSSTokenizer.cpp

    r248659 r251655  
    328328{
    329329    if (m_input.peekWithoutReplacement(0) == '+'
    330         && (isASCIIHexDigit(m_input.peekWithoutReplacement(1))
    331             || m_input.peekWithoutReplacement(1) == '?')) {
     330        && (isASCIIHexDigit(m_input.peekWithoutReplacement(1)) || m_input.peekWithoutReplacement(1) == '?')) {
    332331        m_input.advance();
    333332        return consumeUnicodeRange();
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r251038 r251655  
    102102{
    103103    for (auto& data : dataList) {
    104         if (data->type == WebCore::StyleRule::Style)
     104        if (data->type == WebCore::StyleRuleType::Style)
    105105            target.append(data.copyRef());
    106         else if (data->type == WebCore::StyleRule::Media)
     106        else if (data->type == WebCore::StyleRuleType::Media)
    107107            flattenSourceData(data->childRules, target);
    108         else if (data->type == WebCore::StyleRule::Supports)
     108        else if (data->type == WebCore::StyleRuleType::Supports)
    109109            flattenSourceData(data->childRules, target);
    110110    }
     
    155155   
    156156private:
    157     void startRuleHeader(StyleRule::Type, unsigned) override;
     157    void startRuleHeader(StyleRuleType, unsigned) override;
    158158    void endRuleHeader(unsigned) override;
    159159    void observeSelector(unsigned startOffset, unsigned endOffset) override;
     
    175175};
    176176
    177 void StyleSheetHandler::startRuleHeader(StyleRule::Type type, unsigned offset)
     177void StyleSheetHandler::startRuleHeader(StyleRuleType type, unsigned offset)
    178178{
    179179    // Pop off data for a previous invalid rule.
     
    15691569{
    15701570    if (m_styleText.isEmpty()) {
    1571         auto result = CSSRuleSourceData::create(StyleRule::Style);
     1571        auto result = CSSRuleSourceData::create(StyleRuleType::Style);
    15721572        result->ruleBodyRange.start = 0;
    15731573        result->ruleBodyRange.end = 0;
Note: See TracChangeset for help on using the changeset viewer.