background-size: X treated as background-size: X X, not background-size: X auto
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Oct 2009 22:41:45 +0000 (22:41 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Oct 2009 22:41:45 +0000 (22:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=28440

Reviewed by Beth Dakin.

WebCore:

Updated fast/backgrounds/size/resources/parsing-background-size-values.js
and fast/backgrounds/size/resources/parsing-inherit.js

Reinstated -webkit-background-size and kept its behavior of filling in
the second value with the first one; and changed background-size to have
the behavior of filling in the second value with 'auto'.

* css/CSSComputedStyleDeclaration.cpp:
(computedProperties): Re-added CSSPropertyWebkitBackgroundSize.
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Ditto.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Ditto.
(WebCore::CSSParser::parseFillSize): Adapted for the new parsing rule.
(WebCore::CSSParser::parseFillProperty): Re-added
CSSPropertyWebkitBackgroundSize.
(WebCore::cssPropertyID): Removed mapping of -webkit-background-size to
background-size.
* css/CSSParser.h:
* css/CSSPropertyNames.in: Re-added -webkit-background-size.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty): Re-added
CSSPropertyWebkitBackgroundSize.

LayoutTests:

* fast/backgrounds/size/parsing-background-size-values-expected.txt:
* fast/backgrounds/size/parsing-inherit-expected.txt:
* fast/backgrounds/size/resources/parsing-background-size-values.js:
(test):
* fast/backgrounds/size/resources/parsing-inherit.js:
* platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
* platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50108 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/backgrounds/size/parsing-background-size-values-expected.txt
LayoutTests/fast/backgrounds/size/parsing-inherit-expected.txt
LayoutTests/fast/backgrounds/size/resources/parsing-background-size-values.js
LayoutTests/fast/backgrounds/size/resources/parsing-inherit.js
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSParser.cpp
WebCore/css/CSSParser.h
WebCore/css/CSSPropertyNames.in
WebCore/css/CSSStyleSelector.cpp

index e0e2190..d5b166e 100644 (file)
@@ -1,3 +1,18 @@
+2009-10-26  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        background-size: X treated as background-size: X X, not background-size: X auto
+        https://bugs.webkit.org/show_bug.cgi?id=28440
+
+        * fast/backgrounds/size/parsing-background-size-values-expected.txt:
+        * fast/backgrounds/size/parsing-inherit-expected.txt:
+        * fast/backgrounds/size/resources/parsing-background-size-values.js:
+        (test):
+        * fast/backgrounds/size/resources/parsing-inherit.js:
+        * platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
+        * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+
 2009-10-26  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Reviewed by Geoffrey Garen.
index 3f2a269..5969d19 100644 (file)
@@ -12,12 +12,15 @@ PASS test("background-size: 50px auto;") is "50px "
 PASS test("background-size: auto auto;") is " "
 PASS test("background-size: 30% 20%;") is "30% 20%"
 PASS test("background-size: 4em auto;") is "4em "
-PASS test("background-size: 5em ;") is "5em 5em"
+PASS test("background-size: 5em;") is "5em "
+PASS test("-webkit-background-size: 5em ;") is "5em 5em"
 PASS test("background-size: 100 100 100;") is null
 PASS test("background-size: coconut;") is null
 PASS test("background-size: 100px,;") is null
-PASS test("background-size: 100px, 50%;") is "100px 100px, 50% 50%"
-PASS test("background-size: 50% 100px, 2em, 100px 50%;") is "50% 100px, 2em 2em, 100px 50%"
+PASS test("background-size: 100px, 50%;") is "100px , 50% "
+PASS test("-webkit-background-size: 100px, 50%;") is "100px 100px, 50% 50%"
+PASS test("background-size: 50% 100px, 2em, 100px 50%;") is "50% 100px, 2em , 100px 50%"
+PASS test("-webkit-background-size: 50% 100px, 2em, 100px 50%;") is "50% 100px, 2em 2em, 100px 50%"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 339066d..c90a14b 100644 (file)
@@ -12,7 +12,8 @@ PASS test("background-size: 50px auto;") is "50px auto"
 PASS test("background-size: auto auto;") is "auto auto"
 PASS test("background-size: 30% 20%;") is "30% 20%"
 PASS test("background-size: 4em auto;") is "64px auto"
-PASS test("background-size: 5em ;") is "80px 80px"
+PASS test("background-size: 5em ;") is "80px auto"
+PASS test("-webkit-background-size: 5em ;") is "80px 80px"
 PASS test("background-size: 100 100 100;") is "auto auto"
 PASS test("background-size: coconut;") is "auto auto"
 PASS successfullyParsed is true
index dce3c00..e2fcf04 100644 (file)
@@ -6,7 +6,7 @@ function test(value)
     div.setAttribute("style", value);
     document.body.appendChild(div);
     
-    var result = div.style.getPropertyValue("background-size");
+    var result = div.style.getPropertyValue(value.substring(0, value.indexOf(":")));
     document.body.removeChild(div);
     return result;
 }
