Bug 67162 - Applying a scale transform to an <img> doesn't repaint properly
Summary: Applying a scale transform to an <img> doesn't repaint properly
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tom Zakrajsek
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-08-29 16:10 PDT by Matthew Delaney
Modified: 2014-10-31 20:27 PDT (History)
4 users (show)

See Also:


Attachments
testcase (33.56 KB, application/zip)
2011-08-29 16:10 PDT, Matthew Delaney
no flags Details
Standalone testcase (323 bytes, text/html)
2011-08-29 16:57 PDT, Simon Fraser (smfr)
no flags Details
Patch (111.98 KB, patch)
2011-12-22 11:31 PST, Tom Zakrajsek
no flags Details | Formatted Diff | Diff
Patch (111.85 KB, patch)
2011-12-22 11:39 PST, Tom Zakrajsek
no flags Details | Formatted Diff | Diff
Patch (112.49 KB, patch)
2011-12-22 12:11 PST, Tom Zakrajsek
tomz: review-
tomz: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Delaney 2011-08-29 16:10:11 PDT
Created attachment 105538 [details]
testcase

This affects both Safari and Chrome on Lion - didn't test other OSes.

Attaching a test case that shows the issue. It appears that the dirty rect after the transform is applied is of the initial (smaller) size of the img before the scale.
Comment 1 Radar WebKit Bug Importer 2011-08-29 16:10:23 PDT
<rdar://problem/10042548>
Comment 2 Simon Fraser (smfr) 2011-08-29 16:57:12 PDT
Created attachment 105546 [details]
Standalone testcase
Comment 3 Tom Zakrajsek 2011-12-22 11:31:46 PST
Created attachment 120350 [details]
Patch
Comment 4 Simon Fraser (smfr) 2011-12-22 11:34:33 PST
Comment on attachment 120350 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=120350&action=review

> Source/WebCore/ChangeLog:8
> +        Reviewed by NOBODY (OOPS!).
> +
> +        Test: fast/repaint/bugzilla-67162.html

This needs to say what you changed and why. Your change looks pretty mysterious to me.
Comment 5 Tom Zakrajsek 2011-12-22 11:39:47 PST
Created attachment 120351 [details]
Patch
Comment 6 Simon Fraser (smfr) 2011-12-22 11:41:25 PST
Comment on attachment 120351 [details]
Patch

Still needs a better changelog with an explanation of the change (which doens't look right to me).
Comment 7 Tom Zakrajsek 2011-12-22 12:11:23 PST
Created attachment 120359 [details]
Patch
Comment 8 Julien Chaffraix 2011-12-28 00:29:39 PST
Comment on attachment 120359 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=120359&action=review

It looks like any transform removal could potentially show the same badness. Am I mistaking or do you think it would be possible possible to add some tests with different transforms?

> Source/WebCore/rendering/LayoutRepainter.cpp:40
> +        m_oldBounds = oldBounds ? *oldBounds : IntRect(0, 0, 0, 0);

I second Simon. This code is used by everything (not only when a transform changes) and this looks like it could impact more than just your case.

> LayoutTests/ChangeLog:10
> +        * fast/repaint/bugzilla-67162-expected.png: Added.
> +        * fast/repaint/bugzilla-67162-expected.txt: Added.
> +        * fast/repaint/bugzilla-67162.html: Added.

Nit: we prefer naming that reflects what you test like transform-scale-up.html.

> LayoutTests/fast/repaint/bugzilla-67162.html:19
> +<img src="../repaint/resources/webkit-background.png" style="-webkit-transform: scale(0.25); -moz-transform: scale(0.25); -o-transform: scale(0.25)" id="img">

Looks like the |src| path could be shortened here. It could be resources/webkit-background.png. Also any reason you don't re-use resources/apple.jpg?
Comment 9 Tom Zakrajsek 2012-01-03 15:07:31 PST
(In reply to comment #8)
> (From update of attachment 120359 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=120359&action=review
> 
> It looks like any transform removal could potentially show the same badness. Am I mistaking or do you think it would be possible possible to add some tests with different transforms?
I agree.  And, I can add tests for those too.
> 
> > Source/WebCore/rendering/LayoutRepainter.cpp:40
> > +        m_oldBounds = oldBounds ? *oldBounds : IntRect(0, 0, 0, 0);
> 
> I second Simon. This code is used by everything (not only when a transform changes) and this looks like it could impact more than just your case.
The problem appears to be that LayoutRepainter and RenderObject are each holding state for what they believe was the previously drawn rectangle (oldBounds), as interpreted by RenderObject::repaintAfterLayoutIfNeeded, and they are not in sync.  I'll continue to look for a fix.
> 
> > LayoutTests/ChangeLog:10
> > +        * fast/repaint/bugzilla-67162-expected.png: Added.
> > +        * fast/repaint/bugzilla-67162-expected.txt: Added.
> > +        * fast/repaint/bugzilla-67162.html: Added.
> 
> Nit: we prefer naming that reflects what you test like transform-scale-up.html.
OK.
> 
> > LayoutTests/fast/repaint/bugzilla-67162.html:19
> > +<img src="../repaint/resources/webkit-background.png" style="-webkit-transform: scale(0.25); -moz-transform: scale(0.25); -o-transform: scale(0.25)" id="img">
> 
> Looks like the |src| path could be shortened here. It could be resources/webkit-background.png. Also any reason you don't re-use resources/apple.jpg?
Yeah, the path was a mistake added because at first I accidentally had this test living in .../replace instead of .../repaint. And I hadn't seen the apple.jpg.  I can certainly use that.
Comment 10 Simon Fraser (smfr) 2014-10-31 20:27:11 PDT
This no longer reproduces in Safari 8.