⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286133 in webkit


Ignore:
Timestamp:
Nov 23, 2021, 7:01:01 AM (5 years ago)
Author:
Alan Bujtas
Message:

[IFC][Integration] Inflate ink overflow with box-shadow
https://bugs.webkit.org/show_bug.cgi?id=233437

Reviewed by Antti Koivisto.

Source/WebCore:

  • layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:

(WebCore::Layout::addBoxShadowInkOverflow):
(WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):

  • layout/formattingContexts/inline/InlineRect.h:

(WebCore::Layout::InlineRect::inflate):

  • layout/integration/LayoutIntegrationCoverage.cpp:

(WebCore::LayoutIntegration::printReason):
(WebCore::LayoutIntegration::canUseForRenderInlineChild):
(WebCore::LayoutIntegration::canUseForChild):

  • layout/integration/LayoutIntegrationCoverage.h:

LayoutTests:

  • platform/mac/fast/box-shadow/basic-shadows-expected.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286131 r286133  
     12021-11-23  Alan Bujtas  <zalan@apple.com>
     2
     3        [IFC][Integration] Inflate ink overflow with box-shadow
     4        https://bugs.webkit.org/show_bug.cgi?id=233437
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * platform/mac/fast/box-shadow/basic-shadows-expected.txt:
     9
    1102021-11-23  Adrian Perez de Castro  <aperez@igalia.com>
    211
  • trunk/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.txt

    r268520 r286133  
    88          RenderText {#text} at (5,16) size 57x18
    99            text run at (5,16) width 57: "This text"
    10           RenderBR {BR} at (61,0) size 1x18
     10          RenderBR {BR} at (61,16) size 1x18
    1111          RenderText {#text} at (0,66) size 77x18
    1212            text run at (0,66) width 77: "should have"
    13           RenderBR {BR} at (76,50) size 1x18
     13          RenderBR {BR} at (76,66) size 1x18
    1414          RenderText {#text} at (0,116) size 265x18
    1515            text run at (0,116) width 265: "a multi-line shadow with a border-radius."
  • trunk/Source/WebCore/ChangeLog

    r286129 r286133  
     12021-11-23  Alan Bujtas  <zalan@apple.com>
     2
     3        [IFC][Integration] Inflate ink overflow with box-shadow
     4        https://bugs.webkit.org/show_bug.cgi?id=233437
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
     9        (WebCore::Layout::addBoxShadowInkOverflow):
     10        (WebCore::Layout::InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent):
     11        * layout/formattingContexts/inline/InlineRect.h:
     12        (WebCore::Layout::InlineRect::inflate):
     13        * layout/integration/LayoutIntegrationCoverage.cpp:
     14        (WebCore::LayoutIntegration::printReason):
     15        (WebCore::LayoutIntegration::canUseForRenderInlineChild):
     16        (WebCore::LayoutIntegration::canUseForChild):
     17        * layout/integration/LayoutIntegrationCoverage.h:
     18
    1192021-11-23  Said Abou-Hallawa  <said@apple.com>
    220
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp

    r285784 r286133  
    6666    collectInkOverflowForInlineBoxes(lineBox, boxes);
    6767    return boxes;
     68}
     69
     70static inline void addBoxShadowInkOverflow(const RenderStyle& style, InlineRect& inkOverflow)
     71{
     72    auto topBoxShadow = LayoutUnit { };
     73    auto bottomBoxShadow = LayoutUnit { };
     74    style.getBoxShadowBlockDirectionExtent(topBoxShadow, bottomBoxShadow);
     75
     76    auto leftBoxShadow = LayoutUnit { };
     77    auto rightBoxShadow = LayoutUnit { };
     78    style.getBoxShadowInlineDirectionExtent(leftBoxShadow, rightBoxShadow);
     79    inkOverflow.inflate(InlineLayoutUnit { topBoxShadow }, InlineLayoutUnit { rightBoxShadow }, InlineLayoutUnit { bottomBoxShadow }, InlineLayoutUnit { leftBoxShadow });
    6880}
    6981
     
    206218                }
    207219                RELEASE_ASSERT(m_inlineBoxIndexMap.contains(&parentInlineBox));
    208                 boxes[m_inlineBoxIndexMap.get(&parentInlineBox)].adjustInkOverflow(borderBoxRect);
     220                auto boxInkOverflow = borderBoxRect;
     221                addBoxShadowInkOverflow(style, boxInkOverflow);
     222                boxes[m_inlineBoxIndexMap.get(&parentInlineBox)].adjustInkOverflow(boxInkOverflow);
    209223            };
    210224            adjustParentInlineBoxInkOverflow();
     
    217231            contentRightInVisualOrder += lineRun.logicalWidth();
    218232            if (lineBox.hasContent()) {
     233                auto inkOverflow = [&] {
     234                    auto inkOverflow = inlineBoxBorderBox;
     235                    addBoxShadowInkOverflow(style, inkOverflow);
     236                    return inkOverflow;
     237                };
    219238                // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
    220239                m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
     
    223242                ASSERT(inlineBox.isInlineBox());
    224243                ASSERT(inlineBox.isFirstBox());
    225                 boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
     244                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inkOverflow(), { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
    226245            }
    227246
     
    243262            }
    244263            m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
    245 
    246             auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
    247264            auto inlineBoxBorderBox = displayBoxRect();
     265
     266            auto inkOverflow = [&] {
     267                auto inkOverflow = inlineBoxBorderBox;
     268                addBoxShadowInkOverflow(style, inkOverflow);
     269                return inkOverflow;
     270            };
     271
    248272            // The content right edge should not include the entire inline box here (including its content and right edge).
    249273            contentRightInVisualOrder += lineRun.logicalWidth();
     274
     275            auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
    250276            ASSERT(!inlineBox.isFirstBox());
    251             boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
     277            boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inkOverflow(), { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
    252278
    253279            auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineRect.h

    r281905 r286133  
    6969    void expandVerticallyToContain(const InlineRect&);
    7070    void inflate(InlineLayoutUnit);
     71    void inflate(InlineLayoutUnit top, InlineLayoutUnit right, InlineLayoutUnit bottom, InlineLayoutUnit left);
    7172
    7273    operator InlineLayoutRect() const;
     
    289290}
    290291
     292inline void InlineRect::inflate(InlineLayoutUnit top, InlineLayoutUnit right, InlineLayoutUnit bottom, InlineLayoutUnit left)
     293{
     294    ASSERT(hasValidGeometry());
     295    m_rect.setX(m_rect.x() - left);
     296    m_rect.setY(m_rect.y() - top);
     297    m_rect.setWidth(m_rect.width() + left + right);
     298    m_rect.setHeight(m_rect.height() + top + bottom);
     299}
     300
    291301inline InlineRect::operator InlineLayoutRect() const
    292302{
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp

    r286107 r286133  
    201201        stream << "SVG content";
    202202        break;
    203     case AvoidanceReason::ChildBoxHasUnsupportedStyle:
    204         stream << "child box has unsupported style";
     203    case AvoidanceReason::ChildBoxIsNotInlineBlock:
     204        stream << "child box has unsupported display type";
    205205        break;
    206206    case AvoidanceReason::UnsupportedImageMap:
     
    478478
    479479    auto& style = renderInline.style();
    480     if (style.boxShadow() || !style.hangingPunctuation().isEmpty())
    481         SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
     480    if (!style.hangingPunctuation().isEmpty())
     481        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHangingPunctuation, reasons, includeReasons)
    482482#if ENABLE(CSS_BOX_DECORATION_BREAK)
    483483    if (style.boxDecorationBreak() == BoxDecorationBreak::Clone)
     
    529529    }
    530530
    531     auto isSupportedStyle = [] (const auto& style) {
    532         if (style.boxShadow())
    533             return false;
    534         if (!style.hangingPunctuation().isEmpty())
    535             return false;
    536         return true;
    537     };
    538 
    539531    if (is<RenderReplaced>(child)) {
    540532        auto& replaced = downcast<RenderReplaced>(child);
     
    544536        if (replaced.isSVGRoot())
    545537            SET_REASON_AND_RETURN_IF_NEEDED(ContentIsSVG, reasons, includeReasons);
    546 
    547         if (!isSupportedStyle(replaced.style()))
    548             SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons);
    549538
    550539        if (is<RenderImage>(replaced)) {
     
    567556
    568557        auto& style = block.style();
    569         if (!isSupportedStyle(style))
    570             SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
     558        if (!style.hangingPunctuation().isEmpty())
     559            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHangingPunctuation, reasons, includeReasons)
    571560        if (style.display() != DisplayType::InlineBlock)
    572             SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
     561            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsNotInlineBlock, reasons, includeReasons)
    573562
    574563        return reasons;
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h

    r284334 r286133  
    9696    ChildBoxIsFloatingOrPositioned               = 1LLU  << 55,
    9797    ContentIsSVG                                 = 1LLU  << 56,
    98     ChildBoxHasUnsupportedStyle                  = 1LLU  << 57,
     98    ChildBoxIsNotInlineBlock                     = 1LLU  << 57,
    9999    UnsupportedImageMap                          = 1LLU  << 58,
    100100    InlineBoxNeedsLayer                          = 1LLU  << 59,
Note: See TracChangeset for help on using the changeset viewer.