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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 } | 2838 } |
2850 | 2839 |
2851 LayoutUnit RenderBlock::textIndentOffset() const | 2840 LayoutUnit RenderBlock::textIndentOffset() const |
2852 { | 2841 { |
2853 LayoutUnit cw = 0; | 2842 LayoutUnit cw = 0; |
2854 if (style()->textIndent().isPercent()) | 2843 if (style()->textIndent().isPercent()) |
2855 cw = containingBlock()->availableLogicalWidth(); | 2844 cw = containingBlock()->availableLogicalWidth(); |
2856 return minimumValueForLength(style()->textIndent(), cw); | 2845 return minimumValueForLength(style()->textIndent(), cw); |
2857 } | 2846 } |
2858 | 2847 |
2859 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const | |
2860 { | |
2861 LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLe
ft() + paddingLeft() : borderTop() + paddingTop(); | |
2862 if (!region) | |
2863 return logicalLeftOffset; | |
2864 LayoutRect boxRect = borderBoxRectInRegion(region); | |
2865 return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRec
t.y()); | |
2866 } | |
2867 | |
2868 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region) const | |
2869 { | |
2870 LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderL
eft() + paddingLeft() : borderTop() + paddingTop(); | |
2871 logicalRightOffset += availableLogicalWidth(); | |
2872 if (!region) | |
2873 return logicalRightOffset; | |
2874 LayoutRect boxRect = borderBoxRectInRegion(region); | |
2875 return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? b
oxRect.maxX() : boxRect.maxY())); | |
2876 } | |
2877 | |
2878 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l
ogicalBottom, RootInlineBox* highest) | 2848 void RenderBlock::markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit l
ogicalBottom, RootInlineBox* highest) |
2879 { | 2849 { |
2880 if (logicalTop >= logicalBottom) | 2850 if (logicalTop >= logicalBottom) |
2881 return; | 2851 return; |
2882 | 2852 |
2883 RootInlineBox* lowestDirtyLine = lastRootBox(); | 2853 RootInlineBox* lowestDirtyLine = lastRootBox(); |
2884 RootInlineBox* afterLowest = lowestDirtyLine; | 2854 RootInlineBox* afterLowest = lowestDirtyLine; |
2885 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica
lBottom && logicalBottom < LayoutUnit::max()) { | 2855 while (lowestDirtyLine && lowestDirtyLine->lineBottomWithLeading() >= logica
lBottom && logicalBottom < LayoutUnit::max()) { |
2886 afterLowest = lowestDirtyLine; | 2856 afterLowest = lowestDirtyLine; |
2887 lowestDirtyLine = lowestDirtyLine->prevRootBox(); | 2857 lowestDirtyLine = lowestDirtyLine->prevRootBox(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 && isPointInOverflowControl(result, locationInContainer.point(), adjuste
dLocation)) { | 2920 && isPointInOverflowControl(result, locationInContainer.point(), adjuste
dLocation)) { |
2951 updateHitTestResult(result, locationInContainer.point() - localOffset); | 2921 updateHitTestResult(result, locationInContainer.point() - localOffset); |
2952 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet
. | 2922 // FIXME: isPointInOverflowControl() doesn't handle rect-based tests yet
. |
2953 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca
tionInContainer)) | 2923 if (!result.addNodeToRectBasedTestResult(nodeForHitTest(), request, loca
tionInContainer)) |
2954 return true; | 2924 return true; |
2955 } | 2925 } |
2956 | 2926 |
2957 // If we have clipping, then we can't have any spillout. | 2927 // If we have clipping, then we can't have any spillout. |
2958 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer(); | 2928 bool useOverflowClip = hasOverflowClip() && !hasSelfPaintingLayer(); |
2959 bool useClip = (hasControlClip() || useOverflowClip); | 2929 bool useClip = (hasControlClip() || useOverflowClip); |
2960 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int
ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over
flowClipRect(adjustedLocation, locationInContainer.region(), IncludeOverlayScrol
lbarSize))); | 2930 bool checkChildren = !useClip || (hasControlClip() ? locationInContainer.int
ersects(controlClipRect(adjustedLocation)) : locationInContainer.intersects(over
flowClipRect(adjustedLocation, IncludeOverlayScrollbarSize))); |
2961 if (checkChildren) { | 2931 if (checkChildren) { |
2962 // Hit test descendants first. | 2932 // Hit test descendants first. |
2963 LayoutSize scrolledOffset(localOffset); | 2933 LayoutSize scrolledOffset(localOffset); |
2964 if (hasOverflowClip()) | 2934 if (hasOverflowClip()) |
2965 scrolledOffset -= scrolledContentOffset(); | 2935 scrolledOffset -= scrolledContentOffset(); |
2966 | 2936 |
2967 // Hit test contents if we don't have columns. | 2937 // Hit test contents if we don't have columns. |
2968 if (!hasColumns()) { | 2938 if (!hasColumns()) { |
2969 if (hitTestContents(request, result, locationInContainer, toLayoutPo
int(scrolledOffset), hitTestAction)) { | 2939 if (hitTestContents(request, result, locationInContainer, toLayoutPo
int(scrolledOffset), hitTestAction)) { |
2970 updateHitTestResult(result, flipForWritingMode(locationInContain
er.point() - localOffset)); | 2940 updateHitTestResult(result, flipForWritingMode(locationInContain
er.point() - localOffset)); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 LayoutRect colRect = it.columnRect(); | 3061 LayoutRect colRect = it.columnRect(); |
3092 if (colRect.contains(locationInContainer)) { | 3062 if (colRect.contains(locationInContainer)) { |
3093 it.adjust(offset); | 3063 it.adjust(offset); |
3094 return; | 3064 return; |
3095 } | 3065 } |
3096 } | 3066 } |
3097 } | 3067 } |
3098 | 3068 |
3099 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult&
result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat
edOffset, HitTestAction hitTestAction) | 3069 bool RenderBlock::hitTestContents(const HitTestRequest& request, HitTestResult&
result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulat
edOffset, HitTestAction hitTestAction) |
3100 { | 3070 { |
3101 if (isRenderRegion()) | |
3102 return toRenderRegion(this)->hitTestFlowThreadContents(request, result,
locationInContainer, accumulatedOffset, hitTestAction); | |
3103 | |
3104 if (childrenInline() && !isTable()) { | 3071 if (childrenInline() && !isTable()) { |
3105 // We have to hit-test our line boxes. | 3072 // We have to hit-test our line boxes. |
3106 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu
mulatedOffset, hitTestAction)) | 3073 if (m_lineBoxes.hitTest(this, request, result, locationInContainer, accu
mulatedOffset, hitTestAction)) |
3107 return true; | 3074 return true; |
3108 } else { | 3075 } else { |
3109 // Hit test our children. | 3076 // Hit test our children. |
3110 HitTestAction childHitTest = hitTestAction; | 3077 HitTestAction childHitTest = hitTestAction; |
3111 if (hitTestAction == HitTestChildBlockBackgrounds) | 3078 if (hitTestAction == HitTestChildBlockBackgrounds) |
3112 childHitTest = HitTestChildBlockBackground; | 3079 childHitTest = HitTestChildBlockBackground; |
3113 for (RenderBox* child = lastChildBox(); child; child = child->previousSi
blingBox()) { | 3080 for (RenderBox* child = lastChildBox(); child; child = child->previousSi
blingBox()) { |
(...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5162 | 5129 |
5163 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par
ent) const | 5130 RenderBox* RenderBlock::createAnonymousBoxWithSameTypeAs(const RenderObject* par
ent) const |
5164 { | 5131 { |
5165 if (isAnonymousColumnsBlock()) | 5132 if (isAnonymousColumnsBlock()) |
5166 return createAnonymousColumnsWithParentRenderer(parent); | 5133 return createAnonymousColumnsWithParentRenderer(parent); |
5167 if (isAnonymousColumnSpanBlock()) | 5134 if (isAnonymousColumnSpanBlock()) |
5168 return createAnonymousColumnSpanWithParentRenderer(parent); | 5135 return createAnonymousColumnSpanWithParentRenderer(parent); |
5169 return createAnonymousWithParentRendererAndDisplay(parent, style()->display(
)); | 5136 return createAnonymousWithParentRendererAndDisplay(parent, style()->display(
)); |
5170 } | 5137 } |
5171 | 5138 |
5172 bool RenderBlock::hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule pageBou
ndaryRule) const | |
5173 { | |
5174 ASSERT(view()->layoutState() && view()->layoutState()->isPaginated()); | |
5175 | |
5176 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
5177 if (!flowThread) | |
5178 return true; // Printing and multi-column both make new pages to accommo
date content. | |
5179 | |
5180 // See if we're in the last region. | |
5181 LayoutUnit pageOffset = offsetFromLogicalTopOfFirstPage() + logicalOffset; | |
5182 RenderRegion* region = flowThread->regionAtBlockOffset(pageOffset, this); | |
5183 if (!region) | |
5184 return false; | |
5185 if (region->isLastRegion()) | |
5186 return region->isRenderRegionSet() || region->style()->regionFragment()
== BreakRegionFragment | |
5187 || (pageBoundaryRule == IncludePageBoundary && pageOffset == region-
>logicalTopForFlowThreadContent()); | |
5188 return true; | |
5189 } | |
5190 | |
5191 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar
yRule pageBoundaryRule) const | 5139 LayoutUnit RenderBlock::nextPageLogicalTop(LayoutUnit logicalOffset, PageBoundar
yRule pageBoundaryRule) const |
5192 { | 5140 { |
5193 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 5141 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
5194 if (!pageLogicalHeight) | 5142 if (!pageLogicalHeight) |
5195 return logicalOffset; | 5143 return logicalOffset; |
5196 | 5144 |
5197 // The logicalOffset is in our coordinate space. We can add in our pushed o
ffset. | 5145 // The logicalOffset is in our coordinate space. We can add in our pushed o
ffset. |
5198 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset); | 5146 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset); |
5199 if (pageBoundaryRule == ExcludePageBoundary) | 5147 if (pageBoundaryRule == ExcludePageBoundary) |
5200 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight
: pageLogicalHeight); | 5148 return logicalOffset + (remainingLogicalHeight ? remainingLogicalHeight
: pageLogicalHeight); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5249 return remainingHeight; | 5197 return remainingHeight; |
5250 } | 5198 } |
5251 | 5199 |
5252 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); | 5200 return flowThread->pageRemainingLogicalHeightForOffset(offset, pageBoundaryR
ule); |
5253 } | 5201 } |
5254 | 5202 |
5255 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit
logicalOffset, bool includeMargins) | 5203 LayoutUnit RenderBlock::adjustForUnsplittableChild(RenderBox* child, LayoutUnit
logicalOffset, bool includeMargins) |
5256 { | 5204 { |
5257 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); | 5205 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); |
5258 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; | 5206 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; |
5259 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
5260 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread()
; | |
5261 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) | 5207 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr
eaks && child->style()->columnBreakInside() == PBAVOID) |
5262 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID) | 5208 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); |
5263 || (checkRegionBreaks && child->style()->regionBreakInside() == PBAVOID)
; | |
5264 if (!isUnsplittable) | 5209 if (!isUnsplittable) |
5265 return logicalOffset; | 5210 return logicalOffset; |
5266 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); | 5211 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi
ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); |
5267 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 5212 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
5268 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni
formLogicalHeight(); | |
5269 updateMinimumPageHeight(logicalOffset, childLogicalHeight); | 5213 updateMinimumPageHeight(logicalOffset, childLogicalHeight); |
5270 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && childLogicalHeight
> pageLogicalHeight) | 5214 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) |
5271 || !hasNextPage(logicalOffset)) | |
5272 return logicalOffset; | 5215 return logicalOffset; |
5273 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); | 5216 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); |
5274 if (remainingLogicalHeight < childLogicalHeight) { | 5217 if (remainingLogicalHeight < childLogicalHeight) |
5275 if (!hasUniformPageLogicalHeight && !pushToNextPageWithMinimumLogicalHei
ght(remainingLogicalHeight, logicalOffset, childLogicalHeight)) | |
5276 return logicalOffset; | |
5277 return logicalOffset + remainingLogicalHeight; | 5218 return logicalOffset + remainingLogicalHeight; |
5278 } | |
5279 return logicalOffset; | 5219 return logicalOffset; |
5280 } | 5220 } |
5281 | 5221 |
5282 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment,
LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const | 5222 bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment,
LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const |
5283 { | 5223 { |
5284 bool checkRegion = false; | 5224 // FIXME: multicol will need to do some work here, when we implement support
for multiple rows. |
5285 for (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset
+ adjustment); pageLogicalHeight; | 5225 return false; |
5286 pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustmen
t)) { | |
5287 if (minimumLogicalHeight <= pageLogicalHeight) | |
5288 return true; | |
5289 if (!hasNextPage(logicalOffset + adjustment)) | |
5290 return false; | |
5291 adjustment += pageLogicalHeight; | |
5292 checkRegion = true; | |
5293 } | |
5294 return !checkRegion; | |
5295 } | 5226 } |
5296 | 5227 |
5297 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) | 5228 void RenderBlock::setPageBreak(LayoutUnit offset, LayoutUnit spaceShortage) |
5298 { | 5229 { |
5299 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) | 5230 if (RenderFlowThread* flowThread = flowThreadContainingBlock()) |
5300 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa
ceShortage); | 5231 flowThread->setPageBreak(offsetFromLogicalTopOfFirstPage() + offset, spa
ceShortage); |
5301 } | 5232 } |
5302 | 5233 |
5303 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh
t) | 5234 void RenderBlock::updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeigh
t) |
5304 { | 5235 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5352 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu
alOverflow.maxY()); | 5283 LayoutUnit logicalBottom = max(lineBox->lineBottomWithLeading(), logicalVisu
alOverflow.maxY()); |
5353 LayoutUnit lineHeight = logicalBottom - logicalOffset; | 5284 LayoutUnit lineHeight = logicalBottom - logicalOffset; |
5354 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l
ineBox, logicalOffset, logicalBottom)); | 5285 updateMinimumPageHeight(logicalOffset, calculateMinimumPageHeight(style(), l
ineBox, logicalOffset, logicalBottom)); |
5355 logicalOffset += delta; | 5286 logicalOffset += delta; |
5356 lineBox->setPaginationStrut(0); | 5287 lineBox->setPaginationStrut(0); |
5357 lineBox->setIsFirstAfterPageBreak(false); | 5288 lineBox->setIsFirstAfterPageBreak(false); |
5358 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); | 5289 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); |
5359 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni
formLogicalHeight(); | 5290 bool hasUniformPageLogicalHeight = !flowThread || flowThread->regionsHaveUni
formLogicalHeight(); |
5360 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo
w.height() still fits, we are | 5291 // If lineHeight is greater than pageLogicalHeight, but logicalVisualOverflo
w.height() still fits, we are |
5361 // still going to add a strut, so that the visible overflow fits on a single
page. | 5292 // still going to add a strut, so that the visible overflow fits on a single
page. |
5362 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf
low.height() > pageLogicalHeight) | 5293 if (!pageLogicalHeight || (hasUniformPageLogicalHeight && logicalVisualOverf
low.height() > pageLogicalHeight)) |
5363 || !hasNextPage(logicalOffset)) | |
5364 // 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. | 5294 // 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. |
5365 // 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. | 5295 // 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. |
5366 return; | 5296 return; |
5367 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); | 5297 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi
calOffset, ExcludePageBoundary); |
5368 | 5298 |
5369 int lineIndex = lineCount(lineBox); | 5299 int lineIndex = lineCount(lineBox); |
5370 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { | 5300 if (remainingLogicalHeight < lineHeight || (shouldBreakAtLineToAvoidWidow()
&& lineBreakToAvoidWidow() == lineIndex)) { |
5371 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { | 5301 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { |
5372 clearShouldBreakAtLineToAvoidWidow(); | 5302 clearShouldBreakAtLineToAvoidWidow(); |
5373 setDidBreakAtLineToAvoidWidow(); | 5303 setDidBreakAtLineToAvoidWidow(); |
(...skipping 18 matching lines...) Expand all Loading... |
5392 } | 5322 } |
5393 } else if (remainingLogicalHeight == pageLogicalHeight) { | 5323 } else if (remainingLogicalHeight == pageLogicalHeight) { |
5394 // We're at the very top of a page or column. | 5324 // We're at the very top of a page or column. |
5395 if (lineBox != firstRootBox()) | 5325 if (lineBox != firstRootBox()) |
5396 lineBox->setIsFirstAfterPageBreak(true); | 5326 lineBox->setIsFirstAfterPageBreak(true); |
5397 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) | 5327 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) |
5398 setPageBreak(logicalOffset, lineHeight); | 5328 setPageBreak(logicalOffset, lineHeight); |
5399 } | 5329 } |
5400 } | 5330 } |
5401 | 5331 |
5402 void RenderBlock::updateRegionForLine(RootInlineBox* lineBox) const | |
5403 { | |
5404 ASSERT(lineBox); | |
5405 lineBox->setContainingRegion(regionAtBlockOffset(lineBox->lineTopWithLeading
())); | |
5406 | |
5407 RootInlineBox* prevLineBox = lineBox->prevRootBox(); | |
5408 if (!prevLineBox) | |
5409 return; | |
5410 | |
5411 // This check is more accurate than the one in |adjustLinePositionForPaginat
ion| because it takes into | |
5412 // account just the container changes between lines. The before mentioned fu
nction doesn't set the flag | |
5413 // correctly if the line is positioned at the top of the last fragment conta
iner. | |
5414 if (lineBox->containingRegion() != prevLineBox->containingRegion()) | |
5415 lineBox->setIsFirstAfterPageBreak(true); | |
5416 } | |
5417 | |
5418 bool RenderBlock::lineWidthForPaginatedLineChanged(RootInlineBox* rootBox, Layou
tUnit lineDelta, RenderFlowThread* flowThread) const | |
5419 { | |
5420 if (!flowThread) | |
5421 return false; | |
5422 | |
5423 RenderRegion* currentRegion = regionAtBlockOffset(rootBox->lineTopWithLeadin
g() + lineDelta); | |
5424 // Just bail if the region didn't change. | |
5425 if (rootBox->containingRegion() == currentRegion) | |
5426 return false; | |
5427 return rootBox->paginatedLineWidth() != availableLogicalWidthForContent(curr
entRegion); | |
5428 } | |
5429 | |
5430 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const | 5332 LayoutUnit RenderBlock::offsetFromLogicalTopOfFirstPage() const |
5431 { | 5333 { |
5432 LayoutState* layoutState = view()->layoutState(); | 5334 LayoutState* layoutState = view()->layoutState(); |
5433 if (layoutState && !layoutState->isPaginated()) | 5335 if (layoutState && !layoutState->isPaginated()) |
5434 return 0; | 5336 return 0; |
5435 | 5337 |
5436 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 5338 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
5437 if (flowThread) | 5339 if (flowThread) |
5438 return flowThread->offsetFromLogicalTopOfFirstRegion(this); | 5340 return flowThread->offsetFromLogicalTopOfFirstRegion(this); |
5439 | 5341 |
(...skipping 10 matching lines...) Expand all Loading... |
5450 | 5352 |
5451 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const | 5353 RenderRegion* RenderBlock::regionAtBlockOffset(LayoutUnit blockOffset) const |
5452 { | 5354 { |
5453 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 5355 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
5454 if (!flowThread || !flowThread->hasValidRegionInfo()) | 5356 if (!flowThread || !flowThread->hasValidRegionInfo()) |
5455 return 0; | 5357 return 0; |
5456 | 5358 |
5457 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b
lockOffset, true); | 5359 return flowThread->regionAtBlockOffset(offsetFromLogicalTopOfFirstPage() + b
lockOffset, true); |
5458 } | 5360 } |
5459 | 5361 |
5460 bool RenderBlock::logicalWidthChangedInRegions(RenderFlowThread* flowThread) con
st | |
5461 { | |
5462 if (!flowThread || !flowThread->hasValidRegionInfo()) | |
5463 return false; | |
5464 | |
5465 return flowThread->logicalWidthChangedInRegionsForBlock(this); | |
5466 } | |
5467 | |
5468 RenderRegion* RenderBlock::clampToStartAndEndRegions(RenderRegion* region) const | |
5469 { | |
5470 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
5471 | |
5472 ASSERT(isRenderView() || (region && flowThread)); | |
5473 if (isRenderView()) | |
5474 return region; | |
5475 | |
5476 // We need to clamp to the block, since we want any lines or blocks that ove
rflow out of the | |
5477 // logical top or logical bottom of the block to size as though the border b
ox in the first and | |
5478 // last regions extended infinitely. Otherwise the lines are going to size a
ccording to the regions | |
5479 // they overflow into, which makes no sense when this block doesn't exist in
|region| at all. | |
5480 RenderRegion* startRegion; | |
5481 RenderRegion* endRegion; | |
5482 flowThread->getRegionRangeForBox(this, startRegion, endRegion); | |
5483 | |
5484 if (startRegion && region->logicalTopForFlowThreadContent() < startRegion->l
ogicalTopForFlowThreadContent()) | |
5485 return startRegion; | |
5486 if (endRegion && region->logicalTopForFlowThreadContent() > endRegion->logic
alTopForFlowThreadContent()) | |
5487 return endRegion; | |
5488 | |
5489 return region; | |
5490 } | |
5491 | |
5492 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co
nst | 5362 LayoutUnit RenderBlock::collapsedMarginBeforeForChild(const RenderBox* child) co
nst |
5493 { | 5363 { |
5494 // If the child has the same directionality as we do, then we can just retur
n its | 5364 // If the child has the same directionality as we do, then we can just retur
n its |
5495 // collapsed margin. | 5365 // collapsed margin. |
5496 if (!child->isWritingModeRoot()) | 5366 if (!child->isWritingModeRoot()) |
5497 return child->collapsedMarginBefore(); | 5367 return child->collapsedMarginBefore(); |
5498 | 5368 |
5499 // The child has a different directionality. If the child is parallel, then
it's just | 5369 // The child has a different directionality. If the child is parallel, then
it's just |
5500 // flipped relative to us. We can use the collapsed margin for the opposite
edge. | 5370 // flipped relative to us. We can use the collapsed margin for the opposite
edge. |
5501 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) | 5371 if (child->isHorizontalWritingMode() == isHorizontalWritingMode()) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5644 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 5514 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
5645 { | 5515 { |
5646 showRenderObject(); | 5516 showRenderObject(); |
5647 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 5517 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
5648 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 5518 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
5649 } | 5519 } |
5650 | 5520 |
5651 #endif | 5521 #endif |
5652 | 5522 |
5653 } // namespace WebCore | 5523 } // namespace WebCore |
OLD | NEW |