Title: [94420] trunk
Revision
94420
Author
hy...@apple.com
Date
2011-09-02 09:00:23 -0700 (Fri, 02 Sep 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=67431
        
Implement border-image-repeat. Similar to how border-image-slice was implemented, the parsing of the two
repeat values has been moved into separate functions. The value is represented as a Pair (similar to how we
handle border radius).

Reviewed by Beth Dakin.

Added fast/borders/border-image-repeat.html.

Source/WebCore: 

* css/CSSBorderImageValue.cpp:
(WebCore::CSSBorderImageValue::CSSBorderImageValue):
(WebCore::CSSBorderImageValue::cssText):
* css/CSSBorderImageValue.h:
(WebCore::CSSBorderImageValue::create):
Modified the CSSBorderImageValue (you're living on borrowed time, my friend!) to have a CSSValue that
contains a Pair.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForRepeatRule):
(WebCore::valueForNinePieceImageRepeat):
(WebCore::valueForNinePieceImage):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
Add support for the new properties. Break out the value retrieval for the image repeat rules into its
own function, valueForNinePieceImageRepeat.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::BorderImageParseContext::BorderImageParseContext):
(WebCore::BorderImageParseContext::allowRepeat):
(WebCore::BorderImageParseContext::commitSlice):
(WebCore::BorderImageParseContext::commitSlash):
(WebCore::BorderImageParseContext::commitWidth):
(WebCore::BorderImageParseContext::commitRepeat):
(WebCore::BorderImageParseContext::commitBorderImage):
(WebCore::CSSParser::parseBorderImage):
Modified the parsing of border image to call into parseBorderImageRepeat for the repeat values.

(WebCore::isBorderImageRepeatKeyword):
(WebCore::CSSParser::parseBorderImageRepeat):
The new parsing code for border-image-repeat is here. It will build up a CSSValue containing a Pair and
return the result.

* css/CSSParser.h:
* css/CSSPropertyNames.in:
Add the new properties.

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
(WebCore::CSSStyleSelector::mapNinePieceImage):
(WebCore::CSSStyleSelector::mapNinePieceImageRepeat):
* css/CSSStyleSelector.h:
The mapping into the front end is done the same way as border-image-slice. Factor out the image repeat rules
portion into mapNinePieceImageRepeat.

* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):
* platform/graphics/Image.h:
Add the new 'space' value as a valid image tiling rule. It's not yet supported and, like the 'round' value,
is just mapped to 'repeat' for now.
        
* rendering/style/NinePieceImage.h:
(WebCore::NinePieceImage::copyRepeatFrom):
Helper for copying only the repeat rules from another NinePieceImage.

LayoutTests: 

* fast/borders/border-image-repeat.html: Added.
* fast/css/getComputedStyle/computed-style-expected.txt:
* fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* platform/mac/fast/borders/border-image-repeat-expected.png: Added.
* platform/mac/fast/borders/border-image-repeat-expected.txt: Added.
* svg/css/getComputedStyle-basic-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94419 => 94420)


--- trunk/LayoutTests/ChangeLog	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/LayoutTests/ChangeLog	2011-09-02 16:00:23 UTC (rev 94420)
@@ -1,3 +1,22 @@
+2011-09-01  David Hyatt  <hy...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=67431
+        
+        Implement border-image-repeat. Similar to how border-image-slice was implemented, the parsing of the two
+        repeat values has been moved into separate functions. The value is represented as a Pair (similar to how we
+        handle border radius).
+
+        Reviewed by Beth Dakin.
+
+        Added fast/borders/border-image-repeat.html.
+
+        * fast/borders/border-image-repeat.html: Added.
+        * fast/css/getComputedStyle/computed-style-expected.txt:
+        * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * platform/mac/fast/borders/border-image-repeat-expected.png: Added.
+        * platform/mac/fast/borders/border-image-repeat-expected.txt: Added.
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2011-09-02  Jarred Nicholls  <jar...@sencha.com>
 
         [Qt] number input not rendering spin buttons properly in RTL direction

Added: trunk/LayoutTests/fast/borders/border-image-repeat.html (0 => 94420)


