| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #include "core/fetch/ImageResource.h" | 33 #include "core/fetch/ImageResource.h" |
| 34 #include "core/style/BasicShapes.h" | 34 #include "core/style/BasicShapes.h" |
| 35 #include "core/style/DataEquivalency.h" | 35 #include "core/style/DataEquivalency.h" |
| 36 #include "core/style/ComputedStyleConstants.h" | 36 #include "core/style/ComputedStyleConstants.h" |
| 37 #include "core/style/StyleImage.h" | 37 #include "core/style/StyleImage.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class ShapeValue final : public RefCountedWillBeGarbageCollectedFinalized<ShapeV
alue> { | 42 class ShapeValue final : public GarbageCollectedFinalized<ShapeValue> { |
| 43 public: | 43 public: |
| 44 enum ShapeValueType { | 44 enum ShapeValueType { |
| 45 // The Auto value is defined by a null ShapeValue* | 45 // The Auto value is defined by a null ShapeValue* |
| 46 Shape, | 46 Shape, |
| 47 Box, | 47 Box, |
| 48 Image | 48 Image |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 static PassRefPtrWillBeRawPtr<ShapeValue> createShapeValue(PassRefPtr<BasicS
hape> shape, CSSBoxType cssBox) | 51 static RawPtr<ShapeValue> createShapeValue(PassRefPtr<BasicShape> shape, CSS
BoxType cssBox) |
| 52 { | 52 { |
| 53 return adoptRefWillBeNoop(new ShapeValue(shape, cssBox)); | 53 return new ShapeValue(shape, cssBox); |
| 54 } | 54 } |
| 55 | 55 |
| 56 static PassRefPtrWillBeRawPtr<ShapeValue> createBoxShapeValue(CSSBoxType css
Box) | 56 static RawPtr<ShapeValue> createBoxShapeValue(CSSBoxType cssBox) |
| 57 { | 57 { |
| 58 return adoptRefWillBeNoop(new ShapeValue(cssBox)); | 58 return new ShapeValue(cssBox); |
| 59 } | 59 } |
| 60 | 60 |
| 61 static PassRefPtrWillBeRawPtr<ShapeValue> createImageValue(PassRefPtrWillBeR
awPtr<StyleImage> image) | 61 static RawPtr<ShapeValue> createImageValue(RawPtr<StyleImage> image) |
| 62 { | 62 { |
| 63 return adoptRefWillBeNoop(new ShapeValue(image)); | 63 return new ShapeValue(image); |
| 64 } | 64 } |
| 65 | 65 |
| 66 ShapeValueType type() const { return m_type; } | 66 ShapeValueType type() const { return m_type; } |
| 67 BasicShape* shape() const { return m_shape.get(); } | 67 BasicShape* shape() const { return m_shape.get(); } |
| 68 | 68 |
| 69 StyleImage* image() const { return m_image.get(); } | 69 StyleImage* image() const { return m_image.get(); } |
| 70 bool isImageValid() const | 70 bool isImageValid() const |
| 71 { | 71 { |
| 72 if (!image()) | 72 if (!image()) |
| 73 return false; | 73 return false; |
| 74 if (image()->isImageResource() || image()->isImageResourceSet()) | 74 if (image()->isImageResource() || image()->isImageResourceSet()) |
| 75 return image()->cachedImage() && image()->cachedImage()->hasImage(); | 75 return image()->cachedImage() && image()->cachedImage()->hasImage(); |
| 76 return image()->isGeneratedImage(); | 76 return image()->isGeneratedImage(); |
| 77 } | 77 } |
| 78 void setImage(PassRefPtrWillBeRawPtr<StyleImage> image) | 78 void setImage(RawPtr<StyleImage> image) |
| 79 { | 79 { |
| 80 ASSERT(type() == Image); | 80 ASSERT(type() == Image); |
| 81 if (m_image != image) | 81 if (m_image != image) |
| 82 m_image = image; | 82 m_image = image; |
| 83 } | 83 } |
| 84 CSSBoxType cssBox() const { return m_cssBox; } | 84 CSSBoxType cssBox() const { return m_cssBox; } |
| 85 | 85 |
| 86 bool operator==(const ShapeValue& other) const; | 86 bool operator==(const ShapeValue& other) const; |
| 87 | 87 |
| 88 DEFINE_INLINE_VIRTUAL_TRACE() | 88 DEFINE_INLINE_VIRTUAL_TRACE() |
| 89 { | 89 { |
| 90 visitor->trace(m_image); | 90 visitor->trace(m_image); |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox) | 94 ShapeValue(PassRefPtr<BasicShape> shape, CSSBoxType cssBox) |
| 95 : m_type(Shape) | 95 : m_type(Shape) |
| 96 , m_shape(shape) | 96 , m_shape(shape) |
| 97 , m_cssBox(cssBox) | 97 , m_cssBox(cssBox) |
| 98 { | 98 { |
| 99 } | 99 } |
| 100 ShapeValue(ShapeValueType type) | 100 ShapeValue(ShapeValueType type) |
| 101 : m_type(type) | 101 : m_type(type) |
| 102 , m_cssBox(BoxMissing) | 102 , m_cssBox(BoxMissing) |
| 103 { | 103 { |
| 104 } | 104 } |
| 105 ShapeValue(PassRefPtrWillBeRawPtr<StyleImage> image) | 105 ShapeValue(RawPtr<StyleImage> image) |
| 106 : m_type(Image) | 106 : m_type(Image) |
| 107 , m_image(image) | 107 , m_image(image) |
| 108 , m_cssBox(ContentBox) | 108 , m_cssBox(ContentBox) |
| 109 { | 109 { |
| 110 } | 110 } |
| 111 ShapeValue(CSSBoxType cssBox) | 111 ShapeValue(CSSBoxType cssBox) |
| 112 : m_type(Box) | 112 : m_type(Box) |
| 113 , m_cssBox(cssBox) | 113 , m_cssBox(cssBox) |
| 114 { | 114 { |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 ShapeValueType m_type; | 118 ShapeValueType m_type; |
| 119 RefPtr<BasicShape> m_shape; | 119 RefPtr<BasicShape> m_shape; |
| 120 RefPtrWillBeMember<StyleImage> m_image; | 120 Member<StyleImage> m_image; |
| 121 CSSBoxType m_cssBox; | 121 CSSBoxType m_cssBox; |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 inline bool ShapeValue::operator==(const ShapeValue& other) const | 124 inline bool ShapeValue::operator==(const ShapeValue& other) const |
| 125 { | 125 { |
| 126 if (type() != other.type()) | 126 if (type() != other.type()) |
| 127 return false; | 127 return false; |
| 128 | 128 |
| 129 switch (type()) { | 129 switch (type()) { |
| 130 case Shape: | 130 case Shape: |
| 131 return dataEquivalent(shape(), other.shape()) && cssBox() == other.cssBo
x(); | 131 return dataEquivalent(shape(), other.shape()) && cssBox() == other.cssBo
x(); |
| 132 case Box: | 132 case Box: |
| 133 return cssBox() == other.cssBox(); | 133 return cssBox() == other.cssBox(); |
| 134 case Image: | 134 case Image: |
| 135 return dataEquivalent(image(), other.image()); | 135 return dataEquivalent(image(), other.image()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 ASSERT_NOT_REACHED(); | 138 ASSERT_NOT_REACHED(); |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace blink | 142 } // namespace blink |
| 143 | 143 |
| 144 #endif | 144 #endif |
| OLD | NEW |