Ignore:
Timestamp:
Apr 18, 2021, 11:13:38 PM (4 years ago)
Author:
[email protected]
Message:

Support contain: layout
https://bugs.webkit.org/show_bug.cgi?id=223569

Patch by Rob Buis <[email protected]> on 2021-04-18
Reviewed by Darin Adler.

Source/WebCore:

This patch implements layout containment as specified[1].
It adds shouldApplyLayoutContainment to check whether the
element applies for layout containment. Is so, then:

  • an independent formatting context is established.
  • any overflow is treated as ink overflow.
  • an absolute positioning and fixed positioning

containing block is established.

  • a stacking context is created.
  • for baseline handling, the box is treated as having no

baseline. For grid/flexible box containers/items, this needs
a baseline synthesized from the border edges [2], for buttons it
requires a baseline synthesized from the margin edges [2, 3].

[1] https://drafts.csswg.org/css-contain-2/#layout-containment
[2] https://drafts.csswg.org/css-align-3/#synthesize-baseline
[3] https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::firstLineBaseline const):
(WebCore::RenderBlock::inlineBlockBaseline const):

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::firstLineBaseline const):
(WebCore::RenderBlockFlow::inlineBlockBaseline const):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::createsNewFormattingContext const):
(WebCore::RenderBox::layoutOverflowRectForPropagation const):

  • rendering/RenderBox.h:
  • rendering/RenderButton.cpp:

(WebCore::RenderButton::baselinePosition const):

  • rendering/RenderElement.h:

(WebCore::RenderElement::canContainFixedPositionObjects const):
(WebCore::RenderElement::canContainAbsolutelyPositionedObjects const):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::firstLineBaseline const):

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::firstLineBaseline const):

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::baselinePosition const):

  • rendering/RenderObject.cpp:

(WebCore::objectIsRelayoutBoundary):
(WebCore::shouldApplyLayoutContainment):

  • rendering/RenderObject.h:

(WebCore::RenderObject::isAtomicInlineLevelBox const):

  • rendering/RenderTable.cpp:

(WebCore::RenderTable::firstLineBaseline const):

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::containsLayout const):

  • style/StyleAdjuster.cpp:

(WebCore::Style::Adjuster::adjust const):

LayoutTests:

Unskip tests that pass now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderButton.cpp

    r275594 r276235  
    149149}
    150150
    151 LayoutUnit RenderButton::baselinePosition(FontBaseline, bool, LineDirectionMode direction, LinePositionMode) const
     151LayoutUnit RenderButton::baselinePosition(FontBaseline fontBaseline, bool firstLine, LineDirectionMode direction, LinePositionMode mode) const
    152152{
     153    if (shouldApplyLayoutContainment(*this))
     154        return RenderFlexibleBox::baselinePosition(fontBaseline, firstLine, direction, mode);
    153155    // We cannot rely on RenderFlexibleBox::baselinePosition() because of flexboxes have some special behavior
    154156    // regarding baselines that shouldn't apply to buttons.
Note: See TracChangeset for help on using the changeset viewer.