summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/features_override.gypi1
-rw-r--r--chrome/renderer/render_widget.cc32
-rw-r--r--chrome/renderer/render_widget.h5
-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
11 files changed, 71 insertions, 6 deletions
diff --git a/build/features_override.gypi b/build/features_override.gypi
index eb7c29d..c2430cf 100644
--- a/build/features_override.gypi
+++ b/build/features_override.gypi
@@ -39,6 +39,7 @@
'ENABLE_OPENTYPE_SANITIZER=1',
'ENABLE_ORIENTATION_EVENTS=0',
'ENABLE_PROGRESS_TAG=1',
+ 'ENABLE_REQUEST_ANIMATION_FRAME=1',
'ENABLE_RUBY=1',
'ENABLE_SANDBOX=1',
'ENABLE_SHARED_WORKERS=1',
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 9f73dc0..8fb1d55 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -76,7 +76,8 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread,
popup_type_(popup_type),
pending_window_rect_count_(0),
suppress_next_char_events_(false),
- is_accelerated_compositing_active_(false) {
+ is_accelerated_compositing_active_(false),
+ animation_update_pending_(false) {
RenderProcess::current()->AddRefProcess();
DCHECK(render_thread_);
}
@@ -486,9 +487,16 @@ void RenderWidget::CallDoDeferredUpdate() {
Send(pending_input_event_ack_.release());
}
+void RenderWidget::UpdateAnimationsIfNeeded() {
+ if (!is_hidden() && animation_update_pending_ &&
+ base::Time::Now() > animation_floor_time_) {
+ animation_update_pending_ = false;
+ webwidget_->animate();
+ }
+}
+
void RenderWidget::DoDeferredUpdate() {
- if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() ||
- update_reply_pending())
+ if (!webwidget_ || update_reply_pending())
return;
// Suppress updating when we are hidden.
@@ -498,11 +506,19 @@ void RenderWidget::DoDeferredUpdate() {
return;
}
+ if (base::Time::Now() > animation_floor_time_)
+ UpdateAnimationsIfNeeded();
+
// Layout may generate more invalidation. It may also enable the
// GPU acceleration, so make sure to run layout before we send the
// GpuRenderingActivated message.
webwidget_->layout();
+ // Suppress painting if nothing is dirty. This has to be done after updating
+ // animations running layout as these may generate further invalidations.
+ if (!paint_aggregator_.HasPendingUpdate())
+ return;
+
// OK, save the pending update to a local since painting may cause more
// invalidation. Some WebCore rendering objects only layout when painted.
PaintAggregator::PendingUpdate update;
@@ -684,6 +700,16 @@ void RenderWidget::scheduleComposite() {
didInvalidateRect(WebRect(0, 0, 1, 1));
}
+void RenderWidget::scheduleAnimation() {
+ if (!animation_update_pending_) {
+ animation_update_pending_ = true;
+ animation_floor_time_ =
+ base::Time::Now() + base::TimeDelta::FromMilliseconds(10);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
+ this, &RenderWidget::UpdateAnimationsIfNeeded), 10);
+ }
+}
+
void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
// TODO(darin): Eliminate this temporary.
WebCursor cursor(cursor_info);
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 71a065e..a76623f 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -102,6 +102,7 @@ class RenderWidget : public IPC::Channel::Listener,
virtual void didScrollRect(int dx, int dy, const WebKit::WebRect& clipRect);
virtual void didActivateAcceleratedCompositing(bool active);
virtual void scheduleComposite();
+ virtual void scheduleAnimation();
virtual void didFocus();
virtual void didBlur();
virtual void didChangeCursor(const WebKit::WebCursorInfo&);
@@ -159,6 +160,7 @@ class RenderWidget : public IPC::Channel::Listener,
void PaintDebugBorder(const gfx::Rect& rect, skia::PlatformCanvas* canvas);
void CallDoDeferredUpdate();
+ void UpdateAnimationsIfNeeded();
void DoDeferredUpdate();
void DoDeferredClose();
void DoDeferredSetWindowRect(const WebKit::WebRect& pos);
@@ -368,6 +370,9 @@ class RenderWidget : public IPC::Channel::Listener,
// compositor.
bool is_accelerated_compositing_active_;
+ base::Time animation_floor_time_;
+ bool animation_update_pending_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};
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();