OLD | NEW |
---|---|
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 |
11 LayoutUnit MinAndMaxContentSizes::ShrinkToFit(LayoutUnit container_size) const { | |
cbiesinger
2016/11/11 04:31:47
Interesting idea to add this function as a member
atotic
2016/11/11 05:16:22
Done.
| |
12 return std::min(max_content, std::max(min_content, container_size)); | |
13 } | |
14 | |
11 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const { | 15 NGPhysicalSize NGLogicalSize::ConvertToPhysical(NGWritingMode mode) const { |
12 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size) | 16 return mode == HorizontalTopBottom ? NGPhysicalSize(inline_size, block_size) |
13 : NGPhysicalSize(block_size, inline_size); | 17 : NGPhysicalSize(block_size, inline_size); |
14 } | 18 } |
15 | 19 |
16 bool NGLogicalSize::operator==(const NGLogicalSize& other) const { | 20 bool NGLogicalSize::operator==(const NGLogicalSize& other) const { |
17 return std::tie(other.inline_size, other.block_size) == | 21 return std::tie(other.inline_size, other.block_size) == |
18 std::tie(inline_size, block_size); | 22 std::tie(inline_size, block_size); |
19 } | 23 } |
20 | 24 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 bool NGBoxStrut::IsEmpty() const { | 136 bool NGBoxStrut::IsEmpty() const { |
133 return *this == NGBoxStrut(); | 137 return *this == NGBoxStrut(); |
134 } | 138 } |
135 | 139 |
136 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { | 140 bool NGBoxStrut::operator==(const NGBoxStrut& other) const { |
137 return std::tie(other.inline_start, other.inline_end, other.block_start, | 141 return std::tie(other.inline_start, other.inline_end, other.block_start, |
138 other.block_end) == | 142 other.block_end) == |
139 std::tie(inline_start, inline_end, block_start, block_end); | 143 std::tie(inline_start, inline_end, block_start, block_end); |
140 } | 144 } |
141 | 145 |
146 NGBoxStrut NGPhysicalBoxStrut::ConvertToLogical(NGWritingMode writing_mode, | |
147 TextDirection direction) const { | |
cbiesinger
2016/11/11 04:31:47
This is equivalent to https://cs.chromium.org/chro
atotic
2016/11/11 05:16:23
Oh man, I missed that one. Done, old one has been
| |
148 switch (writing_mode) { | |
149 case HorizontalTopBottom: | |
150 if (direction == LTR) | |
151 return NGBoxStrut{left, right, top, bottom}; | |
152 else | |
153 return NGBoxStrut{right, left, top, bottom}; | |
154 case VerticalRightLeft: | |
155 if (direction == LTR) | |
156 return NGBoxStrut{top, bottom, right, left}; | |
157 else | |
158 return NGBoxStrut{bottom, top, right, left}; | |
159 case VerticalLeftRight: | |
160 if (direction == LTR) | |
161 return NGBoxStrut{top, bottom, left, right}; | |
162 else | |
163 return NGBoxStrut{bottom, top, left, right}; | |
164 case SidewaysRightLeft: | |
165 if (direction == LTR) | |
166 return NGBoxStrut{bottom, top, left, right}; | |
167 else | |
168 return NGBoxStrut{top, bottom, left, right}; | |
169 case SidewaysLeftRight: | |
170 if (direction == LTR) | |
171 return NGBoxStrut{top, bottom, left, right}; | |
172 else | |
173 return NGBoxStrut{bottom, top, left, right}; | |
174 } | |
175 } | |
176 | |
142 LayoutUnit NGMarginStrut::BlockEndSum() const { | 177 LayoutUnit NGMarginStrut::BlockEndSum() const { |
143 return margin_block_end + negative_margin_block_end; | 178 return margin_block_end + negative_margin_block_end; |
144 } | 179 } |
145 | 180 |
146 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { | 181 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { |
147 if (value < 0) { | 182 if (value < 0) { |
148 negative_margin_block_start = | 183 negative_margin_block_start = |
149 -std::max(value.abs(), negative_margin_block_start.abs()); | 184 -std::max(value.abs(), negative_margin_block_start.abs()); |
150 } else { | 185 } else { |
151 margin_block_start = std::max(value, margin_block_start); | 186 margin_block_start = std::max(value, margin_block_start); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 225 |
191 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { | 226 bool NGMarginStrut::operator==(const NGMarginStrut& other) const { |
192 return std::tie(other.margin_block_start, other.margin_block_end, | 227 return std::tie(other.margin_block_start, other.margin_block_end, |
193 other.negative_margin_block_start, | 228 other.negative_margin_block_start, |
194 other.negative_margin_block_end) == | 229 other.negative_margin_block_end) == |
195 std::tie(margin_block_start, margin_block_end, | 230 std::tie(margin_block_start, margin_block_end, |
196 negative_margin_block_start, negative_margin_block_end); | 231 negative_margin_block_start, negative_margin_block_end); |
197 } | 232 } |
198 | 233 |
199 } // namespace blink | 234 } // namespace blink |
OLD | NEW |