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. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 4718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4729 } | 4729 } |
4730 | 4730 |
4731 void LayoutBox::clearPercentHeightDescendants() | 4731 void LayoutBox::clearPercentHeightDescendants() |
4732 { | 4732 { |
4733 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { | 4733 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde
r(this)) { |
4734 if (curr->isBox()) | 4734 if (curr->isBox()) |
4735 toLayoutBox(curr)->removeFromPercentHeightContainer(); | 4735 toLayoutBox(curr)->removeFromPercentHeightContainer(); |
4736 } | 4736 } |
4737 } | 4737 } |
4738 | 4738 |
| 4739 LayoutUnit LayoutBox::pageLogicalHeightForOffset(LayoutUnit offset) const |
| 4740 { |
| 4741 LayoutView* layoutView = view(); |
| 4742 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 4743 if (!flowThread) |
| 4744 return layoutView->layoutState()->pageLogicalHeight(); |
| 4745 return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopO
fFirstPage()); |
| 4746 } |
| 4747 |
| 4748 LayoutUnit LayoutBox::pageRemainingLogicalHeightForOffset(LayoutUnit offset, Pag
eBoundaryRule pageBoundaryRule) const |
| 4749 { |
| 4750 LayoutView* layoutView = view(); |
| 4751 offset += offsetFromLogicalTopOfFirstPage(); |
| 4752 |
| 4753 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 4754 if (!flowThread) { |
| 4755 LayoutUnit pageLogicalHeight = layoutView->layoutState()->pageLogicalHei
ght(); |
| 4756 LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogi
calHeight); |
| 4757 if (pageBoundaryRule == AssociateWithFormerPage) { |
| 4758 // An offset exactly at a page boundary will act as being part of th
e former page in |
| 4759 // question (i.e. no remaining space), rather than being part of the
latter (i.e. one |
| 4760 // whole page length of remaining space). |
| 4761 remainingHeight = intMod(remainingHeight, pageLogicalHeight); |
| 4762 } |
| 4763 return remainingHeight; |
| 4764 } |
| 4765 |
| 4766 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); |
| 4767 } |
| 4768 |
| 4769 LayoutUnit LayoutBox::calculatePaginationStrutToFitContent(LayoutUnit offset, La
youtUnit strutToNextPage, LayoutUnit contentLogicalHeight) const |
| 4770 { |
| 4771 ASSERT(strutToNextPage == pageRemainingLogicalHeightForOffset(offset, Associ
ateWithLatterPage)); |
| 4772 LayoutUnit nextPageLogicalTop = offset + strutToNextPage; |
| 4773 if (pageLogicalHeightForOffset(nextPageLogicalTop) >= contentLogicalHeight) |
| 4774 return strutToNextPage; // Content fits just fine in the next page or co
lumn. |
| 4775 |
| 4776 // Moving to the top of the next page or column doesn't result in enough spa
ce for the content |
| 4777 // that we're trying to fit. If we're in a nested fragmentation context, we
may find enough |
| 4778 // space if we move to a column further ahead, by effectively breaking to th
e next outer |
| 4779 // fragmentainer. |
| 4780 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 4781 if (!flowThread) { |
| 4782 // If there's no flow thread, we're not nested. All pages have the same
height. Give up. |
| 4783 return strutToNextPage; |
| 4784 } |
| 4785 // Start searching for a suitable offset at the top of the next page or colu
mn. |
| 4786 LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLo
gicalTop; |
| 4787 return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flo
wThreadOffset, contentLogicalHeight) - flowThreadOffset; |
| 4788 } |
| 4789 |
4739 } // namespace blink | 4790 } // namespace blink |
OLD | NEW |