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

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

Issue 268223003: Move InvalidationGuard/InstanceUpdateBlocker out of SVGElementInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen t(rootParent)->m_elementsWithRelativeLengths.contains(this)); 336 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen t(rootParent)->m_elementsWithRelativeLengths.contains(this));
337 337
338 Element::removedFrom(rootParent); 338 Element::removedFrom(rootParent);
339 339
340 if (wasInDocument) { 340 if (wasInDocument) {
341 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th is); 341 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th is);
342 document().accessSVGExtensions().removeAllElementReferencesForTarget(thi s); 342 document().accessSVGExtensions().removeAllElementReferencesForTarget(thi s);
343 } 343 }
344 344
345 SVGElementInstance::invalidateAllInstancesOfElement(this); 345 SVGElement::invalidateAllInstancesOfElement(this);
346 } 346 }
347 347
348 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 348 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
349 { 349 {
350 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo untDelta); 350 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo untDelta);
351 351
352 // Invalidate all SVGElementInstances associated with us. 352 // Invalidate all SVGElementInstances associated with us.
353 if (!changedByParser) 353 if (!changedByParser)
354 SVGElementInstance::invalidateAllInstancesOfElement(this); 354 SVGElement::invalidateAllInstancesOfElement(this);
355 } 355 }
356 356
357 CSSPropertyID SVGElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attrName) 357 CSSPropertyID SVGElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attrName)
358 { 358 {
359 if (!attrName.namespaceURI().isNull()) 359 if (!attrName.namespaceURI().isNull())
360 return CSSPropertyInvalid; 360 return CSSPropertyInvalid;
361 361
362 static HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap = 0; 362 static HashMap<StringImpl*, CSSPropertyID>* propertyNameToIdMap = 0;
363 if (!propertyNameToIdMap) { 363 if (!propertyNameToIdMap) {
364 propertyNameToIdMap = new HashMap<StringImpl*, CSSPropertyID>; 364 propertyNameToIdMap = new HashMap<StringImpl*, CSSPropertyID>;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 // Changes to the style attribute are processed lazily (see Element::getAttr ibute() and related methods), 945 // Changes to the style attribute are processed lazily (see Element::getAttr ibute() and related methods),
946 // so we don't want changes to the style attribute to result in extra work h ere. 946 // so we don't want changes to the style attribute to result in extra work h ere.
947 if (name != HTMLNames::styleAttr) 947 if (name != HTMLNames::styleAttr)
948 svgAttributeChanged(name); 948 svgAttributeChanged(name);
949 } 949 }
950 950
951 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) 951 void SVGElement::svgAttributeChanged(const QualifiedName& attrName)
952 { 952 {
953 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName ); 953 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName );
954 if (propId > 0) { 954 if (propId > 0) {
955 SVGElementInstance::invalidateAllInstancesOfElement(this); 955 SVGElement::invalidateAllInstancesOfElement(this);
956 return; 956 return;
957 } 957 }
958 958
959 if (attrName == HTMLNames::classAttr) { 959 if (attrName == HTMLNames::classAttr) {
960 classAttributeChanged(AtomicString(m_className->currentValue()->value()) ); 960 classAttributeChanged(AtomicString(m_className->currentValue()->value()) );
961 SVGElementInstance::invalidateAllInstancesOfElement(this); 961 SVGElement::invalidateAllInstancesOfElement(this);
962 return; 962 return;
963 } 963 }
964 964
965 if (isIdAttributeName(attrName)) { 965 if (isIdAttributeName(attrName)) {
966 RenderObject* object = renderer(); 966 RenderObject* object = renderer();
967 // Notify resources about id changes, this is important as we cache reso urces by id in SVGDocumentExtensions 967 // Notify resources about id changes, this is important as we cache reso urces by id in SVGDocumentExtensions
968 if (object && object->isSVGResourceContainer()) 968 if (object && object->isSVGResourceContainer())
969 toRenderSVGResourceContainer(object)->idChanged(); 969 toRenderSVGResourceContainer(object)->idChanged();
970 if (inDocument()) 970 if (inDocument())
971 buildPendingResourcesIfNeeded(); 971 buildPendingResourcesIfNeeded();
972 SVGElementInstance::invalidateAllInstancesOfElement(this); 972 SVGElement::invalidateAllInstancesOfElement(this);
973 return; 973 return;
974 } 974 }
975 } 975 }
976 976
977 void SVGElement::synchronizeAnimatedSVGAttribute(const QualifiedName& name) cons t 977 void SVGElement::synchronizeAnimatedSVGAttribute(const QualifiedName& name) cons t
978 { 978 {
979 if (!elementData() || !elementData()->m_animatedSVGAttributesAreDirty) 979 if (!elementData() || !elementData()->m_animatedSVGAttributesAreDirty)
980 return; 980 return;
981 981
982 if (name == anyQName()) { 982 if (name == anyQName()) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1040
1041 return svgRareData()->overrideComputedStyle(this, parentStyle); 1041 return svgRareData()->overrideComputedStyle(this, parentStyle);
1042 } 1042 }
1043 1043
1044 bool SVGElement::hasFocusEventListeners() const 1044 bool SVGElement::hasFocusEventListeners() const
1045 { 1045 {
1046 return hasEventListeners(EventTypeNames::focusin) || hasEventListeners(Event TypeNames::focusout) 1046 return hasEventListeners(EventTypeNames::focusin) || hasEventListeners(Event TypeNames::focusout)
1047 || hasEventListeners(EventTypeNames::focus) || hasEventListeners(EventTy peNames::blur); 1047 || hasEventListeners(EventTypeNames::focus) || hasEventListeners(EventTy peNames::blur);
1048 } 1048 }
1049 1049
1050 void SVGElement::invalidateAllInstancesOfElement(SVGElement* element)
pdr. 2014/05/05 21:00:15 There are only a few callers of this. Could we go
1051 {
1052 if (!element || !element->inDocument())
1053 return;
1054
1055 if (element->instanceUpdatesBlocked())
1056 return;
1057
1058 const HashSet<SVGElement*>& set = element->instancesForElement();
1059 if (set.isEmpty())
1060 return;
1061
1062 // Mark all use elements referencing 'element' for rebuilding
1063 const HashSet<SVGElement*>::const_iterator end = set.end();
1064 for (HashSet<SVGElement*>::const_iterator it = set.begin(); it != end; ++it) {
1065 (*it)->setCorrespondingElement(0);
1066
1067 if (SVGUseElement* element = (*it)->correspondingUseElement()) {
1068 ASSERT(element->inDocument());
1069 element->invalidateShadowTree();
1070 }
1071 }
1072
1073 element->document().updateRenderTreeIfNeeded();
1074 }
1075
1076 SVGElement::InstanceUpdateBlocker::InstanceUpdateBlocker(SVGElement* targetEleme nt)
1077 : m_targetElement(targetElement)
1078 {
1079 if (m_targetElement)
1080 m_targetElement->setInstanceUpdatesBlocked(true);
1081 }
1082
1083 SVGElement::InstanceUpdateBlocker::~InstanceUpdateBlocker()
1084 {
1085 if (m_targetElement)
1086 m_targetElement->setInstanceUpdatesBlocked(false);
1087 }
1088
1050 #ifndef NDEBUG 1089 #ifndef NDEBUG
1051 bool SVGElement::isAnimatableAttribute(const QualifiedName& name) const 1090 bool SVGElement::isAnimatableAttribute(const QualifiedName& name) const
1052 { 1091 {
1053 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, animatableAttributes, ()); 1092 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, animatableAttributes, ());
1054 1093
1055 if (animatableAttributes.isEmpty()) { 1094 if (animatableAttributes.isEmpty()) {
1056 animatableAttributes.add(XLinkNames::hrefAttr); 1095 animatableAttributes.add(XLinkNames::hrefAttr);
1057 animatableAttributes.add(SVGNames::amplitudeAttr); 1096 animatableAttributes.add(SVGNames::amplitudeAttr);
1058 animatableAttributes.add(SVGNames::azimuthAttr); 1097 animatableAttributes.add(SVGNames::azimuthAttr);
1059 animatableAttributes.add(SVGNames::baseFrequencyAttr); 1098 animatableAttributes.add(SVGNames::baseFrequencyAttr);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 animatableAttributes.add(SVGNames::zAttr); 1186 animatableAttributes.add(SVGNames::zAttr);
1148 } 1187 }
1149 1188
1150 if (name == classAttr) 1189 if (name == classAttr)
1151 return true; 1190 return true;
1152 1191
1153 return animatableAttributes.contains(name); 1192 return animatableAttributes.contains(name);
1154 } 1193 }
1155 #endif 1194 #endif
1156 } 1195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698