| 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 30 matching lines...) Expand all Loading... |
| 41 : LayoutSVGHiddenContainer(node), | 41 : LayoutSVGHiddenContainer(node), |
| 42 m_isInLayout(false), | 42 m_isInLayout(false), |
| 43 m_id(node->getIdAttribute()), | 43 m_id(node->getIdAttribute()), |
| 44 m_invalidationMask(0), | 44 m_invalidationMask(0), |
| 45 m_registered(false), | 45 m_registered(false), |
| 46 m_isInvalidating(false) {} | 46 m_isInvalidating(false) {} |
| 47 | 47 |
| 48 LayoutSVGResourceContainer::~LayoutSVGResourceContainer() {} | 48 LayoutSVGResourceContainer::~LayoutSVGResourceContainer() {} |
| 49 | 49 |
| 50 void LayoutSVGResourceContainer::layout() { | 50 void LayoutSVGResourceContainer::layout() { |
| 51 // FIXME: Investigate a way to detect and break resource layout dependency cyc
les early. | 51 // FIXME: Investigate a way to detect and break resource layout dependency |
| 52 // Then we can remove this method altogether, and fall back onto LayoutSVGHidd
enContainer::layout(). | 52 // cycles early. Then we can remove this method altogether, and fall back onto |
| 53 // LayoutSVGHiddenContainer::layout(). |
| 53 ASSERT(needsLayout()); | 54 ASSERT(needsLayout()); |
| 54 if (m_isInLayout) | 55 if (m_isInLayout) |
| 55 return; | 56 return; |
| 56 | 57 |
| 57 AutoReset<bool> inLayoutChange(&m_isInLayout, true); | 58 AutoReset<bool> inLayoutChange(&m_isInLayout, true); |
| 58 | 59 |
| 59 LayoutSVGHiddenContainer::layout(); | 60 LayoutSVGHiddenContainer::layout(); |
| 60 | 61 |
| 61 clearInvalidationMask(); | 62 clearInvalidationMask(); |
| 62 } | 63 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 85 registerResource(); | 86 registerResource(); |
| 86 } | 87 } |
| 87 } | 88 } |
| 88 | 89 |
| 89 void LayoutSVGResourceContainer::detachAllClients() { | 90 void LayoutSVGResourceContainer::detachAllClients() { |
| 90 for (auto* client : m_clients) { | 91 for (auto* client : m_clients) { |
| 91 // Unlink the resource from the client's SVGResources. (The actual | 92 // Unlink the resource from the client's SVGResources. (The actual |
| 92 // removal will be signaled after processing all the clients.) | 93 // removal will be signaled after processing all the clients.) |
| 93 SVGResources* resources = | 94 SVGResources* resources = |
| 94 SVGResourcesCache::cachedResourcesForLayoutObject(client); | 95 SVGResourcesCache::cachedResourcesForLayoutObject(client); |
| 95 ASSERT( | 96 // Or else the client wouldn't be in the list in the first place. |
| 96 resources); // Or else the client wouldn't be in the list in the first
place. | 97 DCHECK(resources); |
| 97 resources->resourceDestroyed(this); | 98 resources->resourceDestroyed(this); |
| 98 | 99 |
| 99 // Add a pending resolution based on the id of the old resource. | 100 // Add a pending resolution based on the id of the old resource. |
| 100 Element* clientElement = toElement(client->node()); | 101 Element* clientElement = toElement(client->node()); |
| 101 svgExtensionsFromElement(clientElement) | 102 svgExtensionsFromElement(clientElement) |
| 102 .addPendingResource(m_id, clientElement); | 103 .addPendingResource(m_id, clientElement); |
| 103 } | 104 } |
| 104 | 105 |
| 105 removeAllClientsFromCache(); | 106 removeAllClientsFromCache(); |
| 106 } | 107 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 for (const auto& pendingClient : *clients) { | 234 for (const auto& pendingClient : *clients) { |
| 234 ASSERT(pendingClient->hasPendingResources()); | 235 ASSERT(pendingClient->hasPendingResources()); |
| 235 extensions.clearHasPendingResourcesIfPossible(pendingClient); | 236 extensions.clearHasPendingResourcesIfPossible(pendingClient); |
| 236 LayoutObject* layoutObject = pendingClient->layoutObject(); | 237 LayoutObject* layoutObject = pendingClient->layoutObject(); |
| 237 if (!layoutObject) | 238 if (!layoutObject) |
| 238 continue; | 239 continue; |
| 239 | 240 |
| 240 const ComputedStyle& style = layoutObject->styleRef(); | 241 const ComputedStyle& style = layoutObject->styleRef(); |
| 241 | 242 |
| 242 // If the client has a layer (is a non-SVGElement) we need to signal | 243 // If the client has a layer (is a non-SVGElement) we need to signal |
| 243 // invalidation in the same way as is done in markAllResourceClientsForInval
idation above. | 244 // invalidation in the same way as is done in |
| 245 // markAllResourceClientsForInvalidation above. |
| 244 if (layoutObject->hasLayer() && resourceType() == FilterResourceType) { | 246 if (layoutObject->hasLayer() && resourceType() == FilterResourceType) { |
| 245 if (!style.hasFilter()) | 247 if (!style.hasFilter()) |
| 246 continue; | 248 continue; |
| 247 toLayoutBoxModelObject(layoutObject) | 249 toLayoutBoxModelObject(layoutObject) |
| 248 ->layer() | 250 ->layer() |
| 249 ->filterNeedsPaintInvalidation(); | 251 ->filterNeedsPaintInvalidation(); |
| 250 if (!layoutObject->isSVGRoot()) | 252 if (!layoutObject->isSVGRoot()) |
| 251 continue; | 253 continue; |
| 252 // A root SVG element with a filter, however, still needs to run | 254 // A root SVG element with a filter, however, still needs to run |
| 253 // the full invalidation step below. | 255 // the full invalidation step below. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 278 } | 280 } |
| 279 | 281 |
| 280 if (!object->node() || !object->node()->isSVGElement()) | 282 if (!object->node() || !object->node()->isSVGElement()) |
| 281 return; | 283 return; |
| 282 | 284 |
| 283 SVGElementSet* dependencies = | 285 SVGElementSet* dependencies = |
| 284 toSVGElement(object->node())->setOfIncomingReferences(); | 286 toSVGElement(object->node())->setOfIncomingReferences(); |
| 285 if (!dependencies) | 287 if (!dependencies) |
| 286 return; | 288 return; |
| 287 | 289 |
| 288 // We allow cycles in SVGDocumentExtensions reference sets in order to avoid e
xpensive | 290 // We allow cycles in SVGDocumentExtensions reference sets in order to avoid |
| 289 // reference graph adjustments on changes, so we need to break possible cycles
here. | 291 // expensive reference graph adjustments on changes, so we need to break |
| 290 // This strong reference is safe, as it is guaranteed that this set will be em
ptied | 292 // possible cycles here. |
| 291 // at the end of recursion. | 293 // This strong reference is safe, as it is guaranteed that this set will be |
| 294 // emptied at the end of recursion. |
| 292 DEFINE_STATIC_LOCAL(SVGElementSet, invalidatingDependencies, | 295 DEFINE_STATIC_LOCAL(SVGElementSet, invalidatingDependencies, |
| 293 (new SVGElementSet)); | 296 (new SVGElementSet)); |
| 294 | 297 |
| 295 for (SVGElement* element : *dependencies) { | 298 for (SVGElement* element : *dependencies) { |
| 296 if (LayoutObject* layoutObject = element->layoutObject()) { | 299 if (LayoutObject* layoutObject = element->layoutObject()) { |
| 297 if (UNLIKELY(!invalidatingDependencies.add(element).isNewEntry)) { | 300 if (UNLIKELY(!invalidatingDependencies.add(element).isNewEntry)) { |
| 298 // Reference cycle: we are in process of invalidating this dependant. | 301 // Reference cycle: we are in process of invalidating this dependant. |
| 299 continue; | 302 continue; |
| 300 } | 303 } |
| 301 | 304 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 327 // This will process the rest of the ancestors. | 330 // This will process the rest of the ancestors. |
| 328 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); | 331 toLayoutSVGResourceContainer(current)->removeAllClientsFromCache(); |
| 329 break; | 332 break; |
| 330 } | 333 } |
| 331 | 334 |
| 332 current = current->parent(); | 335 current = current->parent(); |
| 333 } | 336 } |
| 334 } | 337 } |
| 335 | 338 |
| 336 } // namespace blink | 339 } // namespace blink |
| OLD | NEW |