Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / style / ShapeValue.h
index bb71dab..dc12b4f 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "core/fetch/ImageResource.h"
 #include "core/rendering/style/BasicShapes.h"
+#include "core/rendering/style/RenderStyleConstants.h"
 #include "core/rendering/style/StyleImage.h"
 #include "wtf/PassRefPtr.h"
 
@@ -42,18 +43,18 @@ public:
     enum ShapeValueType {
         // The Auto value is defined by a null ShapeValue*
         Shape,
-        Outside,
+        Box,
         Image
     };
 
-    static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape)
+    static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
     {
-        return adoptRef(new ShapeValue(shape));
+        return adoptRef(new ShapeValue(shape, cssBox));
     }
 
-    static PassRefPtr<ShapeValue> createOutsideValue()
+    static PassRefPtr<ShapeValue> createBoxShapeValue(CSSBoxType cssBox)
     {
-        return adoptRef(new ShapeValue(Outside));
+        return adoptRef(new ShapeValue(cssBox));
     }
 
     static PassRefPtr<ShapeValue> createImageValue(PassRefPtr<StyleImage> image)
@@ -65,35 +66,73 @@ public:
     BasicShape* shape() const { return m_shape.get(); }
 
     StyleImage* image() const { return m_image.get(); }
-    bool isImageValid() const { return image() && image()->cachedImage() && image()->cachedImage()->hasImage(); }
+    bool isImageValid() const
+    {
+        if (!image())
+            return false;
+        if (image()->isImageResource() || image()->isImageResourceSet())
+            return image()->cachedImage() && image()->cachedImage()->hasImage();
+        return image()->isGeneratedImage();
+    }
     void setImage(PassRefPtr<StyleImage> image)
     {
         ASSERT(type() == Image);
         if (m_image != image)
             m_image = image;
     }
-    bool operator==(const ShapeValue& other) const { return type() == other.type(); }
+    CSSBoxType cssBox() const { return m_cssBox; }
+
+    bool operator==(const ShapeValue& other) const;
 
 private:
-    ShapeValue(PassRefPtr<BasicShape> shape)
+    ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox)
         : m_type(Shape)
         , m_shape(shape)
+        , m_cssBox(cssBox)
     {
     }
     ShapeValue(ShapeValueType type)
         : m_type(type)
+        , m_cssBox(BoxMissing)
     {
     }
     ShapeValue(PassRefPtr<StyleImage> image)
         : m_type(Image)
         , m_image(image)
+        , m_cssBox(ContentBox)
     {
     }
+    ShapeValue(CSSBoxType cssBox)
+        : m_type(Box)
+        , m_cssBox(cssBox)
+    {
+    }
+
+
     ShapeValueType m_type;
     RefPtr<BasicShape> m_shape;
     RefPtr<StyleImage> m_image;
+    CSSBoxType m_cssBox;
 };
 
+inline bool ShapeValue::operator==(const ShapeValue& other) const
+{
+    if (type() != other.type())
+        return false;
+
+    switch (type()) {
+    case Shape:
+        return shape() == other.shape() && cssBox() == other.cssBox();
+    case Box:
+        return cssBox() == other.cssBox();
+    case Image:
+        return image() == other.image();
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 }
 
 #endif