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 NGBreakToken_h | 5 #ifndef NGBreakToken_h |
6 #define NGBreakToken_h | 6 #define NGBreakToken_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/layout/ng/ng_layout_input_node.h" | 9 #include "core/layout/ng/ng_layout_input_node.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // NGPhysicalFragment* fragment2 = node->Layout(space, fragment->BreakToken()); | 31 // NGPhysicalFragment* fragment2 = node->Layout(space, fragment->BreakToken()); |
32 // | 32 // |
33 // The break token should encapsulate enough information to "resume" the layout. | 33 // The break token should encapsulate enough information to "resume" the layout. |
34 class CORE_EXPORT NGBreakToken : public RefCounted<NGBreakToken> { | 34 class CORE_EXPORT NGBreakToken : public RefCounted<NGBreakToken> { |
35 public: | 35 public: |
36 virtual ~NGBreakToken() {} | 36 virtual ~NGBreakToken() {} |
37 | 37 |
38 enum NGBreakTokenType { kBlockBreakToken, kInlineBreakToken }; | 38 enum NGBreakTokenType { kBlockBreakToken, kInlineBreakToken }; |
39 NGBreakTokenType Type() const { return static_cast<NGBreakTokenType>(type_); } | 39 NGBreakTokenType Type() const { return static_cast<NGBreakTokenType>(type_); } |
40 | 40 |
| 41 bool IsBlockType() const { return Type() == kBlockBreakToken; } |
| 42 bool IsInlineType() const { return Type() == kInlineBreakToken; } |
| 43 |
41 enum NGBreakTokenStatus { kUnfinished, kFinished }; | 44 enum NGBreakTokenStatus { kUnfinished, kFinished }; |
42 | 45 |
43 // Whether the layout node cannot produce any more fragments. | 46 // Whether the layout node cannot produce any more fragments. |
44 bool IsFinished() const { return status_ == kFinished; } | 47 bool IsFinished() const { return status_ == kFinished; } |
45 | 48 |
46 // Returns the node associated with this break token. A break token cannot be | 49 // Returns the node associated with this break token. A break token cannot be |
47 // used with any other node. | 50 // used with any other node. |
48 NGLayoutInputNode* InputNode() const { return node_; } | 51 NGLayoutInputNode* InputNode() const { return node_; } |
49 | 52 |
50 protected: | 53 protected: |
51 NGBreakToken(NGBreakTokenType type, | 54 NGBreakToken(NGBreakTokenType type, |
52 NGBreakTokenStatus status, | 55 NGBreakTokenStatus status, |
53 NGLayoutInputNode* node) | 56 NGLayoutInputNode* node) |
54 : type_(type), status_(status), node_(node) {} | 57 : type_(type), status_(status), node_(node) {} |
55 | 58 |
56 private: | 59 private: |
57 unsigned type_ : 1; | 60 unsigned type_ : 1; |
58 unsigned status_ : 1; | 61 unsigned status_ : 1; |
59 | 62 |
60 Persistent<NGLayoutInputNode> node_; | 63 Persistent<NGLayoutInputNode> node_; |
61 }; | 64 }; |
62 | 65 |
63 } // namespace blink | 66 } // namespace blink |
64 | 67 |
65 #endif // NGBreakToken_h | 68 #endif // NGBreakToken_h |
OLD | NEW |