| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NGLayoutAlgorithm_h | 5 #ifndef NGLayoutAlgorithm_h |
| 6 #define NGLayoutAlgorithm_h | 6 #define NGLayoutAlgorithm_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/heap/Handle.h" | |
| 10 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 11 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
| 12 | 11 |
| 13 namespace blink { | 12 namespace blink { |
| 14 | 13 |
| 15 struct MinAndMaxContentSizes; | 14 struct MinAndMaxContentSizes; |
| 16 class NGConstraintSpace; | |
| 17 class NGPhysicalFragment; | 15 class NGPhysicalFragment; |
| 18 | 16 |
| 19 enum NGLayoutStatus { kNotFinished, kChildAlgorithmRequired, kNewFragment }; | |
| 20 | |
| 21 enum NGLayoutAlgorithmType { | |
| 22 kBlockLayoutAlgorithm, | |
| 23 kInlineLayoutAlgorithm, | |
| 24 kLegacyBlockLayoutAlgorithm, | |
| 25 kTextLayoutAlgorithm | |
| 26 }; | |
| 27 | |
| 28 // Base class for all LayoutNG algorithms. | 17 // Base class for all LayoutNG algorithms. |
| 29 class CORE_EXPORT NGLayoutAlgorithm | 18 class CORE_EXPORT NGLayoutAlgorithm { |
| 30 : public GarbageCollectedFinalized<NGLayoutAlgorithm> { | 19 STACK_ALLOCATED(); |
| 31 WTF_MAKE_NONCOPYABLE(NGLayoutAlgorithm); | |
| 32 | 20 |
| 33 public: | 21 public: |
| 34 NGLayoutAlgorithm(NGLayoutAlgorithmType type) : type_(type) {} | |
| 35 virtual ~NGLayoutAlgorithm() {} | 22 virtual ~NGLayoutAlgorithm() {} |
| 36 | 23 |
| 37 // Actual layout function. Lays out the children and descendents within the | 24 // Actual layout function. Lays out the children and descendents within the |
| 38 // constraints given by the NGConstraintSpace. Returns a fragment with the | 25 // constraints given by the NGConstraintSpace. Returns a fragment with the |
| 39 // resulting layout information. | 26 // resulting layout information. |
| 40 // TODO(layout-dev): attempt to make this function const. | 27 // TODO(layout-dev): attempt to make this function const. |
| 41 virtual NGPhysicalFragment* Layout() = 0; | 28 virtual NGPhysicalFragment* Layout() = 0; |
| 42 | 29 |
| 43 enum MinAndMaxState { kSuccess, kPending, kNotImplemented }; | |
| 44 | |
| 45 // Computes the min-content and max-content intrinsic sizes for the given box. | 30 // Computes the min-content and max-content intrinsic sizes for the given box. |
| 46 // The result will not take any min-width, max-width or width properties into | 31 // The result will not take any min-width, max-width or width properties into |
| 47 // account. Implementations can return false, in which case the caller is | 32 // account. Implementations can return false, in which case the caller is |
| 48 // expected to synthesize this value from the overflow rect returned from | 33 // expected to synthesize this value from the overflow rect returned from |
| 49 // Layout called with a available width of 0 and LayoutUnit::max(), | 34 // Layout called with a available width of 0 and LayoutUnit::max(), |
| 50 // respectively. | 35 // respectively. |
| 51 virtual bool ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) const { | 36 virtual bool ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) const { |
| 52 return false; | 37 return false; |
| 53 } | 38 } |
| 54 | |
| 55 DEFINE_INLINE_VIRTUAL_TRACE() {} | |
| 56 | |
| 57 NGLayoutAlgorithmType algorithmType() const { return type_; } | |
| 58 | |
| 59 private: | |
| 60 NGLayoutAlgorithmType type_; | |
| 61 }; | 39 }; |
| 62 | 40 |
| 63 } // namespace blink | 41 } // namespace blink |
| 64 | 42 |
| 65 #endif // NGLayoutAlgorithm_h | 43 #endif // NGLayoutAlgorithm_h |
| OLD | NEW |