haikuwebkit/Source/WebCore/css/StyleRuleType.h

46 lines
1.7 KiB
C
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/216882@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251655 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-28 16:02:53 +00:00
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
namespace WebCore {
enum class StyleRuleType : uint8_t {
Unknown, // Not used.
Style,
Charset, // Not used. These are internally strings owned by the style sheet.
Import,
Media,
FontFace,
Page,
Keyframes,
Keyframe, // Not used. These are internally non-rule StyleRuleKeyframe objects.
Namespace = 10,
[css-counter-styles] Parse and add feature flag for @counter-style https://bugs.webkit.org/show_bug.cgi?id=223150 Patch by Tyler Wilcock <twilco.o@protonmail.com> on 2021-04-16 Reviewed by Darin Adler. LayoutTests/imported/w3c: @counter-style and its descriptors are now exposed behind a feature flag, so pass some tests and fail others for a different reason because this patch doesn't actually implement descriptor parsing and setting yet. * web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-fallback-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-name-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-negative-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-pad-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-prefix-suffix-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-range-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-speak-as-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-symbols-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/counter-style-system-syntax-expected.txt: * web-platform-tests/css/css-counter-styles/idlharness-expected.txt: * web-platform-tests/css/cssom/CSSCounterStyleRule-expected.txt: Source/WebCore: Parse @counter-style (without implementing descriptor parsing) behind a new feature flag, CSSCounterStyleAtRulesEnabled. A separate feature flag for @counter-style <image> symbol values has also been added, as image symbols have extra complexities that we won't want to hold the entire feature back on. https://www.w3.org/TR/css-counter-styles-3 The CSSCounterStyleRule IDL interface is also added and implemented, and similarly feature flagged. https://www.w3.org/TR/css-counter-styles-3/#apis Test: webexposed/counter-style-is-not-exposed.html and existing WPTs. * CMakeLists.txt: Add CSSCounterStyleRule.idl. * DerivedSources-input.xcfilelist: Add CSSCounterStyleRule.idl. * DerivedSources-output.xcfilelist: Add JSCSSCounterStyleRule.h and JSCSSCounterStyleRule.cpp. * DerivedSources.make: Add CSSCounterStyleRule.idl. * Sources.txt: Add CSSCounterStyleRule.cpp and JSCSSCounterStyleRule.cpp. * WebCore.xcodeproj/project.pbxproj: Add CounterStyle.h, CounterStyle.cpp, and CounterStyle.idl. * bindings/js/JSCSSRuleCustom.cpp: (WebCore::toJSNewlyCreated): Support CSSCounterStyleRule. * bindings/js/WebCoreBuiltinNames.h: Add macro(CSSCounterStyleRule) to generate counter-style built-in names. * css/CSSCounterStyleRule.cpp: Added. (WebCore::StyleRuleCounterStyle::StyleRuleCounterStyle): (WebCore::StyleRuleCounterStyle::create): (WebCore::StyleRuleCounterStyle::mutableProperties): (WebCore::CSSCounterStyleRule::CSSCounterStyleRule): (WebCore::CSSCounterStyleRule::reattach): (WebCore::CSSCounterStyleRule::cssText const): * css/CSSCounterStyleRule.h: Added. (isType): Add specialized rule.isCounterStyleRule() implementation. * css/CSSCounterStyleRule.idl: Added. * css/CSSRule.cpp: Add new StyleRuleType::CounterStyle COMPILE_ASSERT. * css/CSSRule.h: Add COUNTER_STYLE_RULE constant. Also add comment `// WebIDL enum` to disable enum_casing lint, since these values are named to match IDL attributes. * css/CSSRule.idl: Add COUNTER_STYLE_RULE constant behind flag. * css/StyleRule.cpp: (WebCore::StyleRuleBase::destroy): (WebCore::StyleRuleBase::copy const): (WebCore::StyleRuleBase::createCSSOMWrapper const): Handle newly added StyleRuleType::CounterStyle. * css/StyleRule.h: (WebCore::StyleRuleBase::isCounterStyleRule const): Added. * css/StyleRuleType.h: Add StyleRuleType::CounterStyle * css/StyleSheetContents.cpp: (WebCore::traverseRulesInVector): (WebCore::StyleSheetContents::traverseSubresources const): If @counter-style image symbols flag is enabled, do traverse subresources. * css/parser/CSSAtRuleID.cpp: If the @counter-style feature flag is enabled, return newly added CSSAtRuleCounterStyle ID. (WebCore::cssAtRuleID): * css/parser/CSSAtRuleID.h: Add CSSAtRuleCounterStyle ID. * css/parser/CSSParserContext.cpp: (WebCore::operator==): * css/parser/CSSParserContext.h: (WebCore::CSSParserContextHash::hash): Add cssCounterStyleAtRulesEnabled and cssCounterStyleAtRuleImageSymbolsEnabled flags. * css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): Refactor to use new CSSPropertyParserHelpers::isPredefinedCounterStyle method. * css/parser/CSSParserImpl.cpp: (WebCore::computeNewAllowedRules): (WebCore::CSSParserImpl::consumeAtRule): (WebCore::CSSParserImpl::consumeCounterStyleRule): Added. (WebCore::CSSParserImpl::consumeDeclarationList): (WebCore::CSSParserImpl::consumeDeclaration): * css/parser/CSSParserImpl.h: Handle new @counter-style rule. * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseValue): Handle StyleRuleType::CounterStyle. (WebCore::consumeCounterContent): Refactor to use new CSSPropertyParserHelpers::isPredefinedCounterStyle method. (WebCore::CSSPropertyParser::parseCounterStyleDescriptor): Add placeholder for future @counter-style descriptor parsing work. * css/parser/CSSPropertyParser.h: Add parseCounterStyleDescriptor method * css/parser/CSSPropertyParserHelpers.h: * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeCustomIdent): Add new flag that allows consumed custom ident values to be lowercased on-parse. This is necessary for some <counter-style-name> values. (WebCore::CSSPropertyParserHelpers::isPredefinedCounterStyle): Added. (WebCore::CSSPropertyParserHelpers::consumeCounterStyleName): (WebCore::CSSPropertyParserHelpers::consumeCounterStyleNameInPrelude): Parse @counter-style names, both in-prelude names and non-prelude names (e.g. as part of the `extends` descriptor). Source/WTF: * Scripts/Preferences/WebPreferencesExperimental.yaml: Add CSSCounterStyleAtRulesEnabled and CSSCounterStyleAtRuleImageSymbolsEnabled flags. Tools: * DumpRenderTree/TestOptions.cpp: (WTR::TestOptions::defaults): Add `false` defaults for CSSCounterStyleAtRulesEnabled and CSSCounterStyleAtRuleImageSymbolsEnabled flags. LayoutTests: Add tests ensuring @counter-style is not exposed when feature flag is disabled. * webexposed/counter-style-is-not-exposed-expected.txt: Added. * webexposed/counter-style-is-not-exposed.html: Added. Canonical link: https://commits.webkit.org/236643@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-16 19:19:04 +00:00
CounterStyle = 11,
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: Canonical link: https://commits.webkit.org/216882@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251655 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-28 16:02:53 +00:00
Supports = 12,
};
} // namespace WebCore