Title: [148300] trunk/Source
Revision
148300
Author
timothy_hor...@apple.com
Date
2013-04-12 13:17:00 -0700 (Fri, 12 Apr 2013)

Log Message

REGRESSION (r138858): GIFs don't start playing when they come out of background tabs
https://bugs.webkit.org/show_bug.cgi?id=108864
<rdar://problem/13140489>

Reviewed by Antti Koivisto.

Don't repaint the world when animations resume; instead, FrameView
will cause all animated images to repaint. This line also had no effect for
TiledCoreAnimationDrawingArea, which does not implement setNeedsDisplay.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::resumeActiveDOMObjectsAndAnimations):

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::resumeAnimatingImagesForLoader): Added.
Iterate through all of the loader's cached resources. If they are bitmap images
which claim to be animatable, notify the image's observers that the animation advanced
by one frame. In reality, the image is still on the same frame, but will now be repainted,
restarting the animation loop.
* loader/cache/CachedImage.h:
* page/FrameView.cpp:
(WebCore::FrameView::setIsInWindow):
When the FrameView is brought into a window, repaint all animated images.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::canAnimate): Added. 
Return whether or not the image should animate (claims to animate, has not already
finished its animation, and has an ImageObserver) *and* has more than one frame.
* platform/graphics/BitmapImage.h:
(BitmapImage): Add canAnimate.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148299 => 148300)


--- trunk/Source/WebCore/ChangeLog	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/ChangeLog	2013-04-12 20:17:00 UTC (rev 148300)
@@ -1,3 +1,28 @@
+2013-04-12  Tim Horton  <timothy_hor...@apple.com>
+
+        REGRESSION (r138858): GIFs don't start playing when they come out of background tabs
+        https://bugs.webkit.org/show_bug.cgi?id=108864
+        <rdar://problem/13140489>
+
+        Reviewed by Antti Koivisto.
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::resumeAnimatingImagesForLoader): Added.
+        Iterate through all of the loader's cached resources. If they are bitmap images
+        which claim to be animatable, notify the image's observers that the animation advanced
+        by one frame. In reality, the image is still on the same frame, but will now be repainted,
+        restarting the animation loop.
+        * loader/cache/CachedImage.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setIsInWindow):
+        When the FrameView is brought into a window, repaint all animated images.
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::canAnimate): Added. 
+        Return whether or not the image should animate (claims to animate, has not already
+        finished its animation, and has an ImageObserver) *and* has more than one frame.
+        * platform/graphics/BitmapImage.h:
+        (BitmapImage): Add canAnimate.
+
 2013-04-12  Martin Robinson  <mrobin...@igalia.com>
 
         r148197 broke the GTK+ build

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (148299 => 148300)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2013-04-12 20:17:00 UTC (rev 148300)
@@ -475,6 +475,27 @@
     notifyObservers(&rect);
 }
 
+void CachedImage::resumeAnimatingImagesForLoader(CachedResourceLoader* loader)
+{
+    const CachedResourceLoader::DocumentResourceMap& resources = loader->allCachedResources();
+
+    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = resources.begin(), end = resources.end(); it != end; ++it) {
+        const CachedResourceHandle<CachedResource>& resource = it->value;
+        if (!resource || !resource->isImage())
+            continue;
+        CachedImage* cachedImage = static_cast<CachedImage*>(resource.get());
+        if (!cachedImage->hasImage())
+            continue;
+        Image* image = cachedImage->image();
+        if (!image->isBitmapImage())
+            continue;
+        BitmapImage* bitmapImage = static_cast<BitmapImage*>(image);
+        if (!bitmapImage->canAnimate())
+            continue;
+        cachedImage->animationAdvanced(bitmapImage);
+    }
+}
+
 void CachedImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResourceImage);

Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (148299 => 148300)


--- trunk/Source/WebCore/loader/cache/CachedImage.h	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h	2013-04-12 20:17:00 UTC (rev 148300)
@@ -96,6 +96,8 @@
 
     virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
 
+    static void resumeAnimatingImagesForLoader(CachedResourceLoader*);
+
 private:
     void clear();
 

Modified: trunk/Source/WebCore/page/FrameView.cpp (148299 => 148300)


--- trunk/Source/WebCore/page/FrameView.cpp	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/page/FrameView.cpp	2013-04-12 20:17:00 UTC (rev 148300)
@@ -29,6 +29,7 @@
 
 #include "AXObjectCache.h"
 #include "BackForwardController.h"
+#include "CachedImage.h"
 #include "CachedResourceLoader.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
@@ -1060,6 +1061,13 @@
 {
     if (RenderView* renderView = this->renderView())
         renderView->setIsInWindow(isInWindow);
+
+    if (isInWindow) {
+        // Drawing models which cache painted content while out-of-window (WebKit2's composited drawing areas, etc.)
+        // require that we repaint animated images to kickstart the animation loop.
+
+        CachedImage::resumeAnimatingImagesForLoader(frame()->document()->cachedResourceLoader());
+    }
 }
 
 RenderObject* FrameView::layoutRoot(bool onlyDuringLayout) const

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (148299 => 148300)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2013-04-12 20:17:00 UTC (rev 148300)
@@ -573,6 +573,11 @@
 {
     return m_solidColor;
 }
+    
+bool BitmapImage::canAnimate()
+{
+    return shouldAnimate() && frameCount() > 1;
+}
 
 void BitmapImage::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (148299 => 148300)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2013-04-12 20:17:00 UTC (rev 148300)
@@ -184,6 +184,8 @@
 #endif
 
     void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+    
+    bool canAnimate();
 
 private:
     void updateSize() const;

Modified: trunk/Source/WebKit2/ChangeLog (148299 => 148300)


--- trunk/Source/WebKit2/ChangeLog	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebKit2/ChangeLog	2013-04-12 20:17:00 UTC (rev 148300)
@@ -1,3 +1,18 @@
+2013-04-12  Tim Horton  <timothy_hor...@apple.com>
+
+        REGRESSION (r138858): GIFs don't start playing when they come out of background tabs
+        https://bugs.webkit.org/show_bug.cgi?id=108864
+        <rdar://problem/13140489>
+
+        Reviewed by Antti Koivisto.
+
+        Don't repaint the world when animations resume; instead, FrameView
+        will cause all animated images to repaint. This line also had no effect for
+        TiledCoreAnimationDrawingArea, which does not implement setNeedsDisplay.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::resumeActiveDOMObjectsAndAnimations):
+
 2013-04-12  Alexey Proskuryakov  <a...@apple.com>
 
         <rdar://problem/13334446> [Mac] Tweak sandbox profile.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (148299 => 148300)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-12 20:10:30 UTC (rev 148299)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-04-12 20:17:00 UTC (rev 148300)
@@ -2053,9 +2053,6 @@
 void WebPage::resumeActiveDOMObjectsAndAnimations()
 {
     m_page->resumeActiveDOMObjectsAndAnimations();
-
-    // We need to repaint on resume to kickstart animated painting again.
-    m_drawingArea->setNeedsDisplay();
 }
 
 IntPoint WebPage::screenToWindow(const IntPoint& point)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to