| 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 17 matching lines...) Expand all Loading... |
| 28 // NGLayoutInputNode* node = ...; | 28 // NGLayoutInputNode* node = ...; |
| 29 // NGPhysicalFragment* fragment = node->Layout(space); | 29 // NGPhysicalFragment* fragment = node->Layout(space); |
| 30 // DCHECK(!fragment->BreakToken()->IsFinished()); | 30 // DCHECK(!fragment->BreakToken()->IsFinished()); |
| 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, kTextBreakToken }; | 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 enum NGBreakTokenStatus { kUnfinished, kFinished }; | 41 enum NGBreakTokenStatus { kUnfinished, kFinished }; |
| 42 | 42 |
| 43 // Whether the layout node cannot produce any more fragments. | 43 // Whether the layout node cannot produce any more fragments. |
| 44 bool IsFinished() const { return status_ == kFinished; } | 44 bool IsFinished() const { return status_ == kFinished; } |
| 45 | 45 |
| 46 // Returns the node associated with this break token. A break token cannot be | 46 // Returns the node associated with this break token. A break token cannot be |
| 47 // used with any other node. | 47 // used with any other node. |
| 48 NGLayoutInputNode* InputNode() const { return node_; } | 48 NGLayoutInputNode* InputNode() const { return node_; } |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 NGBreakToken(NGBreakTokenType type, | 51 NGBreakToken(NGBreakTokenType type, |
| 52 NGBreakTokenStatus status, | 52 NGBreakTokenStatus status, |
| 53 NGLayoutInputNode* node) | 53 NGLayoutInputNode* node) |
| 54 : type_(type), status_(status), node_(node) {} | 54 : type_(type), status_(status), node_(node) {} |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 unsigned type_ : 1; | 57 unsigned type_ : 1; |
| 58 unsigned status_ : 1; | 58 unsigned status_ : 1; |
| 59 | 59 |
| 60 Persistent<NGLayoutInputNode> node_; | 60 Persistent<NGLayoutInputNode> node_; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| 64 | 64 |
| 65 #endif // NGBreakToken_h | 65 #endif // NGBreakToken_h |
| OLD | NEW |