--- trunk/LayoutTests/fast/borders/border-image-repeat.html	                        (rev 0)
+++ trunk/LayoutTests/fast/borders/border-image-repeat.html	2011-09-02 16:00:23 UTC (rev 94420)
@@ -0,0 +1,40 @@
+<html>
+<head>
+    <style>
+        div {
+            border-width: 21px 30px 30px 21px;
+            width: 75px;
+            height: 75px;
+            margin: 10px;
+            display: inline-block;
+        }
+
+        div.rr {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21;
+            border-image-repeat: repeat repeat;
+        }
+
+        div.rs {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21;
+            border-image-repeat: repeat stretch;
+        }
+
+        div.sr {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21;
+            border-image-repeat: stretch repeat;
+        }
+
+        div.ss {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21 repeat repeat;
+            border-image-repeat: initial
+        }
+    </style>
+</head>
+<body>
+    <div class="rr"></div>
+    <div class="rs"></div>
+    <br>
+    <div class="sr"></div>
+    <div class="ss"></div>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt (94419 => 94420)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt	2011-09-02 16:00:23 UTC (rev 94420)
@@ -14,6 +14,7 @@
 border-bottom-style: none;
 border-bottom-width: 0px;
 border-collapse: separate;
+border-image-repeat: stretch stretch;
 border-image-slice: 100%;
 border-image-source: none;
 border-left-color: rgb(0, 0, 0);
@@ -156,6 +157,7 @@
 -webkit-marquee-style: scroll;
 -webkit-mask-attachment: scroll;
 -webkit-mask-box-image: none;
+-webkit-mask-box-image-repeat: stretch stretch;
 -webkit-mask-box-image-slice: 100%;
 -webkit-mask-box-image-source: none;
 -webkit-mask-clip: border-box;

Modified: trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt (94419 => 94420)


--- trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt	2011-09-02 16:00:23 UTC (rev 94420)
@@ -13,6 +13,7 @@
     border-bottom-style: none
     border-bottom-width: 0px
     border-collapse: separate
+    border-image-repeat: stretch stretch
     border-image-slice: 100%
     border-image-source: none
     border-left-color: rgb(0, 0, 0)
@@ -155,6 +156,7 @@
     -webkit-marquee-style: scroll
     -webkit-mask-attachment: scroll
     -webkit-mask-box-image: none
+    -webkit-mask-box-image-repeat: stretch stretch
     -webkit-mask-box-image-slice: 100%
     -webkit-mask-box-image-source: none
     -webkit-mask-clip: border-box

Added: trunk/LayoutTests/platform/mac/fast/borders/border-image-repeat-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/borders/border-image-repeat-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/borders/border-image-repeat-expected.txt (0 => 94420)


