summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 23:34:50 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 23:34:50 +0000
commit5f8b102b5fafc489ba7044a11748c4194ad2b3ec (patch)
treec9aa1cf1eae89373a4f74abc9e1f7d6e98ec99bc /webkit/tools/test_shell
parentcef99efc12e7fabf12ebfbc0c67fa8322eee8351 (diff)
downloadchromium_src-5f8b102b5fafc489ba7044a11748c4194ad2b3ec.zip
chromium_src-5f8b102b5fafc489ba7044a11748c4194ad2b3ec.tar.gz
chromium_src-5f8b102b5fafc489ba7044a11748c4194ad2b3ec.tar.bz2
Chromium support for window.webkitRequestAnimationFrame()
This is a very simple scheduler that targets 100fps. BUG=64848 TEST=layout tests Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=71909 Review URL: http://codereview.chromium.org/6136005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r--webkit/tools/test_shell/mac/webwidget_host.mm5
-rw-r--r--webkit/tools/test_shell/test_shell.gypi1
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc5
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h1
-rw-r--r--webkit/tools/test_shell/webwidget_host.cc12
-rw-r--r--webkit/tools/test_shell/webwidget_host.h5
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc5
-rw-r--r--webkit/tools/test_shell/webwidget_host_win.cc5
8 files changed, 36 insertions, 3 deletions
diff --git a/webkit/tools/test_shell/mac/webwidget_host.mm b/webkit/tools/test_shell/mac/webwidget_host.mm
index d02b943..f5944dd 100644
--- a/webkit/tools/test_shell/mac/webwidget_host.mm
+++ b/webkit/tools/test_shell/mac/webwidget_host.mm
@@ -149,7 +149,8 @@ WebWidgetHost::WebWidgetHost()
: view_(NULL),
webwidget_(NULL),
scroll_dx_(0),
- scroll_dy_(0) {
+ scroll_dy_(0),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
set_painting(false);
}
@@ -183,6 +184,8 @@ void WebWidgetHost::Paint() {
[NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context
flipped:YES]];
+ webwidget_->animate();
+
// This may result in more invalidation
webwidget_->layout();
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 9a6e7a7..c50ca5b 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -112,6 +112,7 @@
'webview_host_gtk.cc',
'webview_host_win.cc',
'webwidget_host.h',
+ 'webwidget_host.cc',
'webwidget_host_gtk.cc',
'webwidget_host_win.cc',
],
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index f16b9aa..9ca127a 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -685,6 +685,11 @@ void TestWebViewDelegate::scheduleComposite() {
host->ScheduleComposite();
}
+void TestWebViewDelegate::scheduleAnimation() {
+ if (WebWidgetHost* host = GetWidgetHost())
+ host->ScheduleAnimation();
+}
+
void TestWebViewDelegate::didFocus() {
if (WebWidgetHost* host = GetWidgetHost())
shell_->SetFocus(host, true);
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index cd23c90..14b12ca 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -151,6 +151,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient,
virtual void didScrollRect(int dx, int dy,
const WebKit::WebRect& clip_rect);
virtual void scheduleComposite();
+ virtual void scheduleAnimation();
virtual void didFocus();
virtual void didBlur();
virtual void didChangeCursor(const WebKit::WebCursorInfo& cursor);
diff --git a/webkit/tools/test_shell/webwidget_host.cc b/webkit/tools/test_shell/webwidget_host.cc
new file mode 100644
index 0000000..59cf80b
--- /dev/null
+++ b/webkit/tools/test_shell/webwidget_host.cc
@@ -0,0 +1,12 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/tools/test_shell/webwidget_host.h"
+
+#include "base/message_loop.h"
+
+void WebWidgetHost::ScheduleAnimation() {
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ factory_.NewRunnableMethod(&WebWidgetHost::ScheduleComposite), 10);
+}
diff --git a/webkit/tools/test_shell/webwidget_host.h b/webkit/tools/test_shell/webwidget_host.h
index c344b24..02b2669 100644
--- a/webkit/tools/test_shell/webwidget_host.h
+++ b/webkit/tools/test_shell/webwidget_host.h
@@ -6,6 +6,7 @@
#define WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_
#include "base/basictypes.h"
+#include "base/task.h"
#include "base/scoped_ptr.h"
#include "gfx/native_widget_types.h"
#include "gfx/rect.h"
@@ -48,6 +49,7 @@ class WebWidgetHost {
void DidInvalidateRect(const gfx::Rect& rect);
void DidScrollRect(int dx, int dy, const gfx::Rect& clip_rect);
void ScheduleComposite();
+ void ScheduleAnimation();
#if defined(OS_WIN)
void SetCursor(HCURSOR cursor);
#endif
@@ -149,6 +151,9 @@ class WebWidgetHost {
#ifndef NDEBUG
bool painting_;
#endif
+
+ private:
+ ScopedRunnableMethodFactory<WebWidgetHost> factory_;
};
#endif // WEBKIT_TOOLS_TEST_SHELL_WEBWIDGET_HOST_H_
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index 3cd91af..bab38b3 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -327,7 +327,8 @@ WebWidgetHost::WebWidgetHost()
: view_(NULL),
webwidget_(NULL),
scroll_dx_(0),
- scroll_dy_(0) {
+ scroll_dy_(0),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
set_painting(false);
}
@@ -364,6 +365,8 @@ void WebWidgetHost::Paint() {
}
}
+ webwidget_->animate();
+
// This may result in more invalidation
webwidget_->layout();
diff --git a/webkit/tools/test_shell/webwidget_host_win.cc b/webkit/tools/test_shell/webwidget_host_win.cc
index fe3132a..4b49eaf 100644
--- a/webkit/tools/test_shell/webwidget_host_win.cc
+++ b/webkit/tools/test_shell/webwidget_host_win.cc
@@ -200,7 +200,8 @@ WebWidgetHost::WebWidgetHost()
webwidget_(NULL),
track_mouse_leave_(false),
scroll_dx_(0),
- scroll_dy_(0) {
+ scroll_dy_(0),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
set_painting(false);
}
@@ -242,6 +243,8 @@ void WebWidgetHost::Paint() {
paint_rect_.width(), paint_rect_.height(), true));
}
+ webwidget_->animate();
+
// This may result in more invalidation
webwidget_->layout();