[webkit-changes] [WebKit/WebKit] c80dcb: Elements with negative margins do not avoid floats...

Ahmad Saleem noreply at github.com
Sat Oct 29 05:18:05 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c80dcb41f40298f9d1251e3773cda13fe5f3c910
      https://github.com/WebKit/WebKit/commit/c80dcb41f40298f9d1251e3773cda13fe5f3c910
  Author: Ahmad Saleem <ahmad.saleem792+github at gmail.com>
  Date:   2022-10-29 (Sat, 29 Oct 2022)

  Changed paths:
    A LayoutTests/fast/block/float/avoid-floats-with-negative-margins-expected.html
    A LayoutTests/fast/block/float/avoid-floats-with-negative-margins.html
    M LayoutTests/platform/ios/fast/block/float/032-expected.txt
    M LayoutTests/platform/mac/fast/block/float/032-expected.png
    M LayoutTests/platform/mac/fast/block/float/032-expected.txt
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBlock.h
    M Source/WebCore/rendering/RenderBlockFlow.cpp

  Log Message:
  -----------
  Elements with negative margins do not avoid floats when appropriate

Elements with negative margins do not avoid floats when appropriate
https://bugs.webkit.org/show_bug.cgi?id=247076

Reviewed by Alan Baradlay.

Merge - https://src.chromium.org/viewvc/blink?view=revision&revision=180708

This is to align Webkit behavior with Blink / Chrome and Gecko / Firefox and web-specfication.

Web-Spec: https://www.w3.org/TR/CSS2/visuren.html#floats

"The border
box of a table, a block-level replaced element, or an element in the normal flow
that establishes a new block formatting context (such as an element with
'overflow' other than 'visible') must not overlap the margin box of any floats
in the same block formatting context as the element itself."

When an element is replaced or has an overflow clip it should avoid floats
even if a negative margin wants to pull it back onto the floats.
Simplify and correct the function that looks after this. We always want to
position the element after any floats so we always take the greater of the
border/padding + margin or the offset required to avoid floats. If there is
no offset required to avoid floats then it's ok to let the negative margin
pull the element back over the start edge of its containing block.

* Source/WebCore/rendering/RenderBlockFlow.cpp:
(RenderBlockFlow::marginOffForSelfCollapsingBlock): Following:
1) New variable "initialStartPosition" with "startPosition" value
2) Add new variable "positionToAvoidFloats"
3) Add logic for child with an offset from the content edge to avoid floats
* Source/WebCore/rendering/RenderBlock.cpp:
(RenderBlock::computeStartPositionDeltaForChildAvoidingFloats): Deleted
* Source/WebCore/rendering/RenderBlock.h: Remove "computeStartPositionDeltaForChildAvoidingFloats" reference
* LayoutTests/fast/block/float/avoid-floats-with-negative-margins.html: Added Test Case
* LayoutTests/fast/block/float/avoid-floats-with-negative-margins-expected.html: Added Test Case Expectations
* LayoutTests/platform/ios/fast/block/float/032-expected.txt: Updated Test Expectations
* LayoutTests/platform/mac/fast/block/float/032-expected.txt: Updated Test Expectations
* LayoutTests/platform/mac/fast/block/float/032-expected.png: Updated Test Expectations

Canonical link: https://commits.webkit.org/256132@main




More information about the webkit-changes mailing list