Title: [286133] trunk
Revision
286133
Author
[email protected]
Date
2021-11-23 07:01:01 -0800 (Tue, 23 Nov 2021)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286132 => 286133)


--- trunk/LayoutTests/ChangeLog	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/LayoutTests/ChangeLog	2021-11-23 15:01:01 UTC (rev 286133)
@@ -1,3 +1,12 @@
+2021-11-23  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Inflate ink overflow with box-shadow
+        https://bugs.webkit.org/show_bug.cgi?id=233437
+
+        Reviewed by Antti Koivisto.
+
+        * platform/mac/fast/box-shadow/basic-shadows-expected.txt:
+
 2021-11-23  Adrian Perez de Castro  <[email protected]>
 
         [WPE][GTK] Allow enabling JPEG-XL support at build time

Modified: trunk/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.txt (286132 => 286133)


--- trunk/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.txt	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/LayoutTests/platform/mac/fast/box-shadow/basic-shadows-expected.txt	2021-11-23 15:01:01 UTC (rev 286133)
@@ -7,10 +7,10 @@
         RenderInline {SPAN} at (0,0) size 270x128 [border: (5px solid #000000)]
           RenderText {#text} at (5,16) size 57x18
             text run at (5,16) width 57: "This text"
-          RenderBR {BR} at (61,0) size 1x18
+          RenderBR {BR} at (61,16) size 1x18
           RenderText {#text} at (0,66) size 77x18
             text run at (0,66) width 77: "should have"
-          RenderBR {BR} at (76,50) size 1x18
+          RenderBR {BR} at (76,66) size 1x18
           RenderText {#text} at (0,116) size 265x18
             text run at (0,116) width 265: "a multi-line shadow with a border-radius."
         RenderText {#text} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (286132 => 286133)


--- trunk/Source/WebCore/ChangeLog	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/Source/WebCore/ChangeLog	2021-11-23 15:01:01 UTC (rev 286133)
@@ -1,3 +1,21 @@
+2021-11-23  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Inflate ink overflow with box-shadow
+        https://bugs.webkit.org/show_bug.cgi?id=233437
+
+        Reviewed by Antti Koivisto.
+
+        * 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:
+
 2021-11-23  Said Abou-Hallawa  <[email protected]>
 
         [GPU Process] Refactor the FilterEffect result buffers into a new class named 'FilterImage'

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (286132 => 286133)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-11-23 15:01:01 UTC (rev 286133)
@@ -67,6 +67,18 @@
     return boxes;
 }
 
+static inline void addBoxShadowInkOverflow(const RenderStyle& style, InlineRect& inkOverflow)
+{
+    auto topBoxShadow = LayoutUnit { };
+    auto bottomBoxShadow = LayoutUnit { };
+    style.getBoxShadowBlockDirectionExtent(topBoxShadow, bottomBoxShadow);
+
+    auto leftBoxShadow = LayoutUnit { };
+    auto rightBoxShadow = LayoutUnit { };
+    style.getBoxShadowInlineDirectionExtent(leftBoxShadow, rightBoxShadow);
+    inkOverflow.inflate(InlineLayoutUnit { topBoxShadow }, InlineLayoutUnit { rightBoxShadow }, InlineLayoutUnit { bottomBoxShadow }, InlineLayoutUnit { leftBoxShadow });
+}
+
 void InlineDisplayContentBuilder::createBoxesAndUpdateGeometryForLineContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, const size_t lineIndex, DisplayBoxes& boxes)
 {
     // Create the inline boxes on the current line. This is mostly text and atomic inline boxes.
@@ -205,7 +217,9 @@
                     return;
                 }
                 RELEASE_ASSERT(m_inlineBoxIndexMap.contains(&parentInlineBox));
-                boxes[m_inlineBoxIndexMap.get(&parentInlineBox)].adjustInkOverflow(borderBoxRect);
+                auto boxInkOverflow = borderBoxRect;
+                addBoxShadowInkOverflow(style, boxInkOverflow);
+                boxes[m_inlineBoxIndexMap.get(&parentInlineBox)].adjustInkOverflow(boxInkOverflow);
             };
             adjustParentInlineBoxInkOverflow();
             continue;
@@ -216,6 +230,11 @@
             auto inlineBoxBorderBox = displayBoxRect();
             contentRightInVisualOrder += lineRun.logicalWidth();
             if (lineBox.hasContent()) {
+                auto inkOverflow = [&] {
+                    auto inkOverflow = inlineBoxBorderBox;
+                    addBoxShadowInkOverflow(style, inkOverflow);
+                    return inkOverflow;
+                };
                 // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
                 m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
 
@@ -222,7 +241,7 @@
                 auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
                 ASSERT(inlineBox.isInlineBox());
                 ASSERT(inlineBox.isFirstBox());
-                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
+                boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inkOverflow(), { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
             }
 
             auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
@@ -242,13 +261,20 @@
                 continue;
             }
             m_inlineBoxIndexMap.add(&layoutBox, boxes.size());
+            auto inlineBoxBorderBox = displayBoxRect();
 
-            auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
-            auto inlineBoxBorderBox = displayBoxRect();
+            auto inkOverflow = [&] {
+                auto inkOverflow = inlineBoxBorderBox;
+                addBoxShadowInkOverflow(style, inkOverflow);
+                return inkOverflow;
+            };
+
             // The content right edge should not include the entire inline box here (including its content and right edge).
             contentRightInVisualOrder += lineRun.logicalWidth();
+
+            auto& inlineBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox);
             ASSERT(!inlineBox.isFirstBox());
-            boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
+            boxes.append({ lineIndex, InlineDisplay::Box::Type::NonRootInlineBox, layoutBox, lineRun.bidiLevel(), inlineBoxBorderBox, inkOverflow(), { }, { }, inlineBox.hasContent(), isFirstLastBox(inlineBox) });
 
             auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
             auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineRect.h (286132 => 286133)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineRect.h	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineRect.h	2021-11-23 15:01:01 UTC (rev 286133)
@@ -68,6 +68,7 @@
     void expandVertically(InlineLayoutUnit delta) { expand({ }, delta); }
     void expandVerticallyToContain(const InlineRect&);
     void inflate(InlineLayoutUnit);
+    void inflate(InlineLayoutUnit top, InlineLayoutUnit right, InlineLayoutUnit bottom, InlineLayoutUnit left);
 
     operator InlineLayoutRect() const;
 
@@ -288,6 +289,15 @@
     m_rect.inflate(inflate);
 }
 
+inline void InlineRect::inflate(InlineLayoutUnit top, InlineLayoutUnit right, InlineLayoutUnit bottom, InlineLayoutUnit left)
+{
+    ASSERT(hasValidGeometry());
+    m_rect.setX(m_rect.x() - left);
+    m_rect.setY(m_rect.y() - top);
+    m_rect.setWidth(m_rect.width() + left + right);
+    m_rect.setHeight(m_rect.height() + top + bottom);
+}
+
 inline InlineRect::operator InlineLayoutRect() const
 {
     ASSERT(hasValidGeometry()); 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (286132 => 286133)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-11-23 15:01:01 UTC (rev 286133)
@@ -200,8 +200,8 @@
     case AvoidanceReason::ContentIsSVG:
         stream << "SVG content";
         break;
-    case AvoidanceReason::ChildBoxHasUnsupportedStyle:
-        stream << "child box has unsupported style";
+    case AvoidanceReason::ChildBoxIsNotInlineBlock:
+        stream << "child box has unsupported display type";
         break;
     case AvoidanceReason::UnsupportedImageMap:
         stream << "image map";
@@ -477,8 +477,8 @@
         SET_REASON_AND_RETURN_IF_NEEDED(InlineBoxNeedsLayer, reasons, includeReasons)
 
     auto& style = renderInline.style();
-    if (style.boxShadow() || !style.hangingPunctuation().isEmpty())
-        SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
+    if (!style.hangingPunctuation().isEmpty())
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHangingPunctuation, reasons, includeReasons)
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
     if (style.boxDecorationBreak() == BoxDecorationBreak::Clone)
         SET_REASON_AND_RETURN_IF_NEEDED(BoxDecorationBreakClone, reasons, includeReasons);
@@ -528,14 +528,6 @@
         SET_REASON_AND_RETURN_IF_NEEDED(UnsupportedFieldset, reasons, includeReasons)
     }
 
