| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "wtf/FastAllocBase.h" | 23 #include "wtf/FastAllocBase.h" |
| 24 #include "wtf/HashSet.h" | 24 #include "wtf/HashSet.h" |
| 25 #include "wtf/Noncopyable.h" | 25 #include "wtf/Noncopyable.h" |
| 26 #include "wtf/OwnPtr.h" | 26 #include "wtf/OwnPtr.h" |
| 27 #include "wtf/PassOwnPtr.h" | 27 #include "wtf/PassOwnPtr.h" |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 class LayoutObject; | 31 class LayoutObject; |
| 32 class RenderSVGResourceClipper; | 32 class LayoutSVGResourceClipper; |
| 33 class RenderSVGResourceContainer; | 33 class LayoutSVGResourceContainer; |
| 34 class RenderSVGResourceFilter; | 34 class LayoutSVGResourceFilter; |
| 35 class RenderSVGResourceMarker; | 35 class LayoutSVGResourceMarker; |
| 36 class RenderSVGResourceMasker; | 36 class LayoutSVGResourceMasker; |
| 37 class RenderSVGResourcePaintServer; | 37 class LayoutSVGResourcePaintServer; |
| 38 class SVGElement; | 38 class SVGElement; |
| 39 class SVGLayoutStyle; | 39 class SVGLayoutStyle; |
| 40 | 40 |
| 41 // Holds a set of resources associated with a LayoutObject | 41 // Holds a set of resources associated with a LayoutObject |
| 42 class SVGResources { | 42 class SVGResources { |
| 43 WTF_MAKE_NONCOPYABLE(SVGResources); WTF_MAKE_FAST_ALLOCATED; | 43 WTF_MAKE_NONCOPYABLE(SVGResources); WTF_MAKE_FAST_ALLOCATED; |
| 44 public: | 44 public: |
| 45 SVGResources(); | 45 SVGResources(); |
| 46 | 46 |
| 47 static PassOwnPtr<SVGResources> buildResources(const LayoutObject*, const SV
GLayoutStyle&); | 47 static PassOwnPtr<SVGResources> buildResources(const LayoutObject*, const SV
GLayoutStyle&); |
| 48 void layoutIfNeeded(); | 48 void layoutIfNeeded(); |
| 49 | 49 |
| 50 static bool supportsMarkers(const SVGElement&); | 50 static bool supportsMarkers(const SVGElement&); |
| 51 | 51 |
| 52 // Ordinary resources | 52 // Ordinary resources |
| 53 RenderSVGResourceClipper* clipper() const { return m_clipperFilterMaskerData
? m_clipperFilterMaskerData->clipper : 0; } | 53 LayoutSVGResourceClipper* clipper() const { return m_clipperFilterMaskerData
? m_clipperFilterMaskerData->clipper : 0; } |
| 54 RenderSVGResourceMarker* markerStart() const { return m_markerData ? m_marke
rData->markerStart : 0; } | 54 LayoutSVGResourceMarker* markerStart() const { return m_markerData ? m_marke
rData->markerStart : 0; } |
| 55 RenderSVGResourceMarker* markerMid() const { return m_markerData ? m_markerD
ata->markerMid : 0; } | 55 LayoutSVGResourceMarker* markerMid() const { return m_markerData ? m_markerD
ata->markerMid : 0; } |
| 56 RenderSVGResourceMarker* markerEnd() const { return m_markerData ? m_markerD
ata->markerEnd : 0; } | 56 LayoutSVGResourceMarker* markerEnd() const { return m_markerData ? m_markerD
ata->markerEnd : 0; } |
| 57 RenderSVGResourceMasker* masker() const { return m_clipperFilterMaskerData ?
m_clipperFilterMaskerData->masker : 0; } | 57 LayoutSVGResourceMasker* masker() const { return m_clipperFilterMaskerData ?
m_clipperFilterMaskerData->masker : 0; } |
| 58 | 58 |
| 59 RenderSVGResourceFilter* filter() const | 59 LayoutSVGResourceFilter* filter() const |
| 60 { | 60 { |
| 61 if (m_clipperFilterMaskerData) | 61 if (m_clipperFilterMaskerData) |
| 62 return m_clipperFilterMaskerData->filter; | 62 return m_clipperFilterMaskerData->filter; |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Paint servers | 66 // Paint servers |
| 67 RenderSVGResourcePaintServer* fill() const { return m_fillStrokeData ? m_fil
lStrokeData->fill : 0; } | 67 LayoutSVGResourcePaintServer* fill() const { return m_fillStrokeData ? m_fil
lStrokeData->fill : 0; } |
| 68 RenderSVGResourcePaintServer* stroke() const { return m_fillStrokeData ? m_f
illStrokeData->stroke : 0; } | 68 LayoutSVGResourcePaintServer* stroke() const { return m_fillStrokeData ? m_f
illStrokeData->stroke : 0; } |
| 69 | 69 |
| 70 // Chainable resources - linked through xlink:href | 70 // Chainable resources - linked through xlink:href |
| 71 RenderSVGResourceContainer* linkedResource() const { return m_linkedResource
; } | 71 LayoutSVGResourceContainer* linkedResource() const { return m_linkedResource
; } |
| 72 | 72 |
| 73 void buildSetOfResources(HashSet<RenderSVGResourceContainer*>&); | 73 void buildSetOfResources(HashSet<LayoutSVGResourceContainer*>&); |
| 74 | 74 |
| 75 // Methods operating on all cached resources | 75 // Methods operating on all cached resources |
| 76 void removeClientFromCache(LayoutObject*, bool markForInvalidation = true) c
onst; | 76 void removeClientFromCache(LayoutObject*, bool markForInvalidation = true) c
onst; |
| 77 void resourceDestroyed(RenderSVGResourceContainer*); | 77 void resourceDestroyed(LayoutSVGResourceContainer*); |
| 78 | 78 |
| 79 #ifndef NDEBUG | 79 #ifndef NDEBUG |
| 80 void dump(const LayoutObject*); | 80 void dump(const LayoutObject*); |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 friend class SVGResourcesCycleSolver; | 84 friend class SVGResourcesCycleSolver; |
| 85 | 85 |
| 86 bool hasResourceData() const; | 86 bool hasResourceData() const; |
| 87 | 87 |
| 88 // Only used by SVGResourcesCache cycle detection logic | 88 // Only used by SVGResourcesCache cycle detection logic |
| 89 void resetClipper(); | 89 void resetClipper(); |
| 90 void resetFilter(); | 90 void resetFilter(); |
| 91 void resetMarkerStart(); | 91 void resetMarkerStart(); |
| 92 void resetMarkerMid(); | 92 void resetMarkerMid(); |
| 93 void resetMarkerEnd(); | 93 void resetMarkerEnd(); |
| 94 void resetMasker(); | 94 void resetMasker(); |
| 95 void resetFill(); | 95 void resetFill(); |
| 96 void resetStroke(); | 96 void resetStroke(); |
| 97 void resetLinkedResource(); | 97 void resetLinkedResource(); |
| 98 | 98 |
| 99 bool setClipper(RenderSVGResourceClipper*); | 99 bool setClipper(LayoutSVGResourceClipper*); |
| 100 bool setFilter(RenderSVGResourceFilter*); | 100 bool setFilter(LayoutSVGResourceFilter*); |
| 101 bool setMarkerStart(RenderSVGResourceMarker*); | 101 bool setMarkerStart(LayoutSVGResourceMarker*); |
| 102 bool setMarkerMid(RenderSVGResourceMarker*); | 102 bool setMarkerMid(LayoutSVGResourceMarker*); |
| 103 bool setMarkerEnd(RenderSVGResourceMarker*); | 103 bool setMarkerEnd(LayoutSVGResourceMarker*); |
| 104 bool setMasker(RenderSVGResourceMasker*); | 104 bool setMasker(LayoutSVGResourceMasker*); |
| 105 bool setFill(RenderSVGResourcePaintServer*); | 105 bool setFill(LayoutSVGResourcePaintServer*); |
| 106 bool setStroke(RenderSVGResourcePaintServer*); | 106 bool setStroke(LayoutSVGResourcePaintServer*); |
| 107 bool setLinkedResource(RenderSVGResourceContainer*); | 107 bool setLinkedResource(LayoutSVGResourceContainer*); |
| 108 | 108 |
| 109 // From SVG 1.1 2nd Edition | 109 // From SVG 1.1 2nd Edition |
| 110 // clipper: 'container elements' and 'graphics elements' | 110 // clipper: 'container elements' and 'graphics elements' |
| 111 // filter: 'container elements' and 'graphics elements' | 111 // filter: 'container elements' and 'graphics elements' |
| 112 // masker: 'container elements' and 'graphics elements' | 112 // masker: 'container elements' and 'graphics elements' |
| 113 // -> a, circle, defs, ellipse, glyph, g, image, line, marker, mask, missing
-glyph, path, pattern, polygon, polyline, rect, svg, switch, symbol, text, use | 113 // -> a, circle, defs, ellipse, glyph, g, image, line, marker, mask, missing
-glyph, path, pattern, polygon, polyline, rect, svg, switch, symbol, text, use |
| 114 struct ClipperFilterMaskerData { | 114 struct ClipperFilterMaskerData { |
| 115 WTF_MAKE_FAST_ALLOCATED; | 115 WTF_MAKE_FAST_ALLOCATED; |
| 116 public: | 116 public: |
| 117 ClipperFilterMaskerData() | 117 ClipperFilterMaskerData() |
| 118 : clipper(0) | 118 : clipper(0) |
| 119 , filter(0) | 119 , filter(0) |
| 120 , masker(0) | 120 , masker(0) |
| 121 { | 121 { |
| 122 } | 122 } |
| 123 | 123 |
| 124 static PassOwnPtr<ClipperFilterMaskerData> create() | 124 static PassOwnPtr<ClipperFilterMaskerData> create() |
| 125 { | 125 { |
| 126 return adoptPtr(new ClipperFilterMaskerData); | 126 return adoptPtr(new ClipperFilterMaskerData); |
| 127 } | 127 } |
| 128 | 128 |
| 129 RenderSVGResourceClipper* clipper; | 129 LayoutSVGResourceClipper* clipper; |
| 130 RenderSVGResourceFilter* filter; | 130 LayoutSVGResourceFilter* filter; |
| 131 RenderSVGResourceMasker* masker; | 131 LayoutSVGResourceMasker* masker; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 // From SVG 1.1 2nd Edition | 134 // From SVG 1.1 2nd Edition |
| 135 // marker: line, path, polygon, polyline | 135 // marker: line, path, polygon, polyline |
| 136 struct MarkerData { | 136 struct MarkerData { |
| 137 WTF_MAKE_FAST_ALLOCATED; | 137 WTF_MAKE_FAST_ALLOCATED; |
| 138 public: | 138 public: |
| 139 MarkerData() | 139 MarkerData() |
| 140 : markerStart(0) | 140 : markerStart(0) |
| 141 , markerMid(0) | 141 , markerMid(0) |
| 142 , markerEnd(0) | 142 , markerEnd(0) |
| 143 { | 143 { |
| 144 } | 144 } |
| 145 | 145 |
| 146 static PassOwnPtr<MarkerData> create() | 146 static PassOwnPtr<MarkerData> create() |
| 147 { | 147 { |
| 148 return adoptPtr(new MarkerData); | 148 return adoptPtr(new MarkerData); |
| 149 } | 149 } |
| 150 | 150 |
| 151 RenderSVGResourceMarker* markerStart; | 151 LayoutSVGResourceMarker* markerStart; |
| 152 RenderSVGResourceMarker* markerMid; | 152 LayoutSVGResourceMarker* markerMid; |
| 153 RenderSVGResourceMarker* markerEnd; | 153 LayoutSVGResourceMarker* markerEnd; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 // From SVG 1.1 2nd Edition | 156 // From SVG 1.1 2nd Edition |
| 157 // fill: 'shapes' and 'text content elements' | 157 // fill: 'shapes' and 'text content elements' |
| 158 // stroke: 'shapes' and 'text content elements' | 158 // stroke: 'shapes' and 'text content elements' |
| 159 // -> circle, ellipse, line, path, polygon, polyline, rect, text, textPath,
tspan | 159 // -> circle, ellipse, line, path, polygon, polyline, rect, text, textPath,
tspan |
| 160 struct FillStrokeData { | 160 struct FillStrokeData { |
| 161 WTF_MAKE_FAST_ALLOCATED; | 161 WTF_MAKE_FAST_ALLOCATED; |
| 162 public: | 162 public: |
| 163 FillStrokeData() | 163 FillStrokeData() |
| 164 : fill(0) | 164 : fill(0) |
| 165 , stroke(0) | 165 , stroke(0) |
| 166 { | 166 { |
| 167 } | 167 } |
| 168 | 168 |
| 169 static PassOwnPtr<FillStrokeData> create() | 169 static PassOwnPtr<FillStrokeData> create() |
| 170 { | 170 { |
| 171 return adoptPtr(new FillStrokeData); | 171 return adoptPtr(new FillStrokeData); |
| 172 } | 172 } |
| 173 | 173 |
| 174 RenderSVGResourcePaintServer* fill; | 174 LayoutSVGResourcePaintServer* fill; |
| 175 RenderSVGResourcePaintServer* stroke; | 175 LayoutSVGResourcePaintServer* stroke; |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 OwnPtr<ClipperFilterMaskerData> m_clipperFilterMaskerData; | 178 OwnPtr<ClipperFilterMaskerData> m_clipperFilterMaskerData; |
| 179 OwnPtr<MarkerData> m_markerData; | 179 OwnPtr<MarkerData> m_markerData; |
| 180 OwnPtr<FillStrokeData> m_fillStrokeData; | 180 OwnPtr<FillStrokeData> m_fillStrokeData; |
| 181 RenderSVGResourceContainer* m_linkedResource; | 181 LayoutSVGResourceContainer* m_linkedResource; |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 } | 184 } |
| 185 | 185 |
| 186 #endif | 186 #endif |
| OLD | NEW |