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

Side by Side Diff: Source/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp

Issue 54283002: Rename |args| to |info| in V8 bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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) 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 29 matching lines...) Expand all
40 #include "core/html/HTMLCanvasElement.h" 40 #include "core/html/HTMLCanvasElement.h"
41 #include "core/html/canvas/Canvas2DContextAttributes.h" 41 #include "core/html/canvas/Canvas2DContextAttributes.h"
42 #include "core/html/canvas/CanvasRenderingContext.h" 42 #include "core/html/canvas/CanvasRenderingContext.h"
43 #include "core/html/canvas/WebGLContextAttributes.h" 43 #include "core/html/canvas/WebGLContextAttributes.h"
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>& info)
51 { 51 {
52 v8::Handle<v8::Object> holder = args.Holder(); 52 v8::Handle<v8::Object> holder = info.Holder();
53 HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(holder); 53 HTMLCanvasElement* imp = V8HTMLCanvasElement::toNative(holder);
54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, contextIdResource, args[0]); 54 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, contextIdResource, info[0]);
55 String contextId = contextIdResource; 55 String contextId = contextIdResource;
56 RefPtr<CanvasContextAttributes> attributes; 56 RefPtr<CanvasContextAttributes> attributes;
57 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId = = "webkit-3d") { 57 if (contextId == "webgl" || contextId == "experimental-webgl" || contextId = = "webkit-3d") {
58 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes: :create(); 58 RefPtr<WebGLContextAttributes> webGLAttributes = WebGLContextAttributes: :create();
59 if (args.Length() > 1 && args[1]->IsObject()) { 59 if (info.Length() > 1 && info[1]->IsObject()) {
60 v8::Handle<v8::Object> jsAttributes = args[1]->ToObject(); 60 v8::Handle<v8::Object> jsAttributes = info[1]->ToObject();
61 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); 61 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha");
62 if (jsAttributes->Has(alpha)) 62 if (jsAttributes->Has(alpha))
63 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue ()); 63 webGLAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanValue ());
64 v8::Handle<v8::String> depth = v8::String::NewSymbol("depth"); 64 v8::Handle<v8::String> depth = v8::String::NewSymbol("depth");
65 if (jsAttributes->Has(depth)) 65 if (jsAttributes->Has(depth))
66 webGLAttributes->setDepth(jsAttributes->Get(depth)->BooleanValue ()); 66 webGLAttributes->setDepth(jsAttributes->Get(depth)->BooleanValue ());
67 v8::Handle<v8::String> stencil = v8::String::NewSymbol("stencil"); 67 v8::Handle<v8::String> stencil = v8::String::NewSymbol("stencil");
68 if (jsAttributes->Has(stencil)) 68 if (jsAttributes->Has(stencil))
69 webGLAttributes->setStencil(jsAttributes->Get(stencil)->BooleanV alue()); 69 webGLAttributes->setStencil(jsAttributes->Get(stencil)->BooleanV alue());
70 v8::Handle<v8::String> antialias = v8::String::NewSymbol("antialias" ); 70 v8::Handle<v8::String> antialias = v8::String::NewSymbol("antialias" );
71 if (jsAttributes->Has(antialias)) 71 if (jsAttributes->Has(antialias))
72 webGLAttributes->setAntialias(jsAttributes->Get(antialias)->Bool eanValue()); 72 webGLAttributes->setAntialias(jsAttributes->Get(antialias)->Bool eanValue());
73 v8::Handle<v8::String> premultipliedAlpha = v8::String::NewSymbol("p remultipliedAlpha"); 73 v8::Handle<v8::String> premultipliedAlpha = v8::String::NewSymbol("p remultipliedAlpha");
74 if (jsAttributes->Has(premultipliedAlpha)) 74 if (jsAttributes->Has(premultipliedAlpha))
75 webGLAttributes->setPremultipliedAlpha(jsAttributes->Get(premult ipliedAlpha)->BooleanValue()); 75 webGLAttributes->setPremultipliedAlpha(jsAttributes->Get(premult ipliedAlpha)->BooleanValue());
76 v8::Handle<v8::String> preserveDrawingBuffer = v8::String::NewSymbol ("preserveDrawingBuffer"); 76 v8::Handle<v8::String> preserveDrawingBuffer = v8::String::NewSymbol ("preserveDrawingBuffer");
77 if (jsAttributes->Has(preserveDrawingBuffer)) 77 if (jsAttributes->Has(preserveDrawingBuffer))
78 webGLAttributes->setPreserveDrawingBuffer(jsAttributes->Get(pres erveDrawingBuffer)->BooleanValue()); 78 webGLAttributes->setPreserveDrawingBuffer(jsAttributes->Get(pres erveDrawingBuffer)->BooleanValue());
79 } 79 }
80 attributes = webGLAttributes; 80 attributes = webGLAttributes;
81 } else { 81 } else {
82 RefPtr<Canvas2DContextAttributes> canvas2DAttributes = Canvas2DContextAt tributes::create(); 82 RefPtr<Canvas2DContextAttributes> canvas2DAttributes = Canvas2DContextAt tributes::create();
83 if (args.Length() > 1 && args[1]->IsObject()) { 83 if (info.Length() > 1 && info[1]->IsObject()) {
84 v8::Handle<v8::Object> jsAttributes = args[1]->ToObject(); 84 v8::Handle<v8::Object> jsAttributes = info[1]->ToObject();
85 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha"); 85 v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha");
86 if (jsAttributes->Has(alpha)) 86 if (jsAttributes->Has(alpha))
87 canvas2DAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanVa lue()); 87 canvas2DAttributes->setAlpha(jsAttributes->Get(alpha)->BooleanVa lue());
88 } 88 }
89 attributes = canvas2DAttributes; 89 attributes = canvas2DAttributes;
90 } 90 }
91 CanvasRenderingContext* result = imp->getContext(contextId, attributes.get() ); 91 CanvasRenderingContext* result = imp->getContext(contextId, attributes.get() );
92 if (!result) { 92 if (!result) {
93 v8SetReturnValueNull(args); 93 v8SetReturnValueNull(info);
94 return; 94 return;
95 } 95 }
96 if (result->is2d()) { 96 if (result->is2d()) {
97 v8::Handle<v8::Value> v8Result = toV8(static_cast<CanvasRenderingContext 2D*>(result), args.Holder(), args.GetIsolate()); 97 v8::Handle<v8::Value> v8Result = toV8(static_cast<CanvasRenderingContext 2D*>(result), info.Holder(), info.GetIsolate());
98 if (InspectorInstrumentation::canvasAgentEnabled(&imp->document())) { 98 if (InspectorInstrumentation::canvasAgentEnabled(&imp->document())) {
99 ScriptState* scriptState = ScriptState::forContext(v8::Context::GetC urrent()); 99 ScriptState* scriptState = ScriptState::forContext(v8::Context::GetC urrent());
100 ScriptObject context(scriptState, v8::Handle<v8::Object>::Cast(v8Res ult)); 100 ScriptObject context(scriptState, v8::Handle<v8::Object>::Cast(v8Res ult));
101 ScriptObject wrapped = InspectorInstrumentation::wrapCanvas2DRenderi ngContextForInstrumentation(&imp->document(), context); 101 ScriptObject wrapped = InspectorInstrumentation::wrapCanvas2DRenderi ngContextForInstrumentation(&imp->document(), context);
102 if (!wrapped.hasNoValue()) { 102 if (!wrapped.hasNoValue()) {
103 v8SetReturnValue(args, wrapped.v8Value()); 103 v8SetReturnValue(info, wrapped.v8Value());
104 return; 104 return;
105 } 105 }
106 } 106 }
107 v8SetReturnValue(args, v8Result); 107 v8SetReturnValue(info, v8Result);
108 return; 108 return;
109 } 109 }
110 if (result->is3d()) { 110 if (result->is3d()) {
111 v8::Handle<v8::Value> v8Result = toV8(static_cast<WebGLRenderingContext* >(result), args.Holder(), args.GetIsolate()); 111 v8::Handle<v8::Value> v8Result = toV8(static_cast<WebGLRenderingContext* >(result), info.Holder(), info.GetIsolate());
112 if (InspectorInstrumentation::canvasAgentEnabled(&imp->document())) { 112 if (InspectorInstrumentation::canvasAgentEnabled(&imp->document())) {
113 ScriptState* scriptState = ScriptState::forContext(v8::Context::GetC urrent()); 113 ScriptState* scriptState = ScriptState::forContext(v8::Context::GetC urrent());
114 ScriptObject glContext(scriptState, v8::Handle<v8::Object>::Cast(v8R esult)); 114 ScriptObject glContext(scriptState, v8::Handle<v8::Object>::Cast(v8R esult));
115 ScriptObject wrapped = InspectorInstrumentation::wrapWebGLRenderingC ontextForInstrumentation(&imp->document(), glContext); 115 ScriptObject wrapped = InspectorInstrumentation::wrapWebGLRenderingC ontextForInstrumentation(&imp->document(), glContext);
116 if (!wrapped.hasNoValue()) { 116 if (!wrapped.hasNoValue()) {
117 v8SetReturnValue(args, wrapped.v8Value()); 117 v8SetReturnValue(info, wrapped.v8Value());
118 return; 118 return;
119 } 119 }
120 } 120 }
121 v8SetReturnValue(args, v8Result); 121 v8SetReturnValue(info, v8Result);
122 return; 122 return;
123 } 123 }
124 ASSERT_NOT_REACHED(); 124 ASSERT_NOT_REACHED();
125 v8SetReturnValueNull(args); 125 v8SetReturnValueNull(info);
126 } 126 }
127 127
128 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v 8::Value>& args) 128 void V8HTMLCanvasElement::toDataURLMethodCustom(const v8::FunctionCallbackInfo<v 8::Value>& info)
129 { 129 {
130 v8::Handle<v8::Object> holder = args.Holder(); 130 v8::Handle<v8::Object> holder = info.Holder();
131 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); 131 HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder);
132 ExceptionState es(args.GetIsolate()); 132 ExceptionState es(info.GetIsolate());
133 133
134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]); 134 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
135 double quality; 135 double quality;
136 double* qualityPtr = 0; 136 double* qualityPtr = 0;
137 if (args.Length() > 1 && args[1]->IsNumber()) { 137 if (info.Length() > 1 && info[1]->IsNumber()) {
138 quality = args[1]->NumberValue(); 138 quality = info[1]->NumberValue();
139 qualityPtr = &quality; 139 qualityPtr = &quality;
140 } 140 }
141 141
142 String result = canvas->toDataURL(type, qualityPtr, es); 142 String result = canvas->toDataURL(type, qualityPtr, es);
143 es.throwIfNeeded(); 143 es.throwIfNeeded();
144 v8SetReturnValueStringOrUndefined(args, result, args.GetIsolate()); 144 v8SetReturnValueStringOrUndefined(info, result, info.GetIsolate());
145 } 145 }
146 146
147 } // namespace WebCore 147 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp ('k') | Source/bindings/v8/custom/V8HTMLDocumentCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698