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 namespace blink { | 7 namespace blink { |
8 | 8 |
9 LayoutUnit MinAndMaxContentSizes::ShrinkToFit(LayoutUnit available_size) const { | 9 LayoutUnit MinAndMaxContentSizes::ShrinkToFit(LayoutUnit available_size) const { |
10 DCHECK_GE(max_content, min_content); | 10 DCHECK_GE(max_content, min_content); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 size.block_size.toString().ascii().data()); | 55 size.block_size.toString().ascii().data()); |
56 } | 56 } |
57 | 57 |
58 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( | 58 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( |
59 NGWritingMode mode, | 59 NGWritingMode mode, |
60 TextDirection direction, | 60 TextDirection direction, |
61 NGPhysicalSize outer_size, | 61 NGPhysicalSize outer_size, |
62 NGPhysicalSize inner_size) const { | 62 NGPhysicalSize inner_size) const { |
63 switch (mode) { | 63 switch (mode) { |
64 case kHorizontalTopBottom: | 64 case kHorizontalTopBottom: |
65 if (direction == TextDirection::Ltr) | 65 if (direction == TextDirection::kLtr) |
66 return NGPhysicalOffset(inline_offset, block_offset); | 66 return NGPhysicalOffset(inline_offset, block_offset); |
67 else | 67 else |
68 return NGPhysicalOffset( | 68 return NGPhysicalOffset( |
69 outer_size.width - inline_offset - inner_size.width, block_offset); | 69 outer_size.width - inline_offset - inner_size.width, block_offset); |
70 case kVerticalRightLeft: | 70 case kVerticalRightLeft: |
71 case kSidewaysRightLeft: | 71 case kSidewaysRightLeft: |
72 if (direction == TextDirection::Ltr) | 72 if (direction == TextDirection::kLtr) |
73 return NGPhysicalOffset( | 73 return NGPhysicalOffset( |
74 outer_size.width - block_offset - inner_size.width, inline_offset); | 74 outer_size.width - block_offset - inner_size.width, inline_offset); |
75 else | 75 else |
76 return NGPhysicalOffset( | 76 return NGPhysicalOffset( |
77 outer_size.width - block_offset - inner_size.width, | 77 outer_size.width - block_offset - inner_size.width, |
78 outer_size.height - inline_offset - inner_size.height); | 78 outer_size.height - inline_offset - inner_size.height); |
79 case kVerticalLeftRight: | 79 case kVerticalLeftRight: |
80 if (direction == TextDirection::Ltr) | 80 if (direction == TextDirection::kLtr) |
81 return NGPhysicalOffset(block_offset, inline_offset); | 81 return NGPhysicalOffset(block_offset, inline_offset); |
82 else | 82 else |
83 return NGPhysicalOffset( | 83 return NGPhysicalOffset( |
84 block_offset, | 84 block_offset, |
85 outer_size.height - inline_offset - inner_size.height); | 85 outer_size.height - inline_offset - inner_size.height); |
86 case kSidewaysLeftRight: | 86 case kSidewaysLeftRight: |
87 if (direction == TextDirection::Ltr) | 87 if (direction == TextDirection::kLtr) |
88 return NGPhysicalOffset( | 88 return NGPhysicalOffset( |
89 block_offset, | 89 block_offset, |
90 outer_size.height - inline_offset - inner_size.height); | 90 outer_size.height - inline_offset - inner_size.height); |
91 else | 91 else |
92 return NGPhysicalOffset(block_offset, inline_offset); | 92 return NGPhysicalOffset(block_offset, inline_offset); |
93 default: | 93 default: |
94 ASSERT_NOT_REACHED(); | 94 ASSERT_NOT_REACHED(); |
95 return NGPhysicalOffset(); | 95 return NGPhysicalOffset(); |
96 } | 96 } |
97 } | 97 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 case kSidewaysRightLeft: | 180 case kSidewaysRightLeft: |
181 strut = {top, bottom, right, left}; | 181 strut = {top, bottom, right, left}; |
182 break; | 182 break; |
183 case kVerticalLeftRight: | 183 case kVerticalLeftRight: |
184 strut = {top, bottom, left, right}; | 184 strut = {top, bottom, left, right}; |
185 break; | 185 break; |
186 case kSidewaysLeftRight: | 186 case kSidewaysLeftRight: |
187 strut = {bottom, top, left, right}; | 187 strut = {bottom, top, left, right}; |
188 break; | 188 break; |
189 } | 189 } |
190 if (direction == TextDirection::Rtl) | 190 if (direction == TextDirection::kRtl) |
191 std::swap(strut.inline_start, strut.inline_end); | 191 std::swap(strut.inline_start, strut.inline_end); |
192 return strut; | 192 return strut; |
193 } | 193 } |
194 | 194 |
195 LayoutUnit NGMarginStrut::BlockEndSum() const { | 195 LayoutUnit NGMarginStrut::BlockEndSum() const { |
196 return margin_block_end + negative_margin_block_end; | 196 return margin_block_end + negative_margin_block_end; |
197 } | 197 } |
198 | 198 |
199 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { | 199 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { |
200 if (value < 0) { | 200 if (value < 0) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return *this; | 275 return *this; |
276 } | 276 } |
277 | 277 |
278 NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode, | 278 NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode, |
279 TextDirection direction, | 279 TextDirection direction, |
280 NGPhysicalOffset offset) { | 280 NGPhysicalOffset offset) { |
281 NGStaticPosition position; | 281 NGStaticPosition position; |
282 position.offset = offset; | 282 position.offset = offset; |
283 switch (writing_mode) { | 283 switch (writing_mode) { |
284 case kHorizontalTopBottom: | 284 case kHorizontalTopBottom: |
285 position.type = (direction == TextDirection::Ltr) ? kTopLeft : kTopRight; | 285 position.type = (direction == TextDirection::kLtr) ? kTopLeft : kTopRight; |
286 break; | 286 break; |
287 case kVerticalRightLeft: | 287 case kVerticalRightLeft: |
288 case kSidewaysRightLeft: | 288 case kSidewaysRightLeft: |
289 position.type = | 289 position.type = |
290 (direction == TextDirection::Ltr) ? kTopRight : kBottomRight; | 290 (direction == TextDirection::kLtr) ? kTopRight : kBottomRight; |
291 break; | 291 break; |
292 case kVerticalLeftRight: | 292 case kVerticalLeftRight: |
293 position.type = | 293 position.type = |
294 (direction == TextDirection::Ltr) ? kTopLeft : kBottomLeft; | 294 (direction == TextDirection::kLtr) ? kTopLeft : kBottomLeft; |
295 break; | 295 break; |
296 case kSidewaysLeftRight: | 296 case kSidewaysLeftRight: |
297 position.type = | 297 position.type = |
298 (direction == TextDirection::Ltr) ? kBottomLeft : kTopLeft; | 298 (direction == TextDirection::kLtr) ? kBottomLeft : kTopLeft; |
299 break; | 299 break; |
300 } | 300 } |
301 return position; | 301 return position; |
302 } | 302 } |
303 | 303 |
304 } // namespace blink | 304 } // namespace blink |
OLD | NEW |