Title: [276249] trunk/Source/WebCore
Revision
276249
Author
[email protected]
Date
2021-04-19 06:28:40 -0700 (Mon, 19 Apr 2021)

Log Message

[LFC] Implement Box::isLayoutContainmentBox
https://bugs.webkit.org/show_bug.cgi?id=224740

Reviewed by Antti Koivisto.

This is part of https://www.w3.org/TR/css-contain-2/#containment-layout

* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::isLayoutContainmentBox const):
(WebCore::Layout::Box::isInternalTableBox const):
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::isInternalRubyBox const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276248 => 276249)


--- trunk/Source/WebCore/ChangeLog	2021-04-19 13:22:54 UTC (rev 276248)
+++ trunk/Source/WebCore/ChangeLog	2021-04-19 13:28:40 UTC (rev 276249)
@@ -1,3 +1,18 @@
+2021-04-19  Zalan Bujtas  <[email protected]>
+
+        [LFC] Implement Box::isLayoutContainmentBox
+        https://bugs.webkit.org/show_bug.cgi?id=224740
+
+        Reviewed by Antti Koivisto.
+
+        This is part of https://www.w3.org/TR/css-contain-2/#containment-layout
+
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::isLayoutContainmentBox const):
+        (WebCore::Layout::Box::isInternalTableBox const):
+        * layout/layouttree/LayoutBox.h:
+        (WebCore::Layout::Box::isInternalRubyBox const):
+
 2021-04-19  Kimmo Kinnunen  <[email protected]>
 
         Enable -Wthread-safety, add attributes to custom lock classes, and provide macros to declare guards

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (276248 => 276249)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2021-04-19 13:22:54 UTC (rev 276248)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2021-04-19 13:28:40 UTC (rev 276249)
@@ -353,6 +353,30 @@
         || isTableCaption(); // TODO && !replaced element
 }
 
+bool Box::isLayoutContainmentBox() const
+{
+    auto supportsLayoutContainment = [&] {
+        // If the element does not generate a principal box (as is the case with display values of contents or none),
+        // or its principal box is an internal table box other than table-cell, or an internal ruby box, or a non-atomic inline-level box,
+        // layout containment has no effect.
+        if (isInternalTableBox())
+            return isTableCell();
+        if (isInternalRubyBox())
+            return false;
+        if (isInlineLevelBox())
+            return isAtomicInlineLevelBox();
+        return true;
+    };
+    return m_style.contain().contains(Containment::Layout) && supportsLayoutContainment();
+}
+
+bool Box::isInternalTableBox() const
+{
+    // table-row-group, table-header-group, table-footer-group, table-row, table-cell, table-column-group, table-column
+    // generates the appropriate internal table box which participates in a table formatting context.
+    return isTableBody() || isTableHeader() || isTableFooter() || isTableRow() || isTableCell() || isTableColumnGroup() || isTableColumn();
+}
+
 const Box* Box::nextInFlowSibling() const
 {
     auto* nextSibling = this->nextSibling();

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (276248 => 276249)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2021-04-19 13:22:54 UTC (rev 276248)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2021-04-19 13:28:40 UTC (rev 276249)
@@ -117,6 +117,7 @@
     bool isInlineBlockBox() const;
     bool isInlineTableBox() const;
     bool isInitialContainingBlock() const { return baseTypeFlags().contains(InitialContainingBlockFlag); }
+    bool isLayoutContainmentBox() const;
 
     bool isDocumentBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Document; }
     bool isBodyBox() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Body; }
@@ -130,10 +131,12 @@
     bool isTableColumnGroup() const { return style().display() == DisplayType::TableColumnGroup; }
     bool isTableColumn() const { return style().display() == DisplayType::TableColumn; }
     bool isTableCell() const { return style().display() == DisplayType::TableCell; }
+    bool isInternalTableBox() const;
     bool isFlexBox() const { return style().display() == DisplayType::Flex; }
     bool isFlexItem() const;
     bool isIFrame() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::IFrame; }
     bool isImage() const { return m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Image; }
+    bool isInternalRubyBox() const { return false; }
 
     const ContainerBox& parent() const { return *m_parent; }
     const Box* nextSibling() const { return m_nextSibling; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to