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 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) { } | |
|
Julien - ping for review
2014/11/26 21:09:00
Nit: I prefer to stick with a statement per line,
mstensho (USE GERRIT)
2014/11/27 21:20:29
Done.
| |
| 553 | |
| 554 ~ColumnSpannerLayoutScope() | |
| 555 { | |
| 556 if (!m_spanner) | |
| 557 return; | |
| 558 m_spanner->flowThreadContainingBlock()->exitColumnSpannerAfterLayout(m_s panner, m_spanner->parentBlock()->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, m_spanner->parentBlock()->logicalHeight(), layoutScope); | |
| 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 2472 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 |