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

Side by Side Diff: Source/bindings/modules/v8/ModuleBindingsInitializer.cpp

Issue 424813007: Simplify V8 wrapper generation for Event objects (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Tweak comment Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/custom/V8EventCustom.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "bindings/modules/v8/ModuleBindingsInitializer.h" 6 #include "bindings/modules/v8/ModuleBindingsInitializer.h"
7 7
8 #include "bindings/core/v8/ModuleProxy.h" 8 #include "bindings/core/v8/ModuleProxy.h"
9 #include "bindings/core/v8/V8Event.h" 9 #include "bindings/core/v8/V8Event.h"
10 #include "bindings/core/v8/V8EventTarget.h" 10 #include "bindings/core/v8/V8EventTarget.h"
11 #include "modules/EventModulesHeaders.h" 11 #include "modules/EventModulesHeaders.h"
12 #include "modules/EventModulesInterfaces.h" 12 #include "modules/EventModulesInterfaces.h"
13 #include "modules/EventTargetModulesHeaders.h" 13 #include "modules/EventTargetModulesHeaders.h"
14 #include "modules/EventTargetModulesInterfaces.h" 14 #include "modules/EventTargetModulesInterfaces.h"
15 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" 15 #include "modules/indexeddb/IDBPendingTransactionMonitor.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 #define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \ 19 #define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
20 if (EventNames::interfaceName == desiredInterface) \ 20 if (EventNames::interfaceName == desiredInterface) \
21 return wrap(static_cast<interfaceName*>(event), creationContext, isolate ); 21 return wrap(static_cast<interfaceName*>(event), creationContext, isolate );
22 22
23 static v8::Handle<v8::Object> wrapForModuleEvent(Event* event, v8::Handle<v8::Ob ject> creationContext, v8::Isolate *isolate) 23 static v8::Handle<v8::Object> wrapForModuleEvent(Event* event, v8::Handle<v8::Ob ject> creationContext, v8::Isolate *isolate)
24 { 24 {
25 ASSERT(event); 25 ASSERT(event);
26 26
27 String desiredInterface = event->interfaceName(); 27 String desiredInterface = event->interfaceName();
28 EVENT_MODULES_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE) 28 EVENT_MODULES_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE);
29
30 // Wrapping for core event types should have been tried before this
31 // function was called, so |event| should have been a module event type.
32 // If this ASSERT is hit, the event type was missing from both
33 // enumerations.
34 ASSERT_NOT_REACHED();
29 return v8::Handle<v8::Object>(); 35 return v8::Handle<v8::Object>();
30 } 36 }
31 37
32 #undef TRY_TO_WRAP_WITH_INTERFACE 38 #undef TRY_TO_WRAP_WITH_INTERFACE
33 39
34 #define TRY_TO_TOV8_WITH_INTERFACE(interfaceName) \ 40 #define TRY_TO_TOV8_WITH_INTERFACE(interfaceName) \
35 if (EventTargetNames::interfaceName == desiredInterface) \ 41 if (EventTargetNames::interfaceName == desiredInterface) \
36 return toV8(static_cast<interfaceName*>(impl), creationContext, isolate) ; 42 return toV8(static_cast<interfaceName*>(impl), creationContext, isolate) ;
37 43
38 static v8::Handle<v8::Value> toV8ForModuleEventTarget(EventTarget* impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate) 44 static v8::Handle<v8::Value> toV8ForModuleEventTarget(EventTarget* impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate)
(...skipping 16 matching lines...) Expand all
55 } 61 }
56 62
57 void ModuleBindingsInitializer::init() 63 void ModuleBindingsInitializer::init()
58 { 64 {
59 ModuleProxy::moduleProxy().registerWrapForEvent(wrapForModuleEvent); 65 ModuleProxy::moduleProxy().registerWrapForEvent(wrapForModuleEvent);
60 ModuleProxy::moduleProxy().registerToV8ForEventTarget(toV8ForModuleEventTarg et); 66 ModuleProxy::moduleProxy().registerToV8ForEventTarget(toV8ForModuleEventTarg et);
61 ModuleProxy::moduleProxy().registerDidLeaveScriptContextForRecursionScope(di dLeaveScriptContextForModule); 67 ModuleProxy::moduleProxy().registerDidLeaveScriptContextForRecursionScope(di dLeaveScriptContextForModule);
62 } 68 }
63 69
64 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8EventCustom.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698