Closed Bug 138142 Opened 23 years ago Closed 21 years ago

property margin not recognized if property display dynamically set

Categories

(Core :: Layout: Block and Inline, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dietmar.rabich, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(2 files)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.9) Gecko/20020311 BuildID: 2002031104 Look at this source: <html> <head> <style type="text/css"> #a, #b { display: none; } </style> <script> <!-- function chg(id) { var el = document.getElementById(id) el.style.display = (el.style.display == '' || el.style.display == 'none') ? 'block' : 'none' } //--> </script> </head> <body> <p><span onClick="chg('a')">A</span> <span onClick="chg('b')">B</span></p> <div> <p id="a">Example A</p> <p id="b">Example B</p> </div> </body> </html> If the document is shown, you see first only "A" and "B". Click on "A", you see "Example A", click on "B", you see "Example B". Between "Example A" and "Example B" is a distance (from margin). Reload the document. Do the same as before, but first "B", then "A". There is no distancs between "Example A" and "Example B". If you omit the tags <div> and </div> everything works fine. Reproducible: Always Steps to Reproduce: 1. If the document ist shown, you see first only "A" and "B". Click on "A", you see "Example A", click on "B", you see "Example B". Between "Example A" and "Example B" is a distance (from margin). 2. Reload the document. 3. Do the same as before, but first "B", then "A". There is no distancs between "Example A" and "Example B". Actual Results: See description and the reproduce steps. Expected Results: Same behaviour without consideration of the order of clicking.
Component: XP Apps → Style System
Attached file The testcase
To layout. Seeing this on current linux too.
Assignee: sgehani → attinasi
Status: UNCONFIRMED → NEW
Component: Style System → Layout
Ever confirmed: true
OS: Windows NT → All
QA Contact: paw → petersen
Hardware: PC → All
Changing QA contact
QA Contact: petersen → amar
Adding the testcase keyword and setting the priority.
Keywords: testcase
Priority: -- → P3
Target Milestone: --- → Future
The bug shows up just as well when changing node.className to apply different rules. The bug most likely occurs when changing the display property of an element which should have a margin below it other than because its containing element has a bottom margin. You don't need two elements to show the problem. The nastiest side effect is that page coordinates used for a DOM update may be invalidated during processing the update if margination is corrected.
A testcase with one dynamic element: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Gecko Top Margin Error</title> <script type="text/javascript"> function display(id,value) { var node; node=document.getElementById(id); node.style.display=value; return false; } </script> </head> <body> <div> [Before container division #c] </div> <div id=c> <p id=a style="display: none;"> a paragraph #a </p> </div> <div> [After container division #c] </div> <blockquote> Click <a href="#" onclick='return display("a","block")'>display=block</a> to show #a.<br> Click <a href="#" onclick='return display("a","none")'>display="none"</a> to hide #a.<br> Resize the page after each click to correct margins.<br> </blockquote> </body> </html>
I believe I know what the bug is (now). Description: margins around elements switched using CSS display property values of "block" and "none" are incorrectly calculated under particular circumstances when performing DOM updates from script. Platforms: all (Win98,WinXP,linux tested) Browsers: Netscape, Gnome Galion, Mozilla (1.3a tested) Algorithmic error: dynamic update code only searches amoungst siblings of the switched node to find elements which supply, or are ancestors of elements which supply, preceding element margin-bottom and following element margin-top values. If the switched node's parent is not a common ancestor of the elements sought, update code will proceed with substituted or unaltered values - the screen and DOM then reflect bad element positions until the next layout.
.
Assignee: attinasi → block-and-inline
Component: Layout → Layout: Block & Inline
Priority: P3 → --
QA Contact: amar → ian
Target Milestone: Future → ---
Attached file Another test case
Click on the buttons to show/hide a content for the items in the list. The "content" has a bottom margin which doesn't show (and hide) until one doesn't push the "Show/Hide" for the next item in the list.
Fixed by checkin for bug 257612
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Depends on: 257612
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: