| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class ShapeValue : public RefCounted<ShapeValue> { | 41 class ShapeValue : public RefCounted<ShapeValue> { |
| 42 public: | 42 public: |
| 43 enum ShapeValueType { | 43 enum ShapeValueType { |
| 44 // The Auto value is defined by a null ShapeValue* | 44 // The Auto value is defined by a null ShapeValue* |
| 45 Shape, | 45 Shape, |
| 46 Box, | 46 Box, |
| 47 Outside, | 47 Outside, |
| 48 Image | 48 Image |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape,
LayoutBox layoutBox) | 51 static PassRefPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape,
CSSBoxType cssBox) |
| 52 { | 52 { |
| 53 return adoptRef(new ShapeValue(shape, layoutBox)); | 53 return adoptRef(new ShapeValue(shape, cssBox)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 static PassRefPtr<ShapeValue> createOutsideValue() | 56 static PassRefPtr<ShapeValue> createOutsideValue() |
| 57 { | 57 { |
| 58 return adoptRef(new ShapeValue(Outside)); | 58 return adoptRef(new ShapeValue(Outside)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 static PassRefPtr<ShapeValue> createLayoutBoxValue(LayoutBox layoutBox) | 61 static PassRefPtr<ShapeValue> createBoxShapeValue(CSSBoxType cssBox) |
| 62 { | 62 { |
| 63 return adoptRef(new ShapeValue(layoutBox)); | 63 return adoptRef(new ShapeValue(cssBox)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 static PassRefPtr<ShapeValue> createImageValue(PassRefPtr<StyleImage> image) | 66 static PassRefPtr<ShapeValue> createImageValue(PassRefPtr<StyleImage> image) |
| 67 { | 67 { |
| 68 return adoptRef(new ShapeValue(image)); | 68 return adoptRef(new ShapeValue(image)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ShapeValueType type() const { return m_type; } | 71 ShapeValueType type() const { return m_type; } |
| 72 BasicShape* shape() const { return m_shape.get(); } | 72 BasicShape* shape() const { return m_shape.get(); } |
| 73 | 73 |
| 74 StyleImage* image() const { return m_image.get(); } | 74 StyleImage* image() const { return m_image.get(); } |
| 75 bool isImageValid() const { return image() && image()->cachedImage() && imag
e()->cachedImage()->hasImage(); } | 75 bool isImageValid() const { return image() && image()->cachedImage() && imag
e()->cachedImage()->hasImage(); } |
| 76 void setImage(PassRefPtr<StyleImage> image) | 76 void setImage(PassRefPtr<StyleImage> image) |
| 77 { | 77 { |
| 78 ASSERT(type() == Image); | 78 ASSERT(type() == Image); |
| 79 if (m_image != image) | 79 if (m_image != image) |
| 80 m_image = image; | 80 m_image = image; |
| 81 } | 81 } |
| 82 LayoutBox layoutBox() const { return m_layoutBox; } | 82 CSSBoxType cssBox() const { return m_cssBox; } |
| 83 void setLayoutBox(LayoutBox layoutBox) { m_layoutBox = layoutBox; } | |
| 84 | 83 |
| 85 bool operator==(const ShapeValue& other) const; | 84 bool operator==(const ShapeValue& other) const; |
| 86 | 85 |
| 87 private: | 86 private: |
| 88 ShapeValue(PassRefPtr<BasicShape> shape, LayoutBox layoutBox) | 87 ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox) |
| 89 : m_type(Shape) | 88 : m_type(Shape) |
| 90 , m_shape(shape) | 89 , m_shape(shape) |
| 91 , m_layoutBox(layoutBox) | 90 , m_cssBox(cssBox) |
| 92 { | 91 { |
| 93 } | 92 } |
| 94 ShapeValue(ShapeValueType type) | 93 ShapeValue(ShapeValueType type) |
| 95 : m_type(type) | 94 : m_type(type) |
| 96 , m_layoutBox(BoxMissing) | 95 , m_cssBox(BoxMissing) |
| 97 { | 96 { |
| 98 } | 97 } |
| 99 ShapeValue(PassRefPtr<StyleImage> image) | 98 ShapeValue(PassRefPtr<StyleImage> image) |
| 100 : m_type(Image) | 99 : m_type(Image) |
| 101 , m_image(image) | 100 , m_image(image) |
| 102 , m_layoutBox(ContentBox) | 101 , m_cssBox(ContentBox) |
| 103 { | 102 { |
| 104 } | 103 } |
| 105 ShapeValue(LayoutBox layoutBox) | 104 ShapeValue(CSSBoxType cssBox) |
| 106 : m_type(Box) | 105 : m_type(Box) |
| 107 , m_layoutBox(layoutBox) | 106 , m_cssBox(cssBox) |
| 108 { | 107 { |
| 109 } | 108 } |
| 110 | 109 |
| 111 | 110 |
| 112 ShapeValueType m_type; | 111 ShapeValueType m_type; |
| 113 RefPtr<BasicShape> m_shape; | 112 RefPtr<BasicShape> m_shape; |
| 114 RefPtr<StyleImage> m_image; | 113 RefPtr<StyleImage> m_image; |
| 115 LayoutBox m_layoutBox; | 114 CSSBoxType m_cssBox; |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 inline bool ShapeValue::operator==(const ShapeValue& other) const | 117 inline bool ShapeValue::operator==(const ShapeValue& other) const |
| 119 { | 118 { |
| 120 if (type() != other.type()) | 119 if (type() != other.type()) |
| 121 return false; | 120 return false; |
| 122 | 121 |
| 123 switch (type()) { | 122 switch (type()) { |
| 124 case Shape: | 123 case Shape: |
| 125 return shape() == other.shape() && layoutBox() == other.layoutBox(); | 124 return shape() == other.shape() && cssBox() == other.cssBox(); |
| 126 case Box: | 125 case Box: |
| 127 return layoutBox() == other.layoutBox(); | 126 return cssBox() == other.cssBox(); |
| 128 case Outside: | 127 case Outside: |
| 129 return true; | 128 return true; |
| 130 case Image: | 129 case Image: |
| 131 return image() == other.image(); | 130 return image() == other.image(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
| 135 return false; | 134 return false; |
| 136 } | 135 } |
| 137 | 136 |
| 138 } | 137 } |
| 139 | 138 |
| 140 #endif | 139 #endif |
| OLD | NEW |