@@ -20,13 +20,16 @@ shouldBe('test("background-size: 50px auto;")', '"50px "');
 shouldBe('test("background-size: auto auto;")', '" "');
 shouldBe('test("background-size: 30% 20%;")', '"30% 20%"');
 shouldBe('test("background-size: 4em auto;")', '"4em "');
-shouldBe('test("background-size: 5em ;")', '"5em 5em"');
+shouldBe('test("background-size: 5em;")', '"5em "');
+shouldBe('test("-webkit-background-size: 5em ;")', '"5em 5em"');
 
 shouldBe('test("background-size: 100 100 100;")', 'null');
 shouldBe('test("background-size: coconut;")', 'null');
 
 shouldBe('test("background-size: 100px,;")', 'null');
-shouldBe('test("background-size: 100px, 50%;")', '"100px 100px, 50% 50%"');
-shouldBe('test("background-size: 50% 100px, 2em, 100px 50%;")', '"50% 100px, 2em 2em, 100px 50%"');
+shouldBe('test("background-size: 100px, 50%;")', '"100px , 50% "');
+shouldBe('test("-webkit-background-size: 100px, 50%;")', '"100px 100px, 50% 50%"');
+shouldBe('test("background-size: 50% 100px, 2em, 100px 50%;")', '"50% 100px, 2em , 100px 50%"');
+shouldBe('test("-webkit-background-size: 50% 100px, 2em, 100px 50%;")', '"50% 100px, 2em 2em, 100px 50%"');
 
 var successfullyParsed = true;
index 1dacc31..66e71de 100644 (file)
@@ -24,7 +24,8 @@ shouldBe('test("background-size: 50px auto;")', '"50px auto"');
 shouldBe('test("background-size: auto auto;")', '"auto auto"');
 shouldBe('test("background-size: 30% 20%;")', '"30% 20%"');
 shouldBe('test("background-size: 4em auto;")', '"64px auto"');
-shouldBe('test("background-size: 5em ;")', '"80px 80px"');
+shouldBe('test("background-size: 5em ;")', '"80px auto"');
+shouldBe('test("-webkit-background-size: 5em ;")', '"80px 80px"');
 
 shouldBe('test("background-size: 100 100 100;")', '"auto auto"');
 shouldBe('test("background-size: coconut;")', '"auto auto"');
index db70179..5fddcd2 100644 (file)
@@ -105,6 +105,7 @@ zoom: 1;
 -webkit-background-clip: border-box;
 -webkit-background-composite: source-over;
 -webkit-background-origin: padding-box;
+-webkit-background-size: auto auto;
 -webkit-border-fit: border;
 -webkit-border-horizontal-spacing: 0px;
 -webkit-border-image: none;
index ca5ae06..09b1c92 100644 (file)
@@ -104,6 +104,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     -webkit-background-clip: border-box
     -webkit-background-composite: source-over
     -webkit-background-origin: padding-box
+    -webkit-background-size: auto auto
     -webkit-border-fit: border
     -webkit-border-horizontal-spacing: 0px
     -webkit-border-image: none
index 134a499..da50af4 100644 (file)
@@ -1,3 +1,33 @@
+2009-10-26  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        background-size: X treated as background-size: X X, not background-size: X auto
+        https://bugs.webkit.org/show_bug.cgi?id=28440
+
+        Updated fast/backgrounds/size/resources/parsing-background-size-values.js
+        and fast/backgrounds/size/resources/parsing-inherit.js
+
+        Reinstated -webkit-background-size and kept its behavior of filling in
+        the second value with the first one; and changed background-size to have
+        the behavior of filling in the second value with 'auto'.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (computedProperties): Re-added CSSPropertyWebkitBackgroundSize.
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Ditto.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue): Ditto.
+        (WebCore::CSSParser::parseFillSize): Adapted for the new parsing rule.
+        (WebCore::CSSParser::parseFillProperty): Re-added
+        CSSPropertyWebkitBackgroundSize.
+        (WebCore::cssPropertyID): Removed mapping of -webkit-background-size to
+        background-size.
+        * css/CSSParser.h:
+        * css/CSSPropertyNames.in: Re-added -webkit-background-size.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty): Re-added
+        CSSPropertyWebkitBackgroundSize.
+
 2009-10-26  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by Eric Seidel.
