Diff
Modified: trunk/Source/WebCore/ChangeLog (231027 => 231028)
--- trunk/Source/WebCore/ChangeLog 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/ChangeLog 2018-04-25 22:54:01 UTC (rev 231028)
@@ -1,3 +1,54 @@
+2018-04-25 Zalan Bujtas <[email protected]>
+
+ [LFC] Implement LayoutContexet::layout() and its dependencies.
+ https://bugs.webkit.org/show_bug.cgi?id=184951
+
+ Reviewed by Antti Koivisto.
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::FormattingContext):
+ (WebCore::Layout::FormattingContext::~FormattingContext):
+ (WebCore::Layout::FormattingContext::computeStaticPosition):
+ (WebCore::Layout::FormattingContext::computeInFlowPositionedPosition):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowPosition):
+ (WebCore::Layout::FormattingContext::computeWidth):
+ (WebCore::Layout::FormattingContext::computeHeight):
+ (WebCore::Layout::FormattingContext::marginTop):
+ (WebCore::Layout::FormattingContext::marginLeft):
+ (WebCore::Layout::FormattingContext::marginBottom):
+ (WebCore::Layout::FormattingContext::marginRight):
+ * layout/FormattingContext.h:
+ * layout/FormattingState.cpp:
+ (WebCore::Layout::FormattingState::FormattingState):
+ * layout/FormattingState.h:
+ * layout/LayoutContext.cpp:
+ (WebCore::Layout::LayoutContext::LayoutContext):
+ (WebCore::Layout::LayoutContext::updateLayout):
+ (WebCore::Layout::LayoutContext::formattingState):
+ (WebCore::Layout::LayoutContext::formattingContext):
+ * layout/LayoutContext.h:
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
+ (WebCore::Layout::BlockFormattingContext::layout):
+ (WebCore::Layout::BlockFormattingContext::formattingState const):
+ (WebCore::Layout::BlockFormattingContext::computeStaticPosition):
+ (WebCore::Layout::BlockFormattingContext::computeWidth):
+ (WebCore::Layout::BlockFormattingContext::computeHeight):
+ (WebCore::Layout::BlockFormattingContext::marginTop):
+ (WebCore::Layout::BlockFormattingContext::marginBottom):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingState.cpp:
+ (WebCore::Layout::BlockFormattingState::BlockFormattingState):
+ * layout/blockformatting/BlockFormattingState.h:
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
+ (WebCore::Layout::InlineFormattingContext::layout):
+ (WebCore::Layout::InlineFormattingContext::formattingState const):
+ * layout/inlineformatting/InlineFormattingContext.h:
+ * layout/inlineformatting/InlineFormattingState.cpp:
+ (WebCore::Layout::InlineFormattingState::InlineFormattingState):
+ * layout/inlineformatting/InlineFormattingState.h:
+
2018-04-25 Mark Lam <[email protected]>
Push the definition of PtrTag down to the WTF layer.
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,65 @@
#include "config.h"
#include "FormattingContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
+
+FormattingContext::FormattingContext(Box& formattingContextRoot)
+ : m_root(makeWeakPtr(formattingContextRoot))
+{
+}
+
+FormattingContext::~FormattingContext()
+{
+}
+
+void FormattingContext::computeStaticPosition(const Box&) const
+{
+}
+
+void FormattingContext::computeInFlowPositionedPosition(const Box&) const
+{
+}
+
+void FormattingContext::computeOutOfFlowPosition(const Box&) const
+{
+}
+
+void FormattingContext::computeWidth(const Box&) const
+{
+}
+
+void FormattingContext::computeHeight(const Box&) const
+{
+}
+
+LayoutUnit FormattingContext::marginTop(const Box&) const
+{
+ return 0;
+}
+
+LayoutUnit FormattingContext::marginLeft(const Box&) const
+{
+ return 0;
+}
+
+LayoutUnit FormattingContext::marginBottom(const Box&) const
+{
+ return 0;
+}
+
+LayoutUnit FormattingContext::marginRight(const Box&) const
+{
+ return 0;
+}
+
+}
+}
+#endif
Modified: trunk/Source/WebCore/layout/FormattingContext.h (231027 => 231028)
--- trunk/Source/WebCore/layout/FormattingContext.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -29,6 +29,7 @@
#include "LayoutUnit.h"
#include <wtf/IsoMalloc.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -40,25 +41,29 @@
class FormattingContext {
WTF_MAKE_ISO_ALLOCATED(FormattingContext);
public:
- FormattingContext(FormattingState&);
+ FormattingContext(Box& formattingContextRoot);
virtual ~FormattingContext();
- virtual void layout();
+ virtual void layout(FormattingState&) = 0;
+ virtual std::unique_ptr<FormattingState> formattingState() const = 0;
- FormattingState& formattingState() const;
+ const Box& root() const { return *m_root; }
protected:
- virtual void computeStaticPosition(const Box&);
- virtual void computeInFlowPositionedPosition(const Box&);
- virtual void computeOutOfFlowPosition(const Box&);
+ virtual void computeStaticPosition(const Box&) const;
+ virtual void computeInFlowPositionedPosition(const Box&) const;
+ virtual void computeOutOfFlowPosition(const Box&) const;
- virtual void computeWidth(const Box&);
- virtual void computeHeight(const Box&);
+ virtual void computeWidth(const Box&) const;
+ virtual void computeHeight(const Box&) const;
- virtual LayoutUnit marginTop(const Box&);
- virtual LayoutUnit marginLeft(const Box&);
- virtual LayoutUnit marginBottom(const Box&);
- virtual LayoutUnit marginRight(const Box&);
+ virtual LayoutUnit marginTop(const Box&) const;
+ virtual LayoutUnit marginLeft(const Box&) const;
+ virtual LayoutUnit marginBottom(const Box&) const;
+ virtual LayoutUnit marginRight(const Box&) const;
+
+private:
+ WeakPtr<Box> m_root;
};
}
Modified: trunk/Source/WebCore/layout/FormattingState.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/FormattingState.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/FormattingState.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,20 @@
#include "config.h"
#include "FormattingState.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingState);
+
+FormattingState::FormattingState()
+{
+}
+
+}
+}
+#endif
Modified: trunk/Source/WebCore/layout/FormattingState.h (231027 => 231028)
--- trunk/Source/WebCore/layout/FormattingState.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/FormattingState.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -34,18 +34,14 @@
namespace Layout {
class Box;
-class Container;
class FloatingState;
-class LayoutState;
class StyleDiff;
class FormattingState {
WTF_MAKE_ISO_ALLOCATED(FormattingState);
public:
- FormattingState(Container& formattingRoot, LayoutState&);
+ FormattingState();
- Container& formattingRoot() const;
- LayoutState& layoutState() const;
FloatingState& floatingState();
void markNeedsLayout(const Box&, StyleDiff);
Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/LayoutContext.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,53 @@
#include "config.h"
#include "LayoutContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BlockFormattingContext.h"
+#include "BlockFormattingState.h"
+#include "InlineFormattingContext.h"
+#include "InlineFormattingState.h"
+#include "LayoutBox.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(LayoutContext);
+
+LayoutContext::LayoutContext(Box& root)
+ : m_root(makeWeakPtr(root))
+{
+}
+
+void LayoutContext::updateLayout()
+{
+ auto context = formattingContext(*m_root);
+ auto state = formattingState(*context);
+ context->layout(state);
+}
+
+FormattingState& LayoutContext::formattingState(const FormattingContext& context)
+{
+ return *m_formattingStates.ensure(&context.root(), [&context] {
+ return context.formattingState();
+ }).iterator->value;
+}
+
+std::unique_ptr<FormattingContext> LayoutContext::formattingContext(Box& formattingContextRoot)
+{
+ if (formattingContextRoot.establishesBlockFormattingContext())
+ return std::make_unique<BlockFormattingContext>(formattingContextRoot);
+
+ if (formattingContextRoot.establishesInlineFormattingContext())
+ return std::make_unique<InlineFormattingContext>(formattingContextRoot);
+
+ ASSERT_NOT_REACHED();
+ return nullptr;
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/LayoutContext.h (231027 => 231028)
--- trunk/Source/WebCore/layout/LayoutContext.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/LayoutContext.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -27,6 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "LayoutBox.h"
#include <wtf/IsoMalloc.h>
namespace WebCore {
@@ -37,8 +38,6 @@
namespace Layout {
-class Box;
-class Container;
class FormattingContext;
class FormattingState;
class StyleDiff;
@@ -51,20 +50,22 @@
class LayoutContext {
WTF_MAKE_ISO_ALLOCATED(LayoutContext);
public:
- LayoutContext(const Container& rootContainer);
+ LayoutContext(Box& root);
- void layout();
+ void updateLayout();
- Container& rootContainer() const;
- FormattingContext& formattingContext(const Container& formattingRoot) const;
- FormattingState& establishedFormattingState(const Container& formattingRoot);
- FormattingState& formattingState(const Box&);
-
void addDisplayBox(const Box&, Display::Box&);
Display::Box* displayBox(const Box&) const;
void markNeedsLayout(const Box&, StyleDiff);
bool needsLayout(const Box&) const;
+
+private:
+ FormattingState& formattingState(const FormattingContext&);
+ std::unique_ptr<FormattingContext> formattingContext(Box& formattingContextRoot);
+
+ WeakPtr<Box> m_root;
+ HashMap<const Box*, std::unique_ptr<FormattingState>> m_formattingStates;
};
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,54 @@
#include "config.h"
#include "BlockFormattingContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "BlockFormattingState.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext);
+
+BlockFormattingContext::BlockFormattingContext(Box& formattingContextRoot)
+ : FormattingContext(formattingContextRoot)
+{
+}
+
+void BlockFormattingContext::layout(FormattingState&)
+{
+}
+
+std::unique_ptr<FormattingState> BlockFormattingContext::formattingState() const
+{
+ return std::make_unique<BlockFormattingState>();
+}
+
+void BlockFormattingContext::computeStaticPosition(const Box&) const
+{
+}
+
+void BlockFormattingContext::computeWidth(const Box&) const
+{
+}
+
+void BlockFormattingContext::computeHeight(const Box&) const
+{
+}
+
+LayoutUnit BlockFormattingContext::marginTop(const Box&) const
+{
+ return 0;
+}
+
+LayoutUnit BlockFormattingContext::marginBottom(const Box&) const
+{
+ return 0;
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (231027 => 231028)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -43,18 +43,19 @@
class BlockFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
public:
- BlockFormattingContext(BlockFormattingState&);
+ BlockFormattingContext(Box& formattingContextRoot);
- void layout() override;
+ void layout(FormattingState&) override;
+ std::unique_ptr<FormattingState> formattingState() const override;
protected:
- void computeStaticPosition(const Box&) override;
+ void computeStaticPosition(const Box&) const override;
- void computeWidth(const Box&) override;
- void computeHeight(const Box&) override;
+ void computeWidth(const Box&) const override;
+ void computeHeight(const Box&) const override;
- LayoutUnit marginTop(const Box&) override;
- LayoutUnit marginBottom(const Box&) override;
+ LayoutUnit marginTop(const Box&) const override;
+ LayoutUnit marginBottom(const Box&) const override;
};
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,21 @@
#include "config.h"
#include "BlockFormattingState.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingState);
+
+BlockFormattingState::BlockFormattingState()
+ : FormattingState()
+{
+}
+
+}
+}
+#endif
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h (231027 => 231028)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -34,14 +34,11 @@
namespace Layout {
-class Container;
-class LayoutState;
-
// BlockFormattingState holds the state for a particular block formatting context tree.
class BlockFormattingState : public FormattingState {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingState);
public:
- BlockFormattingState(Layout::Container& formattingRoot, LayoutState&);
+ BlockFormattingState();
};
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,32 @@
#include "config.h"
#include "InlineFormattingContext.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineFormattingState.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);
+
+InlineFormattingContext::InlineFormattingContext(Box& formattingContextRoot)
+ : FormattingContext(formattingContextRoot)
+{
+}
+
+void InlineFormattingContext::layout(FormattingState&)
+{
+}
+
+std::unique_ptr<FormattingState> InlineFormattingContext::formattingState() const
+{
+ return std::make_unique<InlineFormattingState>();
+}
+
+}
+}
+
+#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (231027 => 231028)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -41,9 +41,10 @@
class InlineFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
public:
- InlineFormattingContext(InlineFormattingState&);
+ InlineFormattingContext(Box& formattingContextRoot);
- void layout() override;
+ void layout(FormattingState&) override;
+ std::unique_ptr<FormattingState> formattingState() const override;
};
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp (231027 => 231028)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp 2018-04-25 22:54:01 UTC (rev 231028)
@@ -25,3 +25,21 @@
#include "config.h"
#include "InlineFormattingState.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingState);
+
+InlineFormattingState::InlineFormattingState()
+ : FormattingState()
+{
+}
+
+}
+}
+#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (231027 => 231028)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-04-25 22:31:13 UTC (rev 231027)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h 2018-04-25 22:54:01 UTC (rev 231028)
@@ -34,14 +34,11 @@
namespace Layout {
-class Container;
-class LayoutState;
-
// InlineFormattingState holds the state for a particular inline formatting context tree.
class InlineFormattingState : public FormattingState {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingState);
public:
- InlineFormattingState(Layout::Container& formattingRoot, LayoutState&);
+ InlineFormattingState();
};
}