| 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_inline_node.h" | 5 #include "core/layout/ng/ng_inline_node.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
| 8 #include "core/layout/LayoutObject.h" | 8 #include "core/layout/LayoutObject.h" |
| 9 #include "core/layout/LayoutText.h" | 9 #include "core/layout/LayoutText.h" |
| 10 #include "core/layout/ng/ng_bidi_paragraph.h" | 10 #include "core/layout/ng/ng_bidi_paragraph.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Skip non-text items; e.g., bidi controls, atomic inlines, out-of-flow | 256 // Skip non-text items; e.g., bidi controls, atomic inlines, out-of-flow |
| 257 // objects. | 257 // objects. |
| 258 if (!item.style_) | 258 if (!item.style_) |
| 259 continue; | 259 continue; |
| 260 | 260 |
| 261 item.shape_result_ = shaper.shape(&item.Style()->font(), item.Direction(), | 261 item.shape_result_ = shaper.shape(&item.Style()->font(), item.Direction(), |
| 262 item.StartOffset(), item.EndOffset()); | 262 item.StartOffset(), item.EndOffset()); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace*, NGBreakToken*) { | |
| 267 ASSERT_NOT_REACHED(); | |
| 268 return nullptr; | |
| 269 } | |
| 270 | |
| 271 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, | 266 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace* constraint_space, |
| 272 NGFragmentBuilder* parent_builder, | 267 NGBreakToken*) { |
| 273 NGBreakToken* break_token) { | |
| 274 // TODO(kojii): Invalidate PrepareLayout() more efficiently. | 268 // TODO(kojii): Invalidate PrepareLayout() more efficiently. |
| 275 InvalidatePrepareLayout(); | 269 InvalidatePrepareLayout(); |
| 276 NGLineBuilder line_builder(this, constraint_space, parent_builder); | 270 NGLineBuilder line_builder(this, constraint_space); |
| 277 Layout(&line_builder); | 271 Layout(&line_builder); |
| 278 RefPtr<NGLayoutResult> result = line_builder.CreateFragments(); | 272 RefPtr<NGLayoutResult> result = line_builder.CreateFragments(); |
| 279 line_builder.CopyFragmentDataToLayoutBlockFlow(); | 273 line_builder.CopyFragmentDataToLayoutBlockFlow(); |
| 280 return result; | 274 return result; |
| 281 } | 275 } |
| 282 | 276 |
| 283 void NGInlineNode::Layout(NGLineBuilder* line_builder) { | 277 void NGInlineNode::Layout(NGLineBuilder* line_builder) { |
| 284 if (!IsPrepareLayoutFinished()) | 278 if (!IsPrepareLayoutFinished()) |
| 285 PrepareLayout(); | 279 PrepareLayout(); |
| 286 | 280 |
| 287 if (text_content_.isEmpty()) | 281 if (text_content_.isEmpty()) |
| 288 return; | 282 return; |
| 289 | 283 |
| 290 NGTextLayoutAlgorithm(this).LayoutInline(line_builder); | 284 NGTextLayoutAlgorithm(this).LayoutInline(line_builder); |
| 291 } | 285 } |
| 292 | 286 |
| 293 MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() { | 287 MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() { |
| 294 // Compute the max of inline sizes of all line boxes with 0 available inline | 288 // Compute the max of inline sizes of all line boxes with 0 available inline |
| 295 // size. This gives the min-content, the width where lines wrap at every break | 289 // size. This gives the min-content, the width where lines wrap at every break |
| 296 // opportunity. | 290 // opportunity. |
| 297 NGWritingMode writing_mode = | 291 NGWritingMode writing_mode = |
| 298 FromPlatformWritingMode(BlockStyle()->getWritingMode()); | 292 FromPlatformWritingMode(BlockStyle()->getWritingMode()); |
| 299 RefPtr<NGConstraintSpace> constraint_space = | 293 RefPtr<NGConstraintSpace> constraint_space = |
| 300 NGConstraintSpaceBuilder(writing_mode) | 294 NGConstraintSpaceBuilder(writing_mode) |
| 301 .SetTextDirection(BlockStyle()->direction()) | 295 .SetTextDirection(BlockStyle()->direction()) |
| 302 .SetAvailableSize({LayoutUnit(), NGSizeIndefinite}) | 296 .SetAvailableSize({LayoutUnit(), NGSizeIndefinite}) |
| 303 .ToConstraintSpace(writing_mode); | 297 .ToConstraintSpace(writing_mode); |
| 304 NGLineBuilder line_builder(this, constraint_space.get(), nullptr); | 298 NGLineBuilder line_builder(this, constraint_space.get()); |
| 305 Layout(&line_builder); | 299 Layout(&line_builder); |
| 306 MinMaxContentSize sizes; | 300 MinMaxContentSize sizes; |
| 307 sizes.min_content = line_builder.MaxInlineSize(); | 301 sizes.min_content = line_builder.MaxInlineSize(); |
| 308 | 302 |
| 309 // max-content is the width without any line wrapping. | 303 // max-content is the width without any line wrapping. |
| 310 // TODO(kojii): Implement hard breaks (<br> etc.) to break. | 304 // TODO(kojii): Implement hard breaks (<br> etc.) to break. |
| 311 for (const auto& item : items_) | 305 for (const auto& item : items_) |
| 312 sizes.max_content += line_builder.InlineSize(item); | 306 sizes.max_content += line_builder.InlineSize(item); |
| 313 | 307 |
| 314 return sizes; | 308 return sizes; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 Vector<NGLayoutInlineItem>* items, | 362 Vector<NGLayoutInlineItem>* items, |
| 369 unsigned start_index, | 363 unsigned start_index, |
| 370 unsigned end_index) | 364 unsigned end_index) |
| 371 : start_item_(&(*items)[start_index]), | 365 : start_item_(&(*items)[start_index]), |
| 372 size_(end_index - start_index), | 366 size_(end_index - start_index), |
| 373 start_index_(start_index) { | 367 start_index_(start_index) { |
| 374 RELEASE_ASSERT(start_index <= end_index && end_index <= items->size()); | 368 RELEASE_ASSERT(start_index <= end_index && end_index <= items->size()); |
| 375 } | 369 } |
| 376 | 370 |
| 377 } // namespace blink | 371 } // namespace blink |
| OLD | NEW |