| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ASSERT(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)
{ |
| 105 LayoutObject* current = layoutObject; |
| 106 while (current) { |
| 107 if (current->isSVGResourceContainer()) { |
| 108 return true; |
| 109 } |
| 110 current = current->parent(); |
| 111 } |
| 112 return false; |
| 113 } |
| 114 |
| 104 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, | 115 void SVGResourcesCache::clientStyleChanged(LayoutObject* layoutObject, |
| 105 StyleDifference diff, | 116 StyleDifference diff, |
| 106 const ComputedStyle& newStyle) { | 117 const ComputedStyle& newStyle) { |
| 107 ASSERT(layoutObject); | 118 ASSERT(layoutObject); |
| 108 ASSERT(layoutObject->node()); | 119 ASSERT(layoutObject->node()); |
| 109 ASSERT(layoutObject->node()->isSVGElement()); | 120 ASSERT(layoutObject->node()->isSVGElement()); |
| 110 | 121 |
| 111 if (!diff.hasDifference() || !layoutObject->parent()) | 122 if (!diff.hasDifference() || !layoutObject->parent()) |
| 112 return; | 123 return; |
| 113 | 124 |
| 114 // 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 |
| 115 // properties require | 126 // properties require |
| 116 // a relayout or paintInvalidation. | 127 // a relayout or paintInvalidation. |
| 117 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) | 128 if (layoutObject->isSVGResourceFilterPrimitive() && !diff.needsLayout()) |
| 118 return; | 129 return; |
| 119 | 130 |
| 120 // Dynamic changes of CSS properties like 'clip-path' may require us to | 131 // Dynamic changes of CSS properties like 'clip-path' may require us to |
| 121 // recompute the associated resources for a LayoutObject. | 132 // recompute the associated resources for a LayoutObject. |
| 122 // TODO(fs): Avoid passing in a useless StyleDifference, but instead compare | 133 // TODO(fs): Avoid passing in a useless StyleDifference, but instead compare |
| 123 // oldStyle/newStyle to see which resources changed to be able to selectively | 134 // oldStyle/newStyle to see which resources changed to be able to selectively |
| 124 // rebuild individual resources, instead of all of them. | 135 // rebuild individual resources, instead of all of them. |
| 125 if (layoutObjectCanHaveResources(layoutObject)) { | 136 if (layoutObjectCanHaveResources(layoutObject)) { |
| 126 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); | 137 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); |
| 127 cache.removeResourcesFromLayoutObject(layoutObject); | 138 cache.removeResourcesFromLayoutObject(layoutObject); |
| 128 cache.addResourcesFromLayoutObject(layoutObject, newStyle); | 139 cache.addResourcesFromLayoutObject(layoutObject, newStyle); |
| 129 } | 140 } |
| 130 | 141 |
| 142 // If this layoutObject is the child of ResourceContainer and it require |
| 143 // repainting that changes of CSS properties such as 'visibility', |
| 144 // request repainting. |
| 145 bool needsLayout = diff.needsFullPaintInvalidation() && |
| 146 isLayoutObjectOfResourceContainer(layoutObject); |
| 147 |
| 131 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( | 148 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( |
| 132 layoutObject, false); | 149 layoutObject, needsLayout); |
| 133 } | 150 } |
| 134 | 151 |
| 135 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, | 152 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, |
| 136 const ComputedStyle& newStyle) { | 153 const ComputedStyle& newStyle) { |
| 137 if (!layoutObject->node()) | 154 if (!layoutObject->node()) |
| 138 return; | 155 return; |
| 139 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( | 156 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( |
| 140 layoutObject, false); | 157 layoutObject, false); |
| 141 | 158 |
| 142 if (!layoutObjectCanHaveResources(layoutObject)) | 159 if (!layoutObjectCanHaveResources(layoutObject)) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 162 ASSERT(layoutObject); | 179 ASSERT(layoutObject); |
| 163 | 180 |
| 164 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); | 181 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); |
| 165 if (resources) | 182 if (resources) |
| 166 resources->removeClientFromCache(layoutObject); | 183 resources->removeClientFromCache(layoutObject); |
| 167 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); | 184 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); |
| 168 cache.removeResourcesFromLayoutObject(layoutObject); | 185 cache.removeResourcesFromLayoutObject(layoutObject); |
| 169 } | 186 } |
| 170 | 187 |
| 171 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |