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 2575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 | 2586 |
2587 LayoutUnit LayoutBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar
yRule pageBoundaryRule) const | 2587 LayoutUnit LayoutBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar
yRule pageBoundaryRule) const |
2588 { | 2588 { |
2589 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 2589 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
2590 if (!pageLogicalHeight) | 2590 if (!pageLogicalHeight) |
2591 return logicalOffset; | 2591 return logicalOffset; |
2592 | 2592 |
2593 return logicalOffset + pageRemainingLogicalHeightForOffset(logicalOffset, pa
geBoundaryRule); | 2593 return logicalOffset + pageRemainingLogicalHeightForOffset(logicalOffset, pa
geBoundaryRule); |
2594 } | 2594 } |
2595 | 2595 |
2596 LayoutUnit LayoutBlock::pageLogicalHeightForOffset(LayoutUnit offset) const | |
2597 { | |
2598 LayoutView* layoutView = view(); | |
2599 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | |
2600 if (!flowThread) | |
2601 return layoutView->layoutState()->pageLogicalHeight(); | |
2602 return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopO
fFirstPage()); | |
2603 } | |
2604 | |
2605 LayoutUnit LayoutBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, P
ageBoundaryRule pageBoundaryRule) const | |
2606 { | |
2607 LayoutView* layoutView = view(); | |
2608 offset += offsetFromLogicalTopOfFirstPage(); | |
2609 | |
2610 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | |
2611 if (!flowThread) { | |
2612 LayoutUnit pageLogicalHeight = layoutView->layoutState()->pageLogicalHei
ght(); | |
2613 LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogi
calHeight); | |
2614 if (pageBoundaryRule == AssociateWithFormerPage) { | |
2615 // An offset exactly at a page boundary will act as being part of th
e former page in | |
2616 // question (i.e. no remaining space), rather than being part of the
latter (i.e. one | |
2617 // whole page length of remaining space). | |
2618 remainingHeight = intMod(remainingHeight, pageLogicalHeight); | |
2619 } | |
2620 return remainingHeight; | |
2621 } | |
2622 | |
2623 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); | |
2624 } | |
2625 | |
2626 LayoutUnit LayoutBlock::calculatePaginationStrutToFitContent(LayoutUnit offset,
LayoutUnit strutToNextPage, LayoutUnit contentLogicalHeight) const | |
2627 { | |
2628 ASSERT(strutToNextPage == pageRemainingLogicalHeightForOffset(offset, Associ
ateWithLatterPage)); | |
2629 LayoutUnit nextPageLogicalTop = offset + strutToNextPage; | |
2630 if (pageLogicalHeightForOffset(nextPageLogicalTop) >= contentLogicalHeight) | |
2631 return strutToNextPage; // Content fits just fine in the next page or co
lumn. | |
2632 | |
2633 // Moving to the top of the next page or column doesn't result in enough spa
ce for the content | |
2634 // that we're trying to fit. If we're in a nested fragmentation context, we
may find enough | |
2635 // space if we move to a column further ahead, by effectively breaking to th
e next outer | |
2636 // fragmentainer. | |
2637 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | |
2638 if (!flowThread) { | |
2639 // If there's no flow thread, we're not nested. All pages have the same
height. Give up. | |
2640 return strutToNextPage; | |
2641 } | |
2642 // Start searching for a suitable offset at the top of the next page or colu
mn. | |
2643 LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLo
gicalTop; | |
2644 return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flo
wThreadOffset, contentLogicalHeight) - flowThreadOffset; | |
2645 } | |
2646 | |
2647 void LayoutBlock::paginatedContentWasLaidOut(LayoutUnit logicalBottomOffsetAfter
Pagination) | 2596 void LayoutBlock::paginatedContentWasLaidOut(LayoutUnit logicalBottomOffsetAfter
Pagination) |
2648 { | 2597 { |
2649 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) | 2598 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) |
2650 flowThread->contentWasLaidOut(offsetFromLogicalTopOfFirstPage() + logica
lBottomOffsetAfterPagination); | 2599 flowThread->contentWasLaidOut(offsetFromLogicalTopOfFirstPage() + logica
lBottomOffsetAfterPagination); |
2651 } | 2600 } |
2652 | 2601 |
2653 LayoutUnit LayoutBlock::collapsedMarginBeforeForChild(const LayoutBox& child) co
nst | 2602 LayoutUnit LayoutBlock::collapsedMarginBeforeForChild(const LayoutBox& child) co
nst |
2654 { | 2603 { |
2655 // If the child has the same directionality as we do, then we can just retur
n its | 2604 // If the child has the same directionality as we do, then we can just retur
n its |
2656 // collapsed margin. | 2605 // collapsed margin. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2867 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2816 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2868 { | 2817 { |
2869 showLayoutObject(); | 2818 showLayoutObject(); |
2870 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2819 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2871 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2820 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2872 } | 2821 } |
2873 | 2822 |
2874 #endif | 2823 #endif |
2875 | 2824 |
2876 } // namespace blink | 2825 } // namespace blink |
OLD | NEW |