| 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 18 matching lines...) Expand all Loading... |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 SVGResourcesCache::SVGResourcesCache() | 31 SVGResourcesCache::SVGResourcesCache() |
| 32 { | 32 { |
| 33 } | 33 } |
| 34 | 34 |
| 35 SVGResourcesCache::~SVGResourcesCache() | 35 SVGResourcesCache::~SVGResourcesCache() |
| 36 { | 36 { |
| 37 } | 37 } |
| 38 | 38 |
| 39 void SVGResourcesCache::addResourcesFromLayoutObject(LayoutObject* object, const
LayoutStyle& style) | 39 void SVGResourcesCache::addResourcesFromLayoutObject(LayoutObject* object, const
ComputedStyle& style) |
| 40 { | 40 { |
| 41 ASSERT(object); | 41 ASSERT(object); |
| 42 ASSERT(!m_cache.contains(object)); | 42 ASSERT(!m_cache.contains(object)); |
| 43 | 43 |
| 44 const SVGLayoutStyle& svgStyle = style.svgStyle(); | 44 const SVGComputedStyle& svgStyle = style.svgStyle(); |
| 45 | 45 |
| 46 // Build a list of all resources associated with the passed LayoutObject | 46 // Build a list of all resources associated with the passed LayoutObject |
| 47 OwnPtr<SVGResources> newResources = SVGResources::buildResources(object, svg
Style); | 47 OwnPtr<SVGResources> newResources = SVGResources::buildResources(object, svg
Style); |
| 48 if (!newResources) | 48 if (!newResources) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 // Put object in cache. | 51 // Put object in cache. |
| 52 SVGResources* resources = m_cache.set(object, newResources.release()).stored
Value->value.get(); | 52 SVGResources* resources = m_cache.set(object, newResources.release()).stored
Value->value.get(); |
| 53 | 53 |
| 54 // Run cycle-detection _afterwards_, so self-references can be caught as wel
l. | 54 // Run cycle-detection _afterwards_, so self-references can be caught as wel
l. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (object->selfNeedsLayout() || resources->filter()) | 105 if (object->selfNeedsLayout() || resources->filter()) |
| 106 resources->removeClientFromCache(object); | 106 resources->removeClientFromCache(object); |
| 107 } | 107 } |
| 108 | 108 |
| 109 static inline bool layoutObjectCanHaveResources(LayoutObject* layoutObject) | 109 static inline bool layoutObjectCanHaveResources(LayoutObject* layoutObject) |
| 110 { | 110 { |
| 111 ASSERT(layoutObject); | 111 ASSERT(layoutObject); |
| 112 return layoutObject->node() && layoutObject->node()->isSVGElement() && !layo
utObject->isSVGInlineText(); | 112 return layoutObject->node() && layoutObject->node()->isSVGElement() && !layo
utObject->isSVGInlineText(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, StyleDiff
erence diff, const LayoutStyle& newStyle) | 115 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, StyleDiff
erence diff, const ComputedStyle& newStyle) |
| 116 { | 116 { |
| 117 ASSERT(layoutObject); | 117 ASSERT(layoutObject); |
| 118 ASSERT(layoutObject->node()); | 118 ASSERT(layoutObject->node()); |
| 119 ASSERT(layoutObject->node()->isSVGElement()); | 119 ASSERT(layoutObject->node()->isSVGElement()); |
| 120 | 120 |
| 121 if (!diff.hasDifference() || !layoutObject->parent()) | 121 if (!diff.hasDifference() || !layoutObject->parent()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 // In this case the proper SVGFE*Element will decide whether the modified CS
S properties require a relayout or paintInvalidation. | 124 // In this case the proper SVGFE*Element will decide whether the modified CS
S properties require a relayout or paintInvalidation. |
| 125 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) | 125 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // Dynamic changes of CSS properties like 'clip-path' may require us to reco
mpute the associated resources for a layoutObject. | 128 // Dynamic changes of CSS properties like 'clip-path' may require us to reco
mpute the associated resources for a layoutObject. |
| 129 // FIXME: Avoid passing in a useless StyleDifference, but instead compare ol
dStyle/newStyle to see which resources changed | 129 // FIXME: Avoid passing in a useless StyleDifference, but instead compare ol
dStyle/newStyle to see which resources changed |
| 130 // to be able to selectively rebuild individual resources, instead of all of
them. | 130 // to be able to selectively rebuild individual resources, instead of all of
them. |
| 131 if (layoutObjectCanHaveResources(layoutObject)) { | 131 if (layoutObjectCanHaveResources(layoutObject)) { |
| 132 SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); | 132 SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); |
| 133 cache->removeResourcesFromLayoutObject(layoutObject); | 133 cache->removeResourcesFromLayoutObject(layoutObject); |
| 134 cache->addResourcesFromLayoutObject(layoutObject, newStyle); | 134 cache->addResourcesFromLayoutObject(layoutObject, newStyle); |
| 135 } | 135 } |
| 136 | 136 |
| 137 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); | 137 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, const L
ayoutStyle& newStyle) | 140 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, const C
omputedStyle& newStyle) |
| 141 { | 141 { |
| 142 if (!layoutObject->node()) | 142 if (!layoutObject->node()) |
| 143 return; | 143 return; |
| 144 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); | 144 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou
tObject, false); |
| 145 | 145 |
| 146 if (!layoutObjectCanHaveResources(layoutObject)) | 146 if (!layoutObjectCanHaveResources(layoutObject)) |
| 147 return; | 147 return; |
| 148 SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); | 148 SVGResourcesCache* cache = resourcesCacheFromLayoutObject(layoutObject); |
| 149 cache->addResourcesFromLayoutObject(layoutObject, newStyle); | 149 cache->addResourcesFromLayoutObject(layoutObject, newStyle); |
| 150 } | 150 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Mark users of destroyed resources as pending resolution based on the
id of the old resource. | 187 // Mark users of destroyed resources as pending resolution based on the
id of the old resource. |
| 188 Element* resourceElement = resource->element(); | 188 Element* resourceElement = resource->element(); |
| 189 Element* clientElement = toElement(objectResources.key->node()); | 189 Element* clientElement = toElement(objectResources.key->node()); |
| 190 SVGDocumentExtensions& extensions = clientElement->document().accessSVGE
xtensions(); | 190 SVGDocumentExtensions& extensions = clientElement->document().accessSVGE
xtensions(); |
| 191 | 191 |
| 192 extensions.addPendingResource(resourceElement->fastGetAttribute(HTMLName
s::idAttr), clientElement); | 192 extensions.addPendingResource(resourceElement->fastGetAttribute(HTMLName
s::idAttr), clientElement); |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 } | 196 } |
| OLD | NEW |