Diff
Modified: trunk/Source/WebCore/ChangeLog (237632 => 237633)
--- trunk/Source/WebCore/ChangeLog 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/ChangeLog 2018-10-31 13:50:05 UTC (rev 237633)
@@ -1,5 +1,43 @@
2018-10-31 Zalan Bujtas <za...@apple.com>
+ [LFC] FormattingContext class should take FormattingState&
+ https://bugs.webkit.org/show_bug.cgi?id=191099
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for not passing LayoutState& into every layout functions.
+ FormattingContext has FormattingState now and LayoutState can be acquired through FormattingState.
+ LayoutState <- FormattingState <- FormattingContext
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::FormattingContext):
+ (WebCore::Layout::FormattingContext::formattingState const):
+ (WebCore::Layout::FormattingContext::layoutState const):
+ * layout/FormattingContext.h:
+ * layout/FormattingState.cpp:
+ (WebCore::Layout::FormattingState::FormattingState):
+ * layout/FormattingState.h:
+ (WebCore::Layout::FormattingState::layoutState const):
+ * layout/LayoutFormattingState.h:
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingState.cpp:
+ (WebCore::Layout::BlockFormattingState::BlockFormattingState):
+ (WebCore::Layout::BlockFormattingState::formattingContext):
+ (WebCore::Layout::BlockFormattingState::formattingContext const): Deleted.
+ * layout/blockformatting/BlockFormattingState.h:
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
+ * layout/inlineformatting/InlineFormattingContext.h:
+ * layout/inlineformatting/InlineFormattingState.cpp:
+ (WebCore::Layout::InlineFormattingState::InlineFormattingState):
+ (WebCore::Layout::InlineFormattingState::formattingContext):
+ (WebCore::Layout::InlineFormattingState::formattingContext const): Deleted.
+ * layout/inlineformatting/InlineFormattingState.h:
+
+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
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -43,8 +43,9 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
-FormattingContext::FormattingContext(const Box& formattingContextRoot)
+FormattingContext::FormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
: m_root(makeWeakPtr(formattingContextRoot))
+ , m_formattingState(formattingState)
{
}
@@ -52,6 +53,16 @@
{
}
+FormattingState& FormattingContext::formattingState() const
+{
+ return m_formattingState;
+}
+
+LayoutState& FormattingContext::layoutState() const
+{
+ return m_formattingState.layoutState();
+}
+
void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox) const
{
auto compute = [&](std::optional<LayoutUnit> usedWidth) {
Modified: trunk/Source/WebCore/layout/FormattingContext.h (237632 => 237633)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -28,7 +28,6 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "DisplayBox.h"
-#include "FloatingState.h"
#include <wtf/IsoMalloc.h>
#include <wtf/WeakPtr.h>
@@ -47,7 +46,7 @@
class FormattingContext {
WTF_MAKE_ISO_ALLOCATED(FormattingContext);
public:
- FormattingContext(const Box& formattingContextRoot);
+ FormattingContext(const Box& formattingContextRoot, FormattingState&);
virtual ~FormattingContext();
virtual void layout(LayoutState&, FormattingState&) const = 0;
@@ -66,6 +65,8 @@
protected:
using LayoutQueue = Vector<const Box*>;
+ FormattingState& formattingState() const;
+ LayoutState& layoutState() const;
const Box& root() const { return *m_root; }
virtual void computeStaticPosition(const LayoutState&, const Box&) const = 0;
@@ -126,6 +127,7 @@
void computeOutOfFlowHorizontalGeometry(LayoutState&, const Box&) const;
WeakPtr<const Box> m_root;
+ FormattingState& m_formattingState;
};
}
Modified: trunk/Source/WebCore/layout/FormattingState.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/FormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/FormattingState.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -35,7 +35,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingState);
-FormattingState::FormattingState(Ref<FloatingState>&& floatingState, Type type, const LayoutState& layoutState)
+FormattingState::FormattingState(Ref<FloatingState>&& floatingState, Type type, LayoutState& layoutState)
: m_layoutState(layoutState)
, m_floatingState(WTFMove(floatingState))
, m_type(type)
Modified: trunk/Source/WebCore/layout/FormattingState.h (237632 => 237633)
--- trunk/Source/WebCore/layout/FormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/FormattingState.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -46,7 +46,7 @@
public:
virtual ~FormattingState();
- virtual std::unique_ptr<FormattingContext>formattingContext(const Box& formattingContextRoot) const = 0;
+ virtual std::unique_ptr<FormattingContext>formattingContext(const Box& formattingContextRoot) = 0;
FloatingState& floatingState() const { return m_floatingState; }
@@ -60,13 +60,14 @@
bool isBlockFormattingState() const { return m_type == Type::Block; }
bool isInlineFormattingState() const { return m_type == Type::Inline; }
+ LayoutState& layoutState() const { return m_layoutState; }
+
protected:
enum class Type { Block, Inline };
- FormattingState(Ref<FloatingState>&&, Type, const LayoutState&);
+ FormattingState(Ref<FloatingState>&&, Type, LayoutState&);
- const LayoutState& m_layoutState;
-
private:
+ LayoutState& m_layoutState;
Ref<FloatingState> m_floatingState;
HashMap<const Box*, FormattingContext::InstrinsicWidthConstraints> m_instrinsicWidthConstraints;
Type m_type;
Modified: trunk/Source/WebCore/layout/LayoutFormattingState.h (237632 => 237633)
--- trunk/Source/WebCore/layout/LayoutFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/LayoutFormattingState.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -27,7 +27,6 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "FormattingContext.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/IsoMalloc.h>
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -44,8 +44,8 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext);
-BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot)
- : FormattingContext(formattingContextRoot)
+BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
+ : FormattingContext(formattingContextRoot, formattingState)
{
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (237632 => 237633)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -45,7 +45,7 @@
class BlockFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
public:
- BlockFormattingContext(const Box& formattingContextRoot);
+ BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState);
void layout(LayoutState&, FormattingState&) const override;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -37,7 +37,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingState);
-BlockFormattingState::BlockFormattingState(Ref<FloatingState>&& floatingState, const LayoutState& layoutState)
+BlockFormattingState::BlockFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState)
: FormattingState(WTFMove(floatingState), Type::Block, layoutState)
{
}
@@ -46,10 +46,10 @@
{
}
-std::unique_ptr<FormattingContext> BlockFormattingState::formattingContext(const Box& formattingContextRoot) const
+std::unique_ptr<FormattingContext> BlockFormattingState::formattingContext(const Box& formattingContextRoot)
{
ASSERT(formattingContextRoot.establishesBlockFormattingContext());
- return std::make_unique<BlockFormattingContext>(formattingContextRoot);
+ return std::make_unique<BlockFormattingContext>(formattingContextRoot, *this);
}
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h (237632 => 237633)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -38,10 +38,10 @@
class BlockFormattingState : public FormattingState {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingState);
public:
- BlockFormattingState(Ref<FloatingState>&&, const LayoutState&);
+ BlockFormattingState(Ref<FloatingState>&&, LayoutState&);
virtual ~BlockFormattingState();
- std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
+ std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) override;
};
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -46,8 +46,8 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);
-InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot)
- : FormattingContext(formattingContextRoot)
+InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
+ : FormattingContext(formattingContextRoot, formattingState)
{
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (237632 => 237633)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -43,7 +43,7 @@
class InlineFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
public:
- InlineFormattingContext(const Box& formattingContextRoot);
+ InlineFormattingContext(const Box& formattingContextRoot, FormattingState&);
void layout(LayoutState&, FormattingState&) const override;
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp (237632 => 237633)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-10-31 13:50:05 UTC (rev 237633)
@@ -35,7 +35,7 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingState);
-InlineFormattingState::InlineFormattingState(Ref<FloatingState>&& floatingState, const LayoutState& layoutState)
+InlineFormattingState::InlineFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState)
: FormattingState(WTFMove(floatingState), Type::Inline, layoutState)
{
}
@@ -44,10 +44,10 @@
{
}
-std::unique_ptr<FormattingContext> InlineFormattingState::formattingContext(const Box& formattingContextRoot) const
+std::unique_ptr<FormattingContext> InlineFormattingState::formattingContext(const Box& formattingContextRoot)
{
ASSERT(formattingContextRoot.establishesInlineFormattingContext());
- return std::make_unique<InlineFormattingContext>(formattingContextRoot);
+ return std::make_unique<InlineFormattingContext>(formattingContextRoot, this);
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (237632 => 237633)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-31 13:43:03 UTC (rev 237632)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-10-31 13:50:05 UTC (rev 237633)
@@ -39,10 +39,10 @@
class InlineFormattingState : public FormattingState {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingState);
public:
- InlineFormattingState(Ref<FloatingState>&&, const LayoutState&);
+ InlineFormattingState(Ref<FloatingState>&&, LayoutState&);
virtual ~InlineFormattingState();
- std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
+ std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) override;
InlineContent& inlineContent() { return m_inlineContent; }
// Temp