Chromium Code Reviews| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 child->setY(logicalTop); | 545 child->setY(logicalTop); |
| 546 } else { | 546 } else { |
| 547 child->setX(logicalTop); | 547 child->setX(logicalTop); |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 |
| 551 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) | 551 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) |
| 552 { | 552 { |
| 553 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); | 553 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); |
| 554 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); | 554 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); |
| 555 bool childIsColumnSpanner = child->isColumnSpanAll(); | |
| 556 | |
| 557 if (childIsColumnSpanner) { | |
|
Julien - ping for review
2014/09/30 00:39:32
Nit: This looks like it should be a RAII so that w
| |
| 558 // Margins of a column spanner cannot collapse with anything. Block dire ction margins on | |
| 559 // spanners will be ignored here, inside flow thread layout. Instead the y'll be added around | |
| 560 // the RenderMultiColumnSpannerSet. Now skip past the pending margin tha t belongs to the | |
| 561 // columns. | |
| 562 setLogicalHeight(logicalHeight() + marginInfo.margin()); | |
| 563 marginInfo.clearMargin(); | |
| 564 LayoutUnit adjustment = flowThreadContainingBlock()->enterColumnSpanner( child, logicalHeight()); | |
| 565 // A spanner needs to start at an exact column boundary inside the flow thread, so that it | |
| 566 // doesn't bleed into a preceding column. That's what the adjustment is about. | |
| 567 setLogicalHeight(logicalHeight() + adjustment); | |
| 568 } | |
| 555 | 569 |
| 556 // The child is a normal flow object. Compute the margins we will use for co llapsing now. | 570 // The child is a normal flow object. Compute the margins we will use for co llapsing now. |
| 557 child->computeAndSetBlockDirectionMargins(this); | 571 child->computeAndSetBlockDirectionMargins(this); |
| 558 | 572 |
| 559 // Try to guess our correct logical top position. In most cases this guess w ill | 573 // Try to guess our correct logical top position. In most cases this guess w ill |
| 560 // be correct. Only if we're wrong (when we compute the real logical top pos ition) | 574 // be correct. Only if we're wrong (when we compute the real logical top pos ition) |
| 561 // will we have to potentially relayout. | 575 // will we have to potentially relayout. |
| 562 LayoutUnit estimateWithoutPagination; | 576 LayoutUnit estimateWithoutPagination; |
| 563 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); | 577 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); |
| 564 | 578 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 680 bool didNotLayoutAndNeedsPaintInvalidation = !childHadLayout && child->check ForPaintInvalidation(); | 694 bool didNotLayoutAndNeedsPaintInvalidation = !childHadLayout && child->check ForPaintInvalidation(); |
| 681 | 695 |
| 682 if (didNotDoFullLayoutAndMoved || didNotLayoutAndNeedsPaintInvalidation) | 696 if (didNotDoFullLayoutAndMoved || didNotLayoutAndNeedsPaintInvalidation) |
| 683 child->invalidatePaintForOverhangingFloats(true); | 697 child->invalidatePaintForOverhangingFloats(true); |
| 684 | 698 |
| 685 if (paginated) { | 699 if (paginated) { |
| 686 // Check for an after page/column break. | 700 // Check for an after page/column break. |
| 687 LayoutUnit newHeight = applyAfterBreak(child, logicalHeight(), marginInf o); | 701 LayoutUnit newHeight = applyAfterBreak(child, logicalHeight(), marginInf o); |
| 688 if (newHeight != height()) | 702 if (newHeight != height()) |
| 689 setLogicalHeight(newHeight); | 703 setLogicalHeight(newHeight); |
| 704 | |
| 705 if (childIsColumnSpanner) { | |
| 706 flowThreadContainingBlock()->leaveColumnSpanner(child, logicalHeight ()); | |
| 707 ASSERT(!marginInfo.margin()); | |
| 708 } | |
| 690 } | 709 } |
| 691 } | 710 } |
| 692 | 711 |
| 693 LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA fterClear, LayoutUnit estimateWithoutPagination, RenderBox* child, bool atBefore SideOfBlock) | 712 LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA fterClear, LayoutUnit estimateWithoutPagination, RenderBox* child, bool atBefore SideOfBlock) |
| 694 { | 713 { |
| 695 RenderBlockFlow* childBlockFlow = child->isRenderBlockFlow() ? toRenderBlock Flow(child) : 0; | 714 RenderBlockFlow* childBlockFlow = child->isRenderBlockFlow() ? toRenderBlock Flow(child) : 0; |
| 696 | 715 |
| 697 if (estimateWithoutPagination != logicalTopAfterClear) { | 716 if (estimateWithoutPagination != logicalTopAfterClear) { |
| 698 // Our guess prior to pagination movement was wrong. Before we attempt t o paginate, let's try again at the new | 717 // Our guess prior to pagination movement was wrong. Before we attempt t o paginate, let's try again at the new |
| 699 // position. | 718 // position. |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 marginInfo.clearMargin(); | 1297 marginInfo.clearMargin(); |
| 1279 } | 1298 } |
| 1280 | 1299 |
| 1281 if (marginInfo.margin()) | 1300 if (marginInfo.margin()) |
| 1282 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); | 1301 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); |
| 1283 } | 1302 } |
| 1284 | 1303 |
| 1285 // 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 // If margins would pull us past the top of the next page, then we need to p ull back and pretend like the margins |
| 1286 // collapsed into the page edge. | 1305 // collapsed into the page edge. |
| 1287 LayoutState* layoutState = view()->layoutState(); | 1306 LayoutState* layoutState = view()->layoutState(); |
| 1288 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop) { | 1307 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) { |
| 1289 LayoutUnit oldLogicalTop = logicalTop; | 1308 LayoutUnit oldLogicalTop = logicalTop; |
| 1290 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic alTop)); | 1309 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic alTop)); |
| 1291 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); | 1310 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); |
| 1292 } | 1311 } |
| 1293 | 1312 |
| 1294 if (previousBlockFlow) { | 1313 if (previousBlockFlow) { |
| 1295 // 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 // 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 |
| 1296 // any floats from the parent will now overhang. | 1315 // any floats from the parent will now overhang. |
| 1297 LayoutUnit oldLogicalHeight = logicalHeight(); | 1316 LayoutUnit oldLogicalHeight = logicalHeight(); |
| 1298 setLogicalHeight(logicalTop); | 1317 setLogicalHeight(logicalTop); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1494 } | 1513 } |
| 1495 | 1514 |
| 1496 // Collapse the result with our current margins. | 1515 // Collapse the result with our current margins. |
| 1497 if (!discardMarginBefore) | 1516 if (!discardMarginBefore) |
| 1498 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); | 1517 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); |
| 1499 } | 1518 } |
| 1500 | 1519 |
| 1501 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current | 1520 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current |
| 1502 // page. | 1521 // page. |
| 1503 LayoutState* layoutState = view()->layoutState(); | 1522 LayoutState* layoutState = view()->layoutState(); |
| 1504 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight()) | 1523 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight() && !child->isColumnSpanAll()) |
| 1505 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log icalHeight())); | 1524 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log icalHeight())); |
| 1506 | 1525 |
| 1507 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); | 1526 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); |
| 1508 | 1527 |
| 1509 estimateWithoutPagination = logicalTopEstimate; | 1528 estimateWithoutPagination = logicalTopEstimate; |
| 1510 | 1529 |
| 1511 if (layoutState->isPaginated()) { | 1530 if (layoutState->isPaginated()) { |
| 1512 // 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 // If the object has a page or column break value of "before", then we s hould shift to the top of the next page. |
| 1513 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); | 1532 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); |
| 1514 | 1533 |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2939 FrameView* frameView = document().view(); | 2958 FrameView* frameView = document().view(); |
| 2940 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); | 2959 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); |
| 2941 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 2960 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
| 2942 if (height() < visibleHeight) | 2961 if (height() < visibleHeight) |
| 2943 top += (visibleHeight - height()) / 2; | 2962 top += (visibleHeight - height()) / 2; |
| 2944 setY(top); | 2963 setY(top); |
| 2945 dialog->setCentered(top); | 2964 dialog->setCentered(top); |
| 2946 } | 2965 } |
| 2947 | 2966 |
| 2948 } // namespace blink | 2967 } // namespace blink |
| OLD | NEW |