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

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

Powered by Google App Engine
This is Rietveld 408576698