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