| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 start_offset_ = last_break_opportunity_offset_; | 273 start_offset_ = last_break_opportunity_offset_; |
| 274 DCHECK_GE(end_position_, last_break_opportunity_position_); | 274 DCHECK_GE(end_position_, last_break_opportunity_position_); |
| 275 end_position_ -= last_break_opportunity_position_; | 275 end_position_ -= last_break_opportunity_position_; |
| 276 last_break_opportunity_position_ = LayoutUnit(); | 276 last_break_opportunity_position_ = LayoutUnit(); |
| 277 #if DCHECK_IS_ON() | 277 #if DCHECK_IS_ON() |
| 278 is_bidi_reordered_ = false; | 278 is_bidi_reordered_ = false; |
| 279 #endif | 279 #endif |
| 280 | 280 |
| 281 NGLogicalOffset origin_point = | 281 NGLogicalOffset origin_point = |
| 282 GetOriginPointForFloats(ConstraintSpace(), content_size_); | 282 GetOriginPointForFloats(ConstraintSpace(), content_size_); |
| 283 PositionPendingFloats(origin_point.block_offset, MutableConstraintSpace(), | 283 PositionPendingFloats(origin_point.block_offset); |
| 284 &container_builder_); | |
| 285 FindNextLayoutOpportunity(); | 284 FindNextLayoutOpportunity(); |
| 286 return true; | 285 return true; |
| 287 } | 286 } |
| 288 | 287 |
| 289 void NGInlineLayoutAlgorithm::BidiReorder( | 288 void NGInlineLayoutAlgorithm::BidiReorder( |
| 290 Vector<LineItemChunk, 32>* line_item_chunks) { | 289 Vector<LineItemChunk, 32>* line_item_chunks) { |
| 291 #if DCHECK_IS_ON() | 290 #if DCHECK_IS_ON() |
| 292 DCHECK(!is_bidi_reordered_); | 291 DCHECK(!is_bidi_reordered_); |
| 293 is_bidi_reordered_ = true; | 292 is_bidi_reordered_ = true; |
| 294 #endif | 293 #endif |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 layout_result->PhysicalFragment().Get()); | 352 layout_result->PhysicalFragment().Get()); |
| 354 | 353 |
| 355 bool float_does_not_fit = end_position + float_fragment.InlineSize() > | 354 bool float_does_not_fit = end_position + float_fragment.InlineSize() > |
| 356 current_opportunity_.InlineSize(); | 355 current_opportunity_.InlineSize(); |
| 357 // Check if we already have a pending float. That's because a float cannot be | 356 // Check if we already have a pending float. That's because a float cannot be |
| 358 // higher than any block or floated box generated before. | 357 // higher than any block or floated box generated before. |
| 359 if (!container_builder_.UnpositionedFloats().IsEmpty() || | 358 if (!container_builder_.UnpositionedFloats().IsEmpty() || |
| 360 float_does_not_fit) { | 359 float_does_not_fit) { |
| 361 container_builder_.AddUnpositionedFloat(floating_object); | 360 container_builder_.AddUnpositionedFloat(floating_object); |
| 362 } else { | 361 } else { |
| 363 NGLogicalOffset offset = | 362 floating_object->logical_offset = |
| 364 PositionFloat(floating_object.Get(), MutableConstraintSpace()); | 363 PositionFloat(floating_object.Get(), MutableConstraintSpace()); |
| 365 container_builder_.AddFloatingObject(floating_object, offset); | |
| 366 FindNextLayoutOpportunity(); | 364 FindNextLayoutOpportunity(); |
| 367 } | 365 } |
| 368 } | 366 } |
| 369 | 367 |
| 370 bool NGInlineLayoutAlgorithm::PlaceItems( | 368 bool NGInlineLayoutAlgorithm::PlaceItems( |
| 371 const Vector<LineItemChunk, 32>& line_item_chunks) { | 369 const Vector<LineItemChunk, 32>& line_item_chunks) { |
| 372 const Vector<NGLayoutInlineItem>& items = Node()->Items(); | 370 const Vector<NGLayoutInlineItem>& items = Node()->Items(); |
| 373 | 371 |
| 374 // Use a "strut" (a zero-width inline box with the element's font and | 372 // Use a "strut" (a zero-width inline box with the element's font and |
| 375 // line height properties) as the initial metrics for the line box. | 373 // line height properties) as the initial metrics for the line box. |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 561 |
| 564 // max-content is the width without any line wrapping. | 562 // max-content is the width without any line wrapping. |
| 565 // TODO(kojii): Implement hard breaks (<br> etc.) to break. | 563 // TODO(kojii): Implement hard breaks (<br> etc.) to break. |
| 566 for (const auto& item : Node()->Items()) | 564 for (const auto& item : Node()->Items()) |
| 567 sizes.max_content += InlineSize(item); | 565 sizes.max_content += InlineSize(item); |
| 568 | 566 |
| 569 return sizes; | 567 return sizes; |
| 570 } | 568 } |
| 571 | 569 |
| 572 } // namespace blink | 570 } // namespace blink |
| OLD | NEW |