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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h

Issue 2350603002: Ignore zero-height fragments during margin collapsing (Closed)
Patch Set: Created 4 years, 3 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 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 NGFragmentBuilder_h 5 #ifndef NGFragmentBuilder_h
6 #define NGFragmentBuilder_h 6 #define NGFragmentBuilder_h
7 7
8 #include "core/layout/ng/ng_fragment.h" 8 #include "core/layout/ng/ng_fragment.h"
9 #include "core/layout/ng/ng_units.h" 9 #include "core/layout/ng/ng_units.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class CORE_EXPORT NGFragmentBuilder final 13 class CORE_EXPORT NGFragmentBuilder final
14 : public GarbageCollectedFinalized<NGFragmentBuilder> { 14 : public GarbageCollectedFinalized<NGFragmentBuilder> {
15 public: 15 public:
16 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType); 16 NGFragmentBuilder(NGPhysicalFragmentBase::NGFragmentType);
17 17
18 NGFragmentBuilder& SetWritingMode(NGWritingMode); 18 NGFragmentBuilder& SetWritingMode(NGWritingMode);
19 NGFragmentBuilder& SetDirection(NGDirection); 19 NGFragmentBuilder& SetDirection(NGDirection);
20 20
21 NGFragmentBuilder& SetInlineSize(LayoutUnit); 21 NGFragmentBuilder& SetInlineSize(LayoutUnit);
22 NGFragmentBuilder& SetBlockSize(LayoutUnit); 22 NGFragmentBuilder& SetBlockSize(LayoutUnit);
23 23
24 NGFragmentBuilder& SetInlineOverflow(LayoutUnit); 24 NGFragmentBuilder& SetInlineOverflow(LayoutUnit);
25 NGFragmentBuilder& SetBlockOverflow(LayoutUnit); 25 NGFragmentBuilder& SetBlockOverflow(LayoutUnit);
26 26
27 NGFragmentBuilder& AddChild(NGFragment*, NGLogicalOffset); 27 NGFragmentBuilder& AddChild(NGFragment*, NGLogicalOffset);
28 28
29 // Sets MarginStrut for the resultant fragment. 29 // Updates block-{start|end} of the currently constructed fragment.
30 // These 2 methods below should be only called once as we update the 30 //
31 // fragment's MarginStrut block start/end from first/last children MarginStrut 31 // This method is supposed to be called on every child but it only updates
32 NGFragmentBuilder& SetMarginStrutBlockStart(const NGMarginStrut& from); 32 // the block-start once(on the first non-zero height child fragment) and keeps
cbiesinger 2016/09/19 17:05:30 Please add a space before ( here and on the next l
Gleb Lanbin 2016/09/19 17:39:52 Done.
33 NGFragmentBuilder& SetMarginStrutBlockEnd(const NGMarginStrut& from); 33 // updating block-end(on every non-zero height child).
34 NGFragmentBuilder& UpdateMarginStrut(const NGMarginStrut& from);
ikilpatrick 2016/09/19 17:04:19 Is there another way that we can do this without s
Gleb Lanbin 2016/09/19 17:39:52 that was my concern as well. I decided to keep it
ikilpatrick 2016/09/20 11:00:29 I have a preference to leave this in a separate fu
34 35
35 // Offsets are not supposed to be set during fragment construction, so we 36 // Offsets are not supposed to be set during fragment construction, so we
36 // do not provide a setter here. 37 // do not provide a setter here.
37 38
38 // Creates the fragment. Can only be called once. 39 // Creates the fragment. Can only be called once.
39 NGPhysicalFragment* ToFragment(); 40 NGPhysicalFragment* ToFragment();
40 41
41 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(children_); } 42 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(children_); }
42 43
43 private: 44 private:
45 void SetMarginStrutBlockStart(const NGMarginStrut& from);
46 void SetMarginStrutBlockEnd(const NGMarginStrut& from);
47
44 NGPhysicalFragmentBase::NGFragmentType type_; 48 NGPhysicalFragmentBase::NGFragmentType type_;
45 NGWritingMode writing_mode_; 49 NGWritingMode writing_mode_;
46 NGDirection direction_; 50 NGDirection direction_;
47 51
48 NGLogicalSize size_; 52 NGLogicalSize size_;
49 NGLogicalSize overflow_; 53 NGLogicalSize overflow_;
50 54
51 NGMarginStrut margin_strut_; 55 NGMarginStrut margin_strut_;
52 56
53 HeapVector<Member<NGPhysicalFragmentBase>> children_; 57 HeapVector<Member<NGPhysicalFragmentBase>> children_;
54 Vector<NGLogicalOffset> offsets_; 58 Vector<NGLogicalOffset> offsets_;
55 59
56 // Whether MarginStrut block start/end was updated. 60 // Whether MarginStrut block start is updated.
57 // It's used for DCHECK safety check.
58 bool is_margin_strut_block_start_updated_ : 1; 61 bool is_margin_strut_block_start_updated_ : 1;
59 bool is_margin_strut_block_end_updated_ : 1;
60 }; 62 };
61 63
62 } // namespace blink 64 } // namespace blink
63 65
64 #endif // NGFragmentBuilder 66 #endif // NGFragmentBuilder
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698