Bug 12114 - Clearing a float with an element that floats causes problem with next float in the opposite direction
Summary: Clearing a float with an element that floats causes problem with next float i...
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Major
Assignee: Dave Hyatt
URL: http://level39.com/clearing-bug/
Keywords: HasReduction
Depends on:
Blocks: 9610
  Show dependency treegraph
 
Reported: 2007-01-04 13:33 PST by Dan Richman
Modified: 2007-03-15 07:29 PDT (History)
1 user (show)

See Also:


Attachments
Test case of the clearing bug. (1.20 KB, text/html)
2007-01-04 13:36 PST, Dan Richman
no flags Details
Patch that does left/right y-computations separately. (5.15 KB, patch)
2007-01-04 14:41 PST, Dave Hyatt
aroben: review+
Details | Formatted Diff | Diff
Patch that backs out this behavior and reverts to old behavior (while keeping code cleanup) (2.54 KB, patch)
2007-01-05 13:08 PST, Dave Hyatt
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Richman 2007-01-04 13:33:43 PST
If you have an element set to float:right; and you follow it with another element set to clear:right; float:right; and then follow those first two elements with a third element set to float:left; the third element will not float next to the first element, even though it is not being cleared.

This bug is also present when the float directions are reversed from the example described above.
Comment 1 Dan Richman 2007-01-04 13:36:15 PST
Created attachment 12224 [details]
Test case of the clearing bug.
Comment 2 Dan Richman 2007-01-04 13:39:47 PST
See the following link for a more real-world example of this bug:

http://level39.com/clearing-bug/layout.html
Comment 3 Dave Hyatt 2007-01-04 14:41:46 PST
Created attachment 12229 [details]
Patch that does left/right y-computations separately.

This patch makes sure the "don't go above the previous float" rule treats left and right separately.
Comment 4 Adam Roben (:aroben) 2007-01-04 14:48:29 PST
Comment on attachment 12229 [details]
Patch that does left/right y-computations separately.

+    FloatingObject* lastFloat = f;

   Might as well initialize this to f->prev() to save an unnecessary pass through the while loop.

   r=me
Comment 5 Dave Hyatt 2007-01-04 15:14:39 PST
Fixed.
Comment 6 L. David Baron 2007-01-05 07:40:36 PST
This bug is invalid.  The previous behavior was correct.  CSS2 9.5.1 rule 5 says:

The outer top of a floating box may not be higher than the outer top of any block or floated box generated by an element earlier in the source document.

(Below the rules, it says:
References to other elements in these rules refer only to other elements in the same block formatting context as the float.)

http://www.w3.org/TR/CSS21/visuren.html#float-position
Comment 7 Dan Richman 2007-01-05 09:04:54 PST
Can we get clarification on this?
Comment 8 Dave Hyatt 2007-01-05 12:45:53 PST
Yeah, rule 5 is clear.  I missed that.  This bug was invalid.  Will attach a new patch that backs out the behavior but retains the code cleanup.
Comment 9 Dave Hyatt 2007-01-05 12:46:52 PST
For what it's worth, I do like the behavior I just implemented.  Too bad it doesn't match the spec. :(
Comment 10 Dave Hyatt 2007-01-05 13:08:32 PST
Created attachment 12246 [details]
Patch that backs out this behavior and reverts to old behavior (while keeping code cleanup)
Comment 11 mitz 2007-01-05 13:11:30 PST
Comment on attachment 12246 [details]
Patch that backs out this behavior and reverts to old behavior (while keeping code cleanup)

r=me
Comment 12 Dave Hyatt 2007-01-05 13:14:19 PST
Ok fixed.