| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 SVGResourcesCache::SVGResourcesCache() {} | 31 SVGResourcesCache::SVGResourcesCache() {} |
| 32 | 32 |
| 33 SVGResourcesCache::~SVGResourcesCache() {} | 33 SVGResourcesCache::~SVGResourcesCache() {} |
| 34 | 34 |
| 35 void SVGResourcesCache::addResourcesFromLayoutObject( | 35 void SVGResourcesCache::addResourcesFromLayoutObject( |
| 36 LayoutObject* object, | 36 LayoutObject* object, |
| 37 const ComputedStyle& style) { | 37 const ComputedStyle& style) { |
| 38 ASSERT(object); | 38 DCHECK(object); |
| 39 ASSERT(!m_cache.contains(object)); | 39 DCHECK(!m_cache.contains(object)); |
| 40 | 40 |
| 41 // Build a list of all resources associated with the passed LayoutObject. | 41 // Build a list of all resources associated with the passed LayoutObject. |
| 42 std::unique_ptr<SVGResources> newResources = | 42 std::unique_ptr<SVGResources> newResources = |
| 43 SVGResources::buildResources(object, style); | 43 SVGResources::buildResources(object, style); |
| 44 if (!newResources) | 44 if (!newResources) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 // Put object in cache. | 47 // Put object in cache. |
| 48 SVGResources* resources = | 48 SVGResources* resources = |
| 49 m_cache.set(object, std::move(newResources)).storedValue->value.get(); | 49 m_cache.set(object, std::move(newResources)).storedValue->value.get(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 73 for (auto* resourceContainer : resourceSet) | 73 for (auto* resourceContainer : resourceSet) |
| 74 resourceContainer->removeClient(object); | 74 resourceContainer->removeClient(object); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static inline SVGResourcesCache& resourcesCache(Document& document) { | 77 static inline SVGResourcesCache& resourcesCache(Document& document) { |
| 78 return document.accessSVGExtensions().resourcesCache(); | 78 return document.accessSVGExtensions().resourcesCache(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 SVGResources* SVGResourcesCache::cachedResourcesForLayoutObject( | 81 SVGResources* SVGResourcesCache::cachedResourcesForLayoutObject( |
| 82 const LayoutObject* layoutObject) { | 82 const LayoutObject* layoutObject) { |
| 83 ASSERT(layoutObject); | 83 DCHECK(layoutObject); |
| 84 return resourcesCache(layoutObject->document()).m_cache.at(layoutObject); | 84 return resourcesCache(layoutObject->document()).m_cache.at(layoutObject); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void SVGResourcesCache::clientLayoutChanged(LayoutObject* object) { | 87 void SVGResourcesCache::clientLayoutChanged(LayoutObject* object) { |
| 88 SVGResources* resources = cachedResourcesForLayoutObject(object); | 88 SVGResources* resources = cachedResourcesForLayoutObject(object); |
| 89 if (!resources) | 89 if (!resources) |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 // Invalidate the resources if either the LayoutObject itself changed, | 92 // Invalidate the resources if either the LayoutObject itself changed, |
| 93 // or we have filter resources, which could depend on the layout of children. | 93 // or we have filter resources, which could depend on the layout of children. |
| 94 if (object->selfNeedsLayout() || resources->filter()) | 94 if (object->selfNeedsLayout() || resources->filter()) |
| 95 resources->removeClientFromCache(object); | 95 resources->removeClientFromCache(object); |
| 96 } | 96 } |
| 97 | 97 |
| 98 static inline bool layoutObjectCanHaveResources(LayoutObject* layoutObject) { | 98 static inline bool layoutObjectCanHaveResources(LayoutObject* layoutObject) { |
| 99 ASSERT(layoutObject); | 99 DCHECK(layoutObject); |
| 100 return layoutObject->node() && layoutObject->node()->isSVGElement() && | 100 return layoutObject->node() && layoutObject->node()->isSVGElement() && |
| 101 !layoutObject->isSVGInlineText(); | 101 !layoutObject->isSVGInlineText(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static inline bool isLayoutObjectOfResourceContainer(LayoutObject* layoutObject)
{ | 104 static inline bool isLayoutObjectOfResourceContainer(LayoutObject* layoutObject)
{ |
| 105 LayoutObject* current = layoutObject; | 105 LayoutObject* current = layoutObject; |
| 106 while (current) { | 106 while (current) { |
| 107 if (current->isSVGResourceContainer()) { | 107 if (current->isSVGResourceContainer()) { |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 current = current->parent(); | 110 current = current->parent(); |
| 111 } | 111 } |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, | 115 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, |
| 116 StyleDifference diff, | 116 StyleDifference diff, |
| 117 const ComputedStyle& newStyle) { | 117 const ComputedStyle& newStyle) { |
| 118 ASSERT(layoutObject); | 118 DCHECK(layoutObject); |
| 119 ASSERT(layoutObject->node()); | 119 DCHECK(layoutObject->node()); |
| 120 ASSERT(layoutObject->node()->isSVGElement()); | 120 DCHECK(layoutObject->node()->isSVGElement()); |
| 121 | 121 |
| 122 if (!diff.hasDifference() || !layoutObject->parent()) | 122 if (!diff.hasDifference() || !layoutObject->parent()) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 // In this case the proper SVGFE*Element will decide whether the modified CSS | 125 // In this case the proper SVGFE*Element will decide whether the modified CSS |
| 126 // properties require | 126 // properties require |
| 127 // a relayout or paintInvalidation. | 127 // a relayout or paintInvalidation. |
| 128 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) | 128 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) |
| 129 return; | 129 return; |
| 130 | 130 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( | 169 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( |
| 170 layoutObject, false); | 170 layoutObject, false); |
| 171 | 171 |
| 172 if (!layoutObjectCanHaveResources(layoutObject)) | 172 if (!layoutObjectCanHaveResources(layoutObject)) |
| 173 return; | 173 return; |
| 174 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); | 174 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); |
| 175 cache.removeResourcesFromLayoutObject(layoutObject); | 175 cache.removeResourcesFromLayoutObject(layoutObject); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void SVGResourcesCache::clientDestroyed(LayoutObject* layoutObject) { | 178 void SVGResourcesCache::clientDestroyed(LayoutObject* layoutObject) { |
| 179 ASSERT(layoutObject); | 179 DCHECK(layoutObject); |
| 180 | 180 |
| 181 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); | 181 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); |
| 182 if (resources) | 182 if (resources) |
| 183 resources->removeClientFromCache(layoutObject); | 183 resources->removeClientFromCache(layoutObject); |
| 184 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); | 184 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); |
| 185 cache.removeResourcesFromLayoutObject(layoutObject); | 185 cache.removeResourcesFromLayoutObject(layoutObject); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |