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 // |
| 25 // The node is NGBlockNode, or any other NGLayoutInputNode that produces |
| 26 // anonymous box. |
24 static RefPtr<NGBlockBreakToken> create( | 27 static RefPtr<NGBlockBreakToken> create( |
25 NGBlockNode* node, | 28 NGLayoutInputNode* node, |
26 LayoutUnit used_block_size, | 29 LayoutUnit used_block_size, |
27 Vector<RefPtr<NGBreakToken>>& child_break_tokens) { | 30 Vector<RefPtr<NGBreakToken>>& child_break_tokens) { |
28 return adoptRef( | 31 return adoptRef( |
29 new NGBlockBreakToken(node, used_block_size, child_break_tokens)); | 32 new NGBlockBreakToken(node, used_block_size, child_break_tokens)); |
30 } | 33 } |
31 | 34 |
32 // Creates a break token for a node which cannot produce any more fragments. | 35 // Creates a break token for a node which cannot produce any more fragments. |
33 static RefPtr<NGBlockBreakToken> create(NGLayoutInputNode* node) { | 36 static RefPtr<NGBlockBreakToken> create(NGLayoutInputNode* node) { |
34 return adoptRef(new NGBlockBreakToken(node)); | 37 return adoptRef(new NGBlockBreakToken(node)); |
35 } | 38 } |
(...skipping 11 matching lines...) Expand all Loading... |
47 // has an associated break token. This may be either finished (we should skip | 50 // has an associated break token. This may be either finished (we should skip |
48 // this child) or unfinished (we should try and produce the next fragment for | 51 // this child) or unfinished (we should try and produce the next fragment for |
49 // this child). | 52 // this child). |
50 // | 53 // |
51 // A child which we haven't visited yet doesn't have a break token here. | 54 // A child which we haven't visited yet doesn't have a break token here. |
52 const Vector<RefPtr<NGBreakToken>>& ChildBreakTokens() const { | 55 const Vector<RefPtr<NGBreakToken>>& ChildBreakTokens() const { |
53 return child_break_tokens_; | 56 return child_break_tokens_; |
54 } | 57 } |
55 | 58 |
56 private: | 59 private: |
57 NGBlockBreakToken(NGBlockNode* node, | 60 NGBlockBreakToken(NGLayoutInputNode* node, |
58 LayoutUnit used_block_size, | 61 LayoutUnit used_block_size, |
59 Vector<RefPtr<NGBreakToken>>& child_break_tokens); | 62 Vector<RefPtr<NGBreakToken>>& child_break_tokens); |
60 | 63 |
61 explicit NGBlockBreakToken(NGLayoutInputNode* node); | 64 explicit NGBlockBreakToken(NGLayoutInputNode* node); |
62 | 65 |
63 LayoutUnit used_block_size_; | 66 LayoutUnit used_block_size_; |
64 Vector<RefPtr<NGBreakToken>> child_break_tokens_; | 67 Vector<RefPtr<NGBreakToken>> child_break_tokens_; |
65 }; | 68 }; |
66 | 69 |
67 DEFINE_TYPE_CASTS(NGBlockBreakToken, | 70 DEFINE_TYPE_CASTS(NGBlockBreakToken, |
68 NGBreakToken, | 71 NGBreakToken, |
69 token, | 72 token, |
70 token->Type() == NGBreakToken::kBlockBreakToken, | 73 token->Type() == NGBreakToken::kBlockBreakToken, |
71 token.Type() == NGBreakToken::kBlockBreakToken); | 74 token.Type() == NGBreakToken::kBlockBreakToken); |
72 | 75 |
73 } // namespace blink | 76 } // namespace blink |
74 | 77 |
75 #endif // NGBlockBreakToken_h | 78 #endif // NGBlockBreakToken_h |
OLD | NEW |