Bug 15869

Summary: misalignment because of float:left of <div> tag
Product: WebKit Reporter: Anantha Keesara <anantha>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mitz, webkit
Priority: P2 Keywords: HasReduction
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://rc.9you.com/info_car_01.html
Attachments:
Description Flags
reduced testcase
none
screenshot
none
reduced test case #2
none
Use computed width for float avoidance and unify the rules across parsing modes simon.fraser: review+

Description Anantha Keesara 2007-11-06 21:10:16 PST
I .Steps:
-----------
1. Go to: http://rc.9you.com/info_car_01.html

II. Issue:
-----------------
Notice that the contents are outside of the frame. See the screenshot.

III. Other browsers:
--------------------
Only IE gets it right. safari webkit version: 27433
Comment 1 Anantha Keesara 2007-11-06 21:11:31 PST
Created attachment 17082 [details]
reduced testcase
Comment 2 Anantha Keesara 2007-11-06 21:12:21 PST
Created attachment 17083 [details]
screenshot
Comment 3 Robert Blaut 2008-03-04 23:52:14 PST
Created attachment 19544 [details]
reduced test case #2

This test case is pretty interesting if you run it in Gecko. Setting 2px border in Gecko imply proper table positioning :D. The first example is incorrectly rendered. Webkit r30780 fails in both cases.  The latter shows incorrect overflow table outside a parent DIV. Presto (Opera 9.50) correctly displays both cases.

Definitely bug.
Comment 4 Robert Blaut 2008-03-04 23:53:42 PST
This is Live DOM Viewer version of the test case #2
Comment 6 mitz 2008-03-05 00:06:33 PST
This is one of two or three bugs about this quirk. See RenderBlock.cpp:2820.
Comment 7 Robert Blaut 2008-03-05 00:31:39 PST
(In reply to comment #6)
> This is one of two or three bugs about this quirk. See RenderBlock.cpp:2820.
> 

But reduced test case #2 is in strict mode (CSS1Compat) and the issue is still visible. 
Comment 8 mitz 2008-03-05 11:51:36 PST
Yup, there also seems to be an exception for percent-width objects, while on the other hand table widths are computed as if tables always clear floats.
Comment 9 mitz 2009-08-13 12:51:17 PDT
Created attachment 34774 [details]
Use computed width for float avoidance and unify the rules across parsing modes

This appears to match Firefox and IE8 with the exceptions that in Firefox, <hr>s just overflow instead of clearing the float, and in IE, the <hr>’s percent sizes are computed relative to the available width next to the float (so 100% or less never needs to clear the float).
Comment 10 Darin Adler 2009-08-13 13:37:34 PDT
Comment on attachment 34774 [details]
Use computed width for float avoidance and unify the rules across parsing modes

> +        (WebCore::RenderBlock::getClearDelta): Changed to apply the same float
> +            avoisame logic in strict mode and in compatibility mode, which

avoisame -> avoidance

> -    // Do not allow tables to wrap in quirks or even in almost strict mode 
> -    // (ebay on the PLT, finance.yahoo.com in the real world, versiontracker.com forces even almost strict mode not to work)

Did you try these test sites?

>      int result = clearSet ? max(0, bottom - yPos) : 0;
> -    if (!result && child->avoidsFloats() && child->style()->width().isFixed() && 
> -        child->minPrefWidth() > lineWidth(yPos, false) && child->minPrefWidth() <= availableWidth() && 
> -        document()->inStrictMode())   
> -        result = max(0, floatBottom() - yPos);
> +    if (!result && child->avoidsFloats()) {
> +        int oldYPos = child->y();
> +        int oldWidth = child->width();
> +        child->setY(yPos);
> +        child->calcWidth();
> +        if (child->width() > lineWidth(yPos, false) && child->minPrefWidth() <= availableWidth())
> +            result = max(0, floatBottom() - yPos);
> +        child->setY(oldYPos);
> +        child->setWidth(oldWidth);
> +    }

I'd love to say r=me, but this may be a little out of my league. Probably needs a Hyatt review or some other layout expert.
Comment 11 Simon Fraser (smfr) 2009-08-13 13:41:46 PDT
Comment on attachment 34774 [details]
Use computed width for float avoidance and unify the rules across parsing modes

> Index: WebCore/ChangeLog
> ===================================================================

> +        * rendering/RenderBlock.cpp:
> +        (WebCore::RenderBlock::getClearDelta): Changed to apply the same float
> +            avoisame logic in strict mode and in compatibility mode, which

Avoidance?
Comment 12 mitz 2009-08-13 17:35:29 PDT
(In reply to comment #10)
 
> > -    // Do not allow tables to wrap in quirks or even in almost strict mode 
> > -    // (ebay on the PLT, finance.yahoo.com in the real world, versiontracker.com forces even almost strict mode not to work)
> 
> Did you try these test sites?

VersionTracker and Yahoo! Finance in their current form appear to be unaffected by the change. The version of ebay on the PLT is affected, and with the change it looks like it looks in Firefox 3.5. The current version of ebay is unaffected as far as I can tell.
Comment 13 mitz 2009-08-13 17:41:36 PDT
Fixed in <http://trac.webkit.org/projects/webkit/changeset/47255>.