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