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/V8BindingMacros.h" | 9 #include "bindings/core/v8/V8BindingMacros.h" |
| 10 #include "bindings/core/v8/V8CustomElementRegistry.h" | 10 #include "bindings/core/v8/V8CustomElementRegistry.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 const v8::Local<v8::Function>& attributeChangedCallback, | 154 const v8::Local<v8::Function>& attributeChangedCallback, |
| 155 const HashSet<AtomicString>& observedAttributes) | 155 const HashSet<AtomicString>& observedAttributes) |
| 156 : CustomElementDefinition(descriptor, observedAttributes) | 156 : CustomElementDefinition(descriptor, observedAttributes) |
| 157 , m_scriptState(scriptState) | 157 , m_scriptState(scriptState) |
| 158 , m_constructor(scriptState->isolate(), constructor) | 158 , m_constructor(scriptState->isolate(), constructor) |
| 159 { | 159 { |
| 160 } | 160 } |
| 161 | 161 |
| 162 HTMLElement* ScriptCustomElementDefinition::createElementSync( | 162 HTMLElement* ScriptCustomElementDefinition::createElementSync( |
| 163 Document& document, const QualifiedName& tagName, | 163 Document& document, const QualifiedName& tagName, |
| 164 ExceptionState* exceptionState) | |
| 165 { | |
| 166 return exceptionState | |
| 167 ? createElementSync(document, tagName, *exceptionState) | |
| 168 : createElementSync(document, tagName); | |
|
esprehn
2016/08/30 21:32:32
merge them together, there should be a single path
| |
| 169 } | |
| 170 | |
| 171 HTMLElement* ScriptCustomElementDefinition::createElementSync( | |
| 172 Document& document, const QualifiedName& tagName, | |
| 164 ExceptionState& exceptionState) | 173 ExceptionState& exceptionState) |
| 165 { | 174 { |
| 166 DCHECK(ScriptState::current(m_scriptState->isolate()) == m_scriptState); | 175 DCHECK(ScriptState::current(m_scriptState->isolate()) == m_scriptState); |
| 167 | 176 |
| 168 // Create an element | 177 // Create an element |
| 169 // https://dom.spec.whatwg.org/#concept-create-element | 178 // https://dom.spec.whatwg.org/#concept-create-element |
| 170 // 6. If definition is non-null | 179 // 6. If definition is non-null |
| 171 // 6.1. If the synchronous custom elements flag is set: | 180 // 6.1. If the synchronous custom elements flag is set: |
| 172 // 6.1.2. Set result to Construct(C). Rethrow any exceptions. | 181 // 6.1.2. Set result to Construct(C). Rethrow any exceptions. |
| 173 | 182 |
| 174 // Create an element and push to the construction stack. | 183 // Create an element and push to the construction stack. |
| 175 // V8HTMLElement::constructorCustom() can only refer to | 184 // V8HTMLElement::constructorCustom() can only refer to |
| 176 // window.document(), but it is different from the document here | 185 // window.document(), but it is different from the document here |
| 177 // when it is an import document. This is not exactly what the | 186 // when it is an import document. This is not exactly what the |
| 178 // spec defines, but the public behavior matches to the spec. | 187 // spec defines, but the public behavior matches to the spec. |
| 188 | |
| 189 // TODO(dominicc): Simplify this to match the DOM spec when HTML | |
| 190 // Imports is removed. | |
| 179 Element* element = createElementForConstructor(document); | 191 Element* element = createElementForConstructor(document); |
| 180 { | 192 { |
| 181 ConstructionStackScope constructionStackScope(this, element); | 193 ConstructionStackScope constructionStackScope(this, element); |
| 182 v8::TryCatch tryCatch(m_scriptState->isolate()); | 194 v8::TryCatch tryCatch(m_scriptState->isolate()); |
| 183 element = runConstructor(); | 195 element = runConstructor(); |
| 184 if (tryCatch.HasCaught()) { | 196 if (tryCatch.HasCaught()) { |
| 185 exceptionState.rethrowV8Exception(tryCatch.Exception()); | 197 exceptionState.rethrowV8Exception(tryCatch.Exception()); |
| 186 return nullptr; | 198 return nullptr; |
| 187 } | 199 } |
| 188 } | 200 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 v8String(isolate, name.localName()), | 390 v8String(isolate, name.localName()), |
| 379 v8StringOrNull(isolate, oldValue), | 391 v8StringOrNull(isolate, oldValue), |
| 380 v8StringOrNull(isolate, newValue), | 392 v8StringOrNull(isolate, newValue), |
| 381 v8String(isolate, name.namespaceURI()), | 393 v8String(isolate, name.namespaceURI()), |
| 382 }; | 394 }; |
| 383 runCallback(m_attributeChangedCallback.newLocal(isolate), element, | 395 runCallback(m_attributeChangedCallback.newLocal(isolate), element, |
| 384 argc, argv); | 396 argc, argv); |
| 385 } | 397 } |
| 386 | 398 |
| 387 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |