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 ~ColumnSpannerLayoutScope() |
| 555 { |
| 556 if (!m_spanner) |
| 557 return; |
| 558 m_spanner->flowThreadContainingBlock()->leaveColumnSpannerAfterLayout(m_
spanner, toRenderBlock(m_spanner->container())->logicalHeight()); |
| 559 } |
| 560 |
| 561 LayoutUnit enterSpanner(RenderBox* spanner, SubtreeLayoutScope& layoutScope) |
| 562 { |
| 563 ASSERT(!m_spanner); |
| 564 m_spanner = spanner; |
| 565 return m_spanner->flowThreadContainingBlock()->enterColumnSpannerBeforeL
ayout(m_spanner, toRenderBlock(m_spanner->container())->logicalHeight(), layoutS
cope); |
| 566 } |
| 567 |
| 568 private: |
| 569 RenderBox* m_spanner; |
| 570 }; |
| 571 |
549 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) | 572 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) |
550 { | 573 { |
551 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); | 574 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
552 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); | 575 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
553 | 576 |
| 577 SubtreeLayoutScope layoutScope(*child); |
| 578 |
| 579 ColumnSpannerLayoutScope columnSpannerLayoutScope; |
| 580 if (child->isColumnSpanAll()) { |
| 581 LayoutUnit adjustment = columnSpannerLayoutScope.enterSpanner(child, lay
outScope); |
| 582 // A spanner needs to start at an exact column boundary inside the flow
thread, so that it |
| 583 // doesn't bleed into a preceding column. That's what the adjustment is
about. |
| 584 setLogicalHeight(logicalHeight() + adjustment); |
| 585 } |
| 586 |
554 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. | 587 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. |
555 child->computeAndSetBlockDirectionMargins(this); | 588 child->computeAndSetBlockDirectionMargins(this); |
556 | 589 |
557 // Try to guess our correct logical top position. In most cases this guess w
ill | 590 // 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) | 591 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) |
559 // will we have to potentially relayout. | 592 // will we have to potentially relayout. |
560 LayoutUnit estimateWithoutPagination; | 593 LayoutUnit estimateWithoutPagination; |
561 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); | 594 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); |
562 | 595 |
563 // Cache our old rect so that we can dirty the proper paint invalidation rec
ts if the child moves. | 596 // 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; | 618 markDescendantsWithFloats = true; |
586 } | 619 } |
587 | 620 |
588 if (childRenderBlockFlow) { | 621 if (childRenderBlockFlow) { |
589 if (markDescendantsWithFloats) | 622 if (markDescendantsWithFloats) |
590 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); | 623 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); |
591 if (!child->isWritingModeRoot()) | 624 if (!child->isWritingModeRoot()) |
592 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); | 625 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); |
593 } | 626 } |
594 | 627 |
595 SubtreeLayoutScope layoutScope(*child); | |
596 if (!child->needsLayout()) | 628 if (!child->needsLayout()) |
597 child->markForPaginationRelayoutIfNeeded(layoutScope); | 629 child->markForPaginationRelayoutIfNeeded(layoutScope); |
598 | 630 |
599 bool childNeededLayout = child->needsLayout(); | 631 bool childNeededLayout = child->needsLayout(); |
600 if (childNeededLayout) | 632 if (childNeededLayout) |
601 child->layout(); | 633 child->layout(); |
602 | 634 |
603 // Cache if we are at the top of the block right now. | 635 // Cache if we are at the top of the block right now. |
604 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); | 636 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); |
605 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); | 637 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 marginInfo.clearMargin(); | 1322 marginInfo.clearMargin(); |
1291 } | 1323 } |
1292 | 1324 |
1293 if (marginInfo.margin()) | 1325 if (marginInfo.margin()) |
1294 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); | 1326 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); |
1295 } | 1327 } |
1296 | 1328 |
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 | 1329 // 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. | 1330 // collapsed into the page edge. |
1299 LayoutState* layoutState = view()->layoutState(); | 1331 LayoutState* layoutState = view()->layoutState(); |
1300 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop) { | 1332 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) { |
1301 LayoutUnit oldLogicalTop = logicalTop; | 1333 LayoutUnit oldLogicalTop = logicalTop; |
1302 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); | 1334 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); |
1303 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1335 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
1304 } | 1336 } |
1305 | 1337 |
1306 if (previousBlockFlow) { | 1338 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 | 1339 // 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. | 1340 // any floats from the parent will now overhang. |
1309 LayoutUnit oldLogicalHeight = logicalHeight(); | 1341 LayoutUnit oldLogicalHeight = logicalHeight(); |
1310 setLogicalHeight(logicalTop); | 1342 setLogicalHeight(logicalTop); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 } | 1538 } |
1507 | 1539 |
1508 // Collapse the result with our current margins. | 1540 // Collapse the result with our current margins. |
1509 if (!discardMarginBefore) | 1541 if (!discardMarginBefore) |
1510 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1542 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
1511 } | 1543 } |
1512 | 1544 |
1513 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1545 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
1514 // page. | 1546 // page. |
1515 LayoutState* layoutState = view()->layoutState(); | 1547 LayoutState* layoutState = view()->layoutState(); |
1516 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight()) | 1548 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight() && !child->isColumnSpanAll()) |
1517 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); | 1549 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); |
1518 | 1550 |
1519 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); | 1551 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); |
1520 | 1552 |
1521 estimateWithoutPagination = logicalTopEstimate; | 1553 estimateWithoutPagination = logicalTopEstimate; |
1522 | 1554 |
1523 if (layoutState->isPaginated()) { | 1555 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. | 1556 // 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); | 1557 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
1526 | 1558 |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 FrameView* frameView = document().view(); | 3110 FrameView* frameView = document().view(); |
3079 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3111 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3080 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3112 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3081 if (height() < visibleHeight) | 3113 if (height() < visibleHeight) |
3082 top += (visibleHeight - height()) / 2; | 3114 top += (visibleHeight - height()) / 2; |
3083 setY(top); | 3115 setY(top); |
3084 dialog->setCentered(top); | 3116 dialog->setCentered(top); |
3085 } | 3117 } |
3086 | 3118 |
3087 } // namespace blink | 3119 } // namespace blink |
OLD | NEW |