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

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: 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
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 1460
1463 return shapeInfoRequiresRelayout(this); 1461 return shapeInfoRequiresRelayout(this);
1464 } 1462 }
1465 1463
1466 void RenderBlock::computeShapeSize() 1464 void RenderBlock::computeShapeSize()
1467 { 1465 {
1468 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo(); 1466 ShapeInsideInfo* shapeInsideInfo = this->shapeInsideInfo();
1469 if (!shapeInsideInfo) 1467 if (!shapeInsideInfo)
1470 return; 1468 return;
1471 1469
1472 if (isRenderNamedFlowFragment()) { 1470 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvable FromBlock(this, false);
1473 ShapeInsideInfo* parentShapeInsideInfo = toRenderBlock(parent())->shapeI nsideInfo(); 1471 shapeInsideInfo->setShapeSize(logicalWidth(), percentageLogicalHeightResolva ble ? logicalHeight() : LayoutUnit());
1474 ASSERT(parentShapeInsideInfo);
1475 shapeInsideInfo->setShapeSize(parentShapeInsideInfo->shapeSize().width() , parentShapeInsideInfo->shapeSize().height());
1476 } else {
1477 bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolv ableFromBlock(this, false);
1478 shapeInsideInfo->setShapeSize(logicalWidth(), percentageLogicalHeightRes olvable ? logicalHeight() : LayoutUnit());
1479 }
1480 } 1472 }
1481 1473
1482 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged) 1474 void RenderBlock::updateRegionsAndShapesAfterChildLayout(RenderFlowThread* flowT hread, bool heightChanged)
1483 { 1475 {
1484 // A previous sibling has changed dimension, so we need to relayout the shap e with the content 1476 // A previous sibling has changed dimension, so we need to relayout the shap e with the content
1485 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo(); 1477 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
1486 if (heightChanged && shapeInsideInfo) 1478 if (heightChanged && shapeInsideInfo)
1487 shapeInsideInfo->dirtyShapeSize(); 1479 shapeInsideInfo->dirtyShapeSize();
1488 1480
1489 computeRegionRangeForBlock(flowThread); 1481 computeRegionRangeForBlock(flowThread);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 addLayoutOverflow(rectToApply); 1547 addLayoutOverflow(rectToApply);
1556 if (hasRenderOverflow()) 1548 if (hasRenderOverflow())
1557 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge); 1549 m_overflow->setLayoutClientAfterEdge(oldClientAfterEdge);
1558 } 1550 }
1559 1551
1560 // Add visual overflow from box-shadow and border-image-outset. 1552 // Add visual overflow from box-shadow and border-image-outset.
1561 addVisualEffectOverflow(); 1553 addVisualEffectOverflow();
1562 1554
1563 // Add visual overflow from theme. 1555 // Add visual overflow from theme.
1564 addVisualOverflowFromTheme(); 1556 addVisualOverflowFromTheme();
1565
1566 if (isRenderNamedFlowThread())
1567 toRenderNamedFlowThread(this)->computeOversetStateForRegions(oldClientAf terEdge);
1568 } 1557 }
1569 1558
1570 void RenderBlock::addOverflowFromBlockChildren() 1559 void RenderBlock::addOverflowFromBlockChildren()
1571 { 1560 {
1572 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { 1561 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) {
1573 if (!child->isFloatingOrOutOfFlowPositioned()) 1562 if (!child->isFloatingOrOutOfFlowPositioned())
1574 addOverflowFromChild(child); 1563 addOverflowFromChild(child);
1575 } 1564 }
1576 } 1565 }
1577 1566
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 } 2840 }
2852 2841
2853 LayoutUnit RenderBlock::textIndentOffset() const 2842 LayoutUnit RenderBlock::textIndentOffset() const
2854 { 2843 {
2855 LayoutUnit cw = 0; 2844 LayoutUnit cw = 0;
2856 if (style()->textIndent().isPercent()) 2845 if (style()->textIndent().isPercent())
2857 cw = containingBlock()->availableLogicalWidth(); 2846 cw = containingBlock()->availableLogicalWidth();
2858 return minimumValueForLength(style()->textIndent(), cw); 2847 return minimumValueForLength(style()->textIndent(), cw);
2859 } 2848 }
2860 2849
2861 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const
2862 {
2863 LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLe ft() + paddingLeft() : borderTop() + paddingTop();
2864 if (!region)
2865 return logicalLeftOffset;
2866 LayoutRect boxRect = borderBoxRectInRegion(region);
2867 return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRec t.y());
2868 }
2869
2870 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region) const
2871 {
2872 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL eft() + paddingLeft() : borderTop() + paddingTop();
2873 logicalRightOffset += availableLogicalWidth();
2874 if (!region)
2875 return logicalRightOffset;
2876 LayoutRect boxRect = borderBoxRectInRegion(region);
2877 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b oxRect.maxX() : boxRect.maxY()));
2878 }
2879
2880 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l ogicalBottom, RootInlineBox* highest) 2850 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l ogicalBottom, RootInlineBox* highest)
2881 { 2851 {
2882 if (logicalTop >= logicalBottom) 2852 if (logicalTop >= logicalBottom)
2883 return; 2853 return;
2884 2854
2885 RootInlineBox* lowestDirtyLine = lastRootBox(); 2855 RootInlineBox* lowestDirtyLine = lastRootBox();
2886 RootInlineBox* afterLowest = lowestDirtyLine; 2856 RootInlineBox* afterLowest = lowestDirtyLine;
2887 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica lBottom && logicalBottom < LayoutUnit::max()) { 2857 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica lBottom && logicalBottom < LayoutUnit::max()) {
2888 afterLowest = lowestDirtyLine; 2858 afterLowest = lowestDirtyLine;
2889 lowestDirtyLine = lowestDirtyLine->prevRootBox(); 2859 lowestDirtyLine = lowestDirtyLine->prevRootBox();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) { 2922 && isPointInOverflowControl(result, locationInContainer.point(), adjuste dLocation)) {
2953 updateHitTestResult(result, locationInContainer.point() - localOffset); 2923 updateHitTestResult(result, locationInContainer.point() - localOffset);
2954 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet . 2924 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet .
2955 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer)) 2925 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca tionInContainer))
2956 return true; 2926 return true;
2957 } 2927 }
2958 2928
2959 // If we have clipping, then we can't have any spillout. 2929 // If we have clipping, then we can't have any spillout.
2960 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer(); 2930 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer();
2961 bool useClip = (hasControlClip() || useOverflowClip); 2931 bool useClip = (hasControlClip() || useOverflowClip);
2962 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over flowClipRect(adjustedLocation, locationInContainer.region(), IncludeOverlayScrol lbarSize))); 2932 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over flowClipRect(adjustedLocation, IncludeOverlayScrollbarSize)));
2963 if (checkChildren) { 2933 if (checkChildren) {
2964 // Hit test descendants first. 2934 // Hit test descendants first.
2965 LayoutSize scrolledOffset(localOffset); 2935 LayoutSize scrolledOffset(localOffset);
2966 if (hasOverflowClip()) 2936 if (hasOverflowClip())
2967 scrolledOffset -= scrolledContentOffset(); 2937 scrolledOffset -= scrolledContentOffset();
2968 2938
2969 // Hit test contents if we don't have columns. 2939 // Hit test contents if we don't have columns.
2970 if (!hasColumns()) { 2940 if (!hasColumns()) {
2971 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) { 2941 if (hitTestContents(request, result, locationInContainer, toLayoutPo int(scrolledOffset), hitTestAction)) {
2972 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset)); 2942 updateHitTestResult(result, flipForWritingMode(locationInContain er.point() - localOffset));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3093 LayoutRect colRect = it.columnRect(); 3063 LayoutRect colRect = it.columnRect();
3094 if (colRect.contains(locationInContainer)) { 3064 if (colRect.contains(locationInContainer)) {
3095 it.adjust(offset); 3065 it.adjust(offset);
3096 return; 3066 return;
3097 } 3067 }
3098 } 3068 }
3099 } 3069 }
3100 3070
3101 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction) 3071 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat edOffset, HitTestAction hitTestAction)
3102 { 3072 {
3103 if (isRenderRegion())
3104 return toRenderRegion(this)->hitTestFlowThreadContents(request, result, locationInContainer, accumulatedOffset, hitTestAction);
3105
3106 if (childrenInline() && !isTable()) { 3073 if (childrenInline() && !isTable()) {
3107 // We have to hit-test our line boxes. 3074 // We have to hit-test our line boxes.
3108 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction)) 3075 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu mulatedOffset, hitTestAction))
3109 return true; 3076 return true;
3110 } else { 3077 } else {
3111 // Hit test our children. 3078 // Hit test our children.
3112 HitTestAction childHitTest = hitTestAction; 3079 HitTestAction childHitTest = hitTestAction;
3113 if (hitTestAction == HitTestChildBlockBackgrounds) 3080 if (hitTestAction == HitTestChildBlockBackgrounds)
3114 childHitTest = HitTestChildBlockBackground; 3081 childHitTest = HitTestChildBlockBackground;
3115 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) { 3082 for (RenderBox* child = lastChildBox(); child; child = child->previousSi blingBox()) {
(...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after
5142 5109
5143 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const 5110 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par ent) const
5144 { 5111 {
5145 if (isAnonymousColumnsBlock()) 5112 if (isAnonymousColumnsBlock())
5146 return createAnonymousColumnsWithParentRenderer(parent); 5113 return createAnonymousColumnsWithParentRenderer(parent);
5147 if (isAnonymousColumnSpanBlock()) 5114 if (isAnonymousColumnSpanBlock())
5148 return createAnonymousColumnSpanWithParentRenderer(parent); 5115 return createAnonymousColumnSpanWithParentRenderer(parent);
5149 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( )); 5116 return createAnonymousWithParentRendererAndDisplay(parent, style()->display( ));
5150 } 5117 }
5151 5118
5152 bool RenderBlock::hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule pageBou ndaryRule) const
5153 {
5154 ASSERT(view()->layoutState() && view()->layoutState()->isPaginated());
5155
5156 RenderFlowThread* flowThread = flowThreadContainingBlock();
5157 if (!flowThread)
5158 return true; // Printing and multi-column both make new pages to accommo date content.
5159
5160 // See if we're in the last region.
5161 LayoutUnit pageOffset = offsetFromLogicalTopOfFirstPage() + logicalOffset;
5162 RenderRegion* region = flowThread->regionAtBlockOffset(pageOffset, this);
5163 if (!region)
5164 return false;
5165 if (region->isLastRegion())
5166 return region->isRenderRegionSet() || region->style()->regionFragment() == BreakRegionFragment
5167 || (pageBoundaryRule == IncludePageBoundary && pageOffset == region- >logicalTopForFlowThreadContent());
5168 return true;
5169 }
5170
5171 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const 5119 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar yRule pageBoundaryRule) const
5172 { 5120 {
5173 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5121 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5174 if (!pageLogicalHeight) 5122 if (!pageLogicalHeight)
5175 return logicalOffset; 5123 return logicalOffset;
5176 5124
5177 // The logicalOffset is in our coordinate space. We can add in our pushed o ffset. 5125 // The logicalOffset is in our coordinate space. We can add in our pushed o ffset.
5178 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset); 5126 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset);
5179 if (pageBoundaryRule == ExcludePageBoundary) 5127 if (pageBoundaryRule == ExcludePageBoundary)
5180 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight : pageLogicalHeight); 5128 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight : pageLogicalHeight);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 return remainingHeight; 5172 return remainingHeight;
5225 } 5173 }
5226 5174
5227 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR ule); 5175 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR ule);
5228 } 5176 }
5229 5177
5230 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins) 5178 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins)
5231 { 5179 {
5232 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); 5180 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns();
5233 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; 5181 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight;
5234 RenderFlowThread* flowThread = flowThreadContainingBlock();
5235 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread() ;
5236 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID) 5182 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID)
5237 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID) 5183 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID);
5238 || (checkRegionBreaks && child->style()->regionBreakInside() == PBAVOID) ;
5239 if (!isUnsplittable) 5184 if (!isUnsplittable)
5240 return logicalOffset; 5185 return logicalOffset;
5241 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); 5186 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit());
5242 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5187 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5243 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight();
5244 updateMinimumPageHeight(logicalOffset, childLogicalHeight); 5188 updateMinimumPageHeight(logicalOffset, childLogicalHeight);
5245 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && childLogicalHeight > pageLogicalHeight) 5189 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight)
5246 || !hasNextPage(logicalOffset))
5247 return logicalOffset; 5190 return logicalOffset;
5248 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 5191 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
5249 if (remainingLogicalHeight < childLogicalHeight) { 5192 if (remainingLogicalHeight < childLogicalHeight)
5250 if (!hasUniformPageLogicalHeight && !pushToNextPageWithMinimumLogicalHei ght(remainingLogicalHeight, logicalOffset, childLogicalHeight))
5251 return logicalOffset;
5252 return logicalOffset + remainingLogicalHeight; 5193 return logicalOffset + remainingLogicalHeight;
5253 }
5254 return logicalOffset; 5194 return logicalOffset;
5255 } 5195 }
5256 5196
5257 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const 5197 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const
5258 { 5198 {
5259 bool checkRegion = false; 5199 // FIXME: multicol will need to do some work here, when we implement support for multiple rows.
5260 for (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustment); pageLogicalHeight; 5200 return false;
5261 pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustmen t)) {
5262 if (minimumLogicalHeight <= pageLogicalHeight)
5263 return true;
5264 if (!hasNextPage(logicalOffset + adjustment))
5265 return false;
5266 adjustment += pageLogicalHeight;
5267 checkRegion = true;
5268 }
5269 return !checkRegion;
5270 } 5201 }
5271 5202
5272 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) 5203 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage)
5273 { 5204 {
5274 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) 5205 if (RenderFlowThread* flowThread = flowThreadContainingBlock())
5275 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa ceShortage); 5206 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa ceShortage);
5276 } 5207 }
5277 5208
5278 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh t) 5209 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh t)
5279 { 5210 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5327 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu alOverflow.maxY()); 5258 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu alOverflow.maxY());
5328 LayoutUnit lineHeight = logicalBottom - logicalOffset; 5259 LayoutUnit lineHeight = logicalBottom - logicalOffset;
5329 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom)); 5260 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l ineBox, logicalOffset, logicalBottom));
5330 logicalOffset += delta; 5261 logicalOffset += delta;
5331 lineBox->setPaginationStrut(0); 5262 lineBox->setPaginationStrut(0);
5332 lineBox->setIsFirstAfterPageBreak(false); 5263 lineBox->setIsFirstAfterPageBreak(false);
5333 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 5264 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
5334 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight(); 5265 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni formLogicalHeight();
5335 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are 5266 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo w.height() still fits, we are
5336 // still going to add a strut, so that the visible overflow fits on a single page. 5267 // still going to add a strut, so that the visible overflow fits on a single page.
5337 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight) 5268 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf low.height() > pageLogicalHeight))
5338 || !hasNextPage(logicalOffset))
5339 // 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. 5269 // 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.
5340 // 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. 5270 // 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.
5341 return; 5271 return;
5342 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 5272 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
5343 5273
5344 int lineIndex = lineCount(lineBox); 5274 int lineIndex = lineCount(lineBox);
5345 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) { 5275 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIndex)) {
5346 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { 5276 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) {
5347 clearShouldBreakAtLineToAvoidWidow(); 5277 clearShouldBreakAtLineToAvoidWidow();
5348 setDidBreakAtLineToAvoidWidow(); 5278 setDidBreakAtLineToAvoidWidow();
(...skipping 18 matching lines...) Expand all
5367 } 5297 }
5368 } else if (remainingLogicalHeight == pageLogicalHeight) { 5298 } else if (remainingLogicalHeight == pageLogicalHeight) {
5369 // We're at the very top of a page or column. 5299 // We're at the very top of a page or column.
5370 if (lineBox != firstRootBox()) 5300 if (lineBox != firstRootBox())
5371 lineBox->setIsFirstAfterPageBreak(true); 5301 lineBox->setIsFirstAfterPageBreak(true);
5372 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) 5302 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage())
5373 setPageBreak(logicalOffset, lineHeight); 5303 setPageBreak(logicalOffset, lineHeight);
5374 } 5304 }
5375 } 5305 }
5376 5306
5377 void RenderBlock::updateRegionForLine(RootInlineBox* lineBox) const
5378 {
5379 ASSERT(lineBox);
5380 lineBox->setContainingRegion(regionAtBlockOffset(lineBox->lineTopWithLeading ()));
5381
5382 RootInlineBox* prevLineBox = lineBox->prevRootBox();
5383 if (!prevLineBox)
5384 return;
5385
5386 // This check is more accurate than the one in |adjustLinePositionForPaginat ion| because it takes into
5387 // account just the container changes between lines. The before mentioned fu nction doesn't set the flag
5388 // correctly if the line is positioned at the top of the last fragment conta iner.
5389 if (lineBox->containingRegion() != prevLineBox->containingRegion())
5390 lineBox->setIsFirstAfterPageBreak(true);
5391 }
5392
5393 bool RenderBlock::lineWidthForPaginatedLineChanged(RootInlineBox* rootBox, Layou tUnit lineDelta, RenderFlowThread* flowThread) const
5394 {
5395 if (!flowThread)
5396 return false;
5397
5398 RenderRegion* currentRegion = regionAtBlockOffset(rootBox->lineTopWithLeadin g() + lineDelta);
5399 // Just bail if the region didn't change.
5400 if (rootBox->containingRegion() == currentRegion)
5401 return false;
5402 return rootBox->paginatedLineWidth() != availableLogicalWidthForContent(curr entRegion);
5403 }
5404
5405 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const 5307 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const
5406 { 5308 {
5407 LayoutState* layoutState = view()->layoutState(); 5309 LayoutState* layoutState = view()->layoutState();
5408 if (layoutState && !layoutState->isPaginated()) 5310 if (layoutState && !layoutState->isPaginated())
5409 return 0; 5311 return 0;
5410 5312
5411 RenderFlowThread* flowThread = flowThreadContainingBlock(); 5313 RenderFlowThread* flowThread = flowThreadContainingBlock();
5412 if (flowThread) 5314 if (flowThread)
5413 return flowThread->offsetFromLogicalTopOfFirstRegion(this); 5315 return flowThread->offsetFromLogicalTopOfFirstRegion(this);
5414 5316
(...skipping 10 matching lines...) Expand all
5425 5327
5426 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const 5328 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const
5427 { 5329 {
5428 RenderFlowThread* flowThread = flowThreadContainingBlock(); 5330 RenderFlowThread* flowThread = flowThreadContainingBlock();
5429 if (!flowThread || !flowThread->hasValidRegionInfo()) 5331 if (!flowThread || !flowThread->hasValidRegionInfo())
5430 return 0; 5332 return 0;
5431 5333
5432 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b lockOffset, true); 5334 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b lockOffset, true);
5433 } 5335 }
5434 5336
5435 bool RenderBlock::logicalWidthChangedInRegions(RenderFlowThread* flowThread) con st
5436 {
5437 if (!flowThread || !flowThread->hasValidRegionInfo())
5438 return false;
5439
5440 return flowThread->logicalWidthChangedInRegionsForBlock(this);
5441 }
5442
5443 RenderRegion* RenderBlock::clampToStartAndEndRegions(RenderRegion* region) const
5444 {
5445 RenderFlowThread* flowThread = flowThreadContainingBlock();
5446
5447 ASSERT(isRenderView() || (region && flowThread));
5448 if (isRenderView())
5449 return region;
5450
5451 // We need to clamp to the block, since we want any lines or blocks that ove rflow out of the
5452 // logical top or logical bottom of the block to size as though the border b ox in the first and
5453 // last regions extended infinitely. Otherwise the lines are going to size a ccording to the regions
5454 // they overflow into, which makes no sense when this block doesn't exist in |region| at all.
5455 RenderRegion* startRegion;
5456 RenderRegion* endRegion;
5457 flowThread->getRegionRangeForBox(this, startRegion, endRegion);
5458
5459 if (startRegion && region->logicalTopForFlowThreadContent() < startRegion->l ogicalTopForFlowThreadContent())
5460 return startRegion;
5461 if (endRegion && region->logicalTopForFlowThreadContent() > endRegion->logic alTopForFlowThreadContent())
5462 return endRegion;
5463
5464 return region;
5465 }
5466
5467 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst 5337 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co nst
5468 { 5338 {
5469 // If the child has the same directionality as we do, then we can just retur n its 5339 // If the child has the same directionality as we do, then we can just retur n its
5470 // collapsed margin. 5340 // collapsed margin.
5471 if (!child->isWritingModeRoot()) 5341 if (!child->isWritingModeRoot())
5472 return child->collapsedMarginBefore(); 5342 return child->collapsedMarginBefore();
5473 5343
5474 // The child has a different directionality. If the child is parallel, then it's just 5344 // The child has a different directionality. If the child is parallel, then it's just
5475 // flipped relative to us. We can use the collapsed margin for the opposite edge. 5345 // flipped relative to us. We can use the collapsed margin for the opposite edge.
5476 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) 5346 if (child->isHorizontalWritingMode() == isHorizontalWritingMode())
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5619 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 5489 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
5620 { 5490 {
5621 showRenderObject(); 5491 showRenderObject();
5622 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 5492 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
5623 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 5493 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
5624 } 5494 }
5625 5495
5626 #endif 5496 #endif
5627 5497
5628 } // namespace WebCore 5498 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698