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

Side by Side 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 unified diff | Download patch
OLDNEW
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/layout/ng/ng_break_token.h" 8 #include "core/layout/ng/ng_break_token.h"
9 #include "platform/LayoutUnit.h" 9 #include "platform/LayoutUnit.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class NGBlockNode; 13 class NGBlockNode;
14 14
15 // Represents a break token for a block node.
15 class NGBlockBreakToken : public NGBreakToken { 16 class NGBlockBreakToken : public NGBreakToken {
16 public: 17 public:
18 // Creates a break token for a node which did fragment, and can potentially
19 // produce more fragments.
20 NGBlockBreakToken(NGBlockNode* node,
21 LayoutUnit used_block_size,
22 HeapVector<Member<NGBreakToken>>& child_break_tokens)
23 : 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
24 used_block_size_(used_block_size) {
25 child_break_tokens_.swap(child_break_tokens);
26 }
27
28 // Creates a break token for a node which cannot produce any more fragments.
29 explicit NGBlockBreakToken(NGBlockNode* node)
30 : NGBreakToken(kBlockBreakToken, /* is_finished */ true, node) {}
31
32 // TODO(ikilpatrick): Remove this constructor and break_offset once we've
33 // switched to new multi-col approach.
17 NGBlockBreakToken(NGBlockNode* node, LayoutUnit break_offset) 34 NGBlockBreakToken(NGBlockNode* node, LayoutUnit break_offset)
18 : NGBreakToken(kBlockBreakToken), 35 : NGBreakToken(kBlockBreakToken, false, node),
19 node_(node),
20 break_offset_(break_offset) {} 36 break_offset_(break_offset) {}
21 37
22 NGBlockNode& InputNode() const { return *node_.get(); } 38 // Represents the amount of block size used in previous fragments.
39 //
40 // E.g. if the layout node specifies a block size of 200px and the used block
41 // 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!
42 // additional fragmentation).
43 LayoutUnit UsedBlockSize() const { return used_block_size_; }
44
45 // The break tokens for children of the layout node.
46 //
47 // This is used to resume layout of any children which fragmented, it may
48 // contain "finished" break tokens so we know which children to skip for the
49 // next fragment.
50 const HeapVector<Member<NGBreakToken>>& ChildBreakTokens() const {
51 return child_break_tokens_;
52 }
53
54 // TODO(ikilpatrick): Remove this accessor.
23 LayoutUnit BreakOffset() const { return break_offset_; } 55 LayoutUnit BreakOffset() const { return break_offset_; }
24 56
25 DEFINE_INLINE_VIRTUAL_TRACE() { 57 DEFINE_INLINE_VIRTUAL_TRACE() {
26 NGBreakToken::trace(visitor); 58 NGBreakToken::trace(visitor);
27 visitor->trace(node_); 59 visitor->trace(child_break_tokens_);
28 } 60 }
29 61
30 private: 62 private:
31 Member<NGBlockNode> node_;
32 LayoutUnit break_offset_; 63 LayoutUnit break_offset_;
64 LayoutUnit used_block_size_;
65 HeapVector<Member<NGBreakToken>> child_break_tokens_;
33 }; 66 };
34 67
35 DEFINE_TYPE_CASTS(NGBlockBreakToken, 68 DEFINE_TYPE_CASTS(NGBlockBreakToken,
36 NGBreakToken, 69 NGBreakToken,
37 token, 70 token,
38 token->Type() == NGBreakToken::kBlockBreakToken, 71 token->Type() == NGBreakToken::kBlockBreakToken,
39 token.Type() == NGBreakToken::kBlockBreakToken); 72 token.Type() == NGBreakToken::kBlockBreakToken);
40 73
41 } // namespace blink 74 } // namespace blink
42 75
43 #endif // NGBlockBreakToken_h 76 #endif // NGBlockBreakToken_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698