OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
7 * All rights reserved. | 7 * All rights reserved. |
8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 m_frameRect.height().toFloat()); | 699 m_frameRect.height().toFloat()); |
700 } | 700 } |
701 | 701 |
702 void LayoutBox::updateLayerTransformAfterLayout() { | 702 void LayoutBox::updateLayerTransformAfterLayout() { |
703 // Transform-origin depends on box size, so we need to update the layer | 703 // Transform-origin depends on box size, so we need to update the layer |
704 // transform after layout. | 704 // transform after layout. |
705 if (hasLayer()) | 705 if (hasLayer()) |
706 layer()->updateTransformationMatrix(); | 706 layer()->updateTransformationMatrix(); |
707 } | 707 } |
708 | 708 |
| 709 LayoutUnit LayoutBox::logicalHeightIncludingOverflow() const { |
| 710 if (!m_overflow) |
| 711 return logicalHeight(); |
| 712 LayoutRect overflow = layoutOverflowRect(); |
| 713 if (style()->isHorizontalWritingMode()) |
| 714 return overflow.maxY(); |
| 715 return overflow.maxX(); |
| 716 } |
| 717 |
709 LayoutUnit LayoutBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, | 718 LayoutUnit LayoutBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, |
710 LayoutUnit availableWidth, | 719 LayoutUnit availableWidth, |
711 LayoutBlock* cb) const { | 720 LayoutBlock* cb) const { |
712 const ComputedStyle& styleToUse = styleRef(); | 721 const ComputedStyle& styleToUse = styleRef(); |
713 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) | 722 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) |
714 logicalWidth = | 723 logicalWidth = |
715 std::min(logicalWidth, | 724 std::min(logicalWidth, |
716 computeLogicalWidthUsing(MaxSize, styleToUse.logicalMaxWidth(), | 725 computeLogicalWidthUsing(MaxSize, styleToUse.logicalMaxWidth(), |
717 availableWidth, cb)); | 726 availableWidth, cb)); |
718 return std::max(logicalWidth, computeLogicalWidthUsing( | 727 return std::max(logicalWidth, computeLogicalWidthUsing( |
(...skipping 3976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4695 if (scrollableArea->hasHorizontalScrollbar() && | 4704 if (scrollableArea->hasHorizontalScrollbar() && |
4696 !scrollableArea->layerForHorizontalScrollbar()) | 4705 !scrollableArea->layerForHorizontalScrollbar()) |
4697 return true; | 4706 return true; |
4698 if (scrollableArea->hasVerticalScrollbar() && | 4707 if (scrollableArea->hasVerticalScrollbar() && |
4699 !scrollableArea->layerForVerticalScrollbar()) | 4708 !scrollableArea->layerForVerticalScrollbar()) |
4700 return true; | 4709 return true; |
4701 } | 4710 } |
4702 return false; | 4711 return false; |
4703 } | 4712 } |
4704 | 4713 |
| 4714 void LayoutBox::updateFragmentationInfoForChild(LayoutBox& child) { |
| 4715 LayoutState* layoutState = view()->layoutState(); |
| 4716 DCHECK(layoutState->isPaginated()); |
| 4717 child.setOffsetToNextPage(LayoutUnit()); |
| 4718 if (!pageLogicalHeightForOffset(child.logicalTop())) |
| 4719 return; |
| 4720 |
| 4721 LayoutUnit logicalTop = child.logicalTop(); |
| 4722 LayoutUnit logicalHeight = child.logicalHeightIncludingOverflow(); |
| 4723 LayoutUnit spaceLeft = |
| 4724 pageRemainingLogicalHeightForOffset(logicalTop, AssociateWithLatterPage); |
| 4725 if (spaceLeft < logicalHeight) |
| 4726 child.setOffsetToNextPage(spaceLeft); |
| 4727 } |
| 4728 |
4705 void LayoutBox::markChildForPaginationRelayoutIfNeeded( | 4729 void LayoutBox::markChildForPaginationRelayoutIfNeeded( |
4706 LayoutBox& child, | 4730 LayoutBox& child, |
4707 SubtreeLayoutScope& layoutScope) { | 4731 SubtreeLayoutScope& layoutScope) { |
4708 DCHECK(!child.needsLayout()); | 4732 DCHECK(!child.needsLayout()); |
4709 LayoutState* layoutState = view()->layoutState(); | 4733 LayoutState* layoutState = view()->layoutState(); |
4710 if (layoutState->paginationStateChanged()) { | 4734 // TODO(mstensho): Should try to get this to work for floats too, instead of |
| 4735 // just marking and bailing here. |
| 4736 if (layoutState->paginationStateChanged() || child.isFloating()) { |
4711 layoutScope.setChildNeedsLayout(&child); | 4737 layoutScope.setChildNeedsLayout(&child); |
4712 return; | 4738 return; |
4713 } | 4739 } |
4714 if (!layoutState->isPaginated()) | 4740 if (!layoutState->isPaginated()) |
4715 return; | 4741 return; |
4716 | 4742 |
4717 if (layoutState->pageLogicalHeightChanged() || | 4743 LayoutUnit logicalTop = child.logicalTop(); |
4718 (layoutState->pageLogicalHeight() && | 4744 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalTop)) { |
4719 layoutState->pageLogicalOffset(child, child.logicalTop()) != | 4745 // Figure out if we really need to force re-layout of the child. We only |
4720 child.pageLogicalOffset())) | 4746 // need to do this if there's a chance that we need to recalculate |
4721 layoutScope.setChildNeedsLayout(&child); | 4747 // pagination struts inside. |
| 4748 LayoutUnit remainingSpace = pageRemainingLogicalHeightForOffset( |
| 4749 logicalTop, AssociateWithLatterPage); |
| 4750 LayoutUnit logicalHeight = child.logicalHeightIncludingOverflow(); |
| 4751 if ((!child.offsetToNextPage() && logicalHeight <= remainingSpace) || |
| 4752 child.offsetToNextPage() == remainingSpace) { |
| 4753 // We don't need to relayout this child, either because the child wasn't |
| 4754 // previously fragmented, and won't be fragmented now either, or because |
| 4755 // it would fragment at the exact same position as before. |
| 4756 // |
| 4757 // We want to skip layout of this child, but we need to ask the flow |
| 4758 // thread for permission first. We currently cannot skip over objects |
| 4759 // containing column spanners. |
| 4760 LayoutFlowThread* flowThread = child.flowThreadContainingBlock(); |
| 4761 if (!flowThread || flowThread->canSkipLayout(child)) |
| 4762 return; |
| 4763 } |
| 4764 } |
| 4765 |
| 4766 layoutScope.setChildNeedsLayout(&child); |
4722 } | 4767 } |
4723 | 4768 |
4724 void LayoutBox::markOrthogonalWritingModeRoot() { | 4769 void LayoutBox::markOrthogonalWritingModeRoot() { |
4725 ASSERT(frameView()); | 4770 ASSERT(frameView()); |
4726 frameView()->addOrthogonalWritingModeRoot(*this); | 4771 frameView()->addOrthogonalWritingModeRoot(*this); |
4727 } | 4772 } |
4728 | 4773 |
4729 void LayoutBox::unmarkOrthogonalWritingModeRoot() { | 4774 void LayoutBox::unmarkOrthogonalWritingModeRoot() { |
4730 ASSERT(frameView()); | 4775 ASSERT(frameView()); |
4731 frameView()->removeOrthogonalWritingModeRoot(*this); | 4776 frameView()->removeOrthogonalWritingModeRoot(*this); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 // meant to be called on the object currently being laid out. | 5323 // meant to be called on the object currently being laid out. |
5279 ASSERT(!isLayoutBlock()); | 5324 ASSERT(!isLayoutBlock()); |
5280 | 5325 |
5281 // In case this box doesn't establish a layout state, try the containing | 5326 // In case this box doesn't establish a layout state, try the containing |
5282 // block. | 5327 // block. |
5283 LayoutBlock* containerBlock = containingBlock(); | 5328 LayoutBlock* containerBlock = containingBlock(); |
5284 ASSERT(layoutState->layoutObject() == containerBlock); | 5329 ASSERT(layoutState->layoutObject() == containerBlock); |
5285 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 5330 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
5286 } | 5331 } |
5287 | 5332 |
5288 void LayoutBox::setPageLogicalOffset(LayoutUnit offset) { | 5333 void LayoutBox::setOffsetToNextPage(LayoutUnit offset) { |
5289 if (!m_rareData && !offset) | 5334 if (!m_rareData && !offset) |
5290 return; | 5335 return; |
5291 ensureRareData().m_pageLogicalOffset = offset; | 5336 ensureRareData().m_offsetToNextPage = offset; |
5292 } | 5337 } |
5293 | 5338 |
5294 void LayoutBox::logicalExtentAfterUpdatingLogicalWidth( | 5339 void LayoutBox::logicalExtentAfterUpdatingLogicalWidth( |
5295 const LayoutUnit& newLogicalTop, | 5340 const LayoutUnit& newLogicalTop, |
5296 LayoutBox::LogicalExtentComputedValues& computedValues) { | 5341 LayoutBox::LogicalExtentComputedValues& computedValues) { |
5297 // FIXME: None of this is right for perpendicular writing-mode children. | 5342 // FIXME: None of this is right for perpendicular writing-mode children. |
5298 LayoutUnit oldLogicalWidth = logicalWidth(); | 5343 LayoutUnit oldLogicalWidth = logicalWidth(); |
5299 LayoutUnit oldLogicalLeft = logicalLeft(); | 5344 LayoutUnit oldLogicalLeft = logicalLeft(); |
5300 LayoutUnit oldMarginLeft = marginLeft(); | 5345 LayoutUnit oldMarginLeft = marginLeft(); |
5301 LayoutUnit oldMarginRight = marginRight(); | 5346 LayoutUnit oldMarginRight = marginRight(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5595 LayoutRect rect = frameRect(); | 5640 LayoutRect rect = frameRect(); |
5596 | 5641 |
5597 LayoutBlock* block = containingBlock(); | 5642 LayoutBlock* block = containingBlock(); |
5598 if (block) | 5643 if (block) |
5599 block->adjustChildDebugRect(rect); | 5644 block->adjustChildDebugRect(rect); |
5600 | 5645 |
5601 return rect; | 5646 return rect; |
5602 } | 5647 } |
5603 | 5648 |
5604 } // namespace blink | 5649 } // namespace blink |
OLD | NEW |