LayoutState::LayoutState(LayoutBox& layoutObject, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, bool containingBlockLogicalWidthChanged) : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged) , m_next(layoutObject.view()->layoutState()) , m_layoutObject(layoutObject) { if (layoutObject.isLayoutFlowThread()) m_flowThread = toLayoutFlowThread(&layoutObject); else if (!layoutObject.isOutOfFlowPositioned() && !layoutObject.isColumnSpanAll()) m_flowThread = m_next->flowThread(); else m_flowThread = nullptr; layoutObject.view()->pushLayoutState(*this); bool fixed = layoutObject.isOutOfFlowPositioned() && layoutObject.style()->position() == FixedPosition; if (fixed) { // FIXME: This doesn't work correctly with transforms. FloatPoint fixedOffset = layoutObject.view()->localToAbsolute(FloatPoint(), IsFixed); m_layoutOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset; } else { m_layoutOffset = m_next->m_layoutOffset + offset; } if (layoutObject.isOutOfFlowPositioned() && !fixed) { if (LayoutObject* container = layoutObject.container()) { if (container->style()->hasInFlowPosition() && container->isLayoutInline()) m_layoutOffset += toLayoutInline(container)->offsetForInFlowPositionedInline(layoutObject); } } // If we establish a new page height, then cache the offset to the top of the first page. // We can compare this later on to figure out what part of the page we're actually on, if (pageLogicalHeight || layoutObject.isLayoutFlowThread()) { m_pageLogicalHeight = pageLogicalHeight; bool isFlipped = layoutObject.style()->isFlippedBlocksWritingMode(); m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? layoutObject.borderLeft() + layoutObject.paddingLeft() : layoutObject.borderRight() + layoutObject.paddingRight()), m_layoutOffset.height() + (!isFlipped ? layoutObject.borderTop() + layoutObject.paddingTop() : layoutObject.borderBottom() + layoutObject.paddingBottom())); m_pageLogicalHeightChanged = pageLogicalHeightChanged; m_isPaginated = true; } else if (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot()) { // Pagination inside SVG is not allowed. m_flowThread = nullptr; m_pageLogicalHeightChanged = false; m_isPaginated = false; } else { // If we don't establish a new page height, then propagate the old page height and offset down. m_pageLogicalHeight = m_next->m_pageLogicalHeight; m_pageLogicalHeightChanged = m_next->m_pageLogicalHeightChanged; m_pageOffset = m_next->m_pageOffset; // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and // writing mode roots. if (layoutObject.isUnsplittableForPagination()) { m_flowThread = nullptr; m_pageLogicalHeight = 0; m_isPaginated = false; } else { m_isPaginated = m_pageLogicalHeight || m_flowThread; } } // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. }
LayoutState::LayoutState(LayoutBox& layoutObject, bool containingBlockLogicalWidthChanged) : m_containingBlockLogicalWidthChanged(containingBlockLogicalWidthChanged), m_next(layoutObject.view()->layoutState()), m_layoutObject(layoutObject) { if (layoutObject.isLayoutFlowThread()) m_flowThread = toLayoutFlowThread(&layoutObject); else m_flowThread = m_next->flowThread(); m_paginationStateChanged = m_next->m_paginationStateChanged; layoutObject.view()->pushLayoutState(*this); m_heightOffsetForTableHeaders = m_next->heightOffsetForTableHeaders(); if (layoutObject.isLayoutFlowThread()) { // Entering a new pagination context. m_paginationOffset = LayoutSize(); m_isPaginated = true; return; } // Disable pagination for objects we don't support. For now this includes // overflow:scroll/auto, inline blocks and writing mode roots. Additionally, // pagination inside SVG is not allowed. if (layoutObject.getPaginationBreakability() == LayoutBox::ForbidBreaks || (m_layoutObject.isSVG() && !m_layoutObject.isSVGRoot())) { m_flowThread = nullptr; m_isPaginated = false; return; } m_isPaginated = m_next->m_isPaginated; if (!m_isPaginated) return; // Now adjust the pagination offset, so that we can easily figure out how far // away we are from the start of the pagination context. m_paginationOffset = m_next->m_paginationOffset; bool fixed = layoutObject.isOutOfFlowPositioned() && layoutObject.style()->position() == FixedPosition; if (fixed) return; m_paginationOffset = m_next->m_paginationOffset + layoutObject.locationOffset(); if (!layoutObject.isOutOfFlowPositioned()) return; if (LayoutObject* container = layoutObject.container()) { if (container->style()->hasInFlowPosition() && container->isLayoutInline()) { m_paginationOffset += toLayoutInline(container)->offsetForInFlowPositionedInline( layoutObject); } } // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if // present. }