Title: [293222] trunk/Source/WebCore
Revision
293222
Author
za...@apple.com
Date
2022-04-22 08:57:52 -0700 (Fri, 22 Apr 2022)

Log Message

[LFC][Integration] BoxTree should be able to build non-inline content tree
https://bugs.webkit.org/show_bug.cgi?id=239653

Reviewed by Antti Koivisto.

This is in preparation for supporting non-IFC content (e.g. flex).

* layout/integration/LayoutIntegrationBoxTree.cpp:
(WebCore::LayoutIntegration::rootBoxFirstLineStyle):
(WebCore::LayoutIntegration::BoxTree::BoxTree):
(WebCore::LayoutIntegration::BoxTree::buildTreeForInlineContent):
(WebCore::LayoutIntegration::BoxTree::layoutBoxForRenderer):
(WebCore::LayoutIntegration::BoxTree::rendererForLayoutBox):
(WebCore::LayoutIntegration::BoxTree::buildTree): Deleted.
* layout/integration/LayoutIntegrationBoxTree.h:
(WebCore::LayoutIntegration::BoxTree::rootRenderer const):
(WebCore::LayoutIntegration::BoxTree::rootRenderer):
(WebCore::LayoutIntegration::BoxTree::flow const): Deleted.
(WebCore::LayoutIntegration::BoxTree::flow): Deleted.
* layout/integration/inline/LayoutIntegrationLineLayout.h:
(WebCore::LayoutIntegration::LineLayout::flow const):
(WebCore::LayoutIntegration::LineLayout::flow):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (293221 => 293222)


--- trunk/Source/WebCore/ChangeLog	2022-04-22 15:13:42 UTC (rev 293221)
+++ trunk/Source/WebCore/ChangeLog	2022-04-22 15:57:52 UTC (rev 293222)
@@ -1,3 +1,28 @@
+2022-04-22  Alan Bujtas  <za...@apple.com>
+
+        [LFC][Integration] BoxTree should be able to build non-inline content tree
+        https://bugs.webkit.org/show_bug.cgi?id=239653
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting non-IFC content (e.g. flex).
+
+        * layout/integration/LayoutIntegrationBoxTree.cpp:
+        (WebCore::LayoutIntegration::rootBoxFirstLineStyle):
+        (WebCore::LayoutIntegration::BoxTree::BoxTree):
+        (WebCore::LayoutIntegration::BoxTree::buildTreeForInlineContent):
+        (WebCore::LayoutIntegration::BoxTree::layoutBoxForRenderer):
+        (WebCore::LayoutIntegration::BoxTree::rendererForLayoutBox):
+        (WebCore::LayoutIntegration::BoxTree::buildTree): Deleted.
+        * layout/integration/LayoutIntegrationBoxTree.h:
+        (WebCore::LayoutIntegration::BoxTree::rootRenderer const):
+        (WebCore::LayoutIntegration::BoxTree::rootRenderer):
+        (WebCore::LayoutIntegration::BoxTree::flow const): Deleted.
+        (WebCore::LayoutIntegration::BoxTree::flow): Deleted.
+        * layout/integration/inline/LayoutIntegrationLineLayout.h:
+        (WebCore::LayoutIntegration::LineLayout::flow const):
+        (WebCore::LayoutIntegration::LineLayout::flow):
+
 2022-04-22  Mark Lam  <mark....@apple.com>
 
         Apply purifyNaN in more places.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp (293221 => 293222)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp	2022-04-22 15:13:42 UTC (rev 293221)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.cpp	2022-04-22 15:57:52 UTC (rev 293222)
@@ -33,6 +33,7 @@
 #include "LayoutInlineTextBox.h"
 #include "LayoutLineBreakBox.h"
 #include "LayoutReplacedBox.h"
+#include "RenderBlock.h"
 #include "RenderBlockFlow.h"
 #include "RenderChildIterator.h"
 #include "RenderDetailsMarker.h"
@@ -62,32 +63,35 @@
     return clonedStyle;
 }
 
-static std::unique_ptr<RenderStyle> rootBoxFirstLineStyle(const RenderBlockFlow& root)
+static std::unique_ptr<RenderStyle> rootBoxFirstLineStyle(const RenderBlock& rootRenderer)
 {
 #if CAN_USE_FIRST_LINE_STYLE_RESOLVE
-    auto& firstLineStyle = root.firstLineStyle();
-    if (root.style() == firstLineStyle)
+    auto& firstLineStyle = rootRenderer.firstLineStyle();
+    if (rootRenderer.style() == firstLineStyle)
         return { };
     auto clonedStyle = RenderStyle::clonePtr(firstLineStyle);
     clonedStyle->setEffectiveDisplay(DisplayType::Block);
     return clonedStyle;
 #else
-    UNUSED_PARAM(root);
+    UNUSED_PARAM(rootRenderer);
     return { };
 #endif
 }
 
