Ignore:
Timestamp:
Aug 30, 2012, 6:13:50 PM (13 years ago)
Author:
[email protected]
Message:

Make it possible to use CSS Variables inside Calc expressions.
https://bugs.webkit.org/show_bug.cgi?id=95284

Reviewed by Tony Chang.

Allows calc expressions to contain unevaluated variables, which are then resolved in StyleResolver.cpp when building the RenderStyle tree.

Tests:
fast/css/variables/calc.html

  • css/CSSCalculationValue.cpp:

(WebCore::unitCategory):
(WebCore):
(WebCore::CSSCalcValue::customSerializeResolvingVariables):
Generates a CSS expression with variables resolved into their corresponding values.
(WebCore::CSSCalcValue::hasVariableReference):
Returns true if the calculation's expression tree refers to a variable (that needs to be resolved).
(CSSCalcPrimitiveValue):
(WebCore::CSSCalcPrimitiveValue::serializeResolvingVariables):
Resolves the variable using the underlying CSSPrimitiveValue's serializeResolvingVariables function.
(WebCore::CSSCalcPrimitiveValue::hasVariableReference):
(WebCore::CSSCalcPrimitiveValue::toCalcValue):
(WebCore::CSSCalcPrimitiveValue::doubleValue):
(WebCore::CSSCalcPrimitiveValue::computeLengthPx):
(WebCore::CSSCalcBinaryOperation::create):
(CSSCalcBinaryOperation):
(WebCore::CSSCalcBinaryOperation::serializeResolvingVariables):
Builds a CSS expression for contained subtrees.
(WebCore::CSSCalcBinaryOperation::hasVariableReference):
Returns true if either subtree contains a variable.

  • css/CSSCalculationValue.h:

(CSSCalcExpressionNode):
(CSSCalcValue):

  • css/CSSGrammar.y:
  • css/CSSParser.cpp:

(WebCore::CSSParser::validCalculationUnit):

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::primitiveType):
(WebCore::CSSPrimitiveValue::customSerializeResolvingVariables):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::collectMatchingRulesForList):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSCalculationValue.h

    r124768 r127220  
    5353    CalcPercentNumber,
    5454    CalcPercentLength,
     55#if ENABLE(CSS_VARIABLES)
     56    CalcVariable,
     57#endif
    5558    CalcOther
    5659};
     
    6568    virtual double computeLengthPx(RenderStyle* currentStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0;
    6669    virtual String customCssText() const = 0;
     70#if ENABLE(CSS_VARIABLES)
     71    virtual String serializeResolvingVariables(const HashMap<AtomicString, String>&) const = 0;
     72    virtual bool hasVariableReference() const = 0;
     73#endif
    6774
    6875    virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
     
    98105       
    99106    String customCssText() const;
     107#if ENABLE(CSS_VARIABLES)
     108    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
     109    bool hasVariableReference() const;
     110#endif
    100111
    101112    void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
Note: See TracChangeset for help on using the changeset viewer.