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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 template <> | 150 template <> |
151 bool IsResourceOfType<LayoutSVGResourceContainer>( | 151 bool IsResourceOfType<LayoutSVGResourceContainer>( |
152 LayoutSVGResourceContainer* container) { | 152 LayoutSVGResourceContainer* container) { |
153 return true; | 153 return true; |
154 } | 154 } |
155 | 155 |
156 template <typename ContainerType> | 156 template <typename ContainerType> |
157 ContainerType* AttachToResource(SVGTreeScopeResources& tree_scope_resources, | 157 ContainerType* AttachToResource(SVGTreeScopeResources& tree_scope_resources, |
158 const AtomicString& id, | 158 const AtomicString& id, |
159 SVGElement& element) { | 159 SVGElement& element) { |
160 if (LayoutSVGResourceContainer* container = | 160 SVGTreeScopeResources::Resource* resource = |
161 tree_scope_resources.ResourceById(id)) { | 161 tree_scope_resources.ResourceForId(id); |
| 162 if (!resource) |
| 163 return nullptr; |
| 164 if (LayoutSVGResourceContainer* container = resource->ResourceContainer()) { |
162 if (IsResourceOfType<ContainerType>(container)) | 165 if (IsResourceOfType<ContainerType>(container)) |
163 return static_cast<ContainerType*>(container); | 166 return static_cast<ContainerType*>(container); |
164 } | 167 } |
165 tree_scope_resources.AddPendingResource(id, element); | 168 resource->AddWatch(element); |
166 return nullptr; | 169 return nullptr; |
167 } | 170 } |
168 } | 171 } |
169 | 172 |
170 bool SVGResources::HasResourceData() const { | 173 bool SVGResources::HasResourceData() const { |
171 return clipper_filter_masker_data_ || marker_data_ || fill_stroke_data_ || | 174 return clipper_filter_masker_data_ || marker_data_ || fill_stroke_data_ || |
172 linked_resource_; | 175 linked_resource_; |
173 } | 176 } |
174 | 177 |
175 static inline SVGResources& EnsureResources( | 178 static inline SVGResources& EnsureResources( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 AtomicString id = TargetReferenceFromResource(element); | 275 AtomicString id = TargetReferenceFromResource(element); |
273 EnsureResources(resources).SetLinkedResource( | 276 EnsureResources(resources).SetLinkedResource( |
274 AttachToResource<LayoutSVGResourceContainer>(tree_scope_resources, id, | 277 AttachToResource<LayoutSVGResourceContainer>(tree_scope_resources, id, |
275 element)); | 278 element)); |
276 } | 279 } |
277 | 280 |
278 return (!resources || !resources->HasResourceData()) ? nullptr | 281 return (!resources || !resources->HasResourceData()) ? nullptr |
279 : std::move(resources); | 282 : std::move(resources); |
280 } | 283 } |
281 | 284 |
| 285 void SVGResources::RemoveUnreferencedResources(const LayoutObject& object) { |
| 286 SVGTreeScopeResources& tree_scope_resources = |
| 287 ToSVGElement(*object.GetNode()) |
| 288 .TreeScopeForIdResolution() |
| 289 .EnsureSVGTreeScopedResources(); |
| 290 tree_scope_resources.RemoveUnreferencedResources(); |
| 291 } |
| 292 |
| 293 void SVGResources::RemoveWatchesForElement(Element& element) { |
| 294 SECURITY_DCHECK(element.IsSVGElement()); |
| 295 SVGElement& svg_element = ToSVGElement(element); |
| 296 SVGTreeScopeResources& tree_scope_resources = |
| 297 svg_element.TreeScopeForIdResolution().EnsureSVGTreeScopedResources(); |
| 298 tree_scope_resources.RemoveWatchesForElement(svg_element); |
| 299 } |
| 300 |
282 void SVGResources::LayoutIfNeeded() { | 301 void SVGResources::LayoutIfNeeded() { |
283 if (clipper_filter_masker_data_) { | 302 if (clipper_filter_masker_data_) { |
284 if (LayoutSVGResourceClipper* clipper = | 303 if (LayoutSVGResourceClipper* clipper = |
285 clipper_filter_masker_data_->clipper) | 304 clipper_filter_masker_data_->clipper) |
286 clipper->LayoutIfNeeded(); | 305 clipper->LayoutIfNeeded(); |
287 if (LayoutSVGResourceMasker* masker = clipper_filter_masker_data_->masker) | 306 if (LayoutSVGResourceMasker* masker = clipper_filter_masker_data_->masker) |
288 masker->LayoutIfNeeded(); | 307 masker->LayoutIfNeeded(); |
289 if (LayoutSVGResourceFilter* filter = clipper_filter_masker_data_->filter) | 308 if (LayoutSVGResourceFilter* filter = clipper_filter_masker_data_->filter) |
290 filter->LayoutIfNeeded(); | 309 filter->LayoutIfNeeded(); |
291 } | 310 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 stroke->GetElement()); | 673 stroke->GetElement()); |
655 } | 674 } |
656 | 675 |
657 if (linked_resource_) | 676 if (linked_resource_) |
658 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", linked_resource_, | 677 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", linked_resource_, |
659 linked_resource_->GetElement()); | 678 linked_resource_->GetElement()); |
660 } | 679 } |
661 #endif | 680 #endif |
662 | 681 |
663 } // namespace blink | 682 } // namespace blink |
OLD | NEW |