index 793ef81..b8769f9 100644 (file)
@@ -157,6 +157,7 @@ static const int computedProperties[] = {
     CSSPropertyWebkitBackgroundClip,
     CSSPropertyWebkitBackgroundComposite,
     CSSPropertyWebkitBackgroundOrigin,
+    CSSPropertyWebkitBackgroundSize,
     CSSPropertyWebkitBorderFit,
     CSSPropertyWebkitBorderHorizontalSpacing,
     CSSPropertyWebkitBorderImage,
@@ -679,7 +680,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             if (style->backgroundImage())
                 return style->backgroundImage()->cssValue();
             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
-        case CSSPropertyBackgroundSize: {
+        case CSSPropertyBackgroundSize:
+        case CSSPropertyWebkitBackgroundSize: {
             EFillSizeType size = style->backgroundSizeType();
             if (size == Contain)
                 return CSSPrimitiveValue::createIdentifier(CSSValueContain);
index 4299cf0..6024a5b 100644 (file)
@@ -873,6 +873,7 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSSPropertyBackgroundPositionX:
     case CSSPropertyBackgroundPositionY:
     case CSSPropertyBackgroundSize:
+    case CSSPropertyWebkitBackgroundSize:
     case CSSPropertyBackgroundRepeat:
     case CSSPropertyBackgroundRepeatX:
     case CSSPropertyBackgroundRepeatY:
@@ -2329,7 +2330,7 @@ void CSSParser::parseFillRepeat(RefPtr<CSSValue>& value1, RefPtr<CSSValue>& valu
     }
 }
 
-PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
+PassRefPtr<CSSValue> CSSParser::parseFillSize(int propId, bool& allowComma)
 {
     allowComma = true;
     CSSParserValue* value = m_valueList->current();
@@ -2338,7 +2339,7 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
         return CSSPrimitiveValue::createIdentifier(value->id);
 
     RefPtr<CSSPrimitiveValue> parsedValue1;
-    
+
     if (value->id == CSSValueAuto)
         parsedValue1 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
     else {
@@ -2346,8 +2347,9 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
             return 0;
         parsedValue1 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
     }
-    
-    RefPtr<CSSPrimitiveValue> parsedValue2 = parsedValue1;
+
+    CSSPropertyID property = static_cast<CSSPropertyID>(propId);
+    RefPtr<CSSPrimitiveValue> parsedValue2;
     if ((value = m_valueList->next())) {
         if (value->id == CSSValueAuto)
             parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
@@ -2359,7 +2361,13 @@ PassRefPtr<CSSValue> CSSParser::parseFillSize(bool& allowComma)
             parsedValue2 = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes)value->unit);
         }
     }
-    
+    if (!parsedValue2) {
+        if (property == CSSPropertyWebkitBackgroundSize || property == CSSPropertyWebkitMaskSize)
+            parsedValue2 = parsedValue1;
+        else
+            parsedValue2 = CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_UNKNOWN);
+    }
+
     return CSSPrimitiveValue::create(Pair::create(parsedValue1.release(), parsedValue2.release()));
 }
 
@@ -2478,8 +2486,9 @@ bool CSSParser::parseFillProperty(int propId, int& propId1, int& propId2,
                     // parseFillRepeat advances the m_valueList pointer
                     break;
                 case CSSPropertyBackgroundSize:
+                case CSSPropertyWebkitBackgroundSize:
                 case CSSPropertyWebkitMaskSize: {
-                    currValue = parseFillSize(allowComma);
+                    currValue = parseFillSize(propId, allowComma);
                     if (currValue)
                         m_valueList->next();
                     break;
@@ -5194,11 +5203,6 @@ static int cssPropertyID(const UChar* propertyName, unsigned length)
                 const char* const opacity = "opacity";
                 name = opacity;
                 length = strlen(opacity);
-            } else if (strcmp(buffer, "-webkit-background-size") == 0) {
-                // CSS Backgrounds/Borders.  -webkit-background-size worked in Safari 4 and earlier.
-                const char* const backgroundSize = "background-size";
-                name = backgroundSize;
-                length = strlen(backgroundSize);
             } else if (hasPrefix(buffer + 7, length - 7, "-border-")) {
                 // -webkit-border-*-*-radius worked in Safari 4 and earlier. -webkit-border-radius syntax
                 // differs from border-radius, so it is remains as a distinct property.
index 1a156da..6d1bb32 100644 (file)
@@ -83,7 +83,7 @@ namespace WebCore {
         PassRefPtr<CSSValue> parseFillPositionXY(bool& xFound, bool& yFound);
         void parseFillPosition(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
         void parseFillRepeat(RefPtr<CSSValue>&, RefPtr<CSSValue>&);
-        PassRefPtr<CSSValue> parseFillSize(bool &allowComma);
+        PassRefPtr<CSSValue> parseFillSize(int propId, bool &allowComma);
         
         bool parseFillProperty(int propId, int& propId1, int& propId2, RefPtr<CSSValue>&, RefPtr<CSSValue>&);
         bool parseFillShorthand(int propId, const int* properties, int numProperties, bool important);
index 5ef6605..48a18e7 100644 (file)
@@ -160,6 +160,10 @@ zoom
 -webkit-background-clip
 -webkit-background-composite
 -webkit-background-origin
+# -webkit-background-size differs from background-size only in the interpretation of
+# a single value: -webkit-background-size: l; is equivalent to background-size: l l;
+# whereas background-size: l; is equivalent to background-size: l auto;
+-webkit-background-size
 -webkit-binding
 -webkit-border-fit
 -webkit-border-horizontal-spacing
index 181e480..40627cf 100644 (file)
@@ -2961,6 +2961,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         HANDLE_BACKGROUND_VALUE(origin, Origin, value)
         return;
     case CSSPropertyBackgroundSize:
+    case CSSPropertyWebkitBackgroundSize:
         HANDLE_BACKGROUND_VALUE(size, Size, value)
         return;
     case CSSPropertyWebkitMaskAttachment: