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/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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 DCHECK_GE(end_position_, last_break_opportunity_position_); | 279 DCHECK_GE(end_position_, last_break_opportunity_position_); |
280 end_position_ -= last_break_opportunity_position_; | 280 end_position_ -= last_break_opportunity_position_; |
281 last_break_opportunity_position_ = LayoutUnit(); | 281 last_break_opportunity_position_ = LayoutUnit(); |
282 #if DCHECK_IS_ON() | 282 #if DCHECK_IS_ON() |
283 is_bidi_reordered_ = false; | 283 is_bidi_reordered_ = false; |
284 #endif | 284 #endif |
285 | 285 |
286 NGLogicalOffset origin_point = | 286 NGLogicalOffset origin_point = |
287 GetOriginPointForFloats(ConstraintSpace(), content_size_); | 287 GetOriginPointForFloats(ConstraintSpace(), content_size_); |
288 PositionPendingFloats(origin_point.block_offset, MutableConstraintSpace(), | 288 PositionPendingFloats(origin_point.block_offset, &container_builder_, |
289 &container_builder_); | 289 MutableConstraintSpace()); |
290 FindNextLayoutOpportunity(); | 290 FindNextLayoutOpportunity(); |
291 return true; | 291 return true; |
292 } | 292 } |
293 | 293 |
294 void NGInlineLayoutAlgorithm::BidiReorder( | 294 void NGInlineLayoutAlgorithm::BidiReorder( |
295 Vector<LineItemChunk, 32>* line_item_chunks) { | 295 Vector<LineItemChunk, 32>* line_item_chunks) { |
296 #if DCHECK_IS_ON() | 296 #if DCHECK_IS_ON() |
297 DCHECK(!is_bidi_reordered_); | 297 DCHECK(!is_bidi_reordered_); |
298 is_bidi_reordered_ = true; | 298 is_bidi_reordered_ = true; |
299 #endif | 299 #endif |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 layout_result->PhysicalFragment().Get()); | 376 layout_result->PhysicalFragment().Get()); |
377 | 377 |
378 bool float_does_not_fit = end_position + float_fragment.InlineSize() > | 378 bool float_does_not_fit = end_position + float_fragment.InlineSize() > |
379 current_opportunity_.InlineSize(); | 379 current_opportunity_.InlineSize(); |
380 // Check if we already have a pending float. That's because a float cannot be | 380 // Check if we already have a pending float. That's because a float cannot be |
381 // higher than any block or floated box generated before. | 381 // higher than any block or floated box generated before. |
382 if (!container_builder_.UnpositionedFloats().IsEmpty() || | 382 if (!container_builder_.UnpositionedFloats().IsEmpty() || |
383 float_does_not_fit) { | 383 float_does_not_fit) { |
384 container_builder_.AddUnpositionedFloat(floating_object); | 384 container_builder_.AddUnpositionedFloat(floating_object); |
385 } else { | 385 } else { |
386 NGLogicalOffset offset = | 386 floating_object->logical_offset = |
387 PositionFloat(floating_object.Get(), MutableConstraintSpace()); | 387 PositionFloat(floating_object.Get(), MutableConstraintSpace()); |
388 container_builder_.AddFloatingObject(floating_object, offset); | 388 container_builder_.MutablePositionedFloats().push_back(floating_object); |
389 FindNextLayoutOpportunity(); | 389 FindNextLayoutOpportunity(); |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 bool NGInlineLayoutAlgorithm::PlaceItems( | 393 bool NGInlineLayoutAlgorithm::PlaceItems( |
394 const Vector<LineItemChunk, 32>& line_item_chunks) { | 394 const Vector<LineItemChunk, 32>& line_item_chunks) { |
395 const Vector<NGLayoutInlineItem>& items = Node()->Items(); | 395 const Vector<NGLayoutInlineItem>& items = Node()->Items(); |
396 | 396 |
397 // Use a "strut" (a zero-width inline box with the element's font and | 397 // Use a "strut" (a zero-width inline box with the element's font and |
398 // line height properties) as the initial metrics for the line box. | 398 // line height properties) as the initial metrics for the line box. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 585 |
586 // max-content is the width without any line wrapping. | 586 // max-content is the width without any line wrapping. |
587 // TODO(kojii): Implement hard breaks (<br> etc.) to break. | 587 // TODO(kojii): Implement hard breaks (<br> etc.) to break. |
588 for (const auto& item : Node()->Items()) | 588 for (const auto& item : Node()->Items()) |
589 sizes.max_content += InlineSize(item); | 589 sizes.max_content += InlineSize(item); |
590 | 590 |
591 return sizes; | 591 return sizes; |
592 } | 592 } |
593 | 593 |
594 } // namespace blink | 594 } // namespace blink |
OLD | NEW |