Bug 114879 - Incorrect computation of shrink-to-fit width for block with white-space:nowrap and floating children
Summary: Incorrect computation of shrink-to-fit width for block with white-space:nowra...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Robert Hogan
URL:
Keywords:
Depends on: 117824
Blocks:
  Show dependency treegraph
 
Reported: 2013-04-19 09:56 PDT by Boris Zbarsky
Modified: 2013-06-20 01:03 PDT (History)
7 users (show)

See Also:


Attachments
Testcase (322 bytes, text/html)
2013-04-19 09:56 PDT, Boris Zbarsky
no flags Details
Patch (5.46 KB, patch)
2013-05-06 14:25 PDT, Robert Hogan
no flags Details | Formatted Diff | Diff
Patch (22.07 KB, patch)
2013-05-27 13:01 PDT, Robert Hogan
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2 (1.33 MB, application/zip)
2013-05-27 16:33 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-07 for mac-mountainlion (4.95 MB, application/zip)
2013-05-29 00:28 PDT, Build Bot
no flags Details
Patch (46.40 KB, patch)
2013-06-17 12:15 PDT, Robert Hogan
no flags Details | Formatted Diff | Diff
Patch (46.40 KB, patch)
2013-06-17 12:24 PDT, Robert Hogan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Zbarsky 2013-04-19 09:56:54 PDT
Created attachment 198894 [details]
Testcase

Consider the attached testcase.

The width of the first green box should be the minimum width as defined at http://www.w3.org/TR/CSS21/visudet.html#shrink-to-fit-float which means it should be the width if all allowed line-breaks are taken.

The second green box shows that a line-break between the two floats is in fact allowed, if it's needed.

So the first green box should end up with a width of 16px and the two floats in it should stack on top of each other.  But in WebKit they end up next to each other.

Gecko, Trident, Presto get this right as far as I can tell.

Note that removing the "white-space:nowrap" makes WebKit behave correctly, which is odd, since white-space does not affect float positioning...
Comment 1 Robert Hogan 2013-05-06 14:25:31 PDT
Created attachment 200814 [details]
Patch
Comment 2 Dave Hyatt 2013-05-20 12:49:24 PDT
Comment on attachment 200814 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=200814&action=review

r-

> Source/WebCore/rendering/RenderBlock.cpp:5812
> +    bool shrinkToFit = (!isReplaced() && isFloatingOrOutOfFlowPositioned()) || (isInlineBlockOrInlineTable() && !isTable());
> +    if (!style()->autoWrap() && !shrinkToFit && childrenInline()) {

Why special case shrinkToFit? If I'm understanding the bug correctly, it's that we should ignore nowrap completely when computing min intrinsic sizes. Anyway, you'd want to use something like:

RenderBox::sizesLogicalWidthToFitContent

to really catch all the shrink to fit cases, but I'm not convinced that it's correct to do so. It sounds like minimum width is supposed to ignore white-space if I'm understanding this correctly. You'll want to double check and see if tables behave properly if we make that change though.
Comment 3 Boris Zbarsky 2013-05-20 13:11:51 PDT
nowrap is most certainly supposed to affect intrinsic sizes.

What it's not supposed to affect is whether floats can clear past each other and the effect of such floats on intrinsic sizes.
Comment 4 Dave Hyatt 2013-05-20 13:38:43 PDT
This is a float bug. You are always allowed to break before or after a float, so need to just patch the code to handle that. It looks like the code sort of incorrectly tried to handle it but then forgot to set inlineMin to 0.
Comment 5 Robert Hogan 2013-05-27 13:01:54 PDT
Created attachment 203005 [details]
Patch
Comment 6 Build Bot 2013-05-27 16:33:04 PDT
Comment on attachment 203005 [details]
Patch

Attachment 203005 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/749008

New failing tests:
fast/replaced/width100percent-image.html
fast/replaced/width100percent-textarea.html
tables/mozilla/bugs/bug57828.html
fast/replaced/width100percent-textfield.html
fast/replaced/width100percent-menulist.html
fast/css/word-space-extra.html
fast/replaced/width100percent-searchfield.html
Comment 7 Build Bot 2013-05-27 16:33:05 PDT
Created attachment 203016 [details]
Archive of layout-test-results from webkit-ews-09 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-09  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.3
Comment 8 Build Bot 2013-05-29 00:28:27 PDT
Comment on attachment 203005 [details]
Patch

Attachment 203005 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/693239

New failing tests:
fast/replaced/width100percent-image.html
fast/replaced/width100percent-textarea.html
tables/mozilla/bugs/bug57828.html
fast/replaced/width100percent-textfield.html
fast/replaced/width100percent-menulist.html
fast/css/word-space-extra.html
fast/replaced/width100percent-searchfield.html
Comment 9 Build Bot 2013-05-29 00:28:29 PDT
Created attachment 203130 [details]
Archive of layout-test-results from webkit-ews-07 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-07  Port: mac-mountainlion  Platform: Mac OS X 10.8.3
Comment 10 Robert Hogan 2013-06-17 12:15:10 PDT
Created attachment 204847 [details]
Patch
Comment 11 Robert Hogan 2013-06-17 12:24:00 PDT
Created attachment 204848 [details]
Patch
Comment 12 Dave Hyatt 2013-06-18 13:05:20 PDT
Comment on attachment 204848 [details]
Patch

Looks good. Glad to see that line go, since it's bogus.
Comment 13 Dave Hyatt 2013-06-18 13:21:11 PDT
Comment on attachment 204848 [details]
Patch

r=me
Comment 14 WebKit Commit Bot 2013-06-19 10:21:09 PDT
Comment on attachment 204848 [details]
Patch

Clearing flags on attachment: 204848

Committed r151737: <http://trac.webkit.org/changeset/151737>
Comment 15 WebKit Commit Bot 2013-06-19 10:21:12 PDT
All reviewed patches have been landed.  Closing bug.