| 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/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/ng/ng_constraint_space.h" | 8 #include "core/layout/ng/ng_constraint_space.h" |
| 9 #include "core/layout/ng/ng_constraint_space_builder.h" | 9 #include "core/layout/ng/ng_constraint_space_builder.h" |
| 10 #include "core/layout/ng/ng_fragment_builder.h" | 10 #include "core/layout/ng/ng_fragment_builder.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 for (const auto& child : | 98 for (const auto& child : |
| 99 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) | 99 toNGPhysicalBoxFragment(result->PhysicalFragment().get()) |
| 100 ->Children()) { | 100 ->Children()) { |
| 101 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); | 101 fragments_out->push_back(toNGPhysicalTextFragment(child.get())); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 RefPtr<const ComputedStyle> style_; | 105 RefPtr<const ComputedStyle> style_; |
| 106 LayoutBlockFlow* layout_block_flow_ = nullptr; | 106 LayoutBlockFlow* layout_block_flow_ = nullptr; |
| 107 LayoutObject* layout_object_ = nullptr; | 107 LayoutObject* layout_object_ = nullptr; |
| 108 FontCachePurgePreventer purge_preventer_; |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ | 111 #define TEST_ITEM_OFFSET_DIR(item, start, end, direction) \ |
| 111 EXPECT_EQ(start, item.StartOffset()); \ | 112 EXPECT_EQ(start, item.StartOffset()); \ |
| 112 EXPECT_EQ(end, item.EndOffset()); \ | 113 EXPECT_EQ(end, item.EndOffset()); \ |
| 113 EXPECT_EQ(direction, item.Direction()) | 114 EXPECT_EQ(direction, item.Direction()) |
| 114 | 115 |
| 115 TEST_F(NGInlineNodeTest, SegmentASCII) { | 116 TEST_F(NGInlineNodeTest, SegmentASCII) { |
| 116 NGInlineNodeForTest* node = CreateInlineNode(); | 117 NGInlineNodeForTest* node = CreateInlineNode(); |
| 117 node->Append("Hello"); | 118 node->Append("Hello"); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 EXPECT_EQ(end_offset, fragment->EndOffset()); \ | 212 EXPECT_EQ(end_offset, fragment->EndOffset()); \ |
| 212 EXPECT_EQ(dir, node->Items()[fragment->ItemIndex()].Direction()) | 213 EXPECT_EQ(dir, node->Items()[fragment->ItemIndex()].Direction()) |
| 213 | 214 |
| 214 TEST_F(NGInlineNodeTest, CreateLineBidiIsolate) { | 215 TEST_F(NGInlineNodeTest, CreateLineBidiIsolate) { |
| 215 UseLayoutObjectAndAhem(); | 216 UseLayoutObjectAndAhem(); |
| 216 RefPtr<ComputedStyle> style = ComputedStyle::create(); | 217 RefPtr<ComputedStyle> style = ComputedStyle::create(); |
| 217 style->setLineHeight(Length(1, Fixed)); | 218 style->setLineHeight(Length(1, Fixed)); |
| 218 style->font().update(nullptr); | 219 style->font().update(nullptr); |
| 219 NGInlineNodeForTest* node = | 220 NGInlineNodeForTest* node = |
| 220 CreateBidiIsolateNode(CreateInlineNode(), style.get(), layout_object_); | 221 CreateBidiIsolateNode(CreateInlineNode(), style.get(), layout_object_); |
| 222 node->ShapeText(); |
| 221 Vector<RefPtr<const NGPhysicalTextFragment>> fragments; | 223 Vector<RefPtr<const NGPhysicalTextFragment>> fragments; |
| 222 CreateLine(node, &fragments); | 224 CreateLine(node, &fragments); |
| 223 ASSERT_EQ(5u, fragments.size()); | 225 ASSERT_EQ(5u, fragments.size()); |
| 224 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 0u, 6u, TextDirection::kLtr); | 226 TEST_TEXT_FRAGMENT(fragments[0], node, 0u, 0u, 6u, TextDirection::kLtr); |
| 225 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 16u, 21u, TextDirection::kRtl); | 227 TEST_TEXT_FRAGMENT(fragments[1], node, 6u, 16u, 21u, TextDirection::kRtl); |
| 226 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 14u, 15u, TextDirection::kLtr); | 228 TEST_TEXT_FRAGMENT(fragments[2], node, 4u, 14u, 15u, TextDirection::kLtr); |
| 227 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 7u, 13u, TextDirection::kRtl); | 229 TEST_TEXT_FRAGMENT(fragments[3], node, 2u, 7u, 13u, TextDirection::kRtl); |
| 228 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 22u, 28u, TextDirection::kLtr); | 230 TEST_TEXT_FRAGMENT(fragments[4], node, 8u, 22u, 28u, TextDirection::kLtr); |
| 229 } | 231 } |
| 230 | 232 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 249 MinMaxContentSize sizes = node->ComputeMinMaxContentSize(); | 251 MinMaxContentSize sizes = node->ComputeMinMaxContentSize(); |
| 250 // |min_content| should be the width of "BC" because there is an element | 252 // |min_content| should be the width of "BC" because there is an element |
| 251 // boundary between "B" and "C" but no break opportunities. | 253 // boundary between "B" and "C" but no break opportunities. |
| 252 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder | 254 // TODO(kojii): min_content should be 20, but is 30 until NGLineBuilder |
| 253 // implements trailing spaces correctly. | 255 // implements trailing spaces correctly. |
| 254 EXPECT_EQ(30, sizes.min_content); | 256 EXPECT_EQ(30, sizes.min_content); |
| 255 EXPECT_EQ(60, sizes.max_content); | 257 EXPECT_EQ(60, sizes.max_content); |
| 256 } | 258 } |
| 257 | 259 |
| 258 } // namespace blink | 260 } // namespace blink |
| OLD | NEW |