| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmial.com> | 4 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmial.com> |
| 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef SVGPaint_h | 23 #ifndef SVGPaint_h |
| 24 #define SVGPaint_h | 24 #define SVGPaint_h |
| 25 | 25 |
| 26 #include "core/svg/SVGColor.h" | 26 #include "core/css/CSSValue.h" |
| 27 #include "core/css/StyleColor.h" |
| 28 #include "platform/graphics/Color.h" |
| 27 #include "wtf/text/WTFString.h" | 29 #include "wtf/text/WTFString.h" |
| 28 | 30 |
| 29 namespace WebCore { | 31 namespace WebCore { |
| 30 | 32 |
| 31 class ExceptionState; | 33 class ExceptionState; |
| 32 | 34 |
| 33 class SVGPaint : public SVGColor { | 35 class SVGPaint : public CSSValue { |
| 34 public: | 36 public: |
| 35 enum SVGPaintType { | 37 enum SVGPaintType { |
| 36 SVG_PAINTTYPE_UNKNOWN = 0, | 38 SVG_PAINTTYPE_UNKNOWN = 0, |
| 37 SVG_PAINTTYPE_RGBCOLOR = 1, | 39 SVG_PAINTTYPE_RGBCOLOR = 1, |
| 38 SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2, | 40 SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2, |
| 39 SVG_PAINTTYPE_NONE = 101, | 41 SVG_PAINTTYPE_NONE = 101, |
| 40 SVG_PAINTTYPE_CURRENTCOLOR = 102, | 42 SVG_PAINTTYPE_CURRENTCOLOR = 102, |
| 41 SVG_PAINTTYPE_URI_NONE = 103, | 43 SVG_PAINTTYPE_URI_NONE = 103, |
| 42 SVG_PAINTTYPE_URI_CURRENTCOLOR = 104, | 44 SVG_PAINTTYPE_URI_CURRENTCOLOR = 104, |
| 43 SVG_PAINTTYPE_URI_RGBCOLOR = 105, | 45 SVG_PAINTTYPE_URI_RGBCOLOR = 105, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 } | 58 } |
| 57 | 59 |
| 58 static PassRefPtrWillBeRawPtr<SVGPaint> createCurrentColor() | 60 static PassRefPtrWillBeRawPtr<SVGPaint> createCurrentColor() |
| 59 { | 61 { |
| 60 return adoptRefWillBeRefCountedGarbageCollected(new SVGPaint(SVG_PAINTTY
PE_CURRENTCOLOR)); | 62 return adoptRefWillBeRefCountedGarbageCollected(new SVGPaint(SVG_PAINTTY
PE_CURRENTCOLOR)); |
| 61 } | 63 } |
| 62 | 64 |
| 63 static PassRefPtrWillBeRawPtr<SVGPaint> createColor(const Color& color) | 65 static PassRefPtrWillBeRawPtr<SVGPaint> createColor(const Color& color) |
| 64 { | 66 { |
| 65 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_RGBCOLOR)); | 67 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_RGBCOLOR)); |
| 66 paint->setColor(color); | 68 paint->m_color = color; |
| 67 return paint.release(); | 69 return paint.release(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 static PassRefPtrWillBeRawPtr<SVGPaint> createURI(const String& uri) | 72 static PassRefPtrWillBeRawPtr<SVGPaint> createURI(const String& uri) |
| 71 { | 73 { |
| 72 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI, uri)); | 74 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI, uri)); |
| 73 return paint.release(); | 75 return paint.release(); |
| 74 } | 76 } |
| 75 | 77 |
| 76 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndColor(const String& uri,
const Color& color) | 78 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndColor(const String& uri,
const Color& color) |
| 77 { | 79 { |
| 78 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_RGBCOLOR, uri)); | 80 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_RGBCOLOR, uri)); |
| 79 paint->setColor(color); | 81 paint->m_color = color; |
| 80 return paint.release(); | 82 return paint.release(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndNone(const String& uri) | 85 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndNone(const String& uri) |
| 84 { | 86 { |
| 85 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_NONE, uri)); | 87 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_NONE, uri)); |
| 86 return paint.release(); | 88 return paint.release(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndCurrentColor(const Strin
g& uri) | 91 static PassRefPtrWillBeRawPtr<SVGPaint> createURIAndCurrentColor(const Strin
g& uri) |
| 90 { | 92 { |
| 91 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_CURRENTCOLOR, uri)); | 93 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(SVG_PAINTTYPE_URI_CURRENTCOLOR, uri)); |
| 92 return paint.release(); | 94 return paint.release(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 const SVGPaintType& paintType() const { return m_paintType; } | 97 const SVGPaintType& paintType() const { return m_paintType; } |
| 96 String uri() const { return m_uri; } | 98 String uri() const { return m_uri; } |
| 97 | 99 |
| 98 String customCSSText() const; | 100 String customCSSText() const; |
| 99 | 101 |
| 100 PassRefPtrWillBeRawPtr<SVGPaint> cloneForCSSOM() const; | 102 PassRefPtrWillBeRawPtr<SVGPaint> cloneForCSSOM() const; |
| 101 | 103 |
| 102 bool equals(const SVGPaint&) const; | 104 bool equals(const SVGPaint&) const; |
| 103 | 105 |
| 104 void traceAfterDispatch(Visitor* visitor) { SVGColor::traceAfterDispatch(vis
itor); } | 106 void traceAfterDispatch(Visitor* visitor) { CSSValue::traceAfterDispatch(vis
itor); } |
| 107 |
| 108 Color color() const { return m_color; } |
| 109 void setColor(const Color& color) { m_color = color; m_paintType = SVG_PAINT
TYPE_RGBCOLOR; } |
| 110 |
| 111 static StyleColor colorFromRGBColorString(const String&); |
| 105 | 112 |
| 106 private: | 113 private: |
| 107 friend class CSSComputedStyleDeclaration; | 114 friend class CSSComputedStyleDeclaration; |
| 108 | 115 |
| 109 static PassRefPtrWillBeRawPtr<SVGPaint> create(const SVGPaintType& type, con
st String& uri, const Color& color) | 116 static PassRefPtrWillBeRawPtr<SVGPaint> create(const SVGPaintType& type, con
st String& uri, const Color& color) |
| 110 { | 117 { |
| 111 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(type, uri)); | 118 RefPtrWillBeRawPtr<SVGPaint> paint = adoptRefWillBeRefCountedGarbageColl
ected(new SVGPaint(type, uri)); |
| 112 paint->setColor(color); | 119 paint->m_color = color; |
| 113 return paint.release(); | 120 return paint.release(); |
| 114 } | 121 } |
| 115 | 122 |
| 116 private: | 123 private: |
| 117 SVGPaint(const SVGPaintType&, const String& uri = String()); | 124 SVGPaint(const SVGPaintType&, const String& uri = String()); |
| 118 SVGPaint(const SVGPaint& cloneFrom); | 125 SVGPaint(const SVGPaint& cloneFrom); |
| 119 | 126 |
| 120 SVGPaintType m_paintType; | 127 SVGPaintType m_paintType; |
| 128 Color m_color; |
| 121 String m_uri; | 129 String m_uri; |
| 122 }; | 130 }; |
| 123 | 131 |
| 124 DEFINE_CSS_VALUE_TYPE_CASTS(SVGPaint, isSVGPaint()); | 132 DEFINE_CSS_VALUE_TYPE_CASTS(SVGPaint, isSVGPaint()); |
| 125 | 133 |
| 126 } // namespace WebCore | 134 } // namespace WebCore |
| 127 | 135 |
| 128 #endif // SVGPaint_h | 136 #endif // SVGPaint_h |
| OLD | NEW |