Changeset 99024 in webkit
- Timestamp:
- Nov 1, 2011 6:33:15 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99022 r99024 1 2011-11-01 Levi Weintraub <leviw@chromium.org> 2 3 Amend missing uses of LayoutUnit in RenderBlock 4 https://bugs.webkit.org/show_bug.cgi?id=71254 5 6 Reviewed by Darin Adler. 7 8 Switching relevant uses of integers in RenderBlock to LayoutUnits. 9 10 No new tests -- no changes in behavior. 11 12 * rendering/RenderBlock.cpp: 13 (WebCore::RenderBlock::MarginInfo::MarginInfo): 14 (WebCore::RenderBlock::layoutBlock): 15 (WebCore::RenderBlock::adjustFloatingBlock): 16 (WebCore::RenderBlock::clearFloatsIfNeeded): 17 (WebCore::RenderBlock::layoutBlockChild): 18 (WebCore::RenderBlock::paintColumnRules): 19 (WebCore::RenderBlock::paintContents): 20 (WebCore::clipOutPositionedObjects): 21 (WebCore::RenderBlock::removeFloatingObject): 22 (WebCore::RenderBlock::nextFloatLogicalBottomBelow): 23 (WebCore::RenderBlock::getClearDelta): 24 (WebCore::positionForPointRespectingEditingBoundaries): 25 (WebCore::RenderBlock::calcColumnWidth): 26 (WebCore::RenderBlock::layoutColumns): 27 (WebCore::RenderBlock::adjustRectForColumns): 28 (WebCore::RenderBlock::computeInlinePreferredLogicalWidths): 29 (WebCore::RenderBlock::baselinePosition): 30 (WebCore::getHeightForLineCount): 31 (WebCore::RenderBlock::setPaginationStrut): 32 (WebCore::RenderBlock::applyBeforeBreak): 33 (WebCore::RenderBlock::applyAfterBreak): 34 (WebCore::RenderBlock::adjustForUnsplittableChild): 35 * rendering/RenderBlock.h: 36 (WebCore::RenderBlock::availableLogicalWidthForLine): 37 (WebCore::RenderBlock::paginationStrut): 38 (WebCore::RenderBlock::availableLogicalWidthForContent): 39 (WebCore::RenderBlock::FloatWithRect::FloatWithRect): 40 (WebCore::RenderBlock::MarginInfo::setPositiveMargin): 41 (WebCore::RenderBlock::MarginInfo::setNegativeMargin): 42 (WebCore::RenderBlock::MarginInfo::setPositiveMarginIfLarger): 43 (WebCore::RenderBlock::MarginInfo::setNegativeMarginIfLarger): 44 (WebCore::RenderBlock::MarginInfo::setMargin): 45 (WebCore::RenderBlock::FloatIntervalSearchAdapter::FloatIntervalSearchAdapter): 46 (WebCore::RenderBlock::FloatIntervalSearchAdapter::lowValue): 47 (WebCore::RenderBlock::FloatIntervalSearchAdapter::highValue): 48 (WebCore::RenderBlock::RenderBlockRareData::positiveMarginBeforeDefault): 49 (WebCore::RenderBlock::RenderBlockRareData::negativeMarginBeforeDefault): 50 (WebCore::RenderBlock::RenderBlockRareData::positiveMarginAfterDefault): 51 (WebCore::RenderBlock::RenderBlockRareData::negativeMarginAfterDefault): 52 1 53 2011-11-01 Luke Macpherson <macpherson@chromium.org> 2 54 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r98763 r99024 1242 1242 LayoutUnit oldHeight = logicalHeight(); 1243 1243 LayoutUnit oldLogicalTop = logicalTop(); 1244 setLogicalHeight( INT_MAX/ 2);1244 setLogicalHeight(numeric_limits<LayoutUnit>::max() / 2); 1245 1245 computeLogicalHeight(); 1246 1246 enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage()); … … 1725 1725 } 1726 1726 1727 LayoutUnit RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& marginInfo, int oldTopPosMargin, int oldTopNegMargin, int yPos)1727 LayoutUnit RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& marginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos) 1728 1728 { 1729 1729 LayoutUnit heightIncrease = getClearDelta(child, yPos); … … 2136 2136 } 2137 2137 2138 // FIXME: Change to use roughlyEquals when we move to float.2139 // See https://bugs.webkit.org/show_bug.cgi?id=661482140 2138 ASSERT(oldLayoutDelta == view()->layoutDelta()); 2141 2139 } … … 2389 2387 ColumnInfo* colInfo = columnInfo(); 2390 2388 unsigned colCount = columnCount(colInfo); 2389 2391 2390 bool antialias = shouldAntialiasLines(paintInfo.context); 2392 2391 … … 2502 2501 return; 2503 2502 2503 // We don't want to hand off painting in the line box tree with the accumulated error of the render tree, as this will cause 2504 // us to mess up painting aligned things (such as underlines in text) with both the render tree and line box tree's error. 2505 LayoutPoint roundedPaintOffset = roundedIntPoint(paintOffset); 2504 2506 if (childrenInline()) 2505 m_lineBoxes.paint(this, paintInfo, paintOffset);2507 m_lineBoxes.paint(this, paintInfo, roundedPaintOffset); 2506 2508 else 2507 paintChildren(paintInfo, paintOffset);2509 paintChildren(paintInfo, roundedPaintOffset); 2508 2510 } 2509 2511 … … 2895 2897 for (RenderBlock::PositionedObjectsListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { 2896 2898 RenderBox* r = *it; 2897 paintInfo->context->clipOut( LayoutRect(offset.x() + r->x(), offset.y() + r->y(), r->width(), r->height()));2899 paintInfo->context->clipOut(IntRect(offset.x() + r->x(), offset.y() + r->y(), r->width(), r->height())); 2898 2900 } 2899 2901 } … … 3297 3299 FloatingObject* r = *it; 3298 3300 if (childrenInline()) { 3299 int logicalTop = logicalTopForFloat(r);3300 int logicalBottom = logicalBottomForFloat(r);3301 LayoutUnit logicalTop = logicalTopForFloat(r); 3302 LayoutUnit logicalBottom = logicalBottomForFloat(r); 3301 3303 3302 3304 // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. 3303 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTop == numeric_limits< int>::max())3304 logicalBottom = numeric_limits< int>::max();3305 if (logicalBottom < 0 || logicalBottom < logicalTop || logicalTop == numeric_limits<LayoutUnit>::max()) 3306 logicalBottom = numeric_limits<LayoutUnit>::max(); 3305 3307 else { 3306 3308 // Special-case zero- and less-than-zero-height floats: those don't touch … … 3691 3693 } 3692 3694 3693 return bottom == numeric_limits<LayoutUnit>::max() ? logicalHeight: bottom;3695 return bottom == numeric_limits<LayoutUnit>::max() ? 0 : bottom; 3694 3696 } 3695 3697 … … 4313 4315 childLocation += child->relativePositionOffset(); 4314 4316 // FIXME: This is wrong if the child's writing-mode is different from the parent's. 4315 LayoutPoint pointInChildCoordinates( pointInParentCoordinates - childLocation);4317 LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates - childLocation)); 4316 4318 4317 4319 // If this is an anonymous renderer, we just recur normally … … 4477 4479 { 4478 4480 // Calculate our column width and column count. 4481 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744 4479 4482 unsigned desiredColumnCount = 1; 4480 int desiredColumnWidth = contentLogicalWidth();4483 LayoutUnit desiredColumnWidth = contentLogicalWidth(); 4481 4484 4482 4485 // For now, we don't support multi-column layouts when printing, since we have to do a lot of work for proper pagination. … … 4486 4489 } 4487 4490 4488 int availWidth = desiredColumnWidth;4489 int colGap = columnGap();4490 int colWidth = max(1, static_cast<int>(style()->columnWidth()));4491 int colCount = max (1, static_cast<int>(style()->columnCount()));4491 LayoutUnit availWidth = desiredColumnWidth; 4492 LayoutUnit colGap = columnGap(); 4493 LayoutUnit colWidth = max<LayoutUnit>(1, LayoutUnit(style()->columnWidth())); 4494 int colCount = max<int>(1, style()->columnCount()); 4492 4495 4493 4496 if (style()->hasAutoColumnWidth() && !style()->hasAutoColumnCount()) { 4494 4497 desiredColumnCount = colCount; 4495 desiredColumnWidth = max< int>(0, (availWidth - ((desiredColumnCount - 1) * colGap)) / desiredColumnCount);4498 desiredColumnWidth = max<LayoutUnit>(0, (availWidth - ((desiredColumnCount - 1) * colGap)) / desiredColumnCount); 4496 4499 } else if (!style()->hasAutoColumnWidth() && style()->hasAutoColumnCount()) { 4497 desiredColumnCount = max< int>(1, (float)(availWidth + colGap) / (colWidth + colGap));4500 desiredColumnCount = max<LayoutUnit>(1, (availWidth + colGap) / (colWidth + colGap)); 4498 4501 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colGap; 4499 4502 } else { 4500 desiredColumnCount = max (min<int>(colCount, (float)(availWidth + colGap) / (colWidth + colGap)), 1);4503 desiredColumnCount = max<LayoutUnit>(min<LayoutUnit>(colCount, (availWidth + colGap) / (colWidth + colGap)), 1); 4501 4504 desiredColumnWidth = ((availWidth + colGap) / desiredColumnCount) - colGap; 4502 4505 } … … 4583 4586 } 4584 4587 4585 bool RenderBlock::layoutColumns(bool hasSpecifiedPageLogicalHeight, int pageLogicalHeight, LayoutStateMaintainer& statePusher)4588 bool RenderBlock::layoutColumns(bool hasSpecifiedPageLogicalHeight, LayoutUnit pageLogicalHeight, LayoutStateMaintainer& statePusher) 4586 4589 { 4587 4590 if (!hasColumns()) … … 4599 4602 // maximum page break distance. 4600 4603 if (!pageLogicalHeight) { 4601 LayoutUnit distanceBetweenBreaks = max (colInfo->maximumDistanceBetweenForcedBreaks(),4602 view()->layoutState()->pageLogicalOffset(borderBefore() + paddingBefore() + contentLogicalHeight()) - colInfo->forcedBreakOffset());4604 LayoutUnit distanceBetweenBreaks = max<LayoutUnit>(colInfo->maximumDistanceBetweenForcedBreaks(), 4605 view()->layoutState()->pageLogicalOffset(borderBefore() + paddingBefore() + contentLogicalHeight()) - colInfo->forcedBreakOffset()); 4603 4606 columnHeight = max(colInfo->minimumColumnHeight(), distanceBetweenBreaks); 4604 4607 } 4605 4608 } else if (contentLogicalHeight() > pageLogicalHeight * desiredColumnCount) { 4606 4609 // Now that we know the intrinsic height of the columns, we have to rebalance them. 4607 columnHeight = max (colInfo->minimumColumnHeight(), ceiledLayoutUnit((float)contentLogicalHeight() / desiredColumnCount));4610 columnHeight = max<LayoutUnit>(colInfo->minimumColumnHeight(), ceilf((float)contentLogicalHeight() / desiredColumnCount)); 4608 4611 } 4609 4612 … … 4724 4727 LayoutUnit startOffset = max(isHorizontal ? r.y() : r.x(), beforeBorderPadding); 4725 4728 LayoutUnit endOffset = min<LayoutUnit>(isHorizontal ? r.maxY() : r.maxX(), beforeBorderPadding + colCount * colHeight); 4726 4729 4730 // FIXME: Can overflow on fast/block/float/float-not-removed-from-next-sibling4.html, see https://bugs.webkit.org/show_bug.cgi?id=68744 4727 4731 unsigned startColumn = (startOffset - beforeBorderPadding) / colHeight; 4728 4732 unsigned endColumn = (endOffset - beforeBorderPadding) / colHeight; … … 4734 4738 LayoutRect colRect = columnRectAt(colInfo, startColumn); 4735 4739 LayoutRect repaintRect = r; 4740 4736 4741 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) { 4737 4742 if (isHorizontal) … … 5438 5443 : (layer()->horizontalScrollbar() || layer()->scrollXOffset() != 0)))) || (isWritingModeRoot() && !isRubyRun()); 5439 5444 5440 int baselinePos = ignoreBaseline ? -1: lastLineBoxBaseline();5445 int baselinePos = ignoreBaseline ? LayoutUnit(-1) : lastLineBoxBaseline(); 5441 5446 5442 5447 int bottomOfContent = direction == HorizontalLine ? borderTop() + paddingTop() + contentHeight() : borderRight() + paddingRight() + contentWidth(); … … 5954 5959 } 5955 5960 5956 void RenderBlock::setPaginationStrut( int strut)5961 void RenderBlock::setPaginationStrut(LayoutUnit strut) 5957 5962 { 5958 5963 if (!m_rareData) { … … 6285 6290 } 6286 6291 6287 int RenderBlock::applyBeforeBreak(RenderBox* child, int logicalOffset)6292 LayoutUnit RenderBlock::applyBeforeBreak(RenderBox* child, LayoutUnit logicalOffset) 6288 6293 { 6289 6294 // FIXME: Add page break checking here when we support printing. … … 6301 6306 } 6302 6307 6303 int RenderBlock::applyAfterBreak(RenderBox* child, int logicalOffset, MarginInfo& marginInfo)6308 LayoutUnit RenderBlock::applyAfterBreak(RenderBox* child, LayoutUnit logicalOffset, MarginInfo& marginInfo) 6304 6309 { 6305 6310 // FIXME: Add page break checking here when we support printing. -
trunk/Source/WebCore/rendering/RenderBlock.h
r97282 r99024 130 130 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool firstLine, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const 131 131 { 132 return max (0, logicalRightOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage)132 return max<LayoutUnit>(0, logicalRightOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage) 133 133 - logicalLeftOffsetForLine(position, firstLine, region, offsetFromLogicalTopOfFirstPage)); 134 134 } … … 231 231 LayoutRect columnRectAt(ColumnInfo*, unsigned) const; 232 232 233 int paginationStrut() const { return m_rareData ? m_rareData->m_paginationStrut : 0; }234 void setPaginationStrut( int);233 LayoutUnit paginationStrut() const { return m_rareData ? m_rareData->m_paginationStrut : 0; } 234 void setPaginationStrut(LayoutUnit); 235 235 236 236 // The page logical offset is the object's offset from the top of the page in the page progression … … 297 297 LayoutUnit availableLogicalWidthForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const 298 298 { 299 return max (0, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage) -299 return max<LayoutUnit>(0, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage) - 300 300 logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage)); } 301 301 LayoutUnit startOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const … … 477 477 FloatWithRect(RenderBox* f) 478 478 : object(f) 479 , rect( IntRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom()))479 , rect(LayoutRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom())) 480 480 , everHadLayout(f->m_everHadLayout) 481 481 { … … 483 483 484 484 RenderBox* object; 485 IntRect rect;485 LayoutRect rect; 486 486 bool everHadLayout; 487 487 }; … … 575 575 LayoutUnit logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); } 576 576 LayoutUnit logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); } 577 577 578 void setLogicalTopForFloat(FloatingObject* child, LayoutUnit logicalTop) 578 579 { … … 770 771 771 772 void calcColumnWidth(); 772 bool layoutColumns(bool hasSpecifiedPageLogicalHeight, int pageLogicalHeight, LayoutStateMaintainer&);773 bool layoutColumns(bool hasSpecifiedPageLogicalHeight, LayoutUnit pageLogicalHeight, LayoutStateMaintainer&); 773 774 void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild); 774 775 … … 826 827 void setMarginAfterQuirk(bool b) { m_marginAfterQuirk = b; } 827 828 void setDeterminedMarginBeforeQuirk(bool b) { m_determinedMarginBeforeQuirk = b; } 828 void setPositiveMargin(int p) { m_positiveMargin = p; } 829 void setNegativeMargin(int n) { m_negativeMargin = n; } 830 void setPositiveMarginIfLarger(int p) { if (p > m_positiveMargin) m_positiveMargin = p; } 831 void setNegativeMarginIfLarger(int n) { if (n > m_negativeMargin) m_negativeMargin = n; } 832 833 void setMargin(int p, int n) { m_positiveMargin = p; m_negativeMargin = n; } 829 void setPositiveMargin(LayoutUnit p) { m_positiveMargin = p; } 830 void setNegativeMargin(LayoutUnit n) { m_negativeMargin = n; } 831 void setPositiveMarginIfLarger(LayoutUnit p) 832 { 833 if (p > m_positiveMargin) 834 m_positiveMargin = p; 835 } 836 void setNegativeMarginIfLarger(LayoutUnit n) 837 { 838 if (n > m_negativeMargin) 839 m_negativeMargin = n; 840 } 841 842 void setMargin(LayoutUnit p, LayoutUnit n) { m_positiveMargin = p; m_negativeMargin = n; } 834 843 835 844 bool atBeforeSideOfBlock() const { return m_atBeforeSideOfBlock; } … … 855 864 bool handleRunInChild(RenderBox* child); 856 865 LayoutUnit collapseMargins(RenderBox* child, MarginInfo&); 857 LayoutUnit clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);866 LayoutUnit clearFloatsIfNeeded(RenderBox* child, MarginInfo&, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPos); 858 867 LayoutUnit estimateLogicalTopPosition(RenderBox* child, const MarginInfo&, LayoutUnit& estimateWithoutPagination); 859 868 void determineLogicalLeftPositionForChild(RenderBox* child); … … 881 890 bool hasNextPage(LayoutUnit logicalOffset, PageBoundaryRule = ExcludePageBoundary) const; 882 891 883 int applyBeforeBreak(RenderBox* child, int logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top of the next page/column.884 int applyAfterBreak(RenderBox* child, int logicalOffset, MarginInfo& marginInfo); // If the child has an after break, then return a new offset that shifts to the top of the next page/column.892 LayoutUnit applyBeforeBreak(RenderBox* child, LayoutUnit logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top of the next page/column. 893 LayoutUnit applyAfterBreak(RenderBox* child, LayoutUnit logicalOffset, MarginInfo&); // If the child has an after break, then return a new offset that shifts to the top of the next page/column. 885 894 886 895 LayoutUnit pageLogicalHeightForOffset(LayoutUnit offset) const; … … 916 925 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> FloatingObjectSet; 917 926 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator; 918 typedef PODInterval< LayoutUnit, FloatingObject*> FloatingObjectInterval;919 typedef PODIntervalTree< LayoutUnit, FloatingObject*> FloatingObjectTree;927 typedef PODInterval<int, FloatingObject*> FloatingObjectInterval; 928 typedef PODIntervalTree<int, FloatingObject*> FloatingObjectTree; 920 929 921 930 template <FloatingObject::Type FloatTypeValue> … … 924 933 typedef FloatingObjectInterval IntervalType; 925 934 926 FloatIntervalSearchAdapter(const RenderBlock* renderer, LayoutUnit value, LayoutUnit& offset, LayoutUnit* heightRemaining)935 FloatIntervalSearchAdapter(const RenderBlock* renderer, int value, LayoutUnit& offset, LayoutUnit* heightRemaining) 927 936 : m_renderer(renderer) 928 937 , m_value(value) … … 932 941 } 933 942 934 inline LayoutUnit lowValue() const { return m_value; }935 inline LayoutUnit highValue() const { return m_value; }943 inline int lowValue() const { return m_value; } 944 inline int highValue() const { return m_value; } 936 945 void collectIfNeeded(const IntervalType&) const; 937 946 938 947 private: 939 948 const RenderBlock* m_renderer; 940 LayoutUnit m_value;949 int m_value; 941 950 LayoutUnit& m_offset; 942 951 LayoutUnit* m_heightRemaining; … … 1004 1013 } 1005 1014 1006 static int positiveMarginBeforeDefault(const RenderBlock* block)1015 static LayoutUnit positiveMarginBeforeDefault(const RenderBlock* block) 1007 1016 { 1008 1017 return std::max<LayoutUnit>(block->marginBefore(), 0); 1009 1018 } 1010 1019 1011 static int negativeMarginBeforeDefault(const RenderBlock* block)1020 static LayoutUnit negativeMarginBeforeDefault(const RenderBlock* block) 1012 1021 { 1013 1022 return std::max<LayoutUnit>(-block->marginBefore(), 0); 1014 1023 } 1015 static int positiveMarginAfterDefault(const RenderBlock* block)1024 static LayoutUnit positiveMarginAfterDefault(const RenderBlock* block) 1016 1025 { 1017 1026 return std::max<LayoutUnit>(block->marginAfter(), 0); 1018 1027 } 1019 static int negativeMarginAfterDefault(const RenderBlock* block)1028 static LayoutUnit negativeMarginAfterDefault(const RenderBlock* block) 1020 1029 { 1021 1030 return std::max<LayoutUnit>(-block->marginAfter(), 0);
Note: See TracChangeset
for help on using the changeset viewer.