Changeset 107160 in webkit
- Timestamp:
- Feb 8, 2012 5:50:05 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r107159 r107160 1 2012-02-08 David Hyatt <hyatt@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=78157 4 5 Make multi-column layout work with line grids that are outside of the multi-column 6 block. 7 8 Reviewed by Dan Bernstein. 9 10 * fast/line-grid/line-grid-into-columns.html: Added. 11 * platform/mac/fast/line-grid/line-grid-into-columns-expected.png: Added. 12 * platform/mac/fast/line-grid/line-grid-into-columns-expected.txt: Added. 13 1 14 2012-02-08 Matt Falkenhagen <falken@chromium.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r107157 r107160 1 2012-02-08 David Hyatt <hyatt@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=78157 4 5 Make multi-column layout work with line grids that are outside of the multi-column 6 block. 7 8 Reviewed by Dan Bernstein. 9 10 Added new tests in fast/line-grid. 11 12 * rendering/LayoutState.cpp: 13 (WebCore::LayoutState::LayoutState): 14 (WebCore::LayoutState::propagateLineGridInfo): 15 (WebCore::LayoutState::establishLineGrid): 16 (WebCore): 17 (WebCore::LayoutState::computeLineGridPaginationOrigin): 18 * rendering/LayoutState.h: 19 (WebCore::LayoutState::LayoutState): 20 (WebCore::LayoutState::lineGrid): 21 (WebCore::LayoutState::lineGridOffset): 22 (WebCore::LayoutState::lineGridPaginationOrigin): 23 (WebCore::LayoutState::needsBlockDirectionLocationSetBeforeLayout): 24 (LayoutState): 25 * rendering/RenderBlock.cpp: 26 (WebCore::RenderBlock::layoutBlockChildren): 27 * rendering/RenderBlockLineLayout.cpp: 28 (WebCore::RenderBlock::layoutInlineChildren): 29 * rendering/RenderView.h: 30 (WebCore::RenderView::pushLayoutState): 31 * rendering/RootInlineBox.cpp: 32 (WebCore::RootInlineBox::lineGridSnapAdjustment): 33 1 34 2012-02-08 Matthew Delaney <mdelaney@apple.com> 2 35 -
trunk/Source/WebCore/rendering/LayoutState.cpp
r105420 r107160 38 38 LayoutState::LayoutState(LayoutState* prev, RenderBox* renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged, ColumnInfo* columnInfo) 39 39 : m_columnInfo(columnInfo) 40 , m_ currentLineGrid(0)40 , m_lineGrid(0) 41 41 , m_next(prev) 42 42 #ifndef NDEBUG … … 103 103 } 104 104 105 // Propagate line grid information. 106 propagateLineGridInfo(renderer); 107 105 108 if (!m_columnInfo) 106 109 m_columnInfo = m_next->m_columnInfo; … … 110 113 m_isPaginated = m_pageLogicalHeight || m_columnInfo; 111 114 112 // Propagate line grid information.113 propagateLineGridInfo(renderer);115 if (lineGrid() && renderer->hasColumns() && renderer->style()->hasInlineColumnAxis()) 116 computeLineGridPaginationOrigin(renderer); 114 117 115 118 // If we have a new grid to track, then add it to our set. … … 126 129 , m_pageLogicalHeightChanged(regionsChanged) 127 130 , m_columnInfo(0) 128 , m_ currentLineGrid(0)131 , m_lineGrid(0) 129 132 , m_next(prev) 130 133 #ifndef NDEBUG … … 143 146 , m_pageLogicalHeightChanged(false) 144 147 , m_columnInfo(0) 145 , m_ currentLineGrid(0)148 , m_lineGrid(0) 146 149 , m_next(0) 147 150 #ifndef NDEBUG … … 214 217 return; 215 218 216 m_currentLineGrid = m_next->m_currentLineGrid; 217 m_currentLineGridOffset = m_next->m_currentLineGridOffset; 219 m_lineGrid = m_next->m_lineGrid; 220 m_lineGridOffset = m_next->m_lineGridOffset; 221 m_lineGridPaginationOrigin = m_next->m_lineGridPaginationOrigin; 218 222 } 219 223 … … 221 225 { 222 226 // First check to see if this grid has been established already. 223 if (m_ currentLineGrid) {224 if (m_ currentLineGrid->style()->lineGrid() == block->style()->lineGrid())227 if (m_lineGrid) { 228 if (m_lineGrid->style()->lineGrid() == block->style()->lineGrid()) 225 229 return; 226 RenderBlock* currentGrid = m_ currentLineGrid;230 RenderBlock* currentGrid = m_lineGrid; 227 231 for (LayoutState* currentState = m_next; currentState; currentState = currentState->m_next) { 228 if (currentState->m_ currentLineGrid == currentGrid)232 if (currentState->m_lineGrid == currentGrid) 229 233 continue; 230 currentGrid = currentState->m_ currentLineGrid;234 currentGrid = currentState->m_lineGrid; 231 235 if (!currentGrid) 232 236 break; 233 237 if (currentGrid->style()->lineGrid() == block->style()->lineGrid()) { 234 m_ currentLineGrid = currentGrid;235 m_ currentLineGridOffset = currentState->m_currentLineGridOffset;238 m_lineGrid = currentGrid; 239 m_lineGridOffset = currentState->m_lineGridOffset; 236 240 return; 237 241 } … … 240 244 241 245 // We didn't find an already-established grid with this identifier. Our render object establishes the grid. 242 m_currentLineGrid = block; 243 m_currentLineGridOffset = m_layoutOffset; 246 m_lineGrid = block; 247 m_lineGridOffset = m_layoutOffset; 248 } 249 250 void LayoutState::computeLineGridPaginationOrigin(RenderBox* renderer) 251 { 252 // We need to cache a line grid pagination origin so that we understand how to reset the line grid 253 // at the top of each column. 254 // Get the current line grid and offset. 255 if (!lineGrid() || lineGrid()->style()->writingMode() != renderer->style()->writingMode()) 256 return; 257 258 // Get the hypothetical line box used to establish the grid. 259 RootInlineBox* lineGridBox = lineGrid()->lineGridBox(); 260 if (!lineGridBox) 261 return; 262 263 bool isHorizontalWritingMode = lineGrid()->isHorizontalWritingMode(); 264 265 LayoutUnit lineGridBlockOffset = isHorizontalWritingMode ? lineGridOffset().height() : lineGridOffset().width(); 266 267 // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple 268 // as established by the line box. 269 // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume 270 // the grid should honor line-box-contain. 271 LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading(); 272 if (!gridLineHeight) 273 return; 274 275 LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading(); 276 277 if (isPaginated() && pageLogicalHeight()) { 278 LayoutUnit pageLogicalTop = renderer->isHorizontalWritingMode() ? m_pageOffset.height() : m_pageOffset.width(); 279 if (pageLogicalTop > firstLineTopWithLeading) { 280 // Shift to the next highest line grid multiple past the page logical top. Cache the delta 281 // between this new value and the page logical top as the pagination origin. 282 LayoutUnit remainder = (pageLogicalTop - firstLineTopWithLeading) % gridLineHeight; 283 LayoutUnit paginationDelta = gridLineHeight - remainder; 284 if (isHorizontalWritingMode) 285 m_lineGridPaginationOrigin.setHeight(paginationDelta); 286 else 287 m_lineGridPaginationOrigin.setWidth(paginationDelta); 288 } 289 } 244 290 } 245 291 -
trunk/Source/WebCore/rendering/LayoutState.h
r106511 r107160 49 49 , m_pageLogicalHeightChanged(false) 50 50 , m_columnInfo(0) 51 , m_ currentLineGrid(0)51 , m_lineGrid(0) 52 52 , m_next(0) 53 53 #ifndef NDEBUG … … 82 82 bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; } 83 83 84 RenderBlock* currentLineGrid() const { return m_currentLineGrid; } 85 LayoutSize currentLineGridOffset() const { return m_currentLineGridOffset; } 84 RenderBlock* lineGrid() const { return m_lineGrid; } 85 LayoutSize lineGridOffset() const { return m_lineGridOffset; } 86 LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; } 86 87 87 88 LayoutSize layoutOffset() const { return m_layoutOffset; } 88 89 89 bool needsBlockDirectionLocationSetBeforeLayout() const { return m_ currentLineGrid || (m_isPaginated && m_pageLogicalHeight); }90 bool needsBlockDirectionLocationSetBeforeLayout() const { return m_lineGrid || (m_isPaginated && m_pageLogicalHeight); } 90 91 91 92 private: … … 95 96 void propagateLineGridInfo(RenderBox*); 96 97 void establishLineGrid(RenderBlock*); 98 99 void computeLineGridPaginationOrigin(RenderBox*); 97 100 98 101 public: … … 120 123 121 124 // The current line grid that we're snapping to and the offset of the start of the grid. 122 RenderBlock* m_currentLineGrid; 123 LayoutSize m_currentLineGridOffset; 124 125 RenderBlock* m_lineGrid; 126 LayoutSize m_lineGridOffset; 127 LayoutSize m_lineGridPaginationOrigin; 128 125 129 LayoutState* m_next; 126 130 #ifndef NDEBUG -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r107072 r107160 2023 2023 2024 2024 // Lay out our hypothetical grid line as though it occurs at the top of the block. 2025 if (view()->layoutState()-> currentLineGrid() == this)2025 if (view()->layoutState()->lineGrid() == this) 2026 2026 layoutLineGridBox(); 2027 2027 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r107032 r107160 1451 1451 1452 1452 // Lay out our hypothetical grid line as though it occurs at the top of the block. 1453 if (view()->layoutState() && view()->layoutState()-> currentLineGrid() == this)1453 if (view()->layoutState() && view()->layoutState()->lineGrid() == this) 1454 1454 layoutLineGridBox(); 1455 1455 -
trunk/Source/WebCore/rendering/RenderView.h
r106511 r107160 209 209 // We push LayoutState even if layoutState is disabled because it stores layoutDelta too. 210 210 if (!doingFullRepaint() || m_layoutState->isPaginated() || renderer->hasColumns() || renderer->inRenderFlowThread() 211 || m_layoutState-> currentLineGrid() || (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow())) {211 || m_layoutState->lineGrid() || (renderer->style()->lineGrid() != RenderStyle::initialLineGrid() && renderer->isBlockFlow())) { 212 212 m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, pageHeightChanged, colInfo); 213 213 return true; -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r107099 r107160 336 336 // Get the current line grid and offset. 337 337 LayoutState* layoutState = block()->view()->layoutState(); 338 RenderBlock* lineGrid = layoutState-> currentLineGrid();339 LayoutSize lineGridOffset = layoutState-> currentLineGridOffset();338 RenderBlock* lineGrid = layoutState->lineGrid(); 339 LayoutSize lineGridOffset = layoutState->lineGridOffset(); 340 340 if (!lineGrid || lineGrid->style()->writingMode() != block()->style()->writingMode()) 341 341 return 0; … … 360 360 LayoutUnit lineGridFontHeight = lineGridBox->logicalHeight(); 361 361 LayoutUnit firstTextTop = lineGridBlockOffset + lineGridBox->logicalTop(); 362 LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading(); 362 363 LayoutUnit firstBaselinePosition = firstTextTop + lineGridFontAscent; 363 364 … … 365 366 LayoutUnit currentFontAscent = block()->style()->fontMetrics().ascent(baselineType()); 366 367 LayoutUnit currentBaselinePosition = currentTextTop + currentFontAscent; 368 369 LayoutUnit lineGridPaginationOrigin = isHorizontal() ? layoutState->lineGridPaginationOrigin().height() : layoutState->lineGridPaginationOrigin().width(); 367 370 368 371 // If we're paginated, see if we're on a page after the first one. If so, the grid resets on subsequent pages. … … 370 373 LayoutUnit pageLogicalTop = 0; 371 374 if (layoutState->isPaginated() && layoutState->pageLogicalHeight()) { 372 pageLogicalTop = block()->pageLogicalTopForOffset(l ogicalTop() + delta);373 if (pageLogicalTop > first TextTop)374 firstTextTop = pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore() ;375 pageLogicalTop = block()->pageLogicalTopForOffset(lineTopWithLeading() + delta); 376 if (pageLogicalTop > firstLineTopWithLeading) 377 firstTextTop = pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore() + lineGridPaginationOrigin; 375 378 } 376 379 … … 406 409 return result; 407 410 408 // We may haveshifted to a new page. We need to do a re-snap when that happens.409 LayoutUnit newPageLogicalTop = block()->pageLogicalTopForOffset(l ogicalTop() + result);411 // We may end up shifted to a new page. We need to do a re-snap when that happens. 412 LayoutUnit newPageLogicalTop = block()->pageLogicalTopForOffset(lineBottomWithLeading() + result); 410 413 if (newPageLogicalTop == pageLogicalTop) 411 414 return result; 412 415 413 416 // Put ourselves at the top of the next page to force a snap onto the new grid established by that page. 414 return lineGridSnapAdjustment(newPageLogicalTop - (blockOffset + l ogicalTop()));417 return lineGridSnapAdjustment(newPageLogicalTop - (blockOffset + lineTopWithLeading())); 415 418 } 416 419
Note: See TracChangeset
for help on using the changeset viewer.