Last Comment Bug 197065 - bad display of a background image in a block with "position: absolute" when dynamically changing the height of this block
: bad display of a background image in a block with "position: absolute" when d...
Status: RESOLVED FIXED
[fix]
:
Product: Core
Classification: Components
Component: Layout: View Rendering (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Robert O'Callahan (:roc) (email my personal email if necessary)
: Hixie (not reading bugmail)
: Jet Villegas (:jet)
Mentors:
http://jacquetc.free.fr/mozilla/bug1/
: 199812 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-12 09:11 PST by Christophe Jacquet
Modified: 2003-04-05 13:29 PST (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Proposed patch (10.47 KB, patch)
2003-03-19 20:25 PST, Robert O'Callahan (:roc) (email my personal email if necessary)
john: review+
dbaron: superreview+
Details | Diff | Splinter Review

Description Christophe Jacquet 2003-03-12 09:11:05 PST
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030311
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030311

I have a block with "position: absolute" and a background image aligned to the
bottom right corner. When I decrease the height of this block (by collapsing one
of its child blocks through dynamic modification of CSS in Javascript), and then
give it its original size, its background does not get repainted correctly. A
part of the background image appears twice on the screen.

Reproducible: Always

Steps to Reproduce:
1. Load http://jacquetc.free.fr/mozilla/bug1/
2. Click once on "Collapse/Expand" (to collapse the green block)
3. Click another time on "Collapse/Expand" (to re-expand the green block)

Actual Results:  
The background image of the bounding (blue-bordered) box has not been repainted
correctly. The image painted when the block was collapsed remains on the screen.
Thus, the word "RIGHT" appears twice on the screen.

The problem appears on the screenshot at
http://jacquetc.free.fr/mozilla/bug1/screenshot.png

Expected Results:  
The whole background of the bounding box should be repainted, and not only the
part that has grown. The display should be the same as after loading the page.
In particular, the word "RIGHT" should apear only once.

Actually, when I drag the window around or force it to be refreshed by any
means, it gets repainted correctly. So I think that the internal layout of the
page is OK, but a repaint should be triggered upon expansion of the block.

Look at the HTML code for more details. I think that the interesting CSS
properties of the bounding block are the following:
  background-repeat: no-repeat;
  background-image: url("testmoz.png");
  background-position: right bottom;
  position: absolute;

The problem does not arise when I delete the "position: absolute" atrribute.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2003-03-12 11:54:19 PST
Confirmed on current linux trunk.
Comment 2 Chris Casciano 2003-03-12 16:27:07 PST
-> all/all (seeing this on OS X 1.3RC build)
Comment 3 Zibi Braniecki [:gandalf][:zibi] 2003-03-12 19:22:10 PST
Confirming Moz 1.3RC Windows
Comment 4 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-19 20:25:30 PST
Created attachment 117809 [details] [diff] [review]
Proposed patch

proposed fix.

This changes the behavior of the CheckInvalidate function. We're now more
explicit about what it does (see the comment). And we take care of some cases
that the function was missing.

I removed the reflow command checks from the function. I don't see why it's
necessary to detect a style change; the style change hints for the changed
property (e.g., 'border') should take care of any invalidation.
Comment 5 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-19 20:29:26 PST
Comment on attachment 117809 [details] [diff] [review]
Proposed patch

I think jkeiser created this function.
Comment 6 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-19 20:31:05 PST
Note that the patch isn't 'optimal'; there are lots of ways we could reduce
invalidation by checking more style information or by invalidating smaller
areas. But I'm unconvinced that such optimization is necessary.
Comment 7 John Keiser (jkeiser) 2003-03-20 17:32:23 PST
Comment on attachment 117809 [details] [diff] [review]
Proposed patch

This is certainly a lot simpler and more readable, so as long as it doesn't
regress pageload time I'm fine with it.
Comment 8 John Keiser (jkeiser) 2003-03-20 17:37:13 PST
Comment on attachment 117809 [details] [diff] [review]
Proposed patch

Hmm, what about backgrounds that tile?	And non-percent backgrounds that are
aligneed at the bottom right?  I don't see how this will fix all the background
problems.
Comment 9 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-20 18:03:01 PST
> And non-percent backgrounds that are aligneed at the bottom right?

They get translated to percentages in the style system, as far as I can tell.

> what about backgrounds that tile?

Any part of the background that falls outside the difference between the old and
new frame areas will be repainted by the caller. That's what the contract for
CheckInvalidateSizeChange says. We only have to worry about the case where
changing the frame size requires the entire background to be repainted.
Comment 10 David Baron :dbaron: ⌚️UTC-10 2003-03-25 08:22:20 PST
Does this handle things like the case where we used to have borders, but don't
anymore?
Comment 11 David Baron :dbaron: ⌚️UTC-10 2003-03-25 08:23:24 PST
Comment on attachment 117809 [details] [diff] [review]
Proposed patch

(Or is that handled by the style change system, which makes a border change a
reflow *and* repaint?)	Anyway, sr=dbaron if you think there's a good answer to
my question.
Comment 12 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-25 08:34:38 PST
Yes. Style changes to the borders and background and so on are handled by the
style system hinting (which should force a VISUAL change, meaning full repaint
of the frame). All this patch is for is size changes where the actual styles
didn't change.
Comment 13 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-03-29 16:48:41 PST
*** Bug 199812 has been marked as a duplicate of this bug. ***
Comment 14 Robert O'Callahan (:roc) (email my personal email if necessary) 2003-04-05 13:29:18 PST
Checked in.

Note You need to log in before you can comment on or make changes to this bug.