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 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 538 |
539 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) | 539 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) |
540 { | 540 { |
541 if (isHorizontalWritingMode()) { | 541 if (isHorizontalWritingMode()) { |
542 child->setY(logicalTop); | 542 child->setY(logicalTop); |
543 } else { | 543 } else { |
544 child->setX(logicalTop); | 544 child->setX(logicalTop); |
545 } | 545 } |
546 } | 546 } |
547 | 547 |
| 548 class ColumnSpannerLayoutScope { |
| 549 public: |
| 550 ColumnSpannerLayoutScope() |
| 551 : m_spanner(0) { } |
| 552 |
| 553 ~ColumnSpannerLayoutScope() |
| 554 { |
| 555 if (!m_spanner) |
| 556 return; |
| 557 m_spanner->flowThreadContainingBlock()->leaveColumnSpanner(m_spanner, m_
spanner->containingBlock()->logicalHeight()); |
| 558 } |
| 559 |
| 560 LayoutUnit enterSpanner(RenderBox* spanner, SubtreeLayoutScope& layoutScope) |
| 561 { |
| 562 ASSERT(!m_spanner); |
| 563 m_spanner = spanner; |
| 564 return m_spanner->flowThreadContainingBlock()->enterColumnSpanner(m_span
ner, m_spanner->containingBlock()->logicalHeight(), layoutScope); |
| 565 } |
| 566 |
| 567 private: |
| 568 RenderBox* m_spanner; |
| 569 }; |
| 570 |
548 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) | 571 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) |
549 { | 572 { |
550 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); | 573 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
551 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); | 574 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
552 | 575 |
| 576 SubtreeLayoutScope layoutScope(*child); |
| 577 |
| 578 ColumnSpannerLayoutScope columnSpannerLayoutScope; |
| 579 if (child->isColumnSpanAll()) { |
| 580 // Margins of a column spanner cannot collapse with anything. Block dire
ction margins on |
| 581 // spanners will be ignored here, inside flow thread layout. Instead the
y'll be added around |
| 582 // the RenderMultiColumnSpannerSet. Now skip past the pending margin tha
t belongs to the |
| 583 // columns. |
| 584 setLogicalHeight(logicalHeight() + marginInfo.margin()); |
| 585 marginInfo.clearMargin(); |
| 586 LayoutUnit adjustment = columnSpannerLayoutScope.enterSpanner(child, lay
outScope); |
| 587 // A spanner needs to start at an exact column boundary inside the flow
thread, so that it |
| 588 // doesn't bleed into a preceding column. That's what the adjustment is
about. |
| 589 setLogicalHeight(logicalHeight() + adjustment); |
| 590 } |
| 591 |
553 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. | 592 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. |
554 child->computeAndSetBlockDirectionMargins(this); | 593 child->computeAndSetBlockDirectionMargins(this); |
555 | 594 |
556 // Try to guess our correct logical top position. In most cases this guess w
ill | 595 // Try to guess our correct logical top position. In most cases this guess w
ill |
557 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) | 596 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) |
558 // will we have to potentially relayout. | 597 // will we have to potentially relayout. |
559 LayoutUnit estimateWithoutPagination; | 598 LayoutUnit estimateWithoutPagination; |
560 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); | 599 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); |
561 | 600 |
562 // Cache our old rect so that we can dirty the proper paint invalidation rec
ts if the child moves. | 601 // 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... |
584 markDescendantsWithFloats = true; | 623 markDescendantsWithFloats = true; |
585 } | 624 } |
586 | 625 |
587 if (childRenderBlockFlow) { | 626 if (childRenderBlockFlow) { |
588 if (markDescendantsWithFloats) | 627 if (markDescendantsWithFloats) |
589 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); | 628 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); |
590 if (!child->isWritingModeRoot()) | 629 if (!child->isWritingModeRoot()) |
591 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); | 630 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); |
592 } | 631 } |
593 | 632 |
594 SubtreeLayoutScope layoutScope(*child); | |
595 if (!child->needsLayout()) | 633 if (!child->needsLayout()) |
596 child->markForPaginationRelayoutIfNeeded(layoutScope); | 634 child->markForPaginationRelayoutIfNeeded(layoutScope); |
597 | 635 |
598 bool childNeededLayout = child->needsLayout(); | 636 bool childNeededLayout = child->needsLayout(); |
599 if (childNeededLayout) | 637 if (childNeededLayout) |
600 child->layout(); | 638 child->layout(); |
601 | 639 |
602 // Cache if we are at the top of the block right now. | 640 // Cache if we are at the top of the block right now. |
603 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); | 641 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); |
604 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); | 642 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 marginInfo.clearMargin(); | 1327 marginInfo.clearMargin(); |
1290 } | 1328 } |
1291 | 1329 |
1292 if (marginInfo.margin()) | 1330 if (marginInfo.margin()) |
1293 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); | 1331 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); |
1294 } | 1332 } |
1295 | 1333 |
1296 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins | 1334 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins |
1297 // collapsed into the page edge. | 1335 // collapsed into the page edge. |
1298 LayoutState* layoutState = view()->layoutState(); | 1336 LayoutState* layoutState = view()->layoutState(); |
1299 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop) { | 1337 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) { |
1300 LayoutUnit oldLogicalTop = logicalTop; | 1338 LayoutUnit oldLogicalTop = logicalTop; |
1301 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); | 1339 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); |
1302 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1340 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
1303 } | 1341 } |
1304 | 1342 |
1305 if (previousBlockFlow) { | 1343 if (previousBlockFlow) { |
1306 // 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 | 1344 // 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 |
1307 // any floats from the parent will now overhang. | 1345 // any floats from the parent will now overhang. |
1308 LayoutUnit oldLogicalHeight = logicalHeight(); | 1346 LayoutUnit oldLogicalHeight = logicalHeight(); |
1309 setLogicalHeight(logicalTop); | 1347 setLogicalHeight(logicalTop); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 } | 1543 } |
1506 | 1544 |
1507 // Collapse the result with our current margins. | 1545 // Collapse the result with our current margins. |
1508 if (!discardMarginBefore) | 1546 if (!discardMarginBefore) |
1509 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1547 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
1510 } | 1548 } |
1511 | 1549 |
1512 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1550 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
1513 // page. | 1551 // page. |
1514 LayoutState* layoutState = view()->layoutState(); | 1552 LayoutState* layoutState = view()->layoutState(); |
1515 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight()) | 1553 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight() && !child->isColumnSpanAll()) |
1516 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); | 1554 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); |
1517 | 1555 |
1518 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); | 1556 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); |
1519 | 1557 |
1520 estimateWithoutPagination = logicalTopEstimate; | 1558 estimateWithoutPagination = logicalTopEstimate; |
1521 | 1559 |
1522 if (layoutState->isPaginated()) { | 1560 if (layoutState->isPaginated()) { |
1523 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. | 1561 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. |
1524 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); | 1562 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
1525 | 1563 |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 FrameView* frameView = document().view(); | 2896 FrameView* frameView = document().view(); |
2859 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 2897 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
2860 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 2898 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
2861 if (height() < visibleHeight) | 2899 if (height() < visibleHeight) |
2862 top += (visibleHeight - height()) / 2; | 2900 top += (visibleHeight - height()) / 2; |
2863 setY(top); | 2901 setY(top); |
2864 dialog->setCentered(top); | 2902 dialog->setCentered(top); |
2865 } | 2903 } |
2866 | 2904 |
2867 } // namespace blink | 2905 } // namespace blink |
OLD | NEW |