Chromium Code Reviews| Index: Source/core/svg/SVGElement.cpp |
| diff --git a/Source/core/svg/SVGElement.cpp b/Source/core/svg/SVGElement.cpp |
| index a9818bbdced37c909712a016bbab8de3e8e5df05..86bd2bedb6a6c3aeb774046027e06bc7b990eaca 100644 |
| --- a/Source/core/svg/SVGElement.cpp |
| +++ b/Source/core/svg/SVGElement.cpp |
| @@ -836,32 +836,35 @@ static bool hasLoadListener(Element* element) |
| return false; |
| } |
| -void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents) |
| -{ |
| - RefPtrWillBeRawPtr<SVGElement> currentTarget = this; |
| - while (currentTarget && currentTarget->haveLoadedRequiredResources()) { |
| - RefPtrWillBeRawPtr<Element> parent = nullptr; |
| - if (sendParentLoadEvents) |
| - parent = currentTarget->parentOrShadowHostElement(); // save the next parent to dispatch too incase dispatching the event changes the tree |
| - if (hasLoadListener(currentTarget.get()) |
| - && (currentTarget->isStructurallyExternal() || isSVGSVGElement(*currentTarget))) |
| - currentTarget->dispatchEvent(Event::create(EventTypeNames::load)); |
| - currentTarget = (parent && parent->isSVGElement()) ? static_pointer_cast<SVGElement>(parent) : nullptr; |
| - SVGElement* element = currentTarget.get(); |
| - if (!element || !element->isOutermostSVGSVGElement()) |
| - continue; |
| - |
| - // Consider <svg onload="foo()"><image xlink:href="foo.png" externalResourcesRequired="true"/></svg>. |
| - // If foo.png is not yet loaded, the first SVGLoad event will go to the <svg> element, sent through |
| - // Document::implicitClose(). Then the SVGLoad event will fire for <image>, once its loaded. |
| - ASSERT(sendParentLoadEvents); |
| - |
| - // If the load event was not sent yet by Document::implicitClose(), but the <image> from the example |
| - // above, just appeared, don't send the SVGLoad event to the outermost <svg>, but wait for the document |
| - // to be "ready to render", first. |
| - if (!document().loadEventFinished()) |
| - break; |
| - } |
| +bool SVGElement::sendSVGLoadEventIfPossible() |
| +{ |
| + if (!haveLoadedRequiredResources()) |
| + return false; |
| + if ((isStructurallyExternal() || isSVGSVGElement(*this)) && hasLoadListener(this)) |
| + dispatchEvent(Event::create(EventTypeNames::load)); |
| + return true; |
| +} |
| + |
| +void SVGElement::sendSVGLoadEventToSelfAndAncestorChainIfPossible() |
| +{ |
| + // Let Document::implicitClose() dispatch the 'load' to the outermost SVG root. |
| + if (isOutermostSVGSVGElement()) |
| + return; |
| + |
| + // Save the next parent to dispatch to in case dispatching the event mutates the tree. |
| + RefPtrWillBeRawPtr<Element> parent = parentOrShadowHostElement(); |
| + if (!sendSVGLoadEventIfPossible()) |
| + return; |
| + |
| + // If document/window 'load' has been sent already, then only deliver to |
| + // the element in question. |
| + if (document().loadEventFinished()) |
| + return; |
| + |
| + if (!parent || !parent->isSVGElement()) |
| + return; |
| + |
| + static_pointer_cast<SVGElement>(parent)->sendSVGLoadEventToSelfAndAncestorChainIfPossible(); |
|
pdr.
2014/07/10 03:48:15
Should this be toSVGElement(parent)->sendSVGLoadEv
fs
2014/07/10 08:32:50
Yeah, could be. Changed.
|
| } |
| void SVGElement::sendSVGLoadEventIfPossibleAsynchronously() |