Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h

Issue 2697843004: [LayoutNG] Add fields required for new multi-col approach. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h b/third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h
index 14e50e420e69bd8f0962acad138585c2f6bfdef5..0bd994320823062a3c71c13c39e0ebca951e94dd 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_break_token.h
@@ -12,24 +12,57 @@ namespace blink {
class NGBlockNode;
+// Represents a break token for a block node.
class NGBlockBreakToken : public NGBreakToken {
public:
+ // Creates a break token for a node which did fragment, and can potentially
+ // produce more fragments.
+ NGBlockBreakToken(NGBlockNode* node,
+ LayoutUnit used_block_size,
+ HeapVector<Member<NGBreakToken>>& child_break_tokens)
+ : NGBreakToken(kBlockBreakToken, /* is_finished */ false, node),
cbiesinger 2017/02/15 19:23:19 Consider an enum instead of a bool?
ikilpatrick 2017/02/16 17:01:30 Yeah I looked at doing that, but decided against a
ikilpatrick 2017/02/16 17:02:10 I can also change if you feel strongly about this
cbiesinger 2017/02/16 22:03:49 Well, I think /* is_finished */ false looks hideou
+ used_block_size_(used_block_size) {
+ child_break_tokens_.swap(child_break_tokens);
+ }
+
+ // Creates a break token for a node which cannot produce any more fragments.
+ explicit NGBlockBreakToken(NGBlockNode* node)
+ : NGBreakToken(kBlockBreakToken, /* is_finished */ true, node) {}
+
+ // TODO(ikilpatrick): Remove this constructor and break_offset once we've
+ // switched to new multi-col approach.
NGBlockBreakToken(NGBlockNode* node, LayoutUnit break_offset)
- : NGBreakToken(kBlockBreakToken),
- node_(node),
+ : NGBreakToken(kBlockBreakToken, false, node),
break_offset_(break_offset) {}
- NGBlockNode& InputNode() const { return *node_.get(); }
+ // Represents the amount of block size used in previous fragments.
+ //
+ // E.g. if the layout node specifies a block size of 200px and the used block
+ // size is 150px the next fragment should have a size of 50px (assuming no
cbiesinger 2017/02/15 19:24:22 Also, I'm confused by this comment. Typically bloc
ikilpatrick 2017/02/15 19:45:35 So consider this: https://software.hixie.ch/utilit
cbiesinger1 2017/02/16 00:14:55 Oh I see. I missed the fact that 200px is the size
ikilpatrick 2017/02/16 17:01:30 Tried some rewording...
cbiesinger 2017/02/16 22:03:48 Thanks!
+ // additional fragmentation).
+ LayoutUnit UsedBlockSize() const { return used_block_size_; }
+
+ // The break tokens for children of the layout node.
+ //
+ // This is used to resume layout of any children which fragmented, it may
+ // contain "finished" break tokens so we know which children to skip for the
+ // next fragment.
+ const HeapVector<Member<NGBreakToken>>& ChildBreakTokens() const {
+ return child_break_tokens_;
+ }
+
+ // TODO(ikilpatrick): Remove this accessor.
LayoutUnit BreakOffset() const { return break_offset_; }
DEFINE_INLINE_VIRTUAL_TRACE() {
NGBreakToken::trace(visitor);
- visitor->trace(node_);
+ visitor->trace(child_break_tokens_);
}
private:
- Member<NGBlockNode> node_;
LayoutUnit break_offset_;
+ LayoutUnit used_block_size_;
+ HeapVector<Member<NGBreakToken>> child_break_tokens_;
};
DEFINE_TYPE_CASTS(NGBlockBreakToken,

Powered by Google App Engine
This is Rietveld 408576698