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

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

Issue 2346473003: Do not collapse margins with padding/border b/w parent and first/last child (Closed)
Patch Set: synced to the head 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_units.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_units.h" 5 #include "core/layout/ng/ng_units.h"
6 6
7 #include "core/layout/ng/ng_writing_mode.h" 7 #include "core/layout/ng/ng_writing_mode.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 void NGMarginStrut::AppendMarginBlockEnd(const LayoutUnit& value) { 73 void NGMarginStrut::AppendMarginBlockEnd(const LayoutUnit& value) {
74 if (value < 0) { 74 if (value < 0) {
75 negative_margin_block_end = 75 negative_margin_block_end =
76 -std::max(value.abs(), negative_margin_block_end.abs()); 76 -std::max(value.abs(), negative_margin_block_end.abs());
77 } else { 77 } else {
78 margin_block_end = std::max(value, margin_block_end); 78 margin_block_end = std::max(value, margin_block_end);
79 } 79 }
80 } 80 }
81 81
82 void NGMarginStrut::SetMarginBlockStart(const LayoutUnit& value) {
83 if (value < 0) {
84 negative_margin_block_start = value;
85 } else {
86 margin_block_start = value;
87 }
88 }
89
82 void NGMarginStrut::SetMarginBlockEnd(const LayoutUnit& value) { 90 void NGMarginStrut::SetMarginBlockEnd(const LayoutUnit& value) {
83 if (value < 0) { 91 if (value < 0) {
84 negative_margin_block_end = value; 92 negative_margin_block_end = value;
85 } else { 93 } else {
86 margin_block_end = value; 94 margin_block_end = value;
87 } 95 }
88 } 96 }
89 97
90 String NGMarginStrut::ToString() const { 98 String NGMarginStrut::ToString() const {
91 return String::format( 99 return String::format("Start: (%d %d) End: (%d %d)",
92 "Start: (%d %d) End: (%d %d)", negative_margin_block_start.toInt(), 100 margin_block_start.toInt(), margin_block_end.toInt(),
93 margin_block_start.toInt(), negative_margin_block_end.toInt(), 101 negative_margin_block_start.toInt(),
94 margin_block_end.toInt()); 102 negative_margin_block_end.toInt());
95 } 103 }
96 104
97 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { 105 bool NGMarginStrut::operator==(const NGMarginStrut& other) const {
98 return std::tie(other.margin_block_start, other.margin_block_end, 106 return std::tie(other.margin_block_start, other.margin_block_end,
99 other.negative_margin_block_start, 107 other.negative_margin_block_start,
100 other.negative_margin_block_end) == 108 other.negative_margin_block_end) ==
101 std::tie(margin_block_start, margin_block_end, 109 std::tie(margin_block_start, margin_block_end,
102 negative_margin_block_start, negative_margin_block_end); 110 negative_margin_block_start, negative_margin_block_end);
103 } 111 }
104 112
105 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_units.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698