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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp

Issue 2173623003: Add "Failed" custom element state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid multiple toElement Created 4 years, 4 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ScriptCustomElementDefinition.h" 5 #include "bindings/core/v8/ScriptCustomElementDefinition.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8BindingMacros.h" 9 #include "bindings/core/v8/V8BindingMacros.h"
10 #include "bindings/core/v8/V8CustomElementsRegistry.h" 10 #include "bindings/core/v8/V8CustomElementsRegistry.h"
11 #include "bindings/core/v8/V8Element.h" 11 #include "bindings/core/v8/V8Element.h"
12 #include "bindings/core/v8/V8HiddenValue.h" 12 #include "bindings/core/v8/V8HiddenValue.h"
13 #include "bindings/core/v8/V8ScriptRunner.h" 13 #include "bindings/core/v8/V8ScriptRunner.h"
14 #include "bindings/core/v8/V8ThrowException.h" 14 #include "bindings/core/v8/V8ThrowException.h"
15 #include "core/dom/ExceptionCode.h" 15 #include "core/dom/ExceptionCode.h"
16 #include "core/dom/custom/CustomElement.h"
16 #include "core/html/HTMLElement.h" 17 #include "core/html/HTMLElement.h"
17 #include "core/html/HTMLUnknownElement.h"
18 #include "v8.h" 18 #include "v8.h"
19 #include "wtf/Allocator.h" 19 #include "wtf/Allocator.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 // Retrieves the custom elements constructor -> name map, creating it 23 // Retrieves the custom elements constructor -> name map, creating it
24 // if necessary. The same map is used to keep prototypes alive. 24 // if necessary. The same map is used to keep prototypes alive.
25 static v8::Local<v8::Map> ensureCustomElementsRegistryMap( 25 static v8::Local<v8::Map> ensureCustomElementsRegistryMap(
26 ScriptState* scriptState, 26 ScriptState* scriptState,
27 CustomElementsRegistry* registry) 27 CustomElementsRegistry* registry)
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 HTMLElement* element = createElementSync(document, tagName, exceptionState); 198 HTMLElement* element = createElementSync(document, tagName, exceptionState);
199 199
200 if (exceptionState.hadException() || !element) { 200 if (exceptionState.hadException() || !element) {
201 // 7. If this step throws an exception, then report the exception, ... 201 // 7. If this step throws an exception, then report the exception, ...
202 { 202 {
203 v8::TryCatch tryCatch(isolate); 203 v8::TryCatch tryCatch(isolate);
204 tryCatch.SetVerbose(true); 204 tryCatch.SetVerbose(true);
205 exceptionState.throwIfNeeded(); 205 exceptionState.throwIfNeeded();
206 } 206 }
207 207
208 // ...and let element be instead a new element that implements 208 return CustomElement::createFailedElement(document, tagName);
209 // HTMLUnknownElement, with no attributes, namespace set to given
210 // namespace, namespace prefix set to null, custom element state
211 // "undefined", and node document set to document.
212 element = HTMLUnknownElement::create(tagName, document);
213 element->setCustomElementState(CustomElementState::Undefined);
214 } 209 }
215 return element; 210 return element;
216 } 211 }
217 212
218 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades 213 // https://html.spec.whatwg.org/multipage/scripting.html#upgrades
219 bool ScriptCustomElementDefinition::runConstructor(Element* element) 214 bool ScriptCustomElementDefinition::runConstructor(Element* element)
220 { 215 {
221 if (!m_scriptState->contextIsValid()) 216 if (!m_scriptState->contextIsValid())
222 return false; 217 return false;
223 ScriptState::Scope scope(m_scriptState.get()); 218 ScriptState::Scope scope(m_scriptState.get());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 v8String(isolate, name.localName()), 342 v8String(isolate, name.localName()),
348 v8StringOrNull(isolate, oldValue), 343 v8StringOrNull(isolate, oldValue),
349 v8StringOrNull(isolate, newValue), 344 v8StringOrNull(isolate, newValue),
350 v8String(isolate, name.namespaceURI()), 345 v8String(isolate, name.namespaceURI()),
351 }; 346 };
352 runCallback(m_attributeChangedCallback.newLocal(isolate), element, 347 runCallback(m_attributeChangedCallback.newLocal(isolate), element,
353 argc, argv); 348 argc, argv);
354 } 349 }
355 350
356 } // namespace blink 351 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698