-    auto isSupportedStyle = [] (const auto& style) {
-        if (style.boxShadow())
-            return false;
-        if (!style.hangingPunctuation().isEmpty())
-            return false;
-        return true;
-    };
-
     if (is<RenderReplaced>(child)) {
         auto& replaced = downcast<RenderReplaced>(child);
         if (replaced.isFloating() || replaced.isPositioned())
@@ -544,9 +536,6 @@
         if (replaced.isSVGRoot())
             SET_REASON_AND_RETURN_IF_NEEDED(ContentIsSVG, reasons, includeReasons);
 
-        if (!isSupportedStyle(replaced.style()))
-            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons);
-
         if (is<RenderImage>(replaced)) {
             auto& image = downcast<RenderImage>(replaced);
             if (image.imageMap())
@@ -566,10 +555,10 @@
             SET_REASON_AND_RETURN_IF_NEEDED(ContentIsRuby, reasons, includeReasons);
 
         auto& style = block.style();
-        if (!isSupportedStyle(style))
-            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
+        if (!style.hangingPunctuation().isEmpty())
+            SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHangingPunctuation, reasons, includeReasons)
         if (style.display() != DisplayType::InlineBlock)
-            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxHasUnsupportedStyle, reasons, includeReasons)
+            SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsNotInlineBlock, reasons, includeReasons)
 
         return reasons;
     }

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (286132 => 286133)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-11-23 13:20:27 UTC (rev 286132)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-11-23 15:01:01 UTC (rev 286133)
@@ -95,7 +95,7 @@
     UnsupportedFieldset                          = 1LLU  << 54,
     ChildBoxIsFloatingOrPositioned               = 1LLU  << 55,
     ContentIsSVG                                 = 1LLU  << 56,
-    ChildBoxHasUnsupportedStyle                  = 1LLU  << 57,
+    ChildBoxIsNotInlineBlock                     = 1LLU  << 57,
     UnsupportedImageMap                          = 1LLU  << 58,
     InlineBoxNeedsLayer                          = 1LLU  << 59,
     BoxDecorationBreakClone                      = 1LLU  << 60,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to