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

Side by Side Diff: Source/core/dom/custom/CustomElementRegistrationContext.cpp

Issue 296703009: Oilpan: move custom element objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + smaller tweaks 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 27 matching lines...) Expand all
38 #include "core/dom/custom/CustomElement.h" 38 #include "core/dom/custom/CustomElement.h"
39 #include "core/dom/custom/CustomElementDefinition.h" 39 #include "core/dom/custom/CustomElementDefinition.h"
40 #include "core/dom/custom/CustomElementScheduler.h" 40 #include "core/dom/custom/CustomElementScheduler.h"
41 #include "core/html/HTMLElement.h" 41 #include "core/html/HTMLElement.h"
42 #include "core/html/HTMLUnknownElement.h" 42 #include "core/html/HTMLUnknownElement.h"
43 #include "core/svg/SVGUnknownElement.h" 43 #include "core/svg/SVGUnknownElement.h"
44 #include "wtf/RefPtr.h" 44 #include "wtf/RefPtr.h"
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 CustomElementRegistrationContext::CustomElementRegistrationContext()
49 : m_candidates(CustomElementUpgradeCandidateMap::create())
50 {
51 }
52
48 void CustomElementRegistrationContext::registerElement(Document* document, Custo mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom Element::NameSet validNames, ExceptionState& exceptionState) 53 void CustomElementRegistrationContext::registerElement(Document* document, Custo mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom Element::NameSet validNames, ExceptionState& exceptionState)
49 { 54 {
50 CustomElementDefinition* definition = m_registry.registerElement(document, c onstructorBuilder, type, validNames, exceptionState); 55 CustomElementDefinition* definition = m_registry.registerElement(document, c onstructorBuilder, type, validNames, exceptionState);
51 56
52 if (!definition) 57 if (!definition)
53 return; 58 return;
54 59
55 // Upgrade elements that were waiting for this definition. 60 // Upgrade elements that were waiting for this definition.
56 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca ndidates.takeUpgradeCandidatesFor(definition->descriptor()); 61 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca ndidates->takeUpgradeCandidatesFor(definition->descriptor());
57 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra deCandidates.begin(); it != upgradeCandidates.end(); ++it) 62 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra deCandidates.begin(); it != upgradeCandidates.end(); ++it)
58 CustomElement::define(*it, definition); 63 CustomElement::define(*it, definition);
59 } 64 }
60 65
61 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa gElement(Document& document, const QualifiedName& tagName) 66 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa gElement(Document& document, const QualifiedName& tagName)
62 { 67 {
63 ASSERT(CustomElement::isValidName(tagName.localName())); 68 ASSERT(CustomElement::isValidName(tagName.localName()));
64 69
65 RefPtrWillBeRawPtr<Element> element; 70 RefPtrWillBeRawPtr<Element> element;
66 71
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r); 103 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto r);
99 } 104 }
100 105
101 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor) 106 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle mentDescriptor& descriptor)
102 { 107 {
103 CustomElementDefinition* definition = m_registry.find(descriptor); 108 CustomElementDefinition* definition = m_registry.find(descriptor);
104 if (definition) { 109 if (definition) {
105 CustomElement::define(element, definition); 110 CustomElement::define(element, definition);
106 } else { 111 } else {
107 ASSERT(element->customElementState() == Element::WaitingForUpgrade); 112 ASSERT(element->customElementState() == Element::WaitingForUpgrade);
108 m_candidates.add(descriptor, element); 113 m_candidates->add(descriptor, element);
109 } 114 }
110 } 115 }
111 116
112 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::c reate()
113 {
114 return adoptRef(new CustomElementRegistrationContext());
115 }
116
117 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type) 117 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type)
118 { 118 {
119 ASSERT(element); 119 ASSERT(element);
120 ASSERT(!type.isEmpty()); 120 ASSERT(!type.isEmpty());
121 element->setAttribute(HTMLNames::isAttr, type); 121 element->setAttribute(HTMLNames::isAttr, type);
122 setTypeExtension(element, type); 122 setTypeExtension(element, type);
123 } 123 }
124 124
125 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type) 125 void CustomElementRegistrationContext::setTypeExtension(Element* element, const AtomicString& type)
126 { 126 {
(...skipping 16 matching lines...) Expand all
143 // Custom tags take precedence over type extensions 143 // Custom tags take precedence over type extensions
144 ASSERT(!CustomElement::isValidName(element->localName())); 144 ASSERT(!CustomElement::isValidName(element->localName()));
145 145
146 if (!CustomElement::isValidName(type)) 146 if (!CustomElement::isValidName(type))
147 return; 147 return;
148 148
149 element->setCustomElementState(Element::WaitingForUpgrade); 149 element->setCustomElementState(Element::WaitingForUpgrade);
150 context->didGiveTypeExtension(element, type); 150 context->didGiveTypeExtension(element, type);
151 } 151 }
152 152
153 void CustomElementRegistrationContext::trace(Visitor* visitor)
154 {
155 visitor->trace(m_candidates);
156 }
157
153 } // namespace WebCore 158 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698