Diff
Modified: trunk/Source/WebCore/ChangeLog (237631 => 237632)
--- trunk/Source/WebCore/ChangeLog 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/ChangeLog 2018-10-31 13:43:03 UTC (rev 237632)
@@ -1,5 +1,33 @@
2018-10-31 Zalan Bujtas <za...@apple.com>
+ [LFC] The *FormattingState class should provide the *FormattingContext.
+ https://bugs.webkit.org/show_bug.cgi?id=191089
+
+ Reviewed by Antti Koivisto.
+
+ BlockFormattingState provides the BlockFormattingContext object, while InlineFormattingState provides the InlineFormattingContext.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const):
+ * layout/FormattingState.h:
+ * layout/LayoutFormattingState.cpp:
+ (WebCore::Layout::LayoutState::layoutFormattingContextSubtree):
+ (WebCore::Layout::LayoutState::formattingContext const): Deleted.
+ * layout/LayoutFormattingState.h:
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const):
+ (WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const):
+ * layout/blockformatting/BlockFormattingState.cpp:
+ (WebCore::Layout::BlockFormattingState::formattingContext const):
+ * layout/blockformatting/BlockFormattingState.h:
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const):
+ * layout/inlineformatting/InlineFormattingState.cpp:
+ (WebCore::Layout::InlineFormattingState::formattingContext const):
+ * layout/inlineformatting/InlineFormattingState.h:
+
+2018-10-31 Zalan Bujtas <za...@apple.com>
+
[LFC] Rename LayoutContext to LayoutState
https://bugs.webkit.org/show_bug.cgi?id=191080
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -29,6 +29,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "DisplayBox.h"
+#include "FormattingState.h"
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include "LayoutDescendantIterator.h"
@@ -147,13 +148,12 @@
auto& layoutBox = *outOfFlowBox;
ASSERT(layoutBox.establishesFormattingContext());
- auto formattingContext = layoutState.formattingContext(layoutBox);
computeBorderAndPadding(layoutState, layoutBox);
computeOutOfFlowHorizontalGeometry(layoutState, layoutBox);
auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox);
- formattingContext->layout(layoutState, formattingState);
+ formattingState.formattingContext(layoutBox)->layout(layoutState, formattingState);
computeOutOfFlowVerticalGeometry(layoutState, layoutBox);
layoutOutOfFlowDescendants(layoutState, layoutBox);
Modified: trunk/Source/WebCore/layout/FormattingState.h (237631 => 237632)
--- trunk/Source/WebCore/layout/FormattingState.h 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/FormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
@@ -46,6 +46,8 @@
public:
virtual ~FormattingState();
+ virtual std::unique_ptr<FormattingContext>formattingContext(const Box& formattingContextRoot) const = 0;
+
FloatingState& floatingState() const { return m_floatingState; }
void markNeedsLayout(const Box&, StyleDiff);
Modified: trunk/Source/WebCore/layout/LayoutFormattingState.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/LayoutFormattingState.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/LayoutFormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -81,8 +81,8 @@
void LayoutState::layoutFormattingContextSubtree(const Box& layoutRoot)
{
RELEASE_ASSERT(layoutRoot.establishesFormattingContext());
- auto formattingContext = this->formattingContext(layoutRoot);
auto& formattingState = createFormattingStateForFormattingRootIfNeeded(layoutRoot);
+ auto formattingContext = formattingState.formattingContext(layoutRoot);
formattingContext->layout(*this, formattingState);
formattingContext->layoutOutOfFlowDescendants(*this, layoutRoot);
}
@@ -156,19 +156,7 @@
CRASH();
}
-std::unique_ptr<FormattingContext> LayoutState::formattingContext(const Box& formattingContextRoot) const
-{
- if (formattingContextRoot.establishesInlineFormattingContext())
- return std::make_unique<InlineFormattingContext>(formattingContextRoot);
-
- if (formattingContextRoot.establishesBlockFormattingContext())
- return std::make_unique<BlockFormattingContext>(formattingContextRoot);
-
- ASSERT_NOT_IMPLEMENTED_YET();
- return nullptr;
}
-
}
-}
#endif
Modified: trunk/Source/WebCore/layout/LayoutFormattingState.h (237631 => 237632)
--- trunk/Source/WebCore/layout/LayoutFormattingState.h 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/LayoutFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
@@ -75,8 +75,6 @@
void markNeedsUpdate(const Box&, OptionSet<UpdateType>);
bool needsUpdate(const Box&) const;
- std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const;
-
FormattingState& formattingStateForBox(const Box&) const;
FormattingState& establishedFormattingState(const Box& formattingRoot) const;
FormattingState& createFormattingStateForFormattingRootIfNeeded(const Box& formattingRoot);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -134,8 +134,8 @@
precomputeVerticalPositionForFormattingRootIfNeeded(layoutState, layoutBox);
// Swich over to the new formatting context (the one that the root creates).
- auto formattingContext = layoutState.formattingContext(layoutBox);
auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox);
+ auto formattingContext = formattingState.formattingContext(layoutBox);
formattingContext->layout(layoutState, formattingState);
// Come back and finalize the root's geometry.
@@ -383,7 +383,7 @@
instrinsicWidthConstraints = Geometry::instrinsicWidthConstraints(layoutState, childBox);
// Is it a formatting context root?
if (!instrinsicWidthConstraints && childBox.establishesFormattingContext())
- instrinsicWidthConstraints = layoutState.formattingContext(childBox)->instrinsicWidthConstraints(layoutState, childBox);
+ instrinsicWidthConstraints = formattingStateForChildren.formattingContext(childBox)->instrinsicWidthConstraints(layoutState, childBox);
// Go to the next sibling (and skip the descendants) if this box's min/max width is computed.
if (instrinsicWidthConstraints) {
formattingStateForChildren.setInstrinsicWidthConstraints(childBox, *instrinsicWidthConstraints);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -46,6 +46,12 @@
{
}
+std::unique_ptr<FormattingContext> BlockFormattingState::formattingContext(const Box& formattingContextRoot) const
+{
+ ASSERT(formattingContextRoot.establishesBlockFormattingContext());
+ return std::make_unique<BlockFormattingContext>(formattingContextRoot);
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h (237631 => 237632)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
@@ -40,6 +40,8 @@
public:
BlockFormattingState(Ref<FloatingState>&&, const LayoutState&);
virtual ~BlockFormattingState();
+
+ std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
};
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -241,7 +241,8 @@
computeWidthAndMargin();
// Swich over to the new formatting context (the one that the root creates).
- layoutState.formattingContext(layoutBox)->layout(layoutState, layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox));
+ auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox);
+ formattingState.formattingContext(layoutBox)->layout(layoutState, formattingState);
// Come back and finalize the root's height and margin.
computeHeightAndMargin();
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp (237631 => 237632)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
@@ -44,6 +44,12 @@
{
}
+std::unique_ptr<FormattingContext> InlineFormattingState::formattingContext(const Box& formattingContextRoot) const
+{
+ ASSERT(formattingContextRoot.establishesInlineFormattingContext());
+ return std::make_unique<InlineFormattingContext>(formattingContextRoot);
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (237631 => 237632)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-31 13:37:58 UTC (rev 237631)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
@@ -42,6 +42,8 @@
InlineFormattingState(Ref<FloatingState>&&, const LayoutState&);
virtual ~InlineFormattingState();
+ std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
+
InlineContent& inlineContent() { return m_inlineContent; }
// Temp
InlineRuns& inlineRuns() { return m_inlineRuns; }