Changeset 140642 in webkit


Ignore:
Timestamp:
Jan 23, 2013 8:44:10 PM (11 years ago)
Author:
macpherson@chromium.org
Message:

Support variables inside -webkit-box-reflect CSS property.
https://bugs.webkit.org/show_bug.cgi?id=106856

Source/WebCore:

Reviewed by Tony Chang.

The primary change is to make the direction parameter a CSSPrimitiveValue style ident,
so that it can also be a variable reference.

Covered by existing LayoutTests/compositing/reflections/ tests.
Added Test: fast/css/variables/var-inside-box-reflect.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::valueForReflection):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseReflect):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore):
(WebCore::CSSPrimitiveValue::operator CSSReflectionDirection):
(WebCore::CSSPrimitiveValue::convertToLength):

  • css/CSSReflectValue.cpp:

(WebCore::CSSReflectValue::customCssText):
Use String addition operator instead of StringBuilder.
(WebCore):
(WebCore::CSSReflectValue::customSerializeResolvingVariables):
Use String addition operator instead of StringBuilder.

  • css/CSSReflectValue.h:

(WebCore::CSSReflectValue::create):
(WebCore::CSSReflectValue::direction):
(CSSReflectValue):
(WebCore::CSSReflectValue::CSSReflectValue):

  • css/CSSValue.cpp:

(WebCore::CSSValue::serializeResolvingVariables):

  • css/StyleResolver.cpp:

(WebCore::hasVariableReference):
(WebCore::StyleResolver::applyProperty):

LayoutTests:

Adds test for variables as -webkit-box-reflect parameters.

