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

Side by Side Diff: Source/core/svg/SVGUseElement.cpp

Issue 19097005: Remove one SVG animated type special case from the bindings generator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix the regressions Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 5 * Copyright (C) 2011 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
6 * Copyright (C) 2012 University of Szeged 6 * Copyright (C) 2012 University of Szeged
7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org> 7 * Copyright (C) 2012 Renata Hodovan <reni@webkit.org>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 void SVGUseElement::removedFrom(ContainerNode* rootParent) 182 void SVGUseElement::removedFrom(ContainerNode* rootParent)
183 { 183 {
184 SVGGraphicsElement::removedFrom(rootParent); 184 SVGGraphicsElement::removedFrom(rootParent);
185 if (rootParent->inDocument()) 185 if (rootParent->inDocument())
186 clearResourceReferences(); 186 clearResourceReferences();
187 } 187 }
188 188
189 Document* SVGUseElement::referencedDocument() const 189 Document* SVGUseElement::referencedDocument() const
190 { 190 {
191 if (!isExternalURIReference(href(), document())) 191 if (!isExternalURIReference(hrefCurrentValue(), document()))
192 return document(); 192 return document();
193 return externalDocument(); 193 return externalDocument();
194 } 194 }
195 195
196 Document* SVGUseElement::externalDocument() const 196 Document* SVGUseElement::externalDocument() const
197 { 197 {
198 if (m_cachedDocument && m_cachedDocument->isLoaded()) { 198 if (m_cachedDocument && m_cachedDocument->isLoaded()) {
199 // Gracefully handle error condition. 199 // Gracefully handle error condition.
200 if (m_cachedDocument->errorOccurred()) 200 if (m_cachedDocument->errorOccurred())
201 return 0; 201 return 0;
(...skipping 20 matching lines...) Expand all
222 updateRelativeLengthsInformation(); 222 updateRelativeLengthsInformation();
223 if (renderer) 223 if (renderer)
224 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er); 224 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render er);
225 return; 225 return;
226 } 226 }
227 227
228 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) 228 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName))
229 return; 229 return;
230 230
231 if (SVGURIReference::isKnownAttribute(attrName)) { 231 if (SVGURIReference::isKnownAttribute(attrName)) {
232 bool isExternalReference = isExternalURIReference(href(), document()); 232 bool isExternalReference = isExternalURIReference(hrefCurrentValue(), do cument());
233 if (isExternalReference) { 233 if (isExternalReference) {
234 KURL url = document()->completeURL(href()); 234 KURL url = document()->completeURL(hrefCurrentValue());
235 if (url.hasFragmentIdentifier()) { 235 if (url.hasFragmentIdentifier()) {
236 CachedResourceRequest request(ResourceRequest(url.string()), loc alName()); 236 CachedResourceRequest request(ResourceRequest(url.string()), loc alName());
237 setCachedDocument(document()->cachedResourceLoader()->requestSVG Document(request)); 237 setCachedDocument(document()->cachedResourceLoader()->requestSVG Document(request));
238 } 238 }
239 } else 239 } else
240 setCachedDocument(0); 240 setCachedDocument(0);
241 241
242 if (!m_wasInsertedByParser) 242 if (!m_wasInsertedByParser)
243 buildPendingResource(); 243 buildPendingResource();
244 244
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 void SVGUseElement::buildPendingResource() 392 void SVGUseElement::buildPendingResource()
393 { 393 {
394 if (!referencedDocument() || isInShadowTree()) 394 if (!referencedDocument() || isInShadowTree())
395 return; 395 return;
396 clearResourceReferences(); 396 clearResourceReferences();
397 if (!inDocument()) 397 if (!inDocument())
398 return; 398 return;
399 399
400 String id; 400 String id;
401 Element* target = SVGURIReference::targetElementFromIRIString(href(), docume nt(), &id, externalDocument()); 401 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal ue(), document(), &id, externalDocument());
402 if (!target || !target->inDocument()) { 402 if (!target || !target->inDocument()) {
403 // If we can't find the target of an external element, just give up. 403 // If we can't find the target of an external element, just give up.
404 // We can't observe if the target somewhen enters the external document, nor should we do it. 404 // We can't observe if the target somewhen enters the external document, nor should we do it.
405 if (externalDocument()) 405 if (externalDocument())
406 return; 406 return;
407 if (id.isEmpty()) 407 if (id.isEmpty())
408 return; 408 return;
409 409
410 referencedDocument()->accessSVGExtensions()->addPendingResource(id, this ); 410 referencedDocument()->accessSVGExtensions()->addPendingResource(id, this );
411 ASSERT(hasPendingResources()); 411 ASSERT(hasPendingResources());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return; 544 return;
545 545
546 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) { 546 if (n->isSVGElement() && toSVGElement(n)->isSVGGraphicsElement()) {
547 if (!isDirectReference(n)) 547 if (!isDirectReference(n))
548 // Spec: Indirect references are an error (14.3.5) 548 // Spec: Indirect references are an error (14.3.5)
549 document()->accessSVGExtensions()->reportError("Not allowed to use i ndirect reference in <clip-path>"); 549 document()->accessSVGExtensions()->reportError("Not allowed to use i ndirect reference in <clip-path>");
550 else { 550 else {
551 toSVGGraphicsElement(n)->toClipPath(path); 551 toSVGGraphicsElement(n)->toClipPath(path);
552 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf ul. 552 // FIXME: Avoid manual resolution of x/y here. Its potentially harmf ul.
553 SVGLengthContext lengthContext(this); 553 SVGLengthContext lengthContext(this);
554 path.translate(FloatSize(x().value(lengthContext), y().value(lengthC ontext))); 554 path.translate(FloatSize(xCurrentValue().value(lengthContext), yCurr entValue().value(lengthContext)));
555 path.transform(animatedLocalTransform()); 555 path.transform(animatedLocalTransform());
556 } 556 }
557 } 557 }
558 } 558 }
559 559
560 RenderObject* SVGUseElement::rendererClipChild() const 560 RenderObject* SVGUseElement::rendererClipChild() const
561 { 561 {
562 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme nt() : 0; 562 Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeEleme nt() : 0;
563 if (!n) 563 if (!n)
564 return 0; 564 return 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return; 626 return;
627 627
628 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, st atic_cast<SVGUseElement*>(target), newTarget); 628 RefPtr<SVGElementInstance> newInstance = SVGElementInstance::create(this, st atic_cast<SVGUseElement*>(target), newTarget);
629 SVGElementInstance* newInstancePtr = newInstance.get(); 629 SVGElementInstance* newInstancePtr = newInstance.get();
630 targetInstance->appendChild(newInstance.release()); 630 targetInstance->appendChild(newInstance.release());
631 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse); 631 buildInstanceTree(newTarget, newInstancePtr, foundProblem, foundUse);
632 } 632 }
633 633
634 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget) 634 bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstanc e* targetInstance, SVGElement*& newTarget)
635 { 635 {
636 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr ef(), referencedDocument()); 636 Element* targetElement = SVGURIReference::targetElementFromIRIString(use->hr efCurrentValue(), referencedDocument());
637 newTarget = 0; 637 newTarget = 0;
638 if (targetElement && targetElement->isSVGElement()) 638 if (targetElement && targetElement->isSVGElement())
639 newTarget = toSVGElement(targetElement); 639 newTarget = toSVGElement(targetElement);
640 640
641 if (!newTarget) 641 if (!newTarget)
642 return false; 642 return false;
643 643
644 // Shortcut for self-references 644 // Shortcut for self-references
645 if (newTarget == this) 645 if (newTarget == this)
646 return true; 646 return true;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 // do this directly in buildShadowTree, if we encounter a <use> element? 698 // do this directly in buildShadowTree, if we encounter a <use> element?
699 // 699 //
700 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol> 700 // Short answer: Because we may miss to expand some elements. Ie. if a <symb ol>
701 // contains <use> tags, we'd miss them. So once we're done with settin' up t he 701 // contains <use> tags, we'd miss them. So once we're done with settin' up t he
702 // actual shadow tree (after the special case modification for svg/symbol) w e have 702 // actual shadow tree (after the special case modification for svg/symbol) w e have
703 // to walk it completely and expand all <use> elements. 703 // to walk it completely and expand all <use> elements.
704 if (element->hasTagName(SVGNames::useTag)) { 704 if (element->hasTagName(SVGNames::useTag)) {
705 SVGUseElement* use = static_cast<SVGUseElement*>(element); 705 SVGUseElement* use = static_cast<SVGUseElement*>(element);
706 ASSERT(!use->cachedDocumentIsStillLoading()); 706 ASSERT(!use->cachedDocumentIsStillLoading());
707 707
708 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->href(), referencedDocument()); 708 Element* targetElement = SVGURIReference::targetElementFromIRIString(use ->hrefCurrentValue(), referencedDocument());
709 SVGElement* target = 0; 709 SVGElement* target = 0;
710 if (targetElement && targetElement->isSVGElement()) 710 if (targetElement && targetElement->isSVGElement())
711 target = toSVGElement(targetElement); 711 target = toSVGElement(targetElement);
712 712
713 // Don't ASSERT(target) here, it may be "pending", too. 713 // Don't ASSERT(target) here, it may be "pending", too.
714 // Setup sub-shadow tree root node 714 // Setup sub-shadow tree root node
715 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re ferencedDocument()); 715 RefPtr<SVGGElement> cloneParent = SVGGElement::create(SVGNames::gTag, re ferencedDocument());
716 use->cloneChildNodes(cloneParent.get()); 716 use->cloneChildNodes(cloneParent.get());
717 717
718 // Spec: In the generated content, the 'use' will be replaced by 'g', wh ere all attributes from the 718 // Spec: In the generated content, the 'use' will be replaced by 'g', wh ere all attributes from the
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 911
912 to->removeAttribute(SVGNames::xAttr); 912 to->removeAttribute(SVGNames::xAttr);
913 to->removeAttribute(SVGNames::yAttr); 913 to->removeAttribute(SVGNames::yAttr);
914 to->removeAttribute(SVGNames::widthAttr); 914 to->removeAttribute(SVGNames::widthAttr);
915 to->removeAttribute(SVGNames::heightAttr); 915 to->removeAttribute(SVGNames::heightAttr);
916 to->removeAttribute(XLinkNames::hrefAttr); 916 to->removeAttribute(XLinkNames::hrefAttr);
917 } 917 }
918 918
919 bool SVGUseElement::selfHasRelativeLengths() const 919 bool SVGUseElement::selfHasRelativeLengths() const
920 { 920 {
921 if (x().isRelative() 921 if (xCurrentValue().isRelative()
922 || y().isRelative() 922 || yCurrentValue().isRelative()
923 || width().isRelative() 923 || widthCurrentValue().isRelative()
924 || height().isRelative()) 924 || heightCurrentValue().isRelative())
925 return true; 925 return true;
926 926
927 if (!m_targetElementInstance) 927 if (!m_targetElementInstance)
928 return false; 928 return false;
929 929
930 SVGElement* element = m_targetElementInstance->correspondingElement(); 930 SVGElement* element = m_targetElementInstance->correspondingElement();
931 if (!element || !element->isSVGStyledElement()) 931 if (!element || !element->isSVGStyledElement())
932 return false; 932 return false;
933 933
934 return toSVGStyledElement(element)->hasRelativeLengths(); 934 return toSVGStyledElement(element)->hasRelativeLengths();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 983
984 if (m_cachedDocument) 984 if (m_cachedDocument)
985 m_cachedDocument->removeClient(this); 985 m_cachedDocument->removeClient(this);
986 986
987 m_cachedDocument = cachedDocument; 987 m_cachedDocument = cachedDocument;
988 if (m_cachedDocument) 988 if (m_cachedDocument)
989 m_cachedDocument->addClient(this); 989 m_cachedDocument->addClient(this);
990 } 990 }
991 991
992 } 992 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698