Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h |
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h |
| index 115d6247b448d717c59b66e7dd9ebaafb087efb6..04f0a0fd4822ba1ac35052c37ac72d6b30471517 100644 |
| --- a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h |
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h |
| @@ -7,7 +7,7 @@ |
| #include "core/CoreExport.h" |
| #include "core/layout/ng/ng_macros.h" |
| -#include "core/layout/ng/ng_physical_constraint_space.h" |
| +#include "core/layout/ng/ng_units.h" |
| #include "core/layout/ng/ng_writing_mode.h" |
| #include "platform/heap/Handle.h" |
| #include "wtf/text/WTFString.h" |
| @@ -20,39 +20,32 @@ class LayoutBox; |
| class NGFragment; |
| class NGLayoutOpportunityIterator; |
| +// TODO(glebl@): unused, delete. |
| +enum NGExclusionType { |
| + NGClearNone = 0, |
| + NGClearFloatLeft = 1, |
| + NGClearFloatRight = 2, |
| + NGClearFragment = 4 |
| +}; |
| + |
| +enum NGFragmentationType { |
| + FragmentNone, |
| + FragmentPage, |
| + FragmentColumn, |
| + FragmentRegion |
| +}; |
| + |
| // The NGConstraintSpace represents a set of constraints and available space |
| -// which a layout algorithm may produce a NGFragment within. It is a view on |
| -// top of a NGPhysicalConstraintSpace and provides accessor methods in the |
| -// logical coordinate system defined by the writing mode given. |
| +// which a layout algorithm may produce a NGFragment within. |
| class CORE_EXPORT NGConstraintSpace final |
| - : public GarbageCollected<NGConstraintSpace> { |
| + : public GarbageCollectedFinalized<NGConstraintSpace> { |
| public: |
| - // Constructs a constraint space based on an existing backing |
| - // NGPhysicalConstraintSpace. Sets this constraint space's size to the |
| - // physical constraint space's available size, converted to logical |
| - // coordinates. |
| - NGConstraintSpace(NGWritingMode, TextDirection, NGPhysicalConstraintSpace*); |
| - |
| // This should live on NGBlockNode or another layout bridge and probably take |
| - // a root |
| - // NGConstraintSpace or a NGPhysicalConstraintSpace. |
| + // a root NGConstraintSpace. |
| static NGConstraintSpace* CreateFromLayoutObject(const LayoutBox&); |
| - // Mutable Getters. |
| - // TODO(layout-dev): remove const constraint from MutablePhysicalSpace method |
| - NGPhysicalConstraintSpace* MutablePhysicalSpace() const { |
| - return physical_space_; |
| - } |
| - |
| - // Read-only Getters. |
| - const NGPhysicalConstraintSpace* PhysicalSpace() const { |
| - return physical_space_; |
| - } |
| - |
| - const Vector<std::unique_ptr<const NGExclusion>>& Exclusions() const { |
| - WRITING_MODE_IGNORED( |
| - "Exclusions are stored directly in physical constraint space."); |
| - return PhysicalSpace()->Exclusions(); |
| + const std::shared_ptr<NGExclusions>& Exclusions() const { |
| + return exclusions_; |
| } |
| TextDirection Direction() const { |
| @@ -63,18 +56,24 @@ class CORE_EXPORT NGConstraintSpace final |
| return static_cast<NGWritingMode>(writing_mode_); |
| } |
| - // Adds the exclusion in the physical constraint space. |
| - void AddExclusion(const NGExclusion& exclusion) const; |
| - const NGExclusion* LastLeftFloatExclusion() const; |
| - const NGExclusion* LastRightFloatExclusion() const; |
| + void AddExclusion(const NGExclusion& exclusion); |
| // The size to use for percentage resolution. |
| // See: https://drafts.csswg.org/css-sizing/#percentage-sizing |
| - NGLogicalSize PercentageResolutionSize() const; |
| + NGLogicalSize PercentageResolutionSize() const { |
| + return percentage_resolution_size_; |
| + } |
| + |
| + void SetPercentageResolutionSize( |
| + const NGLogicalSize& percentage_resolution_size) { |
| + percentage_resolution_size_ = percentage_resolution_size; |
| + } |
| // The available space size. |
| // See: https://drafts.csswg.org/css-sizing/#available |
| - NGLogicalSize AvailableSize() const; |
| + NGLogicalSize AvailableSize() const { return available_size_; } |
| + |
| + void SetAvailableSize(const NGLogicalSize& size) { available_size_ = size; } |
| // Offset relative to the root constraint space. |
| NGLogicalOffset Offset() const { return offset_; } |
| @@ -82,21 +81,47 @@ class CORE_EXPORT NGConstraintSpace final |
| // Whether the current constraint space is for the newly established |
| // Formatting Context. |
| - bool IsNewFormattingContext() const; |
| + bool IsNewFormattingContext() const { return is_new_fc_; } |
| // Whether exceeding the AvailableSize() triggers the presence of a scrollbar |
| // for the indicated direction. |
| // If exceeded the current layout should be aborted and invoked again with a |
| // constraint space modified to reserve space for a scrollbar. |
| - bool InlineTriggersScrollbar() const; |
| - bool BlockTriggersScrollbar() const; |
| + bool IsInlineDirectionTriggersScrollbar() const { |
| + return is_inline_direction_triggers_scrollbar_; |
| + } |
| + |
| + bool SetIsInlineDirectionTriggersScrollbar( |
|
ikilpatrick
2016/11/23 17:40:38
we don't need the setters any more?
Gleb Lanbin
2016/11/23 18:59:50
Done.
|
| + bool is_inline_direction_triggers_scrollbar) { |
| + return is_inline_direction_triggers_scrollbar_ = |
| + is_inline_direction_triggers_scrollbar; |
| + } |
| + |
| + bool IsBlockDirectionTriggersScrollbar() const { |
| + return is_block_direction_triggers_scrollbar_; |
| + } |
| + |
| + bool SetIsBlockDirectionTriggersScrollbar( |
| + bool is_block_direction_triggers_scrollbar) { |
| + return is_block_direction_triggers_scrollbar_ = |
| + is_block_direction_triggers_scrollbar; |
| + } |
| // Some layout modes “stretch” their children to a fixed size (e.g. flex, |
| // grid). These flags represented whether a layout needs to produce a |
| // fragment that satisfies a fixed constraint in the inline and block |
| // direction respectively. |
| - bool FixedInlineSize() const; |
| - bool FixedBlockSize() const; |
| + bool IsFixedSizeInline() const { return is_fixed_size_inline_; } |
| + |
| + void SetIsFixedSizeInline(bool is_fixed_size_inline) { |
| + is_fixed_size_inline_ = is_fixed_size_inline; |
| + } |
| + |
| + bool IsFixedSizeBlock() const { return is_fixed_size_block_; } |
| + |
| + void SetIsFixedSizeBlock(bool is_fixed_size_block) { |
| + is_fixed_size_block_ = is_fixed_size_block; |
| + } |
| // If specified a layout should produce a Fragment which fragments at the |
| // blockSize if possible. |
| @@ -111,17 +136,46 @@ class CORE_EXPORT NGConstraintSpace final |
| unsigned clear = NGClearNone, |
| bool for_inline_or_bfc = false); |
| - DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(physical_space_); } |
| + DEFINE_INLINE_VIRTUAL_TRACE() {} |
| NGConstraintSpace* ChildSpace(const ComputedStyle* style) const; |
|
ikilpatrick
2016/11/23 17:40:38
I assume this method is going away, add todo?
Gleb Lanbin
2016/11/23 18:59:50
is it? I'm not aware about this. Can you provide a
|
| - |
| String ToString() const; |
| private: |
| - Member<NGPhysicalConstraintSpace> physical_space_; |
| + friend class NGConstraintSpaceBuilder; |
| + // Default constructor. |
| + NGConstraintSpace(NGWritingMode, |
| + TextDirection, |
| + NGLogicalSize available_size, |
| + NGLogicalSize percentage_resolution_size, |
| + bool is_fixed_size_inline, |
| + bool is_fixed_size_block, |
| + bool is_inline_direction_triggers_scrollbar, |
| + bool is_block_direction_triggers_scrollbar, |
| + NGFragmentationType block_direction_fragmentation_type, |
| + bool is_new_fc, |
| + const std::shared_ptr<NGExclusions>& exclusions_); |
| + |
| + NGLogicalSize available_size_; |
| + NGLogicalSize percentage_resolution_size_; |
| + |
| + unsigned is_fixed_size_inline_ : 1; |
| + unsigned is_fixed_size_block_ : 1; |
| + |
| + unsigned is_inline_direction_triggers_scrollbar_ : 1; |
| + unsigned is_block_direction_triggers_scrollbar_ : 1; |
| + |
| + unsigned block_direction_fragmentation_type_ : 2; |
| + |
| + // Whether the current constraint space is for the newly established |
| + // formatting Context |
| + unsigned is_new_fc_ : 1; |
| + |
| NGLogicalOffset offset_; |
| unsigned writing_mode_ : 3; |
| unsigned direction_ : 1; |
| + |
| + const std::shared_ptr<NGExclusions> exclusions_; |
| }; |
| inline std::ostream& operator<<(std::ostream& stream, |