--- trunk/LayoutTests/platform/mac/fast/borders/border-image-repeat-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/borders/border-image-repeat-expected.txt	2011-09-02 16:00:23 UTC (rev 94420)
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (10,10) size 126x126 [border: (21px none #000000) (30px none #000000) (21px none #000000)]
+      RenderText {#text} at (146,132) size 4x18
+        text run at (146,132) width 4: " "
+      RenderBlock {DIV} at (160,10) size 126x126 [border: (21px none #000000) (30px none #000000) (21px none #000000)]
+      RenderText {#text} at (296,132) size 4x18
+        text run at (296,132) width 4: " "
+      RenderBR {BR} at (0,0) size 0x0
+      RenderBlock {DIV} at (10,160) size 126x126 [border: (21px none #000000) (30px none #000000) (21px none #000000)]
+      RenderText {#text} at (146,282) size 4x18
+        text run at (146,282) width 4: " "
+      RenderBlock {DIV} at (160,160) size 126x126 [border: (21px none #000000) (30px none #000000) (21px none #000000)]
+      RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt (94419 => 94420)


--- trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt	2011-09-02 16:00:23 UTC (rev 94420)
@@ -26,6 +26,8 @@
 rect: style.getPropertyCSSValue(border-bottom-width) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(border-collapse) : separate
 rect: style.getPropertyCSSValue(border-collapse) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(border-image-repeat) : stretch stretch
+rect: style.getPropertyCSSValue(border-image-repeat) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(border-image-slice) : 100%
 rect: style.getPropertyCSSValue(border-image-slice) : [object CSSValue]
 rect: style.getPropertyValue(border-image-source) : none
@@ -310,6 +312,8 @@
 rect: style.getPropertyCSSValue(-webkit-mask-attachment) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-mask-box-image) : none
 rect: style.getPropertyCSSValue(-webkit-mask-box-image) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-mask-box-image-repeat) : stretch stretch
+rect: style.getPropertyCSSValue(-webkit-mask-box-image-repeat) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-mask-box-image-slice) : 100%
 rect: style.getPropertyCSSValue(-webkit-mask-box-image-slice) : [object CSSValue]
 rect: style.getPropertyValue(-webkit-mask-box-image-source) : none
@@ -492,6 +496,8 @@
 g: style.getPropertyCSSValue(border-bottom-width) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(border-collapse) : separate
 g: style.getPropertyCSSValue(border-collapse) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(border-image-repeat) : stretch stretch
+g: style.getPropertyCSSValue(border-image-repeat) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(border-image-slice) : 100%
 g: style.getPropertyCSSValue(border-image-slice) : [object CSSValue]
 g: style.getPropertyValue(border-image-source) : none
@@ -776,6 +782,8 @@
 g: style.getPropertyCSSValue(-webkit-mask-attachment) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-mask-box-image) : none
 g: style.getPropertyCSSValue(-webkit-mask-box-image) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-mask-box-image-repeat) : stretch stretch
+g: style.getPropertyCSSValue(-webkit-mask-box-image-repeat) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-mask-box-image-slice) : 100%
 g: style.getPropertyCSSValue(-webkit-mask-box-image-slice) : [object CSSValue]
 g: style.getPropertyValue(-webkit-mask-box-image-source) : none

Modified: trunk/Source/WebCore/ChangeLog (94419 => 94420)


--- trunk/Source/WebCore/ChangeLog	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/ChangeLog	2011-09-02 16:00:23 UTC (rev 94420)
@@ -1,3 +1,70 @@
+2011-09-01  David Hyatt  <hy...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=67431
+        
+        Implement border-image-repeat. Similar to how border-image-slice was implemented, the parsing of the two
+        repeat values has been moved into separate functions. The value is represented as a Pair (similar to how we
+        handle border radius).
+
+        Reviewed by Beth Dakin.
+
+        Added fast/borders/border-image-repeat.html.
+
+        * css/CSSBorderImageValue.cpp:
+        (WebCore::CSSBorderImageValue::CSSBorderImageValue):
+        (WebCore::CSSBorderImageValue::cssText):
+        * css/CSSBorderImageValue.h:
+        (WebCore::CSSBorderImageValue::create):
+        Modified the CSSBorderImageValue (you're living on borrowed time, my friend!) to have a CSSValue that
+        contains a Pair.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::valueForRepeatRule):
+        (WebCore::valueForNinePieceImageRepeat):
+        (WebCore::valueForNinePieceImage):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        Add support for the new properties. Break out the value retrieval for the image repeat rules into its
+        own function, valueForNinePieceImageRepeat.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::BorderImageParseContext::BorderImageParseContext):
+        (WebCore::BorderImageParseContext::allowRepeat):
+        (WebCore::BorderImageParseContext::commitSlice):
+        (WebCore::BorderImageParseContext::commitSlash):
+        (WebCore::BorderImageParseContext::commitWidth):
+        (WebCore::BorderImageParseContext::commitRepeat):
+        (WebCore::BorderImageParseContext::commitBorderImage):
+        (WebCore::CSSParser::parseBorderImage):
+        Modified the parsing of border image to call into parseBorderImageRepeat for the repeat values.
+
+        (WebCore::isBorderImageRepeatKeyword):
+        (WebCore::CSSParser::parseBorderImageRepeat):
+        The new parsing code for border-image-repeat is here. It will build up a CSSValue containing a Pair and
+        return the result.
+
+        * css/CSSParser.h:
+        * css/CSSPropertyNames.in:
+        Add the new properties.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        (WebCore::CSSStyleSelector::mapNinePieceImage):
+        (WebCore::CSSStyleSelector::mapNinePieceImageRepeat):
+        * css/CSSStyleSelector.h:
+        The mapping into the front end is done the same way as border-image-slice. Factor out the image repeat rules
+        portion into mapNinePieceImageRepeat.
+
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::drawTiled):
+        * platform/graphics/Image.h:
+        Add the new 'space' value as a valid image tiling rule. It's not yet supported and, like the 'round' value,
+        is just mapped to 'repeat' for now.
+        
+        * rendering/style/NinePieceImage.h:
+        (WebCore::NinePieceImage::copyRepeatFrom):
+        Helper for copying only the repeat rules from another NinePieceImage.
+
 2011-09-02  Jarred Nicholls  <jar...@sencha.com>
 
         [Qt] number input not rendering spin buttons properly in RTL direction

Modified: trunk/Source/WebCore/css/CSSBorderImageValue.cpp (94419 => 94420)


--- trunk/Source/WebCore/css/CSSBorderImageValue.cpp	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSBorderImageValue.cpp	2011-09-02 16:00:23 UTC (rev 94420)
@@ -26,11 +26,10 @@
 
 namespace WebCore {
 
-CSSBorderImageValue::CSSBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue> slice, int horizontalRule, int verticalRule)
+CSSBorderImageValue::CSSBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue> slice, PassRefPtr<CSSValue> repeat)
     : m_image(image)
     , m_slice(slice)
-    , m_horizontalSizeRule(horizontalRule)
-    , m_verticalSizeRule(verticalRule)
+    , m_repeat(repeat)
 {
 }
 
@@ -49,9 +48,7 @@
 
     // Now the keywords.
     text += " ";
-    text += CSSPrimitiveValue::createIdentifier(m_horizontalSizeRule)->cssText();
-    text += " ";
-    text += CSSPrimitiveValue::createIdentifier(m_verticalSizeRule)->cssText();
+    text += m_repeat->cssText();
 
     return text;
 }

Modified: trunk/Source/WebCore/css/CSSBorderImageValue.h (94419 => 94420)


--- trunk/Source/WebCore/css/CSSBorderImageValue.h	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSBorderImageValue.h	2011-09-02 16:00:23 UTC (rev 94420)
@@ -31,9 +31,9 @@
 
 class CSSBorderImageValue : public CSSValue {
 public:
-    static PassRefPtr<CSSBorderImageValue> create(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue> slice, int horizontalRule, int verticalRule)
+    static PassRefPtr<CSSBorderImageValue> create(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue> slice, PassRefPtr<CSSValue> repeat)
     {
-        return adoptRef(new CSSBorderImageValue(image, slice, horizontalRule, verticalRule));
+        return adoptRef(new CSSBorderImageValue(image, slice, repeat));
     }
     virtual ~CSSBorderImageValue();
 
@@ -51,11 +51,10 @@
     RefPtr<CSSBorderImageSliceValue> m_slice;
 
     // Values for how to handle the scaling/stretching/tiling of the image slices.
-    int m_horizontalSizeRule; // Rule for how to adjust the widths of the top/middle/bottom
-    int m_verticalSizeRule; // Rule for how to adjust the heights of the left/middle/right
+    RefPtr<CSSValue> m_repeat;
 
 private:
-    CSSBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue>, int horizontalRule, int verticalRule);
+    CSSBorderImageValue(PassRefPtr<CSSValue> image, PassRefPtr<CSSBorderImageSliceValue>, PassRefPtr<CSSValue> repeat);
     virtual bool isBorderImageValue() const { return true; }
 };
 

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (94419 => 94420)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-09-02 16:00:23 UTC (rev 94420)
@@ -44,6 +44,7 @@
 #include "ExceptionCode.h"
 #include "FontFeatureSettings.h"
 #include "FontFeatureValue.h"
