haikuwebkit/Source/WebCore/css/CSSVariableReferenceValue.h

67 lines
2.5 KiB
C
Raw Permalink Normal View History

[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
// Copyright 2015 The Chromium Authors. All rights reserved.
// Copyright (C) 2016-2020 Apple Inc. All rights reserved.
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "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 THE COPYRIGHT
// OWNER 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
#include "CSSValue.h"
namespace WebCore {
CSS Custom Properties API Should Support syntax="*" and "<length>", and handle cycles properly https://bugs.webkit.org/show_bug.cgi?id=191042 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt: Source/WebCore: Refactor code so that: - All properties applied in StyleResolver::applyMatchedProperties are only applied once. - Custom properties are only resolved once, in StyleResolver, when they are applied to the RenderStyle. They were previously resolved every time they were referenced, and again in RenderStyle. - The font-size property is applied after its variable references, but before custom properties that depend on it. - Cycles are detected at the same time as resolution. - MutableStyleProperties' custom properties cannot be set from Javascript or WebKitLegacy if they do not parse for the property's type. If they contain var(--...) references, however, then they can be set because we cannot check if the references are valid from setProperty. This behaviour matches chrome, but is not documented in the spec. - Custom property values have more explicit resolved/unresolved state. - RenderStyle only ever holds resolved custom properties, and StyleResolver::CascadedProperties only holds unresolved properties. Tests: css-custom-properties-api/crash.html css-custom-properties-api/cycles.html css-custom-properties-api/inline.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::equals const): (WebCore::CSSCustomPropertyValue::customCSSText const): (WebCore::CSSCustomPropertyValue::tokens const): (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): Deleted. (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): Deleted. (WebCore::CSSCustomPropertyValue::setResolvedTypedValue): Deleted. * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): * css/CSSRegisteredCustomProperty.h: * css/CSSVariableData.cpp: (WebCore::CSSVariableData::CSSVariableData): (WebCore::CSSVariableData::consumeAndUpdateTokens): Deleted. (WebCore::CSSVariableData::checkVariablesForCycles const): Deleted. (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): Deleted. (WebCore::CSSVariableData::resolveVariableFallback const): Deleted. (WebCore::CSSVariableData::resolveVariableReference const): Deleted. (WebCore::CSSVariableData::resolveVariableReferences const): Deleted. (WebCore::CSSVariableData::resolveTokenRange const): Deleted. * css/CSSVariableData.h: (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): Deleted. (WebCore::CSSVariableData::needsVariableResolution const): Deleted. (WebCore::CSSVariableData::CSSVariableData): Deleted. * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): Deleted. * css/CSSVariableReferenceValue.h: (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::equals const): (WebCore::CSSVariableReferenceValue::variableDataValue const): Deleted. * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::setProperty): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::setCustomProperty): * css/StyleProperties.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::CascadedProperties::applyDeferredProperties): (WebCore::StyleResolver::CascadedProperties::Property::apply): (WebCore::StyleResolver::applyCascadedCustomProperty): (WebCore::StyleResolver::applyCascadedProperties): * css/StyleResolver.h: * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::CSSPropertyParser): (WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies): (WebCore::CSSPropertyParser::parseValueStart): (WebCore::CSSPropertyParser::parseSingleValue): * css/parser/CSSPropertyParser.h: * css/parser/CSSVariableParser.cpp: (WebCore::CSSVariableParser::parseDeclarationValue): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::setValueForProperty): (WebCore::variableDataForPositivePixelLength): (WebCore::variableDataForPositiveDuration): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): * rendering/style/StyleCustomPropertyData.h: (WebCore::StyleCustomPropertyData::operator== const): (WebCore::StyleCustomPropertyData::setCustomPropertyValue): (WebCore::StyleCustomPropertyData::StyleCustomPropertyData): (): Deleted. LayoutTests: * css-custom-properties-api/crash-expected.txt: Added. * css-custom-properties-api/crash.html: Added. * css-custom-properties-api/cycles-expected.txt: Added. * css-custom-properties-api/cycles.html: Added. * css-custom-properties-api/inline-expected.txt: Added. * css-custom-properties-api/inline.html: Added. Canonical link: https://commits.webkit.org/205971@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-01 20:35:27 +00:00
class CSSParserTokenRange;
class CSSVariableData;
CSS Custom Properties API Should Support syntax="*" and "<length>", and handle cycles properly https://bugs.webkit.org/show_bug.cgi?id=191042 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt: Source/WebCore: Refactor code so that: - All properties applied in StyleResolver::applyMatchedProperties are only applied once. - Custom properties are only resolved once, in StyleResolver, when they are applied to the RenderStyle. They were previously resolved every time they were referenced, and again in RenderStyle. - The font-size property is applied after its variable references, but before custom properties that depend on it. - Cycles are detected at the same time as resolution. - MutableStyleProperties' custom properties cannot be set from Javascript or WebKitLegacy if they do not parse for the property's type. If they contain var(--...) references, however, then they can be set because we cannot check if the references are valid from setProperty. This behaviour matches chrome, but is not documented in the spec. - Custom property values have more explicit resolved/unresolved state. - RenderStyle only ever holds resolved custom properties, and StyleResolver::CascadedProperties only holds unresolved properties. Tests: css-custom-properties-api/crash.html css-custom-properties-api/cycles.html css-custom-properties-api/inline.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::equals const): (WebCore::CSSCustomPropertyValue::customCSSText const): (WebCore::CSSCustomPropertyValue::tokens const): (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): Deleted. (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): Deleted. (WebCore::CSSCustomPropertyValue::setResolvedTypedValue): Deleted. * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): * css/CSSRegisteredCustomProperty.h: * css/CSSVariableData.cpp: (WebCore::CSSVariableData::CSSVariableData): (WebCore::CSSVariableData::consumeAndUpdateTokens): Deleted. (WebCore::CSSVariableData::checkVariablesForCycles const): Deleted. (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): Deleted. (WebCore::CSSVariableData::resolveVariableFallback const): Deleted. (WebCore::CSSVariableData::resolveVariableReference const): Deleted. (WebCore::CSSVariableData::resolveVariableReferences const): Deleted. (WebCore::CSSVariableData::resolveTokenRange const): Deleted. * css/CSSVariableData.h: (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): Deleted. (WebCore::CSSVariableData::needsVariableResolution const): Deleted. (WebCore::CSSVariableData::CSSVariableData): Deleted. * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): Deleted. * css/CSSVariableReferenceValue.h: (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::equals const): (WebCore::CSSVariableReferenceValue::variableDataValue const): Deleted. * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::setProperty): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::setCustomProperty): * css/StyleProperties.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::CascadedProperties::applyDeferredProperties): (WebCore::StyleResolver::CascadedProperties::Property::apply): (WebCore::StyleResolver::applyCascadedCustomProperty): (WebCore::StyleResolver::applyCascadedProperties): * css/StyleResolver.h: * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::CSSPropertyParser): (WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies): (WebCore::CSSPropertyParser::parseValueStart): (WebCore::CSSPropertyParser::parseSingleValue): * css/parser/CSSPropertyParser.h: * css/parser/CSSVariableParser.cpp: (WebCore::CSSVariableParser::parseDeclarationValue): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::setValueForProperty): (WebCore::variableDataForPositivePixelLength): (WebCore::variableDataForPositiveDuration): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): * rendering/style/StyleCustomPropertyData.h: (WebCore::StyleCustomPropertyData::operator== const): (WebCore::StyleCustomPropertyData::setCustomPropertyValue): (WebCore::StyleCustomPropertyData::StyleCustomPropertyData): (): Deleted. LayoutTests: * css-custom-properties-api/crash-expected.txt: Added. * css-custom-properties-api/crash.html: Added. * css-custom-properties-api/cycles-expected.txt: Added. * css-custom-properties-api/cycles.html: Added. * css-custom-properties-api/inline-expected.txt: Added. * css-custom-properties-api/inline.html: Added. Canonical link: https://commits.webkit.org/205971@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-01 20:35:27 +00:00
Move more cascade related code from StyleResolver to PropertyCascade https://bugs.webkit.org/show_bug.cgi?id=203409 Reviewed by Zalan Bujtas. - Move a bunch of StyleResolver member functions to PropertyCascade. - Make ApplyCascadedPropertyState part of the PropertyCascade internal state. - Pass around a reference to the PropertyCascade itself instead of the state object The state contained PropertyCascade member already so this is equivalent but simpler. * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): * css/CSSVariableReferenceValue.h: * css/ElementRuleCollector.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::cascadedPropertiesForRollback): Deleted. (WebCore::StyleResolver::applyCascadedCustomProperty): Deleted. (WebCore::StyleResolver::applyCascadedProperties): Deleted. (WebCore::StyleResolver::applyCascadedPropertiesImpl): Deleted. These become PropertyCascade members. * css/StyleResolver.h: (WebCore::StyleResolver::State::authorRollback const): Deleted. (WebCore::StyleResolver::State::userRollback const): Deleted. (WebCore::StyleResolver::State::setAuthorRollback): Deleted. (WebCore::StyleResolver::State::setUserRollback): Deleted. Rollbacks are now owned by PropertyCascade. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * style/PropertyCascade.cpp: (WebCore::Style::PropertyCascade::PropertyCascade): (WebCore::Style::PropertyCascade::set): (WebCore::Style::PropertyCascade::addNormalMatches): (WebCore::Style::PropertyCascade::addImportantMatches): (WebCore::Style::PropertyCascade::applyDeferredProperties): (WebCore::Style::PropertyCascade::applyProperties): (WebCore::Style::PropertyCascade::applyPropertiesImpl): (WebCore::Style::PropertyCascade::applyCustomProperties): (WebCore::Style::PropertyCascade::applyCustomProperty): (WebCore::Style::PropertyCascade::propertyCascadeForRollback): (WebCore::Style::PropertyCascade::Property::apply): * style/PropertyCascade.h: (WebCore::Style::PropertyCascade::styleResolver): (WebCore::Style::PropertyCascade::hasAppliedProperty const): (WebCore::Style::PropertyCascade::customProperties): Deleted. Canonical link: https://commits.webkit.org/216838@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-25 23:22:51 +00:00
namespace Style {
Move style building state to a class of its own https://bugs.webkit.org/show_bug.cgi?id=203562 Reviewed by Zalan Bujtas. Move most of the state needed for applying properties from StyleResolver::State and PropertyCascade::ApplyState to new Style::BuilderState. Pass BuilderState around in all functions invoked during style building instead of StyleResolver. Unlike StyleResolver, BuilderState is a stack-allocated object that exists during style building only. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::style const): (WebCore::CSSToStyleMap::useSVGZoomRules const): (WebCore::CSSToStyleMap::styleImage): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapAnimationName): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): (WebCore::CSSToStyleMap::rootElementStyle const): Deleted. * css/CSSToStyleMap.h: * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): * css/CSSVariableReferenceValue.h: * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): * css/StyleBuilder.h: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertLength): (WebCore::StyleBuilderConverter::convertLengthOrAuto): (WebCore::StyleBuilderConverter::convertLengthSizing): (WebCore::StyleBuilderConverter::convertLengthMaxSizing): (WebCore::StyleBuilderConverter::convertTabSize): (WebCore::StyleBuilderConverter::convertComputedLength): (WebCore::StyleBuilderConverter::convertLineWidth): (WebCore::StyleBuilderConverter::convertSpacing): (WebCore::StyleBuilderConverter::convertRadius): (WebCore::StyleBuilderConverter::convertPositionComponentX): (WebCore::StyleBuilderConverter::convertPositionComponentY): (WebCore::StyleBuilderConverter::convertPositionComponent): (WebCore::StyleBuilderConverter::convertObjectPosition): (WebCore::StyleBuilderConverter::convertTextDecoration): (WebCore::StyleBuilderConverter::convertNumber): (WebCore::StyleBuilderConverter::convertNumberOrAuto): (WebCore::StyleBuilderConverter::convertWebkitHyphenateLimitLines): (WebCore::StyleBuilderConverter::convertBorderImage): (WebCore::StyleBuilderConverter::convertBorderMask): (WebCore::StyleBuilderConverter::convertStyleImage): (WebCore::StyleBuilderConverter::convertTransform): (WebCore::StyleBuilderConverter::convertColorScheme): (WebCore::StyleBuilderConverter::convertString): (WebCore::StyleBuilderConverter::convertStringOrAuto): (WebCore::StyleBuilderConverter::convertStringOrNone): (WebCore::StyleBuilderConverter::convertTextEmphasisPosition): (WebCore::StyleBuilderConverter::convertTextAlign): (WebCore::StyleBuilderConverter::convertClipPath): (WebCore::StyleBuilderConverter::convertResize): (WebCore::StyleBuilderConverter::convertMarqueeRepetition): (WebCore::StyleBuilderConverter::convertMarqueeSpeed): (WebCore::StyleBuilderConverter::convertQuotes): (WebCore::StyleBuilderConverter::convertTextUnderlinePosition): (WebCore::StyleBuilderConverter::convertTextUnderlineOffset): (WebCore::StyleBuilderConverter::convertTextDecorationThickness): (WebCore::StyleBuilderConverter::convertReflection): (WebCore::StyleBuilderConverter::convertInitialLetter): (WebCore::StyleBuilderConverter::convertTextStrokeWidth): (WebCore::StyleBuilderConverter::convertLineBoxContain): (WebCore::StyleBuilderConverter::convertTextDecorationSkip): (WebCore::StyleBuilderConverter::convertShapeValue): (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::createGridTrackBreadth): (WebCore::StyleBuilderConverter::createGridTrackSize): (WebCore::StyleBuilderConverter::createGridTrackList): (WebCore::StyleBuilderConverter::convertGridTrackSizeList): (WebCore::StyleBuilderConverter::convertGridTrackSize): (WebCore::StyleBuilderConverter::convertGridPosition): (WebCore::StyleBuilderConverter::convertGridAutoFlow): (WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::StyleBuilderConverter::convertWordSpacing): (WebCore::StyleBuilderConverter::convertPerspective): (WebCore::StyleBuilderConverter::convertMarqueeIncrement): (WebCore::StyleBuilderConverter::convertFilterOperations): (WebCore::StyleBuilderConverter::convertFontFeatureSettings): (WebCore::StyleBuilderConverter::convertFontWeight): (WebCore::StyleBuilderConverter::convertFontStretch): (WebCore::StyleBuilderConverter::convertFontVariationSettings): (WebCore::StyleBuilderConverter::convertTouchCallout): (WebCore::StyleBuilderConverter::convertTapHighlightColor): (WebCore::StyleBuilderConverter::convertTouchAction): (WebCore::StyleBuilderConverter::convertOverflowScrolling): (WebCore::StyleBuilderConverter::convertSVGLengthValue): (WebCore::StyleBuilderConverter::convertSVGLengthVector): (WebCore::StyleBuilderConverter::convertStrokeDashArray): (WebCore::StyleBuilderConverter::convertPaintOrder): (WebCore::StyleBuilderConverter::convertOpacity): (WebCore::StyleBuilderConverter::convertSVGURIReference): (WebCore::StyleBuilderConverter::convertSVGColor): (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData): (WebCore::StyleBuilderConverter::convertContentAlignmentData): (WebCore::StyleBuilderConverter::convertGlyphOrientation): (WebCore::StyleBuilderConverter::convertGlyphOrientationOrAuto): (WebCore::StyleBuilderConverter::convertLineHeight): (WebCore::StyleBuilderConverter::convertFontSynthesis): (WebCore::StyleBuilderConverter::convertSpeakAs): (WebCore::StyleBuilderConverter::convertHangingPunctuation): (WebCore::StyleBuilderConverter::convertGapLength): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitMaskImage): (WebCore::StyleBuilderCustom::applyInheritWebkitMaskImage): (WebCore::StyleBuilderCustom::applyInitialFontFeatureSettings): (WebCore::StyleBuilderCustom::applyInheritFontFeatureSettings): (WebCore::StyleBuilderCustom::applyInitialFontVariationSettings): (WebCore::StyleBuilderCustom::applyInheritFontVariationSettings): (WebCore::StyleBuilderCustom::applyValueDirection): (WebCore::StyleBuilderCustom::applyInitialTextAlign): (WebCore::StyleBuilderCustom::applyValueTextAlign): (WebCore::StyleBuilderCustom::resetEffectiveZoom): (WebCore::StyleBuilderCustom::applyInitialZoom): (WebCore::StyleBuilderCustom::applyInheritZoom): (WebCore::StyleBuilderCustom::applyValueZoom): (WebCore::StyleBuilderCustom::applyValueVerticalAlign): (WebCore::StyleBuilderCustom::applyInheritImageResolution): (WebCore::StyleBuilderCustom::applyInitialImageResolution): (WebCore::StyleBuilderCustom::applyValueImageResolution): (WebCore::StyleBuilderCustom::applyInheritSize): (WebCore::StyleBuilderCustom::applyInitialSize): (WebCore::StyleBuilderCustom::applyValueSize): (WebCore::StyleBuilderCustom::applyInheritTextIndent): (WebCore::StyleBuilderCustom::applyInitialTextIndent): (WebCore::StyleBuilderCustom::applyValueTextIndent): (WebCore::ApplyPropertyBorderImageModifier::applyInheritValue): (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue): (WebCore::ApplyPropertyBorderImageModifier::applyValue): (WebCore::ApplyPropertyBorderImageModifier::getValue): (WebCore::ApplyPropertyBorderImageModifier::setValue): (WebCore::StyleBuilderCustom::applyInheritLineHeight): (WebCore::StyleBuilderCustom::applyInitialLineHeight): (WebCore::StyleBuilderCustom::applyValueLineHeight): (WebCore::StyleBuilderCustom::applyInheritOutlineStyle): (WebCore::StyleBuilderCustom::applyInitialOutlineStyle): (WebCore::StyleBuilderCustom::applyValueOutlineStyle): (WebCore::StyleBuilderCustom::applyInitialClip): (WebCore::StyleBuilderCustom::applyInheritClip): (WebCore::StyleBuilderCustom::applyValueClip): (WebCore::StyleBuilderCustom::applyValueWebkitLocale): (WebCore::StyleBuilderCustom::applyValueWritingMode): (WebCore::StyleBuilderCustom::applyValueWebkitTextOrientation): (WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust): (WebCore::StyleBuilderCustom::applyValueWebkitTextZoom): (WebCore::StyleBuilderCustom::applyValueColorScheme): (WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue): (WebCore::StyleBuilderCustom::applyInitialTextShadow): (WebCore::StyleBuilderCustom::applyInheritTextShadow): (WebCore::StyleBuilderCustom::applyValueTextShadow): (WebCore::StyleBuilderCustom::applyInitialBoxShadow): (WebCore::StyleBuilderCustom::applyInheritBoxShadow): (WebCore::StyleBuilderCustom::applyValueBoxShadow): (WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyInitialFontFamily): (WebCore::StyleBuilderCustom::applyInheritFontFamily): (WebCore::StyleBuilderCustom::applyValueFontFamily): (WebCore::StyleBuilderCustom::isValidDisplayValue): (WebCore::StyleBuilderCustom::applyInheritDisplay): (WebCore::StyleBuilderCustom::applyValueDisplay): (WebCore::StyleBuilderCustom::applyValueBaselineShift): (WebCore::StyleBuilderCustom::applyInitialWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyInheritWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyValueWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyValueWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyInheritCounter): (WebCore::StyleBuilderCustom::applyValueCounter): (WebCore::StyleBuilderCustom::applyInitialCounterIncrement): (WebCore::StyleBuilderCustom::applyInheritCounterIncrement): (WebCore::StyleBuilderCustom::applyValueCounterIncrement): (WebCore::StyleBuilderCustom::applyInitialCounterReset): (WebCore::StyleBuilderCustom::applyInheritCounterReset): (WebCore::StyleBuilderCustom::applyValueCounterReset): (WebCore::StyleBuilderCustom::applyInitialCursor): (WebCore::StyleBuilderCustom::applyInheritCursor): (WebCore::StyleBuilderCustom::applyValueCursor): (WebCore::StyleBuilderCustom::applyInitialFill): (WebCore::StyleBuilderCustom::applyInheritFill): (WebCore::StyleBuilderCustom::applyValueFill): (WebCore::StyleBuilderCustom::applyInitialStroke): (WebCore::StyleBuilderCustom::applyInheritStroke): (WebCore::StyleBuilderCustom::applyValueStroke): (WebCore::StyleBuilderCustom::applyInitialContent): (WebCore::StyleBuilderCustom::applyInheritContent): (WebCore::StyleBuilderCustom::applyValueContent): (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontSize): (WebCore::StyleBuilderCustom::applyInheritFontSize): (WebCore::StyleBuilderCustom::determineRubyTextSizeMultiplier): (WebCore::StyleBuilderCustom::applyInitialFontStyle): (WebCore::StyleBuilderCustom::applyInheritFontStyle): (WebCore::StyleBuilderCustom::applyValueFontStyle): (WebCore::StyleBuilderCustom::applyValueFontSize): (WebCore::StyleBuilderCustom::applyInitialGridTemplateAreas): (WebCore::StyleBuilderCustom::applyInheritGridTemplateAreas): (WebCore::StyleBuilderCustom::applyValueGridTemplateAreas): (WebCore::StyleBuilderCustom::applyInitialGridTemplateColumns): (WebCore::StyleBuilderCustom::applyInheritGridTemplateColumns): (WebCore::StyleBuilderCustom::applyValueGridTemplateColumns): (WebCore::StyleBuilderCustom::applyInitialGridTemplateRows): (WebCore::StyleBuilderCustom::applyInheritGridTemplateRows): (WebCore::StyleBuilderCustom::applyValueGridTemplateRows): (WebCore::StyleBuilderCustom::applyValueAlt): (WebCore::StyleBuilderCustom::applyValueWillChange): (WebCore::StyleBuilderCustom::applyValueStrokeWidth): (WebCore::StyleBuilderCustom::applyValueStrokeColor): (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyInheritCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::State::State): (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::updateFont): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::initializeFontStyle): * css/StyleResolver.h: (WebCore::StyleResolver::inspectorCSSOMWrappers): (WebCore::StyleResolver::State::setApplyPropertyToRegularStyle): Deleted. (WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle): Deleted. (WebCore::StyleResolver::State::applyPropertyToRegularStyle const): Deleted. (WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle const): Deleted. (WebCore::StyleResolver::State::setFontDirty): Deleted. (WebCore::StyleResolver::State::fontDirty const): Deleted. (WebCore::StyleResolver::State::fontDescription): Deleted. (WebCore::StyleResolver::State::parentFontDescription): Deleted. (WebCore::StyleResolver::State::setFontDescription): Deleted. (WebCore::StyleResolver::State::setZoom): Deleted. (WebCore::StyleResolver::State::setEffectiveZoom): Deleted. (WebCore::StyleResolver::State::setWritingMode): Deleted. (WebCore::StyleResolver::State::setTextOrientation): Deleted. (WebCore::StyleResolver::State::cascadeLevel const): Deleted. (WebCore::StyleResolver::State::setCascadeLevel): Deleted. (WebCore::StyleResolver::State::styleScopeOrdinal const): Deleted. (WebCore::StyleResolver::State::setStyleScopeOrdinal): Deleted. (WebCore::StyleResolver::applyPropertyToRegularStyle const): Deleted. (WebCore::StyleResolver::applyPropertyToVisitedLinkStyle const): Deleted. (WebCore::StyleResolver::styleMap): Deleted. (WebCore::StyleResolver::fontDescription): Deleted. (WebCore::StyleResolver::parentFontDescription): Deleted. (WebCore::StyleResolver::setFontDescription): Deleted. (WebCore::StyleResolver::setZoom): Deleted. (WebCore::StyleResolver::setEffectiveZoom): Deleted. (WebCore::StyleResolver::setWritingMode): Deleted. (WebCore::StyleResolver::setTextOrientation): Deleted. * css/makeprop.pl: (getAutoGetter): (getAutoSetter): (getVisitedLinkSetter): (colorFromPrimitiveValue): (generateColorValueSetter): (handleCurrentColorValue): (generateAnimationPropertyInitialValueSetter): (generateAnimationPropertyInheritValueSetter): (generateAnimationPropertyValueSetter): (generateFillLayerPropertyInitialValueSetter): (generateFillLayerPropertyInheritValueSetter): (generateFillLayerPropertyValueSetter): (generateSetValueStatement): (generateInitialValueSetter): (generateInheritValueSetter): (generateValueSetter): * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): * css/parser/CSSPropertyParser.h: * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::setFont): * platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::builderState): (WebCore::GraphicsContext::applyState): Deleted. * platform/graphics/GraphicsContext.h: * platform/graphics/displaylists/DisplayListItems.h: * style/CascadeLevel.h: Copied from Source/WebCore/css/StyleBuilder.h. (WebCore::Style::allCascadeLevels): * style/PropertyCascade.cpp: (WebCore::Style::PropertyCascade::PropertyCascade): (WebCore::Style::PropertyCascade::applyPropertiesImpl): (WebCore::Style::PropertyCascade::applyCustomProperty): (WebCore::Style::PropertyCascade::applyProperty): (WebCore::Style::PropertyCascade::resolveValue): (WebCore::Style::PropertyCascade::resolvedVariableValue): (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode): * style/PropertyCascade.h: (WebCore::Style::PropertyCascade::builderState): (WebCore::Style::allCascadeLevels): Deleted. (WebCore::Style::PropertyCascade::styleResolver): Deleted. * style/StyleBuilderState.cpp: Added. (WebCore::Style::BuilderState::BuilderState): (WebCore::Style::BuilderState::useSVGZoomRules const): (WebCore::Style::BuilderState::useSVGZoomRulesForLength const): (WebCore::Style::BuilderState::createStyleImage): (WebCore::Style::BuilderState::createFilterOperations): (WebCore::Style::BuilderState::colorFromPrimitiveValue const): (WebCore::Style::BuilderState::setFontSize): * style/StyleBuilderState.h: Added. (WebCore::Style::BuilderState::cascade): (WebCore::Style::BuilderState::styleResolver): (WebCore::Style::BuilderState::style): (WebCore::Style::BuilderState::parentStyle const): (WebCore::Style::BuilderState::rootElementStyle const): (WebCore::Style::BuilderState::document const): (WebCore::Style::BuilderState::element const): (WebCore::Style::BuilderState::setFontDescription): (WebCore::Style::BuilderState::setZoom): (WebCore::Style::BuilderState::setEffectiveZoom): (WebCore::Style::BuilderState::setWritingMode): (WebCore::Style::BuilderState::setTextOrientation): (WebCore::Style::BuilderState::fontDirty const): (WebCore::Style::BuilderState::setFontDirty): (WebCore::Style::BuilderState::clearFontDirty): (WebCore::Style::BuilderState::fontDescription): (WebCore::Style::BuilderState::parentFontDescription): (WebCore::Style::BuilderState::applyPropertyToRegularStyle const): (WebCore::Style::BuilderState::applyPropertyToVisitedLinkStyle const): (WebCore::Style::BuilderState::styleScopeOrdinal const): (WebCore::Style::BuilderState::cssToLengthConversionData const): (WebCore::Style::BuilderState::styleMap): Canonical link: https://commits.webkit.org/216994@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-30 20:13:30 +00:00
class BuilderState;
Move more cascade related code from StyleResolver to PropertyCascade https://bugs.webkit.org/show_bug.cgi?id=203409 Reviewed by Zalan Bujtas. - Move a bunch of StyleResolver member functions to PropertyCascade. - Make ApplyCascadedPropertyState part of the PropertyCascade internal state. - Pass around a reference to the PropertyCascade itself instead of the state object The state contained PropertyCascade member already so this is equivalent but simpler. * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): * css/CSSVariableReferenceValue.h: * css/ElementRuleCollector.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::cascadedPropertiesForRollback): Deleted. (WebCore::StyleResolver::applyCascadedCustomProperty): Deleted. (WebCore::StyleResolver::applyCascadedProperties): Deleted. (WebCore::StyleResolver::applyCascadedPropertiesImpl): Deleted. These become PropertyCascade members. * css/StyleResolver.h: (WebCore::StyleResolver::State::authorRollback const): Deleted. (WebCore::StyleResolver::State::userRollback const): Deleted. (WebCore::StyleResolver::State::setAuthorRollback): Deleted. (WebCore::StyleResolver::State::setUserRollback): Deleted. Rollbacks are now owned by PropertyCascade. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * style/PropertyCascade.cpp: (WebCore::Style::PropertyCascade::PropertyCascade): (WebCore::Style::PropertyCascade::set): (WebCore::Style::PropertyCascade::addNormalMatches): (WebCore::Style::PropertyCascade::addImportantMatches): (WebCore::Style::PropertyCascade::applyDeferredProperties): (WebCore::Style::PropertyCascade::applyProperties): (WebCore::Style::PropertyCascade::applyPropertiesImpl): (WebCore::Style::PropertyCascade::applyCustomProperties): (WebCore::Style::PropertyCascade::applyCustomProperty): (WebCore::Style::PropertyCascade::propertyCascadeForRollback): (WebCore::Style::PropertyCascade::Property::apply): * style/PropertyCascade.h: (WebCore::Style::PropertyCascade::styleResolver): (WebCore::Style::PropertyCascade::hasAppliedProperty const): (WebCore::Style::PropertyCascade::customProperties): Deleted. Canonical link: https://commits.webkit.org/216838@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-25 23:22:51 +00:00
}
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
class CSSVariableReferenceValue : public CSSValue {
public:
static Ref<CSSVariableReferenceValue> create(const CSSParserTokenRange&);
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
bool equals(const CSSVariableReferenceValue&) const;
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
String customCSSText() const;
Move style building state to a class of its own https://bugs.webkit.org/show_bug.cgi?id=203562 Reviewed by Zalan Bujtas. Move most of the state needed for applying properties from StyleResolver::State and PropertyCascade::ApplyState to new Style::BuilderState. Pass BuilderState around in all functions invoked during style building instead of StyleResolver. Unlike StyleResolver, BuilderState is a stack-allocated object that exists during style building only. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSToStyleMap.cpp: (WebCore::CSSToStyleMap::CSSToStyleMap): (WebCore::CSSToStyleMap::style const): (WebCore::CSSToStyleMap::useSVGZoomRules const): (WebCore::CSSToStyleMap::styleImage): (WebCore::CSSToStyleMap::mapFillSize): (WebCore::CSSToStyleMap::mapFillXPosition): (WebCore::CSSToStyleMap::mapFillYPosition): (WebCore::CSSToStyleMap::mapAnimationName): (WebCore::CSSToStyleMap::mapNinePieceImageQuad): (WebCore::CSSToStyleMap::rootElementStyle const): Deleted. * css/CSSToStyleMap.h: * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): * css/CSSVariableReferenceValue.h: * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): * css/StyleBuilder.h: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertLength): (WebCore::StyleBuilderConverter::convertLengthOrAuto): (WebCore::StyleBuilderConverter::convertLengthSizing): (WebCore::StyleBuilderConverter::convertLengthMaxSizing): (WebCore::StyleBuilderConverter::convertTabSize): (WebCore::StyleBuilderConverter::convertComputedLength): (WebCore::StyleBuilderConverter::convertLineWidth): (WebCore::StyleBuilderConverter::convertSpacing): (WebCore::StyleBuilderConverter::convertRadius): (WebCore::StyleBuilderConverter::convertPositionComponentX): (WebCore::StyleBuilderConverter::convertPositionComponentY): (WebCore::StyleBuilderConverter::convertPositionComponent): (WebCore::StyleBuilderConverter::convertObjectPosition): (WebCore::StyleBuilderConverter::convertTextDecoration): (WebCore::StyleBuilderConverter::convertNumber): (WebCore::StyleBuilderConverter::convertNumberOrAuto): (WebCore::StyleBuilderConverter::convertWebkitHyphenateLimitLines): (WebCore::StyleBuilderConverter::convertBorderImage): (WebCore::StyleBuilderConverter::convertBorderMask): (WebCore::StyleBuilderConverter::convertStyleImage): (WebCore::StyleBuilderConverter::convertTransform): (WebCore::StyleBuilderConverter::convertColorScheme): (WebCore::StyleBuilderConverter::convertString): (WebCore::StyleBuilderConverter::convertStringOrAuto): (WebCore::StyleBuilderConverter::convertStringOrNone): (WebCore::StyleBuilderConverter::convertTextEmphasisPosition): (WebCore::StyleBuilderConverter::convertTextAlign): (WebCore::StyleBuilderConverter::convertClipPath): (WebCore::StyleBuilderConverter::convertResize): (WebCore::StyleBuilderConverter::convertMarqueeRepetition): (WebCore::StyleBuilderConverter::convertMarqueeSpeed): (WebCore::StyleBuilderConverter::convertQuotes): (WebCore::StyleBuilderConverter::convertTextUnderlinePosition): (WebCore::StyleBuilderConverter::convertTextUnderlineOffset): (WebCore::StyleBuilderConverter::convertTextDecorationThickness): (WebCore::StyleBuilderConverter::convertReflection): (WebCore::StyleBuilderConverter::convertInitialLetter): (WebCore::StyleBuilderConverter::convertTextStrokeWidth): (WebCore::StyleBuilderConverter::convertLineBoxContain): (WebCore::StyleBuilderConverter::convertTextDecorationSkip): (WebCore::StyleBuilderConverter::convertShapeValue): (WebCore::StyleBuilderConverter::convertScrollSnapType): (WebCore::StyleBuilderConverter::convertScrollSnapAlign): (WebCore::StyleBuilderConverter::createGridTrackBreadth): (WebCore::StyleBuilderConverter::createGridTrackSize): (WebCore::StyleBuilderConverter::createGridTrackList): (WebCore::StyleBuilderConverter::convertGridTrackSizeList): (WebCore::StyleBuilderConverter::convertGridTrackSize): (WebCore::StyleBuilderConverter::convertGridPosition): (WebCore::StyleBuilderConverter::convertGridAutoFlow): (WebCore::StyleBuilderConverter::csstoLengthConversionDataWithTextZoomFactor): (WebCore::StyleBuilderConverter::convertWordSpacing): (WebCore::StyleBuilderConverter::convertPerspective): (WebCore::StyleBuilderConverter::convertMarqueeIncrement): (WebCore::StyleBuilderConverter::convertFilterOperations): (WebCore::StyleBuilderConverter::convertFontFeatureSettings): (WebCore::StyleBuilderConverter::convertFontWeight): (WebCore::StyleBuilderConverter::convertFontStretch): (WebCore::StyleBuilderConverter::convertFontVariationSettings): (WebCore::StyleBuilderConverter::convertTouchCallout): (WebCore::StyleBuilderConverter::convertTapHighlightColor): (WebCore::StyleBuilderConverter::convertTouchAction): (WebCore::StyleBuilderConverter::convertOverflowScrolling): (WebCore::StyleBuilderConverter::convertSVGLengthValue): (WebCore::StyleBuilderConverter::convertSVGLengthVector): (WebCore::StyleBuilderConverter::convertStrokeDashArray): (WebCore::StyleBuilderConverter::convertPaintOrder): (WebCore::StyleBuilderConverter::convertOpacity): (WebCore::StyleBuilderConverter::convertSVGURIReference): (WebCore::StyleBuilderConverter::convertSVGColor): (WebCore::StyleBuilderConverter::convertSelfOrDefaultAlignmentData): (WebCore::StyleBuilderConverter::convertContentAlignmentData): (WebCore::StyleBuilderConverter::convertGlyphOrientation): (WebCore::StyleBuilderConverter::convertGlyphOrientationOrAuto): (WebCore::StyleBuilderConverter::convertLineHeight): (WebCore::StyleBuilderConverter::convertFontSynthesis): (WebCore::StyleBuilderConverter::convertSpeakAs): (WebCore::StyleBuilderConverter::convertHangingPunctuation): (WebCore::StyleBuilderConverter::convertGapLength): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialWebkitMaskImage): (WebCore::StyleBuilderCustom::applyInheritWebkitMaskImage): (WebCore::StyleBuilderCustom::applyInitialFontFeatureSettings): (WebCore::StyleBuilderCustom::applyInheritFontFeatureSettings): (WebCore::StyleBuilderCustom::applyInitialFontVariationSettings): (WebCore::StyleBuilderCustom::applyInheritFontVariationSettings): (WebCore::StyleBuilderCustom::applyValueDirection): (WebCore::StyleBuilderCustom::applyInitialTextAlign): (WebCore::StyleBuilderCustom::applyValueTextAlign): (WebCore::StyleBuilderCustom::resetEffectiveZoom): (WebCore::StyleBuilderCustom::applyInitialZoom): (WebCore::StyleBuilderCustom::applyInheritZoom): (WebCore::StyleBuilderCustom::applyValueZoom): (WebCore::StyleBuilderCustom::applyValueVerticalAlign): (WebCore::StyleBuilderCustom::applyInheritImageResolution): (WebCore::StyleBuilderCustom::applyInitialImageResolution): (WebCore::StyleBuilderCustom::applyValueImageResolution): (WebCore::StyleBuilderCustom::applyInheritSize): (WebCore::StyleBuilderCustom::applyInitialSize): (WebCore::StyleBuilderCustom::applyValueSize): (WebCore::StyleBuilderCustom::applyInheritTextIndent): (WebCore::StyleBuilderCustom::applyInitialTextIndent): (WebCore::StyleBuilderCustom::applyValueTextIndent): (WebCore::ApplyPropertyBorderImageModifier::applyInheritValue): (WebCore::ApplyPropertyBorderImageModifier::applyInitialValue): (WebCore::ApplyPropertyBorderImageModifier::applyValue): (WebCore::ApplyPropertyBorderImageModifier::getValue): (WebCore::ApplyPropertyBorderImageModifier::setValue): (WebCore::StyleBuilderCustom::applyInheritLineHeight): (WebCore::StyleBuilderCustom::applyInitialLineHeight): (WebCore::StyleBuilderCustom::applyValueLineHeight): (WebCore::StyleBuilderCustom::applyInheritOutlineStyle): (WebCore::StyleBuilderCustom::applyInitialOutlineStyle): (WebCore::StyleBuilderCustom::applyValueOutlineStyle): (WebCore::StyleBuilderCustom::applyInitialClip): (WebCore::StyleBuilderCustom::applyInheritClip): (WebCore::StyleBuilderCustom::applyValueClip): (WebCore::StyleBuilderCustom::applyValueWebkitLocale): (WebCore::StyleBuilderCustom::applyValueWritingMode): (WebCore::StyleBuilderCustom::applyValueWebkitTextOrientation): (WebCore::StyleBuilderCustom::applyValueWebkitTextSizeAdjust): (WebCore::StyleBuilderCustom::applyValueWebkitTextZoom): (WebCore::StyleBuilderCustom::applyValueColorScheme): (WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue): (WebCore::StyleBuilderCustom::applyInitialTextShadow): (WebCore::StyleBuilderCustom::applyInheritTextShadow): (WebCore::StyleBuilderCustom::applyValueTextShadow): (WebCore::StyleBuilderCustom::applyInitialBoxShadow): (WebCore::StyleBuilderCustom::applyInheritBoxShadow): (WebCore::StyleBuilderCustom::applyValueBoxShadow): (WebCore::StyleBuilderCustom::applyInitialWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyInheritWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyValueWebkitBoxShadow): (WebCore::StyleBuilderCustom::applyInitialFontFamily): (WebCore::StyleBuilderCustom::applyInheritFontFamily): (WebCore::StyleBuilderCustom::applyValueFontFamily): (WebCore::StyleBuilderCustom::isValidDisplayValue): (WebCore::StyleBuilderCustom::applyInheritDisplay): (WebCore::StyleBuilderCustom::applyValueDisplay): (WebCore::StyleBuilderCustom::applyValueBaselineShift): (WebCore::StyleBuilderCustom::applyInitialWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyInheritWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyValueWebkitAspectRatio): (WebCore::StyleBuilderCustom::applyInitialWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyInheritWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyValueWebkitTextEmphasisStyle): (WebCore::StyleBuilderCustom::applyInheritCounter): (WebCore::StyleBuilderCustom::applyValueCounter): (WebCore::StyleBuilderCustom::applyInitialCounterIncrement): (WebCore::StyleBuilderCustom::applyInheritCounterIncrement): (WebCore::StyleBuilderCustom::applyValueCounterIncrement): (WebCore::StyleBuilderCustom::applyInitialCounterReset): (WebCore::StyleBuilderCustom::applyInheritCounterReset): (WebCore::StyleBuilderCustom::applyValueCounterReset): (WebCore::StyleBuilderCustom::applyInitialCursor): (WebCore::StyleBuilderCustom::applyInheritCursor): (WebCore::StyleBuilderCustom::applyValueCursor): (WebCore::StyleBuilderCustom::applyInitialFill): (WebCore::StyleBuilderCustom::applyInheritFill): (WebCore::StyleBuilderCustom::applyValueFill): (WebCore::StyleBuilderCustom::applyInitialStroke): (WebCore::StyleBuilderCustom::applyInheritStroke): (WebCore::StyleBuilderCustom::applyValueStroke): (WebCore::StyleBuilderCustom::applyInitialContent): (WebCore::StyleBuilderCustom::applyInheritContent): (WebCore::StyleBuilderCustom::applyValueContent): (WebCore::StyleBuilderCustom::applyInheritFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInitialFontVariantLigatures): (WebCore::StyleBuilderCustom::applyValueFontVariantLigatures): (WebCore::StyleBuilderCustom::applyInheritFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInitialFontVariantNumeric): (WebCore::StyleBuilderCustom::applyValueFontVariantNumeric): (WebCore::StyleBuilderCustom::applyInheritFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyValueFontVariantEastAsian): (WebCore::StyleBuilderCustom::applyInitialFontSize): (WebCore::StyleBuilderCustom::applyInheritFontSize): (WebCore::StyleBuilderCustom::determineRubyTextSizeMultiplier): (WebCore::StyleBuilderCustom::applyInitialFontStyle): (WebCore::StyleBuilderCustom::applyInheritFontStyle): (WebCore::StyleBuilderCustom::applyValueFontStyle): (WebCore::StyleBuilderCustom::applyValueFontSize): (WebCore::StyleBuilderCustom::applyInitialGridTemplateAreas): (WebCore::StyleBuilderCustom::applyInheritGridTemplateAreas): (WebCore::StyleBuilderCustom::applyValueGridTemplateAreas): (WebCore::StyleBuilderCustom::applyInitialGridTemplateColumns): (WebCore::StyleBuilderCustom::applyInheritGridTemplateColumns): (WebCore::StyleBuilderCustom::applyValueGridTemplateColumns): (WebCore::StyleBuilderCustom::applyInitialGridTemplateRows): (WebCore::StyleBuilderCustom::applyInheritGridTemplateRows): (WebCore::StyleBuilderCustom::applyValueGridTemplateRows): (WebCore::StyleBuilderCustom::applyValueAlt): (WebCore::StyleBuilderCustom::applyValueWillChange): (WebCore::StyleBuilderCustom::applyValueStrokeWidth): (WebCore::StyleBuilderCustom::applyValueStrokeColor): (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyInheritCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::StyleResolver): (WebCore::StyleResolver::State::State): (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::updateFont): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::initializeFontStyle): * css/StyleResolver.h: (WebCore::StyleResolver::inspectorCSSOMWrappers): (WebCore::StyleResolver::State::setApplyPropertyToRegularStyle): Deleted. (WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle): Deleted. (WebCore::StyleResolver::State::applyPropertyToRegularStyle const): Deleted. (WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle const): Deleted. (WebCore::StyleResolver::State::setFontDirty): Deleted. (WebCore::StyleResolver::State::fontDirty const): Deleted. (WebCore::StyleResolver::State::fontDescription): Deleted. (WebCore::StyleResolver::State::parentFontDescription): Deleted. (WebCore::StyleResolver::State::setFontDescription): Deleted. (WebCore::StyleResolver::State::setZoom): Deleted. (WebCore::StyleResolver::State::setEffectiveZoom): Deleted. (WebCore::StyleResolver::State::setWritingMode): Deleted. (WebCore::StyleResolver::State::setTextOrientation): Deleted. (WebCore::StyleResolver::State::cascadeLevel const): Deleted. (WebCore::StyleResolver::State::setCascadeLevel): Deleted. (WebCore::StyleResolver::State::styleScopeOrdinal const): Deleted. (WebCore::StyleResolver::State::setStyleScopeOrdinal): Deleted. (WebCore::StyleResolver::applyPropertyToRegularStyle const): Deleted. (WebCore::StyleResolver::applyPropertyToVisitedLinkStyle const): Deleted. (WebCore::StyleResolver::styleMap): Deleted. (WebCore::StyleResolver::fontDescription): Deleted. (WebCore::StyleResolver::parentFontDescription): Deleted. (WebCore::StyleResolver::setFontDescription): Deleted. (WebCore::StyleResolver::setZoom): Deleted. (WebCore::StyleResolver::setEffectiveZoom): Deleted. (WebCore::StyleResolver::setWritingMode): Deleted. (WebCore::StyleResolver::setTextOrientation): Deleted. * css/makeprop.pl: (getAutoGetter): (getAutoSetter): (getVisitedLinkSetter): (colorFromPrimitiveValue): (generateColorValueSetter): (handleCurrentColorValue): (generateAnimationPropertyInitialValueSetter): (generateAnimationPropertyInheritValueSetter): (generateAnimationPropertyValueSetter): (generateFillLayerPropertyInitialValueSetter): (generateFillLayerPropertyInheritValueSetter): (generateFillLayerPropertyValueSetter): (generateSetValueStatement): (generateInitialValueSetter): (generateInheritValueSetter): (generateValueSetter): * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): * css/parser/CSSPropertyParser.h: * html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::setFont): * platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::builderState): (WebCore::GraphicsContext::applyState): Deleted. * platform/graphics/GraphicsContext.h: * platform/graphics/displaylists/DisplayListItems.h: * style/CascadeLevel.h: Copied from Source/WebCore/css/StyleBuilder.h. (WebCore::Style::allCascadeLevels): * style/PropertyCascade.cpp: (WebCore::Style::PropertyCascade::PropertyCascade): (WebCore::Style::PropertyCascade::applyPropertiesImpl): (WebCore::Style::PropertyCascade::applyCustomProperty): (WebCore::Style::PropertyCascade::applyProperty): (WebCore::Style::PropertyCascade::resolveValue): (WebCore::Style::PropertyCascade::resolvedVariableValue): (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode): * style/PropertyCascade.h: (WebCore::Style::PropertyCascade::builderState): (WebCore::Style::allCascadeLevels): Deleted. (WebCore::Style::PropertyCascade::styleResolver): Deleted. * style/StyleBuilderState.cpp: Added. (WebCore::Style::BuilderState::BuilderState): (WebCore::Style::BuilderState::useSVGZoomRules const): (WebCore::Style::BuilderState::useSVGZoomRulesForLength const): (WebCore::Style::BuilderState::createStyleImage): (WebCore::Style::BuilderState::createFilterOperations): (WebCore::Style::BuilderState::colorFromPrimitiveValue const): (WebCore::Style::BuilderState::setFontSize): * style/StyleBuilderState.h: Added. (WebCore::Style::BuilderState::cascade): (WebCore::Style::BuilderState::styleResolver): (WebCore::Style::BuilderState::style): (WebCore::Style::BuilderState::parentStyle const): (WebCore::Style::BuilderState::rootElementStyle const): (WebCore::Style::BuilderState::document const): (WebCore::Style::BuilderState::element const): (WebCore::Style::BuilderState::setFontDescription): (WebCore::Style::BuilderState::setZoom): (WebCore::Style::BuilderState::setEffectiveZoom): (WebCore::Style::BuilderState::setWritingMode): (WebCore::Style::BuilderState::setTextOrientation): (WebCore::Style::BuilderState::fontDirty const): (WebCore::Style::BuilderState::setFontDirty): (WebCore::Style::BuilderState::clearFontDirty): (WebCore::Style::BuilderState::fontDescription): (WebCore::Style::BuilderState::parentFontDescription): (WebCore::Style::BuilderState::applyPropertyToRegularStyle const): (WebCore::Style::BuilderState::applyPropertyToVisitedLinkStyle const): (WebCore::Style::BuilderState::styleScopeOrdinal const): (WebCore::Style::BuilderState::cssToLengthConversionData const): (WebCore::Style::BuilderState::styleMap): Canonical link: https://commits.webkit.org/216994@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-30 20:13:30 +00:00
RefPtr<CSSVariableData> resolveVariableReferences(Style::BuilderState&) const;
[CSS Parser] Implement CSS variables https://bugs.webkit.org/show_bug.cgi?id=164075 Reviewed by Dean Jackson. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: Add CSSCustomPropertyValue.cpp to the project. * css/CSSCustomPropertyValue.cpp: Added. (WebCore::CSSCustomPropertyValue::checkVariablesForCycles): (WebCore::CSSCustomPropertyValue::resolveVariableReferences): * css/CSSCustomPropertyValue.h: These functions abstract the old and new implementations of CSS variables so that the callers don't have to worry about it. * css/CSSValue.cpp: (WebCore::CSSValue::equals): Make sure CSSVariableReferenceValue and CSSPendingSubstitutionValue have equals implemented. (WebCore::CSSValue::isInvalidCustomPropertyValue): Deleted. This code was dead and never called. * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyValue): (WebCore::CSSValue::hasVariableReferences): Add a helper function for asking if a CSSValue has variable references. This abstracts the old and new implementations so that callers can ask if the value has variables without caring which implementation is being used. * css/CSSValueList.cpp: (WebCore::CSSValueList::checkVariablesForCycles): * css/CSSValueList.h: In order to abstract the old and new variables implementations, custom properties now store CSSCustomPropertyValue as their values instead of raw values. The old implementation needs to be patched to deal with this wrapper being present now. * css/CSSVariableData.cpp: (WebCore::CSSVariableData::checkVariablesForCycles): (WebCore::CSSVariableData::checkVariablesForCyclesWithRange): (WebCore::CSSVariableData::resolveVariableFallback): (WebCore::CSSVariableData::resolveVariableReference): (WebCore::CSSVariableData::resolveVariableReferences): (WebCore::CSSVariableData::resolveTokenRange): * css/CSSVariableData.h: Implementation of cycle checking and variable resolution. The logic of this implementation is the same as the old. It walks CSSParserTokens instead of the old CSSParser structures. * css/CSSVariableReferenceValue.cpp: (WebCore::CSSVariableReferenceValue::customCSSText): Add support for serialization caching, just like the old implementation had in CSSVariableDependentValue. (WebCore::CSSVariableReferenceValue::checkVariablesForCycles): * css/CSSVariableReferenceValue.h: Add cycle checking and variable resolution helper functions. * css/CSSVariableValue.cpp: (WebCore::CSSVariableValue::buildParserValueListSubstitutingVariables): Patched to account for the change in storage of custom properties to have custom property value wrappers. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::borderSpacingValue): (WebCore::StyleProperties::getLayeredShorthandValue): (WebCore::StyleProperties::getShorthandValue): (WebCore::StyleProperties::getCommonValue): (WebCore::StyleProperties::getPropertyCSSValue): (WebCore::StyleProperties::asText): Clean up the resolution of pending substitution values. Instead of hacking it into every possible StyleShorthandProperty crawling function, obtain the shorthand for the property up front, access the first longhand, and if we see a pending substitution value, perform the substitution. * css/StyleResolver.cpp: (WebCore::StyleResolver::MatchResult::addMatchedProperties): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue): * css/StyleResolver.h: Add support for the new implementation in all the same places as the old. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseInlineStyleDeclaration): (WebCore::CSSParser::parseValueWithVariableReferences): (WebCore::CSSParser::parseVariableDependentValue): Deleted. * css/parser/CSSParser.h: Rename parseVariableDependentValue to parseValueWithVariableReferences, since it is operating on three distinct value types now. Turn on new parser support for parseInlineStyleDeclaration. * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::parseVariableValue): Deleted. (WebCore::CSSParserImpl::parseCustomPropertySet): Deleted. * css/parser/CSSParserImpl.h: Remove parser functions that aren't relevant to our implementation of CSS variables. * css/parser/CSSVariableParser.cpp: (WebCore::classifyVariableRange): Add support for the CSS4 'revert' keyword to the new variable parser. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Modified to store CSSCustomPropertyValues as the values always now and to use the method abstractions on CSSCustomPropertyValue to resolve cycles and perform substitutions. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setCustomPropertyValue): (WebCore::RenderStyle::getCustomPropertyValue): * rendering/style/StyleCustomPropertyData.h: (WebCore::StyleCustomPropertyData::operator==): (WebCore::StyleCustomPropertyData::setCustomPropertyValue): (WebCore::StyleCustomPropertyData::getCustomPropertyValue): Tighten up the map to store CSSCustomPropertyValue instead of just CSSValue. Canonical link: https://commits.webkit.org/181795@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208006 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-27 22:05:01 +00:00
// The maximum number of tokens that may be produced by a var()
// reference or var() fallback value.
// https://drafts.csswg.org/css-variables/#long-variables
static constexpr size_t maxSubstitutionTokens = 65536;
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
private:
explicit CSSVariableReferenceValue(Ref<CSSVariableData>&&);
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
CSS Custom Properties API Should Support syntax="*" and "<length>", and handle cycles properly https://bugs.webkit.org/show_bug.cgi?id=191042 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt: * web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt: Source/WebCore: Refactor code so that: - All properties applied in StyleResolver::applyMatchedProperties are only applied once. - Custom properties are only resolved once, in StyleResolver, when they are applied to the RenderStyle. They were previously resolved every time they were referenced, and again in RenderStyle. - The font-size property is applied after its variable references, but before custom properties that depend on it. - Cycles are detected at the same time as resolution. - MutableStyleProperties' custom properties cannot be set from Javascript or WebKitLegacy if they do not parse for the property's type. If they contain var(--...) references, however, then they can be set because we cannot check if the references are valid from setProperty. This behaviour matches chrome, but is not documented in the spec. - Custom property values have more explicit resolved/unresolved state. - RenderStyle only ever holds resolved custom properties, and StyleResolver::CascadedProperties only holds unresolved properties. Tests: css-custom-properties-api/crash.html css-custom-properties-api/cycles.html css-custom-properties-api/inline.html * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::equals const): (WebCore::CSSCustomPropertyValue::customCSSText const): (WebCore::CSSCustomPropertyValue::tokens const): (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): Deleted. (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): Deleted. (WebCore::CSSCustomPropertyValue::setResolvedTypedValue): Deleted. * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): * css/CSSRegisteredCustomProperty.h: * css/CSSVariableData.cpp: (WebCore::CSSVariableData::CSSVariableData): (WebCore::CSSVariableData::consumeAndUpdateTokens): Deleted. (WebCore::CSSVariableData::checkVariablesForCycles const): Deleted. (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): Deleted. (WebCore::CSSVariableData::resolveVariableFallback const): Deleted. (WebCore::CSSVariableData::resolveVariableReference const): Deleted. (WebCore::CSSVariableData::resolveVariableReferences const): Deleted. (WebCore::CSSVariableData::resolveTokenRange const): Deleted. * css/CSSVariableData.h: (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): Deleted. (WebCore::CSSVariableData::needsVariableResolution const): Deleted. (WebCore::CSSVariableData::CSSVariableData): Deleted. * css/CSSVariableReferenceValue.cpp: (WebCore::resolveVariableFallback): (WebCore::resolveVariableReference): (WebCore::resolveTokenRange): (WebCore::CSSVariableReferenceValue::resolveVariableReferences const): (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): Deleted. * css/CSSVariableReferenceValue.h: (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::equals const): (WebCore::CSSVariableReferenceValue::variableDataValue const): Deleted. * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::PropertySetCSSStyleDeclaration::setProperty): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleProperties.cpp: (WebCore::MutableStyleProperties::setCustomProperty): * css/StyleProperties.h: * css/StyleResolver.cpp: (WebCore::StyleResolver::State::setStyle): (WebCore::StyleResolver::styleForKeyframe): (WebCore::StyleResolver::styleForPage): (WebCore::StyleResolver::applyMatchedProperties): (WebCore::StyleResolver::applyPropertyToCurrentStyle): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::CascadedProperties::applyDeferredProperties): (WebCore::StyleResolver::CascadedProperties::Property::apply): (WebCore::StyleResolver::applyCascadedCustomProperty): (WebCore::StyleResolver::applyCascadedProperties): * css/StyleResolver.h: * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::CSSPropertyParser): (WebCore::CSSPropertyParser::canParseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::parseTypedCustomPropertyValue): (WebCore::CSSPropertyParser::collectParsedCustomPropertyValueDependencies): (WebCore::CSSPropertyParser::parseValueStart): (WebCore::CSSPropertyParser::parseSingleValue): * css/parser/CSSPropertyParser.h: * css/parser/CSSVariableParser.cpp: (WebCore::CSSVariableParser::parseDeclarationValue): * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::setValueForProperty): (WebCore::variableDataForPositivePixelLength): (WebCore::variableDataForPositiveDuration): * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Deleted. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): * rendering/style/StyleCustomPropertyData.h: (WebCore::StyleCustomPropertyData::operator== const): (WebCore::StyleCustomPropertyData::setCustomPropertyValue): (WebCore::StyleCustomPropertyData::StyleCustomPropertyData): (): Deleted. LayoutTests: * css-custom-properties-api/crash-expected.txt: Added. * css-custom-properties-api/crash.html: Added. * css-custom-properties-api/cycles-expected.txt: Added. * css-custom-properties-api/cycles.html: Added. * css-custom-properties-api/inline-expected.txt: Added. * css-custom-properties-api/inline.html: Added. Canonical link: https://commits.webkit.org/205971@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237697 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-01 20:35:27 +00:00
Ref<CSSVariableData> m_data;
[CSS Parser] Implement CSS variables https://bugs.webkit.org/show_bug.cgi?id=164075 Reviewed by Dean Jackson. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: Add CSSCustomPropertyValue.cpp to the project. * css/CSSCustomPropertyValue.cpp: Added. (WebCore::CSSCustomPropertyValue::checkVariablesForCycles): (WebCore::CSSCustomPropertyValue::resolveVariableReferences): * css/CSSCustomPropertyValue.h: These functions abstract the old and new implementations of CSS variables so that the callers don't have to worry about it. * css/CSSValue.cpp: (WebCore::CSSValue::equals): Make sure CSSVariableReferenceValue and CSSPendingSubstitutionValue have equals implemented. (WebCore::CSSValue::isInvalidCustomPropertyValue): Deleted. This code was dead and never called. * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyValue): (WebCore::CSSValue::hasVariableReferences): Add a helper function for asking if a CSSValue has variable references. This abstracts the old and new implementations so that callers can ask if the value has variables without caring which implementation is being used. * css/CSSValueList.cpp: (WebCore::CSSValueList::checkVariablesForCycles): * css/CSSValueList.h: In order to abstract the old and new variables implementations, custom properties now store CSSCustomPropertyValue as their values instead of raw values. The old implementation needs to be patched to deal with this wrapper being present now. * css/CSSVariableData.cpp: (WebCore::CSSVariableData::checkVariablesForCycles): (WebCore::CSSVariableData::checkVariablesForCyclesWithRange): (WebCore::CSSVariableData::resolveVariableFallback): (WebCore::CSSVariableData::resolveVariableReference): (WebCore::CSSVariableData::resolveVariableReferences): (WebCore::CSSVariableData::resolveTokenRange): * css/CSSVariableData.h: Implementation of cycle checking and variable resolution. The logic of this implementation is the same as the old. It walks CSSParserTokens instead of the old CSSParser structures. * css/CSSVariableReferenceValue.cpp: (WebCore::CSSVariableReferenceValue::customCSSText): Add support for serialization caching, just like the old implementation had in CSSVariableDependentValue. (WebCore::CSSVariableReferenceValue::checkVariablesForCycles): * css/CSSVariableReferenceValue.h: Add cycle checking and variable resolution helper functions. * css/CSSVariableValue.cpp: (WebCore::CSSVariableValue::buildParserValueListSubstitutingVariables): Patched to account for the change in storage of custom properties to have custom property value wrappers. * css/StyleProperties.cpp: (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::borderSpacingValue): (WebCore::StyleProperties::getLayeredShorthandValue): (WebCore::StyleProperties::getShorthandValue): (WebCore::StyleProperties::getCommonValue): (WebCore::StyleProperties::getPropertyCSSValue): (WebCore::StyleProperties::asText): Clean up the resolution of pending substitution values. Instead of hacking it into every possible StyleShorthandProperty crawling function, obtain the shorthand for the property up front, access the first longhand, and if we see a pending substitution value, perform the substitution. * css/StyleResolver.cpp: (WebCore::StyleResolver::MatchResult::addMatchedProperties): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue): * css/StyleResolver.h: Add support for the new implementation in all the same places as the old. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseInlineStyleDeclaration): (WebCore::CSSParser::parseValueWithVariableReferences): (WebCore::CSSParser::parseVariableDependentValue): Deleted. * css/parser/CSSParser.h: Rename parseVariableDependentValue to parseValueWithVariableReferences, since it is operating on three distinct value types now. Turn on new parser support for parseInlineStyleDeclaration. * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::parseVariableValue): Deleted. (WebCore::CSSParserImpl::parseCustomPropertySet): Deleted. * css/parser/CSSParserImpl.h: Remove parser functions that aren't relevant to our implementation of CSS variables. * css/parser/CSSVariableParser.cpp: (WebCore::classifyVariableRange): Add support for the CSS4 'revert' keyword to the new variable parser. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): Modified to store CSSCustomPropertyValues as the values always now and to use the method abstractions on CSSCustomPropertyValue to resolve cycles and perform substitutions. * rendering/style/RenderStyle.h: (WebCore::RenderStyle::setCustomPropertyValue): (WebCore::RenderStyle::getCustomPropertyValue): * rendering/style/StyleCustomPropertyData.h: (WebCore::StyleCustomPropertyData::operator==): (WebCore::StyleCustomPropertyData::setCustomPropertyValue): (WebCore::StyleCustomPropertyData::getCustomPropertyValue): Tighten up the map to store CSSCustomPropertyValue instead of just CSSValue. Canonical link: https://commits.webkit.org/181795@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208006 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-27 22:05:01 +00:00
mutable String m_stringValue;
[CSS Parser] Add CSS Variable Parsing support https://bugs.webkit.org/show_bug.cgi?id=161916 Reviewed by Dean Jackson. This patch not only adds the parser for CSS variables (from Blink), but it also brings in all of the data structures used to store variables and custom property declarations. We will be abandoning our old data structures eventually in favor of these new ones. They are not significantly different other than operating on the CSSParserTokenRanges rather than the soon-to-be-removed parser value lists. * CMakeLists.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSCustomIdentValue.cpp: Added. (WebCore::CSSCustomIdentValue::CSSCustomIdentValue): (WebCore::CSSCustomIdentValue::customCSSText): * css/CSSCustomIdentValue.h: Added. (WebCore::CSSCustomIdentValue::create): (WebCore::CSSCustomIdentValue::value): (WebCore::CSSCustomIdentValue::isKnownPropertyID): (WebCore::CSSCustomIdentValue::valueAsPropertyID): (WebCore::CSSCustomIdentValue::equals): * css/CSSCustomPropertyDeclaration.cpp: Added. (WebCore::CSSCustomPropertyDeclaration::customCSSText): * css/CSSCustomPropertyDeclaration.h: Added. (WebCore::CSSCustomPropertyDeclaration::create): (WebCore::CSSCustomPropertyDeclaration::name): (WebCore::CSSCustomPropertyDeclaration::value): (WebCore::CSSCustomPropertyDeclaration::id): (WebCore::CSSCustomPropertyDeclaration::equals): (WebCore::CSSCustomPropertyDeclaration::CSSCustomPropertyDeclaration): * css/CSSCustomPropertyValue.h: * css/CSSValue.cpp: (WebCore::CSSValue::cssText): (WebCore::CSSValue::destroy): * css/CSSValue.h: (WebCore::CSSValue::isCustomPropertyDeclaration): (WebCore::CSSValue::isCustomIdentValue): (WebCore::CSSValue::isVariableReferenceValue): * css/CSSValueKeywords.in: * css/CSSVariableData.cpp: Added. (WebCore::CSSVariableData::updateTokens): (WebCore::CSSVariableData::operator==): (WebCore::CSSVariableData::consumeAndUpdateTokens): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableData.h: Added. (WebCore::CSSVariableData::create): (WebCore::CSSVariableData::createResolved): (WebCore::CSSVariableData::tokenRange): (WebCore::CSSVariableData::tokens): (WebCore::CSSVariableData::needsVariableResolution): (WebCore::CSSVariableData::CSSVariableData): * css/CSSVariableDependentValue.h: * css/CSSVariableReferenceValue.cpp: Added. (WebCore::CSSVariableReferenceValue::customCSSText): * css/CSSVariableReferenceValue.h: Added. (WebCore::CSSVariableReferenceValue::create): (WebCore::CSSVariableReferenceValue::variableDataValue): (WebCore::CSSVariableReferenceValue::equals): (WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue): * css/CSSVariableValue.h: * css/parser/CSSParserImpl.cpp: (WebCore::filterProperties): (WebCore::CSSParserImpl::consumeDeclaration): (WebCore::CSSParserImpl::consumeVariableValue): * css/parser/CSSVariableParser.cpp: Added. (WebCore::CSSVariableParser::isValidVariableName): (WebCore::classifyBlock): (WebCore::isValidVariableReference): (WebCore::classifyVariableRange): (WebCore::CSSVariableParser::containsValidVariableReferences): (WebCore::CSSVariableParser::parseDeclarationValue): * css/parser/CSSVariableParser.h: Added. Canonical link: https://commits.webkit.org/180068@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205869 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 19:08:30 +00:00
};
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSVariableReferenceValue, isVariableReferenceValue())