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

Side by Side Diff: Source/core/dom/Element.cpp

Issue 18332025: Split CustomElementRegistry into a registration context and a registry. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tweaks. 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 24 matching lines...) Expand all
35 #include "core/css/CSSParser.h" 35 #include "core/css/CSSParser.h"
36 #include "core/css/CSSStyleSheet.h" 36 #include "core/css/CSSStyleSheet.h"
37 #include "core/css/CSSValuePool.h" 37 #include "core/css/CSSValuePool.h"
38 #include "core/css/PropertySetCSSStyleDeclaration.h" 38 #include "core/css/PropertySetCSSStyleDeclaration.h"
39 #include "core/css/StylePropertySet.h" 39 #include "core/css/StylePropertySet.h"
40 #include "core/css/resolver/StyleResolver.h" 40 #include "core/css/resolver/StyleResolver.h"
41 #include "core/dom/Attr.h" 41 #include "core/dom/Attr.h"
42 #include "core/dom/Attribute.h" 42 #include "core/dom/Attribute.h"
43 #include "core/dom/ClientRect.h" 43 #include "core/dom/ClientRect.h"
44 #include "core/dom/ClientRectList.h" 44 #include "core/dom/ClientRectList.h"
45 #include "core/dom/CustomElementCallbackDispatcher.h" 45 #include "core/dom/CustomElementRegistrationContext.h"
46 #include "core/dom/CustomElementRegistry.h"
47 #include "core/dom/DatasetDOMStringMap.h" 46 #include "core/dom/DatasetDOMStringMap.h"
48 #include "core/dom/Document.h" 47 #include "core/dom/Document.h"
49 #include "core/dom/DocumentSharedObjectPool.h" 48 #include "core/dom/DocumentSharedObjectPool.h"
50 #include "core/dom/ElementRareData.h" 49 #include "core/dom/ElementRareData.h"
51 #include "core/dom/ExceptionCode.h" 50 #include "core/dom/ExceptionCode.h"
52 #include "core/dom/FullscreenController.h" 51 #include "core/dom/FullscreenController.h"
53 #include "core/dom/MutationObserverInterestGroup.h" 52 #include "core/dom/MutationObserverInterestGroup.h"
54 #include "core/dom/MutationRecord.h" 53 #include "core/dom/MutationRecord.h"
55 #include "core/dom/NamedNodeMap.h" 54 #include "core/dom/NamedNodeMap.h"
56 #include "core/dom/NodeRenderStyle.h" 55 #include "core/dom/NodeRenderStyle.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 cssomWrapper->clearParentElement(); 202 cssomWrapper->clearParentElement();
204 203
205 if (hasRareData()) { 204 if (hasRareData()) {
206 ElementRareData* data = elementRareData(); 205 ElementRareData* data = elementRareData();
207 data->setPseudoElement(BEFORE, 0); 206 data->setPseudoElement(BEFORE, 0);
208 data->setPseudoElement(AFTER, 0); 207 data->setPseudoElement(AFTER, 0);
209 data->setPseudoElement(BACKDROP, 0); 208 data->setPseudoElement(BACKDROP, 0);
210 data->clearShadow(); 209 data->clearShadow();
211 } 210 }
212 211
213 if (isCustomElement() && document() && document()->registry()) { 212 if (isCustomElement() && document() && document()->registrationContext())
214 document()->registry()->customElementWasDestroyed(this); 213 document()->registrationContext()->customElementIsBeingDestroyed(this);
215 }
216 214
217 if (hasSyntheticAttrChildNodes()) 215 if (hasSyntheticAttrChildNodes())
218 detachAllAttrNodesFromElement(); 216 detachAllAttrNodesFromElement();
219 217
220 if (hasPendingResources()) { 218 if (hasPendingResources()) {
221 document()->accessSVGExtensions()->removeElementFromPendingResources(thi s); 219 document()->accessSVGExtensions()->removeElementFromPendingResources(thi s);
222 ASSERT(!hasPendingResources()); 220 ASSERT(!hasPendingResources());
223 } 221 }
224 } 222 }
225 223
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 939
942 if (shouldInvalidateStyle) 940 if (shouldInvalidateStyle)
943 setNeedsStyleRecalc(); 941 setNeedsStyleRecalc();
944 942
945 if (AXObjectCache* cache = document()->existingAXObjectCache()) 943 if (AXObjectCache* cache = document()->existingAXObjectCache())
946 cache->handleAttributeChanged(name, this); 944 cache->handleAttributeChanged(name, this);
947 } 945 }
948 946
949 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason) 947 inline void Element::attributeChangedFromParserOrByCloning(const QualifiedName& name, const AtomicString& newValue, AttributeModificationReason reason)
950 { 948 {
951 if (RuntimeEnabledFeatures::customDOMElementsEnabled() && name == isAttr) { 949 if (name == isAttr)
952 document()->ensureCustomElementRegistry()->didGiveTypeExtension(this, ne wValue); 950 document()->registrationContext()->didGiveTypeExtension(this, newValue);
953 }
954 attributeChanged(name, newValue, reason); 951 attributeChanged(name, newValue, reason);
955 } 952 }
956 953
957 template <typename CharacterType> 954 template <typename CharacterType>
958 static inline bool classStringHasClassName(const CharacterType* characters, unsi gned length) 955 static inline bool classStringHasClassName(const CharacterType* characters, unsi gned length)
959 { 956 {
960 ASSERT(length > 0); 957 ASSERT(length > 0);
961 958
962 unsigned i = 0; 959 unsigned i = 0;
963 do { 960 do {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 if (!insertionPoint->isInTreeScope()) 1258 if (!insertionPoint->isInTreeScope())
1262 return InsertionDone; 1259 return InsertionDone;
1263 1260
1264 if (hasRareData()) 1261 if (hasRareData())
1265 elementRareData()->clearClassListValueForQuirksMode(); 1262 elementRareData()->clearClassListValueForQuirksMode();
1266 1263
1267 TreeScope* scope = insertionPoint->treeScope(); 1264 TreeScope* scope = insertionPoint->treeScope();
1268 if (scope != treeScope()) 1265 if (scope != treeScope())
1269 return InsertionDone; 1266 return InsertionDone;
1270 1267
1271 if (isUpgradedCustomElement()) { 1268 if (isUpgradedCustomElement())
1272 RefPtr<CustomElementDefinition> definition = document()->registry()->fin dFor(this); 1269 document()->registrationContext()->customElementDidEnterDocument(this);
1273 CustomElementCallbackDispatcher::instance().enqueueEnteredDocumentCallba ck(definition->callbacks(), this);
1274 }
1275 1270
1276 const AtomicString& idValue = getIdAttribute(); 1271 const AtomicString& idValue = getIdAttribute();
1277 if (!idValue.isNull()) 1272 if (!idValue.isNull())
1278 updateId(scope, nullAtom, idValue); 1273 updateId(scope, nullAtom, idValue);
1279 1274
1280 const AtomicString& nameValue = getNameAttribute(); 1275 const AtomicString& nameValue = getNameAttribute();
1281 if (!nameValue.isNull()) 1276 if (!nameValue.isNull())
1282 updateName(nullAtom, nameValue); 1277 updateName(nullAtom, nameValue);
1283 1278
1284 if (hasTagName(labelTag)) { 1279 if (hasTagName(labelTag)) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 if (treeScope->shouldCacheLabelsByForAttribute()) 1320 if (treeScope->shouldCacheLabelsByForAttribute())
1326 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom); 1321 updateLabel(treeScope, fastGetAttribute(forAttr), nullAtom);
1327 } 1322 }
1328 } 1323 }
1329 1324
1330 ContainerNode::removedFrom(insertionPoint); 1325 ContainerNode::removedFrom(insertionPoint);
1331 if (wasInDocument) { 1326 if (wasInDocument) {
1332 if (hasPendingResources()) 1327 if (hasPendingResources())
1333 document()->accessSVGExtensions()->removeElementFromPendingResources (this); 1328 document()->accessSVGExtensions()->removeElementFromPendingResources (this);
1334 1329
1335 if (isUpgradedCustomElement()) { 1330 if (isUpgradedCustomElement() && document()->registrationContext())
1336 if (CustomElementRegistry* registry = document()->registry()) { 1331 document()->registrationContext()->customElementDidLeaveDocument(thi s);
1337 RefPtr<CustomElementDefinition> definition = registry->findFor(t his);
1338 CustomElementCallbackDispatcher::instance().enqueueLeftDocumentC allback(definition->callbacks(), this);
1339 }
1340 }
1341 } 1332 }
1342 } 1333 }
1343 1334
1344 void Element::createRendererIfNeeded(const AttachContext& context) 1335 void Element::createRendererIfNeeded(const AttachContext& context)
1345 { 1336 {
1346 NodeRenderingContext(this, context).createRendererForElementIfNeeded(); 1337 NodeRenderingContext(this, context).createRendererForElementIfNeeded();
1347 } 1338 }
1348 1339
1349 void Element::attach(const AttachContext& context) 1340 void Element::attach(const AttachContext& context)
1350 { 1341 {
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2806 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2797 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
2807 TreeScope* scope = treeScope(); 2798 TreeScope* scope = treeScope();
2808 if (scope->shouldCacheLabelsByForAttribute()) 2799 if (scope->shouldCacheLabelsByForAttribute())
2809 updateLabel(scope, oldValue, newValue); 2800 updateLabel(scope, oldValue, newValue);
2810 } 2801 }
2811 2802
2812 if (oldValue != newValue) { 2803 if (oldValue != newValue) {
2813 if (attached() && document()->styleResolver() && document()->styleResolv er()->hasSelectorForAttribute(name.localName())) 2804 if (attached() && document()->styleResolver() && document()->styleResolv er()->hasSelectorForAttribute(name.localName()))
2814 setNeedsStyleRecalc(); 2805 setNeedsStyleRecalc();
2815 2806
2816 if (isUpgradedCustomElement()) { 2807 if (isUpgradedCustomElement())
2817 RefPtr<CustomElementDefinition> definition = document()->registry()- >findFor(this); 2808 document()->registrationContext()->customElementAttributeDidChange(t his, name.localName(), oldValue, newValue);
2818 CustomElementCallbackDispatcher::instance().enqueueAttributeChangedC allback(definition->callbacks(), this, name.localName(), oldValue, newValue);
2819 }
2820 } 2809 }
2821 2810
2822 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name)) 2811 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name))
2823 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 2812 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
2824 2813
2825 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newV alue); 2814 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newV alue);
2826 } 2815 }
2827 2816
2828 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val ue) 2817 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val ue)
2829 { 2818 {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 return 0; 3636 return 0;
3648 } 3637 }
3649 3638
3650 Attribute* UniqueElementData::attributeItem(unsigned index) 3639 Attribute* UniqueElementData::attributeItem(unsigned index)
3651 { 3640 {
3652 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3641 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3653 return &m_attributeVector.at(index); 3642 return &m_attributeVector.at(index);
3654 } 3643 }
3655 3644
3656 } // namespace WebCore 3645 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698