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

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

Issue 2798203002: NGInlineLayoutAlgorithm should take margins of inline floats into account (Closed)
Patch Set: use parent's writing mode, direction while calculating margins 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_inline_layout_algorithm_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_inline_layout_algorithm.h" 5 #include "core/layout/ng/ng_inline_layout_algorithm.h"
6 6
7 #include "core/layout/BidiRun.h" 7 #include "core/layout/BidiRun.h"
8 #include "core/layout/LayoutBlockFlow.h" 8 #include "core/layout/LayoutBlockFlow.h"
9 #include "core/layout/line/LineInfo.h" 9 #include "core/layout/line/LineInfo.h"
10 #include "core/layout/line/RootInlineBox.h" 10 #include "core/layout/line/RootInlineBox.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // diff writing mode - get the inline size from performing layout. 324 // diff writing mode - get the inline size from performing layout.
325 RefPtr<NGLayoutResult> layout_result = node->Layout(float_space.get()); 325 RefPtr<NGLayoutResult> layout_result = node->Layout(float_space.get());
326 326
327 NGBoxFragment float_fragment( 327 NGBoxFragment float_fragment(
328 float_space->WritingMode(), 328 float_space->WritingMode(),
329 toNGPhysicalBoxFragment(layout_result->PhysicalFragment().get())); 329 toNGPhysicalBoxFragment(layout_result->PhysicalFragment().get()));
330 330
331 NGLogicalOffset origin_offset = 331 NGLogicalOffset origin_offset =
332 GetOriginPointForFloats(ConstraintSpace(), content_size_); 332 GetOriginPointForFloats(ConstraintSpace(), content_size_);
333 NGLogicalOffset from_offset = ConstraintSpace().BfcOffset(); 333 NGLogicalOffset from_offset = ConstraintSpace().BfcOffset();
334 // TODO(glebl): add margins calculation. 334 const ComputedStyle& float_style = node->Style();
335 NGBoxStrut margins; 335 NGBoxStrut margins = ComputeMargins(ConstraintSpace(), float_style,
336 ConstraintSpace().WritingMode(),
337 ConstraintSpace().Direction());
336 RefPtr<NGFloatingObject> floating_object = NGFloatingObject::Create( 338 RefPtr<NGFloatingObject> floating_object = NGFloatingObject::Create(
337 node->Style(), float_space->WritingMode(), current_opportunity_.size, 339 float_style, float_space->WritingMode(), current_opportunity_.size,
338 origin_offset, from_offset, margins, 340 origin_offset, from_offset, margins,
339 layout_result->PhysicalFragment().get()); 341 layout_result->PhysicalFragment().get());
340 342
341 bool float_does_not_fit = end_position + float_fragment.InlineSize() > 343 bool float_does_not_fit = end_position + float_fragment.InlineSize() >
342 current_opportunity_.InlineSize(); 344 current_opportunity_.InlineSize();
343 // Check if we already have a pending float. That's because a float cannot be 345 // Check if we already have a pending float. That's because a float cannot be
344 // higher than any block or floated box generated before. 346 // higher than any block or floated box generated before.
345 if (!container_builder_.UnpositionedFloats().isEmpty() || 347 if (!container_builder_.UnpositionedFloats().isEmpty() ||
346 float_does_not_fit) { 348 float_does_not_fit) {
347 container_builder_.AddUnpositionedFloat(floating_object); 349 container_builder_.AddUnpositionedFloat(floating_object);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 LayoutUnit baseline = line_top_with_leading + metrics.ascent_and_leading; 637 LayoutUnit baseline = line_top_with_leading + metrics.ascent_and_leading;
636 root_line_box->setLineTopBottomPositions( 638 root_line_box->setLineTopBottomPositions(
637 baseline - metrics.ascent, baseline + metrics.descent, 639 baseline - metrics.ascent, baseline + metrics.descent,
638 line_top_with_leading, baseline + metrics.descent_and_leading); 640 line_top_with_leading, baseline + metrics.descent_and_leading);
639 641
640 bidi_runs.deleteRuns(); 642 bidi_runs.deleteRuns();
641 fragments_for_bidi_runs.clear(); 643 fragments_for_bidi_runs.clear();
642 } 644 }
643 } 645 }
644 } // namespace blink 646 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_inline_layout_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698