| 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) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 r->setNeedsLayout(); | 1791 r->setNeedsLayout(); |
| 1792 | 1792 |
| 1793 r->layoutIfNeeded(); | 1793 r->layoutIfNeeded(); |
| 1794 | 1794 |
| 1795 // Lay out again if our estimate was wrong. | 1795 // Lay out again if our estimate was wrong. |
| 1796 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(r)
!= oldLogicalTop) | 1796 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(r)
!= oldLogicalTop) |
| 1797 r->forceChildLayout(); | 1797 r->forceChildLayout(); |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 if (hasColumns()) | 1800 if (hasColumns()) |
| 1801 view()->layoutState()->m_columnInfo = columnInfo(); // FIXME: Kind of gr
oss. We just put this back into the layout state so that pop() will work. | 1801 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr
oss. We just put this back into the layout state so that pop() will work. |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 void RenderBlock::markPositionedObjectsForLayout() | 1804 void RenderBlock::markPositionedObjectsForLayout() |
| 1805 { | 1805 { |
| 1806 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); | 1806 TrackedRendererListHashSet* positionedDescendants = positionedObjects(); |
| 1807 if (positionedDescendants) { | 1807 if (positionedDescendants) { |
| 1808 RenderBox* r; | 1808 RenderBox* r; |
| 1809 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); | 1809 TrackedRendererListHashSet::iterator end = positionedDescendants->end(); |
| 1810 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be
gin(); it != end; ++it) { | 1810 for (TrackedRendererListHashSet::iterator it = positionedDescendants->be
gin(); it != end; ++it) { |
| 1811 r = *it; | 1811 r = *it; |
| (...skipping 2849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 // The logicalOffset is in our coordinate space. We can add in our pushed o
ffset. | 4661 // The logicalOffset is in our coordinate space. We can add in our pushed o
ffset. |
| 4662 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset); | 4662 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset); |
| 4663 if (pageBoundaryRule == ExcludePageBoundary) | 4663 if (pageBoundaryRule == ExcludePageBoundary) |
| 4664 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight
: pageLogicalHeight); | 4664 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight
: pageLogicalHeight); |
| 4665 return logicalOffset + remainingLogicalHeight; | 4665 return logicalOffset + remainingLogicalHeight; |
| 4666 } | 4666 } |
| 4667 | 4667 |
| 4668 LayoutUnit RenderBlock::pageLogicalTopForOffset(LayoutUnit offset) const | 4668 LayoutUnit RenderBlock::pageLogicalTopForOffset(LayoutUnit offset) const |
| 4669 { | 4669 { |
| 4670 RenderView* renderView = view(); | 4670 RenderView* renderView = view(); |
| 4671 LayoutUnit firstPageLogicalTop = isHorizontalWritingMode() ? renderView->lay
outState()->m_pageOffset.height() : renderView->layoutState()->m_pageOffset.widt
h(); | 4671 LayoutUnit firstPageLogicalTop = isHorizontalWritingMode() ? renderView->lay
outState()->pageOffset().height() : renderView->layoutState()->pageOffset().widt
h(); |
| 4672 LayoutUnit blockLogicalTop = isHorizontalWritingMode() ? renderView->layoutS
tate()->m_layoutOffset.height() : renderView->layoutState()->m_layoutOffset.widt
h(); | 4672 LayoutUnit blockLogicalTop = isHorizontalWritingMode() ? renderView->layoutS
tate()->layoutOffset().height() : renderView->layoutState()->layoutOffset().widt
h(); |
| 4673 | 4673 |
| 4674 LayoutUnit cumulativeOffset = offset + blockLogicalTop; | 4674 LayoutUnit cumulativeOffset = offset + blockLogicalTop; |
| 4675 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 4675 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 4676 if (!flowThread) { | 4676 if (!flowThread) { |
| 4677 LayoutUnit pageLogicalHeight = renderView->layoutState()->pageLogicalHei
ght(); | 4677 LayoutUnit pageLogicalHeight = renderView->layoutState()->pageLogicalHei
ght(); |
| 4678 if (!pageLogicalHeight) | 4678 if (!pageLogicalHeight) |
| 4679 return 0; | 4679 return 0; |
| 4680 return cumulativeOffset - roundToInt(cumulativeOffset - firstPageLogical
Top) % roundToInt(pageLogicalHeight); | 4680 return cumulativeOffset - roundToInt(cumulativeOffset - firstPageLogical
Top) % roundToInt(pageLogicalHeight); |
| 4681 } | 4681 } |
| 4682 return flowThread->pageLogicalTopForOffset(cumulativeOffset); | 4682 return flowThread->pageLogicalTopForOffset(cumulativeOffset); |
| 4683 } | 4683 } |
| 4684 | 4684 |
| 4685 LayoutUnit RenderBlock::pageLogicalHeightForOffset(LayoutUnit offset) const | 4685 LayoutUnit RenderBlock::pageLogicalHeightForOffset(LayoutUnit offset) const |
| 4686 { | 4686 { |
| 4687 RenderView* renderView = view(); | 4687 RenderView* renderView = view(); |
| 4688 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 4688 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 4689 if (!flowThread) | 4689 if (!flowThread) |
| 4690 return renderView->layoutState()->m_pageLogicalHeight; | 4690 return renderView->layoutState()->pageLogicalHeight(); |
| 4691 return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopO
fFirstPage()); | 4691 return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopO
fFirstPage()); |
| 4692 } | 4692 } |
| 4693 | 4693 |
| 4694 LayoutUnit RenderBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, P
ageBoundaryRule pageBoundaryRule) const | 4694 LayoutUnit RenderBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, P
ageBoundaryRule pageBoundaryRule) const |
| 4695 { | 4695 { |
| 4696 RenderView* renderView = view(); | 4696 RenderView* renderView = view(); |
| 4697 offset += offsetFromLogicalTopOfFirstPage(); | 4697 offset += offsetFromLogicalTopOfFirstPage(); |
| 4698 | 4698 |
| 4699 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 4699 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 4700 if (!flowThread) { | 4700 if (!flowThread) { |
| 4701 LayoutUnit pageLogicalHeight = renderView->layoutState()->m_pageLogicalH
eight; | 4701 LayoutUnit pageLogicalHeight = renderView->layoutState()->pageLogicalHei
ght(); |
| 4702 LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogi
calHeight); | 4702 LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogi
calHeight); |
| 4703 if (pageBoundaryRule == IncludePageBoundary) { | 4703 if (pageBoundaryRule == IncludePageBoundary) { |
| 4704 // If includeBoundaryPoint is true the line exactly on the top edge
of a | 4704 // If includeBoundaryPoint is true the line exactly on the top edge
of a |
| 4705 // column will act as being part of the previous column. | 4705 // column will act as being part of the previous column. |
| 4706 remainingHeight = intMod(remainingHeight, pageLogicalHeight); | 4706 remainingHeight = intMod(remainingHeight, pageLogicalHeight); |
| 4707 } | 4707 } |
| 4708 return remainingHeight; | 4708 return remainingHeight; |
| 4709 } | 4709 } |
| 4710 | 4710 |
| 4711 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); | 4711 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); |
| 4712 } | 4712 } |
| 4713 | 4713 |
| 4714 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit
logicalOffset, bool includeMargins) | 4714 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit
logicalOffset, bool includeMargins) |
| 4715 { | 4715 { |
| 4716 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo
wThreadContainingBlock(); | 4716 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo
wThreadContainingBlock(); |
| 4717 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; | 4717 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi
calHeight(); |
| 4718 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) | 4718 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) |
| 4719 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); | 4719 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); |
| 4720 if (!isUnsplittable) | 4720 if (!isUnsplittable) |
| 4721 return logicalOffset; | 4721 return logicalOffset; |
| 4722 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); | 4722 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); |
| 4723 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 4723 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
| 4724 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | 4724 updateMinimumPageHeight(logicalOffset, childLogicalHeight); |
| 4725 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) | 4725 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) |
| 4726 return logicalOffset; | 4726 return logicalOffset; |
| 4727 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); | 4727 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4739 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) | 4739 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) |
| 4740 { | 4740 { |
| 4741 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) | 4741 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) |
| 4742 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa
ceShortage); | 4742 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa
ceShortage); |
| 4743 } | 4743 } |
| 4744 | 4744 |
| 4745 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh
t) | 4745 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh
t) |
| 4746 { | 4746 { |
| 4747 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) | 4747 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) |
| 4748 flowThread->updateMinimumPageHeight(offsetFromLogicalTopOfFirstPage() +
offset, minHeight); | 4748 flowThread->updateMinimumPageHeight(offsetFromLogicalTopOfFirstPage() +
offset, minHeight); |
| 4749 else if (ColumnInfo* colInfo = view()->layoutState()->m_columnInfo) | 4749 else if (ColumnInfo* colInfo = view()->layoutState()->columnInfo()) |
| 4750 colInfo->updateMinimumColumnHeight(minHeight); | 4750 colInfo->updateMinimumColumnHeight(minHeight); |
| 4751 } | 4751 } |
| 4752 | 4752 |
| 4753 static inline LayoutUnit calculateMinimumPageHeight(RenderStyle* renderStyle, Ro
otInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom) | 4753 static inline LayoutUnit calculateMinimumPageHeight(RenderStyle* renderStyle, Ro
otInlineBox* lastLine, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 4754 { | 4754 { |
| 4755 // We may require a certain minimum number of lines per page in order to sat
isfy | 4755 // We may require a certain minimum number of lines per page in order to sat
isfy |
| 4756 // orphans and widows, and that may affect the minimum page height. | 4756 // orphans and widows, and that may affect the minimum page height. |
| 4757 unsigned lineCount = max<unsigned>(renderStyle->hasAutoOrphans() ? 1 : rende
rStyle->orphans(), renderStyle->hasAutoWidows() ? 1 : renderStyle->widows()); | 4757 unsigned lineCount = max<unsigned>(renderStyle->hasAutoOrphans() ? 1 : rende
rStyle->orphans(), renderStyle->hasAutoWidows() ? 1 : renderStyle->widows()); |
| 4758 if (lineCount > 1) { | 4758 if (lineCount > 1) { |
| 4759 RootInlineBox* line = lastLine; | 4759 RootInlineBox* line = lastLine; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4846 if (layoutState && !layoutState->isPaginated()) | 4846 if (layoutState && !layoutState->isPaginated()) |
| 4847 return 0; | 4847 return 0; |
| 4848 | 4848 |
| 4849 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 4849 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| 4850 if (flowThread) | 4850 if (flowThread) |
| 4851 return flowThread->offsetFromLogicalTopOfFirstRegion(this); | 4851 return flowThread->offsetFromLogicalTopOfFirstRegion(this); |
| 4852 | 4852 |
| 4853 if (layoutState) { | 4853 if (layoutState) { |
| 4854 ASSERT(layoutState->renderer() == this); | 4854 ASSERT(layoutState->renderer() == this); |
| 4855 | 4855 |
| 4856 LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pa
geOffset; | 4856 LayoutSize offsetDelta = layoutState->layoutOffset() - layoutState->page
Offset(); |
| 4857 return isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.wi
dth(); | 4857 return isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.wi
dth(); |
| 4858 } | 4858 } |
| 4859 | 4859 |
| 4860 ASSERT_NOT_REACHED(); | 4860 ASSERT_NOT_REACHED(); |
| 4861 return 0; | 4861 return 0; |
| 4862 } | 4862 } |
| 4863 | 4863 |
| 4864 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const | 4864 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const |
| 4865 { | 4865 { |
| 4866 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 4866 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 5025 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 5026 { | 5026 { |
| 5027 showRenderObject(); | 5027 showRenderObject(); |
| 5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 5028 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 5029 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 5030 } | 5030 } |
| 5031 | 5031 |
| 5032 #endif | 5032 #endif |
| 5033 | 5033 |
| 5034 } // namespace WebCore | 5034 } // namespace WebCore |
| OLD | NEW |