+#include "Pair.h"
 #include "Rect.h"
 #include "RenderBox.h"
 #include "RenderLayer.h"
@@ -73,6 +74,7 @@
     CSSPropertyBorderBottomStyle,
     CSSPropertyBorderBottomWidth,
     CSSPropertyBorderCollapse,
+    CSSPropertyBorderImageRepeat,
     CSSPropertyBorderImageSlice,
     CSSPropertyBorderImageSource,
     CSSPropertyBorderLeftColor,
@@ -225,6 +227,7 @@
     CSSPropertyWebkitMarqueeStyle,
     CSSPropertyWebkitMaskAttachment,
     CSSPropertyWebkitMaskBoxImage,
+    CSSPropertyWebkitMaskBoxImageRepeat,
     CSSPropertyWebkitMaskBoxImageSlice,
     CSSPropertyWebkitMaskBoxImageSource,
     CSSPropertyWebkitMaskClip,
@@ -316,12 +319,13 @@
             return CSSValueRepeat;
         case RoundImageRule:
             return CSSValueRound;
+        case SpaceImageRule:
+            return CSSValueSpace;
         default:
             return CSSValueStretch;
     }
 }
 
-
 static PassRefPtr<CSSBorderImageSliceValue> valueForNinePieceImageSlice(const NinePieceImage& image, CSSPrimitiveValueCache* primitiveValueCache)
 {
     // Create the slices.
@@ -358,6 +362,12 @@
     return CSSBorderImageSliceValue::create(rect, image.fill());
 }
 
