WebKit Bugzilla
Attachment 338796 Details for
Bug 184951
: [LFC] Implement LayoutContexet::layout() and its dependencies.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-184951-20180425143911.patch (text/plain), 18.38 KB, created by
zalan
on 2018-04-25 14:39:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-04-25 14:39:12 PDT
Size:
18.38 KB
patch
obsolete
>Subversion Revision: 231017 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 122bbcd84a5f8265e7866e6b797c87e60d5fec8f..b1cbdb63de666ddc0f4c1e55eae8ab3d1a711cd7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,54 @@ >+2018-04-25 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Implement LayoutContexet::layout() and its dependencies. >+ https://bugs.webkit.org/show_bug.cgi?id=184951 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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 Zalan Bujtas <zalan@apple.com> > > [LFC] Implement Layout::BlockContainer functions. >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 51a92b47aeb86a5ac06d280bb4c0b8816b25571d..9855bad4295e7a9b5c8bdf5f2c87d3f41b14d4ec 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -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 >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 87f39d74fccb4adf81ffb45e997eab9c2bf343be..e86cff92d2775a3057774837b294f04ee7f81d51 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -29,6 +29,7 @@ > > #include "LayoutUnit.h" > #include <wtf/IsoMalloc.h> >+#include <wtf/WeakPtr.h> > > namespace WebCore { > >@@ -40,25 +41,29 @@ class Box; > 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; > }; > > } >diff --git a/Source/WebCore/layout/FormattingState.cpp b/Source/WebCore/layout/FormattingState.cpp >index be0f314194bd94c65fb4f4d50b69923c57a59188..8fa0d438ccf7c53096a38db4c44afc12e410c93f 100644 >--- a/Source/WebCore/layout/FormattingState.cpp >+++ b/Source/WebCore/layout/FormattingState.cpp >@@ -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 >diff --git a/Source/WebCore/layout/FormattingState.h b/Source/WebCore/layout/FormattingState.h >index 7821e7b19c64046599e6787fa20d4f4fda5e43ad..e34c009c3c0631f42baa5b6f2f61c705efba219d 100644 >--- a/Source/WebCore/layout/FormattingState.h >+++ b/Source/WebCore/layout/FormattingState.h >@@ -34,18 +34,14 @@ namespace WebCore { > 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); >diff --git a/Source/WebCore/layout/LayoutContext.cpp b/Source/WebCore/layout/LayoutContext.cpp >index 386b85c9511446e75218f191f37a6d251dcfb56d..e15c3be7a259e28349e7d6e6ea30ab933c8a9522 100644 >--- a/Source/WebCore/layout/LayoutContext.cpp >+++ b/Source/WebCore/layout/LayoutContext.cpp >@@ -25,3 +25,51 @@ > > #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 >diff --git a/Source/WebCore/layout/LayoutContext.h b/Source/WebCore/layout/LayoutContext.h >index 15c84158c5e735922a57d2af1edc9dbf30d1dd93..15007d60a621aa64a0aa9ab4b3d3885f6945a5de 100644 >--- a/Source/WebCore/layout/LayoutContext.h >+++ b/Source/WebCore/layout/LayoutContext.h >@@ -27,6 +27,7 @@ > > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > >+#include "LayoutBox.h" > #include <wtf/IsoMalloc.h> > > namespace WebCore { >@@ -37,8 +38,6 @@ class Box; > > namespace Layout { > >-class Box; >-class Container; > class FormattingContext; > class FormattingState; > class StyleDiff; >@@ -51,20 +50,22 @@ class StyleDiff; > class LayoutContext { > WTF_MAKE_ISO_ALLOCATED(LayoutContext); > public: >- LayoutContext(const Container& rootContainer); >- >- void layout(); >+ LayoutContext(Box& root); > >- Container& rootContainer() const; >- FormattingContext& formattingContext(const Container& formattingRoot) const; >- FormattingState& establishedFormattingState(const Container& formattingRoot); >- FormattingState& formattingState(const Box&); >+ void updateLayout(); > > 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; > }; > > } >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 397a97d5e93058bdb2b3e848b62a7e03a93c8a9d..d37e1814bbede6d7737dbd0115fccd75f61d1ced 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -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 >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >index 969b85a77eb9810c2a480380d3a2e9d9fedd98a9..f12e7e762d53341ea26ccde7a1d81be9c9fdbbfa 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.h >@@ -43,18 +43,19 @@ class Box; > 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; > }; > > } >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp >index f781853a3a921da96a2ac8e7ec589837ec34d4a2..244d8254acef7f1c3291de976204af82de57fe2c 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp >@@ -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 >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingState.h b/Source/WebCore/layout/blockformatting/BlockFormattingState.h >index 2b37ba2098753002e6d156005a56c9bea999e5d1..5485bda2f68ddeacc14e28bd5c95f1bc74c5633f 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingState.h >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingState.h >@@ -34,14 +34,11 @@ namespace WebCore { > > 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(); > }; > > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index 05f1d82d59f75f15957451183f1b63810754ad47..7d1b76403d9cb43977f35d917bc718d244bb5af6 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -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 >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index 1bbe266cbc2a3965473f7ce5c2ed6534f39a9db0..6026060e9ec4e787f230501649a2dbe898d27125 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -41,9 +41,10 @@ class InlineFormattingState; > 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; > }; > > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp >index 8d73ec5af331306d8aa8f611dc5c4be45e99d201..930a88504192b2f75ac52fd6ec1a8c8a26065640 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp >@@ -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 >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingState.h b/Source/WebCore/layout/inlineformatting/InlineFormattingState.h >index f0ef9e1c56cd5d198e04b9a3a80d3a2820fbb106..ed9bcdadc7844f17e0e7ea861734d05b31ee55bc 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingState.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingState.h >@@ -34,14 +34,11 @@ namespace WebCore { > > 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(); > }; > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 184951
:
338796
|
338808