• macpherson@chromium.org's avatar
    Make it possible to use CSS Variables inside Calc expressions. · 34d76eee
    macpherson@chromium.org authored
    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):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    34d76eee
calc-invalid-variable.html 280 Bytes