Image animation is not always stopped if used as background-image of a div that is outside viewport. In particular, the animation is not stopped if the div has content overflowing *inside* the viewport (even though the animated gif is not visible, only the overflowing content is). This is because shouldRepaintForImageAnimation() relies on the renderer's overflow rect instead of its bounding box to determine if it is inside viewport.
Created attachment 243098 [details] Patch
Created attachment 243103 [details] Patch
Created attachment 243104 [details] Patch
I regressed this in http://trac.webkit.org/changeset/176212 when refactoring the code to detect if we're inside viewport to be shared between animated images and DOM Timer throttling.
Comment on attachment 243104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=243104&action=review > Source/WebCore/rendering/RenderElement.cpp:1371 > + LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect(&renderer.view()) : renderer.absoluteBoundingBoxRect(); But doesn't this regress the reflection case, and possibly others?
Comment on attachment 243104 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=243104&action=review >> Source/WebCore/rendering/RenderElement.cpp:1371 >> + LayoutRect backgroundPaintingRect = backgroundIsPaintedByRoot ? renderer.view().backgroundRect(&renderer.view()) : renderer.absoluteBoundingBoxRect(); > > But doesn't this regress the reflection case, and possibly others? Hmm, I will have to check. It is indeed possible. If so, it is better to be conservative and use the overflow rect.