-BoxTree::BoxTree(RenderBlockFlow& flow)
-    : m_flow(flow)
-    , m_root(Layout::Box::ElementAttributes { Layout::Box::ElementType::IntegrationBlockContainer }, rootBoxStyle(flow.style()), rootBoxFirstLineStyle(flow))
+BoxTree::BoxTree(RenderBlock& rootRenderer)
+    : m_rootRenderer(rootRenderer)
+    , m_root(Layout::Box::ElementAttributes { Layout::Box::ElementType::IntegrationBlockContainer }, rootBoxStyle(rootRenderer.style()), rootBoxFirstLineStyle(rootRenderer))
 {
-    if (flow.isAnonymous())
+    if (rootRenderer.isAnonymous())
         m_root.setIsAnonymous();
 
-    buildTree();
+    if (is<RenderBlockFlow>(rootRenderer))
+        buildTreeForInlineContent();
+    else
+        ASSERT_NOT_IMPLEMENTED_YET();
 }
 
-void BoxTree::buildTree()
+void BoxTree::buildTreeForInlineContent()
 {
     auto createChildBox = [&](RenderObject& childRenderer) -> std::unique_ptr<Layout::Box> {
         std::unique_ptr<RenderStyle> firstLineStyle;
@@ -162,7 +166,7 @@
         return nullptr;
     };
 
-    for (auto walker = InlineWalker(m_flow); !walker.atEnd(); walker.advance()) {
+    for (auto walker = InlineWalker(downcast<RenderBlockFlow>(m_rootRenderer)); !walker.atEnd(); walker.advance()) {
         auto& childRenderer = *walker.current();
         auto childBox = createChildBox(childRenderer);
         appendChild(makeUniqueRefFromNonNullUniquePtr(WTFMove(childBox)), childRenderer);
@@ -215,7 +219,7 @@
 
 Layout::Box& BoxTree::layoutBoxForRenderer(const RenderObject& renderer)
 {
-    if (&renderer == &m_flow)
+    if (&renderer == &m_rootRenderer)
         return m_root;
 
     if (m_boxes.size() <= smallTreeThreshold) {
@@ -237,7 +241,7 @@
 RenderObject& BoxTree::rendererForLayoutBox(const Layout::Box& box)
 {
     if (&box == &m_root)
-        return m_flow;
+        return m_rootRenderer;
 
     if (m_boxes.size() <= smallTreeThreshold) {
         auto index = m_boxes.findIf([&](auto& entry) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h (293221 => 293222)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h	2022-04-22 15:13:42 UTC (rev 293221)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationBoxTree.h	2022-04-22 15:57:52 UTC (rev 293222)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-class RenderBlockFlow;
+class RenderBlock;
 class RenderBoxModelObject;
 
 namespace LayoutIntegration {
@@ -45,12 +45,12 @@
 
 class BoxTree {
 public:
-    BoxTree(RenderBlockFlow&);
+    BoxTree(RenderBlock&);
 
     void updateStyle(const RenderBoxModelObject&);
 
-    const RenderBlockFlow& flow() const { return m_flow; }
-    RenderBlockFlow& flow() { return m_flow; }
+    const RenderBlock& rootRenderer() const { return m_rootRenderer; }
+    RenderBlock& rootRenderer() { return m_rootRenderer; }
 
     const Layout::ContainerBox& rootLayoutBox() const { return m_root; }
     Layout::ContainerBox& rootLayoutBox() { return m_root; }
@@ -70,10 +70,10 @@
     const auto& boxAndRendererList() const { return m_boxes; }
 
 private:
-    void buildTree();
+    void buildTreeForInlineContent();
     void appendChild(UniqueRef<Layout::Box>, RenderObject&);
 
-    RenderBlockFlow& m_flow;
+    RenderBlock& m_rootRenderer;
     Layout::ContainerBox m_root;
     Vector<BoxAndRenderer, 1> m_boxes;
 

Modified: trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h (293221 => 293222)


--- trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h	2022-04-22 15:13:42 UTC (rev 293221)
+++ trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.h	2022-04-22 15:57:52 UTC (rev 293222)
@@ -116,8 +116,8 @@
     InlineIterator::LineBoxIterator lastLineBox() const;
 
     const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
-    const RenderBlockFlow& flow() const { return m_boxTree.flow(); }
-    RenderBlockFlow& flow() { return m_boxTree.flow(); }
+    const RenderBlockFlow& flow() const { return downcast<RenderBlockFlow>(m_boxTree.rootRenderer()); }
+    RenderBlockFlow& flow() { return downcast<RenderBlockFlow>(m_boxTree.rootRenderer()); }
 
     static void releaseCaches(RenderView&);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to