| 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/V8CustomElementsRegistry.h" | 10 #include "bindings/core/v8/V8CustomElementsRegistry.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 HTMLElement* ScriptCustomElementDefinition::createElementSync( | 187 HTMLElement* ScriptCustomElementDefinition::createElementSync( |
| 188 Document& document, const QualifiedName& tagName) | 188 Document& document, const QualifiedName& tagName) |
| 189 { | 189 { |
| 190 ScriptState::Scope scope(m_scriptState.get()); | 190 ScriptState::Scope scope(m_scriptState.get()); |
| 191 v8::Isolate* isolate = m_scriptState->isolate(); | 191 v8::Isolate* isolate = m_scriptState->isolate(); |
| 192 | 192 |
| 193 // When invoked from "create an element for a token": | 193 // When invoked from "create an element for a token": |
| 194 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-
the-token | 194 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-
the-token |
| 195 | 195 |
| 196 // 7. If this step throws an exception, then report the exception, ... |
| 197 v8::TryCatch tryCatch(isolate); |
| 198 tryCatch.SetVerbose(true); |
| 196 ExceptionState exceptionState(ExceptionState::ConstructionContext, | 199 ExceptionState exceptionState(ExceptionState::ConstructionContext, |
| 197 "CustomElement", constructor(), isolate); | 200 "CustomElement", constructor(), isolate); |
| 198 HTMLElement* element = createElementSync(document, tagName, exceptionState); | 201 HTMLElement* element = createElementSync(document, tagName, exceptionState); |
| 199 | 202 |
| 200 if (exceptionState.hadException() || !element) { | 203 if (exceptionState.hadException() || !element) { |
| 201 // 7. If this step throws an exception, then report the exception, ... | |
| 202 { | |
| 203 v8::TryCatch tryCatch(isolate); | |
| 204 tryCatch.SetVerbose(true); | |
| 205 exceptionState.throwIfNeeded(); | |
| 206 } | |
| 207 | |
| 208 // ...and let element be instead a new element that implements | 204 // ...and let element be instead a new element that implements |
| 209 // HTMLUnknownElement, with no attributes, namespace set to given | 205 // HTMLUnknownElement, with no attributes, namespace set to given |
| 210 // namespace, namespace prefix set to null, custom element state | 206 // namespace, namespace prefix set to null, custom element state |
| 211 // "undefined", and node document set to document. | 207 // "undefined", and node document set to document. |
| 212 element = HTMLUnknownElement::create(tagName, document); | 208 element = HTMLUnknownElement::create(tagName, document); |
| 213 element->setCustomElementState(CustomElementState::Undefined); | 209 element->setCustomElementState(CustomElementState::Undefined); |
| 214 } | 210 } |
| 215 return element; | 211 return element; |
| 216 } | 212 } |
| 217 | 213 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 v8String(isolate, name.localName()), | 343 v8String(isolate, name.localName()), |
| 348 v8StringOrNull(isolate, oldValue), | 344 v8StringOrNull(isolate, oldValue), |
| 349 v8StringOrNull(isolate, newValue), | 345 v8StringOrNull(isolate, newValue), |
| 350 v8String(isolate, name.namespaceURI()), | 346 v8String(isolate, name.namespaceURI()), |
| 351 }; | 347 }; |
| 352 runCallback(m_attributeChangedCallback.newLocal(isolate), element, | 348 runCallback(m_attributeChangedCallback.newLocal(isolate), element, |
| 353 argc, argv); | 349 argc, argv); |
| 354 } | 350 } |
| 355 | 351 |
| 356 } // namespace blink | 352 } // namespace blink |
| OLD | NEW |