Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: third_party/WebKit/WebCore/svg/SVGUseElement.cpp

Issue 669237: Merge WebKit r55511 (Closed) Base URL: svn://chrome-svn/chrome/branches/249/src/
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/WebCore/svg/SVGUseElement.cpp
===================================================================
--- third_party/WebKit/WebCore/svg/SVGUseElement.cpp (revision 40819)
+++ third_party/WebKit/WebCore/svg/SVGUseElement.cpp (working copy)
@@ -388,7 +388,7 @@
ASSERT(!m_targetElementInstance);
if (!targetElement) {
- if (m_isPendingResource)
+ if (m_isPendingResource || id.isEmpty())
return;
m_isPendingResource = true;
@@ -408,7 +408,12 @@
{
String id = SVGURIReference::getTarget(href());
Element* targetElement = document()->getElementById(id);
- ASSERT(targetElement);
+ if (!targetElement) {
+ // The only time we should get here is when the use element has not been
+ // given a resource to target.
+ ASSERT(m_resourceId.isEmpty());
+ return;
+ }
// Do not build the shadow/instance tree for <use> elements living in a shadow tree.
// The will be expanded soon anyway - see expandUseElementsInShadowTree().
@@ -710,27 +715,15 @@
target = static_cast<SVGElement*>(targetElement);
// Don't ASSERT(target) here, it may be "pending", too.
- if (target) {
- // Setup sub-shadow tree root node
- RefPtr<SVGShadowTreeContainerElement> cloneParent = new SVGShadowTreeContainerElement(document());
+ // Setup sub-shadow tree root node
+ RefPtr<SVGShadowTreeContainerElement> cloneParent = new SVGShadowTreeContainerElement(document());
- // Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the
- // 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element.
- transferUseAttributesToReplacedElement(use, cloneParent.get());
+ // Spec: In the generated content, the 'use' will be replaced by 'g', where all attributes from the
+ // 'use' element except for x, y, width, height and xlink:href are transferred to the generated 'g' element.
+ transferUseAttributesToReplacedElement(use, cloneParent.get());
- ExceptionCode ec = 0;
-
- // For instance <use> on <foreignObject> (direct case).
- if (isDisallowedElement(target)) {
- // We still have to setup the <use> replacment (<g>). Otherwhise
- // associateInstancesWithShadowTreeElements() makes wrong assumptions.
- // Replace <use> with referenced content.
- ASSERT(use->parentNode());
- use->parentNode()->replaceChild(cloneParent.release(), use, ec);
- ASSERT(!ec);
- return;
- }
-
+ ExceptionCode ec = 0;
+ if (target && !isDisallowedElement(target)) {
RefPtr<Element> newChild = target->cloneElementWithChildren();
// We don't walk the target tree element-by-element, and clone each element,
@@ -748,16 +741,16 @@
cloneParent->appendChild(newChild.release(), ec);
ASSERT(!ec);
+ }
- // Replace <use> with referenced content.
- ASSERT(use->parentNode());
- use->parentNode()->replaceChild(cloneParent.release(), use, ec);
- ASSERT(!ec);
+ // Replace <use> with referenced content.
+ ASSERT(use->parentNode());
+ use->parentNode()->replaceChild(cloneParent.release(), use, ec);
+ ASSERT(!ec);
- // Immediately stop here, and restart expanding.
- expandUseElementsInShadowTree(shadowRoot, shadowRoot);
- return;
- }
+ // Immediately stop here, and restart expanding.
+ expandUseElementsInShadowTree(shadowRoot, shadowRoot);
+ return;
}
for (RefPtr<Node> child = element->firstChild(); child; child = child->nextSibling())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698