+static PassRefPtr<CSSValue> valueForNinePieceImageRepeat(const NinePieceImage& image, CSSPrimitiveValueCache* primitiveValueCache)
+{
+    return primitiveValueCache->createValue(Pair::create(primitiveValueCache->createIdentifierValue(valueForRepeatRule(image.horizontalRule())),
+        primitiveValueCache->createIdentifierValue(valueForRepeatRule(image.verticalRule()))));
+}
+
 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image, CSSPrimitiveValueCache* primitiveValueCache)
 {
     if (!image.hasImage())
@@ -370,7 +380,11 @@
     
     // Create the slices.
     RefPtr<CSSBorderImageSliceValue> slice = valueForNinePieceImageSlice(image, primitiveValueCache);
-    return CSSBorderImageValue::create(imageValue, slice, valueForRepeatRule(image.horizontalRule()), valueForRepeatRule(image.verticalRule()));
+    
+    // Create the repeat rules.
+    RefPtr<CSSValue> repeat = valueForNinePieceImageRepeat(image, primitiveValueCache);
+
+    return CSSBorderImageValue::create(imageValue, slice, repeat);
 }
 
 inline static PassRefPtr<CSSPrimitiveValue> zoomAdjustedPixelValue(int value, const RenderStyle* style, CSSPrimitiveValueCache* primitiveValueCache)
@@ -1595,10 +1609,14 @@
             return primitiveValueCache->createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
         case CSSPropertyWebkitBorderImage:
             return valueForNinePieceImage(style->borderImage(), primitiveValueCache);
+        case CSSPropertyBorderImageRepeat:
+            return valueForNinePieceImageRepeat(style->borderImage(), primitiveValueCache);
         case CSSPropertyBorderImageSlice:
             return valueForNinePieceImageSlice(style->borderImage(), primitiveValueCache);
         case CSSPropertyWebkitMaskBoxImage:
             return valueForNinePieceImage(style->maskBoxImage(), primitiveValueCache);
+        case CSSPropertyWebkitMaskBoxImageRepeat:
+            return valueForNinePieceImageRepeat(style->maskBoxImage(), primitiveValueCache);
         case CSSPropertyWebkitMaskBoxImageSlice:
             return valueForNinePieceImageSlice(style->maskBoxImage(), primitiveValueCache);
         case CSSPropertyWebkitMaskBoxImageSource:

Modified: trunk/Source/WebCore/css/CSSParser.cpp (94419 => 94420)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-09-02 16:00:23 UTC (rev 94420)
@@ -1451,6 +1451,15 @@
         }
         break;
     }
+    case CSSPropertyBorderImageRepeat:
+    case CSSPropertyWebkitMaskBoxImageRepeat: {
+        RefPtr<CSSValue> result;
+        if (parseBorderImageRepeat(result)) {
+            addProperty(propId, result, important);
+            return true;
+        }
+        break;
+    }
     case CSSPropertyBorderImageSlice:
     case CSSPropertyWebkitMaskBoxImageSlice: {
         RefPtr<CSSBorderImageSliceValue> result;
@@ -5129,27 +5138,25 @@
     , m_allowBreak(false)
     , m_allowSlash(false)
     , m_allowWidth(false)
-    , m_allowRule(false)
+    , m_allowRepeat(false)
     , m_borderTop(0)
     , m_borderRight(0)
     , m_borderBottom(0)
     , m_borderLeft(0)
-    , m_horizontalRule(0)
-    , m_verticalRule(0)
     {}
 
     bool allowBreak() const { return m_allowBreak; }
     bool allowSlash() const { return m_allowSlash; }
     bool allowWidth() const { return m_allowWidth; }
-    bool allowRule() const { return m_allowRule; }
+    bool allowRepeat() const { return m_allowRepeat; }
 
     void commitImage(PassRefPtr<CSSValue> image) { m_image = image; }
     void commitSlice(PassRefPtr<CSSBorderImageSliceValue> slice)
     {
         m_slice = slice;
-        m_allowBreak = m_allowSlash = m_allowRule = true;
+        m_allowBreak = m_allowSlash = m_allowRepeat = true;
     }
-    void commitSlash() { m_allowBreak = m_allowSlash = false; m_allowWidth = true; }
+    void commitSlash() { m_allowBreak = m_allowSlash = m_allowRepeat = false; m_allowWidth = true; }
     void commitWidth(CSSParserValue* val)
     {
         if (!m_borderTop)
@@ -5163,27 +5170,23 @@
             m_borderLeft = val;
         }
 
-        m_allowBreak = m_allowRule = true;
+        m_allowBreak = m_allowRepeat = true;
         m_allowWidth = !m_borderLeft;
     }
