Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9b61fa3ef0eca16cc3fd40cb758c4f0739f49097
      
https://github.com/WebKit/WebKit/commit/9b61fa3ef0eca16cc3fd40cb758c4f0739f49097
  Author: Alan Baradlay <[email protected]>
  Date:   2026-04-27 (Mon, 27 Apr 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-001-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-001.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-ref.html
    M Source/WebCore/layout/floats/FloatAvoider.h

  Log Message:
  -----------
  Float with margin-start overlaps adjacent float
https://bugs.webkit.org/show_bug.cgi?id=313316

Reviewed by Antti Koivisto.

When a float has a non-zero start margin, FloatAvoider::inlineEnd() computes 
the wrong margin box edge.

Inline start's initial value is the border box start. In order to expand it to 
the margin box
we do inlineStart -= marginStart (correct). However when we compute inline end 
as
'inlineStart + borderBoxWidth + marginEnd' the start margin is gone now 
(incorrect).

For example, a left float with margin-left: 50px and width: 30px should have a
margin box spanning 0..80. But inlineEnd() returned 30 instead of 80 because it
went from margin-box-left (0) + border-box-width (30) + margin-end (0) = 30,
missing the 50px start margin.

This caused findAvailablePosition to think the float was much narrower than it
actually is, so it would not push the float below an adjacent float when the
margin box did not fit.

The fix is to use inlineStart() + marginBoxWidth() for floats, which correctly 
accounts for all margins.

* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-001-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-001.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-002.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-003.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-006.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-007.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-008.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-009.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-010.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-011.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/CSS2/floats/float-avoids-float-with-margin-ref.html:
 Added.
* Source/WebCore/layout/floats/FloatAvoider.h:
(WebCore::Layout::FloatAvoider::inlineEnd const):

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Canonical link: https://commits.webkit.org/312083@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to