Chromium Code Reviews| 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 bool needsLayout = diff.needsPaintInvalidation() && | |
|
fs
2017/02/20 09:07:43
It would be good to add a comment here to describe
hyunjunekim2
2017/03/13 10:40:11
Done. Added a comment. Could you check it? Thank y
| |
| 143 isLayoutObjectOfResourceContainer(layoutObject); | |
| 144 | |
| 131 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( | 145 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( |
| 132 layoutObject, false); | 146 layoutObject, needsLayout); |
| 133 } | 147 } |
| 134 | 148 |
| 135 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, | 149 void SVGResourcesCache::clientWasAddedToTree(LayoutObject* layoutObject, |
| 136 const ComputedStyle& newStyle) { | 150 const ComputedStyle& newStyle) { |
| 137 if (!layoutObject->node()) | 151 if (!layoutObject->node()) |
| 138 return; | 152 return; |
| 139 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( | 153 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation( |
| 140 layoutObject, false); | 154 layoutObject, false); |
| 141 | 155 |
| 142 if (!layoutObjectCanHaveResources(layoutObject)) | 156 if (!layoutObjectCanHaveResources(layoutObject)) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 162 ASSERT(layoutObject); | 176 ASSERT(layoutObject); |
| 163 | 177 |
| 164 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); | 178 SVGResources* resources = cachedResourcesForLayoutObject(layoutObject); |
| 165 if (resources) | 179 if (resources) |
| 166 resources->removeClientFromCache(layoutObject); | 180 resources->removeClientFromCache(layoutObject); |
| 167 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); | 181 SVGResourcesCache& cache = resourcesCache(layoutObject->document()); |
| 168 cache.removeResourcesFromLayoutObject(layoutObject); | 182 cache.removeResourcesFromLayoutObject(layoutObject); |
| 169 } | 183 } |
| 170 | 184 |
| 171 } // namespace blink | 185 } // namespace blink |
| OLD | NEW |