haikuwebkit/Source/WebCore/css/CSSRegisteredCustomProperty...

49 lines
1.9 KiB
C++
Raw Permalink Normal View History

Registered custom properties should allow inheritance to be controlled https://bugs.webkit.org/show_bug.cgi?id=190038 Patch by Justin Michaud <justin_michaud@apple.com> on 2018-10-03 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Update web platform tests for css registered custom properties to fail in a different way. * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/url-resolution-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: Tests: css-custom-properties-api/inherits.html css-custom-properties-api/length.html css-custom-properties-api/length2.html Add support for inherits property on registered css custom properties, as well as a starting point for evaluating registered custom properties with types. Registered custom properties are evaluated as length values before being substituted. Currently, relative unit cycles are not detected. A proper solution is still needed to resolve relative unit cycles, and to apply properties like font and line-height before they are needed by custom properties. In this patch, the font-size property is applied twice, once before and once after resolving custom property values. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): (WebCore::CSSComputedStyleDeclaration::length const): (WebCore::CSSComputedStyleDeclaration::item const): Allow JS to get custom properties that have been resolved to a length. Also add properties from m_rareNonInheritedData. * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: Copied from Source/WebCore/css/CSSRegisteredCustomProperty.h. (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): (WebCore::CSSRegisteredCustomProperty::initialValueCopy const): * css/CSSRegisteredCustomProperty.h: (WebCore::CSSRegisteredCustomProperty::initialValue const): * css/CSSVariableData.cpp: (WebCore::CSSVariableData::checkVariablesForCycles const): (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): (WebCore::CSSVariableData::resolveVariableFallback const): (WebCore::CSSVariableData::resolveVariableReference const): (WebCore::CSSVariableData::resolveVariableReferences const): (WebCore::CSSVariableData::resolveTokenRange const): * css/CSSVariableData.h: * css/CSSVariableReferenceValue.cpp: (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): * css/CSSVariableReferenceValue.h: * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): Use RenderStyle over passing in a customProperties map. * css/StyleBuilder.h: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertLength): (WebCore::StyleBuilderConverter::convertLengthOrAuto): (WebCore::StyleBuilderConverter::convertLengthSizing): (WebCore::StyleBuilderConverter::convertLengthMaxSizing): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyInheritCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::useSVGZoomRules const): (WebCore::StyleResolver::useSVGZoomRulesForLength const): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::applyCascadedProperties): (WebCore::StyleResolver::useSVGZoomRules): Deleted. (WebCore::StyleResolver::useSVGZoomRulesForLength): Deleted. (WebCore::StyleResolver::resolvedVariableValue): Deleted. * css/StyleResolver.h: * css/makeprop.pl: Move custom property initial values to StyleBuilerCustom. Hook them up to correctly deal with inheritance, unset and revert values. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSParserContext.cpp: (WebCore::CSSParserContext::CSSParserContext): * css/parser/CSSParserContext.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): Allow parsing custom property values as lengths. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::inheritedCustomProperties const): (WebCore::RenderStyle::nonInheritedCustomProperties const): (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): (WebCore::RenderStyle::getCustomProperty const): (WebCore::RenderStyle::customProperties const): Deleted. (WebCore::RenderStyle::setCustomPropertyValue): Deleted. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator== const): * rendering/style/StyleRareNonInheritedData.h: * style/StyleResolveForDocument.cpp: (WebCore::Style::resolveForDocument): Add support for RenderStyle to deal with both inherited and non-inherited properties, and to find cycles between them. LayoutTests: Add tests to check css registered custom properties with inherits. Also test calc expression evaluation for inherited registered custom properties. * css-custom-properties-api/inherits-expected.txt: Added. * css-custom-properties-api/inherits.html: Added. * css-custom-properties-api/length-expected.txt: Added. * css-custom-properties-api/length.html: Added. * css-custom-properties-api/length2-expected.txt: Added. * css-custom-properties-api/length2.html: Added. Canonical link: https://commits.webkit.org/205226@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-04 06:23:02 +00:00
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "CSSRegisteredCustomProperty.h"
#include "CSSCustomPropertyValue.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
CSSRegisteredCustomProperty::CSSRegisteredCustomProperty(const String& name, const String& syntax, bool inherits, RefPtr<CSSCustomPropertyValue>&& initialValue)
Registered custom properties should allow inheritance to be controlled https://bugs.webkit.org/show_bug.cgi?id=190038 Patch by Justin Michaud <justin_michaud@apple.com> on 2018-10-03 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Update web platform tests for css registered custom properties to fail in a different way. * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/url-resolution-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: Tests: css-custom-properties-api/inherits.html css-custom-properties-api/length.html css-custom-properties-api/length2.html Add support for inherits property on registered css custom properties, as well as a starting point for evaluating registered custom properties with types. Registered custom properties are evaluated as length values before being substituted. Currently, relative unit cycles are not detected. A proper solution is still needed to resolve relative unit cycles, and to apply properties like font and line-height before they are needed by custom properties. In this patch, the font-size property is applied twice, once before and once after resolving custom property values. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): (WebCore::CSSComputedStyleDeclaration::length const): (WebCore::CSSComputedStyleDeclaration::item const): Allow JS to get custom properties that have been resolved to a length. Also add properties from m_rareNonInheritedData. * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: Copied from Source/WebCore/css/CSSRegisteredCustomProperty.h. (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): (WebCore::CSSRegisteredCustomProperty::initialValueCopy const): * css/CSSRegisteredCustomProperty.h: (WebCore::CSSRegisteredCustomProperty::initialValue const): * css/CSSVariableData.cpp: (WebCore::CSSVariableData::checkVariablesForCycles const): (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): (WebCore::CSSVariableData::resolveVariableFallback const): (WebCore::CSSVariableData::resolveVariableReference const): (WebCore::CSSVariableData::resolveVariableReferences const): (WebCore::CSSVariableData::resolveTokenRange const): * css/CSSVariableData.h: * css/CSSVariableReferenceValue.cpp: (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): * css/CSSVariableReferenceValue.h: * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): Use RenderStyle over passing in a customProperties map. * css/StyleBuilder.h: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertLength): (WebCore::StyleBuilderConverter::convertLengthOrAuto): (WebCore::StyleBuilderConverter::convertLengthSizing): (WebCore::StyleBuilderConverter::convertLengthMaxSizing): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyInheritCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::useSVGZoomRules const): (WebCore::StyleResolver::useSVGZoomRulesForLength const): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::applyCascadedProperties): (WebCore::StyleResolver::useSVGZoomRules): Deleted. (WebCore::StyleResolver::useSVGZoomRulesForLength): Deleted. (WebCore::StyleResolver::resolvedVariableValue): Deleted. * css/StyleResolver.h: * css/makeprop.pl: Move custom property initial values to StyleBuilerCustom. Hook them up to correctly deal with inheritance, unset and revert values. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSParserContext.cpp: (WebCore::CSSParserContext::CSSParserContext): * css/parser/CSSParserContext.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): Allow parsing custom property values as lengths. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::inheritedCustomProperties const): (WebCore::RenderStyle::nonInheritedCustomProperties const): (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): (WebCore::RenderStyle::getCustomProperty const): (WebCore::RenderStyle::customProperties const): Deleted. (WebCore::RenderStyle::setCustomPropertyValue): Deleted. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator== const): * rendering/style/StyleRareNonInheritedData.h: * style/StyleResolveForDocument.cpp: (WebCore::Style::resolveForDocument): Add support for RenderStyle to deal with both inherited and non-inherited properties, and to find cycles between them. LayoutTests: Add tests to check css registered custom properties with inherits. Also test calc expression evaluation for inherited registered custom properties. * css-custom-properties-api/inherits-expected.txt: Added. * css-custom-properties-api/inherits.html: Added. * css-custom-properties-api/length-expected.txt: Added. * css-custom-properties-api/length.html: Added. * css-custom-properties-api/length2-expected.txt: Added. * css-custom-properties-api/length2.html: Added. Canonical link: https://commits.webkit.org/205226@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-04 06:23:02 +00:00
: name(name)
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
, syntax(syntax)
Registered custom properties should allow inheritance to be controlled https://bugs.webkit.org/show_bug.cgi?id=190038 Patch by Justin Michaud <justin_michaud@apple.com> on 2018-10-03 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Update web platform tests for css registered custom properties to fail in a different way. * web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt: * web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt: * web-platform-tests/css/css-properties-values-api/url-resolution-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: Tests: css-custom-properties-api/inherits.html css-custom-properties-api/length.html css-custom-properties-api/length2.html Add support for inherits property on registered css custom properties, as well as a starting point for evaluating registered custom properties with types. Registered custom properties are evaluated as length values before being substituted. Currently, relative unit cycles are not detected. A proper solution is still needed to resolve relative unit cycles, and to apply properties like font and line-height before they are needed by custom properties. In this patch, the font-size property is applied twice, once before and once after resolving custom property values. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::customPropertyValue): (WebCore::CSSComputedStyleDeclaration::length const): (WebCore::CSSComputedStyleDeclaration::item const): Allow JS to get custom properties that have been resolved to a length. Also add properties from m_rareNonInheritedData. * css/CSSCustomPropertyValue.cpp: (WebCore::CSSCustomPropertyValue::checkVariablesForCycles const): (WebCore::CSSCustomPropertyValue::resolveVariableReferences const): * css/CSSCustomPropertyValue.h: * css/CSSRegisteredCustomProperty.cpp: Copied from Source/WebCore/css/CSSRegisteredCustomProperty.h. (WebCore::CSSRegisteredCustomProperty::CSSRegisteredCustomProperty): (WebCore::CSSRegisteredCustomProperty::initialValueCopy const): * css/CSSRegisteredCustomProperty.h: (WebCore::CSSRegisteredCustomProperty::initialValue const): * css/CSSVariableData.cpp: (WebCore::CSSVariableData::checkVariablesForCycles const): (WebCore::CSSVariableData::checkVariablesForCyclesWithRange const): (WebCore::CSSVariableData::resolveVariableFallback const): (WebCore::CSSVariableData::resolveVariableReference const): (WebCore::CSSVariableData::resolveVariableReferences const): (WebCore::CSSVariableData::resolveTokenRange const): * css/CSSVariableData.h: * css/CSSVariableReferenceValue.cpp: (WebCore::CSSVariableReferenceValue::checkVariablesForCycles const): * css/CSSVariableReferenceValue.h: * css/DOMCSSRegisterCustomProperty.cpp: (WebCore::DOMCSSRegisterCustomProperty::registerProperty): Use RenderStyle over passing in a customProperties map. * css/StyleBuilder.h: * css/StyleBuilderConverter.h: (WebCore::StyleBuilderConverter::convertLength): (WebCore::StyleBuilderConverter::convertLengthOrAuto): (WebCore::StyleBuilderConverter::convertLengthSizing): (WebCore::StyleBuilderConverter::convertLengthMaxSizing): * css/StyleBuilderCustom.h: (WebCore::StyleBuilderCustom::applyInitialCustomProperty): (WebCore::StyleBuilderCustom::applyInheritCustomProperty): (WebCore::StyleBuilderCustom::applyValueCustomProperty): * css/StyleResolver.cpp: (WebCore::StyleResolver::useSVGZoomRules const): (WebCore::StyleResolver::useSVGZoomRulesForLength const): (WebCore::StyleResolver::applyProperty): (WebCore::StyleResolver::resolvedVariableValue const): (WebCore::StyleResolver::applyCascadedProperties): (WebCore::StyleResolver::useSVGZoomRules): Deleted. (WebCore::StyleResolver::useSVGZoomRulesForLength): Deleted. (WebCore::StyleResolver::resolvedVariableValue): Deleted. * css/StyleResolver.h: * css/makeprop.pl: Move custom property initial values to StyleBuilerCustom. Hook them up to correctly deal with inheritance, unset and revert values. * css/parser/CSSParser.cpp: (WebCore::CSSParser::parseValueWithVariableReferences): * css/parser/CSSParser.h: * css/parser/CSSParserContext.cpp: (WebCore::CSSParserContext::CSSParserContext): * css/parser/CSSParserContext.h: * css/parser/CSSPropertyParser.cpp: (WebCore::CSSPropertyParser::parseSingleValue): Allow parsing custom property values as lengths. * rendering/style/RenderStyle.cpp: (WebCore::RenderStyle::checkVariablesInCustomProperties): * rendering/style/RenderStyle.h: (WebCore::RenderStyle::inheritedCustomProperties const): (WebCore::RenderStyle::nonInheritedCustomProperties const): (WebCore::RenderStyle::setInheritedCustomPropertyValue): (WebCore::RenderStyle::setNonInheritedCustomPropertyValue): (WebCore::RenderStyle::getCustomProperty const): (WebCore::RenderStyle::customProperties const): Deleted. (WebCore::RenderStyle::setCustomPropertyValue): Deleted. * rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator== const): * rendering/style/StyleRareNonInheritedData.h: * style/StyleResolveForDocument.cpp: (WebCore::Style::resolveForDocument): Add support for RenderStyle to deal with both inherited and non-inherited properties, and to find cycles between them. LayoutTests: Add tests to check css registered custom properties with inherits. Also test calc expression evaluation for inherited registered custom properties. * css-custom-properties-api/inherits-expected.txt: Added. * css-custom-properties-api/inherits.html: Added. * css-custom-properties-api/length-expected.txt: Added. * css-custom-properties-api/length.html: Added. * css-custom-properties-api/length2-expected.txt: Added. * css-custom-properties-api/length2.html: Added. Canonical link: https://commits.webkit.org/205226@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-04 06:23:02 +00:00
, inherits(inherits)
, m_initialValue(WTFMove(initialValue))
{
}
RefPtr<CSSCustomPropertyValue> CSSRegisteredCustomProperty::initialValueCopy() const
{
if (m_initialValue)
return CSSCustomPropertyValue::create(*m_initialValue);
return nullptr;
}
} // namespace WebCore