void LayoutMultiColumnFlowThread::createAndInsertMultiColumnSet(LayoutBox* insertBefore) { LayoutBlockFlow* multicolContainer = multiColumnBlockFlow(); LayoutMultiColumnSet* newSet = LayoutMultiColumnSet::createAnonymous(*this, multicolContainer->styleRef()); multicolContainer->LayoutBlock::addChild(newSet, insertBefore); invalidateColumnSets(); // We cannot handle immediate column set siblings (and there's no need for it, either). // There has to be at least one spanner separating them. ASSERT(!newSet->previousSiblingMultiColumnBox() || !newSet->previousSiblingMultiColumnBox()->isLayoutMultiColumnSet()); ASSERT(!newSet->nextSiblingMultiColumnBox() || !newSet->nextSiblingMultiColumnBox()->isLayoutMultiColumnSet()); }
void LayoutMultiColumnFlowThread::createAndInsertSpannerPlaceholder(LayoutBox* spannerObjectInFlowThread, LayoutObject* insertedBeforeInFlowThread) { LayoutBox* insertBeforeColumnBox = nullptr; LayoutMultiColumnSet* setToSplit = nullptr; if (insertedBeforeInFlowThread) { // The spanner is inserted before something. Figure out what this entails. If the // next object is a spanner too, it means that we can simply insert a new spanner // placeholder in front of its placeholder. insertBeforeColumnBox = insertedBeforeInFlowThread->spannerPlaceholder(); if (!insertBeforeColumnBox) { // The next object isn't a spanner; it's regular column content. Examine what // comes right before us in the flow thread, then. LayoutObject* previousLayoutObject = previousInPreOrderSkippingOutOfFlow(this, spannerObjectInFlowThread); if (!previousLayoutObject || previousLayoutObject == this) { // The spanner is inserted as the first child of the multicol container, // which means that we simply insert a new spanner placeholder at the // beginning. insertBeforeColumnBox = firstMultiColumnBox(); } else if (LayoutMultiColumnSpannerPlaceholder* previousPlaceholder = containingColumnSpannerPlaceholder(previousLayoutObject)) { // Before us is another spanner. We belong right after it then. insertBeforeColumnBox = previousPlaceholder->nextSiblingMultiColumnBox(); } else { // We're inside regular column content with both feet. Find out which column // set this is. It needs to be split it into two sets, so that we can insert // a new spanner placeholder between them. setToSplit = mapDescendantToColumnSet(previousLayoutObject); ASSERT(setToSplit == mapDescendantToColumnSet(insertedBeforeInFlowThread)); insertBeforeColumnBox = setToSplit->nextSiblingMultiColumnBox(); // We've found out which set that needs to be split. Now proceed to // inserting the spanner placeholder, and then insert a second column set. } } ASSERT(setToSplit || insertBeforeColumnBox); } LayoutBlockFlow* multicolContainer = multiColumnBlockFlow(); LayoutMultiColumnSpannerPlaceholder* newPlaceholder = LayoutMultiColumnSpannerPlaceholder::createAnonymous(multicolContainer->styleRef(), *spannerObjectInFlowThread); ASSERT(!insertBeforeColumnBox || insertBeforeColumnBox->parent() == multicolContainer); multicolContainer->LayoutBlock::addChild(newPlaceholder, insertBeforeColumnBox); spannerObjectInFlowThread->setSpannerPlaceholder(*newPlaceholder); if (setToSplit) createAndInsertMultiColumnSet(insertBeforeColumnBox); }