Title: [232249] trunk/Source/WebCore
Revision
232249
Author
[email protected]
Date
2018-05-28 11:56:34 -0700 (Mon, 28 May 2018)

Log Message

[LFC] Add formatting context testing codepath in FrameViewLayoutContext
https://bugs.webkit.org/show_bug.cgi?id=186036

Reviewed by Antti Koivisto.

This is to verify the formatting context layout correctness.

* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::LayoutContext):
(WebCore::Layout::LayoutContext::initializeRoot):
* layout/LayoutContext.h:
(WebCore::Layout::LayoutContext::displayBoxForLayoutBox const):
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):
(WebCore::FrameViewLayoutContext::layout):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232248 => 232249)


--- trunk/Source/WebCore/ChangeLog	2018-05-28 17:55:18 UTC (rev 232248)
+++ trunk/Source/WebCore/ChangeLog	2018-05-28 18:56:34 UTC (rev 232249)
@@ -1,5 +1,23 @@
 2018-05-28  Zalan Bujtas  <[email protected]>
 
+        [LFC] Add formatting context testing codepath in FrameViewLayoutContext
+        https://bugs.webkit.org/show_bug.cgi?id=186036
+
+        Reviewed by Antti Koivisto.
+
+        This is to verify the formatting context layout correctness.
+
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::LayoutContext):
+        (WebCore::Layout::LayoutContext::initializeRoot):
+        * layout/LayoutContext.h:
+        (WebCore::Layout::LayoutContext::displayBoxForLayoutBox const):
+        * page/FrameViewLayoutContext.cpp:
+        (WebCore::layoutUsingFormattingContext):
+        (WebCore::FrameViewLayoutContext::layout):
+
+2018-05-28  Zalan Bujtas  <[email protected]>
+
         [LFC] Add layout tree verification.
         https://bugs.webkit.org/show_bug.cgi?id=186018
 

Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (232248 => 232249)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	2018-05-28 17:55:18 UTC (rev 232248)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2018-05-28 18:56:34 UTC (rev 232249)
@@ -45,11 +45,37 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutContext);
 
-LayoutContext::LayoutContext(const Box& root)
-    : m_root(makeWeakPtr(const_cast<Box&>(root)))
+LayoutContext::LayoutContext()
 {
 }
 
+void LayoutContext::initializeRoot(const Container& root, const LayoutSize& containerSize)
+{
+    m_root = makeWeakPtr(const_cast<Container&>(root));
+    auto& displayBox = createDisplayBox(root);
+    // Root is always at 0 0 with no margin 
+    displayBox.setTopLeft({ });
+    displayBox.setWidth(containerSize.width());
+    displayBox.setHeight(containerSize.height());
+    displayBox.setMargin({ });
+
+    auto& style = root.style();
+    // FIXME: m_root could very well be a formatting context root with ancestors and resolvable border and padding (as opposed to the topmost root)  
+    displayBox.setBorder({
+        style.borderTop().width(),
+        style.borderLeft().width(),
+        style.borderBottom().width(),
+        style.borderRight().width()
+
+    });
+    displayBox.setPadding({
+        valueForLength(style.paddingTop(), containerSize.width()),
+        valueForLength(style.paddingLeft(), containerSize.width()),
+        valueForLength(style.paddingBottom(), containerSize.width()),
+        valueForLength(style.paddingRight(), containerSize.width())
+    });
+}
+
 void LayoutContext::updateLayout()
 {
     ASSERT(!m_formattingContextRootListForLayout.isEmpty());

Modified: trunk/Source/WebCore/layout/LayoutContext.h (232248 => 232249)


--- trunk/Source/WebCore/layout/LayoutContext.h	2018-05-28 17:55:18 UTC (rev 232248)
+++ trunk/Source/WebCore/layout/LayoutContext.h	2018-05-28 18:56:34 UTC (rev 232249)
@@ -58,13 +58,10 @@
 class LayoutContext {
     WTF_MAKE_ISO_ALLOCATED(LayoutContext);
 public:
-    LayoutContext(const Box& root);
+    LayoutContext();
 
+    void initializeRoot(const Container&, const LayoutSize&);
     void updateLayout();
-
-    Display::Box& createDisplayBox(const Box&);
-    Display::Box* displayBoxForLayoutBox(const Box& layoutBox) const { return m_layoutToDisplayBox.get(&layoutBox); }
-
     void styleChanged(const Box&, StyleDiff);
 
     enum class UpdateType {
@@ -83,8 +80,11 @@
     // For testing purposes only
     void verifyAndOutputMismatchingLayoutTree(const RenderView&) const;
 
+    Display::Box& createDisplayBox(const Box&);
+    Display::Box* displayBoxForLayoutBox(const Box& layoutBox) const { return m_layoutToDisplayBox.get(&layoutBox); }
+
 private:
-    WeakPtr<Box> m_root;
+    WeakPtr<Container> m_root;
     HashSet<const Container*> m_formattingContextRootListForLayout;
     HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
     HashMap<const Box*, std::unique_ptr<Display::Box>> m_layoutToDisplayBox;

Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (232248 => 232249)


--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2018-05-28 17:55:18 UTC (rev 232248)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2018-05-28 18:56:34 UTC (rev 232249)
@@ -39,6 +39,12 @@
 #include "ScriptDisallowedScope.h"
 #include "Settings.h"
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "LayoutContainer.h"
+#include "LayoutContext.h"
+#include "LayoutTreeBuilder.h"
+#endif
+
 #include <wtf/SetForScope.h>
 #include <wtf/SystemTracing.h>
 #include <wtf/text/TextStream.h>
@@ -45,6 +51,17 @@
 
 namespace WebCore {
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+static void layoutUsingFormattingContext(const RenderView& renderView)
+{
+    auto initialContainingBlock = Layout::TreeBuilder::createLayoutTree(renderView);
+    auto layoutContext = std::make_unique<Layout::LayoutContext>();
+    layoutContext->initializeRoot(*initialContainingBlock, renderView.size());
+    layoutContext->updateLayout();
+    layoutContext->verifyAndOutputMismatchingLayoutTree(renderView);
+} 
+#endif
+
 static bool isObjectAncestorContainerOf(RenderElement& ancestor, RenderElement& descendant)
 {
     for (auto* renderer = &descendant; renderer; renderer = renderer->container()) {
@@ -189,6 +206,9 @@
         RenderTreeNeedsLayoutChecker checker(*layoutRoot);
 #endif
         layoutRoot->layout();
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    layoutUsingFormattingContext(*renderView());
+#endif
         ++m_layoutCount;
 #if ENABLE(TEXT_AUTOSIZING)
         applyTextSizingIfNeeded(*layoutRoot.get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to