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

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

Issue 2555923002: Changed TextDirection to an enum class and renamed its members (Closed)
Patch Set: Rebase after reopen Created 4 years 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_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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 size.block_size.toString().ascii().data()); 50 size.block_size.toString().ascii().data());
51 } 51 }
52 52
53 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical( 53 NGPhysicalOffset NGLogicalOffset::ConvertToPhysical(
54 NGWritingMode mode, 54 NGWritingMode mode,
55 TextDirection direction, 55 TextDirection direction,
56 NGPhysicalSize outer_size, 56 NGPhysicalSize outer_size,
57 NGPhysicalSize inner_size) const { 57 NGPhysicalSize inner_size) const {
58 switch (mode) { 58 switch (mode) {
59 case kHorizontalTopBottom: 59 case kHorizontalTopBottom:
60 if (direction == LTR) 60 if (direction == TextDirection::Ltr)
61 return NGPhysicalOffset(inline_offset, block_offset); 61 return NGPhysicalOffset(inline_offset, block_offset);
62 else 62 else
63 return NGPhysicalOffset( 63 return NGPhysicalOffset(
64 outer_size.width - inline_offset - inner_size.width, block_offset); 64 outer_size.width - inline_offset - inner_size.width, block_offset);
65 case kVerticalRightLeft: 65 case kVerticalRightLeft:
66 case kSidewaysRightLeft: 66 case kSidewaysRightLeft:
67 if (direction == LTR) 67 if (direction == TextDirection::Ltr)
68 return NGPhysicalOffset( 68 return NGPhysicalOffset(
69 outer_size.width - block_offset - inner_size.width, inline_offset); 69 outer_size.width - block_offset - inner_size.width, inline_offset);
70 else 70 else
71 return NGPhysicalOffset( 71 return NGPhysicalOffset(
72 outer_size.width - block_offset - inner_size.width, 72 outer_size.width - block_offset - inner_size.width,
73 outer_size.height - inline_offset - inner_size.height); 73 outer_size.height - inline_offset - inner_size.height);
74 case kVerticalLeftRight: 74 case kVerticalLeftRight:
75 if (direction == LTR) 75 if (direction == TextDirection::Ltr)
76 return NGPhysicalOffset(block_offset, inline_offset); 76 return NGPhysicalOffset(block_offset, inline_offset);
77 else 77 else
78 return NGPhysicalOffset( 78 return NGPhysicalOffset(
79 block_offset, 79 block_offset,
80 outer_size.height - inline_offset - inner_size.height); 80 outer_size.height - inline_offset - inner_size.height);
81 case kSidewaysLeftRight: 81 case kSidewaysLeftRight:
82 if (direction == LTR) 82 if (direction == TextDirection::Ltr)
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 else 86 else
87 return NGPhysicalOffset(block_offset, inline_offset); 87 return NGPhysicalOffset(block_offset, inline_offset);
88 default: 88 default:
89 ASSERT_NOT_REACHED(); 89 ASSERT_NOT_REACHED();
90 return NGPhysicalOffset(); 90 return NGPhysicalOffset();
91 } 91 }
92 } 92 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 case kSidewaysRightLeft: 165 case kSidewaysRightLeft:
166 strut = {top, bottom, right, left}; 166 strut = {top, bottom, right, left};
167 break; 167 break;
168 case kVerticalLeftRight: 168 case kVerticalLeftRight:
169 strut = {top, bottom, left, right}; 169 strut = {top, bottom, left, right};
170 break; 170 break;
171 case kSidewaysLeftRight: 171 case kSidewaysLeftRight:
172 strut = {bottom, top, left, right}; 172 strut = {bottom, top, left, right};
173 break; 173 break;
174 } 174 }
175 if (direction == RTL) 175 if (direction == TextDirection::Rtl)
176 std::swap(strut.inline_start, strut.inline_end); 176 std::swap(strut.inline_start, strut.inline_end);
177 return strut; 177 return strut;
178 } 178 }
179 179
180 LayoutUnit NGMarginStrut::BlockEndSum() const { 180 LayoutUnit NGMarginStrut::BlockEndSum() const {
181 return margin_block_end + negative_margin_block_end; 181 return margin_block_end + negative_margin_block_end;
182 } 182 }
183 183
184 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) { 184 void NGMarginStrut::AppendMarginBlockStart(const LayoutUnit& value) {
185 if (value < 0) { 185 if (value < 0) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 return *this; 260 return *this;
261 } 261 }
262 262
263 NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode, 263 NGStaticPosition NGStaticPosition::Create(NGWritingMode writing_mode,
264 TextDirection direction, 264 TextDirection direction,
265 NGPhysicalOffset offset) { 265 NGPhysicalOffset offset) {
266 NGStaticPosition position; 266 NGStaticPosition position;
267 position.offset = offset; 267 position.offset = offset;
268 switch (writing_mode) { 268 switch (writing_mode) {
269 case kHorizontalTopBottom: 269 case kHorizontalTopBottom:
270 position.type = (direction == LTR) ? kTopLeft : kTopRight; 270 position.type = (direction == TextDirection::Ltr) ? kTopLeft : kTopRight;
271 break; 271 break;
272 case kVerticalRightLeft: 272 case kVerticalRightLeft:
273 case kSidewaysRightLeft: 273 case kSidewaysRightLeft:
274 position.type = (direction == LTR) ? kTopRight : kBottomRight; 274 position.type =
275 (direction == TextDirection::Ltr) ? kTopRight : kBottomRight;
275 break; 276 break;
276 case kVerticalLeftRight: 277 case kVerticalLeftRight:
277 position.type = (direction == LTR) ? kTopLeft : kBottomLeft; 278 position.type =
279 (direction == TextDirection::Ltr) ? kTopLeft : kBottomLeft;
278 break; 280 break;
279 case kSidewaysLeftRight: 281 case kSidewaysLeftRight:
280 position.type = (direction == LTR) ? kBottomLeft : kTopLeft; 282 position.type =
283 (direction == TextDirection::Ltr) ? kBottomLeft : kTopLeft;
281 break; 284 break;
282 } 285 }
283 return position; 286 return position;
284 } 287 }
285 288
286 } // namespace blink 289 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698