Bug 139528

Summary: Image animation is not always stopped if used as background-image of a div that is outside viewport
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Layout and RenderingAssignee: Chris Dumez <cdumez>
Status: RESOLVED INVALID    
Severity: Normal CC: esprehn+autocc, glenn, kling, koivisto, kondapallykalyan, ossy, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 139435    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Chris Dumez 2014-12-10 21:28:57 PST
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.
Comment 1 Chris Dumez 2014-12-10 21:36:59 PST
Created attachment 243098 [details]
Patch
Comment 2 Chris Dumez 2014-12-10 22:01:31 PST
Created attachment 243103 [details]
Patch
Comment 3 Chris Dumez 2014-12-10 22:06:53 PST
Created attachment 243104 [details]
Patch
Comment 4 Chris Dumez 2014-12-10 23:46:25 PST
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 5 Simon Fraser (smfr) 2014-12-11 10:20:53 PST
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 6 Chris Dumez 2014-12-11 10:23:39 PST
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.