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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) | 541 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) |
542 { | 542 { |
543 if (isHorizontalWritingMode()) { | 543 if (isHorizontalWritingMode()) { |
544 child->setY(logicalTop); | 544 child->setY(logicalTop); |
545 } else { | 545 } else { |
546 child->setX(logicalTop); | 546 child->setX(logicalTop); |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
| 550 class ColumnSpannerLayoutScope { |
| 551 public: |
| 552 ColumnSpannerLayoutScope() |
| 553 : m_spanner(0) { } |
| 554 |
| 555 ~ColumnSpannerLayoutScope() |
| 556 { |
| 557 if (!m_spanner) |
| 558 return; |
| 559 m_spanner->flowThreadContainingBlock()->leaveColumnSpanner(m_spanner, m_
spanner->containingBlock()->logicalHeight()); |
| 560 } |
| 561 |
| 562 LayoutUnit enterSpanner(RenderBox* spanner, SubtreeLayoutScope& layoutScope) |
| 563 { |
| 564 ASSERT(!m_spanner); |
| 565 m_spanner = spanner; |
| 566 return m_spanner->flowThreadContainingBlock()->enterColumnSpanner(m_span
ner, m_spanner->containingBlock()->logicalHeight(), layoutScope); |
| 567 } |
| 568 |
| 569 private: |
| 570 RenderBox* m_spanner; |
| 571 }; |
| 572 |
550 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) | 573 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo,
LayoutUnit& previousFloatLogicalBottom) |
551 { | 574 { |
552 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); | 575 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
553 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); | 576 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
554 | 577 |
| 578 SubtreeLayoutScope layoutScope(*child); |
| 579 |
| 580 ColumnSpannerLayoutScope columnSpannerLayoutScope; |
| 581 if (child->isColumnSpanAll()) { |
| 582 // Margins of a column spanner cannot collapse with anything. Block dire
ction margins on |
| 583 // spanners will be ignored here, inside flow thread layout. Instead the
y'll be added around |
| 584 // the RenderMultiColumnSpannerSet. Now skip past the pending margin tha
t belongs to the |
| 585 // columns. |
| 586 setLogicalHeight(logicalHeight() + marginInfo.margin()); |
| 587 marginInfo.clearMargin(); |
| 588 LayoutUnit adjustment = columnSpannerLayoutScope.enterSpanner(child, lay
outScope); |
| 589 // A spanner needs to start at an exact column boundary inside the flow
thread, so that it |
| 590 // doesn't bleed into a preceding column. That's what the adjustment is
about. |
| 591 setLogicalHeight(logicalHeight() + adjustment); |
| 592 } |
| 593 |
555 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. | 594 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. |
556 child->computeAndSetBlockDirectionMargins(this); | 595 child->computeAndSetBlockDirectionMargins(this); |
557 | 596 |
558 // Try to guess our correct logical top position. In most cases this guess w
ill | 597 // Try to guess our correct logical top position. In most cases this guess w
ill |
559 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) | 598 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) |
560 // will we have to potentially relayout. | 599 // will we have to potentially relayout. |
561 LayoutUnit estimateWithoutPagination; | 600 LayoutUnit estimateWithoutPagination; |
562 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); | 601 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo
, estimateWithoutPagination); |
563 | 602 |
564 // Cache our old rect so that we can dirty the proper paint invalidation rec
ts if the child moves. | 603 // 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... |
586 markDescendantsWithFloats = true; | 625 markDescendantsWithFloats = true; |
587 } | 626 } |
588 | 627 |
589 if (childRenderBlockFlow) { | 628 if (childRenderBlockFlow) { |
590 if (markDescendantsWithFloats) | 629 if (markDescendantsWithFloats) |
591 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); | 630 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); |
592 if (!child->isWritingModeRoot()) | 631 if (!child->isWritingModeRoot()) |
593 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); | 632 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol
dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); |
594 } | 633 } |
595 | 634 |
596 SubtreeLayoutScope layoutScope(*child); | |
597 if (!child->needsLayout()) | 635 if (!child->needsLayout()) |
598 child->markForPaginationRelayoutIfNeeded(layoutScope); | 636 child->markForPaginationRelayoutIfNeeded(layoutScope); |
599 | 637 |
600 bool childHadLayout = child->everHadLayout(); | 638 bool childHadLayout = child->everHadLayout(); |
601 bool childNeededLayout = child->needsLayout(); | 639 bool childNeededLayout = child->needsLayout(); |
602 if (childNeededLayout) | 640 if (childNeededLayout) |
603 child->layout(); | 641 child->layout(); |
604 | 642 |
605 // Cache if we are at the top of the block right now. | 643 // Cache if we are at the top of the block right now. |
606 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); | 644 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 marginInfo.clearMargin(); | 1334 marginInfo.clearMargin(); |
1297 } | 1335 } |
1298 | 1336 |
1299 if (marginInfo.margin()) | 1337 if (marginInfo.margin()) |
1300 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); | 1338 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); |
1301 } | 1339 } |
1302 | 1340 |
1303 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins | 1341 // If margins would pull us past the top of the next page, then we need to p
ull back and pretend like the margins |
1304 // collapsed into the page edge. | 1342 // collapsed into the page edge. |
1305 LayoutState* layoutState = view()->layoutState(); | 1343 LayoutState* layoutState = view()->layoutState(); |
1306 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop) { | 1344 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) { |
1307 LayoutUnit oldLogicalTop = logicalTop; | 1345 LayoutUnit oldLogicalTop = logicalTop; |
1308 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); | 1346 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic
alTop)); |
1309 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1347 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
1310 } | 1348 } |
1311 | 1349 |
1312 if (previousBlockFlow) { | 1350 if (previousBlockFlow) { |
1313 // 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 | 1351 // 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 |
1314 // any floats from the parent will now overhang. | 1352 // any floats from the parent will now overhang. |
1315 LayoutUnit oldLogicalHeight = logicalHeight(); | 1353 LayoutUnit oldLogicalHeight = logicalHeight(); |
1316 setLogicalHeight(logicalTop); | 1354 setLogicalHeight(logicalTop); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 } | 1550 } |
1513 | 1551 |
1514 // Collapse the result with our current margins. | 1552 // Collapse the result with our current margins. |
1515 if (!discardMarginBefore) | 1553 if (!discardMarginBefore) |
1516 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1554 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive
MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
1517 } | 1555 } |
1518 | 1556 |
1519 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current | 1557 // Adjust logicalTopEstimate down to the next page if the margins are so lar
ge that we don't fit on the current |
1520 // page. | 1558 // page. |
1521 LayoutState* layoutState = view()->layoutState(); | 1559 LayoutState* layoutState = view()->layoutState(); |
1522 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight()) | 1560 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica
lTopEstimate > logicalHeight() && !child->isColumnSpanAll()) |
1523 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); | 1561 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log
icalHeight())); |
1524 | 1562 |
1525 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); | 1563 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); |
1526 | 1564 |
1527 estimateWithoutPagination = logicalTopEstimate; | 1565 estimateWithoutPagination = logicalTopEstimate; |
1528 | 1566 |
1529 if (layoutState->isPaginated()) { | 1567 if (layoutState->isPaginated()) { |
1530 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. | 1568 // If the object has a page or column break value of "before", then we s
hould shift to the top of the next page. |
1531 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); | 1569 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
1532 | 1570 |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2932 FrameView* frameView = document().view(); | 2970 FrameView* frameView = document().view(); |
2933 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 2971 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
2934 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 2972 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
2935 if (height() < visibleHeight) | 2973 if (height() < visibleHeight) |
2936 top += (visibleHeight - height()) / 2; | 2974 top += (visibleHeight - height()) / 2; |
2937 setY(top); | 2975 setY(top); |
2938 dialog->setCentered(top); | 2976 dialog->setCentered(top); |
2939 } | 2977 } |
2940 | 2978 |
2941 } // namespace blink | 2979 } // namespace blink |
OLD | NEW |