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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGElement.cpp

Issue 2149893003: Rename Node::inShadowIncludingDocument() to Node::isConnected() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Created 4 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
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, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #endif 66 #endif
67 , m_SVGRareData(nullptr) 67 , m_SVGRareData(nullptr)
68 , m_className(SVGAnimatedString::create(this, HTMLNames::classAttr, SVGStrin g::create())) 68 , m_className(SVGAnimatedString::create(this, HTMLNames::classAttr, SVGStrin g::create()))
69 { 69 {
70 addToPropertyMap(m_className); 70 addToPropertyMap(m_className);
71 setHasCustomStyleCallbacks(); 71 setHasCustomStyleCallbacks();
72 } 72 }
73 73
74 SVGElement::~SVGElement() 74 SVGElement::~SVGElement()
75 { 75 {
76 ASSERT(inShadowIncludingDocument() || !hasRelativeLengths()); 76 ASSERT(isConnected() || !hasRelativeLengths());
77 } 77 }
78 78
79 void SVGElement::detach(const AttachContext& context) 79 void SVGElement::detach(const AttachContext& context)
80 { 80 {
81 Element::detach(context); 81 Element::detach(context);
82 if (SVGElement* element = correspondingElement()) 82 if (SVGElement* element = correspondingElement())
83 element->removeInstanceMapping(this); 83 element->removeInstanceMapping(this);
84 } 84 }
85 85
86 void SVGElement::attach(const AttachContext& context) 86 void SVGElement::attach(const AttachContext& context)
(...skipping 16 matching lines...) Expand all
103 return; 103 return;
104 // If the style changes because of a regular property change (not induced by SMIL animations themselves) 104 // If the style changes because of a regular property change (not induced by SMIL animations themselves)
105 // reset the "computed style without SMIL style properties", so the base val ue change gets reflected. 105 // reset the "computed style without SMIL style properties", so the base val ue change gets reflected.
106 if (change > NoChange || needsStyleRecalc()) 106 if (change > NoChange || needsStyleRecalc())
107 svgRareData()->setNeedsOverrideComputedStyleUpdate(); 107 svgRareData()->setNeedsOverrideComputedStyleUpdate();
108 } 108 }
109 109
110 void SVGElement::buildPendingResourcesIfNeeded() 110 void SVGElement::buildPendingResourcesIfNeeded()
111 { 111 {
112 Document& document = this->document(); 112 Document& document = this->document();
113 if (!needsPendingResourceHandling() || !inShadowIncludingDocument() || inUse ShadowTree()) 113 if (!needsPendingResourceHandling() || !isConnected() || inUseShadowTree())
114 return; 114 return;
115 115
116 SVGDocumentExtensions& extensions = document.accessSVGExtensions(); 116 SVGDocumentExtensions& extensions = document.accessSVGExtensions();
117 AtomicString resourceId = getIdAttribute(); 117 AtomicString resourceId = getIdAttribute();
118 if (!extensions.hasPendingResource(resourceId)) 118 if (!extensions.hasPendingResource(resourceId))
119 return; 119 return;
120 120
121 // Mark pending resources as pending for removal. 121 // Mark pending resources as pending for removal.
122 extensions.markPendingResourcesForRemoval(resourceId); 122 extensions.markPendingResourcesForRemoval(resourceId);
123 123
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 Node::InsertionNotificationRequest SVGElement::insertedInto(ContainerNode* rootP arent) 279 Node::InsertionNotificationRequest SVGElement::insertedInto(ContainerNode* rootP arent)
280 { 280 {
281 Element::insertedInto(rootParent); 281 Element::insertedInto(rootParent);
282 updateRelativeLengthsInformation(); 282 updateRelativeLengthsInformation();
283 buildPendingResourcesIfNeeded(); 283 buildPendingResourcesIfNeeded();
284 return InsertionDone; 284 return InsertionDone;
285 } 285 }
286 286
287 void SVGElement::removedFrom(ContainerNode* rootParent) 287 void SVGElement::removedFrom(ContainerNode* rootParent)
288 { 288 {
289 bool wasInDocument = rootParent->inShadowIncludingDocument(); 289 bool wasInDocument = rootParent->isConnected();
290 290
291 if (wasInDocument && hasRelativeLengths()) { 291 if (wasInDocument && hasRelativeLengths()) {
292 // The root of the subtree being removed should take itself out from its parent's relative 292 // The root of the subtree being removed should take itself out from its parent's relative
293 // length set. For the other nodes in the subtree we don't need to do an ything: they will 293 // length set. For the other nodes in the subtree we don't need to do an ything: they will
294 // get their own removedFrom() notification and just clear their sets. 294 // get their own removedFrom() notification and just clear their sets.
295 if (rootParent->isSVGElement() && !parentNode()) { 295 if (rootParent->isSVGElement() && !parentNode()) {
296 ASSERT(toSVGElement(rootParent)->m_elementsWithRelativeLengths.conta ins(this)); 296 ASSERT(toSVGElement(rootParent)->m_elementsWithRelativeLengths.conta ins(this));
297 toSVGElement(rootParent)->updateRelativeLengthsInformation(false, th is); 297 toSVGElement(rootParent)->updateRelativeLengthsInformation(false, th is);
298 } 298 }
299 299
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 399
400 return propertyNameToIdMap->get(attrName.localName().impl()); 400 return propertyNameToIdMap->get(attrName.localName().impl());
401 } 401 }
402 402
403 void SVGElement::updateRelativeLengthsInformation(bool clientHasRelativeLengths, SVGElement* clientElement) 403 void SVGElement::updateRelativeLengthsInformation(bool clientHasRelativeLengths, SVGElement* clientElement)
404 { 404 {
405 ASSERT(clientElement); 405 ASSERT(clientElement);
406 406
407 // If we're not yet in a document, this function will be called again from i nsertedInto(). Do nothing now. 407 // If we're not yet in a document, this function will be called again from i nsertedInto(). Do nothing now.
408 if (!inShadowIncludingDocument()) 408 if (!isConnected())
409 return; 409 return;
410 410
411 // An element wants to notify us that its own relative lengths state changed . 411 // An element wants to notify us that its own relative lengths state changed .
412 // Register it in the relative length map, and register us in the parent rel ative length map. 412 // Register it in the relative length map, and register us in the parent rel ative length map.
413 // Register the parent in the grandparents map, etc. Repeat procedure until the root of the SVG tree. 413 // Register the parent in the grandparents map, etc. Repeat procedure until the root of the SVG tree.
414 for (Node& currentNode : NodeTraversal::inclusiveAncestorsOf(*this)) { 414 for (Node& currentNode : NodeTraversal::inclusiveAncestorsOf(*this)) {
415 if (!currentNode.isSVGElement()) 415 if (!currentNode.isSVGElement())
416 break; 416 break;
417 SVGElement& currentElement = toSVGElement(currentNode); 417 SVGElement& currentElement = toSVGElement(currentNode);
418 ASSERT(!currentElement.m_inRelativeLengthClientsInvalidation); 418 ASSERT(!currentElement.m_inRelativeLengthClientsInvalidation);
(...skipping 17 matching lines...) Expand all
436 SVGDocumentExtensions& svgExtensions = accessDocumentSVGExtensions(); 436 SVGDocumentExtensions& svgExtensions = accessDocumentSVGExtensions();
437 if (clientElement->hasRelativeLengths()) 437 if (clientElement->hasRelativeLengths())
438 svgExtensions.addSVGRootWithRelativeLengthDescendents(toSVGSVGElemen t(clientElement)); 438 svgExtensions.addSVGRootWithRelativeLengthDescendents(toSVGSVGElemen t(clientElement));
439 else 439 else
440 svgExtensions.removeSVGRootWithRelativeLengthDescendents(toSVGSVGEle ment(clientElement)); 440 svgExtensions.removeSVGRootWithRelativeLengthDescendents(toSVGSVGEle ment(clientElement));
441 } 441 }
442 } 442 }
443 443
444 void SVGElement::invalidateRelativeLengthClients(SubtreeLayoutScope* layoutScope ) 444 void SVGElement::invalidateRelativeLengthClients(SubtreeLayoutScope* layoutScope )
445 { 445 {
446 if (!inShadowIncludingDocument()) 446 if (!isConnected())
447 return; 447 return;
448 448
449 ASSERT(!m_inRelativeLengthClientsInvalidation); 449 ASSERT(!m_inRelativeLengthClientsInvalidation);
450 #if ENABLE(ASSERT) 450 #if ENABLE(ASSERT)
451 TemporaryChange<bool> inRelativeLengthClientsInvalidationChange(m_inRelative LengthClientsInvalidation, true); 451 TemporaryChange<bool> inRelativeLengthClientsInvalidationChange(m_inRelative LengthClientsInvalidation, true);
452 #endif 452 #endif
453 453
454 if (LayoutObject* layoutObject = this->layoutObject()) { 454 if (LayoutObject* layoutObject = this->layoutObject()) {
455 if (hasRelativeLengths() && layoutObject->isSVGResourceContainer()) 455 if (hasRelativeLengths() && layoutObject->isSVGResourceContainer())
456 toLayoutSVGResourceContainer(layoutObject)->invalidateCacheAndMarkFo rLayout(layoutScope); 456 toLayoutSVGResourceContainer(layoutObject)->invalidateCacheAndMarkFo rLayout(layoutScope);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 classAttributeChanged(AtomicString(m_className->currentValue()->value()) ); 839 classAttributeChanged(AtomicString(m_className->currentValue()->value()) );
840 invalidateInstances(); 840 invalidateInstances();
841 return; 841 return;
842 } 842 }
843 843
844 if (attrName == HTMLNames::idAttr) { 844 if (attrName == HTMLNames::idAttr) {
845 LayoutObject* object = layoutObject(); 845 LayoutObject* object = layoutObject();
846 // Notify resources about id changes, this is important as we cache reso urces by id in SVGDocumentExtensions 846 // Notify resources about id changes, this is important as we cache reso urces by id in SVGDocumentExtensions
847 if (object && object->isSVGResourceContainer()) 847 if (object && object->isSVGResourceContainer())
848 toLayoutSVGResourceContainer(object)->idChanged(); 848 toLayoutSVGResourceContainer(object)->idChanged();
849 if (inShadowIncludingDocument()) 849 if (isConnected())
850 buildPendingResourcesIfNeeded(); 850 buildPendingResourcesIfNeeded();
851 invalidateInstances(); 851 invalidateInstances();
852 return; 852 return;
853 } 853 }
854 } 854 }
855 855
856 void SVGElement::svgAttributeBaseValChanged(const QualifiedName& attribute) 856 void SVGElement::svgAttributeBaseValChanged(const QualifiedName& attribute)
857 { 857 {
858 svgAttributeChanged(attribute); 858 svgAttributeChanged(attribute);
859 859
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 966
967 const HeapHashSet<WeakMember<SVGElement>>& set = instancesForElement(); 967 const HeapHashSet<WeakMember<SVGElement>>& set = instancesForElement();
968 if (set.isEmpty()) 968 if (set.isEmpty())
969 return; 969 return;
970 970
971 // Mark all use elements referencing 'element' for rebuilding 971 // Mark all use elements referencing 'element' for rebuilding
972 for (SVGElement* instance : set) { 972 for (SVGElement* instance : set) {
973 instance->setCorrespondingElement(0); 973 instance->setCorrespondingElement(0);
974 974
975 if (SVGUseElement* element = instance->correspondingUseElement()) { 975 if (SVGUseElement* element = instance->correspondingUseElement()) {
976 if (element->inShadowIncludingDocument()) 976 if (element->isConnected())
977 element->invalidateShadowTree(); 977 element->invalidateShadowTree();
978 } 978 }
979 } 979 }
980 980
981 svgRareData()->elementInstances().clear(); 981 svgRareData()->elementInstances().clear();
982 } 982 }
983 983
984 SVGElement::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetEleme nt) 984 SVGElement::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetEleme nt)
985 : m_targetElement(targetElement) 985 : m_targetElement(targetElement)
986 { 986 {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 Element::trace(visitor); 1169 Element::trace(visitor);
1170 } 1170 }
1171 1171
1172 const AtomicString& SVGElement::eventParameterName() 1172 const AtomicString& SVGElement::eventParameterName()
1173 { 1173 {
1174 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); 1174 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt"));
1175 return evtString; 1175 return evtString;
1176 } 1176 }
1177 1177
1178 } // namespace blink 1178 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp ('k') | third_party/WebKit/Source/core/svg/SVGFEImageElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698