| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/
v8 | 35 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/
v8 |
| 36 #include "sky/engine/bindings/core/v8/CustomElementBinding.h" | 36 #include "sky/engine/bindings/core/v8/CustomElementBinding.h" |
| 37 #include "sky/engine/bindings/core/v8/DOMWrapperWorld.h" | 37 #include "sky/engine/bindings/core/v8/DOMWrapperWorld.h" |
| 38 #include "sky/engine/bindings/core/v8/Dictionary.h" | 38 #include "sky/engine/bindings/core/v8/Dictionary.h" |
| 39 #include "sky/engine/bindings/core/v8/ExceptionState.h" | 39 #include "sky/engine/bindings/core/v8/ExceptionState.h" |
| 40 #include "sky/engine/bindings/core/v8/V8Binding.h" | 40 #include "sky/engine/bindings/core/v8/V8Binding.h" |
| 41 #include "sky/engine/bindings/core/v8/V8HiddenValue.h" | 41 #include "sky/engine/bindings/core/v8/V8HiddenValue.h" |
| 42 #include "sky/engine/bindings/core/v8/V8PerContextData.h" | 42 #include "sky/engine/bindings/core/v8/V8PerContextData.h" |
| 43 #include "sky/engine/core/dom/Document.h" | 43 #include "sky/engine/core/dom/Document.h" |
| 44 #include "sky/engine/core/dom/custom/CustomElementDefinition.h" | 44 #include "sky/engine/core/dom/custom/CustomElementDefinition.h" |
| 45 #include "sky/engine/core/dom/custom/CustomElementDescriptor.h" | |
| 46 #include "sky/engine/core/dom/custom/CustomElementException.h" | 45 #include "sky/engine/core/dom/custom/CustomElementException.h" |
| 47 #include "sky/engine/core/dom/custom/CustomElementProcessingStack.h" | 46 #include "sky/engine/core/dom/custom/CustomElementProcessingStack.h" |
| 48 #include "sky/engine/wtf/Assertions.h" | 47 #include "sky/engine/wtf/Assertions.h" |
| 49 | 48 |
| 50 namespace blink { | 49 namespace blink { |
| 51 | 50 |
| 52 static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&); | 51 static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&); |
| 53 | 52 |
| 54 CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* sc
riptState, const Dictionary* options) | 53 CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* sc
riptState, const Dictionary* options) |
| 55 : m_scriptState(scriptState) | 54 : m_scriptState(scriptState) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 158 } |
| 160 | 159 |
| 161 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust
omElementDefinition* definition, ExceptionState& exceptionState) | 160 bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust
omElementDefinition* definition, ExceptionState& exceptionState) |
| 162 { | 161 { |
| 163 ASSERT(!m_prototype.IsEmpty()); | 162 ASSERT(!m_prototype.IsEmpty()); |
| 164 ASSERT(m_constructor.IsEmpty()); | 163 ASSERT(m_constructor.IsEmpty()); |
| 165 ASSERT(document); | 164 ASSERT(document); |
| 166 | 165 |
| 167 v8::Isolate* isolate = m_scriptState->isolate(); | 166 v8::Isolate* isolate = m_scriptState->isolate(); |
| 168 | 167 |
| 169 if (!prototypeIsValid(definition->descriptor().localName(), exceptionState)) | 168 if (!prototypeIsValid(definition->localName(), exceptionState)) |
| 170 return false; | 169 return false; |
| 171 | 170 |
| 172 v8::Local<v8::FunctionTemplate> constructorTemplate = v8::FunctionTemplate::
New(isolate); | 171 v8::Local<v8::FunctionTemplate> constructorTemplate = v8::FunctionTemplate::
New(isolate); |
| 173 constructorTemplate->SetCallHandler(constructCustomElement); | 172 constructorTemplate->SetCallHandler(constructCustomElement); |
| 174 m_constructor = constructorTemplate->GetFunction(); | 173 m_constructor = constructorTemplate->GetFunction(); |
| 175 if (m_constructor.IsEmpty()) { | 174 if (m_constructor.IsEmpty()) { |
| 176 CustomElementException::throwException(CustomElementException::ContextDe
stroyedRegisteringDefinition, definition->descriptor().localName(), exceptionSta
te); | 175 CustomElementException::throwException(CustomElementException::ContextDe
stroyedRegisteringDefinition, definition->localName(), exceptionState); |
| 177 return false; | 176 return false; |
| 178 } | 177 } |
| 179 | 178 |
| 180 const CustomElementDescriptor& descriptor = definition->descriptor(); | 179 v8::Handle<v8::String> v8TagName = v8String(isolate, definition->localName()
); |
| 181 | |
| 182 v8::Handle<v8::String> v8TagName = v8String(isolate, descriptor.localName())
; | |
| 183 | 180 |
| 184 m_constructor->SetName(v8TagName); | 181 m_constructor->SetName(v8TagName); |
| 185 | 182 |
| 186 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE
lementDocument(isolate), toV8(document, m_scriptState->context()->Global(), isol
ate)); | 183 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE
lementDocument(isolate), toV8(document, m_scriptState->context()->Global(), isol
ate)); |
| 187 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE
lementTagName(isolate), v8TagName); | 184 V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customE
lementTagName(isolate), v8TagName); |
| 188 | 185 |
| 189 v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype"); | 186 v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype"); |
| 190 v8::Handle<v8::String> constructorKey = v8String(isolate, "constructor"); | 187 v8::Handle<v8::String> constructorKey = v8String(isolate, "constructor"); |
| 191 | 188 |
| 192 ASSERT(m_constructor->HasOwnProperty(prototypeKey)); | 189 ASSERT(m_constructor->HasOwnProperty(prototypeKey)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 266 |
| 270 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl
ement", info.Holder(), info.GetIsolate()); | 267 ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomEl
ement", info.Holder(), info.GetIsolate()); |
| 271 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 268 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
| 272 RefPtr<Element> element = document->createElement(tagName, exceptionState); | 269 RefPtr<Element> element = document->createElement(tagName, exceptionState); |
| 273 if (exceptionState.throwIfNeeded()) | 270 if (exceptionState.throwIfNeeded()) |
| 274 return; | 271 return; |
| 275 v8SetReturnValueFast(info, element.release(), document); | 272 v8SetReturnValueFast(info, element.release(), document); |
| 276 } | 273 } |
| 277 | 274 |
| 278 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |