Registered custom properties should allow inheritance to be controlled
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2018 06:23:02 +0000 (06:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2018 06:23:02 +0000 (06:23 +0000)
commit4c574c6395c9b46503818ac4d269598863edca88
tree5aee69f0e0a143cd1ca9832df7cf34b3e15e0175
parent6a415628b419bf3cd97ed213315aab92a9543f70
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236828 268f45cc-cd09-0410-ab3c-d52691b4dbfc
48 files changed:
LayoutTests/ChangeLog
LayoutTests/css-custom-properties-api/inherits-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/inherits.html [new file with mode: 0644]
LayoutTests/css-custom-properties-api/length-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/length.html [new file with mode: 0644]
LayoutTests/css-custom-properties-api/length2-expected.txt [new file with mode: 0644]
LayoutTests/css-custom-properties-api/length2.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/property-cascade-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-properties-inheritance-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-cssom-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-initial-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/typedom.tentative-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/url-resolution-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-cycles-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/var-reference-registered-properties-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSCustomPropertyValue.cpp
Source/WebCore/css/CSSCustomPropertyValue.h
Source/WebCore/css/CSSRegisteredCustomProperty.cpp [new file with mode: 0644]
Source/WebCore/css/CSSRegisteredCustomProperty.h
Source/WebCore/css/CSSVariableData.cpp
Source/WebCore/css/CSSVariableData.h
Source/WebCore/css/CSSVariableReferenceValue.cpp
Source/WebCore/css/CSSVariableReferenceValue.h
Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp
Source/WebCore/css/StyleBuilder.h
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/makeprop.pl
Source/WebCore/css/parser/CSSParser.cpp
Source/WebCore/css/parser/CSSParser.h
Source/WebCore/css/parser/CSSParserContext.cpp
Source/WebCore/css/parser/CSSParserContext.h
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleCustomPropertyData.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h
Source/WebCore/style/StyleResolveForDocument.cpp