-    void commitRule(int keyword)
+    void commitRepeat(PassRefPtr<CSSValue> repeat)
     {
-        if (!m_horizontalRule)
-            m_horizontalRule = keyword;
-        else if (!m_verticalRule)
-            m_verticalRule = keyword;
-        m_allowRule = !m_verticalRule;
+        m_repeat = repeat;
+        m_allowRepeat = m_allowSlash = m_allowWidth = false;
+        m_allowBreak = true;
     }
+
     PassRefPtr<CSSValue> commitBorderImage(CSSParser* p, bool important)
     {
-        // Fill in STRETCH as the default if it wasn't specified.
-        if (!m_horizontalRule)
-            m_horizontalRule = CSSValueStretch;
+        if (!m_repeat) {
+            // Fill in STRETCH as the initial value if no repeat value was specified.
+            m_repeat = m_primitiveValueCache->createValue(Pair::create(m_primitiveValueCache->createIdentifierValue(CSSValueStretch), m_primitiveValueCache->createIdentifierValue(CSSValueStretch)));
+        }
 
-        // The vertical rule should match the horizontal rule if unspecified.
-        if (!m_verticalRule)
-            m_verticalRule = m_horizontalRule;
-
         // Now we have to deal with the border widths.  The best way to deal with these is to actually put these values into a value
         // list and then make our parsing machinery do the parsing.
         if (m_borderTop) {
@@ -5202,7 +5205,7 @@
         }
 
         // Make our new border image value now.
-        return CSSBorderImageValue::create(m_image, m_slice, m_horizontalRule, m_verticalRule);
+        return CSSBorderImageValue::create(m_image, m_slice, m_repeat);
     }
     
     CSSPrimitiveValueCache* m_primitiveValueCache;
@@ -5210,7 +5213,7 @@
     bool m_allowBreak;
     bool m_allowSlash;
     bool m_allowWidth;
-    bool m_allowRule;
+    bool m_allowRepeat;
 
     RefPtr<CSSValue> m_image;
     RefPtr<CSSBorderImageSliceValue> m_slice;
@@ -5219,9 +5222,8 @@
     CSSParserValue* m_borderRight;
     CSSParserValue* m_borderBottom;
     CSSParserValue* m_borderLeft;
-
-    int m_horizontalRule;
-    int m_verticalRule;
+    
+    RefPtr<CSSValue> m_repeat;
 };
 
 bool CSSParser::parseBorderImage(int propId, bool important, RefPtr<CSSValue>& result)
@@ -5257,9 +5259,10 @@
         } else if (context.allowWidth() &&
             (val->id == CSSValueThin || val->id == CSSValueMedium || val->id == CSSValueThick || validUnit(val, FLength, m_strict))) {
             context.commitWidth(val);
-        } else if (context.allowRule() &&
-            (val->id == CSSValueStretch || val->id == CSSValueRound || val->id == CSSValueRepeat)) {
-            context.commitRule(val->id);
+        } else if (context.allowRepeat()) {
+            RefPtr<CSSValue> repeat;
+            if (parseBorderImageRepeat(repeat))
+                context.commitRepeat(repeat);
         } else {
             // Something invalid was encountered.
             return false;
@@ -5357,6 +5360,34 @@
     bool m_fill;
 };
 
