Chromium Code Reviews| 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 "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class NGLayoutInputNode; | |
|
Gleb Lanbin
2017/02/15 19:21:39
can we just include NGLayoutInputNode?
https://goo
mstensho (USE GERRIT)
2017/02/15 21:25:38
Chromium style thankfully overrides this, though:
ikilpatrick
2017/02/16 17:01:30
We should try and push for keeping the forward dec
| |
| 14 | |
| 15 // A break token is a continuation token for layout. A single layout input node | |
| 16 // can have multiple fragments asssociated with it. | |
| 17 // | |
| 18 // Each fragment has a break token which can be used to determine if a layout | |
| 19 // input node has been "exhausted" of fragments, and optionally used to produce | |
| 20 // the next fragment in the chain. | |
| 21 // | |
| 22 // See CSS Fragmentation (https://drafts.csswg.org/css-break/) for a detailed | |
| 23 // description of different types of breaks which can occur in CSS. | |
| 24 // | |
| 25 // Each layout algorithm which can fragment, e.g. block-flow can optionally | |
| 26 // accept a break token. For example: | |
| 27 // | |
| 28 // NGLayoutInputNode* node = ...; | |
| 29 // NGPhysicalFragment* fragment = node->Layout(space); | |
| 30 // DCHECK(!fragment->BreakToken()->IsFinished()); | |
| 31 // NGPhysicalFragment* fragment2 = node->Layout(space, fragment->BreakToken()); | |
| 32 // | |
| 33 // The break token should encapsulate enough information to "resume" the layout. | |
| 13 class CORE_EXPORT NGBreakToken | 34 class CORE_EXPORT NGBreakToken |
| 14 : public GarbageCollectedFinalized<NGBreakToken> { | 35 : public GarbageCollectedFinalized<NGBreakToken> { |
| 15 public: | 36 public: |
| 16 virtual ~NGBreakToken() {} | 37 virtual ~NGBreakToken() {} |
| 17 | 38 |
| 18 enum NGBreakTokenType { kBlockBreakToken, kTextBreakToken }; | 39 enum NGBreakTokenType { kBlockBreakToken, kTextBreakToken }; |
| 19 NGBreakTokenType Type() const { return static_cast<NGBreakTokenType>(type_); } | 40 NGBreakTokenType Type() const { return static_cast<NGBreakTokenType>(type_); } |
| 20 | 41 |
| 21 DEFINE_INLINE_VIRTUAL_TRACE() {} | 42 // Whether the layout node cannot produce any more fragments. |
| 43 bool IsFinished() const { return is_finished_; } | |
|
Gleb Lanbin
2017/02/15 19:21:38
.nit you used "exhausted" word to explain this cas
ikilpatrick
2017/02/16 17:01:30
I'll keep as IsFinished, but reworded above...
| |
| 44 | |
| 45 // Returns the node associated with this break token. A break token cannot be | |
| 46 // used with any other node. | |
| 47 NGLayoutInputNode* InputNode() const { return node_.get(); } | |
|
Gleb Lanbin
2017/02/15 19:21:39
just return node_;
ikilpatrick
2017/02/16 17:01:30
Done.
| |
| 48 | |
| 49 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(node_); } | |
| 22 | 50 |
| 23 protected: | 51 protected: |
| 24 NGBreakToken(NGBreakTokenType type) : type_(type) {} | 52 NGBreakToken(NGBreakTokenType type, bool is_finished, NGLayoutInputNode* node) |
| 53 : type_(type), is_finished_(is_finished), node_(node) {} | |
| 25 | 54 |
| 26 private: | 55 private: |
| 27 unsigned type_ : 1; | 56 unsigned type_ : 1; |
| 57 unsigned is_finished_ : 1; | |
| 58 | |
| 59 Member<NGLayoutInputNode> node_; | |
| 28 }; | 60 }; |
| 29 | 61 |
| 30 } // namespace blink | 62 } // namespace blink |
| 31 | 63 |
| 32 #endif // NGBreakToken_h | 64 #endif // NGBreakToken_h |
| OLD | NEW |