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

Side by Side Diff: Source/bindings/core/v8/CustomElementWrapper.cpp

Issue 531183003: bindings: Retires manual dispatching in createV8{HTML,SVG}Wrapper, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed bindings/modules/v8/custom/custom.gni Created 6 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/core/v8/CustomElementWrapper.h" 32 #include "bindings/core/v8/CustomElementWrapper.h"
33 33
34 #include "bindings/core/v8/DOMDataStore.h" 34 #include "bindings/core/v8/DOMDataStore.h"
35 #include "bindings/core/v8/DOMWrapperWorld.h" 35 #include "bindings/core/v8/DOMWrapperWorld.h"
36 #include "bindings/core/v8/V8HTMLElement.h" 36 #include "bindings/core/v8/V8HTMLElement.h"
37 #include "bindings/core/v8/V8PerContextData.h" 37 #include "bindings/core/v8/V8PerContextData.h"
38 #include "bindings/core/v8/V8SVGElement.h" 38 #include "bindings/core/v8/V8SVGElement.h"
39 #include "core/V8HTMLElementWrapperFactory.h" // FIXME: should be bindings/core/ v8
40 #include "core/V8SVGElementWrapperFactory.h" // FIXME: should be bindings/core/v 8
41 #include "core/dom/custom/CustomElement.h" 39 #include "core/dom/custom/CustomElement.h"
42 #include "core/html/HTMLElement.h" 40 #include "core/html/HTMLElement.h"
43 #include "core/html/HTMLUnknownElement.h"
44 #include "core/svg/SVGElement.h" 41 #include "core/svg/SVGElement.h"
45 42
46 namespace blink { 43 namespace blink {
47 44
48 template<typename ElementType> 45 template<typename ElementType>
49 v8::Handle<v8::Object> createDirectWrapper(ElementType*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
50
51 template<>
52 v8::Handle<v8::Object> createDirectWrapper<HTMLElement>(HTMLElement* element, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate)
53 {
54 return createV8HTMLDirectWrapper(element, creationContext, isolate);
55 }
56
57 template<>
58 v8::Handle<v8::Object> createDirectWrapper<SVGElement>(SVGElement* element, v8:: Handle<v8::Object> creationContext, v8::Isolate* isolate)
59 {
60 return createV8SVGDirectWrapper(element, creationContext, isolate);
61 }
62
63 template<typename ElementType>
64 v8::Handle<v8::Object> createFallbackWrapper(ElementType*, v8::Handle<v8::Object > creationContext, v8::Isolate*);
65
66 template<>
67 v8::Handle<v8::Object> createFallbackWrapper<HTMLElement>(HTMLElement* element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
68 {
69 return createV8HTMLFallbackWrapper(toHTMLUnknownElement(element), creationCo ntext, isolate);
70 }
71
72 template<>
73 v8::Handle<v8::Object> createFallbackWrapper<SVGElement>(SVGElement* element, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate)
74 {
75 return createV8SVGFallbackWrapper(element, creationContext, isolate);
76 }
77
78 template<typename ElementType>
79 v8::Handle<v8::Object> createUpgradeCandidateWrapper(ElementType* element, v8::H andle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v8::Object> creationCo ntext, v8::Isolate*)) 46 v8::Handle<v8::Object> createUpgradeCandidateWrapper(ElementType* element, v8::H andle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v8::Object> creationCo ntext, v8::Isolate*))
80 { 47 {
81 if (CustomElement::isValidName(element->localName())) 48 if (CustomElement::isValidName(element->localName()))
82 return createDirectWrapper(element, creationContext, isolate); 49 return element->wrap(creationContext, isolate);
83 if (createSpecificWrapper) 50 if (createSpecificWrapper)
84 return createSpecificWrapper(element, creationContext, isolate); 51 return createSpecificWrapper(element, creationContext, isolate);
85 return createFallbackWrapper(element, creationContext, isolate); 52 return element->wrap(creationContext, isolate);
86 } 53 }
87 54
88 template<typename ElementType, typename WrapperType> 55 template<typename ElementType, typename WrapperType>
89 v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(Pass RefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementTy pe* element, v8::Handle<v8::Object> creationContext, v8::Isolate*)) 56 v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(Pass RefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementTy pe* element, v8::Handle<v8::Object> creationContext, v8::Isolate*))
90 { 57 {
91 ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty() ); 58 ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty() );
92 59
93 ASSERT(!creationContext.IsEmpty()); 60 ASSERT(!creationContext.IsEmpty());
94 v8::Handle<v8::Context> context = creationContext->CreationContext(); 61 v8::Handle<v8::Context> context = creationContext->CreationContext();
95 62
(...skipping 16 matching lines...) Expand all
112 return wrapper; 79 return wrapper;
113 } 80 }
114 81
115 template 82 template
116 class CustomElementWrapper<HTMLElement, V8HTMLElement>; 83 class CustomElementWrapper<HTMLElement, V8HTMLElement>;
117 84
118 template 85 template
119 class CustomElementWrapper<SVGElement, V8SVGElement>; 86 class CustomElementWrapper<SVGElement, V8SVGElement>;
120 87
121 } // namespace blink 88 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698