OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * | 5 * |
6 * Use of this source code is governed by a BSD-style license that can be | 6 * Use of this source code is governed by a BSD-style license that can be |
7 * found in the LICENSE file. | 7 * found in the LICENSE file. |
8 * | 8 * |
9 */ | 9 */ |
10 #include <v8.h> | 10 #include <v8.h> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 JsContext* jsContext = Unwrap(info.This()); | 201 JsContext* jsContext = Unwrap(info.This()); |
202 SetStyle(name, value, info, jsContext->fStrokeStyle); | 202 SetStyle(name, value, info, jsContext->fStrokeStyle); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 void JsContext::GetWidth(Local<String> name, | 206 void JsContext::GetWidth(Local<String> name, |
207 const PropertyCallbackInfo<Value>& info) { | 207 const PropertyCallbackInfo<Value>& info) { |
208 JsContext* jsContext = Unwrap(info.This()); | 208 JsContext* jsContext = Unwrap(info.This()); |
209 SkISize size = jsContext->fCanvas->getDeviceSize(); | 209 SkISize size = jsContext->fCanvas->getDeviceSize(); |
210 | 210 |
211 info.GetReturnValue().Set(Int32::New(size.fWidth)); | 211 info.GetReturnValue().Set( |
| 212 Int32::New(jsContext->fGlobal->getIsolate(), size.fWidth)); |
212 } | 213 } |
213 | 214 |
214 void JsContext::GetHeight(Local<String> name, | 215 void JsContext::GetHeight(Local<String> name, |
215 const PropertyCallbackInfo<Value>& info) { | 216 const PropertyCallbackInfo<Value>& info) { |
216 JsContext* jsContext = Unwrap(info.This()); | 217 JsContext* jsContext = Unwrap(info.This()); |
217 SkISize size = jsContext->fCanvas->getDeviceSize(); | 218 SkISize size = jsContext->fCanvas->getDeviceSize(); |
218 | 219 |
219 info.GetReturnValue().Set(Int32::New(size.fHeight)); | 220 info.GetReturnValue().Set( |
| 221 Int32::New(jsContext->fGlobal->getIsolate(), size.fHeight)); |
220 } | 222 } |
221 | 223 |
222 | 224 |
223 Persistent<ObjectTemplate> JsContext::gContextTemplate; | 225 Persistent<ObjectTemplate> JsContext::gContextTemplate; |
224 | 226 |
225 #define ADD_METHOD(name, fn) \ | 227 #define ADD_METHOD(name, fn) \ |
226 result->Set(String::NewFromUtf8( \ | 228 result->Set(String::NewFromUtf8( \ |
227 fGlobal->getIsolate(), name, \ | 229 fGlobal->getIsolate(), name, \ |
228 String::kInternalizedString), \ | 230 String::kInternalizedString), \ |
229 FunctionTemplate::New(fn)) | 231 FunctionTemplate::New(fGlobal->getIsolate(), fn)) |
230 | 232 |
231 Handle<ObjectTemplate> JsContext::makeContextTemplate() { | 233 Handle<ObjectTemplate> JsContext::makeContextTemplate() { |
232 EscapableHandleScope handleScope(fGlobal->getIsolate()); | 234 EscapableHandleScope handleScope(fGlobal->getIsolate()); |
233 | 235 |
234 Local<ObjectTemplate> result = ObjectTemplate::New(); | 236 Local<ObjectTemplate> result = ObjectTemplate::New(); |
235 | 237 |
236 // Add a field to store the pointer to a JsContext instance. | 238 // Add a field to store the pointer to a JsContext instance. |
237 result->SetInternalFieldCount(1); | 239 result->SetInternalFieldCount(1); |
238 | 240 |
239 // Add accessors for each of the fields of the context object. | 241 // Add accessors for each of the fields of the context object. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 367 |
366 // It is a function; cast it to a Function. | 368 // It is a function; cast it to a Function. |
367 Handle<Function> fn_fun = Handle<Function>::Cast(fn_val); | 369 Handle<Function> fn_fun = Handle<Function>::Cast(fn_val); |
368 | 370 |
369 // Store the function in a Persistent handle, since we also want that to | 371 // Store the function in a Persistent handle, since we also want that to |
370 // remain after this call returns. | 372 // remain after this call returns. |
371 fOnDraw.Reset(fGlobal->getIsolate(), fn_fun); | 373 fOnDraw.Reset(fGlobal->getIsolate(), fn_fun); |
372 | 374 |
373 return true; | 375 return true; |
374 } | 376 } |
OLD | NEW |