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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "wtf/MathExtras.h" | 46 #include "wtf/MathExtras.h" |
47 #include "wtf/text/WTFString.h" | 47 #include "wtf/text/WTFString.h" |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& info) | 51 void V8HTMLCanvasElement::getContextMethodCustom(const v8::FunctionCallbackInfo<
v8::Value>& info) |
52 { | 52 { |
53 v8::Handle<v8::Object> holder = info.Holder(); | 53 v8::Handle<v8::Object> holder = info.Holder(); |
54 v8::Isolate* isolate = info.GetIsolate(); | 54 v8::Isolate* isolate = info.GetIsolate(); |
55 HTMLCanvasElement* impl = V8HTMLCanvasElement::toNative(holder); | 55 HTMLCanvasElement* impl = V8HTMLCanvasElement::toNative(holder); |
56 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, contextIdResource,
info[0]); | 56 V8STRINGRESOURCE_PREPARE_VOID(V8StringResource<>, contextIdResource, info[0]
); |
57 String contextId = contextIdResource; | 57 String contextId = contextIdResource; |
58 RefPtr<CanvasContextAttributes> attributes; | 58 RefPtr<CanvasContextAttributes> attributes; |
59 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId =
= "webkit-3d") { | 59 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId =
= "webkit-3d") { |
60 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes:
:create(); | 60 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes:
:create(); |
61 if (info.Length() > 1 && info[1]->IsObject()) { | 61 if (info.Length() > 1 && info[1]->IsObject()) { |
62 v8::Handle<v8::Object> jsAttributes = info[1]->ToObject(); | 62 v8::Handle<v8::Object> jsAttributes = info[1]->ToObject(); |
63 v8::Handle<v8::String> alpha = v8AtomicString(isolate, "alpha"); | 63 v8::Handle<v8::String> alpha = v8AtomicString(isolate, "alpha"); |
64 if (jsAttributes->Has(alpha)) | 64 if (jsAttributes->Has(alpha)) |
65 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue
()); | 65 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue
()); |
66 v8::Handle<v8::String> depth = v8AtomicString(isolate, "depth"); | 66 v8::Handle<v8::String> depth = v8AtomicString(isolate, "depth"); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 ASSERT_NOT_REACHED(); | 129 ASSERT_NOT_REACHED(); |
130 v8SetReturnValueNull(info); | 130 v8SetReturnValueNull(info); |
131 } | 131 } |
132 | 132 |
133 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& info) | 133 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& info) |
134 { | 134 { |
135 v8::Handle<v8::Object> holder = info.Holder(); | 135 v8::Handle<v8::Object> holder = info.Holder(); |
136 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); | 136 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); |
137 ExceptionState exceptionState(ExceptionState::ExecutionContext, "toDataURL",
"HTMLCanvasElement", info.Holder(), info.GetIsolate()); | 137 ExceptionState exceptionState(ExceptionState::ExecutionContext, "toDataURL",
"HTMLCanvasElement", info.Holder(), info.GetIsolate()); |
138 | 138 |
139 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); | 139 V8STRINGRESOURCE_PREPARE_VOID(V8StringResource<>, type, info[0]); |
140 double quality; | 140 double quality; |
141 double* qualityPtr = 0; | 141 double* qualityPtr = 0; |
142 if (info.Length() > 1 && info[1]->IsNumber()) { | 142 if (info.Length() > 1 && info[1]->IsNumber()) { |
143 quality = info[1]->NumberValue(); | 143 quality = info[1]->NumberValue(); |
144 qualityPtr = &quality; | 144 qualityPtr = &quality; |
145 } | 145 } |
146 | 146 |
147 String result = canvas->toDataURL(type, qualityPtr, exceptionState); | 147 String result = canvas->toDataURL(type, qualityPtr, exceptionState); |
148 exceptionState.throwIfNeeded(); | 148 exceptionState.throwIfNeeded(); |
149 v8SetReturnValueStringOrUndefined(info, result, info.GetIsolate()); | 149 v8SetReturnValueStringOrUndefined(info, result, info.GetIsolate()); |
150 } | 150 } |
151 | 151 |
152 } // namespace WebCore | 152 } // namespace WebCore |
OLD | NEW |