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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 extensions.clearHasPendingResourcesIfPossible(clientElement); 151 extensions.clearHasPendingResourcesIfPossible(clientElement);
152 } 152 }
153 } 153 }
154 } 154 }
155 155
156 SVGElementRareData* SVGElement::ensureSVGRareData() 156 SVGElementRareData* SVGElement::ensureSVGRareData()
157 { 157 {
158 if (hasSVGRareData()) 158 if (hasSVGRareData())
159 return svgRareData(); 159 return svgRareData();
160 160
161 m_SVGRareData = adoptPtrWillBeNoop(new SVGElementRareData(this)); 161 m_SVGRareData = (new SVGElementRareData(this));
162 return m_SVGRareData.get(); 162 return m_SVGRareData.get();
163 } 163 }
164 164
165 bool SVGElement::isOutermostSVGSVGElement() const 165 bool SVGElement::isOutermostSVGSVGElement() const
166 { 166 {
167 if (!isSVGSVGElement(*this)) 167 if (!isSVGSVGElement(*this))
168 return false; 168 return false;
169 169
170 // Element may not be in the document, pretend we're outermost for viewport( ), getCTM(), etc. 170 // Element may not be in the document, pretend we're outermost for viewport( ), getCTM(), etc.
171 if (!parentNode()) 171 if (!parentNode())
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 SVGElement::InstanceUpdateBlocker blocker(element); 256 SVGElement::InstanceUpdateBlocker blocker(element);
257 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) { 257 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) {
258 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) { 258 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) {
259 callback(*animatedProperty); 259 callback(*animatedProperty);
260 instance->invalidateSVGAttributes(); 260 instance->invalidateSVGAttributes();
261 instance->svgAttributeChanged(attribute); 261 instance->svgAttributeChanged(attribute);
262 } 262 }
263 } 263 }
264 } 264 }
265 265
266 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, PassRef PtrWillBeRawPtr<SVGPropertyBase> value) 266 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, RawPtr< SVGPropertyBase> value)
267 { 267 {
268 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) { 268 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) {
269 animatedProperty.setAnimatedValue(value.get()); 269 animatedProperty.setAnimatedValue(value.get());
270 }); 270 });
271 ensureSVGRareData()->webAnimatedAttributes().add(&attribute); 271 ensureSVGRareData()->webAnimatedAttributes().add(&attribute);
272 } 272 }
273 273
274 void SVGElement::clearWebAnimatedAttributes() 274 void SVGElement::clearWebAnimatedAttributes()
275 { 275 {
276 if (!hasSVGRareData()) 276 if (!hasSVGRareData())
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // This function is provided for use by SVGAnimatedProperty to avoid 508 // This function is provided for use by SVGAnimatedProperty to avoid
509 // global inclusion of core/dom/Document.h in SVG code. 509 // global inclusion of core/dom/Document.h in SVG code.
510 return document().accessSVGExtensions(); 510 return document().accessSVGExtensions();
511 } 511 }
512 512
513 void SVGElement::mapInstanceToElement(SVGElement* instance) 513 void SVGElement::mapInstanceToElement(SVGElement* instance)
514 { 514 {
515 ASSERT(instance); 515 ASSERT(instance);
516 ASSERT(instance->inUseShadowTree()); 516 ASSERT(instance->inUseShadowTree());
517 517
518 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& instances = ensureSVG RareData()->elementInstances(); 518 HeapHashSet<WeakMember<SVGElement>>& instances = ensureSVGRareData()->elemen tInstances();
519 ASSERT(!instances.contains(instance)); 519 ASSERT(!instances.contains(instance));
520 520
521 instances.add(instance); 521 instances.add(instance);
522 } 522 }
523 523
524 void SVGElement::removeInstanceMapping(SVGElement* instance) 524 void SVGElement::removeInstanceMapping(SVGElement* instance)
525 { 525 {
526 ASSERT(instance); 526 ASSERT(instance);
527 ASSERT(instance->inUseShadowTree()); 527 ASSERT(instance->inUseShadowTree());
528 528
529 if (!hasSVGRareData()) 529 if (!hasSVGRareData())
530 return; 530 return;
531 531
532 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& instances = svgRareDa ta()->elementInstances(); 532 HeapHashSet<WeakMember<SVGElement>>& instances = svgRareData()->elementInsta nces();
533 533
534 instances.remove(instance); 534 instances.remove(instance);
535 } 535 }
536 536
537 static WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& emptyInstances() 537 static HeapHashSet<WeakMember<SVGElement>>& emptyInstances()
538 { 538 {
539 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeWea kMember<SVGElement>>>, emptyInstances, (adoptPtrWillBeNoop(new WillBeHeapHashSet <RawPtrWillBeWeakMember<SVGElement>>()))); 539 DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<WeakMember<SVGElement>>>, emptyIn stances, ((new HeapHashSet<WeakMember<SVGElement>>())));
540 return *emptyInstances; 540 return *emptyInstances;
541 } 541 }
542 542
543 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& SVGElement::instanc esForElement() const 543 const HeapHashSet<WeakMember<SVGElement>>& SVGElement::instancesForElement() con st
544 { 544 {
545 if (!hasSVGRareData()) 545 if (!hasSVGRareData())
546 return emptyInstances(); 546 return emptyInstances();
547 return svgRareData()->elementInstances(); 547 return svgRareData()->elementInstances();
548 } 548 }
549 549
550 void SVGElement::setCursorElement(SVGCursorElement* cursorElement) 550 void SVGElement::setCursorElement(SVGCursorElement* cursorElement)
551 { 551 {
552 SVGElementRareData* rareData = ensureSVGRareData(); 552 SVGElementRareData* rareData = ensureSVGRareData();
553 if (SVGCursorElement* oldCursorElement = rareData->cursorElement()) { 553 if (SVGCursorElement* oldCursorElement = rareData->cursorElement()) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 for (size_t i = 0; i < WTF_ARRAY_LENGTH(attrToTypes); i++) 706 for (size_t i = 0; i < WTF_ARRAY_LENGTH(attrToTypes); i++)
707 cssPropertyMap.set(attrToTypes[i].attr, attrToTypes[i].propType); 707 cssPropertyMap.set(attrToTypes[i].attr, attrToTypes[i].propType);
708 } 708 }
709 709
710 if (cssPropertyMap.contains(attributeName)) 710 if (cssPropertyMap.contains(attributeName))
711 return cssPropertyMap.get(attributeName); 711 return cssPropertyMap.get(attributeName);
712 712
713 return AnimatedUnknown; 713 return AnimatedUnknown;
714 } 714 }
715 715
716 void SVGElement::addToPropertyMap(PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase > passProperty) 716 void SVGElement::addToPropertyMap(RawPtr<SVGAnimatedPropertyBase> passProperty)
717 { 717 {
718 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property(passProperty); 718 RawPtr<SVGAnimatedPropertyBase> property(passProperty);
719 QualifiedName attributeName = property->attributeName(); 719 QualifiedName attributeName = property->attributeName();
720 m_attributeToPropertyMap.set(attributeName, property.release()); 720 m_attributeToPropertyMap.set(attributeName, property.release());
721 } 721 }
722 722
723 SVGAnimatedPropertyBase* SVGElement::propertyFromAttribute(const QualifiedName& attributeName) const 723 SVGAnimatedPropertyBase* SVGElement::propertyFromAttribute(const QualifiedName& attributeName) const
724 { 724 {
725 AttributeToPropertyMap::const_iterator it = m_attributeToPropertyMap.find<SV GAttributeHashTranslator>(attributeName); 725 AttributeToPropertyMap::const_iterator it = m_attributeToPropertyMap.find<SV GAttributeHashTranslator>(attributeName);
726 if (it == m_attributeToPropertyMap.end()) 726 if (it == m_attributeToPropertyMap.end())
727 return nullptr; 727 return nullptr;
728 728
(...skipping 19 matching lines...) Expand all
748 748
749 bool SVGElement::haveLoadedRequiredResources() 749 bool SVGElement::haveLoadedRequiredResources()
750 { 750 {
751 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) { 751 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) {
752 if (!child->haveLoadedRequiredResources()) 752 if (!child->haveLoadedRequiredResources())
753 return false; 753 return false;
754 } 754 }
755 return true; 755 return true;
756 } 756 }
757 757
758 static inline void collectInstancesForSVGElement(SVGElement* element, WillBeHeap HashSet<RawPtrWillBeWeakMember<SVGElement>>& instances) 758 static inline void collectInstancesForSVGElement(SVGElement* element, HeapHashSe t<WeakMember<SVGElement>>& instances)
759 { 759 {
760 ASSERT(element); 760 ASSERT(element);
761 if (element->containingShadowRoot()) 761 if (element->containingShadowRoot())
762 return; 762 return;
763 763
764 ASSERT(!element->instanceUpdatesBlocked()); 764 ASSERT(!element->instanceUpdatesBlocked());
765 765
766 instances = element->instancesForElement(); 766 instances = element->instancesForElement();
767 } 767 }
768 768
769 bool SVGElement::addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener> prpListener, const EventListenerOptions& options) 769 bool SVGElement::addEventListenerInternal(const AtomicString& eventType, RawPtr< EventListener> prpListener, const EventListenerOptions& options)
770 { 770 {
771 RefPtrWillBeRawPtr<EventListener> listener = prpListener; 771 RawPtr<EventListener> listener = prpListener;
772 772
773 // Add event listener to regular DOM element 773 // Add event listener to regular DOM element
774 if (!Node::addEventListenerInternal(eventType, listener, options)) 774 if (!Node::addEventListenerInternal(eventType, listener, options))
775 return false; 775 return false;
776 776
777 // Add event listener to all shadow tree DOM element instances 777 // Add event listener to all shadow tree DOM element instances
778 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>> instances; 778 HeapHashSet<WeakMember<SVGElement>> instances;
779 collectInstancesForSVGElement(this, instances); 779 collectInstancesForSVGElement(this, instances);
780 for (SVGElement* element : instances) { 780 for (SVGElement* element : instances) {
781 bool result = element->Node::addEventListenerInternal(eventType, listene r, options); 781 bool result = element->Node::addEventListenerInternal(eventType, listene r, options);
782 ASSERT_UNUSED(result, result); 782 ASSERT_UNUSED(result, result);
783 } 783 }
784 784
785 return true; 785 return true;
786 } 786 }
787 787
788 bool SVGElement::removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener> prpListener, const EventListenerOptions& optio ns) 788 bool SVGElement::removeEventListenerInternal(const AtomicString& eventType, RawP tr<EventListener> prpListener, const EventListenerOptions& options)
789 { 789 {
790 RefPtrWillBeRawPtr<EventListener> listener = prpListener; 790 RawPtr<EventListener> listener = prpListener;
791 791
792 // Remove event listener from regular DOM element 792 // Remove event listener from regular DOM element
793 if (!Node::removeEventListenerInternal(eventType, listener, options)) 793 if (!Node::removeEventListenerInternal(eventType, listener, options))
794 return false; 794 return false;
795 795
796 // Remove event listener from all shadow tree DOM element instances 796 // Remove event listener from all shadow tree DOM element instances
797 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>> instances; 797 HeapHashSet<WeakMember<SVGElement>> instances;
798 collectInstancesForSVGElement(this, instances); 798 collectInstancesForSVGElement(this, instances);
799 for (SVGElement* shadowTreeElement : instances) { 799 for (SVGElement* shadowTreeElement : instances) {
800 ASSERT(shadowTreeElement); 800 ASSERT(shadowTreeElement);
801 801
802 shadowTreeElement->Node::removeEventListenerInternal(eventType, listener , options); 802 shadowTreeElement->Node::removeEventListenerInternal(eventType, listener , options);
803 } 803 }
804 804
805 return true; 805 return true;
806 } 806 }
807 807
(...skipping 24 matching lines...) Expand all
832 return true; 832 return true;
833 } 833 }
834 834
835 void SVGElement::sendSVGLoadEventToSelfAndAncestorChainIfPossible() 835 void SVGElement::sendSVGLoadEventToSelfAndAncestorChainIfPossible()
836 { 836 {
837 // Let Document::implicitClose() dispatch the 'load' to the outermost SVG ro ot. 837 // Let Document::implicitClose() dispatch the 'load' to the outermost SVG ro ot.
838 if (isOutermostSVGSVGElement()) 838 if (isOutermostSVGSVGElement())
839 return; 839 return;
840 840
841 // Save the next parent to dispatch to in case dispatching the event mutates the tree. 841 // Save the next parent to dispatch to in case dispatching the event mutates the tree.
842 RefPtrWillBeRawPtr<Element> parent = parentOrShadowHostElement(); 842 RawPtr<Element> parent = parentOrShadowHostElement();
843 if (!sendSVGLoadEventIfPossible()) 843 if (!sendSVGLoadEventIfPossible())
844 return; 844 return;
845 845
846 // If document/window 'load' has been sent already, then only deliver to 846 // If document/window 'load' has been sent already, then only deliver to
847 // the element in question. 847 // the element in question.
848 if (document().loadEventFinished()) 848 if (document().loadEventFinished())
849 return; 849 return;
850 850
851 if (!parent || !parent->isSVGElement()) 851 if (!parent || !parent->isSVGElement())
852 return; 852 return;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (name == anyQName()) { 930 if (name == anyQName()) {
931 AttributeToPropertyMap::const_iterator::Values it = m_attributeToPropert yMap.values().begin(); 931 AttributeToPropertyMap::const_iterator::Values it = m_attributeToPropert yMap.values().begin();
932 AttributeToPropertyMap::const_iterator::Values end = m_attributeToProper tyMap.values().end(); 932 AttributeToPropertyMap::const_iterator::Values end = m_attributeToProper tyMap.values().end();
933 for (; it != end; ++it) { 933 for (; it != end; ++it) {
934 if ((*it)->needsSynchronizeAttribute()) 934 if ((*it)->needsSynchronizeAttribute())
935 (*it)->synchronizeAttribute(); 935 (*it)->synchronizeAttribute();
936 } 936 }
937 937
938 elementData()->m_animatedSVGAttributesAreDirty = false; 938 elementData()->m_animatedSVGAttributesAreDirty = false;
939 } else { 939 } else {
940 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = m_attributeToProp ertyMap.get(name); 940 RawPtr<SVGAnimatedPropertyBase> property = m_attributeToPropertyMap.get( name);
941 if (property && property->needsSynchronizeAttribute()) 941 if (property && property->needsSynchronizeAttribute())
942 property->synchronizeAttribute(); 942 property->synchronizeAttribute();
943 } 943 }
944 } 944 }
945 945
946 PassRefPtr<ComputedStyle> SVGElement::customStyleForLayoutObject() 946 PassRefPtr<ComputedStyle> SVGElement::customStyleForLayoutObject()
947 { 947 {
948 if (!correspondingElement()) 948 if (!correspondingElement())
949 return document().ensureStyleResolver().styleForElement(this); 949 return document().ensureStyleResolver().styleForElement(this);
950 950
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 { 999 {
1000 ASSERT(layoutObject); 1000 ASSERT(layoutObject);
1001 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou tObject, true); 1001 LayoutSVGResourceContainer::markForLayoutAndParentResourceInvalidation(layou tObject, true);
1002 } 1002 }
1003 1003
1004 void SVGElement::invalidateInstances() 1004 void SVGElement::invalidateInstances()
1005 { 1005 {
1006 if (instanceUpdatesBlocked()) 1006 if (instanceUpdatesBlocked())
1007 return; 1007 return;
1008 1008
1009 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& set = instances ForElement(); 1009 const HeapHashSet<WeakMember<SVGElement>>& set = instancesForElement();
1010 if (set.isEmpty()) 1010 if (set.isEmpty())
1011 return; 1011 return;
1012 1012
1013 // Mark all use elements referencing 'element' for rebuilding 1013 // Mark all use elements referencing 'element' for rebuilding
1014 for (SVGElement* instance : set) { 1014 for (SVGElement* instance : set) {
1015 instance->setCorrespondingElement(0); 1015 instance->setCorrespondingElement(0);
1016 1016
1017 if (SVGUseElement* element = instance->correspondingUseElement()) { 1017 if (SVGUseElement* element = instance->correspondingUseElement()) {
1018 if (element->inDocument()) 1018 if (element->inDocument())
1019 element->invalidateShadowTree(); 1019 element->invalidateShadowTree();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 } 1164 }
1165 1165
1166 void SVGElement::rebuildAllIncomingReferences() 1166 void SVGElement::rebuildAllIncomingReferences()
1167 { 1167 {
1168 if (!hasSVGRareData()) 1168 if (!hasSVGRareData())
1169 return; 1169 return;
1170 1170
1171 const SVGElementSet& incomingReferences = svgRareData()->incomingReferences( ); 1171 const SVGElementSet& incomingReferences = svgRareData()->incomingReferences( );
1172 1172
1173 // Iterate on a snapshot as |incomingReferences| may be altered inside loop. 1173 // Iterate on a snapshot as |incomingReferences| may be altered inside loop.
1174 WillBeHeapVector<RawPtrWillBeMember<SVGElement>> incomingReferencesSnapshot; 1174 HeapVector<Member<SVGElement>> incomingReferencesSnapshot;
1175 copyToVector(incomingReferences, incomingReferencesSnapshot); 1175 copyToVector(incomingReferences, incomingReferencesSnapshot);
1176 1176
1177 // Force rebuilding the |sourceElement| so it knows about this change. 1177 // Force rebuilding the |sourceElement| so it knows about this change.
1178 for (SVGElement* sourceElement : incomingReferencesSnapshot) { 1178 for (SVGElement* sourceElement : incomingReferencesSnapshot) {
1179 // Before rebuilding |sourceElement| ensure it was not removed from unde r us. 1179 // Before rebuilding |sourceElement| ensure it was not removed from unde r us.
1180 if (incomingReferences.contains(sourceElement)) 1180 if (incomingReferences.contains(sourceElement))
1181 sourceElement->svgAttributeChanged(XLinkNames::hrefAttr); 1181 sourceElement->svgAttributeChanged(XLinkNames::hrefAttr);
1182 } 1182 }
1183 } 1183 }
1184 1184
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 Element::trace(visitor); 1219 Element::trace(visitor);
1220 } 1220 }
1221 1221
1222 const AtomicString& SVGElement::eventParameterName() 1222 const AtomicString& SVGElement::eventParameterName()
1223 { 1223 {
1224 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral)); 1224 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral));
1225 return evtString; 1225 return evtString;
1226 } 1226 }
1227 1227
1228 } // namespace blink 1228 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698