| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/core/v8/CustomElementConstructorBuilder.h" | 32 #include "bindings/core/v8/CustomElementConstructorBuilder.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/CustomElementBinding.h" | 34 #include "bindings/core/v8/CustomElementBinding.h" |
| 35 #include "bindings/core/v8/DOMWrapperWorld.h" | 35 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 36 #include "bindings/core/v8/Dictionary.h" | 36 #include "bindings/core/v8/Dictionary.h" |
| 37 #include "bindings/core/v8/DictionaryHelper.h" |
| 37 #include "bindings/core/v8/ExceptionState.h" | 38 #include "bindings/core/v8/ExceptionState.h" |
| 38 #include "bindings/core/v8/V8Binding.h" | 39 #include "bindings/core/v8/V8Binding.h" |
| 39 #include "bindings/core/v8/V8Document.h" | 40 #include "bindings/core/v8/V8Document.h" |
| 40 #include "bindings/core/v8/V8HiddenValue.h" | 41 #include "bindings/core/v8/V8HiddenValue.h" |
| 41 #include "bindings/core/v8/V8PerContextData.h" | 42 #include "bindings/core/v8/V8PerContextData.h" |
| 42 #include "core/HTMLNames.h" | 43 #include "core/HTMLNames.h" |
| 43 #include "core/SVGNames.h" | 44 #include "core/SVGNames.h" |
| 44 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/
v8 | 45 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/
v8 |
| 45 #include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v
8 | 46 #include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v
8 |
| 46 #include "core/dom/Document.h" | 47 #include "core/dom/Document.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 return m_scriptState->world().isMainWorld(); | 68 return m_scriptState->world().isMainWorld(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 bool CustomElementConstructorBuilder::validateOptions(const AtomicString& type,
QualifiedName& tagName, ExceptionState& exceptionState) | 71 bool CustomElementConstructorBuilder::validateOptions(const AtomicString& type,
QualifiedName& tagName, ExceptionState& exceptionState) |
| 71 { | 72 { |
| 72 ASSERT(m_prototype.IsEmpty()); | 73 ASSERT(m_prototype.IsEmpty()); |
| 73 | 74 |
| 74 v8::TryCatch tryCatch; | 75 v8::TryCatch tryCatch; |
| 75 | 76 |
| 76 ScriptValue prototypeScriptValue; | 77 ScriptValue prototypeScriptValue; |
| 77 if (m_options->get("prototype", prototypeScriptValue) && !prototypeScriptVal
ue.isNull()) { | 78 if (DictionaryHelper::get(*m_options, "prototype", prototypeScriptValue) &&
!prototypeScriptValue.isNull()) { |
| 78 ASSERT(!tryCatch.HasCaught()); | 79 ASSERT(!tryCatch.HasCaught()); |
| 79 if (!prototypeScriptValue.isObject()) { | 80 if (!prototypeScriptValue.isObject()) { |
| 80 CustomElementException::throwException(CustomElementException::Proto
typeNotAnObject, type, exceptionState); | 81 CustomElementException::throwException(CustomElementException::Proto
typeNotAnObject, type, exceptionState); |
| 81 tryCatch.ReThrow(); | 82 tryCatch.ReThrow(); |
| 82 return false; | 83 return false; |
| 83 } | 84 } |
| 84 m_prototype = prototypeScriptValue.v8Value().As<v8::Object>(); | 85 m_prototype = prototypeScriptValue.v8Value().As<v8::Object>(); |
| 85 } else if (!tryCatch.HasCaught()) { | 86 } else if (!tryCatch.HasCaught()) { |
| 86 m_prototype = v8::Object::New(m_scriptState->isolate()); | 87 m_prototype = v8::Object::New(m_scriptState->isolate()); |
| 87 v8::Local<v8::Object> basePrototype = m_scriptState->perContextData()->p
rototypeForType(&V8HTMLElement::wrapperTypeInfo); | 88 v8::Local<v8::Object> basePrototype = m_scriptState->perContextData()->p
rototypeForType(&V8HTMLElement::wrapperTypeInfo); |
| 88 if (!basePrototype.IsEmpty()) | 89 if (!basePrototype.IsEmpty()) |
| 89 m_prototype->SetPrototype(basePrototype); | 90 m_prototype->SetPrototype(basePrototype); |
| 90 } | 91 } |
| 91 | 92 |
| 92 if (tryCatch.HasCaught()) { | 93 if (tryCatch.HasCaught()) { |
| 93 tryCatch.ReThrow(); | 94 tryCatch.ReThrow(); |
| 94 return false; | 95 return false; |
| 95 } | 96 } |
| 96 | 97 |
| 97 AtomicString extends; | 98 AtomicString extends; |
| 98 bool extendsProvidedAndNonNull = m_options->get("extends", extends); | 99 bool extendsProvidedAndNonNull = DictionaryHelper::get(*m_options, "extends"
, extends); |
| 99 | 100 |
| 100 if (tryCatch.HasCaught()) { | 101 if (tryCatch.HasCaught()) { |
| 101 tryCatch.ReThrow(); | 102 tryCatch.ReThrow(); |
| 102 return false; | 103 return false; |
| 103 } | 104 } |
| 104 | 105 |
| 105 if (!m_scriptState->perContextData()) { | 106 if (!m_scriptState->perContextData()) { |
| 106 // FIXME: This should generate an InvalidContext exception at a later po
int. | 107 // FIXME: This should generate an InvalidContext exception at a later po
int. |
| 107 CustomElementException::throwException(CustomElementException::ContextDe
stroyedCheckingPrototype, type, exceptionState); | 108 CustomElementException::throwException(CustomElementException::ContextDe
stroyedCheckingPrototype, type, exceptionState); |
| 108 tryCatch.ReThrow(); | 109 tryCatch.ReThrow(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 295 |
| 295 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl
ement", info.Holder(), info.GetIsolate()); | 296 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl
ement", info.Holder(), info.GetIsolate()); |
| 296 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 297 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 297 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI
, tagName, maybeType->IsNull() ? nullAtom : type, exceptionState); | 298 RefPtrWillBeRawPtr<Element> element = document->createElementNS(namespaceURI
, tagName, maybeType->IsNull() ? nullAtom : type, exceptionState); |
| 298 if (exceptionState.throwIfNeeded()) | 299 if (exceptionState.throwIfNeeded()) |
| 299 return; | 300 return; |
| 300 v8SetReturnValueFast(info, element.release(), document); | 301 v8SetReturnValueFast(info, element.release(), document); |
| 301 } | 302 } |
| 302 | 303 |
| 303 } // namespace WebCore | 304 } // namespace WebCore |
| OLD | NEW |