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

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

Issue 69533003: Upgrade parser-created Custom Elements in creation order. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring patch to head. Created 7 years, 1 month 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/Node.cpp ('k') | Source/core/dom/custom/CustomElementRegistrationContext.h » ('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) 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition> passDefinition) 92 void CustomElement::define(Element* element, PassRefPtr<CustomElementDefinition> passDefinition)
93 { 93 {
94 RefPtr<CustomElementDefinition> definition(passDefinition); 94 RefPtr<CustomElementDefinition> definition(passDefinition);
95 95
96 switch (element->customElementState()) { 96 switch (element->customElementState()) {
97 case Element::NotCustomElement: 97 case Element::NotCustomElement:
98 case Element::Upgraded: 98 case Element::Upgraded:
99 ASSERT_NOT_REACHED(); 99 ASSERT_NOT_REACHED();
100 break; 100 break;
101 101
102 case Element::WaitingForParser:
103 definitions().add(element, definition);
104 break;
105
106 case Element::WaitingForUpgrade: 102 case Element::WaitingForUpgrade:
107 definitions().add(element, definition); 103 definitions().add(element, definition);
108 CustomElementCallbackScheduler::scheduleCreatedCallback(definition->call backs(), element); 104 CustomElementCallbackScheduler::scheduleCreatedCallback(definition->call backs(), element);
109 break; 105 break;
110 } 106 }
111 } 107 }
112 108
113 CustomElementDefinition* CustomElement::definitionFor(Element* element) 109 CustomElementDefinition* CustomElement::definitionFor(Element* element)
114 { 110 {
115 CustomElementDefinition* definition = definitions().get(element); 111 CustomElementDefinition* definition = definitions().get(element);
116 ASSERT(definition); 112 ASSERT(definition);
117 return definition; 113 return definition;
118 } 114 }
119 115
120 void CustomElement::didFinishParsingChildren(Element* element)
121 {
122 ASSERT(element->customElementState() == Element::WaitingForParser);
123 element->setCustomElementState(Element::WaitingForUpgrade);
124
125 CustomElementObserver::notifyElementDidFinishParsingChildren(element);
126
127 if (CustomElementDefinition* definition = definitions().get(element))
128 CustomElementCallbackScheduler::scheduleCreatedCallback(definition->call backs(), element);
129 }
130
131 void CustomElement::attributeDidChange(Element* element, const AtomicString& nam e, const AtomicString& oldValue, const AtomicString& newValue) 116 void CustomElement::attributeDidChange(Element* element, const AtomicString& nam e, const AtomicString& oldValue, const AtomicString& newValue)
132 { 117 {
133 ASSERT(element->customElementState() == Element::Upgraded); 118 ASSERT(element->customElementState() == Element::Upgraded);
134 CustomElementCallbackScheduler::scheduleAttributeChangedCallback(definitionF or(element)->callbacks(), element, name, oldValue, newValue); 119 CustomElementCallbackScheduler::scheduleAttributeChangedCallback(definitionF or(element)->callbacks(), element, name, oldValue, newValue);
135 } 120 }
136 121
137 void CustomElement::didEnterDocument(Element* element, const Document& document) 122 void CustomElement::didEnterDocument(Element* element, const Document& document)
138 { 123 {
139 ASSERT(element->customElementState() == Element::Upgraded); 124 ASSERT(element->customElementState() == Element::Upgraded);
140 if (!document.domWindow()) 125 if (!document.domWindow())
141 return; 126 return;
142 CustomElementCallbackScheduler::scheduleEnteredViewCallback(definitionFor(el ement)->callbacks(), element); 127 CustomElementCallbackScheduler::scheduleEnteredViewCallback(definitionFor(el ement)->callbacks(), element);
143 } 128 }
144 129
145 void CustomElement::didLeaveDocument(Element* element, const Document& document) 130 void CustomElement::didLeaveDocument(Element* element, const Document& document)
146 { 131 {
147 ASSERT(element->customElementState() == Element::Upgraded); 132 ASSERT(element->customElementState() == Element::Upgraded);
148 if (!document.domWindow()) 133 if (!document.domWindow())
149 return; 134 return;
150 CustomElementCallbackScheduler::scheduleLeftViewCallback(definitionFor(eleme nt)->callbacks(), element); 135 CustomElementCallbackScheduler::scheduleLeftViewCallback(definitionFor(eleme nt)->callbacks(), element);
151 } 136 }
152 137
153 void CustomElement::wasDestroyed(Element* element) 138 void CustomElement::wasDestroyed(Element* element)
154 { 139 {
155 switch (element->customElementState()) { 140 switch (element->customElementState()) {
156 case Element::NotCustomElement: 141 case Element::NotCustomElement:
157 ASSERT_NOT_REACHED(); 142 ASSERT_NOT_REACHED();
158 break; 143 break;
159 144
160 case Element::WaitingForParser:
161 case Element::WaitingForUpgrade: 145 case Element::WaitingForUpgrade:
162 case Element::Upgraded: 146 case Element::Upgraded:
163 definitions().remove(element); 147 definitions().remove(element);
164 CustomElementObserver::notifyElementWasDestroyed(element); 148 CustomElementObserver::notifyElementWasDestroyed(element);
165 break; 149 break;
166 } 150 }
167 } 151 }
168 152
169 void CustomElement::DefinitionMap::add(Element* element, PassRefPtr<CustomElemen tDefinition> definition) 153 void CustomElement::DefinitionMap::add(Element* element, PassRefPtr<CustomElemen tDefinition> definition)
170 { 154 {
171 ASSERT(definition.get()); 155 ASSERT(definition.get());
172 DefinitionMap::ElementDefinitionHashMap::AddResult result = m_definitions.ad d(element, definition); 156 DefinitionMap::ElementDefinitionHashMap::AddResult result = m_definitions.ad d(element, definition);
173 ASSERT_UNUSED(result, result.isNewEntry); 157 ASSERT_UNUSED(result, result.isNewEntry);
174 } 158 }
175 159
176 CustomElement::DefinitionMap& CustomElement::definitions() 160 CustomElement::DefinitionMap& CustomElement::definitions()
177 { 161 {
178 DEFINE_STATIC_LOCAL(DefinitionMap, map, ()); 162 DEFINE_STATIC_LOCAL(DefinitionMap, map, ());
179 return map; 163 return map;
180 } 164 }
181 165
182 } // namespace WebCore 166 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/dom/custom/CustomElementRegistrationContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698