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

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: Synced to tip. 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
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/scripts/make_names.pl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2819 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) { 2810 else if (name == HTMLNames::forAttr && hasTagName(labelTag)) {
2820 TreeScope* scope = treeScope(); 2811 TreeScope* scope = treeScope();
2821 if (scope->shouldCacheLabelsByForAttribute()) 2812 if (scope->shouldCacheLabelsByForAttribute())
2822 updateLabel(scope, oldValue, newValue); 2813 updateLabel(scope, oldValue, newValue);
2823 } 2814 }
2824 2815
2825 if (oldValue != newValue) { 2816 if (oldValue != newValue) {
2826 if (attached() && document()->styleResolver() && document()->styleResolv er()->hasSelectorForAttribute(name.localName())) 2817 if (attached() && document()->styleResolver() && document()->styleResolv er()->hasSelectorForAttribute(name.localName()))
2827 setNeedsStyleRecalc(); 2818 setNeedsStyleRecalc();
2828 2819
2829 if (isUpgradedCustomElement()) { 2820 if (isUpgradedCustomElement())
2830 RefPtr<CustomElementDefinition> definition = document()->registry()- >findFor(this); 2821 document()->registrationContext()->customElementAttributeDidChange(t his, name.localName(), oldValue, newValue);
2831 CustomElementCallbackDispatcher::instance().enqueueAttributeChangedC allback(definition->callbacks(), this, name.localName(), oldValue, newValue);
2832 }
2833 } 2822 }
2834 2823
2835 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name)) 2824 if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInter estGroup::createForAttributesMutation(this, name))
2836 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue)); 2825 recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
2837 2826
2838 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newV alue); 2827 InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newV alue);
2839 } 2828 }
2840 2829
2841 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val ue) 2830 void Element::didAddAttribute(const QualifiedName& name, const AtomicString& val ue)
2842 { 2831 {
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
3660 return 0; 3649 return 0;
3661 } 3650 }
3662 3651
3663 Attribute* UniqueElementData::attributeItem(unsigned index) 3652 Attribute* UniqueElementData::attributeItem(unsigned index)
3664 { 3653 {
3665 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3654 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3666 return &m_attributeVector.at(index); 3655 return &m_attributeVector.at(index);
3667 } 3656 }
3668 3657
3669 } // namespace WebCore 3658 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/scripts/make_names.pl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698