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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251655 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/css/StyleRule.cpp b/Source/WebCore/css/StyleRule.cpp
index 1df0a2a..1f99fdf 100644
--- a/Source/WebCore/css/StyleRule.cpp
+++ b/Source/WebCore/css/StyleRule.cpp
@@ -58,42 +58,42 @@
void StyleRuleBase::destroy()
{
switch (type()) {
- case Style:
+ case StyleRuleType::Style:
delete downcast<StyleRule>(this);
return;
- case Page:
+ case StyleRuleType::Page:
delete downcast<StyleRulePage>(this);
return;
- case FontFace:
+ case StyleRuleType::FontFace:
delete downcast<StyleRuleFontFace>(this);
return;
- case Media:
+ case StyleRuleType::Media:
delete downcast<StyleRuleMedia>(this);
return;
- case Supports:
+ case StyleRuleType::Supports:
delete downcast<StyleRuleSupports>(this);
return;
- case Import:
+ case StyleRuleType::Import:
delete downcast<StyleRuleImport>(this);
return;
- case Keyframes:
+ case StyleRuleType::Keyframes:
delete downcast<StyleRuleKeyframes>(this);
return;
#if ENABLE(CSS_DEVICE_ADAPTATION)
- case Viewport:
+ case StyleRuleType::Viewport:
delete downcast<StyleRuleViewport>(this);
return;
#endif
- case Namespace:
+ case StyleRuleType::Namespace:
delete downcast<StyleRuleNamespace>(this);
return;
- case Keyframe:
+ case StyleRuleType::Keyframe:
delete downcast<StyleRuleKeyframe>(this);
return;
- case Charset:
+ case StyleRuleType::Charset:
delete downcast<StyleRuleCharset>(this);
return;
- case Unknown:
+ case StyleRuleType::Unknown:
ASSERT_NOT_REACHED();
return;
}
@@ -103,29 +103,29 @@
Ref<StyleRuleBase> StyleRuleBase::copy() const
{
switch (type()) {
- case Style:
+ case StyleRuleType::Style:
return downcast<StyleRule>(*this).copy();
- case Page:
+ case StyleRuleType::Page:
return downcast<StyleRulePage>(*this).copy();
- case FontFace:
+ case StyleRuleType::FontFace:
return downcast<StyleRuleFontFace>(*this).copy();
- case Media:
+ case StyleRuleType::Media:
return downcast<StyleRuleMedia>(*this).copy();
- case Supports:
+ case StyleRuleType::Supports:
return downcast<StyleRuleSupports>(*this).copy();
- case Keyframes:
+ case StyleRuleType::Keyframes:
return downcast<StyleRuleKeyframes>(*this).copy();
#if ENABLE(CSS_DEVICE_ADAPTATION)
- case Viewport:
+ case StyleRuleType::Viewport:
return downcast<StyleRuleViewport>(*this).copy();
#endif
- case Import:
- case Namespace:
+ case StyleRuleType::Import:
+ case StyleRuleType::Namespace:
// FIXME: Copy import and namespace rules.
break;
- case Unknown:
- case Charset:
- case Keyframe:
+ case StyleRuleType::Unknown:
+ case StyleRuleType::Charset:
+ case StyleRuleType::Keyframe:
break;
}
CRASH();
@@ -136,38 +136,38 @@
RefPtr<CSSRule> rule;
StyleRuleBase& self = const_cast<StyleRuleBase&>(*this);
switch (type()) {
- case Style:
+ case StyleRuleType::Style:
rule = CSSStyleRule::create(downcast<StyleRule>(self), parentSheet);
break;
- case Page:
+ case StyleRuleType::Page:
rule = CSSPageRule::create(downcast<StyleRulePage>(self), parentSheet);
break;
- case FontFace:
+ case StyleRuleType::FontFace:
rule = CSSFontFaceRule::create(downcast<StyleRuleFontFace>(self), parentSheet);
break;
- case Media:
+ case StyleRuleType::Media:
rule = CSSMediaRule::create(downcast<StyleRuleMedia>(self), parentSheet);
break;
- case Supports:
+ case StyleRuleType::Supports:
rule = CSSSupportsRule::create(downcast<StyleRuleSupports>(self), parentSheet);
break;
- case Import:
+ case StyleRuleType::Import:
rule = CSSImportRule::create(downcast<StyleRuleImport>(self), parentSheet);
break;
- case Keyframes:
+ case StyleRuleType::Keyframes:
rule = CSSKeyframesRule::create(downcast<StyleRuleKeyframes>(self), parentSheet);
break;
#if ENABLE(CSS_DEVICE_ADAPTATION)
- case Viewport:
+ case StyleRuleType::Viewport:
rule = WebKitCSSViewportRule::create(downcast<StyleRuleViewport>(self), parentSheet);
break;
#endif
- case Namespace:
+ case StyleRuleType::Namespace:
rule = CSSNamespaceRule::create(downcast<StyleRuleNamespace>(self), parentSheet);
break;
- case Unknown:
- case Charset:
- case Keyframe:
+ case StyleRuleType::Unknown:
+ case StyleRuleType::Charset:
+ case StyleRuleType::Keyframe:
ASSERT_NOT_REACHED();
break;
}
@@ -184,7 +184,7 @@
}
StyleRule::StyleRule(Ref<StylePropertiesBase>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors)
- : StyleRuleBase(Style, hasDocumentSecurityOrigin)
+ : StyleRuleBase(StyleRuleType::Style, hasDocumentSecurityOrigin)
, m_properties(WTFMove(properties))
, m_selectorList(WTFMove(selectors))
{
@@ -250,7 +250,7 @@
}
StyleRulePage::StyleRulePage(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors)
- : StyleRuleBase(Page)
+ : StyleRuleBase(StyleRuleType::Page)
, m_properties(WTFMove(properties))
, m_selectorList(WTFMove(selectors))
{
@@ -273,7 +273,7 @@
}
StyleRuleFontFace::StyleRuleFontFace(Ref<StyleProperties>&& properties)
- : StyleRuleBase(FontFace)
+ : StyleRuleBase(StyleRuleType::FontFace)
, m_properties(WTFMove(properties))
{
}
@@ -311,13 +311,13 @@
m_parser->parseKeyframeList(m_tokens, keyframesRule);
}
-StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase>>& adoptRule)
+StyleRuleGroup::StyleRuleGroup(StyleRuleType type, Vector<RefPtr<StyleRuleBase>>& adoptRule)
: StyleRuleBase(type)
{
m_childRules.swap(adoptRule);
}
-StyleRuleGroup::StyleRuleGroup(Type type, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
+StyleRuleGroup::StyleRuleGroup(StyleRuleType type, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
: StyleRuleBase(type)
, m_deferredRules(WTFMove(deferredRules))
{
@@ -359,13 +359,13 @@
}
StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>& adoptRules)
- : StyleRuleGroup(Media, adoptRules)
+ : StyleRuleGroup(StyleRuleType::Media, adoptRules)
, m_mediaQueries(WTFMove(media))
{
}
StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
- : StyleRuleGroup(Media, WTFMove(deferredRules))
+ : StyleRuleGroup(StyleRuleType::Media, WTFMove(deferredRules))
, m_mediaQueries(WTFMove(media))
{
}
@@ -379,14 +379,14 @@
StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>& adoptRules)
- : StyleRuleGroup(Supports, adoptRules)
+ : StyleRuleGroup(StyleRuleType::Supports, adoptRules)
, m_conditionText(conditionText)
, m_conditionIsSupported(conditionIsSupported)
{
}
StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, std::unique_ptr<DeferredStyleGroupRuleList>&& deferredRules)
- : StyleRuleGroup(Supports, WTFMove(deferredRules))
+ : StyleRuleGroup(StyleRuleType::Supports, WTFMove(deferredRules))
, m_conditionText(conditionText)
, m_conditionIsSupported(conditionIsSupported)
{
@@ -401,7 +401,7 @@
#if ENABLE(CSS_DEVICE_ADAPTATION)
StyleRuleViewport::StyleRuleViewport(Ref<StyleProperties>&& properties)
- : StyleRuleBase(Viewport)
+ : StyleRuleBase(StyleRuleType::Viewport)
, m_properties(WTFMove(properties))
{
}
@@ -423,7 +423,7 @@
#endif // ENABLE(CSS_DEVICE_ADAPTATION)
StyleRuleCharset::StyleRuleCharset()
- : StyleRuleBase(Charset)
+ : StyleRuleBase(StyleRuleType::Charset)
{
}
@@ -435,7 +435,7 @@
StyleRuleCharset::~StyleRuleCharset() = default;
StyleRuleNamespace::StyleRuleNamespace(AtomString prefix, AtomString uri)
- : StyleRuleBase(Namespace)
+ : StyleRuleBase(StyleRuleType::Namespace)
, m_prefix(prefix)
, m_uri(uri)
{