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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef RenderSVGResourceContainer_h | 20 #ifndef RenderSVGResourceContainer_h |
21 #define RenderSVGResourceContainer_h | 21 #define RenderSVGResourceContainer_h |
22 | 22 |
23 #include "core/rendering/svg/RenderSVGHiddenContainer.h" | 23 #include "core/rendering/svg/RenderSVGHiddenContainer.h" |
24 #include "core/rendering/svg/RenderSVGResource.h" | 24 #include "core/rendering/svg/RenderSVGResource.h" |
25 | 25 |
26 namespace blink { | 26 namespace blink { |
27 | 27 |
28 class RenderLayer; | |
29 | |
30 class RenderSVGResourceContainer : public RenderSVGHiddenContainer, | 28 class RenderSVGResourceContainer : public RenderSVGHiddenContainer, |
31 public RenderSVGResource { | 29 public RenderSVGResource { |
32 public: | 30 public: |
33 explicit RenderSVGResourceContainer(SVGElement*); | 31 explicit RenderSVGResourceContainer(SVGElement*); |
34 virtual ~RenderSVGResourceContainer(); | 32 virtual ~RenderSVGResourceContainer(); |
35 | 33 |
36 virtual void layout() OVERRIDE; | 34 virtual void layout() OVERRIDE; |
37 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV
ERRIDE FINAL; | 35 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OV
ERRIDE FINAL; |
38 | 36 |
39 virtual bool isSVGResourceContainer() const OVERRIDE FINAL { return true; } | 37 virtual bool isSVGResourceContainer() const OVERRIDE FINAL { return true; } |
40 | 38 |
41 static AffineTransform transformOnNonScalingStroke(RenderObject*, const Affi
neTransform& resourceTransform); | 39 static AffineTransform transformOnNonScalingStroke(RenderObject*, const Affi
neTransform& resourceTransform); |
42 | 40 |
43 void idChanged(); | 41 void idChanged(); |
44 void addClientRenderLayer(Node*); | 42 void addClient(RenderObject*); |
45 void addClientRenderLayer(RenderLayer*); | 43 void removeClient(RenderObject*); |
46 void removeClientRenderLayer(RenderLayer*); | |
47 | 44 |
48 void invalidateCacheAndMarkForLayout(SubtreeLayoutScope* = 0); | 45 void invalidateCacheAndMarkForLayout(SubtreeLayoutScope* = 0); |
49 | 46 |
50 protected: | 47 protected: |
51 // When adding modes, make sure we don't overflow m_invalidationMask below. | 48 // When adding modes, make sure we don't overflow m_invalidationMask below. |
52 enum InvalidationMode { | 49 enum InvalidationMode { |
53 LayoutAndBoundariesInvalidation = 1 << 0, | 50 LayoutAndBoundariesInvalidation = 1 << 0, |
54 BoundariesInvalidation = 1 << 1, | 51 BoundariesInvalidation = 1 << 1, |
55 RepaintInvalidation = 1 << 2, | 52 RepaintInvalidation = 1 << 2, |
56 ParentOnlyInvalidation = 1 << 3 | 53 ParentOnlyInvalidation = 1 << 3 |
57 }; | 54 }; |
58 | 55 |
59 // Used from the invalidateClient/invalidateClients methods from classes, in
heriting from us. | 56 // Used from the invalidateClient/invalidateClients methods from classes, in
heriting from us. |
60 void markAllClientsForInvalidation(InvalidationMode); | 57 void markAllClientsForInvalidation(InvalidationMode); |
61 void markAllClientLayersForInvalidation(); | |
62 void markClientForInvalidation(RenderObject*, InvalidationMode); | 58 void markClientForInvalidation(RenderObject*, InvalidationMode); |
63 | 59 |
64 void clearInvalidationMask() { m_invalidationMask = 0; } | 60 void clearInvalidationMask() { m_invalidationMask = 0; } |
65 | 61 |
66 static AffineTransform computeResourceSpaceTransform(RenderObject*, const Af
fineTransform& baseTransform, const SVGRenderStyle&, unsigned short resourceMode
); | 62 static AffineTransform computeResourceSpaceTransform(RenderObject*, const Af
fineTransform& baseTransform, const SVGRenderStyle&, unsigned short resourceMode
); |
67 | 63 |
68 bool m_isInLayout; | 64 bool m_isInLayout; |
69 | 65 |
70 private: | 66 private: |
71 friend class SVGResourcesCache; | 67 friend class SVGResourcesCache; |
72 void addClient(RenderObject*); | |
73 void removeClient(RenderObject*); | |
74 | 68 |
75 virtual void willBeDestroyed() OVERRIDE FINAL; | 69 virtual void willBeDestroyed() OVERRIDE FINAL; |
76 void registerResource(); | 70 void registerResource(); |
77 | 71 |
78 AtomicString m_id; | 72 AtomicString m_id; |
79 // Track global (markAllClientsForInvalidation) invals to avoid redundant cr
awls. | 73 // Track global (markAllClientsForInvalidation) invals to avoid redundant cr
awls. |
80 unsigned m_invalidationMask : 8; | 74 unsigned m_invalidationMask : 8; |
81 | 75 |
82 bool m_registered : 1; | 76 bool m_registered : 1; |
83 bool m_isInvalidating : 1; | 77 bool m_isInvalidating : 1; |
84 // 22 padding bits available | 78 // 22 padding bits available |
85 | 79 |
86 HashSet<RenderObject*> m_clients; | 80 HashSet<RenderObject*> m_clients; |
87 HashSet<RenderLayer*> m_clientLayers; | |
88 }; | 81 }; |
89 | 82 |
90 inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(TreeScope&
treeScope, const AtomicString& id) | 83 inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(TreeScope&
treeScope, const AtomicString& id) |
91 { | 84 { |
92 if (id.isEmpty()) | 85 if (id.isEmpty()) |
93 return 0; | 86 return 0; |
94 | 87 |
95 if (RenderSVGResourceContainer* renderResource = treeScope.document().access
SVGExtensions().resourceById(id)) | 88 if (RenderSVGResourceContainer* renderResource = treeScope.document().access
SVGExtensions().resourceById(id)) |
96 return renderResource; | 89 return renderResource; |
97 | 90 |
98 return 0; | 91 return 0; |
99 } | 92 } |
100 | 93 |
101 template<typename Renderer> | 94 template<typename Renderer> |
102 Renderer* getRenderSVGResourceById(TreeScope& treeScope, const AtomicString& id) | 95 Renderer* getRenderSVGResourceById(TreeScope& treeScope, const AtomicString& id) |
103 { | 96 { |
104 if (RenderSVGResourceContainer* container = getRenderSVGResourceContainerByI
d(treeScope, id)) | 97 if (RenderSVGResourceContainer* container = getRenderSVGResourceContainerByI
d(treeScope, id)) |
105 return container->cast<Renderer>(); | 98 return container->cast<Renderer>(); |
106 | 99 |
107 return 0; | 100 return 0; |
108 } | 101 } |
109 | 102 |
110 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceContainer, isSVGResourceContain
er()); | 103 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderSVGResourceContainer, isSVGResourceContain
er()); |
111 | 104 |
112 } | 105 } |
113 | 106 |
114 #endif | 107 #endif |
OLD | NEW |