| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 NGBlockBreakToken_h | 5 #ifndef NGBlockBreakToken_h |
| 6 #define NGBlockBreakToken_h | 6 #define NGBlockBreakToken_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/ng_break_token.h" | 9 #include "core/layout/ng/ng_break_token.h" |
| 10 #include "platform/LayoutUnit.h" | 10 #include "platform/LayoutUnit.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class NGBlockNode; | 14 class NGBlockNode; |
| 15 | 15 |
| 16 // Represents a break token for a block node. | 16 // Represents a break token for a block node. |
| 17 class CORE_EXPORT NGBlockBreakToken : public NGBreakToken { | 17 class CORE_EXPORT NGBlockBreakToken : public NGBreakToken { |
| 18 public: | 18 public: |
| 19 // Creates a break token for a node which did fragment, and can potentially | 19 // Creates a break token for a node which did fragment, and can potentially |
| 20 // produce more fragments. | 20 // produce more fragments. |
| 21 // | 21 // |
| 22 // The NGBlockBreakToken takes ownership of child_break_tokens, leaving it | 22 // The NGBlockBreakToken takes ownership of child_break_tokens, leaving it |
| 23 // empty for the caller. | 23 // empty for the caller. |
| 24 NGBlockBreakToken(NGBlockNode* node, | 24 NGBlockBreakToken(NGBlockNode* node, |
| 25 LayoutUnit used_block_size, | 25 LayoutUnit used_block_size, |
| 26 HeapVector<Member<NGBreakToken>>& child_break_tokens); | 26 HeapVector<Member<NGBreakToken>>& child_break_tokens); |
| 27 | 27 |
| 28 // Creates a break token for a node which cannot produce any more fragments. | 28 // Creates a break token for a node which cannot produce any more fragments. |
| 29 explicit NGBlockBreakToken(NGBlockNode* node); | 29 explicit NGBlockBreakToken(NGLayoutInputNode* node); |
| 30 | |
| 31 // TODO(ikilpatrick): Remove this constructor and break_offset once we've | |
| 32 // switched to new multi-col approach. | |
| 33 NGBlockBreakToken(NGBlockNode* node, LayoutUnit break_offset); | |
| 34 | 30 |
| 35 // Represents the amount of block size used in previous fragments. | 31 // Represents the amount of block size used in previous fragments. |
| 36 // | 32 // |
| 37 // E.g. if the layout block specifies a block size of 200px, and the previous | 33 // E.g. if the layout block specifies a block size of 200px, and the previous |
| 38 // fragments of this block used 150px (used block size), the next fragment | 34 // fragments of this block used 150px (used block size), the next fragment |
| 39 // should have a size of 50px (assuming no additional fragmentation). | 35 // should have a size of 50px (assuming no additional fragmentation). |
| 40 LayoutUnit UsedBlockSize() const { return used_block_size_; } | 36 LayoutUnit UsedBlockSize() const { return used_block_size_; } |
| 41 | 37 |
| 42 // The break tokens for children of the layout node. | 38 // The break tokens for children of the layout node. |
| 43 // | 39 // |
| 44 // Each child we have visited previously in the block-flow layout algorithm | 40 // Each child we have visited previously in the block-flow layout algorithm |
| 45 // has an associated break token. This may be either finished (we should skip | 41 // has an associated break token. This may be either finished (we should skip |
| 46 // this child) or unfinished (we should try and produce the next fragment for | 42 // this child) or unfinished (we should try and produce the next fragment for |
| 47 // this child). | 43 // this child). |
| 48 // | 44 // |
| 49 // A child which we haven't visited yet doesn't have a break token here. | 45 // A child which we haven't visited yet doesn't have a break token here. |
| 50 const HeapVector<Member<NGBreakToken>>& ChildBreakTokens() const { | 46 const HeapVector<Member<NGBreakToken>>& ChildBreakTokens() const { |
| 51 return child_break_tokens_; | 47 return child_break_tokens_; |
| 52 } | 48 } |
| 53 | 49 |
| 54 // TODO(ikilpatrick): Remove this accessor. | |
| 55 LayoutUnit BreakOffset() const { return break_offset_; } | |
| 56 | |
| 57 DEFINE_INLINE_VIRTUAL_TRACE() { | 50 DEFINE_INLINE_VIRTUAL_TRACE() { |
| 58 NGBreakToken::trace(visitor); | 51 NGBreakToken::trace(visitor); |
| 59 visitor->trace(child_break_tokens_); | 52 visitor->trace(child_break_tokens_); |
| 60 } | 53 } |
| 61 | 54 |
| 62 private: | 55 private: |
| 63 LayoutUnit break_offset_; | |
| 64 LayoutUnit used_block_size_; | 56 LayoutUnit used_block_size_; |
| 65 HeapVector<Member<NGBreakToken>> child_break_tokens_; | 57 HeapVector<Member<NGBreakToken>> child_break_tokens_; |
| 66 }; | 58 }; |
| 67 | 59 |
| 68 DEFINE_TYPE_CASTS(NGBlockBreakToken, | 60 DEFINE_TYPE_CASTS(NGBlockBreakToken, |
| 69 NGBreakToken, | 61 NGBreakToken, |
| 70 token, | 62 token, |
| 71 token->Type() == NGBreakToken::kBlockBreakToken, | 63 token->Type() == NGBreakToken::kBlockBreakToken, |
| 72 token.Type() == NGBreakToken::kBlockBreakToken); | 64 token.Type() == NGBreakToken::kBlockBreakToken); |
| 73 | 65 |
| 74 } // namespace blink | 66 } // namespace blink |
| 75 | 67 |
| 76 #endif // NGBlockBreakToken_h | 68 #endif // NGBlockBreakToken_h |
| OLD | NEW |