Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h

Issue 2828643002: Make customElements.define faster
Patch Set: Remove some unneeded casts. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef ScriptCustomElementDefinition_h 5 #ifndef ScriptCustomElementDefinition_h
6 #define ScriptCustomElementDefinition_h 6 #define ScriptCustomElementDefinition_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/TraceWrapperV8Reference.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
11 #include "core/dom/custom/CustomElementDefinition.h" 11 #include "core/dom/custom/CustomElementDefinition.h"
12 #include "platform/wtf/Noncopyable.h" 12 #include "platform/wtf/Noncopyable.h"
13 #include "platform/wtf/RefPtr.h" 13 #include "platform/wtf/RefPtr.h"
14 #include "v8.h" 14 #include "v8.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class CustomElementDescriptor; 18 class CustomElementDescriptor;
19 class CustomElementRegistry; 19 class CustomElementRegistry;
20 20
21 class CORE_EXPORT ScriptCustomElementDefinition final 21 class CORE_EXPORT ScriptCustomElementDefinition final
22 : public CustomElementDefinition { 22 : public CustomElementDefinition {
23 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition); 23 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition);
24 24
25 public: 25 public:
26 static ScriptCustomElementDefinition* ForConstructor( 26 static ScriptCustomElementDefinition* ForConstructor(
27 ScriptState*, 27 ScriptState*,
28 CustomElementRegistry*, 28 CustomElementRegistry*,
29 const v8::Local<v8::Value>& constructor); 29 const v8::Local<v8::Value>& constructor);
30 30
31 static ScriptCustomElementDefinition* Create( 31 static ScriptCustomElementDefinition* Create(
32 ScriptState*, 32 ScriptState*,
33 CustomElementRegistry*, 33 CustomElementRegistry*,
34 const CustomElementDescriptor&, 34 const CustomElementDescriptor&,
35 CustomElementDefinition::Id,
35 const v8::Local<v8::Object>& constructor, 36 const v8::Local<v8::Object>& constructor,
36 const v8::Local<v8::Function>& connected_callback, 37 const v8::Local<v8::Function>& connected_callback,
37 const v8::Local<v8::Function>& disconnected_callback, 38 const v8::Local<v8::Function>& disconnected_callback,
38 const v8::Local<v8::Function>& adopted_callback, 39 const v8::Local<v8::Function>& adopted_callback,
39 const v8::Local<v8::Function>& attribute_changed_callback, 40 const v8::Local<v8::Function>& attribute_changed_callback,
40 const HashSet<AtomicString>& observed_attributes); 41 HashSet<AtomicString>&& observed_attributes);
41 42
42 virtual ~ScriptCustomElementDefinition() = default; 43 virtual ~ScriptCustomElementDefinition() = default;
43 44
45 DECLARE_VIRTUAL_TRACE_WRAPPERS();
46
44 v8::Local<v8::Object> Constructor() const; 47 v8::Local<v8::Object> Constructor() const;
45 48
46 HTMLElement* CreateElementSync(Document&, const QualifiedName&) override; 49 HTMLElement* CreateElementSync(Document&, const QualifiedName&) override;
47 50
48 bool HasConnectedCallback() const override; 51 bool HasConnectedCallback() const override;
49 bool HasDisconnectedCallback() const override; 52 bool HasDisconnectedCallback() const override;
50 bool HasAdoptedCallback() const override; 53 bool HasAdoptedCallback() const override;
51 54
52 void RunConnectedCallback(Element*) override; 55 void RunConnectedCallback(Element*) override;
53 void RunDisconnectedCallback(Element*) override; 56 void RunDisconnectedCallback(Element*) override;
54 void RunAdoptedCallback(Element*, 57 void RunAdoptedCallback(Element*,
55 Document* old_owner, 58 Document* old_owner,
56 Document* new_owner) override; 59 Document* new_owner) override;
57 void RunAttributeChangedCallback(Element*, 60 void RunAttributeChangedCallback(Element*,
58 const QualifiedName&, 61 const QualifiedName&,
59 const AtomicString& old_value, 62 const AtomicString& old_value,
60 const AtomicString& new_value) override; 63 const AtomicString& new_value) override;
61 64
62 private: 65 private:
63 ScriptCustomElementDefinition( 66 ScriptCustomElementDefinition(
64 ScriptState*, 67 ScriptState*,
65 const CustomElementDescriptor&, 68 const CustomElementDescriptor&,
66 const v8::Local<v8::Object>& constructor, 69 const v8::Local<v8::Object>& constructor,
67 const v8::Local<v8::Function>& connected_callback, 70 const v8::Local<v8::Function>& connected_callback,
68 const v8::Local<v8::Function>& disconnected_callback, 71 const v8::Local<v8::Function>& disconnected_callback,
69 const v8::Local<v8::Function>& adopted_callback, 72 const v8::Local<v8::Function>& adopted_callback,
70 const v8::Local<v8::Function>& attribute_changed_callback, 73 const v8::Local<v8::Function>& attribute_changed_callback,
71 const HashSet<AtomicString>& observed_attributes); 74 HashSet<AtomicString>&& observed_attributes);
72 75
73 // Implementations of |CustomElementDefinition| 76 // Implementations of |CustomElementDefinition|
74 ScriptValue GetConstructorForScript() final; 77 ScriptValue GetConstructorForScript() final;
75 bool RunConstructor(Element*) override; 78 bool RunConstructor(Element*) override;
76 79
77 // Calls the constructor. The script scope, etc. must already be set up. 80 // Calls the constructor. The script scope, etc. must already be set up.
78 Element* CallConstructor(); 81 Element* CallConstructor();
79 82
80 void RunCallback(v8::Local<v8::Function>, 83 void RunCallback(v8::Local<v8::Function>,
81 Element*, 84 Element*,
82 int argc = 0, 85 int argc = 0,
83 v8::Local<v8::Value> argv[] = nullptr); 86 v8::Local<v8::Value> argv[] = nullptr);
84 87
85 HTMLElement* HandleCreateElementSyncException(Document&, 88 HTMLElement* HandleCreateElementSyncException(Document&,
86 const QualifiedName& tag_name, 89 const QualifiedName& tag_name,
87 v8::Isolate*, 90 v8::Isolate*,
88 ExceptionState&); 91 ExceptionState&);
89 92
90 RefPtr<ScriptState> script_state_; 93 RefPtr<ScriptState> script_state_;
91 ScopedPersistent<v8::Object> constructor_; 94 TraceWrapperV8Reference<v8::Object> constructor_;
92 ScopedPersistent<v8::Function> connected_callback_; 95 TraceWrapperV8Reference<v8::Function> connected_callback_;
93 ScopedPersistent<v8::Function> disconnected_callback_; 96 TraceWrapperV8Reference<v8::Function> disconnected_callback_;
94 ScopedPersistent<v8::Function> adopted_callback_; 97 TraceWrapperV8Reference<v8::Function> adopted_callback_;
95 ScopedPersistent<v8::Function> attribute_changed_callback_; 98 TraceWrapperV8Reference<v8::Function> attribute_changed_callback_;
96 }; 99 };
97 100
98 } // namespace blink 101 } // namespace blink
99 102
100 #endif // ScriptCustomElementDefinition_h 103 #endif // ScriptCustomElementDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698