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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 96743003: Fix JS interface for synthetic smooth scroll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 "chrome.gpuBenchmarking.smoothScrollBy = " 276 "chrome.gpuBenchmarking.smoothScrollBy = "
277 " function(pixels_to_scroll, opt_callback, opt_start_x," 277 " function(pixels_to_scroll, opt_callback, opt_start_x,"
278 " opt_start_y, opt_gesture_source_type," 278 " opt_start_y, opt_gesture_source_type,"
279 " opt_speed_in_pixels_s) {" 279 " opt_speed_in_pixels_s) {"
280 " pixels_to_scroll = pixels_to_scroll || 0;" 280 " pixels_to_scroll = pixels_to_scroll || 0;"
281 " callback = opt_callback || function() { };" 281 " callback = opt_callback || function() { };"
282 " gesture_source_type = opt_gesture_source_type ||" 282 " gesture_source_type = opt_gesture_source_type ||"
283 " chrome.gpuBenchmarking.DEFAULT_INPUT;" 283 " chrome.gpuBenchmarking.DEFAULT_INPUT;"
284 " speed_in_pixels_s = opt_speed_in_pixels_s || 800;" 284 " speed_in_pixels_s = opt_speed_in_pixels_s || 800;"
285 " native function BeginSmoothScroll();" 285 " native function BeginSmoothScroll();"
286 " if (typeof opt_mouse_event_x !== 'undefined' &&" 286 " if (typeof opt_start_x !== 'undefined' &&"
287 " typeof opt_mouse_event_y !== 'undefined') {" 287 " typeof opt_start_y !== 'undefined') {"
288 " return BeginSmoothScroll(pixels_to_scroll, callback," 288 " return BeginSmoothScroll(pixels_to_scroll, callback,"
289 " gesture_source_type, speed_in_pixels_s," 289 " gesture_source_type, speed_in_pixels_s,"
290 " opt_mouse_event_x, opt_mouse_event_y);" 290 " opt_start_x, opt_start_y);"
291 " } else {" 291 " } else {"
292 " return BeginSmoothScroll(pixels_to_scroll, callback," 292 " return BeginSmoothScroll(pixels_to_scroll, callback,"
293 " gesture_source_type," 293 " gesture_source_type,"
294 " speed_in_pixels_s);" 294 " speed_in_pixels_s);"
295 " }" 295 " }"
296 "};" 296 "};"
297 "chrome.gpuBenchmarking.smoothScrollBySendsTouch = function() {" 297 "chrome.gpuBenchmarking.smoothScrollBySendsTouch = function() {"
298 " native function SmoothScrollSendsTouch();" 298 " native function SmoothScrollSendsTouch();"
299 " return SmoothScrollSendsTouch();" 299 " return SmoothScrollSendsTouch();"
300 "};" 300 "};"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 args.GetReturnValue().Set(false); 470 args.GetReturnValue().Set(false);
471 #endif 471 #endif
472 } 472 }
473 473
474 static void BeginSmoothScroll( 474 static void BeginSmoothScroll(
475 const v8::FunctionCallbackInfo<v8::Value>& args) { 475 const v8::FunctionCallbackInfo<v8::Value>& args) {
476 GpuBenchmarkingContext context; 476 GpuBenchmarkingContext context;
477 if (!context.Init(false)) 477 if (!context.Init(false))
478 return; 478 return;
479 479
480 // Account for the 2 optional arguments, mouse_event_x and mouse_event_y. 480 // Account for the 2 optional arguments, start_x and start_y.
481 int arglen = args.Length(); 481 int arglen = args.Length();
482 if (arglen < 4 || 482 if (arglen < 4 ||
483 !args[0]->IsNumber() || 483 !args[0]->IsNumber() ||
484 !args[1]->IsFunction() || 484 !args[1]->IsFunction() ||
485 !args[2]->IsNumber() || 485 !args[2]->IsNumber() ||
486 !args[3]->IsNumber()) { 486 !args[3]->IsNumber()) {
487 args.GetReturnValue().Set(false); 487 args.GetReturnValue().Set(false);
488 return; 488 return;
489 } 489 }
490 490
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); 721 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel();
722 args.GetReturnValue().Set(!!gpu_channel); 722 args.GetReturnValue().Set(!!gpu_channel);
723 } 723 }
724 }; 724 };
725 725
726 v8::Extension* GpuBenchmarkingExtension::Get() { 726 v8::Extension* GpuBenchmarkingExtension::Get() {
727 return new GpuBenchmarkingWrapper(); 727 return new GpuBenchmarkingWrapper();
728 } 728 }
729 729
730 } // namespace content 730 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698