Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlock.cpp

Issue 1602773005: Respect break-inside:avoid on table rows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 2561
2562 LayoutUnit LayoutBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const 2562 LayoutUnit LayoutBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const
2563 { 2563 {
2564 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 2564 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
2565 if (!pageLogicalHeight) 2565 if (!pageLogicalHeight)
2566 return logicalOffset; 2566 return logicalOffset;
2567 2567
2568 return logicalOffset + pageRemainingLogicalHeightForOffset(logicalOffset, pa geBoundaryRule); 2568 return logicalOffset + pageRemainingLogicalHeightForOffset(logicalOffset, pa geBoundaryRule);
2569 } 2569 }
2570 2570
2571 LayoutUnit LayoutBlock::pageLogicalHeightForOffset(LayoutUnit offset) const
2572 {
2573 LayoutView* layoutView = view();
2574 LayoutFlowThread* flowThread = flowThreadContainingBlock();
2575 if (!flowThread)
2576 return layoutView->layoutState()->pageLogicalHeight();
2577 return flowThread->pageLogicalHeightForOffset(offset + offsetFromLogicalTopO fFirstPage());
2578 }
2579
2580 LayoutUnit LayoutBlock::pageRemainingLogicalHeightForOffset(LayoutUnit offset, P ageBoundaryRule pageBoundaryRule) const
2581 {
2582 LayoutView* layoutView = view();
2583 offset += offsetFromLogicalTopOfFirstPage();
2584
2585 LayoutFlowThread* flowThread = flowThreadContainingBlock();
2586 if (!flowThread) {
2587 LayoutUnit pageLogicalHeight = layoutView->layoutState()->pageLogicalHei ght();
2588 LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogi calHeight);
2589 if (pageBoundaryRule == AssociateWithFormerPage) {
2590 // An offset exactly at a page boundary will act as being part of th e former page in
2591 // question (i.e. no remaining space), rather than being part of the latter (i.e. one
2592 // whole page length of remaining space).
2593 remainingHeight = intMod(remainingHeight, pageLogicalHeight);
2594 }
2595 return remainingHeight;
2596 }
2597
2598 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR ule);
2599 }
2600
2601 LayoutUnit LayoutBlock::calculatePaginationStrutToFitContent(LayoutUnit offset, LayoutUnit strutToNextPage, LayoutUnit contentLogicalHeight) const
2602 {
2603 ASSERT(strutToNextPage == pageRemainingLogicalHeightForOffset(offset, Associ ateWithLatterPage));
2604 LayoutUnit nextPageLogicalTop = offset + strutToNextPage;
2605 if (pageLogicalHeightForOffset(nextPageLogicalTop) >= contentLogicalHeight)
2606 return strutToNextPage; // Content fits just fine in the next page or co lumn.
2607
2608 // Moving to the top of the next page or column doesn't result in enough spa ce for the content
2609 // that we're trying to fit. If we're in a nested fragmentation context, we may find enough
2610 // space if we move to a column further ahead, by effectively breaking to th e next outer
2611 // fragmentainer.
2612 LayoutFlowThread* flowThread = flowThreadContainingBlock();
2613 if (!flowThread) {
2614 // If there's no flow thread, we're not nested. All pages have the same height. Give up.
2615 return strutToNextPage;
2616 }
2617 // Start searching for a suitable offset at the top of the next page or colu mn.
2618 LayoutUnit flowThreadOffset = offsetFromLogicalTopOfFirstPage() + nextPageLo gicalTop;
2619 return strutToNextPage + flowThread->nextLogicalTopForUnbreakableContent(flo wThreadOffset, contentLogicalHeight) - flowThreadOffset;
2620 }
2621
2622 void LayoutBlock::paginatedContentWasLaidOut(LayoutUnit logicalBottomOffsetAfter Pagination) 2571 void LayoutBlock::paginatedContentWasLaidOut(LayoutUnit logicalBottomOffsetAfter Pagination)
2623 { 2572 {
2624 if (LayoutFlowThread* flowThread = flowThreadContainingBlock()) 2573 if (LayoutFlowThread* flowThread = flowThreadContainingBlock())
2625 flowThread->contentWasLaidOut(offsetFromLogicalTopOfFirstPage() + logica lBottomOffsetAfterPagination); 2574 flowThread->contentWasLaidOut(offsetFromLogicalTopOfFirstPage() + logica lBottomOffsetAfterPagination);
2626 } 2575 }
2627 2576
2628 LayoutUnit LayoutBlock::collapsedMarginBeforeForChild(const LayoutBox& child) co nst 2577 LayoutUnit LayoutBlock::collapsedMarginBeforeForChild(const LayoutBox& child) co nst
2629 { 2578 {
2630 // If the child has the same directionality as we do, then we can just retur n its 2579 // If the child has the same directionality as we do, then we can just retur n its
2631 // collapsed margin. 2580 // collapsed margin.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2791 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2843 { 2792 {
2844 showLayoutObject(); 2793 showLayoutObject();
2845 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2794 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2846 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2795 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2847 } 2796 }
2848 2797
2849 #endif 2798 #endif
2850 2799
2851 } // namespace blink 2800 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.h ('k') | third_party/WebKit/Source/core/layout/LayoutBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698