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

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

Issue 2892293002: Add a basic support of text-align:right property to NGInlineLayoutAlgorithm. (Closed)
Patch Set: fix comments Created 3 years, 7 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/inline/ng_inline_layout_algorithm.h" 5 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h"
6 6
7 #include "core/layout/ng/inline/ng_bidi_paragraph.h" 7 #include "core/layout/ng/inline/ng_bidi_paragraph.h"
8 #include "core/layout/ng/inline/ng_inline_break_token.h" 8 #include "core/layout/ng/inline/ng_inline_break_token.h"
9 #include "core/layout/ng/inline/ng_inline_node.h" 9 #include "core/layout/ng/inline/ng_inline_node.h"
10 #include "core/layout/ng/inline/ng_line_box_fragment.h" 10 #include "core/layout/ng/inline/ng_line_box_fragment.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // and block_start do not match. 308 // and block_start do not match.
309 309
310 // Up until this point, children are placed so that the dominant baseline is 310 // Up until this point, children are placed so that the dominant baseline is
311 // at 0. Move them to the final baseline position, and set the logical top of 311 // at 0. Move them to the final baseline position, and set the logical top of
312 // the line box to the line top. 312 // the line box to the line top.
313 line_box.MoveChildrenInBlockDirection(baseline); 313 line_box.MoveChildrenInBlockDirection(baseline);
314 314
315 DCHECK_EQ(line_left_position, LogicalLeftOffset()); 315 DCHECK_EQ(line_left_position, LogicalLeftOffset());
316 LayoutUnit inline_size = position - line_left_position; 316 LayoutUnit inline_size = position - line_left_position;
317 line_box.SetInlineSize(inline_size); 317 line_box.SetInlineSize(inline_size);
318
319 // Account for text align property.
320 if (Node()->Style().GetTextAlign() == ETextAlign::kRight) {
321 line_box.MoveChildrenInInlineDirection(
322 current_opportunity_.size.inline_size - inline_size);
323 }
324
318 container_builder_.AddChild( 325 container_builder_.AddChild(
319 line_box.ToLineBoxFragment(), 326 line_box.ToLineBoxFragment(),
320 {LayoutUnit(), baseline - box_states_.LineBoxState().metrics.ascent}); 327 {LayoutUnit(), baseline - box_states_.LineBoxState().metrics.ascent});
321 328
322 max_inline_size_ = std::max(max_inline_size_, inline_size); 329 max_inline_size_ = std::max(max_inline_size_, inline_size);
323 content_size_ = line_bottom; 330 content_size_ = line_bottom;
324 return true; 331 return true;
325 } 332 }
326 333
327 // TODO(kojii): Currently, this function does not change item_result, but 334 // TODO(kojii): Currently, this function does not change item_result, but
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // Margin struts shouldn't need to be passed through like this once we've 417 // Margin struts shouldn't need to be passed through like this once we've
411 // removed LayoutInline splitting. 418 // removed LayoutInline splitting.
412 if (!container_builder_.BfcOffset()) { 419 if (!container_builder_.BfcOffset()) {
413 container_builder_.SetEndMarginStrut(ConstraintSpace().MarginStrut()); 420 container_builder_.SetEndMarginStrut(ConstraintSpace().MarginStrut());
414 } 421 }
415 422
416 return container_builder_.ToBoxFragment(); 423 return container_builder_.ToBoxFragment();
417 } 424 }
418 425
419 } // namespace blink 426 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698