New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 754136 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Sep 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

big padding should push float elements on a new line

Reported by kdub...@mozilla.com, Aug 10 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:57.0) Gecko/20100101 Firefox/57.0

Steps to reproduce the problem:
1. With Chrome and a window 360px wide (to emulate a mobile viewport) or with chrome on Android
2. Go to https://m.disneystore.com/disney/store/products/filter?Ntt=disney+animators+collection
3. Click on Products.
4. With Firefox Nightly, do the same steps, side by side

This is a spin-off of https://webcompat.com/issues/5604

What is the expected behavior?
The layout should be the same in both browsers.

What went wrong?
The defined CSS looks like this

.subcategoryContents.container_0 a.subcategoryLink {
    padding: 10px 242px 10px 0px;
}

see the big right padding of 242px doesn't give space to the number (floated element) on the right side:

* On Firefox, the floated element is pushed to a new line
* On Chrome, the floated element stays in place and the right side of the box becomes 0px.

You can see this effect clearly when putting a visible outline around the boxes and changing the value for the padding. Some screenshots in 
https://webcompat.com/issues/5604#issuecomment-321180454

The behavior in Firefox seems to be legit and is implemented as-is in Edge too. 

Daniel Holbert provided a reduced test case
 https://jsfiddle.net/doy5okmz/

HTML:

<div class="container">
  <span class="padded">
      a
      <span class="float">Float

CSS:

.container {
  width: 300px;
  border: 3px solid black;
}
.padded {
  padding-right: 260px;
  border: 2px dotted lime;
}
.float {
  float: right;
  width: 50px;
  border: 2px dotted red;
}

Did this work before? N/A 

Chrome version: <Copy from: 'about:version'>  Channel: n/a
OS Version: OS X 10.12
Flash Version: 

The CSS specification might need to be clarified.
https://www.w3.org/TR/CSS22/visuren.html#float-position
 

Comment 1 by foolip@chromium.org, Aug 10 2017

Components: -UI Blink>Layout
Came here from https://github.com/webcompat/web-bugs/issues/5604, putting it into layout team triage.

Comment 2 Deleted

Comment 3 by dholb...@gmail.com, Aug 10 2017

The specific relevant spec text (which I think Chrome is violating here) is:
 
> Here are the precise rules that govern the behavior of floats:
> [...]
>  8. A floating box must be placed as high as possible.
https://www.w3.org/TR/CSS22/visuren.html#float-position

"As high as possible" is a bit hand-wavy here, but I think it *at least* means that a float shouldn't intersect the padding box of in-flow content that comes before it -- it needs to be pushed down to avoid such overlap.

Here's a version of the jsfiddle testcase linked above, but with a background added to the in-flow element: https://jsfiddle.net/doy5okmz/2/
Here, in Chrome, the float is partially obstructed (it's underneath the other element's background) -- it's hard to imagine that this obstruction is correct "as high as possible" placement. The Firefox/Edge behavior (with the float pushed to the next line) makes more sense, I think.

Comment 4 by robho...@gmail.com, Aug 13 2017

Owner: robho...@gmail.com
Status: Assigned (was: Unconfirmed)
In the test case the padding doesn't come before the float, it comes after it. It is padding on the float's inline parent:

<div class="container">
  <span class="padded">
    a
    <span class="float">Float</span>
  </span>
</div>

So at first it seems counter-intuitive to take it into account. But the padding isn't applied to the float but to the inline boxes generated by the span so we do have to treat the padding as though it has already been applied to the float's previous sibling when we decide whether the float fits or not.




Project Member

Comment 5 by bugdroid1@chromium.org, Aug 26 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1b587acb3f69f120e85e2bc667927cafc353fc6e

commit 1b587acb3f69f120e85e2bc667927cafc353fc6e
Author: Robert Hogan <robhogan@gmail.com>
Date: Sat Aug 26 12:08:47 2017

Include end-padding, -border etc. when deciding if float can fit on a line

Bug:  754136 
Change-Id: I52ad9adf3d8607bf22944c952137ec32c200e331
Reviewed-on: https://chromium-review.googlesource.com/612356
Commit-Queue: Robert Hogan <robhogan@gmail.com>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497661}
[add] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/fast/block/float-avoids-padding-inline-ancestors-expected.txt
[add] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/fast/block/float-avoids-padding-inline-ancestors.html
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/forms/suggestion-picker/month-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/forms/suggestion-picker/time-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.10/fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.11/fast/forms/suggestion-picker/date-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.9/fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.9/fast/forms/suggestion-picker/date-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.9/fast/forms/suggestion-picker/time-suggestion-picker-appearance-locale-hebrew-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.9/fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-mac10.9/fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-retina/fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac-retina/fast/forms/suggestion-picker/date-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac/fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/mac/fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/LayoutTests/platform/win7/fast/forms/suggestion-picker/month-suggestion-picker-appearance-with-scroll-bar-expected.png
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/Source/core/html/forms/resources/suggestionPicker.js
[modify] https://crrev.com/1b587acb3f69f120e85e2bc667927cafc353fc6e/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Comment 6 by robho...@gmail.com, Sep 26 2017

Status: Fixed (was: Assigned)

Sign in to add a comment