OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/LayoutBlockFlow.h" | 5 #include "core/layout/LayoutBlockFlow.h" |
6 #include "core/layout/LayoutMultiColumnFlowThread.h" | 6 #include "core/layout/LayoutMultiColumnFlowThread.h" |
7 | 7 |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class PaginationStrutTest : public RenderingTest { | 13 class PaginationStrutTest : public RenderingTest { |
14 public: | 14 public: |
15 int strutForBox(const char* blockId) | 15 int strutForBox(const char* blockId) |
16 { | 16 { |
17 Node* node = document().getElementById(blockId); | 17 LayoutObject* layoutObject = getLayoutObjectByElementId(blockId); |
18 if (!node || !node->layoutObject() || !node->layoutObject()->isBox()) | 18 if (!layoutObject || !layoutObject->isBox()) |
19 return std::numeric_limits<int>::min(); | 19 return std::numeric_limits<int>::min(); |
20 LayoutBox* box = toLayoutBox(node->layoutObject()); | 20 LayoutBox* box = toLayoutBox(layoutObject); |
21 return box->paginationStrut().toInt(); | 21 return box->paginationStrut().toInt(); |
22 } | 22 } |
23 | 23 |
24 int strutForLine(const char* containerId, int lineIndex) | 24 int strutForLine(const char* containerId, int lineIndex) |
25 { | 25 { |
26 Node* node = document().getElementById(containerId); | 26 LayoutObject* layoutObject = getLayoutObjectByElementId(containerId); |
27 if (!node || !node->layoutObject() || !node->layoutObject()->isLayoutBlo
ckFlow()) | 27 if (!layoutObject || !layoutObject->isLayoutBlockFlow()) |
28 return std::numeric_limits<int>::min(); | 28 return std::numeric_limits<int>::min(); |
29 LayoutBlockFlow* block = toLayoutBlockFlow(node->layoutObject()); | 29 LayoutBlockFlow* block = toLayoutBlockFlow(layoutObject); |
30 if (block->multiColumnFlowThread()) | 30 if (block->multiColumnFlowThread()) |
31 block = block->multiColumnFlowThread(); | 31 block = block->multiColumnFlowThread(); |
32 for (RootInlineBox* line = block->firstRootBox(); line; line = line->nex
tRootBox(), lineIndex--) { | 32 for (RootInlineBox* line = block->firstRootBox(); line; line = line->nex
tRootBox(), lineIndex--) { |
33 if (lineIndex) | 33 if (lineIndex) |
34 continue; | 34 continue; |
35 return line->paginationStrut().toInt(); | 35 return line->paginationStrut().toInt(); |
36 } | 36 } |
37 return std::numeric_limits<int>::min(); | 37 return std::numeric_limits<int>::min(); |
38 } | 38 } |
39 }; | 39 }; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 " </div>" | 144 " </div>" |
145 "</div>"); | 145 "</div>"); |
146 EXPECT_EQ(0, strutForBox("block1")); | 146 EXPECT_EQ(0, strutForBox("block1")); |
147 EXPECT_EQ(0, strutForLine("block1", 0)); | 147 EXPECT_EQ(0, strutForLine("block1", 0)); |
148 EXPECT_EQ(0, strutForBox("block2")); | 148 EXPECT_EQ(0, strutForBox("block2")); |
149 EXPECT_EQ(48, strutForBox("innerBlock")); | 149 EXPECT_EQ(48, strutForBox("innerBlock")); |
150 EXPECT_EQ(0, strutForLine("innerBlock", 0)); | 150 EXPECT_EQ(0, strutForLine("innerBlock", 0)); |
151 } | 151 } |
152 | 152 |
153 } // namespace blink | 153 } // namespace blink |
OLD | NEW |