OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bool LayoutBlockFlow::updateLogicalWidthAndColumnWidth() { | 271 bool LayoutBlockFlow::updateLogicalWidthAndColumnWidth() { |
272 bool relayoutChildren = LayoutBlock::updateLogicalWidthAndColumnWidth(); | 272 bool relayoutChildren = LayoutBlock::updateLogicalWidthAndColumnWidth(); |
273 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { | 273 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { |
274 if (flowThread->needsNewWidth()) | 274 if (flowThread->needsNewWidth()) |
275 return true; | 275 return true; |
276 } | 276 } |
277 return relayoutChildren; | 277 return relayoutChildren; |
278 } | 278 } |
279 | 279 |
280 void LayoutBlockFlow::checkForPaginationLogicalHeightChange( | 280 void LayoutBlockFlow::checkForPaginationLogicalHeightChange( |
281 LayoutUnit& pageLogicalHeight, | 281 LayoutUnit& pageLogicalHeight) { |
282 bool& pageLogicalHeightChanged, | |
283 bool& hasSpecifiedPageLogicalHeight) { | |
284 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { | 282 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { |
285 // Calculate the non-auto content box height, or set it to 0 if it's auto. | 283 // Calculate the non-auto content box height, or set it to 0 if it's auto. |
286 // We need to know this before layout, so that we can figure out where to | 284 // We need to know this before layout, so that we can figure out where to |
287 // insert column breaks. We also treat LayoutView (which may be paginated, | 285 // insert column breaks. We also treat LayoutView (which may be paginated, |
288 // which uses the multicol implmentation) as having non-auto height, since | 286 // which uses the multicol implmentation) as having non-auto height, since |
289 // its height is deduced from the viewport height. | 287 // its height is deduced from the viewport height. |
290 // We use computeLogicalHeight() to calculate the content box height. That | 288 // We use computeLogicalHeight() to calculate the content box height. That |
291 // method will clamp against max-height and min-height. Since we're now at | 289 // method will clamp against max-height and min-height. Since we're now at |
292 // the beginning of layout, and we don't know the actual height of the | 290 // the beginning of layout, and we don't know the actual height of the |
293 // content yet, only call that method when height is definite, or we might | 291 // content yet, only call that method when height is definite, or we might |
294 // fool ourselves into believing that columns have a definite height when | 292 // fool ourselves into believing that columns have a definite height when |
295 // they in fact don't. | 293 // they in fact don't. |
296 LayoutUnit columnHeight; | 294 LayoutUnit columnHeight; |
297 if (hasDefiniteLogicalHeight() || isLayoutView()) { | 295 if (hasDefiniteLogicalHeight() || isLayoutView()) { |
298 LogicalExtentComputedValues computedValues; | 296 LogicalExtentComputedValues computedValues; |
299 computeLogicalHeight(LayoutUnit(), logicalTop(), computedValues); | 297 computeLogicalHeight(LayoutUnit(), logicalTop(), computedValues); |
300 columnHeight = computedValues.m_extent - borderAndPaddingLogicalHeight() - | 298 columnHeight = computedValues.m_extent - borderAndPaddingLogicalHeight() - |
301 scrollbarLogicalHeight(); | 299 scrollbarLogicalHeight(); |
302 } | 300 } |
303 pageLogicalHeightChanged = | |
304 columnHeight != flowThread->columnHeightAvailable(); | |
305 flowThread->setColumnHeightAvailable(std::max(columnHeight, LayoutUnit())); | 301 flowThread->setColumnHeightAvailable(std::max(columnHeight, LayoutUnit())); |
306 } else if (isLayoutFlowThread()) { | 302 } else if (isLayoutFlowThread()) { |
307 LayoutFlowThread* flowThread = toLayoutFlowThread(this); | 303 LayoutFlowThread* flowThread = toLayoutFlowThread(this); |
308 | 304 |
309 // FIXME: This is a hack to always make sure we have a page logical height, | 305 // FIXME: This is a hack to always make sure we have a page logical height, |
310 // if said height is known. The page logical height thing in LayoutState is | 306 // if said height is known. The page logical height thing in LayoutState is |
311 // meaningless for flow thread-based pagination (page height isn't | 307 // meaningless for flow thread-based pagination (page height isn't |
312 // necessarily uniform throughout the flow thread), but as long as it is | 308 // necessarily uniform throughout the flow thread), but as long as it is |
313 // used universally as a means to determine whether page height is known or | 309 // used universally as a means to determine whether page height is known or |
314 // not, we need this. Page height is unknown when column balancing is | 310 // not, we need this. Page height is unknown when column balancing is |
315 // enabled and flow thread height is still unknown (i.e. during the first | 311 // enabled and flow thread height is still unknown (i.e. during the first |
316 // layout pass). When it's unknown, we need to prevent the pagination code | 312 // layout pass). When it's unknown, we need to prevent the pagination code |
317 // from assuming page breaks everywhere and thereby eating every top margin. | 313 // from assuming page breaks everywhere and thereby eating every top margin. |
318 // It should be trivial to clean up and get rid of this hack once the old | 314 // It should be trivial to clean up and get rid of this hack once the old |
319 // multicol implementation is gone. | 315 // multicol implementation is gone. |
320 pageLogicalHeight = | 316 pageLogicalHeight = |
321 flowThread->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(); | 317 flowThread->isPageLogicalHeightKnown() ? LayoutUnit(1) : LayoutUnit(); |
322 | |
323 pageLogicalHeightChanged = flowThread->pageLogicalSizeChanged(); | |
324 } | 318 } |
325 } | 319 } |
326 | 320 |
327 void LayoutBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak) { | 321 void LayoutBlockFlow::setBreakAtLineToAvoidWidow(int lineToBreak) { |
328 ASSERT(lineToBreak >= 0); | 322 ASSERT(lineToBreak >= 0); |
329 ensureRareData(); | 323 ensureRareData(); |
330 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow); | 324 ASSERT(!m_rareData->m_didBreakAtLineToAvoidWidow); |
331 m_rareData->m_lineBreakToAvoidWidow = lineToBreak; | 325 m_rareData->m_lineBreakToAvoidWidow = lineToBreak; |
332 } | 326 } |
333 | 327 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 DISABLE_CFI_PERF | 462 DISABLE_CFI_PERF |
469 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, | 463 inline bool LayoutBlockFlow::layoutBlockFlow(bool relayoutChildren, |
470 LayoutUnit& pageLogicalHeight, | 464 LayoutUnit& pageLogicalHeight, |
471 SubtreeLayoutScope& layoutScope) { | 465 SubtreeLayoutScope& layoutScope) { |
472 LayoutUnit oldLeft = logicalLeft(); | 466 LayoutUnit oldLeft = logicalLeft(); |
473 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); | 467 bool logicalWidthChanged = updateLogicalWidthAndColumnWidth(); |
474 relayoutChildren |= logicalWidthChanged; | 468 relayoutChildren |= logicalWidthChanged; |
475 | 469 |
476 rebuildFloatsFromIntruding(); | 470 rebuildFloatsFromIntruding(); |
477 | 471 |
478 bool pageLogicalHeightChanged = false; | 472 checkForPaginationLogicalHeightChange(pageLogicalHeight); |
479 bool hasSpecifiedPageLogicalHeight = false; | |
480 checkForPaginationLogicalHeightChange(pageLogicalHeight, | |
481 pageLogicalHeightChanged, | |
482 hasSpecifiedPageLogicalHeight); | |
483 if (pageLogicalHeightChanged) | |
484 relayoutChildren = true; | |
485 | 473 |
486 LayoutState state(*this, pageLogicalHeight, logicalWidthChanged); | 474 LayoutState state(*this, pageLogicalHeight, logicalWidthChanged); |
487 | 475 |
488 if (m_paginationStateChanged) { | 476 if (m_paginationStateChanged) { |
489 // We now need a deep layout to clean up struts after pagination, if we | 477 // We now need a deep layout to clean up struts after pagination, if we |
490 // just ceased to be paginated, or, if we just became paginated on the | 478 // just ceased to be paginated, or, if we just became paginated on the |
491 // other hand, we now need the deep layout, to insert pagination struts. | 479 // other hand, we now need the deep layout, to insert pagination struts. |
492 m_paginationStateChanged = false; | 480 m_paginationStateChanged = false; |
493 state.setPaginationStateChanged(); | 481 state.setPaginationStateChanged(); |
494 } | 482 } |
(...skipping 4062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4557 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 4545 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
4558 } | 4546 } |
4559 | 4547 |
4560 void LayoutBlockFlow::invalidateDisplayItemClients( | 4548 void LayoutBlockFlow::invalidateDisplayItemClients( |
4561 PaintInvalidationReason invalidationReason) const { | 4549 PaintInvalidationReason invalidationReason) const { |
4562 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( | 4550 BlockFlowPaintInvalidator(*this).invalidateDisplayItemClients( |
4563 invalidationReason); | 4551 invalidationReason); |
4564 } | 4552 } |
4565 | 4553 |
4566 } // namespace blink | 4554 } // namespace blink |
OLD | NEW |