Ignore:
Timestamp:
Oct 3, 2018, 11:23:02 PM (7 years ago)
Author:
[email protected]
Message:

Registered custom properties should allow inheritance to be controlled
https://bugs.webkit.org/show_bug.cgi?id=190038

Patch by Justin Michaud <Justin Michaud> 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSCustomPropertyValue.cpp

    r236379 r236828  
    3030namespace WebCore {
    3131
    32 bool CSSCustomPropertyValue::checkVariablesForCycles(const AtomicString& name, CustomPropertyValueMap& customProperties, HashSet<AtomicString>& seenProperties, HashSet<AtomicString>& invalidProperties) const
     32bool CSSCustomPropertyValue::checkVariablesForCycles(const AtomicString& name, const RenderStyle& style, HashSet<AtomicString>& seenProperties, HashSet<AtomicString>& invalidProperties) const
    3333{
    3434    ASSERT(containsVariables());
    3535    if (m_value)
    36         return m_value->checkVariablesForCycles(name, customProperties, seenProperties, invalidProperties);
     36        return m_value->checkVariablesForCycles(name, style, seenProperties, invalidProperties);
    3737    return true;
    3838}
    3939
    40 void CSSCustomPropertyValue::resolveVariableReferences(const CustomPropertyValueMap& customProperties, const CSSRegisteredCustomPropertySet& registeredProperties, Vector<Ref<CSSCustomPropertyValue>>& resolvedValues) const
     40void CSSCustomPropertyValue::resolveVariableReferences(const CSSRegisteredCustomPropertySet& registeredProperties, Vector<Ref<CSSCustomPropertyValue>>& resolvedValues, const RenderStyle& style) const
    4141{
    4242    ASSERT(containsVariables());
     
    4545   
    4646    ASSERT(m_value->needsVariableResolution());
    47     RefPtr<CSSVariableData> resolvedData = m_value->resolveVariableReferences(customProperties, registeredProperties);
     47    RefPtr<CSSVariableData> resolvedData = m_value->resolveVariableReferences(registeredProperties, style);
    4848    if (resolvedData)
    4949        resolvedValues.append(CSSCustomPropertyValue::createWithVariableData(m_name, resolvedData.releaseNonNull()));
Note: See TracChangeset for help on using the changeset viewer.