| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 #ifndef CustomElementConstructorBuilder_h | 31 #ifndef V0CustomElementConstructorBuilder_h |
| 32 #define CustomElementConstructorBuilder_h | 32 #define V0CustomElementConstructorBuilder_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "bindings/core/v8/V8CustomElementLifecycleCallbacks.h" | 35 #include "bindings/core/v8/V8V0CustomElementLifecycleCallbacks.h" |
| 36 #include "core/dom/QualifiedName.h" | 36 #include "core/dom/QualifiedName.h" |
| 37 #include "core/dom/custom/CustomElementLifecycleCallbacks.h" | 37 #include "core/dom/custom/V0CustomElementLifecycleCallbacks.h" |
| 38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/text/AtomicString.h" | 40 #include "wtf/text/AtomicString.h" |
| 41 #include <v8.h> | 41 #include <v8.h> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class CustomElementDefinition; | 45 class V0CustomElementDefinition; |
| 46 class Document; | 46 class Document; |
| 47 class ElementRegistrationOptions; | 47 class ElementRegistrationOptions; |
| 48 class ExceptionState; | 48 class ExceptionState; |
| 49 class QualifiedName; | 49 class QualifiedName; |
| 50 struct WrapperTypeInfo; | 50 struct WrapperTypeInfo; |
| 51 | 51 |
| 52 // Handles the scripting-specific parts of the Custom Elements element | 52 // Handles the scripting-specific parts of the Custom Elements element |
| 53 // registration algorithm and constructor generation algorithm. It is | 53 // registration algorithm and constructor generation algorithm. It is |
| 54 // used in the implementation of those algorithms in | 54 // used in the implementation of those algorithms in |
| 55 // Document::registerElement. | 55 // Document::registerElement. |
| 56 class CustomElementConstructorBuilder { | 56 class V0CustomElementConstructorBuilder { |
| 57 WTF_MAKE_NONCOPYABLE(CustomElementConstructorBuilder); | 57 WTF_MAKE_NONCOPYABLE(V0CustomElementConstructorBuilder); |
| 58 STACK_ALLOCATED(); | 58 STACK_ALLOCATED(); |
| 59 public: | 59 public: |
| 60 CustomElementConstructorBuilder(ScriptState*, const ElementRegistrationOptio
ns&); | 60 V0CustomElementConstructorBuilder(ScriptState*, const ElementRegistrationOpt
ions&); |
| 61 | 61 |
| 62 // The builder accumulates state and may run script at specific | 62 // The builder accumulates state and may run script at specific |
| 63 // points. These methods must be called in order. When one fails | 63 // points. These methods must be called in order. When one fails |
| 64 // (returns false), the calls must stop. | 64 // (returns false), the calls must stop. |
| 65 | 65 |
| 66 bool isFeatureAllowed() const; | 66 bool isFeatureAllowed() const; |
| 67 bool validateOptions(const AtomicString& type, QualifiedName& tagName, Excep
tionState&); | 67 bool validateOptions(const AtomicString& type, QualifiedName& tagName, Excep
tionState&); |
| 68 CustomElementLifecycleCallbacks* createCallbacks(); | 68 V0CustomElementLifecycleCallbacks* createCallbacks(); |
| 69 bool createConstructor(Document*, CustomElementDefinition*, ExceptionState&)
; | 69 bool createConstructor(Document*, V0CustomElementDefinition*, ExceptionState
&); |
| 70 bool didRegisterDefinition() const; | 70 bool didRegisterDefinition() const; |
| 71 | 71 |
| 72 // This method collects a return value for the bindings. It is | 72 // This method collects a return value for the bindings. It is |
| 73 // safe to call this method even if the builder failed; it will | 73 // safe to call this method even if the builder failed; it will |
| 74 // return an empty value. | 74 // return an empty value. |
| 75 ScriptValue bindingsReturnValue() const; | 75 ScriptValue bindingsReturnValue() const; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 bool hasValidPrototypeChainFor(const WrapperTypeInfo*) const; | 78 bool hasValidPrototypeChainFor(const WrapperTypeInfo*) const; |
| 79 bool prototypeIsValid(const AtomicString& type, ExceptionState&) const; | 79 bool prototypeIsValid(const AtomicString& type, ExceptionState&) const; |
| 80 v8::MaybeLocal<v8::Function> retrieveCallback(const char* name); | 80 v8::MaybeLocal<v8::Function> retrieveCallback(const char* name); |
| 81 | 81 |
| 82 RefPtr<ScriptState> m_scriptState; | 82 RefPtr<ScriptState> m_scriptState; |
| 83 const ElementRegistrationOptions& m_options; | 83 const ElementRegistrationOptions& m_options; |
| 84 v8::Local<v8::Object> m_prototype; | 84 v8::Local<v8::Object> m_prototype; |
| 85 v8::Local<v8::Function> m_constructor; | 85 v8::Local<v8::Function> m_constructor; |
| 86 Member<V8CustomElementLifecycleCallbacks> m_callbacks; | 86 Member<V8V0CustomElementLifecycleCallbacks> m_callbacks; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace blink | 89 } // namespace blink |
| 90 | 90 |
| 91 #endif // CustomElementConstructorBuilder_h | 91 #endif // V0CustomElementConstructorBuilder_h |
| OLD | NEW |