Title: [140642] trunk
Revision
140642
Author
[email protected]
Date
2013-01-23 20:44:10 -0800 (Wed, 23 Jan 2013)

Log 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140641 => 140642)


--- trunk/LayoutTests/ChangeLog	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/LayoutTests/ChangeLog	2013-01-24 04:44:10 UTC (rev 140642)
@@ -1,3 +1,15 @@
+2013-01-23  Luke Macpherson   <[email protected]>
+
+        Support variables inside -webkit-box-reflect CSS property.
+        https://bugs.webkit.org/show_bug.cgi?id=106856
+
+        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.
+
 2013-01-23  Rafael Weinstein  <[email protected]>
 
         Template element should parse in XHTML just as it does in HTML

Added: trunk/LayoutTests/fast/css/variables/var-inside-box-reflect-expected.html (0 => 140642)


--- trunk/LayoutTests/fast/css/variables/var-inside-box-reflect-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/var-inside-box-reflect-expected.html	2013-01-24 04:44:10 UTC (rev 140642)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<style>
+div {
+  -webkit-box-reflect: below 5px;
+}
+</style>
+<div>This text should be reflected on the right.</div>
+</html>

Added: trunk/LayoutTests/fast/css/variables/var-inside-box-reflect.html (0 => 140642)


--- trunk/LayoutTests/fast/css/variables/var-inside-box-reflect.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/variables/var-inside-box-reflect.html	2013-01-24 04:44:10 UTC (rev 140642)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<script>
+if (window.internals)
+    internals.settings.setCSSVariablesEnabled(true);
+</script>
+<style>
+div {
+  -webkit-box-reflect: -webkit-var(a) -webkit-calc(-webkit-var(b));
+  -webkit-var-a: below;
+  -webkit-var-b: 5px;
+}
+</style>
+<div>This text should be reflected on the right.</div>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (140641 => 140642)


--- trunk/Source/WebCore/ChangeLog	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/ChangeLog	2013-01-24 04:44:10 UTC (rev 140642)
@@ -1,3 +1,42 @@
+2013-01-23  Luke Macpherson   <[email protected]>
+
+        Support variables inside -webkit-box-reflect CSS property.
+        https://bugs.webkit.org/show_bug.cgi?id=106856
+
+        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):
+
 2013-01-23  Abhishek Arya  <[email protected]>
 
         Add ASSERT_WITH_SECURITY_IMPLICATION to detect bad casts in rendering

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (140641 => 140642)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2013-01-24 04:44:10 UTC (rev 140642)
@@ -594,7 +594,23 @@
     else
         offset = zoomAdjustedPixelValue(reflection->offset().value(), style);
 
-    return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask()));
+    RefPtr<CSSPrimitiveValue> direction;
+    switch (reflection->direction()) {
+    case ReflectionBelow:
+        direction = cssValuePool().createIdentifierValue(CSSValueBelow);
+        break;
+    case ReflectionAbove:
+        direction = cssValuePool().createIdentifierValue(CSSValueAbove);
+        break;
+    case ReflectionLeft:
+        direction = cssValuePool().createIdentifierValue(CSSValueLeft);
+        break;
+    case ReflectionRight:
+        direction = cssValuePool().createIdentifierValue(CSSValueRight);
+        break;
+    }
+
+    return CSSReflectValue::create(direction.release(), offset.release(), valueForNinePieceImage(reflection->mask()));
 }
 
 static PassRefPtr<CSSValueList> createPositionListForLayer(CSSPropertyID propertyID, const FillLayer* layer, const RenderStyle* style)

Modified: trunk/Source/WebCore/css/CSSParser.cpp (140641 => 140642)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-01-24 04:44:10 UTC (rev 140642)
@@ -6214,19 +6214,18 @@
 
     // Direction comes first.
     CSSParserValue* val = m_valueList->current();
-    CSSReflectionDirection direction;
+    RefPtr<CSSPrimitiveValue> direction;
+#if ENABLE(CSS_VARIABLES)
+    if (val->unit == CSSPrimitiveValue::CSS_VARIABLE_NAME)
+        direction = createPrimitiveVariableNameValue(val);
+    else
+#endif
     switch (val->id) {
         case CSSValueAbove:
-            direction = ReflectionAbove;
-            break;
         case CSSValueBelow:
-            direction = ReflectionBelow;
-            break;
         case CSSValueLeft:
-            direction = ReflectionLeft;
-            break;
         case CSSValueRight:
-            direction = ReflectionRight;
+            direction = cssValuePool().createIdentifierValue(val->id);
             break;
         default:
             return false;
@@ -6251,7 +6250,7 @@
             return false;
     }
 
-    RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction, offset.release(), mask.release());
+    RefPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.release(), offset.release(), mask.release());
     addProperty(propId, reflectValue.release(), important);
     m_valueList->next();
     return true;

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (140641 => 140642)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2013-01-24 04:44:10 UTC (rev 140642)
@@ -32,6 +32,7 @@
 
 #include "CSSCalculationValue.h"
 #include "CSSPrimitiveValue.h"
+#include "CSSReflectionDirection.h"
 #include "ColorSpace.h"
 #include "CSSValueKeywords.h"
 #include "FontDescription.h"
