diff options
author | Cary Clark <cary@android.com> | 2010-08-24 10:52:43 -0400 |
---|---|---|
committer | Cary Clark <cary@android.com> | 2010-08-24 15:33:14 -0400 |
commit | 016ea440f1b61a966483fc809a078dd28b784e46 (patch) | |
tree | 07052cb749cb1352f7b27e13a17cd7f4f6244463 | |
parent | c570a147a94b126d4172c30914f53dea17b4c8f5 (diff) | |
download | external_webkit-016ea440f1b61a966483fc809a078dd28b784e46.zip external_webkit-016ea440f1b61a966483fc809a078dd28b784e46.tar.gz external_webkit-016ea440f1b61a966483fc809a078dd28b784e46.tar.bz2 |
communicate drawing pause to webkit to pause gif animation
Gif frames continue even if the webkit changes aren't drawn.
When we suspend drawing, suspend the gif animation as well.
This is accomplished by fooling webkit into thinking the
browser window is offscreen. When the webkit drawing is
resumed, invalidate the entire content so the gif animations
start up once more.
requires companion change in frameworks/base
Change-Id: I78846214048b038cd8d0401dad103d451cd5a269
http://b/2621902
-rw-r--r-- | WebCore/platform/ScrollView.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/android/ScrollViewAndroid.cpp | 8 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 26 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 |
4 files changed, 37 insertions, 1 deletions
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp index 615ae5d..927a9fc 100644 --- a/WebCore/platform/ScrollView.cpp +++ b/WebCore/platform/ScrollView.cpp @@ -1088,7 +1088,6 @@ void ScrollView::platformOffscreenContentRectangle(const IntRect& ) { } #endif -#endif bool ScrollView::platformIsOffscreen() const { @@ -1096,6 +1095,7 @@ bool ScrollView::platformIsOffscreen() const } #endif +#endif } diff --git a/WebCore/platform/android/ScrollViewAndroid.cpp b/WebCore/platform/android/ScrollViewAndroid.cpp index dec3183..aefa64a 100644 --- a/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/WebCore/platform/android/ScrollViewAndroid.cpp @@ -141,4 +141,12 @@ void ScrollView::platformOffscreenContentRectangle(const IntRect& vis, const Int } #endif +bool ScrollView::platformIsOffscreen() const +{ + /* other platforms override platformIsOffscreen when the browser + window is no longer on screen. We override it to prevent gif + animations from queuing up subsequent frames during dragging. */ + return android::WebViewCore::getWebViewCore(this)->drawIsPaused(); +} + } // namespace WebCore diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 3b4872f..e81e335 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -210,6 +210,7 @@ struct WebViewCoreFields { jfieldID m_viewportUserScalable; jfieldID m_viewportDensityDpi; jfieldID m_webView; + jfieldID m_drawIsPaused; } gWebViewCoreFields; // ---------------------------------------------------------------------------- @@ -918,6 +919,13 @@ void WebViewCore::contentInvalidate(const WebCore::IntRect &r) contentDraw(); } +void WebViewCore::contentInvalidateAll() +{ + WebCore::FrameView* view = m_mainFrame->view(); + contentInvalidate(WebCore::IntRect(0, 0, + view->contentsWidth(), view->contentsHeight())); +} + void WebViewCore::offInvalidate(const WebCore::IntRect &r) { // FIXME: these invalidates are offscreen, and can be throttled or @@ -2858,6 +2866,13 @@ void WebViewCore::notifyWebAppCanBeInstalled() checkException(env); } +bool WebViewCore::drawIsPaused() const +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + return env->GetBooleanField(m_javaGlue->object(env).get(), + gWebViewCoreFields.m_drawIsPaused); +} + //---------------------------------------------------------------------- // Native JNI methods //---------------------------------------------------------------------- @@ -2952,6 +2967,11 @@ static void Click(JNIEnv *env, jobject obj, int framePtr, int nodePtr) reinterpret_cast<WebCore::Node*>(nodePtr)); } +static void ContentInvalidateAll(JNIEnv *env, jobject obj) +{ + GET_NATIVE_VIEW(env, obj)->contentInvalidateAll(); +} + static void DeleteSelection(JNIEnv *env, jobject obj, jint start, jint end, jint textGeneration) { @@ -3512,6 +3532,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) Key }, { "nativeClick", "(II)V", (void*) Click }, + { "nativeContentInvalidateAll", "()V", + (void*) ContentInvalidateAll }, { "nativeSendListBoxChoices", "([ZI)V", (void*) SendListBoxChoices }, { "nativeSendListBoxChoice", "(I)V", @@ -3639,6 +3661,10 @@ int register_webviewcore(JNIEnv* env) "mWebView", "Landroid/webkit/WebView;"); LOG_ASSERT(gWebViewCoreFields.m_webView, "Unable to find android/webkit/WebViewCore.mWebView"); + gWebViewCoreFields.m_drawIsPaused = env->GetFieldID(widget, + "mDrawIsPaused", "Z"); + LOG_ASSERT(gWebViewCoreFields.m_drawIsPaused, + "Unable to find android/webkit/WebViewCore.mDrawIsPaused"); return jniRegisterNativeMethods(env, "android/webkit/WebViewCore", gJavaWebViewCoreMethods, NELEM(gJavaWebViewCoreMethods)); diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 11a7228..89cdc8a 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -131,6 +131,7 @@ namespace android { * Record the invalid rectangle */ void contentInvalidate(const WebCore::IntRect &rect); + void contentInvalidateAll(); /** * Satisfy any outstanding invalidates, so that the current state @@ -494,6 +495,7 @@ namespace android { WTF::Vector<Container> m_buttons; bool isPaused() const { return m_isPaused; } void setIsPaused(bool isPaused) { m_isPaused = isPaused; } + bool drawIsPaused() const; // end of shared members // internal functions |