OLD | NEW |
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/ScriptCustomElementDefinitionBuilder.h" | 5 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.h" |
6 | 6 |
7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "bindings/core/v8/ScriptCustomElementDefinition.h" | 9 #include "bindings/core/v8/ScriptCustomElementDefinition.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
11 #include "bindings/core/v8/ScriptValue.h" | 11 #include "bindings/core/v8/ScriptValue.h" |
12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
13 #include "bindings/core/v8/V8BindingMacros.h" | 13 #include "bindings/core/v8/V8BindingMacros.h" |
14 #include "core/dom/ExceptionCode.h" | 14 #include "core/dom/ExceptionCode.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 ScriptCustomElementDefinitionBuilder* ScriptCustomElementDefinitionBuilder | 18 ScriptCustomElementDefinitionBuilder* ScriptCustomElementDefinitionBuilder |
19 ::s_stack = nullptr; | 19 ::s_stack = nullptr; |
20 | 20 |
21 ScriptCustomElementDefinitionBuilder::ScriptCustomElementDefinitionBuilder( | 21 ScriptCustomElementDefinitionBuilder::ScriptCustomElementDefinitionBuilder( |
22 ScriptState* scriptState, | 22 ScriptState* scriptState, |
23 CustomElementsRegistry* registry, | 23 CustomElementRegistry* registry, |
24 const ScriptValue& constructor, | 24 const ScriptValue& constructor, |
25 ExceptionState& exceptionState) | 25 ExceptionState& exceptionState) |
26 : m_prev(s_stack) | 26 : m_prev(s_stack) |
27 , m_scriptState(scriptState) | 27 , m_scriptState(scriptState) |
28 , m_registry(registry) | 28 , m_registry(registry) |
29 , m_constructorValue(constructor.v8Value()) | 29 , m_constructorValue(constructor.v8Value()) |
30 , m_exceptionState(exceptionState) | 30 , m_exceptionState(exceptionState) |
31 { | 31 { |
32 s_stack = this; | 32 s_stack = this; |
33 } | 33 } |
34 | 34 |
35 ScriptCustomElementDefinitionBuilder::~ScriptCustomElementDefinitionBuilder() | 35 ScriptCustomElementDefinitionBuilder::~ScriptCustomElementDefinitionBuilder() |
36 { | 36 { |
37 s_stack = m_prev; | 37 s_stack = m_prev; |
38 } | 38 } |
39 | 39 |
40 bool ScriptCustomElementDefinitionBuilder::checkConstructorIntrinsics() | 40 bool ScriptCustomElementDefinitionBuilder::checkConstructorIntrinsics() |
41 { | 41 { |
42 DCHECK(m_scriptState->world().isMainWorld()); | 42 DCHECK(m_scriptState->world().isMainWorld()); |
43 | 43 |
44 // The signature of CustomElementsRegistry.define says this is a | 44 // The signature of CustomElementRegistry.define says this is a |
45 // Function | 45 // Function |
46 // https://html.spec.whatwg.org/multipage/scripting.html#customelementsregis
try | 46 // https://html.spec.whatwg.org/multipage/scripting.html#customelementsregis
try |
47 CHECK(m_constructorValue->IsFunction()); | 47 CHECK(m_constructorValue->IsFunction()); |
48 m_constructor = m_constructorValue.As<v8::Object>(); | 48 m_constructor = m_constructorValue.As<v8::Object>(); |
49 if (!m_constructor->IsConstructor()) { | 49 if (!m_constructor->IsConstructor()) { |
50 m_exceptionState.throwTypeError( | 50 m_exceptionState.throwTypeError( |
51 "constructor argument is not a constructor"); | 51 "constructor argument is not a constructor"); |
52 return false; | 52 return false; |
53 } | 53 } |
54 return true; | 54 return true; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 m_constructor, | 171 m_constructor, |
172 m_prototype, | 172 m_prototype, |
173 m_connectedCallback, | 173 m_connectedCallback, |
174 m_disconnectedCallback, | 174 m_disconnectedCallback, |
175 m_adoptedCallback, | 175 m_adoptedCallback, |
176 m_attributeChangedCallback, | 176 m_attributeChangedCallback, |
177 m_observedAttributes); | 177 m_observedAttributes); |
178 } | 178 } |
179 | 179 |
180 } // namespace blink | 180 } // namespace blink |
OLD | NEW |