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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) | 540 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) |
541 { | 541 { |
542 if (isHorizontalWritingMode()) { | 542 if (isHorizontalWritingMode()) { |
543 child->setY(logicalTop); | 543 child->setY(logicalTop); |
544 } else { | 544 } else { |
545 child->setX(logicalTop); | 545 child->setX(logicalTop); |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
| 549 class ColumnSpannerLayoutScope { |
| 550 public: |
| 551 ColumnSpannerLayoutScope() |
| 552 : m_spanner(0) |
| 553 { |
| 554 } |
| 555 |
| 556 ~ColumnSpannerLayoutScope() |
| 557 { |
| 558 if (!m_spanner) |
| 559 return; |
| 560 m_spanner->flowThreadContainingBlock()->exitColumnSpannerAfterLayout(m_s
panner, m_spanner->parentBlock()->logicalHeight()); |
| 561 } |
| 562 |
| 563 LayoutUnit enterSpanner(RenderBox* spanner, SubtreeLayoutScope& layoutScope) |
| 564 { |
| 565 ASSERT(!m_spanner); |
| 566 m_spanner = spanner; |
| 567 return m_spanner->flowThreadContainingBlock()->enterColumnSpannerBeforeL
ayout(m_spanner, m_spanner->parentBlock()->logicalHeight(), layoutScope); |
| 568 } |
| 569 |
| 570 private: |
| 571 RenderBox* m_spanner; |
| 572 }; |
| 573 |
549 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) | 574 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) |
550 { | 575 { |
551 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); | 576 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
552 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); | 577 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
553 | 578 |
| 579 SubtreeLayoutScope layoutScope(*child); |
| 580 |
| 581 ColumnSpannerLayoutScope columnSpannerLayoutScope; |
| 582 if (child->isColumnSpanAll()) { |
| 583 LayoutUnit adjustment = columnSpannerLayoutScope.enterSpanner(child, lay
outScope); |
| 584 // A spanner needs to start at an exact column boundary inside the flow
thread, so that it |
| 585 // doesn't bleed into a preceding column. That's what the adjustment is
about. |
| 586 setLogicalHeight(logicalHeight() + adjustment); |
| 587 } |
| 588 |
554 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. | 589 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. |
555 child->computeAndSetBlockDirectionMargins(this); | 590 child->computeAndSetBlockDirectionMargins(this); |
556 | 591 |
557 // Try to guess our correct logical top position. In most cases this guess w
ill | 592 // Try to guess our correct logical top position. In most cases this guess w
ill |
558 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) | 593 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) |
559 // will we have to potentially relayout. | 594 // will we have to potentially relayout. |
560 LayoutUnit estimateWithoutPagination; | 595 LayoutUnit estimateWithoutPagination; |
561 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); | 596 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); |
562 | 597 |
563 // Cache our old rect so that we can dirty the proper paint invalidation rec
ts if the child moves. | 598 // Cache our old rect so that we can dirty the proper paint invalidation rec
ts if the child moves. |
(...skipping 21 matching lines...) Expand all Loading... |
585 markDescendantsWithFloats = true; | 620 markDescendantsWithFloats = true; |
586 } | 621 } |
587 | 622 |
588 if (childRenderBlockFlow) { | 623 if (childRenderBlockFlow) { |
589 if (markDescendantsWithFloats) | 624 if (markDescendantsWithFloats) |
590 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); | 625 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); |
591 if (!child->isWritingModeRoot()) | 626 if (!child->isWritingModeRoot()) |
592 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); | 627 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); |
593 } | 628 } |
594 | 629 |
595 SubtreeLayoutScope layoutScope(*child); | |
596 if (!child->needsLayout()) | 630 if (!child->needsLayout()) |
597 child->markForPaginationRelayoutIfNeeded(layoutScope); | 631 child->markForPaginationRelayoutIfNeeded(layoutScope); |
598 | 632 |
599 bool childNeededLayout = child->needsLayout(); | 633 bool childNeededLayout = child->needsLayout(); |
600 if (childNeededLayout) | 634 if (childNeededLayout) |
601 child->layout(); | 635 child->layout(); |
602 | 636 |
603 // Cache if we are at the top of the block right now. | 637 // Cache if we are at the top of the block right now. |
604 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); | 638 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); |
605 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); | 639 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 // We're at the very top of a page or column. | 894 // We're at the very top of a page or column. |
861 if (lineBox != firstRootBox()) | 895 if (lineBox != firstRootBox()) |
862 lineBox->setIsFirstAfterPageBreak(true); | 896 lineBox->setIsFirstAfterPageBreak(true); |
863 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) | 897 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) |
864 setPageBreak(logicalOffset, lineHeight); | 898 setPageBreak(logicalOffset, lineHeight); |
865 } | 899 } |
866 } | 900 } |
867 | 901 |
868 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox* child, LayoutU
nit logicalOffset, bool includeMargins) | 902 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox* child, LayoutU
nit logicalOffset, bool includeMargins) |
869 { | 903 { |
| 904 if (child->isColumnSpanAll()) |
| 905 return logicalOffset; |
870 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo
wThreadContainingBlock(); | 906 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo
wThreadContainingBlock(); |
871 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); | 907 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); |
872 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) | 908 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) |
873 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); | 909 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); |
874 if (!isUnsplittable) | 910 if (!isUnsplittable) |
875 return logicalOffset; | 911 return logicalOffset; |
876 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); | 912 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); |
877 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 913 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
878 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | 914 updateMinimumPageHeight(logicalOffset, childLogicalHeight); |
879 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) | 915 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 marginInfo.clearMargin(); | 1326 marginInfo.clearMargin(); |
1291 } | 1327 } |
1292 | 1328 |
1293 if (marginInfo.margin()) | 1329 if (marginInfo.margin()) |
1294 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); | 1330 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); |
1295 } | 1331 } |
1296 | 1332 |
1297 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins | 1333 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins |
1298 // collapsed into the page edge. | 1334 // collapsed into the page edge. |
1299 LayoutState* layoutState = view()->layoutState(); | 1335 LayoutState* layoutState = view()->layoutState(); |
1300 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop) { | 1336 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) { |
1301 LayoutUnit oldLogicalTop = logicalTop; | 1337 LayoutUnit oldLogicalTop = logicalTop; |
1302 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); | 1338 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); |
1303 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1339 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
1304 } | 1340 } |
1305 | 1341 |
1306 if (previousBlockFlow) { | 1342 if (previousBlockFlow) { |
1307 // If |child| is a self-collapsing block it may have collapsed into a pr
evious sibling and although it hasn't reduced the height of the parent yet | 1343 // If |child| is a self-collapsing block it may have collapsed into a pr
evious sibling and although it hasn't reduced the height of the parent yet |
1308 // any floats from the parent will now overhang. | 1344 // any floats from the parent will now overhang. |
1309 LayoutUnit oldLogicalHeight = logicalHeight(); | 1345 LayoutUnit oldLogicalHeight = logicalHeight(); |
1310 setLogicalHeight(logicalTop); | 1346 setLogicalHeight(logicalTop); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 } | 1542 } |
1507 | 1543 |
1508 // Collapse the result with our current margins. | 1544 // Collapse the result with our current margins. |
1509 if (!discardMarginBefore) | 1545 if (!discardMarginBefore) |
1510 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1546 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
1511 } | 1547 } |
1512 | 1548 |
1513 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1549 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
1514 // page. | 1550 // page. |
1515 LayoutState* layoutState = view()->layoutState(); | 1551 LayoutState* layoutState = view()->layoutState(); |
1516 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight()) | 1552 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight() && !child->isColumnSpanAll()) |
1517 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); | 1553 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); |
1518 | 1554 |
1519 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); | 1555 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); |
1520 | 1556 |
1521 estimateWithoutPagination = logicalTopEstimate; | 1557 estimateWithoutPagination = logicalTopEstimate; |
1522 | 1558 |
1523 if (layoutState->isPaginated()) { | 1559 if (layoutState->isPaginated()) { |
1524 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. | 1560 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. |
1525 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); | 1561 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
1526 | 1562 |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 FrameView* frameView = document().view(); | 3114 FrameView* frameView = document().view(); |
3079 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3115 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3080 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3116 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3081 if (height() < visibleHeight) | 3117 if (height() < visibleHeight) |
3082 top += (visibleHeight - height()) / 2; | 3118 top += (visibleHeight - height()) / 2; |
3083 setY(top); | 3119 setY(top); |
3084 dialog->setCentered(top); | 3120 dialog->setCentered(top); |
3085 } | 3121 } |
3086 | 3122 |
3087 } // namespace blink | 3123 } // namespace blink |
OLD | NEW |