Changeset 90668 in webkit
- Timestamp:
- Jul 8, 2011 3:15:14 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90667 r90668 1 2011-07-08 Tony Chang <tony@chromium.org> 2 3 Refactor override size to be a size rather than just an int 4 https://bugs.webkit.org/show_bug.cgi?id=64195 5 6 Reviewed by David Hyatt. 7 8 Also convert to LayoutSize and LayoutUnit. 9 10 Covered by existing tests. 11 12 * rendering/RenderBox.cpp: 13 (WebCore::RenderBox::overrideSize): Pass in a LayoutSize. 14 (WebCore::RenderBox::setOverrideSize): 15 (WebCore::RenderBox::clearOverrideSize): New method for clearing the 16 override size (previous we would pass in -1) 17 (WebCore::RenderBox::overrideWidth): 18 (WebCore::RenderBox::overrideHeight): 19 (WebCore::RenderBox::computeLogicalWidth): 20 (WebCore::RenderBox::computeLogicalHeight): 21 (WebCore::RenderBox::computePercentageLogicalHeight): 22 (WebCore::RenderBox::availableLogicalHeightUsing): 23 * rendering/RenderBox.h: 24 * rendering/RenderDeprecatedFlexibleBox.cpp: 25 (WebCore::gatherFlexChildrenInfo): 26 (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox): 27 (WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox): 28 (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp): 29 * rendering/RenderTableCell.cpp: 30 (WebCore::RenderTableCell::setOverrideSizeFromRowHeight): 31 * rendering/RenderTableCell.h: Remove setOverrideSize since it was 32 only called in one place to clear the override size. Inline this 33 logic instead. 34 * rendering/RenderTableSection.cpp: 35 (WebCore::RenderTableSection::calcRowLogicalHeight): 36 * rendering/RenderWidget.cpp: 37 (WebCore::RenderWidget::destroy): 38 1 39 2011-07-08 Emil A Eklund <eae@chromium.org> 2 40 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r90667 r90668 59 59 using namespace HTMLNames; 60 60 61 // Used by flexible boxes when flexing this element .62 typedef WTF::HashMap<const RenderBox*, int> OverrideSizeMap;61 // Used by flexible boxes when flexing this element and by table cells. 62 typedef WTF::HashMap<const RenderBox*, LayoutSize> OverrideSizeMap; 63 63 static OverrideSizeMap* gOverrideSizeMap = 0; 64 64 … … 687 687 } 688 688 689 intRenderBox::overrideSize() const689 LayoutSize RenderBox::overrideSize() const 690 690 { 691 691 if (!hasOverrideSize()) 692 return -1;692 return LayoutSize(-1, -1); 693 693 return gOverrideSizeMap->get(this); 694 694 } 695 695 696 void RenderBox::setOverrideSize(int s) 697 { 698 if (s == -1) { 699 if (hasOverrideSize()) { 700 setHasOverrideSize(false); 701 gOverrideSizeMap->remove(this); 702 } 703 } else { 704 if (!gOverrideSizeMap) 705 gOverrideSizeMap = new OverrideSizeMap(); 706 setHasOverrideSize(true); 707 gOverrideSizeMap->set(this, s); 708 } 709 } 710 711 int RenderBox::overrideWidth() const 712 { 713 return hasOverrideSize() ? overrideSize() : width(); 714 } 715 716 int RenderBox::overrideHeight() const 717 { 718 return hasOverrideSize() ? overrideSize() : height(); 696 void RenderBox::setOverrideSize(const LayoutSize& size) 697 { 698 if (!gOverrideSizeMap) 699 gOverrideSizeMap = new OverrideSizeMap(); 700 setHasOverrideSize(true); 701 gOverrideSizeMap->set(this, size); 702 } 703 704 void RenderBox::clearOverrideSize() 705 { 706 if (!hasOverrideSize()) 707 return; 708 setHasOverrideSize(false); 709 gOverrideSizeMap->remove(this); 710 } 711 712 LayoutUnit RenderBox::overrideWidth() const 713 { 714 return hasOverrideSize() ? overrideSize().width() : width(); 715 } 716 717 LayoutUnit RenderBox::overrideHeight() const 718 { 719 return hasOverrideSize() ? overrideSize().height() : height(); 719 720 } 720 721 … … 1555 1556 if (hasOverrideSize() && parent()->style()->boxOrient() == HORIZONTAL 1556 1557 && parent()->isFlexibleBox() && parent()->isFlexingChildren()) { 1557 setLogicalWidth(override Size());1558 setLogicalWidth(overrideWidth()); 1558 1559 return; 1559 1560 } … … 1769 1770 if (hasOverrideSize() && parent()->isFlexibleBox() && parent()->style()->boxOrient() == VERTICAL 1770 1771 && parent()->isFlexingChildren()) 1771 h = Length(override Size() - borderAndPaddingLogicalHeight(), Fixed);1772 h = Length(overrideHeight() - borderAndPaddingLogicalHeight(), Fixed); 1772 1773 else if (treatAsReplaced) 1773 1774 h = Length(computeReplacedLogicalHeight(), Fixed); … … 1887 1888 if (cb->isTableCell()) { 1888 1889 if (!skippedAutoHeightContainingBlock) { 1889 result = cb->overrideSize(); 1890 if (result == -1) { 1890 if (!cb->hasOverrideSize()) { 1891 1891 // Normally we would let the cell size intrinsically, but scrolling overflow has to be 1892 1892 // treated differently, since WinIE lets scrolled overflow regions shrink as needed. … … 1901 1901 return -1; 1902 1902 } 1903 result = cb->overrideHeight(); 1903 1904 includeBorderPadding = true; 1904 1905 } … … 2053 2054 // height, and then when we lay out again we'll use the calculation below. 2054 2055 if (isTableCell() && (h.isAuto() || h.isPercent())) 2055 return override Size() - borderAndPaddingLogicalWidth();2056 return overrideHeight() - borderAndPaddingLogicalWidth(); 2056 2057 2057 2058 if (h.isPercent()) -
trunk/Source/WebCore/rendering/RenderBox.h
r90667 r90668 245 245 virtual int maxPreferredLogicalWidth() const; 246 246 247 int overrideSize() const; 248 int overrideWidth() const; 249 int overrideHeight() const; 250 virtual void setOverrideSize(int); 247 LayoutSize overrideSize() const; 248 LayoutUnit overrideWidth() const; 249 LayoutUnit overrideHeight() const; 250 void setOverrideSize(const LayoutSize&); 251 void clearOverrideSize(); 251 252 252 253 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const; -
trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp
r90568 r90668 294 294 // We always have to lay out flexible objects again, since the flex distribution 295 295 // may have changed, and we need to reallocate space. 296 child-> setOverrideSize(-1);296 child->clearOverrideSize(); 297 297 if (!relayoutChildren) 298 298 child->setChildNeedsLayout(true, false); … … 497 497 int spaceAdd = (int)(spaceAvailableThisPass * (child->style()->boxFlex()/totalFlex)); 498 498 if (spaceAdd) { 499 child->setOverrideSize( child->overrideWidth() + spaceAdd);499 child->setOverrideSize(LayoutSize(child->overrideWidth() + spaceAdd, 0)); 500 500 m_flexingChildren = true; 501 501 relayoutChildren = true; … … 514 514 for (RenderBox* child = iterator.first(); child && groupRemainingSpace; child = iterator.next()) { 515 515 if (allowedChildFlex(child, expanding, i)) { 516 child->setOverrideSize( child->overrideWidth() + spaceAdd);516 child->setOverrideSize(LayoutSize(child->overrideWidth() + spaceAdd, 0)); 517 517 m_flexingChildren = true; 518 518 relayoutChildren = true; … … 743 743 int spaceAdd = (int)(spaceAvailableThisPass * (child->style()->boxFlex()/totalFlex)); 744 744 if (spaceAdd) { 745 child->setOverrideSize( child->overrideHeight() + spaceAdd);745 child->setOverrideSize(LayoutSize(0, child->overrideHeight() + spaceAdd)); 746 746 m_flexingChildren = true; 747 747 relayoutChildren = true; … … 760 760 for (RenderBox* child = iterator.first(); child && groupRemainingSpace; child = iterator.next()) { 761 761 if (allowedChildFlex(child, expanding, i)) { 762 child->setOverrideSize( child->overrideHeight() + spaceAdd);762 child->setOverrideSize(LayoutSize(0, child->overrideHeight() + spaceAdd)); 763 763 m_flexingChildren = true; 764 764 relayoutChildren = true; … … 874 874 875 875 child->setChildNeedsLayout(true, false); 876 child->setOverrideSize( newHeight);876 child->setOverrideSize(LayoutSize(0, newHeight)); 877 877 m_flexingChildren = true; 878 878 child->layoutIfNeeded(); 879 879 m_flexingChildren = false; 880 child-> setOverrideSize(-1);880 child->clearOverrideSize(); 881 881 882 882 // FIXME: For now don't support RTL. -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r90600 r90668 213 213 } 214 214 215 void RenderTableCell::setOverrideSize (int size)215 void RenderTableCell::setOverrideSizeFromRowHeight(int rowHeight) 216 216 { 217 217 clearIntrinsicPadding(); 218 RenderBlock::setOverrideSize(size); 219 } 220 221 void RenderTableCell::setOverrideSizeFromRowHeight(int rowHeight) 222 { 223 clearIntrinsicPadding(); 224 RenderBlock::setOverrideSize(max(0, rowHeight - borderBefore() - paddingBefore() - borderAfter() - paddingAfter())); 218 RenderBlock::setOverrideSize(LayoutSize(0, max(0, rowHeight - borderBefore() - paddingBefore() - borderAfter() - paddingAfter()))); 225 219 } 226 220 -
trunk/Source/WebCore/rendering/RenderTableCell.h
r90525 r90668 120 120 virtual int paddingAfter(bool includeIntrinsicPadding = true) const; 121 121 122 virtual void setOverrideSize(int);123 122 void setOverrideSizeFromRowHeight(int); 124 123 -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r90600 r90668 336 336 int indx = max(r - cell->rowSpan() + 1, 0); 337 337 338 if (cell-> overrideSize() != -1) {338 if (cell->hasOverrideSize()) { 339 339 if (!statePusher.didPush()) { 340 340 // Technically, we should also push state for the row, but since … … 342 342 statePusher.push(this, IntSize(x(), y())); 343 343 } 344 cell->setOverrideSize(-1); 344 cell->clearIntrinsicPadding(); 345 cell->clearOverrideSize(); 345 346 cell->setChildNeedsLayout(true, false); 346 347 cell->layoutIfNeeded(); -
trunk/Source/WebCore/rendering/RenderWidget.cpp
r90515 r90668 140 140 // removes from override size map 141 141 if (hasOverrideSize()) 142 setOverrideSize(-1);142 clearOverrideSize(); 143 143 144 144 if (style() && (style()->logicalHeight().isPercent() || style()->logicalMinHeight().isPercent() || style()->logicalMaxHeight().isPercent()))
Note: See TracChangeset
for help on using the changeset viewer.