| 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" | 9 #include "platform/heap/Handle.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| 11 #include "wtf/Noncopyable.h" | 11 #include "wtf/Noncopyable.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 struct MinAndMaxContentSizes; | 15 struct MinAndMaxContentSizes; |
| 16 class NGBlockNode; | 16 class NGBlockNode; |
| 17 class NGConstraintSpace; | 17 class NGConstraintSpace; |
| 18 class NGPhysicalFragmentBase; | 18 class NGPhysicalFragment; |
| 19 | 19 |
| 20 enum NGLayoutStatus { kNotFinished, kChildAlgorithmRequired, kNewFragment }; | 20 enum NGLayoutStatus { kNotFinished, kChildAlgorithmRequired, kNewFragment }; |
| 21 | 21 |
| 22 enum NGLayoutAlgorithmType { | 22 enum NGLayoutAlgorithmType { |
| 23 kBlockLayoutAlgorithm, | 23 kBlockLayoutAlgorithm, |
| 24 kInlineLayoutAlgorithm, | 24 kInlineLayoutAlgorithm, |
| 25 kLegacyBlockLayoutAlgorithm, | 25 kLegacyBlockLayoutAlgorithm, |
| 26 kTextLayoutAlgorithm | 26 kTextLayoutAlgorithm |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Base class for all LayoutNG algorithms. | 29 // Base class for all LayoutNG algorithms. |
| 30 class CORE_EXPORT NGLayoutAlgorithm | 30 class CORE_EXPORT NGLayoutAlgorithm |
| 31 : public GarbageCollectedFinalized<NGLayoutAlgorithm> { | 31 : public GarbageCollectedFinalized<NGLayoutAlgorithm> { |
| 32 WTF_MAKE_NONCOPYABLE(NGLayoutAlgorithm); | 32 WTF_MAKE_NONCOPYABLE(NGLayoutAlgorithm); |
| 33 | 33 |
| 34 public: | 34 public: |
| 35 NGLayoutAlgorithm(NGLayoutAlgorithmType type) : type_(type) {} | 35 NGLayoutAlgorithm(NGLayoutAlgorithmType type) : type_(type) {} |
| 36 virtual ~NGLayoutAlgorithm() {} | 36 virtual ~NGLayoutAlgorithm() {} |
| 37 | 37 |
| 38 // Actual layout function. Lays out the children and descendents within the | 38 // Actual layout function. Lays out the children and descendents within the |
| 39 // constraints given by the NGConstraintSpace. Returns a fragment with the | 39 // constraints given by the NGConstraintSpace. Returns a fragment with the |
| 40 // resulting layout information. | 40 // resulting layout information. |
| 41 // This function can not be const because for interruptible layout, we have | 41 // This function can not be const because for interruptible layout, we have |
| 42 // to be able to store state information. | 42 // to be able to store state information. |
| 43 // If this function returns NotFinished, it has to be called again. | 43 // If this function returns NotFinished, it has to be called again. |
| 44 // If it returns ChildAlgorithmRequired, the NGBlockNode out parameter will | 44 // If it returns ChildAlgorithmRequired, the NGBlockNode out parameter will |
| 45 // be set with the NGBlockNode that needs to be layed out next. | 45 // be set with the NGBlockNode that needs to be layed out next. |
| 46 // If it returns NewFragment, the NGPhysicalFragmentBase out parameter | 46 // If it returns NewFragment, the NGPhysicalFragmentBase out parameter |
| 47 // will contain the new fragment. | 47 // will contain the new fragment. |
| 48 virtual NGLayoutStatus Layout(NGPhysicalFragmentBase*, | 48 virtual NGLayoutStatus Layout(NGPhysicalFragment*, |
| 49 NGPhysicalFragmentBase**, | 49 NGPhysicalFragment**, |
| 50 NGLayoutAlgorithm**) = 0; | 50 NGLayoutAlgorithm**) = 0; |
| 51 | 51 |
| 52 enum MinAndMaxState { kSuccess, kPending, kNotImplemented }; | 52 enum MinAndMaxState { kSuccess, kPending, kNotImplemented }; |
| 53 | 53 |
| 54 // Computes the min-content and max-content intrinsic sizes for the given box. | 54 // Computes the min-content and max-content intrinsic sizes for the given box. |
| 55 // The result will not take any min-width. max-width or width properties into | 55 // The result will not take any min-width. max-width or width properties into |
| 56 // account. Implementations can return NotImplemented, in which case the | 56 // account. Implementations can return NotImplemented, in which case the |
| 57 // caller is expected to synthesize this value from the overflow rect returned | 57 // caller is expected to synthesize this value from the overflow rect returned |
| 58 // from Layout called with a available width of 0 and LayoutUnit::max(), | 58 // from Layout called with a available width of 0 and LayoutUnit::max(), |
| 59 // respectively. | 59 // respectively. |
| 60 // A Pending return value has the same meaning as a false return from layout, | 60 // A Pending return value has the same meaning as a false return from layout, |
| 61 // i.e. it is a request to call this function again. | 61 // i.e. it is a request to call this function again. |
| 62 virtual MinAndMaxState ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) { | 62 virtual MinAndMaxState ComputeMinAndMaxContentSizes(MinAndMaxContentSizes*) { |
| 63 return kNotImplemented; | 63 return kNotImplemented; |
| 64 } | 64 } |
| 65 | 65 |
| 66 DEFINE_INLINE_VIRTUAL_TRACE() {} | 66 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 67 | 67 |
| 68 NGLayoutAlgorithmType algorithmType() const { return type_; } | 68 NGLayoutAlgorithmType algorithmType() const { return type_; } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 NGLayoutAlgorithmType type_; | 71 NGLayoutAlgorithmType type_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace blink | 74 } // namespace blink |
| 75 | 75 |
| 76 #endif // NGLayoutAlgorithm_h | 76 #endif // NGLayoutAlgorithm_h |
| OLD | NEW |