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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // may end up being the only node in the map and get garbage-collected prema
turely. | 95 // may end up being the only node in the map and get garbage-collected prema
turely. |
96 toV8(document, info.Holder(), info.GetIsolate()); | 96 toV8(document, info.Holder(), info.GetIsolate()); |
97 | 97 |
98 RefPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJ
SConstructor(*document); | 98 RefPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJ
SConstructor(*document); |
99 v8::Handle<v8::Object> wrapper = info.Holder(); | 99 v8::Handle<v8::Object> wrapper = info.Holder(); |
100 | 100 |
101 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.re
lease(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.
GetIsolate(), WrapperConfiguration::Dependent); | 101 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.re
lease(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.
GetIsolate(), WrapperConfiguration::Dependent); |
102 v8SetReturnValue(info, wrapper); | 102 v8SetReturnValue(info, wrapper); |
103 } | 103 } |
104 | 104 |
105 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTempl
ate(v8::Isolate* isolate, WrapperWorldType currentWorldType) | 105 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTempl
ate(v8::Isolate* isolate) |
106 { | 106 { |
107 static int domTemplateKey; // This address is used for a key to look up the
dom template. | 107 static int domTemplateKey; // This address is used for a key to look up the
dom template. |
108 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 108 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
109 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(currentWo
rldType, &domTemplateKey); | 109 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl
ateKey); |
110 if (!result.IsEmpty()) | 110 if (!result.IsEmpty()) |
111 return result; | 111 return result; |
112 | 112 |
113 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 113 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
114 v8::EscapableHandleScope scope(isolate); | 114 v8::EscapableHandleScope scope(isolate); |
115 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstr
uctorCallback); | 115 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstr
uctorCallback); |
116 | 116 |
117 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 117 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
118 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internal
FieldCount); | 118 instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internal
FieldCount); |
119 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget")); | 119 result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget")); |
120 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate, currentWorl
dType)); | 120 result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate)); |
121 data->setDOMTemplate(currentWorldType, &domTemplateKey, result); | 121 data->setDOMTemplate(&domTemplateKey, result); |
122 | |
123 return scope.Escape(result); | 122 return scope.Escape(result); |
124 } | 123 } |
125 | 124 |
126 static void configureV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionT
emplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldTy
pe) | 125 static void configureV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionT
emplate> functionTemplate, v8::Isolate* isolate) |
127 { | 126 { |
128 functionTemplate->ReadOnlyPrototype(); | 127 functionTemplate->ReadOnlyPrototype(); |
129 | 128 |
130 v8::Local<v8::Signature> defaultSignature; | 129 v8::Local<v8::Signature> defaultSignature; |
131 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate, currentWorl
dType), V8TestInterfaceEventTarget::internalFieldCount, | 130 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInte
rfaceEventTarget::internalFieldCount, |
132 0, 0, | 131 0, 0, |
133 0, 0, | 132 0, 0, |
134 0, 0, | 133 0, 0, |
135 isolate, currentWorldType); | 134 isolate); |
136 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 135 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
137 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 136 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
138 | 137 |
139 // Custom toString template | 138 // Custom toString template |
140 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 139 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
141 } | 140 } |
142 | 141 |
143 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Iso
late* isolate, WrapperWorldType currentWorldType) | 142 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Iso
late* isolate) |
144 { | 143 { |
145 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 144 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
146 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 145 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&w
rapperTypeInfo); |
147 if (result != data->templateMap(currentWorldType).end()) | 146 if (result != data->templateMap().end()) |
148 return result->value.newLocal(isolate); | 147 return result->value.newLocal(isolate); |
149 | 148 |
150 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 149 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
151 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 150 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
152 configureV8TestInterfaceEventTargetTemplate(templ, isolate, currentWorldType
); | 151 configureV8TestInterfaceEventTargetTemplate(templ, isolate); |
153 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 152 data->templateMap().add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTempl
ate>(isolate, templ)); |
154 return templ; | 153 return templ; |
155 } | 154 } |
156 | 155 |
157 bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> jsValue, v8::
Isolate* isolate) | 156 bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> jsValue, v8::
Isolate* isolate) |
158 { | 157 { |
159 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); | 158 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); |
160 } | 159 } |
161 | 160 |
162 v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(
v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) | 161 v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(
v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) |
163 { | 162 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 fromInternalPointer(object)->deref(); | 198 fromInternalPointer(object)->deref(); |
200 } | 199 } |
201 | 200 |
202 template<> | 201 template<> |
203 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) | 202 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) |
204 { | 203 { |
205 return toV8(impl, creationContext, isolate); | 204 return toV8(impl, creationContext, isolate); |
206 } | 205 } |
207 | 206 |
208 } // namespace WebCore | 207 } // namespace WebCore |
OLD | NEW |