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

Side by Side Diff: Source/core/rendering/RenderBlock.cpp

Issue 134473008: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase master Created 6 years, 10 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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockFlow.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/rendering/HitTestLocation.h" 42 #include "core/rendering/HitTestLocation.h"
43 #include "core/rendering/HitTestResult.h" 43 #include "core/rendering/HitTestResult.h"
44 #include "core/rendering/InlineIterator.h" 44 #include "core/rendering/InlineIterator.h"
45 #include "core/rendering/InlineTextBox.h" 45 #include "core/rendering/InlineTextBox.h"
46 #include "core/rendering/LayoutRectRecorder.h" 46 #include "core/rendering/LayoutRectRecorder.h"
47 #include "core/rendering/LayoutRepainter.h" 47 #include "core/rendering/LayoutRepainter.h"
48 #include "core/rendering/PaintInfo.h" 48 #include "core/rendering/PaintInfo.h"
49 #include "core/rendering/RenderCombineText.h" 49 #include "core/rendering/RenderCombineText.h"
50 #include "core/rendering/RenderDeprecatedFlexibleBox.h" 50 #include "core/rendering/RenderDeprecatedFlexibleBox.h"
51 #include "core/rendering/RenderFlexibleBox.h" 51 #include "core/rendering/RenderFlexibleBox.h"
52 #include "core/rendering/RenderFlowThread.h"
52 #include "core/rendering/RenderInline.h" 53 #include "core/rendering/RenderInline.h"
53 #include "core/rendering/RenderLayer.h" 54 #include "core/rendering/RenderLayer.h"
54 #include "core/rendering/RenderMarquee.h" 55 #include "core/rendering/RenderMarquee.h"
55 #include "core/rendering/RenderNamedFlowThread.h"
56 #include "core/rendering/RenderRegion.h" 56 #include "core/rendering/RenderRegion.h"
57 #include "core/rendering/RenderTableCell.h" 57 #include "core/rendering/RenderTableCell.h"
58 #include "core/rendering/RenderTextControl.h" 58 #include "core/rendering/RenderTextControl.h"
59 #include "core/rendering/RenderTextFragment.h" 59 #include "core/rendering/RenderTextFragment.h"
60 #include "core/rendering/RenderTheme.h" 60 #include "core/rendering/RenderTheme.h"
61 #include "core/rendering/RenderView.h" 61 #include "core/rendering/RenderView.h"
62 #include "core/rendering/shapes/ShapeOutsideInfo.h" 62 #include "core/rendering/shapes/ShapeOutsideInfo.h"
63 #include "core/rendering/style/ContentData.h" 63 #include "core/rendering/style/ContentData.h"
64 #include "core/rendering/style/RenderStyle.h" 64 #include "core/rendering/style/RenderStyle.h"
65 #include "platform/geometry/FloatQuad.h" 65 #include "platform/geometry/FloatQuad.h"
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 RenderObject* nextSibling = child->nextSibling(); 1051 RenderObject* nextSibling = child->nextSibling();
1052 1052
1053 RenderFlowThread* childFlowThread = child->flowThreadContainingBlock(); 1053 RenderFlowThread* childFlowThread = child->flowThreadContainingBlock();
1054 CurrentRenderFlowThreadMaintainer flowThreadMaintainer(childFlowThread); 1054 CurrentRenderFlowThreadMaintainer flowThreadMaintainer(childFlowThread);
1055 1055
1056 parent->children()->removeChildNode(parent, child, child->hasLayer()); 1056 parent->children()->removeChildNode(parent, child, child->hasLayer());
1057 child->moveAllChildrenTo(parent, nextSibling, child->hasLayer()); 1057 child->moveAllChildrenTo(parent, nextSibling, child->hasLayer());
1058 // Explicitly delete the child's line box tree, or the special anonymous 1058 // Explicitly delete the child's line box tree, or the special anonymous
1059 // block handling in willBeDestroyed will cause problems. 1059 // block handling in willBeDestroyed will cause problems.
1060 child->deleteLineBoxTree(); 1060 child->deleteLineBoxTree();
1061 if (childFlowThread && childFlowThread->isRenderNamedFlowThread())
1062 toRenderNamedFlowThread(childFlowThread)->removeFlowChildInfo(child);
1063 child->destroy(); 1061 child->destroy();
1064 } 1062 }
1065 1063
1066 void RenderBlock::removeChild(RenderObject* oldChild) 1064 void RenderBlock::removeChild(RenderObject* oldChild)
1067 { 1065 {
1068 // No need to waste time in merging or removing empty anonymous blocks. 1066 // No need to waste time in merging or removing empty anonymous blocks.
1069 // We can just bail out if our document is getting destroyed. 1067 // We can just bail out if our document is getting destroyed.
1070 if (documentBeingDestroyed()) { 1068 if (documentBeingDestroyed()) {
1071 RenderBox::removeChild(oldChild); 1069 RenderBox::removeChild(oldChild);
1072 return; 1070 return;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 1456
1459 return shapeInfoRequiresRelayout(this); 1457 return shapeInfoRequiresRelayout(this);
1460 } 1458 }
1461 1459
1462 void RenderBlock::computeShapeSize() 1460 void RenderBlock::computeShapeSize()
1463 { 1461 {
1464 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo(); 1462 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo();
1465 if (!shapeInsideInfo) 1463 if (!shapeInsideInfo)
1466 return; 1464 return;
1467 1465
1468 if (isRenderNamedFlowFragment()) { 1466 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvable FromBlock(this, false);
1469 ShapeInsideInfo* parentShapeInsideInfo = toRenderBlock(parent())->shapeI nsideInfo(); 1467 shapeInsideInfo->setShapeSize(logicalWidth(), percentageLogicalHeightResolva ble ? logicalHeight() : LayoutUnit());
1470 ASSERT(parentShapeInsideInfo);
1471 shapeInsideInfo->setShapeSize(parentShapeInsideInfo->shapeSize().width() , parentShapeInsideInfo->shapeSize().height());
1472 } else {
1473 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolv ableFromBlock(this, false);
1474 shapeInsideInfo->setShapeSize(logicalWidth(), percentageLogicalHeightRes olvable ? logicalHeight() : LayoutUnit());
1475 }
1476 } 1468 }
1477 1469
1478 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged) 1470 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged)
1479 { 1471 {
1480 // A previous sibling has changed dimension, so we need to relayout the shap e with the content 1472 // A previous sibling has changed dimension, so we need to relayout the shap e with the content
1481 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo(); 1473 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
1482 if (heightChanged && shapeInsideInfo) 1474 if (heightChanged && shapeInsideInfo)
1483 shapeInsideInfo->dirtyShapeSize(); 1475 shapeInsideInfo->dirtyShapeSize();
1484 1476
1485 computeRegionRangeForBlock(flowThread); 1477 computeRegionRangeForBlock(flowThread);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 addLayoutOverflow(rectToApply); 1543 addLayoutOverflow(rectToApply);
1552 if (hasRenderOverflow()) 1544 if (hasRenderOverflow())
1553 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 1545 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
1554 } 1546 }
1555 1547
1556 // Add visual overflow from box-shadow and border-image-outset. 1548 // Add visual overflow from box-shadow and border-image-outset.
1557 addVisualEffectOverflow(); 1549 addVisualEffectOverflow();
1558 1550
1559 // Add visual overflow from theme. 1551 // Add visual overflow from theme.
1560 addVisualOverflowFromTheme(); 1552 addVisualOverflowFromTheme();
1561
1562 if (isRenderNamedFlowThread())
1563 toRenderNamedFlowThread(this)->computeOversetStateForRegions(oldClientAf terEdge);
1564 } 1553 }
1565 1554
1566 void RenderBlock::addOverflowFromBlockChildren() 1555 void RenderBlock::addOverflowFromBlockChildren()
1567 { 1556 {
1568 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 1557 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
1569 if (!child->isFloatingOrOutOfFlowPositioned()) 1558 if (!child->isFloatingOrOutOfFlowPositioned())
1570 addOverflowFromChild(child); 1559 addOverflowFromChild(child);
1571 } 1560 }
1572 } 1561 }
1573 1562
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 } 2836 }
2848 2837
2849 LayoutUnit RenderBlock::textIndentOffset() const 2838 LayoutUnit RenderBlock::textIndentOffset() const
2850 { 2839 {
2851 LayoutUnit cw = 0; 2840 LayoutUnit cw = 0;
2852 if (style()->textIndent().isPercent()) 2841 if (style()->textIndent().isPercent())
2853 cw = containingBlock()->availableLogicalWidth(); 2842 cw = containingBlock()->availableLogicalWidth();
2854 return minimumValueForLength(style()->textIndent(), cw); 2843 return minimumValueForLength(style()->textIndent(), cw);
2855 } 2844 }
2856 2845
2857 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const
2858 {
2859 LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLe ft() + paddingLeft() : borderTop() + paddingTop();
2860 if (!region)
2861 return logicalLeftOffset;
2862 LayoutRect boxRect = borderBoxRectInRegion(region);
2863 return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRec t.y());
2864 }
2865
2866 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region) const
2867 {
2868 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop();
2869 logicalRightOffset += availableLogicalWidth();
2870 if (!region)
2871 return logicalRightOffset;
2872 LayoutRect boxRect = borderBoxRectInRegion(region);
2873 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY()));
2874 }
2875
2876 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l ogicalBottom, RootInlineBox* highest) 2846 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l ogicalBottom, RootInlineBox* highest)
2877 { 2847 {
2878 if (logicalTop >= logicalBottom) 2848 if (logicalTop >= logicalBottom)
2879 return; 2849 return;
2880 2850
2881 RootInlineBox* lowestDirtyLine = lastRootBox(); 2851 RootInlineBox* lowestDirtyLine = lastRootBox();
2882 RootInlineBox* afterLowest = lowestDirtyLine; 2852 RootInlineBox* afterLowest = lowestDirtyLine;
2883 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica lBottom && logicalBottom < LayoutUnit::max()) { 2853 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica lBottom && logicalBottom < LayoutUnit::max()) {
2884 afterLowest = lowestDirtyLine; 2854 afterLowest = lowestDirtyLine;
2885 lowestDirtyLine = lowestDirtyLine->prevRootBox(); 2855 lowestDirtyLine = lowestDirtyLine->prevRootBox();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) { 2918 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) {
2949 updateHitTestResult(result, locationInContainer.point() - localOffset); 2919 updateHitTestResult(result, locationInContainer.point() - localOffset);
2950 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet . 2920 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet .
2951 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer)) 2921 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer))
2952 return true; 2922 return true;
2953 } 2923 }
2954 2924
2955 // If we have clipping, then we can't have any spillout. 2925 // If we have clipping, then we can't have any spillout.
2956 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer(); 2926 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer();
2957 bool useClip = (hasControlClip() || useOverflowClip); 2927 bool useClip = (hasControlClip() || useOverflowClip);
2958 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over flowClipRect(adjustedLocation, locationInContainer.region(), IncludeOverlayScrol lbarSize))); 2928 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over flowClipRect(adjustedLocation, IncludeOverlayScrollbarSize)));
2959 if (checkChildren) { 2929 if (checkChildren) {
2960 // Hit test descendants first. 2930 // Hit test descendants first.
2961 LayoutSize scrolledOffset(localOffset); 2931 LayoutSize scrolledOffset(localOffset);
2962 if (hasOverflowClip()) 2932 if (hasOverflowClip())
2963 scrolledOffset -= scrolledContentOffset(); 2933 scrolledOffset -= scrolledContentOffset();
2964 2934
2965 // Hit test contents if we don't have columns. 2935 // Hit test contents if we don't have columns.
2966 if (!hasColumns()) { 2936 if (!hasColumns()) {
2967 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) { 2937 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) {
2968 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset)); 2938 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 LayoutRect colRect = it.columnRect(); 3059 LayoutRect colRect = it.columnRect();
3090 if (colRect.contains(locationInContainer)) { 3060 if (colRect.contains(locationInContainer)) {
3091 it.adjust(offset); 3061 it.adjust(offset);
3092 return; 3062 return;
3093 } 3063 }
3094 } 3064 }
3095 } 3065 }
3096 3066
3097 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction) 3067 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction)
3098 { 3068 {
3099 if (isRenderRegion())
3100 return toRenderRegion(this)->hitTestFlowThreadContents(request, result, locationInContainer, accumulatedOffset, hitTestAction);
3101
3102 if (childrenInline() && !isTable()) { 3069 if (childrenInline() && !isTable()) {
3103 // We have to hit-test our line boxes. 3070 // We have to hit-test our line boxes.
3104 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction)) 3071 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction))
3105 return true; 3072 return true;
3106 } else { 3073 } else {
3107 // Hit test our children. 3074 // Hit test our children.
3108 HitTestAction childHitTest = hitTestAction; 3075 HitTestAction childHitTest = hitTestAction;
3109 if (hitTestAction == HitTestChildBlockBackgrounds) 3076 if (hitTestAction == HitTestChildBlockBackgrounds)
3110 childHitTest = HitTestChildBlockBackground; 3077 childHitTest = HitTestChildBlockBackground;
3111 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) { 3078 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) {
(...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 5105
5139 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const 5106 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const
5140 { 5107 {
5141 if (isAnonymousColumnsBlock()) 5108 if (isAnonymousColumnsBlock())
5142 return createAnonymousColumnsWithParentRenderer(parent); 5109 return createAnonymousColumnsWithParentRenderer(parent);
5143 if (isAnonymousColumnSpanBlock()) 5110 if (isAnonymousColumnSpanBlock())
5144 return createAnonymousColumnSpanWithParentRenderer(parent); 5111 return createAnonymousColumnSpanWithParentRenderer(parent);
5145 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( )); 5112 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( ));
5146 } 5113 }
5147 5114
5148 bool RenderBlock::hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule pageBou ndaryRule) const
5149 {
5150 ASSERT(view()->layoutState() && view()->layoutState()->isPaginated());
5151
5152 RenderFlowThread* flowThread = flowThreadContainingBlock();
5153 if (!flowThread)
5154 return true; // Printing and multi-column both make new pages to accommo date content.
5155
5156 // See if we're in the last region.
5157 LayoutUnit pageOffset = offsetFromLogicalTopOfFirstPage() + logicalOffset;
5158 RenderRegion* region = flowThread->regionAtBlockOffset(pageOffset, this);
5159 if (!region)
5160 return false;
5161 if (region->isLastRegion())
5162 return region->isRenderRegionSet() || region->style()->regionFragment() == BreakRegionFragment
5163 || (pageBoundaryRule == IncludePageBoundary && pageOffset == region- >logicalTopForFlowThreadContent());
5164 return true;
5165 }
5166
5167 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const 5115 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const
5168 { 5116 {
5169 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5117 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5170 if (!pageLogicalHeight) 5118 if (!pageLogicalHeight)
5171 return logicalOffset; 5119 return logicalOffset;
5172 5120
5173 // The logicalOffset is in our coordinate space. We can add in our pushed o ffset. 5121 // The logicalOffset is in our coordinate space. We can add in our pushed o ffset.
5174 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset); 5122 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset);
5175 if (pageBoundaryRule == ExcludePageBoundary) 5123 if (pageBoundaryRule == ExcludePageBoundary)
5176 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight : pageLogicalHeight); 5124 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight : pageLogicalHeight);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5220 return remainingHeight; 5168 return remainingHeight;
5221 } 5169 }
5222 5170
5223 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR ule); 5171 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR ule);
5224 } 5172 }
5225 5173
5226 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins) 5174 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins)
5227 { 5175 {
5228 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); 5176 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
5229 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; 5177 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight;
5230 RenderFlowThread* flowThread = flowThreadContainingBlock();
5231 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread() ;
5232 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID) 5178 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID)
5233 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID) 5179 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID);
5234 || (checkRegionBreaks && child->style()->regionBreakInside() == PBAVOID) ;
5235 if (!isUnsplittable) 5180 if (!isUnsplittable)
5236 return logicalOffset; 5181 return logicalOffset;
5237 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); 5182 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit());
5238 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5183 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5239 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight();
5240 updateMinimumPageHeight(logicalOffset, childLogicalHeight); 5184 updateMinimumPageHeight(logicalOffset, childLogicalHeight);
5241 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && childLogicalHeight > pageLogicalHeight) 5185 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight)
5242 || !hasNextPage(logicalOffset))
5243 return logicalOffset; 5186 return logicalOffset;
5244 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 5187 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
5245 if (remainingLogicalHeight < childLogicalHeight) { 5188 if (remainingLogicalHeight < childLogicalHeight)
5246 if (!hasUniformPageLogicalHeight && !pushToNextPageWithMinimumLogicalHei ght(remainingLogicalHeight, logicalOffset, childLogicalHeight))
5247 return logicalOffset;
5248 return logicalOffset + remainingLogicalHeight; 5189 return logicalOffset + remainingLogicalHeight;
5249 }
5250 return logicalOffset; 5190 return logicalOffset;
5251 } 5191 }
5252 5192
5253 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const 5193 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const
5254 { 5194 {
5255 bool checkRegion = false; 5195 // FIXME: multicol will need to do some work here, when we implement support for multiple rows.
5256 for (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustment); pageLogicalHeight; 5196 return false;
5257 pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustmen t)) {
5258 if (minimumLogicalHeight <= pageLogicalHeight)
5259 return true;
5260 if (!hasNextPage(logicalOffset + adjustment))
5261 return false;
5262 adjustment += pageLogicalHeight;
5263 checkRegion = true;
5264 }
5265 return !checkRegion;
5266 } 5197 }
5267 5198
5268 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) 5199 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage)
5269 { 5200 {
5270 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) 5201 if (RenderFlowThread* flowThread = flowThreadContainingBlock())
5271 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa ceShortage); 5202 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa ceShortage);
5272 } 5203 }
5273 5204
5274 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh t) 5205 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh t)
5275 { 5206 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5323 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu alOverflow.maxY()); 5254 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu alOverflow.maxY());
5324 LayoutUnit lineHeight = logicalBottom - logicalOffset; 5255 LayoutUnit lineHeight = logicalBottom - logicalOffset;
5325 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom)); 5256 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom));
5326 logicalOffset += delta; 5257 logicalOffset += delta;
5327 lineBox->setPaginationStrut(0); 5258 lineBox->setPaginationStrut(0);
5328 lineBox->setIsFirstAfterPageBreak(false); 5259 lineBox->setIsFirstAfterPageBreak(false);
5329 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5260 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5330 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight(); 5261 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight();
5331 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are 5262 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are
5332 // still going to add a strut, so that the visible overflow fits on a single page. 5263 // still going to add a strut, so that the visible overflow fits on a single page.
5333 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight) 5264 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight))
5334 || !hasNextPage(logicalOffset))
5335 // FIXME: In case the line aligns with the top of the page (or it's slig htly shifted downwards) it will not be marked as the first line in the page. 5265 // FIXME: In case the line aligns with the top of the page (or it's slig htly shifted downwards) it will not be marked as the first line in the page.
5336 // From here, the fix is not straightforward because it's not easy to al ways determine when the current line is the first in the page. 5266 // From here, the fix is not straightforward because it's not easy to al ways determine when the current line is the first in the page.
5337 return; 5267 return;
5338 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 5268 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
5339 5269
5340 int lineIndex = lineCount(lineBox); 5270 int lineIndex = lineCount(lineBox);
5341 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) { 5271 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) {
5342 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { 5272 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) {
5343 clearShouldBreakAtLineToAvoidWidow(); 5273 clearShouldBreakAtLineToAvoidWidow();
5344 setDidBreakAtLineToAvoidWidow(); 5274 setDidBreakAtLineToAvoidWidow();
(...skipping 18 matching lines...) Expand all
5363 } 5293 }
5364 } else if (remainingLogicalHeight == pageLogicalHeight) { 5294 } else if (remainingLogicalHeight == pageLogicalHeight) {
5365 // We're at the very top of a page or column. 5295 // We're at the very top of a page or column.
5366 if (lineBox != firstRootBox()) 5296 if (lineBox != firstRootBox())
5367 lineBox->setIsFirstAfterPageBreak(true); 5297 lineBox->setIsFirstAfterPageBreak(true);
5368 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) 5298 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage())
5369 setPageBreak(logicalOffset, lineHeight); 5299 setPageBreak(logicalOffset, lineHeight);
5370 } 5300 }
5371 } 5301 }
5372 5302
5373 void RenderBlock::updateRegionForLine(RootInlineBox* lineBox) const
5374 {
5375 ASSERT(lineBox);
5376 lineBox->setContainingRegion(regionAtBlockOffset(lineBox->lineTopWithLeading ()));
5377
5378 RootInlineBox* prevLineBox = lineBox->prevRootBox();
5379 if (!prevLineBox)
5380 return;
5381
5382 // This check is more accurate than the one in |adjustLinePositionForPaginat ion| because it takes into
5383 // account just the container changes between lines. The before mentioned fu nction doesn't set the flag
5384 // correctly if the line is positioned at the top of the last fragment conta iner.
5385 if (lineBox->containingRegion() != prevLineBox->containingRegion())
5386 lineBox->setIsFirstAfterPageBreak(true);
5387 }
5388
5389 bool RenderBlock::lineWidthForPaginatedLineChanged(RootInlineBox* rootBox, Layou tUnit lineDelta, RenderFlowThread* flowThread) const
5390 {
5391 if (!flowThread)
5392 return false;
5393
5394 RenderRegion* currentRegion = regionAtBlockOffset(rootBox->lineTopWithLeadin g() + lineDelta);
5395 // Just bail if the region didn't change.
5396 if (rootBox->containingRegion() == currentRegion)
5397 return false;
5398 return rootBox->paginatedLineWidth() != availableLogicalWidthForContent(curr entRegion);
5399 }
5400
5401 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const 5303 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const
5402 { 5304 {
5403 LayoutState* layoutState = view()->layoutState(); 5305 LayoutState* layoutState = view()->layoutState();
5404 if (layoutState && !layoutState->isPaginated()) 5306 if (layoutState && !layoutState->isPaginated())
5405 return 0; 5307 return 0;
5406 5308
5407 RenderFlowThread* flowThread = flowThreadContainingBlock(); 5309 RenderFlowThread* flowThread = flowThreadContainingBlock();
5408 if (flowThread) 5310 if (flowThread)
5409 return flowThread->offsetFromLogicalTopOfFirstRegion(this); 5311 return flowThread->offsetFromLogicalTopOfFirstRegion(this);
5410 5312
(...skipping 10 matching lines...) Expand all
5421 5323
5422 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const 5324 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const
5423 { 5325 {
5424 RenderFlowThread* flowThread = flowThreadContainingBlock(); 5326 RenderFlowThread* flowThread = flowThreadContainingBlock();
5425 if (!flowThread || !flowThread->hasValidRegionInfo()) 5327 if (!flowThread || !flowThread->hasValidRegionInfo())
5426 return 0; 5328 return 0;
5427 5329
5428 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b lockOffset, true); 5330 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b lockOffset, true);
5429 } 5331 }
5430 5332
5431 bool RenderBlock::logicalWidthChangedInRegions(RenderFlowThread* flowThread) con st
5432 {
5433 if (!flowThread || !flowThread->hasValidRegionInfo())
5434 return false;
5435
5436 return flowThread->logicalWidthChangedInRegionsForBlock(this);
5437 }
5438
5439 RenderRegion* RenderBlock::clampToStartAndEndRegions(RenderRegion* region) const
5440 {
5441 RenderFlowThread* flowThread = flowThreadContainingBlock();
5442
5443 ASSERT(isRenderView() || (region && flowThread));
5444 if (isRenderView())
5445 return region;
5446
5447 // We need to clamp to the block, since we want any lines or blocks that ove rflow out of the
5448 // logical top or logical bottom of the block to size as though the border b ox in the first and
5449 // last regions extended infinitely. Otherwise the lines are going to size a ccording to the regions
5450 // they overflow into, which makes no sense when this block doesn't exist in |region| at all.
5451 RenderRegion* startRegion;
5452 RenderRegion* endRegion;
5453 flowThread->getRegionRangeForBox(this, startRegion, endRegion);
5454
5455 if (startRegion && region->logicalTopForFlowThreadContent() < startRegion->l ogicalTopForFlowThreadContent())
5456 return startRegion;
5457 if (endRegion && region->logicalTopForFlowThreadContent() > endRegion->logic alTopForFlowThreadContent())
5458 return endRegion;
5459
5460 return region;
5461 }
5462
5463 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst 5333 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst
5464 { 5334 {
5465 // If the child has the same directionality as we do, then we can just retur n its 5335 // If the child has the same directionality as we do, then we can just retur n its
5466 // collapsed margin. 5336 // collapsed margin.
5467 if (!child->isWritingModeRoot()) 5337 if (!child->isWritingModeRoot())
5468 return child->collapsedMarginBefore(); 5338 return child->collapsedMarginBefore();
5469 5339
5470 // The child has a different directionality. If the child is parallel, then it's just 5340 // The child has a different directionality. If the child is parallel, then it's just
5471 // flipped relative to us. We can use the collapsed margin for the opposite edge. 5341 // flipped relative to us. We can use the collapsed margin for the opposite edge.
5472 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) 5342 if (child->isHorizontalWritingMode() == isHorizontalWritingMode())
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5615 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5485 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5616 { 5486 {
5617 showRenderObject(); 5487 showRenderObject();
5618 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5488 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5619 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5489 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5620 } 5490 }
5621 5491
5622 #endif 5492 #endif
5623 5493
5624 } // namespace WebCore 5494 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | Source/core/rendering/RenderBlockFlow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698