Reviewed by Tony Chang.

  • fast/css/variables/var-inside-box-reflect-expected.html: Added.
  • fast/css/variables/var-inside-box-reflect.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140631 r140642  
     12013-01-23  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Support variables inside -webkit-box-reflect CSS property.
     4        https://bugs.webkit.org/show_bug.cgi?id=106856
     5
     6        Adds test for variables as -webkit-box-reflect parameters.
     7
     8        Reviewed by Tony Chang.
     9
     10        * fast/css/variables/var-inside-box-reflect-expected.html: Added.
     11        * fast/css/variables/var-inside-box-reflect.html: Added.
     12
    1132013-01-23  Rafael Weinstein  <rafaelw@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r140640 r140642  
     12013-01-23  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Support variables inside -webkit-box-reflect CSS property.
     4        https://bugs.webkit.org/show_bug.cgi?id=106856
     5
     6        Reviewed by Tony Chang.
     7
     8        The primary change is to make the direction parameter a CSSPrimitiveValue style ident,
     9        so that it can also be a variable reference.
     10
     11        Covered by existing LayoutTests/compositing/reflections/ tests.
     12        Added Test: fast/css/variables/var-inside-box-reflect.html
     13
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore::valueForReflection):
     16        * css/CSSParser.cpp:
     17        (WebCore::CSSParser::parseReflect):
     18        * css/CSSPrimitiveValueMappings.h:
     19        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     20        (WebCore):
     21        (WebCore::CSSPrimitiveValue::operator CSSReflectionDirection):
     22        (WebCore::CSSPrimitiveValue::convertToLength):
     23        * css/CSSReflectValue.cpp:
     24        (WebCore::CSSReflectValue::customCssText):
     25        Use String addition operator instead of StringBuilder.
     26        (WebCore):
     27        (WebCore::CSSReflectValue::customSerializeResolvingVariables):
     28        Use String addition operator instead of StringBuilder.
     29        * css/CSSReflectValue.h:
     30        (WebCore::CSSReflectValue::create):
     31        (WebCore::CSSReflectValue::direction):
     32        (CSSReflectValue):
     33        (WebCore::CSSReflectValue::CSSReflectValue):
     34        * css/CSSValue.cpp:
     35        (WebCore::CSSValue::serializeResolvingVariables):
     36        * css/StyleResolver.cpp:
     37        (WebCore::hasVariableReference):
     38        (WebCore::StyleResolver::applyProperty):
     39
    1402013-01-23  Abhishek Arya  <inferno@chromium.org>
    241
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r139321 r140642  
    595595        offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
    596596
    597     return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
     597    RefPtr<CSSPrimitiveValue> direction;
     598    switch (reflection->direction()) {
     599    case ReflectionBelow:
     600        direction = cssValuePool().createIdentifierValue(CSSValueBelow);
     601        break;
     602    case ReflectionAbove:
     603        direction = cssValuePool().createIdentifierValue(CSSValueAbove);
     604        break;
     605    case ReflectionLeft:
     606        direction = cssValuePool().createIdentifierValue(CSSValueLeft);
     607        break;
     608    case ReflectionRight:
     609        direction = cssValuePool().createIdentifierValue(CSSValueRight);
     610        break;
     611    }
     612
     613    return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
    598614}
    599615
  • trunk/Source/WebCore/css/CSSParser.cpp

    r140560 r140642  
    62156215    // Direction comes first.
    62166216    CSSParserValue* val = m_valueList->current();
    6217     CSSReflectionDirection direction;
     6217    RefPtr<CSSPrimitiveValue> direction;
     6218#if ENABLE(CSS_VARIABLES)
     6219    if (val->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME)
     6220        direction = createPrimitiveVariableNameValue(val);
     6221    else
     6222#endif
    62186223    switch (val->id) {
    62196224        case CSSValueAbove:
    6220             direction = ReflectionAbove;
    6221             break;
    62226225        case CSSValueBelow:
    6223             direction = ReflectionBelow;
    6224             break;
    62256226        case CSSValueLeft:
    6226             direction = ReflectionLeft;
    6227             break;
    62286227        case CSSValueRight:
    6229             direction = ReflectionRight;
     6228            direction = cssValuePool().createIdentifierValue(val->id);
    62306229            break;
    62316230        default:
     
    62526251    }
    62536252
    6254     RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction, offset.release(), mask.release());
     6253    RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.release(), offset.release(), mask.release());
    62556254    addProperty(propId, reflectValue.release(), important);
    62566255    m_valueList->next();
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r139734 r140642  
    3333#include "CSSCalculationValue.h"
    3434#include "CSSPrimitiveValue.h"
     35#include "CSSReflectionDirection.h"
    3536#include "ColorSpace.h"
    3637#include "CSSValueKeywords.h"
     
    140141    ASSERT_NOT_REACHED();
    141142    return LineClampValue();
     143}
     144
     145template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSReflectionDirection e)
     146    : CSSValue(PrimitiveClass)
     147{
     148    m_primitiveUnitType = CSS_IDENT;
     149    switch (e) {
     150    case ReflectionAbove:
     151        m_value.ident = CSSValueAbove;
     152        break;
     153    case ReflectionBelow:
     154        m_value.ident = CSSValueBelow;
     155        break;
     156    case ReflectionLeft:
     157        m_value.ident = CSSValueLeft;
     158        break;
     159    case ReflectionRight:
     160        m_value.ident = CSSValueRight;
     161    }
     162}
     163
     164template<> inline CSSPrimitiveValue::operator CSSReflectionDirection() const
     165{
     166    switch (m_value.ident) {
     167    case CSSValueAbove:
     168        return ReflectionAbove;
     169    case CSSValueBelow:
     170        return ReflectionBelow;
     171    case CSSValueLeft:
     172        return ReflectionLeft;
     173    case CSSValueRight:
     174        return ReflectionRight;
     175    }
     176
     177    ASSERT_NOT_REACHED();
     178    return ReflectionBelow;
    142179}
    143180
     
    40784115template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
    40794116{
     4117#if ENABLE(CSS_VARIABLES)
     4118    ASSERT(!hasVariableReference());
     4119#endif
    40804120    if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
    40814121        return Length(Undefined);
  • trunk/Source/WebCore/css/CSSReflectValue.cpp

    r128762 r140642  
    3737String CSSReflectValue::customCssText() const
    3838{
    39     StringBuilder result;
    40     switch (m_direction) {
    41         case ReflectionBelow:
    42             result.appendLiteral("below ");
    43             break;
    44         case ReflectionAbove:
    45             result.appendLiteral("above ");
    46             break;
    47         case ReflectionLeft:
    48             result.appendLiteral("left ");
    49             break;
    50         case ReflectionRight:
    51             result.appendLiteral("right ");
    52             break;
    53         default:
    54             break;
    55     }
     39    if (m_mask)
     40        return m_direction->cssText() + ' ' + m_offset->cssText() + ' ' + m_mask->cssText();
     41    return m_direction->cssText() + ' ' + m_offset->cssText();
     42}
    5643
    57     result.append(m_offset->cssText());
    58     result.append(' ');
     44#if ENABLE(CSS_VARIABLES)
     45String CSSReflectValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
     46{
    5947    if (m_mask)
    60         result.append(m_mask->cssText());
    61     return result.toString();
     48        return m_direction->customSerializeResolvingVariables(variables) + ' ' + m_offset->customSerializeResolvingVariables(variables) + ' ' + m_mask->serializeResolvingVariables(variables);
     49    return m_direction->customSerializeResolvingVariables(variables) + ' ' + m_offset->customSerializeResolvingVariables(variables);
    6250}
     51#endif
    6352
    6453void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
  • trunk/Source/WebCore/css/CSSReflectValue.h

    r124768 r140642  
    3838class CSSReflectValue : public CSSValue {
    3939public:
    40     static PassRefPtr<CSSReflectValue> create(CSSReflectionDirection direction,
     40    static PassRefPtr<CSSReflectValue> create(PassRefPtr<CSSPrimitiveValue> direction,
    4141        PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
    4242    {
     
    4444    }
    4545
    46     CSSReflectionDirection direction() const { return m_direction; }
     46    CSSPrimitiveValue* direction() const { return m_direction.get(); }
    4747    CSSPrimitiveValue* offset() const { return m_offset.get(); }
    4848    CSSValue* mask() const { return m_mask.get(); }
    4949
    5050    String customCssText() const;
     51#if ENABLE(CSS_VARIABLES)
     52    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
     53#endif
    5154
    5255    void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
     
    5558
    5659private:
    57     CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
     60    CSSReflectValue(PassRefPtr<CSSPrimitiveValue> direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
    5861        : CSSValue(ReflectClass)
    5962        , m_direction(direction)
     
    6366    }
    6467
    65     CSSReflectionDirection m_direction;
     68    RefPtr<CSSPrimitiveValue> m_direction;
    6669    RefPtr<CSSPrimitiveValue> m_offset;
    6770    RefPtr<CSSValue> m_mask;
  • trunk/Source/WebCore/css/CSSValue.cpp

    r128762 r140642  
    375375    case PrimitiveClass:
    376376        return static_cast<const CSSPrimitiveValue*>(this)->customSerializeResolvingVariables(variables);
     377    case ReflectClass:
     378        return static_cast<const CSSReflectValue*>(this)->customSerializeResolvingVariables(variables);
    377379    case ValueListClass:
    378380        return static_cast<const CSSValueList*>(this)->customSerializeResolvingVariables(variables);
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r140531 r140642  
    29582958        return static_cast<CSSCalcValue*>(value)->hasVariableReference();
    29592959
     2960    if (value->isReflectValue()) {
     2961        CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value);
     2962        CSSPrimitiveValue* direction = reflectValue->direction();
     2963        CSSPrimitiveValue* offset = reflectValue->offset();
     2964        CSSValue* mask = reflectValue->mask();
     2965        return (direction && hasVariableReference(direction)) || (offset && hasVariableReference(offset)) || (mask && hasVariableReference(mask));
     2966    }
     2967
    29602968    for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
    29612969        if (hasVariableReference(i.value()))
     
    33953403        CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value);
    33963404        RefPtr<StyleReflection> reflection = StyleReflection::create();
    3397         reflection->setDirection(reflectValue->direction());
     3405        reflection->setDirection(*reflectValue->direction());
    33983406        if (reflectValue->offset())
    33993407            reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor));
Note: See TracChangeset for help on using the changeset viewer.