| 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/V8HTMLElement.h" | 5 #include "bindings/core/v8/V8HTMLElement.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/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/core/v8/V8BindingMacros.h" | 11 #include "bindings/core/v8/V8BindingMacros.h" |
| 11 #include "bindings/core/v8/V8DOMWrapper.h" | 12 #include "bindings/core/v8/V8DOMWrapper.h" |
| 12 #include "bindings/core/v8/V8ThrowException.h" | 13 #include "bindings/core/v8/V8ThrowException.h" |
| 13 #include "core/dom/Document.h" | 14 #include "core/dom/Document.h" |
| 14 #include "core/dom/custom/CustomElementDefinition.h" | |
| 15 #include "core/dom/custom/CustomElementsRegistry.h" | 15 #include "core/dom/custom/CustomElementsRegistry.h" |
| 16 #include "core/frame/LocalDOMWindow.h" | 16 #include "core/frame/LocalDOMWindow.h" |
| 17 #include "platform/RuntimeEnabledFeatures.h" | 17 #include "platform/RuntimeEnabledFeatures.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 | 20 |
| 21 void V8HTMLElement::constructorCustom( | 21 void V8HTMLElement::constructorCustom( |
| 22 const v8::FunctionCallbackInfo<v8::Value>& info) | 22 const v8::FunctionCallbackInfo<v8::Value>& info) |
| 23 { | 23 { |
| 24 DCHECK(info.IsConstructCall()); | 24 DCHECK(info.IsConstructCall()); |
| 25 | 25 |
| 26 v8::Isolate* isolate = info.GetIsolate(); | 26 v8::Isolate* isolate = info.GetIsolate(); |
| 27 ScriptState* scriptState = ScriptState::current(isolate); | 27 ScriptState* scriptState = ScriptState::current(isolate); |
| 28 | 28 |
| 29 if (!RuntimeEnabledFeatures::customElementsV1Enabled() | 29 if (!RuntimeEnabledFeatures::customElementsV1Enabled() |
| 30 || !scriptState->world().isMainWorld()) { | 30 || !scriptState->world().isMainWorld()) { |
| 31 V8ThrowException::throwTypeError(info.GetIsolate(), "Illegal constructor
"); | 31 V8ThrowException::throwTypeError(info.GetIsolate(), "Illegal constructor
"); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 | 34 |
| 35 LocalDOMWindow* window = scriptState->domWindow(); | 35 LocalDOMWindow* window = scriptState->domWindow(); |
| 36 CustomElementDefinition* def = | 36 ScriptCustomElementDefinition* def = |
| 37 window->customElements(scriptState)->definitionForConstructor( | 37 ScriptCustomElementDefinition::forConstructor( |
| 38 scriptState, | 38 scriptState, |
| 39 window->customElements(), |
| 39 info.NewTarget()); | 40 info.NewTarget()); |
| 40 if (!def) { | 41 if (!def) { |
| 41 V8ThrowException::throwTypeError(isolate, "Illegal constructor"); | 42 V8ThrowException::throwTypeError(isolate, "Illegal constructor"); |
| 42 return; | 43 return; |
| 43 } | 44 } |
| 44 | 45 |
| 45 // TODO(dominicc): Implement cases where the definition's | 46 // TODO(dominicc): Implement cases where the definition's |
| 46 // construction stack is not empty when parser-creation is | 47 // construction stack is not empty when parser-creation is |
| 47 // implemented. | 48 // implemented. |
| 48 | 49 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 65 info.This()); | 66 info.This()); |
| 66 | 67 |
| 67 if (!v8CallBoolean(wrapper->SetPrototype( | 68 if (!v8CallBoolean(wrapper->SetPrototype( |
| 68 scriptState->context(), | 69 scriptState->context(), |
| 69 def->prototype(scriptState)))) { | 70 def->prototype(scriptState)))) { |
| 70 return; | 71 return; |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |