summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/LayoutState.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-09 14:16:12 +0100
commit03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch)
tree52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebCore/rendering/LayoutState.cpp
parentcd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff)
downloadqtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebCore/rendering/LayoutState.cpp')
-rw-r--r--Source/WebCore/rendering/LayoutState.cpp78
1 files changed, 62 insertions, 16 deletions
diff --git a/Source/WebCore/rendering/LayoutState.cpp b/Source/WebCore/rendering/LayoutState.cpp
index c59e97002..c9018c599 100644
--- a/Source/WebCore/rendering/LayoutState.cpp
+++ b/Source/WebCore/rendering/LayoutState.cpp
@@ -37,7 +37,7 @@ namespace WebCore {
LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo)
: m_columnInfo(columnInfo)
- , m_currentLineGrid(0)
+ , m_lineGrid(0)
, m_next(prev)
#ifndef NDEBUG
, m_renderer(renderer)
@@ -102,6 +102,9 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz
m_pageLogicalHeight = 0;
}
+ // Propagate line grid information.
+ propagateLineGridInfo(renderer);
+
if (!m_columnInfo)
m_columnInfo = m_next->m_columnInfo;
@@ -109,8 +112,8 @@ LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSiz
m_isPaginated = m_pageLogicalHeight || m_columnInfo;
- // Propagate line grid information.
- propagateLineGridInfo(renderer);
+ if (lineGrid() && renderer->hasColumns() && renderer->style()->hasInlineColumnAxis())
+ computeLineGridPaginationOrigin(renderer);
// If we have a new grid to track, then add it to our set.
if (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow())
@@ -125,7 +128,7 @@ LayoutState::LayoutState(LayoutState* prev, RenderFlowThread* flowThread, bool r
, m_pageLogicalHeight(1) // Use a fake height here. That value is not important, just needs to be non-zero.
, m_pageLogicalHeightChanged(regionsChanged)
, m_columnInfo(0)
- , m_currentLineGrid(0)
+ , m_lineGrid(0)
, m_next(prev)
#ifndef NDEBUG
, m_renderer(flowThread)
@@ -142,7 +145,7 @@ LayoutState::LayoutState(RenderObject* root)
, m_pageLogicalHeight(0)
, m_pageLogicalHeightChanged(false)
, m_columnInfo(0)
- , m_currentLineGrid(0)
+ , m_lineGrid(0)
, m_next(0)
#ifndef NDEBUG
, m_renderer(root)
@@ -213,34 +216,77 @@ void LayoutState::propagateLineGridInfo(RenderBox* renderer)
if (!m_next || renderer->isUnsplittableForPagination())
return;
- m_currentLineGrid = m_next->m_currentLineGrid;
- m_currentLineGridOffset = m_next->m_currentLineGridOffset;
+ m_lineGrid = m_next->m_lineGrid;
+ m_lineGridOffset = m_next->m_lineGridOffset;
+ m_lineGridPaginationOrigin = m_next->m_lineGridPaginationOrigin;
}
void LayoutState::establishLineGrid(RenderBlock* block)
{
// First check to see if this grid has been established already.
- if (m_currentLineGrid) {
- if (m_currentLineGrid->style()->lineGrid() == block->style()->lineGrid())
+ if (m_lineGrid) {
+ if (m_lineGrid->style()->lineGrid() == block->style()->lineGrid())
return;
- RenderBlock* currentGrid = m_currentLineGrid;
+ RenderBlock* currentGrid = m_lineGrid;
for (LayoutState* currentState = m_next; currentState; currentState = currentState->m_next) {
- if (currentState->m_currentLineGrid == currentGrid)
+ if (currentState->m_lineGrid == currentGrid)
continue;
- currentGrid = currentState->m_currentLineGrid;
+ currentGrid = currentState->m_lineGrid;
if (!currentGrid)
break;
if (currentGrid->style()->lineGrid() == block->style()->lineGrid()) {
- m_currentLineGrid = currentGrid;
- m_currentLineGridOffset = currentState->m_currentLineGridOffset;
+ m_lineGrid = currentGrid;
+ m_lineGridOffset = currentState->m_lineGridOffset;
return;
}
}
}
// We didn't find an already-established grid with this identifier. Our render object establishes the grid.
- m_currentLineGrid = block;
- m_currentLineGridOffset = m_layoutOffset;
+ m_lineGrid = block;
+ m_lineGridOffset = m_layoutOffset;
+}
+
+void LayoutState::computeLineGridPaginationOrigin(RenderBox* renderer)
+{
+ // We need to cache a line grid pagination origin so that we understand how to reset the line grid
+ // at the top of each column.
+ // Get the current line grid and offset.
+ if (!lineGrid() || lineGrid()->style()->writingMode() != renderer->style()->writingMode())
+ return;
+
+ // Get the hypothetical line box used to establish the grid.
+ RootInlineBox* lineGridBox = lineGrid()->lineGridBox();
+ if (!lineGridBox)
+ return;
+
+ bool isHorizontalWritingMode = lineGrid()->isHorizontalWritingMode();
+
+ LayoutUnit lineGridBlockOffset = isHorizontalWritingMode ? lineGridOffset().height() : lineGridOffset().width();
+
+ // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple
+ // as established by the line box.
+ // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume
+ // the grid should honor line-box-contain.
+ LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading();
+ if (!gridLineHeight)
+ return;
+
+ LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading();
+
+ if (isPaginated() && pageLogicalHeight()) {
+ LayoutUnit pageLogicalTop = renderer->isHorizontalWritingMode() ? m_pageOffset.height() : m_pageOffset.width();
+ if (pageLogicalTop > firstLineTopWithLeading) {
+ // Shift to the next highest line grid multiple past the page logical top. Cache the delta
+ // between this new value and the page logical top as the pagination origin.
+ LayoutUnit remainder = (pageLogicalTop - firstLineTopWithLeading) % gridLineHeight;
+ LayoutUnit paginationDelta = gridLineHeight - remainder;
+ if (isHorizontalWritingMode)
+ m_lineGridPaginationOrigin.setHeight(paginationDelta);
+ else
+ m_lineGridPaginationOrigin.setWidth(paginationDelta);
+ }
+ }
}
} // namespace WebCore