| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutMultiColumnFlowThread.h" | 7 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 8 | 8 |
| 9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
| 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 String columnSetSignature(LayoutMultiColumnFlowThread*); | 26 String columnSetSignature(LayoutMultiColumnFlowThread*); |
| 27 String columnSetSignature(const char* multicolId); | 27 String columnSetSignature(const char* multicolId); |
| 28 | 28 |
| 29 void setMulticolHTML(const String&); | 29 void setMulticolHTML(const String&); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread(const char
* id) const | 32 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread(const char
* id) const |
| 33 { | 33 { |
| 34 Node* multicol = document().getElementById(id); | 34 Node* multicol = document().getElementById(id); |
| 35 if (!multicol) | 35 if (!multicol) |
| 36 return 0; | 36 return nullptr; |
| 37 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(multicol->layoutObjec
t()); | 37 LayoutBlockFlow* multicolContainer = toLayoutBlockFlow(multicol->layoutObjec
t()); |
| 38 if (!multicolContainer) | 38 if (!multicolContainer) |
| 39 return 0; | 39 return nullptr; |
| 40 return multicolContainer->multiColumnFlowThread(); | 40 return multicolContainer->multiColumnFlowThread(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 String MultiColumnRenderingTest::columnSetSignature(LayoutMultiColumnFlowThread*
flowThread) | 43 String MultiColumnRenderingTest::columnSetSignature(LayoutMultiColumnFlowThread*
flowThread) |
| 44 { | 44 { |
| 45 String signature = ""; | 45 String signature = ""; |
| 46 for (LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 46 for (LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
| 47 columnBox; | 47 columnBox; |
| 48 columnBox = columnBox->nextSiblingMultiColumnBox()) { | 48 columnBox = columnBox->nextSiblingMultiColumnBox()) { |
| 49 if (columnBox->isLayoutMultiColumnSpannerPlaceholder()) | 49 if (columnBox->isLayoutMultiColumnSpannerPlaceholder()) |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(799)), secondRow); | 337 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(799)), secondRow); |
| 338 LayoutMultiColumnSet* thirdRow = secondRow->nextSiblingMultiColumnSet(); | 338 LayoutMultiColumnSet* thirdRow = secondRow->nextSiblingMultiColumnSet(); |
| 339 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(800)), thirdRow); | 339 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(800)), thirdRow); |
| 340 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(899)), thirdRow); //
bottom of last row | 340 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(899)), thirdRow); //
bottom of last row |
| 341 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(10000)), thirdRow);
// overflow | 341 EXPECT_EQ(flowThread->columnSetAtBlockOffset(LayoutUnit(10000)), thirdRow);
// overflow |
| 342 } | 342 } |
| 343 | 343 |
| 344 class MultiColumnTreeModifyingTest : public MultiColumnRenderingTest { | 344 class MultiColumnTreeModifyingTest : public MultiColumnRenderingTest { |
| 345 public: | 345 public: |
| 346 void setMulticolHTML(const char*); | 346 void setMulticolHTML(const char*); |
| 347 void reparentLayoutObject(const char* newParentId, const char* childId, cons
t char* insertBeforeId = 0); | 347 void reparentLayoutObject(const char* newParentId, const char* childId, cons
t char* insertBeforeId = nullptr); |
| 348 void destroyLayoutObject(LayoutObject* child); | 348 void destroyLayoutObject(LayoutObject* child); |
| 349 void destroyLayoutObject(const char* childId); | 349 void destroyLayoutObject(const char* childId); |
| 350 }; | 350 }; |
| 351 | 351 |
| 352 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) | 352 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) |
| 353 { | 353 { |
| 354 MultiColumnRenderingTest::setMulticolHTML(html); | 354 MultiColumnRenderingTest::setMulticolHTML(html); |
| 355 // Allow modifications to the layout tree structure, because that's what we
want to test. | 355 // Allow modifications to the layout tree structure, because that's what we
want to test. |
| 356 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); | 356 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void MultiColumnTreeModifyingTest::reparentLayoutObject(const char* newParentId,
const char* childId, const char* insertBeforeId) | 359 void MultiColumnTreeModifyingTest::reparentLayoutObject(const char* newParentId,
const char* childId, const char* insertBeforeId) |
| 360 { | 360 { |
| 361 LayoutObject* newParent = document().getElementById(newParentId)->layoutObje
ct(); | 361 LayoutObject* newParent = document().getElementById(newParentId)->layoutObje
ct(); |
| 362 LayoutObject* child = document().getElementById(childId)->layoutObject(); | 362 LayoutObject* child = document().getElementById(childId)->layoutObject(); |
| 363 LayoutObject* insertBefore = insertBeforeId ? document().getElementById(inse
rtBeforeId)->layoutObject() : 0; | 363 LayoutObject* insertBefore = insertBeforeId ? document().getElementById(inse
rtBeforeId)->layoutObject() : nullptr; |
| 364 child->remove(); | 364 child->remove(); |
| 365 newParent->addChild(child, insertBefore); | 365 newParent->addChild(child, insertBefore); |
| 366 } | 366 } |
| 367 | 367 |
| 368 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) | 368 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) |
| 369 { | 369 { |
| 370 // Remove and destroy in separate steps, so that we get to test removal of s
ubtrees. | 370 // Remove and destroy in separate steps, so that we get to test removal of s
ubtrees. |
| 371 child->remove(); | 371 child->remove(); |
| 372 child->node()->detach(); | 372 child->node()->detach(); |
| 373 } | 373 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 { | 797 { |
| 798 setMulticolHTML("<div id='mc'>text<div id='spanner'><div class='s'></div></d
iv>text</div>"); | 798 setMulticolHTML("<div id='mc'>text<div id='spanner'><div class='s'></div></d
iv>text</div>"); |
| 799 EXPECT_EQ(columnSetSignature("mc"), "csc"); | 799 EXPECT_EQ(columnSetSignature("mc"), "csc"); |
| 800 destroyLayoutObject("spanner"); | 800 destroyLayoutObject("spanner"); |
| 801 EXPECT_EQ(columnSetSignature("mc"), "c"); | 801 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 802 } | 802 } |
| 803 | 803 |
| 804 } // anonymous namespace | 804 } // anonymous namespace |
| 805 | 805 |
| 806 } // namespace blink | 806 } // namespace blink |
| OLD | NEW |