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

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

Issue 2350603002: Ignore zero-height fragments during margin collapsing (Closed)
Patch Set: Set writing mode and fixed size on style_. Created 4 years, 2 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 #include "core/layout/ng/ng_fragment_builder.h" 5 #include "core/layout/ng/ng_fragment_builder.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 NGFragmentBuilder::NGFragmentBuilder( 9 NGFragmentBuilder::NGFragmentBuilder(
10 NGPhysicalFragmentBase::NGFragmentType type) 10 NGPhysicalFragmentBase::NGFragmentType type)
11 : type_(type), 11 : type_(type),
12 writing_mode_(HorizontalTopBottom), 12 writing_mode_(HorizontalTopBottom),
13 direction_(LeftToRight), 13 direction_(LeftToRight) {}
14 is_margin_strut_block_start_updated_(false),
15 is_margin_strut_block_end_updated_(false) {}
16 14
17 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( 15 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode(
18 NGWritingMode writing_mode) { 16 NGWritingMode writing_mode) {
19 writing_mode_ = writing_mode; 17 writing_mode_ = writing_mode;
20 return *this; 18 return *this;
21 } 19 }
22 20
23 NGFragmentBuilder& NGFragmentBuilder::SetDirection(NGDirection direction) { 21 NGFragmentBuilder& NGFragmentBuilder::SetDirection(NGDirection direction) {
24 direction_ = direction; 22 direction_ = direction;
25 return *this; 23 return *this;
(...skipping 23 matching lines...) Expand all
49 NGLogicalOffset offset) { 47 NGLogicalOffset offset) {
50 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox) 48 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox)
51 << "Only box fragments can have children"; 49 << "Only box fragments can have children";
52 children_.append(child->PhysicalFragment()); 50 children_.append(child->PhysicalFragment());
53 offsets_.append(offset); 51 offsets_.append(offset);
54 return *this; 52 return *this;
55 } 53 }
56 54
57 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockStart( 55 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockStart(
58 const NGMarginStrut& from) { 56 const NGMarginStrut& from) {
59 DCHECK(!is_margin_strut_block_start_updated_);
60 margin_strut_.margin_block_start = from.margin_block_start; 57 margin_strut_.margin_block_start = from.margin_block_start;
61 margin_strut_.negative_margin_block_start = from.negative_margin_block_start; 58 margin_strut_.negative_margin_block_start = from.negative_margin_block_start;
62 is_margin_strut_block_start_updated_ = true;
63 return *this; 59 return *this;
64 } 60 }
65 61
66 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockEnd( 62 NGFragmentBuilder& NGFragmentBuilder::SetMarginStrutBlockEnd(
67 const NGMarginStrut& from) { 63 const NGMarginStrut& from) {
68 DCHECK(!is_margin_strut_block_end_updated_);
69 margin_strut_.margin_block_end = from.margin_block_end; 64 margin_strut_.margin_block_end = from.margin_block_end;
70 margin_strut_.negative_margin_block_end = from.negative_margin_block_end; 65 margin_strut_.negative_margin_block_end = from.negative_margin_block_end;
71 is_margin_strut_block_end_updated_ = true;
72 return *this; 66 return *this;
73 } 67 }
74 68
75 NGPhysicalFragment* NGFragmentBuilder::ToFragment() { 69 NGPhysicalFragment* NGFragmentBuilder::ToFragment() {
76 // TODO(layout-ng): Support text fragments 70 // TODO(layout-ng): Support text fragments
77 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox); 71 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox);
78 DCHECK_EQ(offsets_.size(), children_.size()); 72 DCHECK_EQ(offsets_.size(), children_.size());
79 73
80 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_); 74 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
81 HeapVector<Member<const NGPhysicalFragmentBase>> children; 75 HeapVector<Member<const NGPhysicalFragmentBase>> children;
82 children.reserveCapacity(children_.size()); 76 children.reserveCapacity(children_.size());
83 77
84 for (size_t i = 0; i < children_.size(); ++i) { 78 for (size_t i = 0; i < children_.size(); ++i) {
85 NGPhysicalFragmentBase* child = children_[i].get(); 79 NGPhysicalFragmentBase* child = children_[i].get();
86 child->SetOffset(offsets_[i].ConvertToPhysical( 80 child->SetOffset(offsets_[i].ConvertToPhysical(
87 writing_mode_, direction_, physical_size, child->Size())); 81 writing_mode_, direction_, physical_size, child->Size()));
88 children.append(child); 82 children.append(child);
89 } 83 }
90 return new NGPhysicalFragment(physical_size, 84 return new NGPhysicalFragment(physical_size,
91 overflow_.ConvertToPhysical(writing_mode_), 85 overflow_.ConvertToPhysical(writing_mode_),
92 children, margin_strut_); 86 children, margin_strut_);
93 } 87 }
94 88
95 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.h ('k') | third_party/WebKit/Source/core/layout/ng/ng_units.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698