@@ -141,6 +142,42 @@
     return LineClampValue();
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSReflectionDirection e)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_IDENT;
+    switch (e) {
+    case ReflectionAbove:
+        m_value.ident = CSSValueAbove;
+        break;
+    case ReflectionBelow:
+        m_value.ident = CSSValueBelow;
+        break;
+    case ReflectionLeft:
+        m_value.ident = CSSValueLeft;
+        break;
+    case ReflectionRight:
+        m_value.ident = CSSValueRight;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator CSSReflectionDirection() const
+{
+    switch (m_value.ident) {
+    case CSSValueAbove:
+        return ReflectionAbove;
+    case CSSValueBelow:
+        return ReflectionBelow;
+    case CSSValueLeft:
+        return ReflectionLeft;
+    case CSSValueRight:
+        return ReflectionRight;
+    }
+
+    ASSERT_NOT_REACHED();
+    return ReflectionBelow;
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ColumnSpan columnSpan)
     : CSSValue(PrimitiveClass)
 {
@@ -4077,6 +4114,9 @@
 
 template<int supported> Length CSSPrimitiveValue::convertToLength(RenderStyle* style, RenderStyle* rootStyle, double multiplier, bool computingFontSize)
 {
+#if ENABLE(CSS_VARIABLES)
+    ASSERT(!hasVariableReference());
+#endif
     if ((supported & (FixedIntegerConversion | FixedFloatConversion)) && isFontRelativeLength() && (!style || !rootStyle))
         return Length(Undefined);
     if ((supported & FixedIntegerConversion) && isLength())

Modified: trunk/Source/WebCore/css/CSSReflectValue.cpp (140641 => 140642)


--- trunk/Source/WebCore/css/CSSReflectValue.cpp	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSReflectValue.cpp	2013-01-24 04:44:10 UTC (rev 140642)
@@ -36,30 +36,19 @@
 
 String CSSReflectValue::customCssText() const
 {
-    StringBuilder result;
-    switch (m_direction) {
-        case ReflectionBelow:
-            result.appendLiteral("below ");
-            break;
-        case ReflectionAbove:
-            result.appendLiteral("above ");
-            break;
-        case ReflectionLeft:
-            result.appendLiteral("left ");
-            break;
-        case ReflectionRight:
-            result.appendLiteral("right ");
-            break;
-        default:
-            break;
-    }
+    if (m_mask)
+        return m_direction->cssText() + ' ' + m_offset->cssText() + ' ' + m_mask->cssText();
+    return m_direction->cssText() + ' ' + m_offset->cssText();
+}
 
-    result.append(m_offset->cssText());
-    result.append(' ');
+#if ENABLE(CSS_VARIABLES)
+String CSSReflectValue::customSerializeResolvingVariables(const HashMap<AtomicString, String>& variables) const
+{
     if (m_mask)
-        result.append(m_mask->cssText());
-    return result.toString();
+        return m_direction->customSerializeResolvingVariables(variables) + ' ' + m_offset->customSerializeResolvingVariables(variables) + ' ' + m_mask->serializeResolvingVariables(variables);
+    return m_direction->customSerializeResolvingVariables(variables) + ' ' + m_offset->customSerializeResolvingVariables(variables);
 }
+#endif
 
 void CSSReflectValue::addSubresourceStyleURLs(ListHashSet<KURL>& urls, const StyleSheetContents* styleSheet) const
 {

Modified: trunk/Source/WebCore/css/CSSReflectValue.h (140641 => 140642)


--- trunk/Source/WebCore/css/CSSReflectValue.h	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSReflectValue.h	2013-01-24 04:44:10 UTC (rev 140642)
@@ -37,24 +37,27 @@
 
 class CSSReflectValue : public CSSValue {
 public:
-    static PassRefPtr<CSSReflectValue> create(CSSReflectionDirection direction,
+    static PassRefPtr<CSSReflectValue> create(PassRefPtr<CSSPrimitiveValue> direction,
         PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
     {
         return adoptRef(new CSSReflectValue(direction, offset, mask));
     }
 
-    CSSReflectionDirection direction() const { return m_direction; }
+    CSSPrimitiveValue* direction() const { return m_direction.get(); }
     CSSPrimitiveValue* offset() const { return m_offset.get(); }
     CSSValue* mask() const { return m_mask.get(); }
 
     String customCssText() const;
+#if ENABLE(CSS_VARIABLES)
+    String customSerializeResolvingVariables(const HashMap<AtomicString, String>&) const;
+#endif
 
     void addSubresourceStyleURLs(ListHashSet<KURL>&, const StyleSheetContents*) const;
 
     void reportDescendantMemoryUsage(MemoryObjectInfo*) const;
 
 private:
-    CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
+    CSSReflectValue(PassRefPtr<CSSPrimitiveValue> direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
         : CSSValue(ReflectClass)
         , m_direction(direction)
         , m_offset(offset)
@@ -62,7 +65,7 @@
     {
     }
 
-    CSSReflectionDirection m_direction;
+    RefPtr<CSSPrimitiveValue> m_direction;
     RefPtr<CSSPrimitiveValue> m_offset;
     RefPtr<CSSValue> m_mask;
 };

Modified: trunk/Source/WebCore/css/CSSValue.cpp (140641 => 140642)


--- trunk/Source/WebCore/css/CSSValue.cpp	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2013-01-24 04:44:10 UTC (rev 140642)
@@ -374,6 +374,8 @@
     switch (classType()) {
     case PrimitiveClass:
         return static_cast<const CSSPrimitiveValue*>(this)->customSerializeResolvingVariables(variables);
+    case ReflectClass:
+        return static_cast<const CSSReflectValue*>(this)->customSerializeResolvingVariables(variables);
     case ValueListClass:
         return static_cast<const CSSValueList*>(this)->customSerializeResolvingVariables(variables);
     case WebKitCSSTransformClass:

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (140641 => 140642)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-24 04:29:04 UTC (rev 140641)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-24 04:44:10 UTC (rev 140642)
@@ -2957,6 +2957,14 @@
     if (value->isCalculationValue())
         return static_cast<CSSCalcValue*>(value)->hasVariableReference();
 
+    if (value->isReflectValue()) {
+        CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value);
+        CSSPrimitiveValue* direction = reflectValue->direction();
+        CSSPrimitiveValue* offset = reflectValue->offset();
+        CSSValue* mask = reflectValue->mask();
+        return (direction && hasVariableReference(direction)) || (offset && hasVariableReference(offset)) || (mask && hasVariableReference(mask));
+    }
+
     for (CSSValueListIterator i = value; i.hasMore(); i.advance()) {
         if (hasVariableReference(i.value()))
             return true;
@@ -3394,7 +3402,7 @@
 
         CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value);
         RefPtr<StyleReflection> reflection = StyleReflection::create();
-        reflection->setDirection(reflectValue->direction());
+        reflection->setDirection(*reflectValue->direction());
         if (reflectValue->offset())
             reflection->setOffset(reflectValue->offset()->convertToLength<FixedIntegerConversion | PercentConversion | CalculatedConversion>(style(), m_rootElementStyle, zoomFactor));
         NinePieceImage mask;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to