| 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/ng_line_builder.h" | 5 #include "core/layout/ng/ng_line_builder.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" |
| 11 #include "core/layout/ng/ng_bidi_paragraph.h" | 11 #include "core/layout/ng/ng_bidi_paragraph.h" |
| 12 #include "core/layout/ng/ng_box_fragment.h" | 12 #include "core/layout/ng/ng_box_fragment.h" |
| 13 #include "core/layout/ng/ng_constraint_space.h" | 13 #include "core/layout/ng/ng_constraint_space.h" |
| 14 #include "core/layout/ng/ng_constraint_space_builder.h" | 14 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 15 #include "core/layout/ng/ng_fragment_builder.h" | 15 #include "core/layout/ng/ng_fragment_builder.h" |
| 16 #include "core/layout/ng/ng_inline_node.h" | 16 #include "core/layout/ng/ng_inline_node.h" |
| 17 #include "core/layout/ng/ng_length_utils.h" | 17 #include "core/layout/ng/ng_length_utils.h" |
| 18 #include "core/layout/ng/ng_text_fragment.h" | 18 #include "core/layout/ng/ng_text_fragment.h" |
| 19 #include "core/style/ComputedStyle.h" | 19 #include "core/style/ComputedStyle.h" |
| 20 #include "platform/text/BidiRunList.h" | 20 #include "platform/text/BidiRunList.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 NGLineBuilder::NGLineBuilder(NGInlineNode* inline_box, | 24 NGLineBuilder::NGLineBuilder(NGInlineNode* inline_box, |
| 25 NGConstraintSpace* constraint_space, | 25 NGConstraintSpace* constraint_space) |
| 26 NGFragmentBuilder* containing_block_builder) | |
| 27 : inline_box_(inline_box), | 26 : inline_box_(inline_box), |
| 28 constraint_space_(constraint_space), | 27 constraint_space_(constraint_space), |
| 29 containing_block_builder_(containing_block_builder), | |
| 30 container_builder_(NGPhysicalFragment::kFragmentBox, inline_box_), | 28 container_builder_(NGPhysicalFragment::kFragmentBox, inline_box_), |
| 31 container_layout_result_(nullptr), | 29 container_layout_result_(nullptr), |
| 32 is_horizontal_writing_mode_( | 30 is_horizontal_writing_mode_( |
| 33 blink::IsHorizontalWritingMode(constraint_space->WritingMode())) | 31 blink::IsHorizontalWritingMode(constraint_space->WritingMode())) |
| 34 #if DCHECK_IS_ON() | 32 #if DCHECK_IS_ON() |
| 35 , | 33 , |
| 36 is_bidi_reordered_(false) | 34 is_bidi_reordered_(false) |
| 37 #endif | 35 #endif |
| 38 { | 36 { |
| 39 if (!is_horizontal_writing_mode_) | 37 if (!is_horizontal_writing_mode_) |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // The direction of a fragment is the CSS direction to resolve logical | 300 // The direction of a fragment is the CSS direction to resolve logical |
| 303 // properties, not the resolved bidi direction. | 301 // properties, not the resolved bidi direction. |
| 304 text_builder.SetDirection(style->direction()) | 302 text_builder.SetDirection(style->direction()) |
| 305 .SetInlineSize(line_item_chunk.inline_size) | 303 .SetInlineSize(line_item_chunk.inline_size) |
| 306 .SetInlineOverflow(line_item_chunk.inline_size) | 304 .SetInlineOverflow(line_item_chunk.inline_size) |
| 307 .SetBlockSize(line_height) | 305 .SetBlockSize(line_height) |
| 308 .SetBlockOverflow(line_height); | 306 .SetBlockOverflow(line_height); |
| 309 } else { | 307 } else { |
| 310 LayoutObject* layout_object = item.GetLayoutObject(); | 308 LayoutObject* layout_object = item.GetLayoutObject(); |
| 311 if (layout_object->isOutOfFlowPositioned()) { | 309 if (layout_object->isOutOfFlowPositioned()) { |
| 312 if (containing_block_builder_) { | 310 // Absolute positioning blockifies the box's display type. |
| 313 // Absolute positioning blockifies the box's display type. | 311 // https://drafts.csswg.org/css-display/#transformations |
| 314 // https://drafts.csswg.org/css-display/#transformations | 312 // |
| 315 containing_block_builder_->AddOutOfFlowChildCandidate( | 313 // TODO(layout-dev): Report the correct static position for the out of |
| 316 new NGBlockNode(layout_object), | 314 // flow descendant. We can't do this here yet as it doesn't know the |
| 317 NGLogicalOffset(line_box_data.inline_size, content_size_)); | 315 // size of the line box. |
| 318 } | 316 container_builder_.AddOutOfFlowDescendant( |
| 317 new NGBlockNode(layout_object), |
| 318 NGStaticPosition::Create(ConstraintSpace().WritingMode(), |
| 319 ConstraintSpace().Direction(), |
| 320 NGPhysicalOffset())); |
| 319 continue; | 321 continue; |
| 320 } else if (layout_object->isFloating()) { | 322 } else if (layout_object->isFloating()) { |
| 321 // TODO(kojii): Implement float. | 323 // TODO(kojii): Implement float. |
| 322 DLOG(ERROR) << "Floats in inline not implemented yet."; | 324 DLOG(ERROR) << "Floats in inline not implemented yet."; |
| 323 // TODO(kojii): Temporarily clearNeedsLayout() for not to assert. | 325 // TODO(kojii): Temporarily clearNeedsLayout() for not to assert. |
| 324 layout_object->clearNeedsLayout(); | 326 layout_object->clearNeedsLayout(); |
| 325 continue; | 327 continue; |
| 326 } | 328 } |
| 327 block_start = PlaceAtomicInline(item, estimated_baseline, &line_box_data, | 329 block_start = PlaceAtomicInline(item, estimated_baseline, &line_box_data, |
| 328 &text_builder); | 330 &text_builder); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 baseline_position - LayoutUnit(line_box_data.max_ascent), | 561 baseline_position - LayoutUnit(line_box_data.max_ascent), |
| 560 baseline_position + LayoutUnit(line_box_data.max_descent), | 562 baseline_position + LayoutUnit(line_box_data.max_descent), |
| 561 line_box_data.top_with_leading, | 563 line_box_data.top_with_leading, |
| 562 baseline_position + LayoutUnit(line_box_data.max_descent_and_leading)); | 564 baseline_position + LayoutUnit(line_box_data.max_descent_and_leading)); |
| 563 | 565 |
| 564 bidi_runs.deleteRuns(); | 566 bidi_runs.deleteRuns(); |
| 565 fragments_for_bidi_runs.clear(); | 567 fragments_for_bidi_runs.clear(); |
| 566 } | 568 } |
| 567 } | 569 } |
| 568 } // namespace blink | 570 } // namespace blink |
| OLD | NEW |