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 LayoutSVGResourceContainer_h | 20 #ifndef LayoutSVGResourceContainer_h |
21 #define LayoutSVGResourceContainer_h | 21 #define LayoutSVGResourceContainer_h |
22 | 22 |
23 #include "core/layout/svg/LayoutSVGHiddenContainer.h" | 23 #include "core/layout/svg/LayoutSVGHiddenContainer.h" |
24 #include "core/svg/SVGDocumentExtensions.h" | 24 #include "core/svg/SVGDocumentExtensions.h" |
25 #include "core/svg/SVGResourceClient.h" | |
26 #include "platform/heap/Handle.h" | |
27 | 25 |
28 namespace blink { | 26 namespace blink { |
29 | 27 |
| 28 class SVGElementProxySet; |
| 29 |
30 enum LayoutSVGResourceType { | 30 enum LayoutSVGResourceType { |
31 MaskerResourceType, | 31 MaskerResourceType, |
32 MarkerResourceType, | 32 MarkerResourceType, |
33 PatternResourceType, | 33 PatternResourceType, |
34 LinearGradientResourceType, | 34 LinearGradientResourceType, |
35 RadialGradientResourceType, | 35 RadialGradientResourceType, |
36 FilterResourceType, | 36 FilterResourceType, |
37 ClipperResourceType | 37 ClipperResourceType |
38 }; | 38 }; |
39 | 39 |
40 class PaintLayer; | |
41 | |
42 class LayoutSVGResourceContainer : public LayoutSVGHiddenContainer { | 40 class LayoutSVGResourceContainer : public LayoutSVGHiddenContainer { |
43 public: | 41 public: |
44 explicit LayoutSVGResourceContainer(SVGElement*); | 42 explicit LayoutSVGResourceContainer(SVGElement*); |
45 ~LayoutSVGResourceContainer() override; | 43 ~LayoutSVGResourceContainer() override; |
46 | 44 |
47 virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0; | 45 virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0; |
48 virtual void removeClientFromCache(LayoutObject*, | 46 virtual void removeClientFromCache(LayoutObject*, |
49 bool markForInvalidation = true) = 0; | 47 bool markForInvalidation = true) = 0; |
50 | 48 |
51 void layout() override; | 49 void layout() override; |
52 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) final; | 50 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) final; |
53 bool isOfType(LayoutObjectType type) const override { | 51 bool isOfType(LayoutObjectType type) const override { |
54 return type == LayoutObjectSVGResourceContainer || | 52 return type == LayoutObjectSVGResourceContainer || |
55 LayoutSVGHiddenContainer::isOfType(type); | 53 LayoutSVGHiddenContainer::isOfType(type); |
56 } | 54 } |
57 | 55 |
58 virtual LayoutSVGResourceType resourceType() const = 0; | 56 virtual LayoutSVGResourceType resourceType() const = 0; |
59 | 57 |
60 bool isSVGPaintServer() const { | 58 bool isSVGPaintServer() const { |
61 LayoutSVGResourceType resourceType = this->resourceType(); | 59 LayoutSVGResourceType resourceType = this->resourceType(); |
62 return resourceType == PatternResourceType || | 60 return resourceType == PatternResourceType || |
63 resourceType == LinearGradientResourceType || | 61 resourceType == LinearGradientResourceType || |
64 resourceType == RadialGradientResourceType; | 62 resourceType == RadialGradientResourceType; |
65 } | 63 } |
66 | 64 |
67 void idChanged(); | 65 void idChanged(); |
68 void addResourceClient(SVGResourceClient*); | |
69 void removeResourceClient(SVGResourceClient*); | |
70 | 66 |
71 void invalidateCacheAndMarkForLayout(SubtreeLayoutScope* = nullptr); | 67 void invalidateCacheAndMarkForLayout(SubtreeLayoutScope* = nullptr); |
72 | 68 |
73 static void markForLayoutAndParentResourceInvalidation( | 69 static void markForLayoutAndParentResourceInvalidation( |
74 LayoutObject*, | 70 LayoutObject*, |
75 bool needsLayout = true); | 71 bool needsLayout = true); |
76 | 72 |
77 void clearInvalidationMask() { m_invalidationMask = 0; } | 73 void clearInvalidationMask() { m_invalidationMask = 0; } |
78 | 74 |
79 protected: | 75 protected: |
80 // When adding modes, make sure we don't overflow m_invalidationMask below. | 76 // When adding modes, make sure we don't overflow m_invalidationMask below. |
81 enum InvalidationMode { | 77 enum InvalidationMode { |
82 LayoutAndBoundariesInvalidation = 1 << 0, | 78 LayoutAndBoundariesInvalidation = 1 << 0, |
83 BoundariesInvalidation = 1 << 1, | 79 BoundariesInvalidation = 1 << 1, |
84 PaintInvalidation = 1 << 2, | 80 PaintInvalidation = 1 << 2, |
85 ParentOnlyInvalidation = 1 << 3 | 81 ParentOnlyInvalidation = 1 << 3 |
86 }; | 82 }; |
87 | 83 |
88 // Used from the invalidateClient/invalidateClients methods from classes, | 84 // Used from the invalidateClient/invalidateClients methods from classes, |
89 // inheriting from us. | 85 // inheriting from us. |
90 void markAllClientsForInvalidation(InvalidationMode); | 86 void markAllClientsForInvalidation(InvalidationMode); |
91 void markAllResourceClientsForInvalidation(); | |
92 void markClientForInvalidation(LayoutObject*, InvalidationMode); | 87 void markClientForInvalidation(LayoutObject*, InvalidationMode); |
93 | 88 |
| 89 void notifyContentChanged(); |
| 90 void invalidateProxies(); |
| 91 virtual SVGElementProxySet* elementProxySet() { return nullptr; } |
| 92 |
94 void willBeDestroyed() override; | 93 void willBeDestroyed() override; |
95 | 94 |
96 bool m_isInLayout; | 95 bool m_isInLayout; |
97 | 96 |
98 private: | 97 private: |
99 friend class SVGResourcesCache; | 98 friend class SVGResourcesCache; |
100 void addClient(LayoutObject*); | 99 void addClient(LayoutObject*); |
101 void removeClient(LayoutObject*); | 100 void removeClient(LayoutObject*); |
102 void detachAllClients(); | 101 void detachAllClients(); |
103 | 102 |
104 void registerResource(); | 103 void registerResource(); |
105 | 104 |
106 AtomicString m_id; | 105 AtomicString m_id; |
107 // Track global (markAllClientsForInvalidation) invals to avoid redundant | 106 // Track global (markAllClientsForInvalidation) invals to avoid redundant |
108 // crawls. | 107 // crawls. |
109 unsigned m_invalidationMask : 8; | 108 unsigned m_invalidationMask : 8; |
110 | 109 |
111 unsigned m_registered : 1; | 110 unsigned m_registered : 1; |
112 unsigned m_isInvalidating : 1; | 111 unsigned m_isInvalidating : 1; |
113 // 22 padding bits available | 112 // 22 padding bits available |
114 | 113 |
115 HashSet<LayoutObject*> m_clients; | 114 HashSet<LayoutObject*> m_clients; |
116 PersistentHeapHashSet<WeakMember<SVGResourceClient>> m_resourceClients; | |
117 }; | 115 }; |
118 | 116 |
119 inline LayoutSVGResourceContainer* getLayoutSVGResourceContainerById( | 117 inline LayoutSVGResourceContainer* getLayoutSVGResourceContainerById( |
120 TreeScope& treeScope, | 118 TreeScope& treeScope, |
121 const AtomicString& id) { | 119 const AtomicString& id) { |
122 if (id.isEmpty()) | 120 if (id.isEmpty()) |
123 return nullptr; | 121 return nullptr; |
124 | 122 |
125 if (LayoutSVGResourceContainer* layoutResource = | 123 if (LayoutSVGResourceContainer* layoutResource = |
126 treeScope.document().accessSVGExtensions().resourceById(id)) | 124 treeScope.document().accessSVGExtensions().resourceById(id)) |
(...skipping 16 matching lines...) Expand all Loading... |
143 isSVGResourceContainer()); | 141 isSVGResourceContainer()); |
144 | 142 |
145 #define DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ | 143 #define DEFINE_LAYOUT_SVG_RESOURCE_TYPE_CASTS(thisType, typeName) \ |
146 DEFINE_TYPE_CASTS(thisType, LayoutSVGResourceContainer, resource, \ | 144 DEFINE_TYPE_CASTS(thisType, LayoutSVGResourceContainer, resource, \ |
147 resource->resourceType() == typeName, \ | 145 resource->resourceType() == typeName, \ |
148 resource.resourceType() == typeName) | 146 resource.resourceType() == typeName) |
149 | 147 |
150 } // namespace blink | 148 } // namespace blink |
151 | 149 |
152 #endif | 150 #endif |
OLD | NEW |