Chromium Code Reviews| 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/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/V8CustomElementsRegistry.h" | 9 #include "bindings/core/v8/V8CustomElementsRegistry.h" |
| 10 #include "bindings/core/v8/V8HiddenValue.h" | 10 #include "bindings/core/v8/V8HiddenValue.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 102 |
| 103 return definition; | 103 return definition; |
| 104 } | 104 } |
| 105 | 105 |
| 106 ScriptCustomElementDefinition::ScriptCustomElementDefinition( | 106 ScriptCustomElementDefinition::ScriptCustomElementDefinition( |
| 107 ScriptState* scriptState, | 107 ScriptState* scriptState, |
| 108 const CustomElementDescriptor& descriptor, | 108 const CustomElementDescriptor& descriptor, |
| 109 const v8::Local<v8::Object>& constructor, | 109 const v8::Local<v8::Object>& constructor, |
| 110 const v8::Local<v8::Object>& prototype) | 110 const v8::Local<v8::Object>& prototype) |
| 111 : CustomElementDefinition(descriptor) | 111 : CustomElementDefinition(descriptor) |
| 112 , m_scriptState(scriptState) | |
| 112 , m_constructor(scriptState->isolate(), constructor) | 113 , m_constructor(scriptState->isolate(), constructor) |
| 113 , m_prototype(scriptState->isolate(), prototype) | 114 , m_prototype(scriptState->isolate(), prototype) |
| 114 { | 115 { |
| 115 // These objects are kept alive by references from the | 116 // These objects are kept alive by references from the |
| 116 // CustomElementsRegistry wrapper set up by | 117 // CustomElementsRegistry wrapper set up by |
| 117 // ScriptCustomElementDefinition::create. | 118 // ScriptCustomElementDefinition::create. |
| 118 m_constructor.setPhantom(); | 119 m_constructor.setPhantom(); |
| 119 m_prototype.setPhantom(); | 120 m_prototype.setPhantom(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 v8::Local<v8::Object> ScriptCustomElementDefinition::constructor( | 123 v8::Local<v8::Object> ScriptCustomElementDefinition::constructor( |
| 123 ScriptState* scriptState) const | 124 ScriptState* scriptState) const |
| 124 { | 125 { |
| 126 DCHECK_EQ(m_scriptState, scriptState); | |
| 125 DCHECK(!m_constructor.isEmpty()); | 127 DCHECK(!m_constructor.isEmpty()); |
| 126 return m_constructor.newLocal(scriptState->isolate()); | 128 return m_constructor.newLocal(scriptState->isolate()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 v8::Local<v8::Object> ScriptCustomElementDefinition::prototype( | 131 v8::Local<v8::Object> ScriptCustomElementDefinition::prototype( |
| 130 ScriptState* scriptState) const | 132 ScriptState* scriptState) const |
| 131 { | 133 { |
| 134 DCHECK_EQ(m_scriptState, scriptState); | |
|
yosin_UTC9
2016/05/31 09:16:57
Do we really need to have this check?
| |
| 132 DCHECK(!m_prototype.isEmpty()); | 135 DCHECK(!m_prototype.isEmpty()); |
| 133 return m_prototype.newLocal(scriptState->isolate()); | 136 return m_prototype.newLocal(scriptState->isolate()); |
| 134 } | 137 } |
| 135 | 138 |
| 139 // CustomElementDefinition | |
| 140 ScriptValue ScriptCustomElementDefinition::getConstructor( | |
| 141 ScriptState* scriptState) | |
| 142 { | |
| 143 if (m_scriptState != scriptState) | |
|
yosin_UTC9
2016/05/31 09:16:57
Do we really need to have this check?
| |
| 144 return ScriptValue(scriptState, v8Undefined()); | |
|
yosin_UTC9
2016/05/31 09:16:57
Should be |ScriptValue()|
dominicc (has gone to gerrit)
2016/05/31 22:56:32
Why not just do that?
yosin_UTC9
2016/06/01 02:14:37
I expect to have this patch isn't ready for commit
| |
| 145 return ScriptValue(scriptState, constructor(scriptState)); | |
| 146 } | |
| 147 | |
| 136 } // namespace blink | 148 } // namespace blink |
| OLD | NEW |