summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/render_view.cc17
-rw-r--r--chrome/renderer/render_view.h2
-rw-r--r--webkit/glue/webkit_constants.h22
-rw-r--r--webkit/glue/webkit_glue.gypi1
-rw-r--r--webkit/glue/webpreferences.cc4
-rw-r--r--webkit/support/webkit_support.cc6
-rw-r--r--webkit/support/webkit_support.h4
7 files changed, 52 insertions, 4 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 4357721..48a3f62 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -185,6 +185,7 @@
#include "webkit/glue/site_isolation_metrics.h"
#include "webkit/glue/webaccessibility.h"
#include "webkit/glue/webdropdata.h"
+#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webmediaplayer_impl.h"
#include "webkit/plugins/npapi/default_plugin_shared.h"
@@ -5370,29 +5371,41 @@ void RenderView::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) {
FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event));
}
-#if defined(OS_MACOSX)
void RenderView::OnWasHidden() {
RenderWidget::OnWasHidden();
+ if (webview()) {
+ webview()->settings()->setMinimumTimerInterval(
+ webkit_glue::kBackgroundTabTimerInterval);
+ }
+
+#if defined(OS_MACOSX)
// Inform plugins that their container is no longer visible.
std::set<WebPluginDelegateProxy*>::iterator plugin_it;
for (plugin_it = plugin_delegates_.begin();
plugin_it != plugin_delegates_.end(); ++plugin_it) {
(*plugin_it)->SetContainerVisibility(false);
}
+#endif // OS_MACOSX
}
void RenderView::OnWasRestored(bool needs_repainting) {
RenderWidget::OnWasRestored(needs_repainting);
+ if (webview()) {
+ webview()->settings()->setMinimumTimerInterval(
+ webkit_glue::kForegroundTabTimerInterval);
+ }
+
+#if defined(OS_MACOSX)
// Inform plugins that their container is now visible.
std::set<WebPluginDelegateProxy*>::iterator plugin_it;
for (plugin_it = plugin_delegates_.begin();
plugin_it != plugin_delegates_.end(); ++plugin_it) {
(*plugin_it)->SetContainerVisibility(true);
}
-}
#endif // OS_MACOSX
+}
void RenderView::OnSetFocus(bool enable) {
RenderWidget::OnSetFocus(enable);
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 7944059..d16012c 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -652,10 +652,8 @@ class RenderView : public RenderWidget,
virtual void DidHandleKeyEvent();
virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
virtual void OnSetFocus(bool enable);
-#if OS_MACOSX
virtual void OnWasHidden();
virtual void OnWasRestored(bool needs_repainting);
-#endif
private:
// For unit tests.
diff --git a/webkit/glue/webkit_constants.h b/webkit/glue/webkit_constants.h
new file mode 100644
index 0000000..54e7e00
--- /dev/null
+++ b/webkit/glue/webkit_constants.h
@@ -0,0 +1,22 @@
+// 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.
+
+#ifndef WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
+#define WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
+
+namespace webkit_glue {
+
+// Chromium sets the minimum interval timeout to 4ms, overriding the
+// default of 10ms. We'd like to go lower, however there are poorly
+// coded websites out there which do create CPU-spinning loops. Using
+// 4ms prevents the CPU from spinning too busily and provides a balance
+// between CPU spinning and the smallest possible interval timer.
+const double kForegroundTabTimerInterval = 0.004;
+
+// Provides control over the minimum timer interval for background tabs.
+const double kBackgroundTabTimerInterval = 0.004;
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEBKIT_CONSTANTS_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 7060ed2..c3bb964 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -422,6 +422,7 @@
'webdropdata.h',
'webfileutilities_impl.cc',
'webfileutilities_impl.h',
+ 'webkit_constants.h',
'webkit_glue.cc',
'webkit_glue.h',
'webkitclient_impl.cc',
diff --git a/webkit/glue/webpreferences.cc b/webkit/glue/webpreferences.cc
index 03c87bf..86c40f6 100644
--- a/webkit/glue/webpreferences.cc
+++ b/webkit/glue/webpreferences.cc
@@ -12,6 +12,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebRuntimeFeatures;
@@ -197,4 +198,7 @@ void WebPreferences::Apply(WebView* web_view) const {
settings->setInteractiveFormValidationEnabled(
interactive_form_validation_enabled);
+
+ // Tabs start out hidden and are made visible.
+ settings->setMinimumTimerInterval(webkit_glue::kBackgroundTabTimerInterval);
}
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 2e893f9..9e850f4 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -37,6 +37,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
#include "webkit/glue/media/video_renderer_impl.h"
+#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h"
#include "webkit/glue/webmediaplayer_impl.h"
@@ -548,4 +549,9 @@ void OpenFileSystem(WebFrame* frame, WebFileSystem::Type type,
fileSystem->OpenFileSystem(frame, type, size, create, callbacks);
}
+// Timers
+double GetForegroundTabTimerInterval() {
+ return webkit_glue::kForegroundTabTimerInterval;
+}
+
} // namespace webkit_support
diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h
index 30cb885..d145955 100644
--- a/webkit/support/webkit_support.h
+++ b/webkit/support/webkit_support.h
@@ -182,6 +182,10 @@ enum {
VKEY_F1 = ui::VKEY_F1,
};
+// - Timers
+
+double GetForegroundTabTimerInterval();
+
} // namespace webkit_support
#endif // WEBKIT_SUPPORT_WEBIT_CLIENT_IMPL_H_