⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 237633 in webkit


Ignore:
Timestamp:
Oct 31, 2018, 6:50:05 AM (8 years ago)
Author:
Alan Bujtas
Message:

[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:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r237632 r237633  
     12018-10-31  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] FormattingContext class should take FormattingState&
     4        https://bugs.webkit.org/show_bug.cgi?id=191099
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for not passing LayoutState& into every layout functions.
     9        FormattingContext has FormattingState now and LayoutState can be acquired through FormattingState.
     10        LayoutState <- FormattingState <- FormattingContext
     11
     12        * layout/FormattingContext.cpp:
     13        (WebCore::Layout::FormattingContext::FormattingContext):
     14        (WebCore::Layout::FormattingContext::formattingState const):
     15        (WebCore::Layout::FormattingContext::layoutState const):
     16        * layout/FormattingContext.h:
     17        * layout/FormattingState.cpp:
     18        (WebCore::Layout::FormattingState::FormattingState):
     19        * layout/FormattingState.h:
     20        (WebCore::Layout::FormattingState::layoutState const):
     21        * layout/LayoutFormattingState.h:
     22        * layout/blockformatting/BlockFormattingContext.cpp:
     23        (WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
     24        * layout/blockformatting/BlockFormattingContext.h:
     25        * layout/blockformatting/BlockFormattingState.cpp:
     26        (WebCore::Layout::BlockFormattingState::BlockFormattingState):
     27        (WebCore::Layout::BlockFormattingState::formattingContext):
     28        (WebCore::Layout::BlockFormattingState::formattingContext const): Deleted.
     29        * layout/blockformatting/BlockFormattingState.h:
     30        * layout/inlineformatting/InlineFormattingContext.cpp:
     31        (WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
     32        * layout/inlineformatting/InlineFormattingContext.h:
     33        * layout/inlineformatting/InlineFormattingState.cpp:
     34        (WebCore::Layout::InlineFormattingState::InlineFormattingState):
     35        (WebCore::Layout::InlineFormattingState::formattingContext):
     36        (WebCore::Layout::InlineFormattingState::formattingContext const): Deleted.
     37        * layout/inlineformatting/InlineFormattingState.h:
     38
    1392018-10-31  Zalan Bujtas  <zalan@apple.com>
    240
  • trunk/Source/WebCore/layout/FormattingContext.cpp

    r237632 r237633  
    4444WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
    4545
    46 FormattingContext::FormattingContext(const Box& formattingContextRoot)
     46FormattingContext::FormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
    4747    : m_root(makeWeakPtr(formattingContextRoot))
     48    , m_formattingState(formattingState)
    4849{
    4950}
     
    5152FormattingContext::~FormattingContext()
    5253{
     54}
     55
     56FormattingState& FormattingContext::formattingState() const
     57{
     58    return m_formattingState;
     59}
     60
     61LayoutState& FormattingContext::layoutState() const
     62{
     63    return m_formattingState.layoutState();
    5364}
    5465
  • trunk/Source/WebCore/layout/FormattingContext.h

    r237631 r237633  
    2929
    3030#include "DisplayBox.h"
    31 #include "FloatingState.h"
    3231#include <wtf/IsoMalloc.h>
    3332#include <wtf/WeakPtr.h>
     
    4847    WTF_MAKE_ISO_ALLOCATED(FormattingContext);
    4948public:
    50     FormattingContext(const Box& formattingContextRoot);
     49    FormattingContext(const Box& formattingContextRoot, FormattingState&);
    5150    virtual ~FormattingContext();
    5251
     
    6766    using LayoutQueue = Vector<const Box*>;
    6867
     68    FormattingState& formattingState() const;
     69    LayoutState& layoutState() const;
    6970    const Box& root() const { return *m_root; }
    7071
     
    127128
    128129    WeakPtr<const Box> m_root;
     130    FormattingState& m_formattingState;
    129131};
    130132
  • trunk/Source/WebCore/layout/FormattingState.cpp

    r237631 r237633  
    3636WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingState);
    3737
    38 FormattingState::FormattingState(Ref<FloatingState>&& floatingState, Type type, const LayoutState& layoutState)
     38FormattingState::FormattingState(Ref<FloatingState>&& floatingState, Type type, LayoutState& layoutState)
    3939    : m_layoutState(layoutState)
    4040    , m_floatingState(WTFMove(floatingState))
  • trunk/Source/WebCore/layout/FormattingState.h

    r237632 r237633  
    4747    virtual ~FormattingState();
    4848
    49     virtual std::unique_ptr<FormattingContext>formattingContext(const Box& formattingContextRoot) const = 0;
     49    virtual std::unique_ptr<FormattingContext>formattingContext(const Box& formattingContextRoot) = 0;
    5050
    5151    FloatingState& floatingState() const { return m_floatingState; }
     
    6161    bool isInlineFormattingState() const { return m_type == Type::Inline; }
    6262
     63    LayoutState& layoutState() const { return m_layoutState; }
     64
    6365protected:
    6466    enum class Type { Block, Inline };
    65     FormattingState(Ref<FloatingState>&&, Type, const LayoutState&);
    66 
    67     const LayoutState& m_layoutState;
     67    FormattingState(Ref<FloatingState>&&, Type, LayoutState&);
    6868
    6969private:
     70    LayoutState& m_layoutState;
    7071    Ref<FloatingState> m_floatingState;
    7172    HashMap<const Box*, FormattingContext::InstrinsicWidthConstraints> m_instrinsicWidthConstraints;
  • trunk/Source/WebCore/layout/LayoutFormattingState.h

    r237632 r237633  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "FormattingContext.h"
    3130#include <wtf/HashMap.h>
    3231#include <wtf/HashSet.h>
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp

    r237632 r237633  
    4545WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext);
    4646
    47 BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot)
    48     : FormattingContext(formattingContextRoot)
     47BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
     48    : FormattingContext(formattingContextRoot, formattingState)
    4949{
    5050}
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r237631 r237633  
    4646    WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
    4747public:
    48     BlockFormattingContext(const Box& formattingContextRoot);
     48    BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState);
    4949
    5050    void layout(LayoutState&, FormattingState&) const override;
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp

    r237632 r237633  
    3838WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingState);
    3939
    40 BlockFormattingState::BlockFormattingState(Ref<FloatingState>&& floatingState, const LayoutState& layoutState)
     40BlockFormattingState::BlockFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState)
    4141    : FormattingState(WTFMove(floatingState), Type::Block, layoutState)
    4242{
     
    4747}
    4848
    49 std::unique_ptr<FormattingContext> BlockFormattingState::formattingContext(const Box& formattingContextRoot) const
     49std::unique_ptr<FormattingContext> BlockFormattingState::formattingContext(const Box& formattingContextRoot)
    5050{
    5151    ASSERT(formattingContextRoot.establishesBlockFormattingContext());
    52     return std::make_unique<BlockFormattingContext>(formattingContextRoot);
     52    return std::make_unique<BlockFormattingContext>(formattingContextRoot, *this);
    5353}
    5454
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h

    r237632 r237633  
    3939    WTF_MAKE_ISO_ALLOCATED(BlockFormattingState);
    4040public:
    41     BlockFormattingState(Ref<FloatingState>&&, const LayoutState&);
     41    BlockFormattingState(Ref<FloatingState>&&, LayoutState&);
    4242    virtual ~BlockFormattingState();
    4343
    44     std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
     44    std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) override;
    4545};
    4646
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp

    r237632 r237633  
    4747WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);
    4848
    49 InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot)
    50     : FormattingContext(formattingContextRoot)
     49InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
     50    : FormattingContext(formattingContextRoot, formattingState)
    5151{
    5252}
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h

    r237631 r237633  
    4444    WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
    4545public:
    46     InlineFormattingContext(const Box& formattingContextRoot);
     46    InlineFormattingContext(const Box& formattingContextRoot, FormattingState&);
    4747
    4848    void layout(LayoutState&, FormattingState&) const override;
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.cpp

    r237632 r237633  
    3636WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingState);
    3737
    38 InlineFormattingState::InlineFormattingState(Ref<FloatingState>&& floatingState, const LayoutState& layoutState)
     38InlineFormattingState::InlineFormattingState(Ref<FloatingState>&& floatingState, LayoutState& layoutState)
    3939    : FormattingState(WTFMove(floatingState), Type::Inline, layoutState)
    4040{
     
    4545}
    4646
    47 std::unique_ptr<FormattingContext> InlineFormattingState::formattingContext(const Box& formattingContextRoot) const
     47std::unique_ptr<FormattingContext> InlineFormattingState::formattingContext(const Box& formattingContextRoot)
    4848{
    4949    ASSERT(formattingContextRoot.establishesInlineFormattingContext());
    50     return std::make_unique<InlineFormattingContext>(formattingContextRoot);
     50    return std::make_unique<InlineFormattingContext>(formattingContextRoot, this);
    5151}
    5252
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h

    r237632 r237633  
    4040    WTF_MAKE_ISO_ALLOCATED(InlineFormattingState);
    4141public:
    42     InlineFormattingState(Ref<FloatingState>&&, const LayoutState&);
     42    InlineFormattingState(Ref<FloatingState>&&, LayoutState&);
    4343    virtual ~InlineFormattingState();
    4444
    45     std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) const override;
     45    std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot) override;
    4646
    4747    InlineContent& inlineContent() { return m_inlineContent; }
Note: See TracChangeset for help on using the changeset viewer.