+static bool isBorderImageRepeatKeyword(int id)
+{
+     return id == CSSValueStretch || id == CSSValueRepeat || id == CSSValueSpace || id == CSSValueRound;
+}
+
+bool CSSParser::parseBorderImageRepeat(RefPtr<CSSValue>& result)
+{
+    RefPtr<CSSPrimitiveValue> firstValue;
+    RefPtr<CSSPrimitiveValue> secondValue;
+    CSSParserValue* val = m_valueList->current();
+    if (isBorderImageRepeatKeyword(val->id))
+        firstValue = primitiveValueCache()->createIdentifierValue(val->id);
+    else
+        return false;
+    
+    val = m_valueList->next();
+    if (val) {
+        if (isBorderImageRepeatKeyword(val->id))
+            secondValue = primitiveValueCache()->createIdentifierValue(val->id);
+        else
+            return false;
+    } else
+        secondValue = firstValue;
+
+    result = primitiveValueCache()->createValue(Pair::create(firstValue, secondValue));
+    return true;
+}
+
 bool CSSParser::parseBorderImageSlice(int propId, RefPtr<CSSBorderImageSliceValue>& result)
 {
     BorderImageSliceParseContext context(primitiveValueCache());

Modified: trunk/Source/WebCore/css/CSSParser.h (94419 => 94420)


--- trunk/Source/WebCore/css/CSSParser.h	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSParser.h	2011-09-02 16:00:23 UTC (rev 94420)
@@ -167,6 +167,7 @@
     // CSS3 Parsing Routines (for properties specific to CSS3)
     bool parseShadow(int propId, bool important);
     bool parseBorderImage(int propId, bool important, RefPtr<CSSValue>&);
+    bool parseBorderImageRepeat(RefPtr<CSSValue>&);
     bool parseBorderImageSlice(int propId, RefPtr<CSSBorderImageSliceValue>&);
     bool parseBorderRadius(int propId, bool important);
 

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (94419 => 94420)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2011-09-02 16:00:23 UTC (rev 94420)
@@ -58,6 +58,7 @@
 border-bottom-width
 border-collapse
 border-color
+border-image-repeat
 border-image-slice
 border-image-source
 border-left
@@ -280,6 +281,7 @@
 -webkit-mask
 -webkit-mask-attachment
 -webkit-mask-box-image
+-webkit-mask-box-image-repeat
 -webkit-mask-box-image-slice
 -webkit-mask-box-image-source
 -webkit-mask-clip

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (94419 => 94420)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-09-02 16:00:23 UTC (rev 94420)
@@ -4328,6 +4328,24 @@
             m_style->setMaskBoxImage(image);
         return;
     }
+    case CSSPropertyBorderImageRepeat:
+    case CSSPropertyWebkitMaskBoxImageRepeat: {
+        bool isBorderImage = id == CSSPropertyBorderImageRepeat;
+        NinePieceImage image(isBorderImage ? m_style->borderImage() : m_style->maskBoxImage());
+        if (isInherit)
+            image.copyRepeatFrom(isBorderImage ? m_parentStyle->borderImage() : m_parentStyle->maskBoxImage());
+        else if (isInitial) {
+            image.setHorizontalRule(StretchImageRule);
+            image.setVerticalRule(StretchImageRule);
+        } else
+            mapNinePieceImageRepeat(value, image);
+        
+        if (isBorderImage)
+            m_style->setBorderImage(image);
+        else
+            m_style->setMaskBoxImage(image);
+        return;
+    }
     case CSSPropertyBorderImageSlice:
     case CSSPropertyWebkitMaskBoxImageSlice: {
         bool isBorderImage = id == CSSPropertyBorderImageSlice;
@@ -5692,33 +5710,7 @@
     mapNinePieceImageSlice(borderImage->m_slice.get(), image);
 
     // Set the appropriate rules for stretch/round/repeat of the slices
-    ENinePieceImageRule horizontalRule;
-    switch (borderImage->m_horizontalSizeRule) {
-        case CSSValueStretch:
-            horizontalRule = StretchImageRule;
-            break;
-        case CSSValueRound:
-            horizontalRule = RoundImageRule;
-            break;
-        default: // CSSValueRepeat
-            horizontalRule = RepeatImageRule;
-            break;
-    }
-    image.setHorizontalRule(horizontalRule);
-
-    ENinePieceImageRule verticalRule;
-    switch (borderImage->m_verticalSizeRule) {
-        case CSSValueStretch:
-            verticalRule = StretchImageRule;
-            break;
-        case CSSValueRound:
-            verticalRule = RoundImageRule;
-            break;
-        default: // CSSValueRepeat
-            verticalRule = RepeatImageRule;
-            break;
-    }
-    image.setVerticalRule(verticalRule);
+    mapNinePieceImageRepeat(borderImage->m_repeat.get(), image);
 }
 
 void CSSStyleSelector::mapNinePieceImageSlice(CSSValue* value, NinePieceImage& image)
