Bug 15994

Summary: REGRESSION: Incomplete repaint of CSS image substitution
Product: WebKit Reporter: Philip Timmermann <pepto>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: abarth, benjamin, eric, gsherloc, hamaji, hausmann, hyatt, jamesr, mitz, simon.fraser, webkit
Priority: P1 Keywords: HasReduction, Regression
Version: 523.x (Safari 3)   
Hardware: All   
OS: All   
URL: http://www.duema.de/haeuser/index.shtml
Attachments:
Description Flags
Reduction
none
Fix for the LayoutState-enabled code path
none
Reduction without LayoutState
none
Fix the issue
none
Patch and test abarth: review-

Description Philip Timmermann 2007-11-14 19:17:12 PST
This URL contains CSS image-substitution on hover in the navigation-bar on top of the page and on the images of houses further down the page (just check in any other browser to see how it should look)...

The hover-effect works correctly in virtually any browser: IE5 (even IE5:mac), IE6, IE7, Firefox 1+, Opera, Netscape 6+ (etc.) and Safari-versions before Safari 3...

The image-substitution basically works by changing the upper padding of a fixed size <a> (display:block) containing an <img>, on hover. This <a> has overflow:hidden properties, so by changing its upper padding, the contained image gets shifted into the hidden overflow-area, revealing an image below it (layering is done via negative margins)...

This might sound a little complicated for simple image-substitution, but avoids flicker in old IE versions, doesn't need preloading, is css-only and works in virtually any browser except for Safari 3...
Comment 1 Matt Lilek 2007-11-14 20:06:08 PST
The actual image substitution works, but it isn't repainted.  It seems to repaint the first link you hover over fine, but from there you need to force a repaint.
Comment 2 Matt Lilek 2007-11-14 21:02:56 PST
Created attachment 17286 [details]
Reduction

This is partly fixed in ToT from Safari 3, but is still a definite regression from Safari 2.

In Safari 2, both squares change to blue when hovered over.

In Safari 3.0.4 (Tiger), the green square changes to blue on hover, the red square never becomes blue unless a repaint is forced.

In ToT (r27761), the green square changes to blue on hover, as does the red square, but if you move the cursor from red square -> green square, the red square stays blue until a repaint is forced.
Comment 3 mitz 2007-11-15 10:51:19 PST
WebKit actually repaints the wrong rectangle because it applies a translated clip. The reason for that is that the repainting happens under a non-zero layoutDelta but clip computation ignores that. I have a one-line fix for the LayoutState code path - when pushing state and adding clipping, translate the additional clip by the current layout delta. But I don't know what to do in the non-LayoutState code path.
Comment 4 mitz 2007-11-15 11:38:21 PST
Created attachment 17299 [details]
Fix for the LayoutState-enabled code path
Comment 5 Darin Adler 2007-11-16 20:09:10 PST
Comment on attachment 17299 [details]
Fix for the LayoutState-enabled code path

r=me
Comment 6 mitz 2007-11-16 21:11:26 PST
Comment on attachment 17299 [details]
Fix for the LayoutState-enabled code path

Landed in r27869. Clearing the review flag.
Comment 7 Philip Timmermann 2007-11-17 14:19:08 PST
'just checked r27875... looks great to me...

thanks guys... looking forward to the next safari release-update...

Comment 8 Robert Blaut 2008-02-01 14:00:03 PST
The test case works fine. I suppose this bug is fixed, isn't it?
Comment 9 mitz 2008-02-01 14:05:58 PST
(In reply to comment #8)
> The test case works fine. I suppose this bug is fixed, isn't it?

Not completely.
Comment 10 Gavin Sherlock 2009-09-19 01:55:27 PDT
The test case seems to work correctly now (in r48518, and Safari 4.03), so maybe this can be closed?
Comment 11 Benjamin Poulain 2010-03-18 01:45:48 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > The test case works fine. I suppose this bug is fixed, isn't it?
> 
> Not completely.

What do you mean? What is missing?
Comment 12 mitz 2010-03-18 02:02:29 PDT
(In reply to comment #11)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > The test case works fine. I suppose this bug is fixed, isn't it?
> > 
> > Not completely.
> 
> What do you mean? What is missing?

At the time, what I meant was that the bug was still present in the unoptimized code path (where LayoutState is not used). I don’t know if that’s still the case—someone could make a version of the test that take the unoptimized code path in order to find out.
Comment 13 Benjamin Poulain 2010-03-18 08:24:11 PDT
Created attachment 51025 [details]
Reduction without LayoutState

> At the time, what I meant was that the bug was still present in the unoptimized
> code path (where LayoutState is not used). I don’t know if that’s still the
> case—someone could make a version of the test that take the unoptimized code
> path in order to find out.

You are right, the bug is still there for the unoptimized code path. I have attached a test case, I will try to have a look at the problem today.
Comment 14 Benjamin Poulain 2010-03-18 13:02:16 PDT
Created attachment 51080 [details]
Fix the issue

First attempt to fix the issue.

It think there is still a missing case. If I understand correctly, the layoutDelta is relative to the enclosing layer(?).
If in the slow path, but with a layer(), layoutDelta should be transformed before applied to the clipping rect.

Is that right?
Comment 15 Benjamin Poulain 2010-03-22 03:38:34 PDT
Created attachment 51272 [details]
Patch and test

Here is a patch that can be integrated.

I am surprised by the two little white rects on the expected image. Someone might know where they come from.
Comment 16 Simon Hausmann 2010-03-22 14:57:23 PDT
(In reply to comment #15)
> Created an attachment (id=51272) [details]
> Patch and test

You may want to skip the newly added test on the other platforms until they have pixel test results :)
Comment 17 Adam Barth 2010-05-13 00:22:58 PDT
This patch has been up for review for almost two months and Hyatt isn't even CCed.  According to my understanding, he's one of the few people on earth who can review repainting patches.
Comment 18 Adam Barth 2010-06-20 09:03:26 PDT
Comment on attachment 51272 [details]
Patch and test

I'm sorry to have to r- your patch.  In order to make changes like this the codebase, you need to socialize your change with folks who can review them.  In this case, there are only a handful of people who can (or are willing to) review repainting bugs, mostly because the code is subtle, fragile, and poorly tested.  If current trends continue, your patch will be up for review indefinitely, which is bad for the project.  Feel free to renominate your patch for review (or to post an updated patch) when you've found someone who is willing and able to review your patch.

Again, my apologies that you're running up against some of the brokenness in our review system.  Hopefully this won't discourage you from contributing more patches in the future.