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

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

Issue 2798203002: NGInlineLayoutAlgorithm should take margins of inline floats into account (Closed)
Patch Set: Created 3 years, 8 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/ng_length_utils.h" 5 #include "core/layout/ng/ng_length_utils.h"
6 6
7 #include "core/layout/ng/ng_constraint_space.h" 7 #include "core/layout/ng/ng_constraint_space.h"
8 #include "core/layout/ng/ng_constraint_space_builder.h" 8 #include "core/layout/ng/ng_constraint_space_builder.h"
9 #include "core/layout/ng/ng_fragment.h" 9 #include "core/layout/ng/ng_fragment.h"
10 #include "core/style/ComputedStyle.h" 10 #include "core/style/ComputedStyle.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 constraint_space, style, empty_sizes, style.paddingAfter(), 393 constraint_space, style, empty_sizes, style.paddingAfter(),
394 LengthResolveType::kMarginBorderPaddingSize); 394 LengthResolveType::kMarginBorderPaddingSize);
395 return padding; 395 return padding;
396 } 396 }
397 397
398 void ApplyAutoMargins(const NGConstraintSpace& constraint_space, 398 void ApplyAutoMargins(const NGConstraintSpace& constraint_space,
399 const ComputedStyle& style, 399 const ComputedStyle& style,
400 const LayoutUnit& inline_size, 400 const LayoutUnit& inline_size,
401 NGBoxStrut* margins) { 401 NGBoxStrut* margins) {
402 DCHECK(margins) << "Margins cannot be NULL here"; 402 DCHECK(margins) << "Margins cannot be NULL here";
403
404 if (style.isFloating())
405 return;
406
403 const LayoutUnit used_space = inline_size + margins->InlineSum(); 407 const LayoutUnit used_space = inline_size + margins->InlineSum();
404 const LayoutUnit available_space = 408 const LayoutUnit available_space =
405 constraint_space.AvailableSize().inline_size - used_space; 409 constraint_space.AvailableSize().inline_size - used_space;
406 if (available_space < LayoutUnit()) 410 if (available_space < LayoutUnit())
407 return; 411 return;
408 if (style.marginStart().isAuto() && style.marginEnd().isAuto()) { 412 if (style.marginStart().isAuto() && style.marginEnd().isAuto()) {
409 margins->inline_start = available_space / 2; 413 margins->inline_start = available_space / 2;
410 margins->inline_end = available_space - margins->inline_start; 414 margins->inline_end = available_space - margins->inline_start;
411 } else if (style.marginStart().isAuto()) { 415 } else if (style.marginStart().isAuto()) {
412 margins->inline_start = available_space; 416 margins->inline_start = available_space;
413 } else if (style.marginEnd().isAuto()) { 417 } else if (style.marginEnd().isAuto()) {
414 margins->inline_end = available_space; 418 margins->inline_end = available_space;
415 } 419 }
416 } 420 }
417 421
418 LayoutUnit ConstrainByMinMax(LayoutUnit length, 422 LayoutUnit ConstrainByMinMax(LayoutUnit length,
419 Optional<LayoutUnit> min, 423 Optional<LayoutUnit> min,
420 Optional<LayoutUnit> max) { 424 Optional<LayoutUnit> max) {
421 if (max && length > max.value()) 425 if (max && length > max.value())
422 length = max.value(); 426 length = max.value();
423 if (min && length < min.value()) 427 if (min && length < min.value())
424 length = min.value(); 428 length = min.value();
425 return length; 429 return length;
426 } 430 }
427 431
428 } // namespace blink 432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698