@@ -5754,6 +5746,54 @@
     image.setFill(borderImageSlice->m_fill);
 }
 
+void CSSStyleSelector::mapNinePieceImageRepeat(CSSValue* value, NinePieceImage& image)
+{
+    if (!value || !value->isPrimitiveValue())
+        return;
+    
+    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+    Pair* pair = primitiveValue->getPairValue();
+    if (!pair || !pair->first() || !pair->second())
+        return;
+
+    int firstIdentifier = pair->first()->getIdent();
+    int secondIdentifier = pair->second()->getIdent();
+
+    ENinePieceImageRule horizontalRule;
+    switch (firstIdentifier) {
+    case CSSValueStretch:
+        horizontalRule = StretchImageRule;
+        break;
+    case CSSValueRound:
+        horizontalRule = RoundImageRule;
+        break;
+    case CSSValueSpace:
+        horizontalRule = SpaceImageRule;
+        break;
+    default: // CSSValueRepeat
+        horizontalRule = RepeatImageRule;
+        break;
+    }
+    image.setHorizontalRule(horizontalRule);
+
+    ENinePieceImageRule verticalRule;
+    switch (secondIdentifier) {
+    case CSSValueStretch:
+        verticalRule = StretchImageRule;
+        break;
+    case CSSValueRound:
+        verticalRule = RoundImageRule;
+        break;
+    case CSSValueSpace:
+        verticalRule = SpaceImageRule;
+        break;
+    default: // CSSValueRepeat
+        verticalRule = RepeatImageRule;
+        break;
+    }
+    image.setVerticalRule(verticalRule);
+}
+
 void CSSStyleSelector::checkForTextSizeAdjust()
 {
     if (m_style->textSizeAdjust())

Modified: trunk/Source/WebCore/css/CSSStyleSelector.h (94419 => 94420)


--- trunk/Source/WebCore/css/CSSStyleSelector.h	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/css/CSSStyleSelector.h	2011-09-02 16:00:23 UTC (rev 94420)
@@ -331,7 +331,8 @@
 
         void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&);
         void mapNinePieceImageSlice(CSSValue*, NinePieceImage&);
-    
+        void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&);
+
         bool canShareStyleWithControl(StyledElement*) const;
 
         void applyProperty(int id, CSSValue*);

Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (94419 => 94420)


--- trunk/Source/WebCore/platform/graphics/Image.cpp	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp	2011-09-02 16:00:23 UTC (rev 94420)
@@ -158,10 +158,10 @@
         return;
     }
     
-    // FIXME: We do not support 'round' yet.  For now just map it to 'repeat'.
-    if (hRule == RoundTile)
+    // FIXME: We do not support 'round' or 'space' yet. For now just map them to 'repeat'.
+    if (hRule == RoundTile || hRule == SpaceTile)
         hRule = RepeatTile;
-    if (vRule == RoundTile)
+    if (vRule == RoundTile || vRule == SpaceTile)
         vRule = RepeatTile;
 
     FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule);

Modified: trunk/Source/WebCore/platform/graphics/Image.h (94419 => 94420)


--- trunk/Source/WebCore/platform/graphics/Image.h	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/platform/graphics/Image.h	2011-09-02 16:00:23 UTC (rev 94420)
@@ -128,7 +128,7 @@
     // Typically the CachedImage that owns us.
     ImageObserver* imageObserver() const { return m_imageObserver; }
 
-    enum TileRule { StretchTile, RoundTile, RepeatTile };
+    enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
 
     virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
     

Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (94419 => 94420)


--- trunk/Source/WebCore/rendering/style/NinePieceImage.h	2011-09-02 15:57:44 UTC (rev 94419)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h	2011-09-02 16:00:23 UTC (rev 94420)
@@ -30,7 +30,7 @@
 namespace WebCore {
 
 enum ENinePieceImageRule {
-    StretchImageRule, RoundImageRule, RepeatImageRule
+    StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule
 };
 
 class NinePieceImage {
@@ -78,6 +78,12 @@
         m_fill = other.m_fill;
     }
 
+    void copyRepeatFrom(const NinePieceImage& other)
+    {
+        m_horizontalRule = other.m_horizontalRule;
+        m_verticalRule = other.m_verticalRule;
+    }
+
 private:
     RefPtr<StyleImage> m_image;
     LengthBox m_slices;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to