| 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 "core/layout/LayoutMultiColumnFlowThread.h" | 5 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutMultiColumnSet.h" | 7 #include "core/layout/LayoutMultiColumnSet.h" |
| 8 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 8 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class MultiColumnRenderingTest : public RenderingTest { | 16 class MultiColumnRenderingTest : public RenderingTest { |
| 17 public: | 17 public: |
| 18 LayoutMultiColumnFlowThread* findFlowThread(const char* id) const; | 18 LayoutMultiColumnFlowThread* findFlowThread(const char* id) const; |
| 19 | 19 |
| 20 // Generate a signature string based on what kind of column boxes the flow thr
ead has | 20 // Generate a signature string based on what kind of column boxes the flow |
| 21 // established. 'c' is used for regular column content sets, while 's' is used
for spanners. | 21 // thread has established. 'c' is used for regular column content sets, while |
| 22 // '?' is used when there's an unknown box type (which should be considered a
failure). | 22 // 's' is used for spanners. '?' is used when there's an unknown box type |
| 23 // (which should be considered a failure). |
| 23 String columnSetSignature(LayoutMultiColumnFlowThread*); | 24 String columnSetSignature(LayoutMultiColumnFlowThread*); |
| 24 String columnSetSignature(const char* multicolId); | 25 String columnSetSignature(const char* multicolId); |
| 25 | 26 |
| 26 void setMulticolHTML(const String&); | 27 void setMulticolHTML(const String&); |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread( | 30 LayoutMultiColumnFlowThread* MultiColumnRenderingTest::findFlowThread( |
| 30 const char* id) const { | 31 const char* id) const { |
| 31 if (LayoutBlockFlow* multicolContainer = | 32 if (LayoutBlockFlow* multicolContainer = |
| 32 toLayoutBlockFlow(getLayoutObjectByElementId(id))) | 33 toLayoutBlockFlow(getLayoutObjectByElementId(id))) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 void MultiColumnRenderingTest::setMulticolHTML(const String& html) { | 57 void MultiColumnRenderingTest::setMulticolHTML(const String& html) { |
| 57 const char* style = | 58 const char* style = |
| 58 "<style>" | 59 "<style>" |
| 59 " #mc { columns:2; }" | 60 " #mc { columns:2; }" |
| 60 " .s, #spanner, #spanner1, #spanner2 { column-span:all; }" | 61 " .s, #spanner, #spanner1, #spanner2 { column-span:all; }" |
| 61 "</style>"; | 62 "</style>"; |
| 62 setBodyInnerHTML(style + html); | 63 setBodyInnerHTML(style + html); |
| 63 } | 64 } |
| 64 | 65 |
| 65 TEST_F(MultiColumnRenderingTest, OneBlockWithInDepthTreeStructureCheck) { | 66 TEST_F(MultiColumnRenderingTest, OneBlockWithInDepthTreeStructureCheck) { |
| 66 // Examine the layout tree established by a simple multicol container with a b
lock with some text inside. | 67 // Examine the layout tree established by a simple multicol container with a |
| 68 // block with some text inside. |
| 67 setMulticolHTML("<div id='mc'><div>xxx</div></div>"); | 69 setMulticolHTML("<div id='mc'><div>xxx</div></div>"); |
| 68 LayoutBlockFlow* multicolContainer = | 70 LayoutBlockFlow* multicolContainer = |
| 69 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); | 71 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); |
| 70 ASSERT_TRUE(multicolContainer); | 72 ASSERT_TRUE(multicolContainer); |
| 71 LayoutMultiColumnFlowThread* flowThread = | 73 LayoutMultiColumnFlowThread* flowThread = |
| 72 multicolContainer->multiColumnFlowThread(); | 74 multicolContainer->multiColumnFlowThread(); |
| 73 ASSERT_TRUE(flowThread); | 75 ASSERT_TRUE(flowThread); |
| 74 EXPECT_EQ(columnSetSignature(flowThread), "c"); | 76 EXPECT_EQ(columnSetSignature(flowThread), "c"); |
| 75 EXPECT_EQ(flowThread->parent(), multicolContainer); | 77 EXPECT_EQ(flowThread->parent(), multicolContainer); |
| 76 EXPECT_FALSE(flowThread->previousSibling()); | 78 EXPECT_FALSE(flowThread->previousSibling()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 97 setMulticolHTML("<div id='mc'><div id='block'></div></div>"); | 99 setMulticolHTML("<div id='mc'><div id='block'></div></div>"); |
| 98 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 100 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 99 ASSERT_EQ(columnSetSignature(flowThread), "c"); | 101 ASSERT_EQ(columnSetSignature(flowThread), "c"); |
| 100 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 102 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
| 101 EXPECT_EQ( | 103 EXPECT_EQ( |
| 102 flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("block")), | 104 flowThread->mapDescendantToColumnSet(getLayoutObjectByElementId("block")), |
| 103 columnSet); | 105 columnSet); |
| 104 } | 106 } |
| 105 | 107 |
| 106 TEST_F(MultiColumnRenderingTest, TwoBlocks) { | 108 TEST_F(MultiColumnRenderingTest, TwoBlocks) { |
| 107 // No matter how much content, we should only create one column set (unless th
ere are spanners). | 109 // No matter how much content, we should only create one column set (unless |
| 110 // there are spanners). |
| 108 setMulticolHTML( | 111 setMulticolHTML( |
| 109 "<div id='mc'><div id='block1'></div><div id='block2'></div></div>"); | 112 "<div id='mc'><div id='block1'></div><div id='block2'></div></div>"); |
| 110 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 113 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 111 ASSERT_EQ(columnSetSignature(flowThread), "c"); | 114 ASSERT_EQ(columnSetSignature(flowThread), "c"); |
| 112 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 115 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
| 113 EXPECT_EQ(flowThread->mapDescendantToColumnSet( | 116 EXPECT_EQ(flowThread->mapDescendantToColumnSet( |
| 114 getLayoutObjectByElementId("block1")), | 117 getLayoutObjectByElementId("block1")), |
| 115 columnSet); | 118 columnSet); |
| 116 EXPECT_EQ(flowThread->mapDescendantToColumnSet( | 119 EXPECT_EQ(flowThread->mapDescendantToColumnSet( |
| 117 getLayoutObjectByElementId("block2")), | 120 getLayoutObjectByElementId("block2")), |
| 118 columnSet); | 121 columnSet); |
| 119 } | 122 } |
| 120 | 123 |
| 121 TEST_F(MultiColumnRenderingTest, Spanner) { | 124 TEST_F(MultiColumnRenderingTest, Spanner) { |
| 122 // With one spanner and no column content, we should create a spanner set. | 125 // With one spanner and no column content, we should create a spanner set. |
| 123 setMulticolHTML("<div id='mc'><div id='spanner'></div></div>"); | 126 setMulticolHTML("<div id='mc'><div id='spanner'></div></div>"); |
| 124 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 127 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 125 ASSERT_EQ(columnSetSignature(flowThread), "s"); | 128 ASSERT_EQ(columnSetSignature(flowThread), "s"); |
| 126 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 129 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
| 127 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); | 130 EXPECT_EQ(flowThread->firstMultiColumnSet(), nullptr); |
| 128 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 131 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 129 getLayoutObjectByElementId("spanner")), | 132 getLayoutObjectByElementId("spanner")), |
| 130 columnBox); | 133 columnBox); |
| 131 EXPECT_EQ(getLayoutObjectByElementId("spanner")->spannerPlaceholder(), | 134 EXPECT_EQ(getLayoutObjectByElementId("spanner")->spannerPlaceholder(), |
| 132 columnBox); | 135 columnBox); |
| 133 } | 136 } |
| 134 | 137 |
| 135 TEST_F(MultiColumnRenderingTest, ContentThenSpanner) { | 138 TEST_F(MultiColumnRenderingTest, ContentThenSpanner) { |
| 136 // With some column content followed by a spanner, we need a column set follow
ed by a spanner set. | 139 // With some column content followed by a spanner, we need a column set |
| 140 // followed by a spanner set. |
| 137 setMulticolHTML( | 141 setMulticolHTML( |
| 138 "<div id='mc'><div id='columnContent'></div><div " | 142 "<div id='mc'><div id='columnContent'></div><div " |
| 139 "id='spanner'></div></div>"); | 143 "id='spanner'></div></div>"); |
| 140 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 144 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 141 ASSERT_EQ(columnSetSignature(flowThread), "cs"); | 145 ASSERT_EQ(columnSetSignature(flowThread), "cs"); |
| 142 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 146 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
| 143 EXPECT_EQ(flowThread->mapDescendantToColumnSet( | 147 EXPECT_EQ(flowThread->mapDescendantToColumnSet( |
| 144 getLayoutObjectByElementId("columnContent")), | 148 getLayoutObjectByElementId("columnContent")), |
| 145 columnBox); | 149 columnBox); |
| 146 columnBox = columnBox->nextSiblingMultiColumnBox(); | 150 columnBox = columnBox->nextSiblingMultiColumnBox(); |
| 147 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 151 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 148 getLayoutObjectByElementId("spanner")), | 152 getLayoutObjectByElementId("spanner")), |
| 149 columnBox); | 153 columnBox); |
| 150 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 154 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 151 getLayoutObjectByElementId("columnContent")), | 155 getLayoutObjectByElementId("columnContent")), |
| 152 nullptr); | 156 nullptr); |
| 153 } | 157 } |
| 154 | 158 |
| 155 TEST_F(MultiColumnRenderingTest, SpannerThenContent) { | 159 TEST_F(MultiColumnRenderingTest, SpannerThenContent) { |
| 156 // With a spanner followed by some column content, we need a spanner set follo
wed by a column set. | 160 // With a spanner followed by some column content, we need a spanner set |
| 161 // followed by a column set. |
| 157 setMulticolHTML( | 162 setMulticolHTML( |
| 158 "<div id='mc'><div id='spanner'></div><div " | 163 "<div id='mc'><div id='spanner'></div><div " |
| 159 "id='columnContent'></div></div>"); | 164 "id='columnContent'></div></div>"); |
| 160 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 165 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 161 ASSERT_EQ(columnSetSignature(flowThread), "sc"); | 166 ASSERT_EQ(columnSetSignature(flowThread), "sc"); |
| 162 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 167 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
| 163 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 168 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 164 getLayoutObjectByElementId("spanner")), | 169 getLayoutObjectByElementId("spanner")), |
| 165 columnBox); | 170 columnBox); |
| 166 columnBox = columnBox->nextSiblingMultiColumnBox(); | 171 columnBox = columnBox->nextSiblingMultiColumnBox(); |
| 167 EXPECT_EQ(flowThread->mapDescendantToColumnSet( | 172 EXPECT_EQ(flowThread->mapDescendantToColumnSet( |
| 168 getLayoutObjectByElementId("columnContent")), | 173 getLayoutObjectByElementId("columnContent")), |
| 169 columnBox); | 174 columnBox); |
| 170 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 175 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 171 getLayoutObjectByElementId("columnContent")), | 176 getLayoutObjectByElementId("columnContent")), |
| 172 nullptr); | 177 nullptr); |
| 173 } | 178 } |
| 174 | 179 |
| 175 TEST_F(MultiColumnRenderingTest, ContentThenSpannerThenContent) { | 180 TEST_F(MultiColumnRenderingTest, ContentThenSpannerThenContent) { |
| 176 // With column content followed by a spanner followed by some column content,
we need a column | 181 // With column content followed by a spanner followed by some column content, |
| 182 // we need a column |
| 177 // set followed by a spanner set followed by a column set. | 183 // set followed by a spanner set followed by a column set. |
| 178 setMulticolHTML( | 184 setMulticolHTML( |
| 179 "<div id='mc'><div id='columnContentBefore'></div><div " | 185 "<div id='mc'><div id='columnContentBefore'></div><div " |
| 180 "id='spanner'></div><div id='columnContentAfter'></div></div>"); | 186 "id='spanner'></div><div id='columnContentAfter'></div></div>"); |
| 181 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 187 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 182 ASSERT_EQ(columnSetSignature(flowThread), "csc"); | 188 ASSERT_EQ(columnSetSignature(flowThread), "csc"); |
| 183 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); | 189 LayoutBox* columnBox = flowThread->firstMultiColumnSet(); |
| 184 EXPECT_EQ(flowThread->mapDescendantToColumnSet( | 190 EXPECT_EQ(flowThread->mapDescendantToColumnSet( |
| 185 getLayoutObjectByElementId("columnContentBefore")), | 191 getLayoutObjectByElementId("columnContentBefore")), |
| 186 columnBox); | 192 columnBox); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 215 columnBox); | 221 columnBox); |
| 216 columnBox = columnBox->nextSiblingMultiColumnBox(); | 222 columnBox = columnBox->nextSiblingMultiColumnBox(); |
| 217 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 223 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 218 getLayoutObjectByElementId("spanner2")), | 224 getLayoutObjectByElementId("spanner2")), |
| 219 columnBox); | 225 columnBox); |
| 220 EXPECT_EQ(getLayoutObjectByElementId("spanner2")->spannerPlaceholder(), | 226 EXPECT_EQ(getLayoutObjectByElementId("spanner2")->spannerPlaceholder(), |
| 221 columnBox); | 227 columnBox); |
| 222 } | 228 } |
| 223 | 229 |
| 224 TEST_F(MultiColumnRenderingTest, SpannerThenContentThenSpanner) { | 230 TEST_F(MultiColumnRenderingTest, SpannerThenContentThenSpanner) { |
| 225 // With two spanners and some column content in-between, we need a spanner set
, a column set and another spanner set. | 231 // With two spanners and some column content in-between, we need a spanner |
| 232 // set, a column set and another spanner set. |
| 226 setMulticolHTML( | 233 setMulticolHTML( |
| 227 "<div id='mc'><div id='spanner1'></div><div " | 234 "<div id='mc'><div id='spanner1'></div><div " |
| 228 "id='columnContent'></div><div id='spanner2'></div></div>"); | 235 "id='columnContent'></div><div id='spanner2'></div></div>"); |
| 229 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 236 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 230 ASSERT_EQ(columnSetSignature(flowThread), "scs"); | 237 ASSERT_EQ(columnSetSignature(flowThread), "scs"); |
| 231 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); | 238 LayoutMultiColumnSet* columnSet = flowThread->firstMultiColumnSet(); |
| 232 EXPECT_EQ(columnSet->nextSiblingMultiColumnSet(), nullptr); | 239 EXPECT_EQ(columnSet->nextSiblingMultiColumnSet(), nullptr); |
| 233 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); | 240 LayoutBox* columnBox = flowThread->firstMultiColumnBox(); |
| 234 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( | 241 EXPECT_EQ(flowThread->containingColumnSpannerPlaceholder( |
| 235 getLayoutObjectByElementId("spanner1")), | 242 getLayoutObjectByElementId("spanner1")), |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 void setMulticolHTML(const char*); | 568 void setMulticolHTML(const char*); |
| 562 void reparentLayoutObject(const char* newParentId, | 569 void reparentLayoutObject(const char* newParentId, |
| 563 const char* childId, | 570 const char* childId, |
| 564 const char* insertBeforeId = nullptr); | 571 const char* insertBeforeId = nullptr); |
| 565 void destroyLayoutObject(LayoutObject* child); | 572 void destroyLayoutObject(LayoutObject* child); |
| 566 void destroyLayoutObject(const char* childId); | 573 void destroyLayoutObject(const char* childId); |
| 567 }; | 574 }; |
| 568 | 575 |
| 569 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) { | 576 void MultiColumnTreeModifyingTest::setMulticolHTML(const char* html) { |
| 570 MultiColumnRenderingTest::setMulticolHTML(html); | 577 MultiColumnRenderingTest::setMulticolHTML(html); |
| 571 // Allow modifications to the layout tree structure, because that's what we wa
nt to test. | 578 // Allow modifications to the layout tree structure, because that's what we |
| 579 // want to test. |
| 572 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); | 580 document().lifecycle().advanceTo(DocumentLifecycle::InStyleRecalc); |
| 573 } | 581 } |
| 574 | 582 |
| 575 void MultiColumnTreeModifyingTest::reparentLayoutObject( | 583 void MultiColumnTreeModifyingTest::reparentLayoutObject( |
| 576 const char* newParentId, | 584 const char* newParentId, |
| 577 const char* childId, | 585 const char* childId, |
| 578 const char* insertBeforeId) { | 586 const char* insertBeforeId) { |
| 579 LayoutObject* newParent = getLayoutObjectByElementId(newParentId); | 587 LayoutObject* newParent = getLayoutObjectByElementId(newParentId); |
| 580 LayoutObject* child = getLayoutObjectByElementId(childId); | 588 LayoutObject* child = getLayoutObjectByElementId(childId); |
| 581 LayoutObject* insertBefore = | 589 LayoutObject* insertBefore = |
| 582 insertBeforeId ? getLayoutObjectByElementId(insertBeforeId) : nullptr; | 590 insertBeforeId ? getLayoutObjectByElementId(insertBeforeId) : nullptr; |
| 583 child->remove(); | 591 child->remove(); |
| 584 newParent->addChild(child, insertBefore); | 592 newParent->addChild(child, insertBefore); |
| 585 } | 593 } |
| 586 | 594 |
| 587 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) { | 595 void MultiColumnTreeModifyingTest::destroyLayoutObject(LayoutObject* child) { |
| 588 // Remove and destroy in separate steps, so that we get to test removal of sub
trees. | 596 // Remove and destroy in separate steps, so that we get to test removal of |
| 597 // subtrees. |
| 589 child->remove(); | 598 child->remove(); |
| 590 child->node()->detachLayoutTree(); | 599 child->node()->detachLayoutTree(); |
| 591 } | 600 } |
| 592 | 601 |
| 593 void MultiColumnTreeModifyingTest::destroyLayoutObject(const char* childId) { | 602 void MultiColumnTreeModifyingTest::destroyLayoutObject(const char* childId) { |
| 594 destroyLayoutObject(getLayoutObjectByElementId(childId)); | 603 destroyLayoutObject(getLayoutObjectByElementId(childId)); |
| 595 } | 604 } |
| 596 | 605 |
| 597 TEST_F(MultiColumnTreeModifyingTest, InsertFirstContentAndRemove) { | 606 TEST_F(MultiColumnTreeModifyingTest, InsertFirstContentAndRemove) { |
| 598 setMulticolHTML("<div id='block'></div><div id='mc'></div>"); | 607 setMulticolHTML("<div id='block'></div><div id='mc'></div>"); |
| 599 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 608 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 600 LayoutBlockFlow* block = | 609 LayoutBlockFlow* block = |
| 601 toLayoutBlockFlow(getLayoutObjectByElementId("block")); | 610 toLayoutBlockFlow(getLayoutObjectByElementId("block")); |
| 602 LayoutBlockFlow* multicolContainer = | 611 LayoutBlockFlow* multicolContainer = |
| 603 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); | 612 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); |
| 604 block->remove(); | 613 block->remove(); |
| 605 multicolContainer->addChild(block); | 614 multicolContainer->addChild(block); |
| 606 EXPECT_EQ(block->parent(), flowThread); | 615 EXPECT_EQ(block->parent(), flowThread); |
| 607 // A set should have appeared, now that the multicol container has content. | 616 // A set should have appeared, now that the multicol container has content. |
| 608 EXPECT_EQ(columnSetSignature(flowThread), "c"); | 617 EXPECT_EQ(columnSetSignature(flowThread), "c"); |
| 609 | 618 |
| 610 destroyLayoutObject(block); | 619 destroyLayoutObject(block); |
| 611 // The set should be gone again now, since there's nothing inside the multicol
container anymore. | 620 // The set should be gone again now, since there's nothing inside the multicol |
| 621 // container anymore. |
| 612 EXPECT_EQ(columnSetSignature("mc"), ""); | 622 EXPECT_EQ(columnSetSignature("mc"), ""); |
| 613 } | 623 } |
| 614 | 624 |
| 615 TEST_F(MultiColumnTreeModifyingTest, InsertContentBeforeContentAndRemove) { | 625 TEST_F(MultiColumnTreeModifyingTest, InsertContentBeforeContentAndRemove) { |
| 616 setMulticolHTML( | 626 setMulticolHTML( |
| 617 "<div id='block'></div><div id='mc'><div id='insertBefore'></div></div>"); | 627 "<div id='block'></div><div id='mc'><div id='insertBefore'></div></div>"); |
| 618 EXPECT_EQ(columnSetSignature("mc"), "c"); | 628 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 619 reparentLayoutObject("mc", "block", "insertBefore"); | 629 reparentLayoutObject("mc", "block", "insertBefore"); |
| 620 // There was already some content prior to our insertion, so no new set should
be inserted. | 630 // There was already some content prior to our insertion, so no new set should |
| 631 // be inserted. |
| 621 EXPECT_EQ(columnSetSignature("mc"), "c"); | 632 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 622 destroyLayoutObject("block"); | 633 destroyLayoutObject("block"); |
| 623 // There's still some content after the removal, so the set should remain. | 634 // There's still some content after the removal, so the set should remain. |
| 624 EXPECT_EQ(columnSetSignature("mc"), "c"); | 635 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 625 } | 636 } |
| 626 | 637 |
| 627 TEST_F(MultiColumnTreeModifyingTest, InsertContentAfterContentAndRemove) { | 638 TEST_F(MultiColumnTreeModifyingTest, InsertContentAfterContentAndRemove) { |
| 628 setMulticolHTML("<div id='block'></div><div id='mc'><div></div></div>"); | 639 setMulticolHTML("<div id='block'></div><div id='mc'><div></div></div>"); |
| 629 EXPECT_EQ(columnSetSignature("mc"), "c"); | 640 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 630 reparentLayoutObject("mc", "block"); | 641 reparentLayoutObject("mc", "block"); |
| 631 // There was already some content prior to our insertion, so no new set should
be inserted. | 642 // There was already some content prior to our insertion, so no new set should |
| 643 // be inserted. |
| 632 EXPECT_EQ(columnSetSignature("mc"), "c"); | 644 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 633 destroyLayoutObject("block"); | 645 destroyLayoutObject("block"); |
| 634 // There's still some content after the removal, so the set should remain. | 646 // There's still some content after the removal, so the set should remain. |
| 635 EXPECT_EQ(columnSetSignature("mc"), "c"); | 647 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 636 } | 648 } |
| 637 | 649 |
| 638 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAndRemove) { | 650 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAndRemove) { |
| 639 setMulticolHTML("<div id='spanner'></div><div id='mc'></div>"); | 651 setMulticolHTML("<div id='spanner'></div><div id='mc'></div>"); |
| 640 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); | 652 LayoutMultiColumnFlowThread* flowThread = findFlowThread("mc"); |
| 641 LayoutBlockFlow* spanner = | 653 LayoutBlockFlow* spanner = |
| 642 toLayoutBlockFlow(getLayoutObjectByElementId("spanner")); | 654 toLayoutBlockFlow(getLayoutObjectByElementId("spanner")); |
| 643 LayoutBlockFlow* multicolContainer = | 655 LayoutBlockFlow* multicolContainer = |
| 644 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); | 656 toLayoutBlockFlow(getLayoutObjectByElementId("mc")); |
| 645 spanner->remove(); | 657 spanner->remove(); |
| 646 multicolContainer->addChild(spanner); | 658 multicolContainer->addChild(spanner); |
| 647 EXPECT_EQ(spanner->parent(), flowThread); | 659 EXPECT_EQ(spanner->parent(), flowThread); |
| 648 // We should now have a spanner placeholder, since we just moved a spanner int
o the multicol container. | 660 // We should now have a spanner placeholder, since we just moved a spanner |
| 661 // into the multicol container. |
| 649 EXPECT_EQ(columnSetSignature(flowThread), "s"); | 662 EXPECT_EQ(columnSetSignature(flowThread), "s"); |
| 650 destroyLayoutObject(spanner); | 663 destroyLayoutObject(spanner); |
| 651 EXPECT_EQ(columnSetSignature(flowThread), ""); | 664 EXPECT_EQ(columnSetSignature(flowThread), ""); |
| 652 } | 665 } |
| 653 | 666 |
| 654 TEST_F(MultiColumnTreeModifyingTest, InsertTwoSpannersAndRemove) { | 667 TEST_F(MultiColumnTreeModifyingTest, InsertTwoSpannersAndRemove) { |
| 655 setMulticolHTML( | 668 setMulticolHTML( |
| 656 "<div id='block'>ee<div class='s'></div><div class='s'></div></div><div " | 669 "<div id='block'>ee<div class='s'></div><div class='s'></div></div><div " |
| 657 "id='mc'></div>"); | 670 "id='mc'></div>"); |
| 658 reparentLayoutObject("mc", "block"); | 671 reparentLayoutObject("mc", "block"); |
| 659 EXPECT_EQ(columnSetSignature("mc"), "css"); | 672 EXPECT_EQ(columnSetSignature("mc"), "css"); |
| 660 destroyLayoutObject("block"); | 673 destroyLayoutObject("block"); |
| 661 EXPECT_EQ(columnSetSignature("mc"), ""); | 674 EXPECT_EQ(columnSetSignature("mc"), ""); |
| 662 } | 675 } |
| 663 | 676 |
| 664 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAfterContentAndRemove) { | 677 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerAfterContentAndRemove) { |
| 665 setMulticolHTML("<div id='spanner'></div><div id='mc'><div></div></div>"); | 678 setMulticolHTML("<div id='spanner'></div><div id='mc'><div></div></div>"); |
| 666 reparentLayoutObject("mc", "spanner"); | 679 reparentLayoutObject("mc", "spanner"); |
| 667 // We should now have a spanner placeholder, since we just moved a spanner int
o the multicol container. | 680 // We should now have a spanner placeholder, since we just moved a spanner |
| 681 // into the multicol container. |
| 668 EXPECT_EQ(columnSetSignature("mc"), "cs"); | 682 EXPECT_EQ(columnSetSignature("mc"), "cs"); |
| 669 destroyLayoutObject("spanner"); | 683 destroyLayoutObject("spanner"); |
| 670 EXPECT_EQ(columnSetSignature("mc"), "c"); | 684 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 671 } | 685 } |
| 672 | 686 |
| 673 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerBeforeContentAndRemove) { | 687 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerBeforeContentAndRemove) { |
| 674 setMulticolHTML( | 688 setMulticolHTML( |
| 675 "<div id='spanner'></div><div id='mc'><div " | 689 "<div id='spanner'></div><div id='mc'><div " |
| 676 "id='columnContent'></div></div>"); | 690 "id='columnContent'></div></div>"); |
| 677 reparentLayoutObject("mc", "spanner", "columnContent"); | 691 reparentLayoutObject("mc", "spanner", "columnContent"); |
| 678 // We should now have a spanner placeholder, since we just moved a spanner int
o the multicol container. | 692 // We should now have a spanner placeholder, since we just moved a spanner |
| 693 // into the multicol container. |
| 679 EXPECT_EQ(columnSetSignature("mc"), "sc"); | 694 EXPECT_EQ(columnSetSignature("mc"), "sc"); |
| 680 destroyLayoutObject("spanner"); | 695 destroyLayoutObject("spanner"); |
| 681 EXPECT_EQ(columnSetSignature("mc"), "c"); | 696 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 682 } | 697 } |
| 683 | 698 |
| 684 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerBetweenContentAndRemove) { | 699 TEST_F(MultiColumnTreeModifyingTest, InsertSpannerBetweenContentAndRemove) { |
| 685 setMulticolHTML( | 700 setMulticolHTML( |
| 686 "<div id='spanner'></div><div id='mc'><div></div><div " | 701 "<div id='spanner'></div><div id='mc'><div></div><div " |
| 687 "id='insertBefore'></div></div>"); | 702 "id='insertBefore'></div></div>"); |
| 688 reparentLayoutObject("mc", "spanner", "insertBefore"); | 703 reparentLayoutObject("mc", "spanner", "insertBefore"); |
| 689 // Since the spanner was inserted in the middle of column content, what used t
o be one column | 704 // Since the spanner was inserted in the middle of column content, what used |
| 690 // set had to be split in two, in order to get a spot to insert the spanner pl
aceholder. | 705 // to be one column set had to be split in two, in order to get a spot to |
| 706 // insert the spanner placeholder. |
| 691 EXPECT_EQ(columnSetSignature("mc"), "csc"); | 707 EXPECT_EQ(columnSetSignature("mc"), "csc"); |
| 692 destroyLayoutObject("spanner"); | 708 destroyLayoutObject("spanner"); |
| 693 // The spanner placeholder should be gone again now, and the two sets be merge
d into one. | 709 // The spanner placeholder should be gone again now, and the two sets be |
| 710 // merged into one. |
| 694 EXPECT_EQ(columnSetSignature("mc"), "c"); | 711 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 695 } | 712 } |
| 696 | 713 |
| 697 TEST_F(MultiColumnTreeModifyingTest, | 714 TEST_F(MultiColumnTreeModifyingTest, |
| 698 InsertSubtreeWithContentAndSpannerAndRemove) { | 715 InsertSubtreeWithContentAndSpannerAndRemove) { |
| 699 setMulticolHTML( | 716 setMulticolHTML( |
| 700 "<div id='block'>text<div id='spanner'></div>text</div><div " | 717 "<div id='block'>text<div id='spanner'></div>text</div><div " |
| 701 "id='mc'></div>"); | 718 "id='mc'></div>"); |
| 702 reparentLayoutObject("mc", "block"); | 719 reparentLayoutObject("mc", "block"); |
| 703 EXPECT_EQ(columnSetSignature("mc"), "csc"); | 720 EXPECT_EQ(columnSetSignature("mc"), "csc"); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 EXPECT_EQ(columnSetSignature("mc"), "s"); | 784 EXPECT_EQ(columnSetSignature("mc"), "s"); |
| 768 } | 785 } |
| 769 | 786 |
| 770 TEST_F(MultiColumnTreeModifyingTest, | 787 TEST_F(MultiColumnTreeModifyingTest, |
| 771 InsertContentAfterContentBeforeSpannerAndRemove) { | 788 InsertContentAfterContentBeforeSpannerAndRemove) { |
| 772 setMulticolHTML( | 789 setMulticolHTML( |
| 773 "<div id='block'></div><div id='mc'>text<div id='insertBefore' " | 790 "<div id='block'></div><div id='mc'>text<div id='insertBefore' " |
| 774 "class='s'></div></div>"); | 791 "class='s'></div></div>"); |
| 775 EXPECT_EQ(columnSetSignature("mc"), "cs"); | 792 EXPECT_EQ(columnSetSignature("mc"), "cs"); |
| 776 reparentLayoutObject("mc", "block", "insertBefore"); | 793 reparentLayoutObject("mc", "block", "insertBefore"); |
| 777 // There was already some content before the spanner prior to our insertion, s
o no new set | 794 // There was already some content before the spanner prior to our insertion, |
| 778 // should be inserted. | 795 // so no new set should be inserted. |
| 779 EXPECT_EQ(columnSetSignature("mc"), "cs"); | 796 EXPECT_EQ(columnSetSignature("mc"), "cs"); |
| 780 destroyLayoutObject("block"); | 797 destroyLayoutObject("block"); |
| 781 EXPECT_EQ(columnSetSignature("mc"), "cs"); | 798 EXPECT_EQ(columnSetSignature("mc"), "cs"); |
| 782 } | 799 } |
| 783 | 800 |
| 784 TEST_F(MultiColumnTreeModifyingTest, | 801 TEST_F(MultiColumnTreeModifyingTest, |
| 785 InsertContentAfterContentAndSpannerAndRemove) { | 802 InsertContentAfterContentAndSpannerAndRemove) { |
| 786 setMulticolHTML( | 803 setMulticolHTML( |
| 787 "<div id='block'></div><div id='mc'>content<div class='s'></div></div>"); | 804 "<div id='block'></div><div id='mc'>content<div class='s'></div></div>"); |
| 788 EXPECT_EQ(columnSetSignature("mc"), "cs"); | 805 EXPECT_EQ(columnSetSignature("mc"), "cs"); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 "<div id='mc'>text<div id='spanner'><div " | 1081 "<div id='mc'>text<div id='spanner'><div " |
| 1065 "class='s'></div></div>text</div>"); | 1082 "class='s'></div></div>text</div>"); |
| 1066 EXPECT_EQ(columnSetSignature("mc"), "csc"); | 1083 EXPECT_EQ(columnSetSignature("mc"), "csc"); |
| 1067 destroyLayoutObject("spanner"); | 1084 destroyLayoutObject("spanner"); |
| 1068 EXPECT_EQ(columnSetSignature("mc"), "c"); | 1085 EXPECT_EQ(columnSetSignature("mc"), "c"); |
| 1069 } | 1086 } |
| 1070 | 1087 |
| 1071 } // anonymous namespace | 1088 } // anonymous namespace |
| 1072 | 1089 |
| 1073 } // namespace blink | 1090 } // namespace blink |
| OLD | NEW |