OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 3 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/inspector/InspectorCanvasInstrumentation.h" | 44 #include "core/inspector/InspectorCanvasInstrumentation.h" |
45 #include "wtf/MathExtras.h" | 45 #include "wtf/MathExtras.h" |
46 #include "wtf/text/WTFString.h" | 46 #include "wtf/text/WTFString.h" |
47 | 47 |
48 namespace WebCore { | 48 namespace WebCore { |
49 | 49 |
50 void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& args) | 50 void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& args) |
51 { | 51 { |
52 v8::Handle<v8::Object> holder = args.Holder(); | 52 v8::Handle<v8::Object> holder = args.Holder(); |
53 HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(holder); | 53 HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(holder); |
54 String contextId = toWebCoreString(args[0]); | 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, contextIdResource,
args[0]); |
| 55 String contextId = contextIdResource; |
55 RefPtr<CanvasContextAttributes> attributes; | 56 RefPtr<CanvasContextAttributes> attributes; |
56 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId =
= "webkit-3d") { | 57 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId =
= "webkit-3d") { |
57 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes:
:create(); | 58 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes:
:create(); |
58 if (args.Length() > 1 && args[1]->IsObject()) { | 59 if (args.Length() > 1 && args[1]->IsObject()) { |
59 v8::Handle<v8::Object> jsAttributes = args[1]->ToObject(); | 60 v8::Handle<v8::Object> jsAttributes = args[1]->ToObject(); |
60 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); | 61 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); |
61 if (jsAttributes->Has(alpha)) | 62 if (jsAttributes->Has(alpha)) |
62 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue
()); | 63 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue
()); |
63 v8::Handle<v8::String> depth = v8::String::NewSymbol("depth"); | 64 v8::Handle<v8::String> depth = v8::String::NewSymbol("depth"); |
64 if (jsAttributes->Has(depth)) | 65 if (jsAttributes->Has(depth)) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 ASSERT_NOT_REACHED(); | 124 ASSERT_NOT_REACHED(); |
124 v8SetReturnValueNull(args); | 125 v8SetReturnValueNull(args); |
125 } | 126 } |
126 | 127 |
127 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& args) | 128 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& args) |
128 { | 129 { |
129 v8::Handle<v8::Object> holder = args.Holder(); | 130 v8::Handle<v8::Object> holder = args.Holder(); |
130 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); | 131 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); |
131 ExceptionState es(args.GetIsolate()); | 132 ExceptionState es(args.GetIsolate()); |
132 | 133 |
133 String type = toWebCoreString(args[0]); | 134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); |
134 double quality; | 135 double quality; |
135 double* qualityPtr = 0; | 136 double* qualityPtr = 0; |
136 if (args.Length() > 1 && args[1]->IsNumber()) { | 137 if (args.Length() > 1 && args[1]->IsNumber()) { |
137 quality = args[1]->NumberValue(); | 138 quality = args[1]->NumberValue(); |
138 qualityPtr = &quality; | 139 qualityPtr = &quality; |
139 } | 140 } |
140 | 141 |
141 String result = canvas->toDataURL(type, qualityPtr, es); | 142 String result = canvas->toDataURL(type, qualityPtr, es); |
142 es.throwIfNeeded(); | 143 es.throwIfNeeded(); |
143 v8SetReturnValueStringOrUndefined(args, result, args.GetIsolate()); | 144 v8SetReturnValueStringOrUndefined(args, result, args.GetIsolate()); |
144 } | 145 } |
145 | 146 |
146 } // namespace WebCore | 147 } // namespace WebCore |
OLD | NEW |