Changeset 40142 in webkit
- Timestamp:
- Jan 22, 2009 7:42:12 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r40139 r40142 1 2009-01-22 David Hyatt <hyatt@apple.com> 2 3 Fix for https://bugs.webkit.org/show_bug.cgi?id=23487. 4 5 This patch completely reworks vertical alignment of table cells. The current system uses methods called borderTopExtra() and borderBottomExtra() to 6 add extra space above and below the content of a cell. This system was not confined to the table code and spilled out into all the other RenderObjects. 7 The y-position of the table cell box was set to the outer edge of the cell, but the y() method of RenderBox lied and added in borderTopExtra(). height() 8 also excluded the extra space, so did not accurately reflect the true size of the cell. 9 10 With the new system, the table cell box is completely accurate. The extra space becomes part of the padding of the cell. Padding has been reworked so that 11 additional intrinsic padding can be added on to the specified padding from style. Only the table code has to deal with the extra cell padding. 12 13 localToAbsoluteForContent has now been removed, since there no longer has to be a special hacked content box. 14 15 A number of table layout tests progress with this change, since the new layout system actually fixes existing bugs in baseline alignment of cells. 16 17 Reviewed by Oliver Hunt 18 19 * css/CSSComputedStyleDeclaration.cpp: 20 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 21 Make CSSComputedStyleDeclaration ask for padding values that exclude the built-in intrinsic padding. This ensures that getComputedStyle continues 22 to give the right answer. 23 24 * dom/ContainerNode.cpp: 25 (WebCore::ContainerNode::getLowerRightCorner): 26 * editing/visible_units.cpp: 27 (WebCore::previousLinePosition): 28 (WebCore::nextLinePosition): 29 * rendering/LayoutState.cpp: 30 (WebCore::LayoutState::LayoutState): 31 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 32 33 * rendering/RenderBlock.cpp: 34 (WebCore::RenderBlock::overflowRect): 35 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 36 37 (WebCore::RenderBlock::layoutBlock): 38 (WebCore::RenderBlock::expandsToEncloseOverhangingFloats): 39 The expandsToEncloseOverhangingFloats logic has been reworked. Table cells and fieldsets did not properly handle floats that spilled into the bottom padding. The 40 resulting box needed to not only expand to encompass the float, but also needed to place the full bottom padding after the float. The switch to make the extra table cell 41 space into padding exposed this issue. No extra layout test is required, since an existing table layout test exposes this issue and progresses to match Firefox with 42 this change. 43 44 (WebCore::RenderBlock::selectionGapRects): 45 (WebCore::RenderBlock::paintSelection): 46 (WebCore::RenderBlock::fillSelectionGaps): 47 (WebCore::RenderBlock::nodeAtPoint): 48 (WebCore::RenderBlock::positionForCoordinates): 49 (WebCore::RenderBlock::offsetForContents): 50 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 51 52 * rendering/RenderBlock.h: 53 Add the new simplified method for expanding to encompass overhanging floats. The method has been devirtualized and made to include all of the cases (and not just a subset). 54 55 * rendering/RenderBox.cpp: 56 (WebCore::RenderBox::absoluteRects): 57 (WebCore::RenderBox::absoluteQuads): 58 (WebCore::RenderBox::absoluteContentBox): 59 (WebCore::RenderBox::paintBoxDecorations): 60 (WebCore::RenderBox::paintMask): 61 (WebCore::RenderBox::getOverflowClipRect): 62 (WebCore::RenderBox::localToAbsolute): 63 (WebCore::RenderBox::absoluteToLocal): 64 (WebCore::RenderBox::localToAbsoluteQuad): 65 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 66 67 * rendering/RenderBox.h: 68 (WebCore::RenderBox::y): 69 (WebCore::RenderBox::location): 70 (WebCore::RenderBox::borderBoxRect): 71 (WebCore::RenderBox::offsetHeight): 72 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 73 74 * rendering/RenderContainer.cpp: 75 (WebCore::RenderContainer::addLineBoxRects): 76 * rendering/RenderFieldset.cpp: 77 (WebCore::RenderFieldset::paintBoxDecorations): 78 (WebCore::RenderFieldset::paintMask): 79 * rendering/RenderFieldset.h: 80 (WebCore::RenderFieldset::avoidsFloats): 81 * rendering/RenderFlow.cpp: 82 (WebCore::RenderFlow::localCaretRect): 83 * rendering/RenderLayer.cpp: 84 (WebCore::RenderLayer::updateLayerPosition): 85 (WebCore::RenderLayer::paintLayer): 86 (WebCore::RenderLayer::hitTestLayer): 87 (WebCore::RenderLayer::boundingBox): 88 * rendering/RenderListBox.cpp: 89 (WebCore::RenderListBox::isPointInOverflowControl): 90 * rendering/RenderObject.cpp: 91 (WebCore::RenderObject::localToAbsolute): 92 (WebCore::RenderObject::absoluteToLocal): 93 (WebCore::RenderObject::localToAbsoluteQuad): 94 (WebCore::RenderObject::offsetFromContainer): 95 (WebCore::RenderObject::paddingTop): 96 (WebCore::RenderObject::paddingBottom): 97 (WebCore::RenderObject::paddingLeft): 98 (WebCore::RenderObject::paddingRight): 99 * rendering/RenderObject.h: 100 (WebCore::RenderObject::hasOverhangingFloats): 101 * rendering/RenderReplaced.cpp: 102 (WebCore::RenderReplaced::selectionRect): 103 (WebCore::RenderReplaced::localSelectionRect): 104 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. Also modifed paddingLeft/Top/Right/Bottom to take an argument indicating 105 whether or not the intrinsic padding of an object should be included (by default it is). getComputedStyle needs to exclude it, which is why this argument is 106 necessary. 107 108 * rendering/RenderTableCell.cpp: 109 (WebCore::RenderTableCell::RenderTableCell): 110 (WebCore::RenderTableCell::paddingTop): 111 (WebCore::RenderTableCell::paddingBottom): 112 The new paddingTop() and paddingBottom() methods on table cells include the extra intrinsic padding. 113 114 (WebCore::RenderTableCell::setOverrideSize): 115 When a table's override size gets altered, the intrinsic padding needs to be cleared. 116 117 (WebCore::RenderTableCell::absoluteClippedOverflowRect): 118 (WebCore::RenderTableCell::computeAbsoluteRepaintRect): 119 (WebCore::RenderTableCell::baselinePosition): 120 (WebCore::RenderTableCell::paint): 121 (WebCore::RenderTableCell::paintBackgroundsBehindCell): 122 (WebCore::RenderTableCell::paintBoxDecorations): 123 (WebCore::RenderTableCell::paintMask): 124 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 125 126 * rendering/RenderTableCell.h: 127 (WebCore::RenderTableCell::setIntrinsicPaddingTop): 128 (WebCore::RenderTableCell::setIntrinsicPaddingBottom): 129 (WebCore::RenderTableCell::setIntrinsicPadding): 130 (WebCore::RenderTableCell::clearIntrinsicPadding): 131 (WebCore::RenderTableCell::intrinsicPaddingTop): 132 (WebCore::RenderTableCell::intrinsicPaddingBottom): 133 Add new helper methods for getting/setting a cell's intrinsic padding. 134 135 * rendering/RenderTableSection.cpp: 136 (WebCore::RenderTableSection::calcRowHeight): 137 calcRowHeight has been modified to exclude the intrinsic padding when calculating the base height of rows prior to flexing. Because a cell now includes that 138 extra space, it has to be subtracted out in this method. 139 140 (WebCore::RenderTableSection::layoutRows): 141 Modify the code that sets up the intrinsic padding so that it does a relayout if the intrinsic padding changes. There was also an error where the baseline 142 position mismatched leading to negative intrinsic padding being added in (this error exists in ToT). The code now properly ignores cells that don't establish 143 a baseline. A number of tests progress with this change. 144 145 * rendering/RenderText.cpp: 146 (WebCore::RenderText::addLineBoxRects): 147 Remove borderTopExtra()/borderBottomExtra() hacks and localToAbsoluteForContent calls. 148 149 * rendering/RenderTreeAsText.cpp: 150 (WebCore::operator<<): 151 (WebCore::writeTextRun): 152 Modify the render tree dumping code to continue to produce the same results as before. This is really a hack, since we're now capable of indicating the correct 153 position for the descendants of cells with intrinsic padding (and also indicating what the correct cell box is). A future patch can remove these hacks so that the 154 layout test results can all be regenerated. 155 1 156 2009-01-22 Eric Seidel <eric@webkit.org> 2 157 -
trunk/WebCore/css/CSSComputedStyleDeclaration.cpp
r40107 r40142 864 864 case CSSPropertyPaddingTop: 865 865 if (renderer) 866 return CSSPrimitiveValue::create(renderer->paddingTop( ), CSSPrimitiveValue::CSS_PX);866 return CSSPrimitiveValue::create(renderer->paddingTop(false), CSSPrimitiveValue::CSS_PX); 867 867 return CSSPrimitiveValue::create(style->paddingTop()); 868 868 case CSSPropertyPaddingRight: 869 869 if (renderer) 870 return CSSPrimitiveValue::create(renderer->paddingRight( ), CSSPrimitiveValue::CSS_PX);870 return CSSPrimitiveValue::create(renderer->paddingRight(false), CSSPrimitiveValue::CSS_PX); 871 871 return CSSPrimitiveValue::create(style->paddingRight()); 872 872 case CSSPropertyPaddingBottom: 873 873 if (renderer) 874 return CSSPrimitiveValue::create(renderer->paddingBottom( ), CSSPrimitiveValue::CSS_PX);874 return CSSPrimitiveValue::create(renderer->paddingBottom(false), CSSPrimitiveValue::CSS_PX); 875 875 return CSSPrimitiveValue::create(style->paddingBottom()); 876 876 case CSSPropertyPaddingLeft: 877 877 if (renderer) 878 return CSSPrimitiveValue::create(renderer->paddingLeft( ), CSSPrimitiveValue::CSS_PX);878 return CSSPrimitiveValue::create(renderer->paddingLeft(false), CSSPrimitiveValue::CSS_PX); 879 879 return CSSPrimitiveValue::create(style->paddingLeft()); 880 880 case CSSPropertyPageBreakAfter: -
trunk/WebCore/dom/ContainerNode.cpp
r40107 r40142 723 723 RenderBox* box = RenderBox::toRenderBox(o); 724 724 point = o->localToAbsolute(); 725 point.move(box->width(), 726 box->height() + box->borderTopExtra() + box->borderBottomExtra()); 725 point.move(box->width(), box->height()); 727 726 return true; 728 727 } -
trunk/WebCore/editing/visible_units.cpp
r38304 r40142 495 495 if (root) { 496 496 // FIXME: Can be wrong for multi-column layout and with transforms. 497 FloatPoint absPos = containingBlock->localToAbsolute ForContent(FloatPoint());497 FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint()); 498 498 if (containingBlock->hasOverflowClip()) 499 499 absPos -= containingBlock->layer()->scrolledContentOffset(); … … 596 596 if (root) { 597 597 // FIXME: Can be wrong for multi-column layout and with transforms. 598 FloatPoint absPos = containingBlock->localToAbsolute ForContent(FloatPoint());598 FloatPoint absPos = containingBlock->localToAbsolute(FloatPoint()); 599 599 if (containingBlock->hasOverflowClip()) 600 600 absPos -= containingBlock->layer()->scrolledContentOffset(); -
trunk/WebCore/rendering/LayoutState.cpp
r39834 r40142 89 89 { 90 90 RenderObject* container = root->container(); 91 FloatPoint absContentPoint = container->localToAbsolute ForContent(FloatPoint(), false, true);91 FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), false, true); 92 92 m_offset = IntSize(absContentPoint.x(), absContentPoint.y()); 93 93 } -
trunk/WebCore/rendering/RenderBlock.cpp
r40107 r40142 511 511 return borderBoxRect(); 512 512 int l = overflowLeft(includeInterior); 513 int t = min(overflowTop(includeInterior), -borderTopExtra());514 return IntRect(l, t, overflowWidth(includeInterior) - l, max(overflowHeight(includeInterior), height() + borderBottomExtra()) - t);513 int t = overflowTop(includeInterior); 514 return IntRect(l, t, overflowWidth(includeInterior) - l, max(overflowHeight(includeInterior), height()) - t); 515 515 } 516 516 … … 660 660 // Expand our intrinsic height to encompass floats. 661 661 int toAdd = borderBottom() + paddingBottom() + horizontalScrollbarHeight(); 662 if (floatBottom() > (height() - toAdd) && (isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || 663 (parent() && parent()->isFlexibleBox() || m_hasColumns))) 662 if (floatBottom() > (height() - toAdd) && expandsToEncloseOverhangingFloats()) 664 663 setHeight(floatBottom() + toAdd); 665 664 … … 694 693 relayoutChildren = true; 695 694 696 // Some classes of objects (floats and fieldsets with no specified heights and table cells) expand to encompass697 // overhanging floats.698 if (hasOverhangingFloats() && expandsToEncloseOverhangingFloats())699 setHeight(floatBottom() + borderBottom() + paddingBottom());700 701 695 if ((isCell || isInline() || isFloatingOrPositioned() || isRoot()) && !hasOverflowClip() && !hasControlClip()) 702 696 addVisualOverflow(floatRect()); … … 763 757 } 764 758 setNeedsLayout(false); 759 } 760 761 bool RenderBlock::expandsToEncloseOverhangingFloats() const 762 { 763 return isInlineBlockOrInlineTable() || isFloatingOrPositioned() || hasOverflowClip() || (parent() && parent()->isFlexibleBox()) || m_hasColumns || isTableCell() || isFieldset(); 765 764 } 766 765 … … 1897 1896 1898 1897 // FIXME: this is broken with transforms 1899 FloatPoint absContentPoint = localToAbsolute ForContent(FloatPoint());1898 FloatPoint absContentPoint = localToAbsolute(FloatPoint()); 1900 1899 if (hasOverflowClip()) 1901 1900 absContentPoint -= layer()->scrolledContentOffset(); 1902 1901 1903 int lastTop = -borderTopExtra();1902 int lastTop = 0; 1904 1903 int lastLeft = leftSelectionOffset(this, lastTop); 1905 1904 int lastRight = rightSelectionOffset(this, lastTop); … … 1911 1910 { 1912 1911 if (shouldPaintSelectionGaps() && paintInfo.phase == PaintPhaseForeground) { 1913 int lastTop = -borderTopExtra();1912 int lastTop = 0; 1914 1913 int lastLeft = leftSelectionOffset(this, lastTop); 1915 1914 int lastRight = rightSelectionOffset(this, lastTop); … … 1974 1973 // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block. 1975 1974 if (rootBlock == this && (m_selectionState != SelectionBoth && m_selectionState != SelectionEnd)) 1976 result.uniteCenter(fillVerticalSelectionGap(lastTop, lastLeft, lastRight, ty + height() + borderBottomExtra(),1975 result.uniteCenter(fillVerticalSelectionGap(lastTop, lastLeft, lastRight, ty + height(), 1977 1976 rootBlock, blockX, blockY, paintInfo)); 1978 1977 return result; … … 3165 3164 // Now hit test our background 3166 3165 if (!inlineFlow && (hitTestAction == HitTestBlockBackground || hitTestAction == HitTestChildBlockBackground)) { 3167 int topExtra = borderTopExtra(); 3168 IntRect boundsRect(tx, ty - topExtra, width(), height() + topExtra + borderBottomExtra()); 3166 IntRect boundsRect(tx, ty, width(), height()); 3169 3167 if (visibleToHitTesting() && boundsRect.contains(_x, _y)) { 3170 updateHitTestResult(result, IntPoint(_x - tx, _y - ty + topExtra));3168 updateHitTestResult(result, IntPoint(_x - tx, _y - ty)); 3171 3169 return true; 3172 3170 } … … 3276 3274 3277 3275 int top = borderTop(); 3278 int bottom = top + borderTopExtra() + paddingTop() + contentHeight() + paddingBottom() + borderBottomExtra();3276 int bottom = top + paddingTop() + contentHeight() + paddingBottom(); 3279 3277 3280 3278 int left = borderLeft(); … … 3387 3385 void RenderBlock::offsetForContents(int& tx, int& ty) const 3388 3386 { 3389 ty -= borderTopExtra();3390 3391 3387 if (hasOverflowClip()) 3392 3388 m_layer->addScrolledContentOffset(tx, ty); -
trunk/WebCore/rendering/RenderBlock.h
r40107 r40142 332 332 int layoutColumns(int endOfContent = -1); 333 333 334 bool expandsToEncloseOverhangingFloats() const; 335 334 336 protected: 335 337 struct FloatingObject { -
trunk/WebCore/rendering/RenderBox.cpp
r40126 r40142 357 357 ty - y() + continuation->containingBlock()->y(), topLevel); 358 358 } else 359 rects.append(IntRect(tx, ty, width(), height() + borderTopExtra() + borderBottomExtra()));359 rects.append(IntRect(tx, ty, width(), height())); 360 360 } 361 361 … … 372 372 continuation->absoluteQuads(quads, topLevel); 373 373 } else 374 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height() + borderTopExtra() + borderBottomExtra())));374 quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height()))); 375 375 } 376 376 … … 378 378 { 379 379 IntRect rect = contentBoxRect(); 380 FloatPoint absPos = localToAbsolute ForContent(FloatPoint());380 FloatPoint absPos = localToAbsolute(FloatPoint()); 381 381 rect.move(absPos.x(), absPos.y()); 382 382 return rect; … … 652 652 653 653 int w = width(); 654 int h = height() + borderTopExtra() + borderBottomExtra(); 655 ty -= borderTopExtra(); 654 int h = height(); 656 655 657 656 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat … … 694 693 695 694 int w = width(); 696 int h = height() + borderTopExtra() + borderBottomExtra(); 697 ty -= borderTopExtra(); 695 int h = height(); 698 696 699 697 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat … … 1159 1157 int clipY = ty + bTop; 1160 1158 int clipWidth = width() - bLeft - borderRight(); 1161 int clipHeight = height() - bTop - borderBottom() + borderTopExtra() + borderBottomExtra();1159 int clipHeight = height() - bTop - borderBottom(); 1162 1160 1163 1161 // Subtract out scrollbars if we have them. … … 1271 1269 localPoint += offsetFromContainer(o); 1272 1270 1273 return o->localToAbsolute ForContent(localPoint, fixed, useTransforms);1271 return o->localToAbsolute(localPoint, fixed, useTransforms); 1274 1272 } 1275 1273 … … 1291 1289 if (o) { 1292 1290 FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms); 1293 1294 // Take into account space above a vertically aligned table cell1295 // (see localToAbsoluteForContent())1296 localPoint.move(0.0f, -static_cast<float>(borderTopExtra()));1297 1298 1291 localPoint -= offsetFromContainer(o); 1299 1300 1292 if (useTransforms && m_layer && m_layer->transform()) 1301 1293 localPoint = m_layer->transform()->inverse().mapPoint(localPoint); 1302 1303 1294 return localPoint; 1304 1295 } … … 1319 1310 quad = m_layer->transform()->mapQuad(quad); 1320 1311 } 1321 1322 1312 quad += offsetFromContainer(o); 1323 1324 // Take into account space above a vertically aligned table cell1325 // (see localToAbsoluteForContent())1326 quad.move(0.0f, static_cast<float>(o->borderTopExtra()));1327 1328 1313 return o->localToAbsoluteQuad(quad, fixed); 1329 1314 } -
trunk/WebCore/rendering/RenderBox.h
r40107 r40142 41 41 42 42 int x() const { return m_frameRect.x(); } 43 int y() const { return m_frameRect.y() + borderTopExtra(); } // FIXME: Need to deal with the borderTopExtra() lie in a sane way.43 int y() const { return m_frameRect.y(); } 44 44 int width() const { return m_frameRect.width(); } 45 45 int height() const { return m_frameRect.height(); } … … 50 50 void setHeight(int height) { m_frameRect.setHeight(height); } 51 51 52 IntPoint location() const { return m_frameRect.location(); } // FIXME: Be aware that this is not equivalent to x(), y() because of y()'s borderTopExtra() lie!52 IntPoint location() const { return m_frameRect.location(); } 53 53 IntSize size() const { return m_frameRect.size(); } 54 54 … … 62 62 void setFrameRect(const IntRect& rect) { m_frameRect = rect; } 63 63 64 IntRect borderBoxRect() const { return IntRect(0, -borderTopExtra(), width(), height() + borderTopExtra() + borderBottomExtra()); }64 IntRect borderBoxRect() const { return IntRect(0, 0, width(), height()); } 65 65 66 66 // The content area of the box (excludes padding and border). … … 97 97 // to return the remaining width on a given line (and the height of a single line). 98 98 virtual int offsetWidth() const { return width(); } 99 virtual int offsetHeight() const { return height() + borderTopExtra() + borderBottomExtra(); }99 virtual int offsetHeight() const { return height(); } 100 100 virtual int offsetLeft() const; 101 101 virtual int offsetTop() const; -
trunk/WebCore/rendering/RenderContainer.cpp
r40107 r40142 672 672 { 673 673 if (!m_firstChild && (isInline() || isAnonymousBlock())) { 674 FloatPoint absPos = localToAbsolute ForContent(FloatPoint());674 FloatPoint absPos = localToAbsolute(FloatPoint()); 675 675 absoluteRects(rects, absPos.x(), absPos.y()); 676 676 return; … … 683 683 for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) { 684 684 if (child->isText() || child->isInline() || child->isAnonymousBlock()) { 685 FloatPoint absPos = child->localToAbsolute ForContent(FloatPoint());685 FloatPoint absPos = child->localToAbsolute(FloatPoint()); 686 686 child->absoluteRects(rects, absPos.x(), absPos.y()); 687 687 } -
trunk/WebCore/rendering/RenderFieldset.cpp
r40107 r40142 122 122 { 123 123 int w = width(); 124 int h = height() + borderTopExtra() + borderBottomExtra();124 int h = height(); 125 125 RenderBox* legend = findLegend(); 126 126 if (!legend) … … 130 130 int legendBottom = ty + legend->y() + legend->height(); 131 131 h -= yOff; 132 ty += yOff - borderTopExtra();132 ty += yOff; 133 133 134 134 int my = max(ty, paintInfo.rect.y()); … … 168 168 169 169 int w = width(); 170 int h = height() + borderTopExtra() + borderBottomExtra();170 int h = height(); 171 171 RenderBox* legend = findLegend(); 172 172 if (!legend) … … 175 175 int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2; 176 176 h -= yOff; 177 ty += yOff - borderTopExtra();177 ty += yOff; 178 178 179 179 int my = max(ty, paintInfo.rect.y()); -
trunk/WebCore/rendering/RenderFieldset.h
r40107 r40142 42 42 virtual void calcPrefWidths(); 43 43 virtual bool avoidsFloats() const { return true; } 44 virtual bool expandsToEncloseOverhangingFloats() const { return style()->height().isAuto(); }45 44 virtual bool stretchesToMinIntrinsicWidth() const { return true; } 46 45 -
trunk/WebCore/rendering/RenderFlow.cpp
r40107 r40142 687 687 int myRight = x + caretWidth; 688 688 // FIXME: why call localToAbsoluteForContent() twice here, too? 689 FloatPoint absRightPoint = localToAbsolute ForContent(FloatPoint(myRight, 0));689 FloatPoint absRightPoint = localToAbsolute(FloatPoint(myRight, 0)); 690 690 691 691 int containerRight = containingBlock()->x() + containingBlockWidth(); 692 FloatPoint absContainerPoint = localToAbsolute ForContent(FloatPoint(containerRight, 0));692 FloatPoint absContainerPoint = localToAbsolute(FloatPoint(containerRight, 0)); 693 693 694 694 *extraWidthToEndOfLine = absContainerPoint.x() - absRightPoint.x(); -
trunk/WebCore/rendering/RenderLayer.cpp
r40107 r40142 379 379 380 380 int x = renderer()->x(); 381 int y = renderer()->y() - renderer()->borderTopExtra();381 int y = renderer()->y(); 382 382 383 383 if (!renderer()->isPositioned() && renderer()->parent()) { … … 394 394 curr = curr->parentBox(); 395 395 } 396 y += curr->borderTopExtra();397 396 if (curr->isTableRow()) { 398 397 // Put ourselves into the row coordinate space. … … 434 433 } else { 435 434 setWidth(renderer()->width()); 436 setHeight(renderer()->height() + renderer()->borderTopExtra() + renderer()->borderBottomExtra());435 setHeight(renderer()->height()); 437 436 } 438 437 … … 1734 1733 int y = layerBounds.y(); 1735 1734 int tx = x - renderer()->x(); 1736 int ty = y - renderer()->y() + renderer()->borderTopExtra();1735 int ty = y - renderer()->y(); 1737 1736 1738 1737 // Ensure our lists are up-to-date. … … 1958 1957 renderer()->hitTest(request, result, hitTestPoint, 1959 1958 layerBounds.x() - renderer()->x(), 1960 layerBounds.y() - renderer()->y() + renderer()->borderTopExtra(),1959 layerBounds.y() - renderer()->y(), 1961 1960 HitTestDescendants)) { 1962 1961 // For positioned generated content, we might still not have a … … 1988 1987 renderer()->hitTest(request, result, hitTestPoint, 1989 1988 layerBounds.x() - renderer()->x(), 1990 layerBounds.y() - renderer()->y() + renderer()->borderTopExtra(),1989 layerBounds.y() - renderer()->y(), 1991 1990 HitTestSelf)) { 1992 1991 if (!result.innerNode() || !result.innerNonSharedNode()) { … … 2232 2231 if (child->isTableCell()) { 2233 2232 IntRect bbox = RenderBox::toRenderBox(child)->borderBoxRect(); 2234 bbox.move(0, child->borderTopExtra());2235 2233 result.unite(bbox); 2236 2234 IntRect overflowRect = renderer()->overflowRect(false); 2237 overflowRect.move(0, child->borderTopExtra());2238 2235 if (bbox != overflowRect) 2239 2236 result.unite(overflowRect); … … 2253 2250 2254 2251 // We have to adjust the x/y of this result so that it is in the coordinate space of the layer. 2255 // We also have to add in intrinsicPaddingTop here, since borderBoxRect(), in order to play well with methods like 2256 // floatRect that deal with child content, uses an origin of (0,0) that is at the child content box (so 2257 // border box returns a y coord of -borderTopExtra(). The layer, however, uses the outer box. This is all 2258 // really confusing. 2259 result.move(m_x, m_y + renderer()->borderTopExtra()); 2252 result.move(m_x, m_y); 2260 2253 } 2261 2254 -
trunk/WebCore/rendering/RenderListBox.cpp
r40137 r40142 371 371 372 372 IntRect vertRect(_tx + width() - borderRight() - m_vBar->width(), 373 _ty + borderTop() - borderTopExtra(),374 m_vBar->width(),375 height() + borderTopExtra() + borderBottomExtra() - borderTop() - borderBottom());373 _ty, 374 m_vBar->width(), 375 height() - borderTop() - borderBottom()); 376 376 377 377 if (vertRect.contains(_x, _y)) { -
trunk/WebCore/rendering/RenderObject.cpp
r40118 r40142 2257 2257 RenderObject* o = parent(); 2258 2258 if (o) { 2259 localPoint.move(0.0f, static_cast<float>(o->borderTopExtra()));2260 2259 if (o->hasOverflowClip()) 2261 2260 localPoint -= o->layer()->scrolledContentOffset(); … … 2271 2270 if (o) { 2272 2271 FloatPoint localPoint = o->absoluteToLocal(containerPoint, fixed, useTransforms); 2273 localPoint.move(0.0f, -static_cast<float>(o->borderTopExtra()));2274 2272 if (o->hasOverflowClip()) 2275 2273 localPoint += o->layer()->scrolledContentOffset(); … … 2284 2282 if (o) { 2285 2283 FloatQuad quad = localQuad; 2286 quad.move(0.0f, static_cast<float>(o->borderTopExtra()));2287 2284 if (o->hasOverflowClip()) 2288 2285 quad -= o->layer()->scrolledContentOffset(); … … 2298 2295 2299 2296 IntSize offset; 2300 offset.expand(0, o->borderTopExtra());2301 2302 2297 if (o->hasOverflowClip()) 2303 2298 offset -= o->layer()->scrolledContentOffset(); … … 2314 2309 } 2315 2310 2316 int RenderObject::paddingTop( ) const2311 int RenderObject::paddingTop(bool) const 2317 2312 { 2318 2313 int w = 0; … … 2323 2318 } 2324 2319 2325 int RenderObject::paddingBottom( ) const2320 int RenderObject::paddingBottom(bool) const 2326 2321 { 2327 2322 int w = 0; … … 2332 2327 } 2333 2328 2334 int RenderObject::paddingLeft( ) const2329 int RenderObject::paddingLeft(bool) const 2335 2330 { 2336 2331 int w = 0; … … 2341 2336 } 2342 2337 2343 int RenderObject::paddingRight( ) const2338 int RenderObject::paddingRight(bool) const 2344 2339 { 2345 2340 int w = 0; -
trunk/WebCore/rendering/RenderObject.h
r40118 r40142 568 568 virtual FloatPoint absoluteToLocal(FloatPoint, bool fixed = false, bool useTransforms = false) const; 569 569 570 // This function is used to deal with the extra top space that can occur in table cells (called intrinsicPaddingTop).571 // The children of the cell do not factor this space in, so we have to add it in. Any code that wants to572 // accurately deal with the contents of a cell must call this function instad of absolutePosition.573 FloatPoint localToAbsoluteForContent(FloatPoint localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const574 {575 localPoint.move(0.0f, static_cast<float>(borderTopExtra()));576 return localToAbsolute(localPoint, fixed, useTransforms);577 }578 579 570 // Convert a local quad to an absolute quad, taking transforms into account. 580 571 virtual FloatQuad localToAbsoluteQuad(const FloatQuad&, bool fixed = false) const; … … 613 604 614 605 // Virtual since table cells override 615 virtual int paddingTop() const; 616 virtual int paddingBottom() const; 617 virtual int paddingLeft() const; 618 virtual int paddingRight() const; 619 620 virtual int borderTopExtra() const { return 0; } 621 virtual int borderBottomExtra() const { return 0; } 606 virtual int paddingTop(bool includeIntrinsicPadding = true) const; 607 virtual int paddingBottom(bool includeIntrinsicPadding = true) const; 608 virtual int paddingLeft(bool includeIntrinsicPadding = true) const; 609 virtual int paddingRight(bool includeIntrinsicPadding = true) const; 622 610 623 611 virtual int borderTop() const { return style()->borderTopWidth(); } … … 695 683 virtual bool containsFloat(RenderObject*) { return false; } 696 684 virtual bool hasOverhangingFloats() { return false; } 697 virtual bool expandsToEncloseOverhangingFloats() const { return isFloating() && style()->height().isAuto(); }698 685 699 686 virtual void removePositionedObjects(RenderBlock*) { } -
trunk/WebCore/rendering/RenderReplaced.cpp
r40107 r40142 255 255 computeAbsoluteRepaintRect(rect); 256 256 else { 257 FloatPoint absPos = localToAbsolute ForContent(FloatPoint());257 FloatPoint absPos = localToAbsolute(FloatPoint()); 258 258 rect.move(absPos.x(), absPos.y()); 259 259 } … … 269 269 if (!m_inlineBoxWrapper) 270 270 // We're a block-level replaced element. Just return our own dimensions. 271 return IntRect(0, 0, width(), height() + borderTopExtra() + borderBottomExtra());271 return IntRect(0, 0, width(), height()); 272 272 273 273 RenderBlock* cb = containingBlock(); -
trunk/WebCore/rendering/RenderTableCell.cpp
r40107 r40142 44 44 , m_rowSpan(1) 45 45 , m_columnSpan(1) 46 , m_ topExtra(0)47 , m_ bottomExtra(0)46 , m_intrinsicPaddingTop(0) 47 , m_intrinsicPaddingBottom(0) 48 48 , m_widthChanged(false) 49 49 , m_percentageHeight(0) … … 138 138 } 139 139 140 int RenderTableCell::paddingTop(bool includeIntrinsicPadding) const 141 { 142 return RenderBlock::paddingTop() + (includeIntrinsicPadding ? intrinsicPaddingTop() : 0); 143 } 144 145 int RenderTableCell::paddingBottom(bool includeIntrinsicPadding) const 146 { 147 return RenderBlock::paddingBottom() + (includeIntrinsicPadding ? intrinsicPaddingBottom() : 0); 148 } 149 150 void RenderTableCell::setOverrideSize(int size) 151 { 152 clearIntrinsicPadding(); 153 RenderBlock::setOverrideSize(size); 154 } 155 140 156 IntRect RenderTableCell::absoluteClippedOverflowRect() 141 157 { … … 178 194 } 179 195 left = max(left, -overflowLeft(false)); 180 top = max(top, -overflowTop(false) - borderTopExtra());181 IntRect r(-left, - borderTopExtra() - top, left + max(width() + right, overflowWidth(false)), borderTopExtra() + top + max(height() + bottom + borderBottomExtra(), overflowHeight(false)));196 top = max(top, -overflowTop(false)); 197 IntRect r(-left, - top, left + max(width() + right, overflowWidth(false)), top + max(height() + bottom, overflowHeight(false))); 182 198 183 199 if (RenderView* v = view()) … … 190 206 void RenderTableCell::computeAbsoluteRepaintRect(IntRect& r, bool fixed) 191 207 { 192 r.setY(r.y() + m_topExtra);208 r.setY(r.y()); 193 209 RenderView* v = view(); 194 210 if ((!v || !v->layoutStateEnabled()) && parent()) … … 232 248 // the first in-flow line box in the cell, or the first in-flow table-row in the cell, whichever comes first. If there 233 249 // is no such line box or table-row, the baseline is the bottom of content edge of the cell box. 234 235 250 int firstLineBaseline = getBaselineOfFirstLineBox(); 236 251 if (firstLineBaseline != -1) 237 252 return firstLineBaseline; 238 239 253 return paddingTop() + borderTop() + contentHeight(); 240 254 } … … 639 653 if (paintInfo.phase == PaintPhaseCollapsedTableBorders && style()->visibility() == VISIBLE) { 640 654 if (ty - table()->outerBorderTop() >= paintInfo.rect.bottom() + os || 641 ty + m_topExtra + height() + m_bottomExtra+ table()->outerBorderBottom() <= paintInfo.rect.y() - os)655 ty + height() + table()->outerBorderBottom() <= paintInfo.rect.y() - os) 642 656 return; 643 int w = width(); 644 int h = height() + borderTopExtra() + borderBottomExtra(); 645 paintCollapsedBorder(paintInfo.context, tx, ty, w, h); 657 paintCollapsedBorder(paintInfo.context, tx, ty, width(), height()); 646 658 } else { 647 if (ty + overflowTop(false) >= paintInfo.rect.bottom() + os || ty + m_topExtra + overflowHeight(false) + m_bottomExtra<= paintInfo.rect.y() - os)659 if (ty + overflowTop(false) >= paintInfo.rect.bottom() + os || ty + overflowHeight(false) <= paintInfo.rect.y() - os) 648 660 return; 649 RenderBlock::paintObject(paintInfo, tx, ty + m_topExtra);661 RenderBlock::paintObject(paintInfo, tx, ty); 650 662 } 651 663 } … … 809 821 if (backgroundObject != this) { 810 822 tx += x(); 811 ty += m_frameRect.y() + m_topExtra;823 ty += m_frameRect.y(); 812 824 } 813 825 814 826 int w = width(); 815 int h = height() + borderTopExtra() + borderBottomExtra(); 816 ty -= borderTopExtra(); 827 int h = height(); 817 828 818 829 int my = max(ty, paintInfo.rect.y()); … … 846 857 847 858 int w = width(); 848 int h = height() + borderTopExtra() + borderBottomExtra();859 int h = height(); 849 860 850 861 if (style()->boxShadow()) 851 paintBoxShadow(paintInfo.context, tx, ty - borderTopExtra(), w, h, style());862 paintBoxShadow(paintInfo.context, tx, ty, w, h, style()); 852 863 853 864 // Paint our cell background. … … 857 868 return; 858 869 859 ty -= borderTopExtra();860 870 paintBorder(paintInfo.context, tx, ty, w, h, style()); 861 871 } … … 871 881 872 882 int w = width(); 873 int h = height() + borderTopExtra() + borderBottomExtra();883 int h = height(); 874 884 875 885 int my = max(ty, paintInfo.rect.y()); -
trunk/WebCore/rendering/RenderTableCell.h
r40107 r40142 66 66 void updateWidth(int); 67 67 68 virtual bool expandsToEncloseOverhangingFloats() const { return true; }69 70 68 int borderLeft() const; 71 69 int borderRight() const; … … 105 103 virtual int baselinePosition(bool firstLine = false, bool isRootLineBox = false) const; 106 104 107 void setCellTopExtra(int p) { m_topExtra = p; } 108 void setCellBottomExtra(int p) { m_bottomExtra = p; } 105 void setIntrinsicPaddingTop(int p) { m_intrinsicPaddingTop = p; } 106 void setIntrinsicPaddingBottom(int p) { m_intrinsicPaddingBottom = p; } 107 void setIntrinsicPadding(int top, int bottom) { setIntrinsicPaddingTop(top); setIntrinsicPaddingBottom(bottom); } 108 void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); } 109 109 110 virtual int borderTopExtra() const { return m_topExtra; } 111 virtual int borderBottomExtra() const { return m_bottomExtra; } 110 int intrinsicPaddingTop() const { return m_intrinsicPaddingTop; } 111 int intrinsicPaddingBottom() const { return m_intrinsicPaddingBottom; } 112 113 virtual int paddingTop(bool includeIntrinsicPadding = true) const; 114 virtual int paddingBottom(bool includeIntrinsicPadding = true) const; 115 116 virtual void setOverrideSize(int); 112 117 113 118 protected: … … 120 125 int m_rowSpan; 121 126 int m_columnSpan; 122 int m_ topExtra: 31;123 int m_ bottomExtra: 31;127 int m_intrinsicPaddingTop : 31; 128 int m_intrinsicPaddingBottom : 31; 124 129 bool m_widthChanged : 1; 125 130 int m_percentageHeight; -
trunk/WebCore/rendering/RenderTableSection.cpp
r40107 r40142 341 341 } 342 342 343 int adjustedPaddingTop = cell->paddingTop() - cell->intrinsicPaddingTop(); 344 int adjustedPaddingBottom = cell->paddingBottom() - cell->intrinsicPaddingBottom(); 345 int adjustedHeight = cell->height() - (cell->intrinsicPaddingTop() + cell->intrinsicPaddingBottom()); 346 343 347 // Explicit heights use the border box in quirks mode. In strict mode do the right 344 348 // thing and actually add in the border and padding. 345 349 ch = cell->style()->height().calcValue(0) + 346 (cell->style()->htmlHacks() ? 0 : ( cell->paddingTop() + cell->paddingBottom()+350 (cell->style()->htmlHacks() ? 0 : (adjustedPaddingTop + adjustedPaddingBottom + 347 351 cell->borderTop() + cell->borderBottom())); 348 ch = max(ch, cell->height());352 ch = max(ch, adjustedHeight); 349 353 350 354 pos = m_rowPos[indx] + ch + (m_grid[r].rowRenderer ? spacing : 0); … … 357 361 int b = cell->baselinePosition(); 358 362 if (b > cell->borderTop() + cell->paddingTop()) { 359 baseline = max(baseline, b );360 bdesc = max(bdesc, m_rowPos[indx] + ch - b);363 baseline = max(baseline, b - cell->intrinsicPaddingTop()); 364 bdesc = max(bdesc, m_rowPos[indx] + ch - (b - cell->intrinsicPaddingTop())); 361 365 } 362 366 } … … 504 508 } 505 509 } 510 506 511 if (cellChildrenFlex) { 507 512 // Alignment within a cell is based off the calculated 508 513 // height, which becomes irrelevant once the cell has 509 // been resized based off its percentage. -dwh514 // been resized based off its percentage. 510 515 cell->setOverrideSize(max(0, 511 516 rHeight - cell->borderTop() - cell->paddingTop() - … … 522 527 } 523 528 529 int oldTe = cell->intrinsicPaddingTop(); 530 int oldBe = cell->intrinsicPaddingBottom(); 531 int heightWithoutIntrinsicPadding = cell->height() - oldTe - oldBe; 532 524 533 int te = 0; 525 534 switch (cell->style()->verticalAlign()) { … … 529 538 case TEXT_BOTTOM: 530 539 case BASELINE: 531 te = getBaseline(r) - cell->baselinePosition(); 540 int b = cell->baselinePosition(); 541 if (b > cell->borderTop() + cell->paddingTop()) 542 te = getBaseline(r) - (b - oldTe); 532 543 break; 533 544 case TOP: … … 535 546 break; 536 547 case MIDDLE: 537 te = (rHeight - cell->height()) / 2;548 te = (rHeight - heightWithoutIntrinsicPadding) / 2; 538 549 break; 539 550 case BOTTOM: 540 te = rHeight - cell->height();551 te = rHeight - heightWithoutIntrinsicPadding; 541 552 break; 542 553 default: 543 554 break; 544 555 } 545 546 int oldTe = cell->borderTopExtra(); 547 int oldBe = cell->borderBottomExtra(); 548 549 int be = rHeight - cell->height() - te; 550 cell->setCellTopExtra(te); 551 cell->setCellBottomExtra(be); 556 557 int be = rHeight - heightWithoutIntrinsicPadding - te; 558 cell->setIntrinsicPaddingTop(te); 559 cell->setIntrinsicPaddingBottom(be); 560 if (te != oldTe || be != oldBe) { 561 cell->setNeedsLayout(true, false); 562 cell->layoutIfNeeded(); 563 } 564 552 565 if ((te != oldTe || be > oldBe) && !table()->selfNeedsLayout() && cell->checkForRepaintDuringLayout()) 553 566 cell->repaint(); 554 567 555 IntRect oldCellRect(cell->x(), cell->y() - cell->borderTopExtra(), cell->width(), cell->height());568 IntRect oldCellRect(cell->x(), cell->y() , cell->width(), cell->height()); 556 569 557 570 if (style()->direction() == RTL) { -
trunk/WebCore/rendering/RenderText.cpp
r40107 r40142 222 222 end = min(end, static_cast<unsigned>(INT_MAX)); 223 223 224 FloatPoint absPos = localToAbsolute ForContent(FloatPoint());224 FloatPoint absPos = localToAbsolute(FloatPoint()); 225 225 226 226 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { -
trunk/WebCore/rendering/RenderTreeAsText.cpp
r40107 r40142 182 182 } 183 183 184 bool adjustForTableCells = o.containingBlock()->isTableCell(); 185 184 186 IntRect r; 185 187 if (o.isText()) { … … 188 190 const RenderText& text = static_cast<const RenderText&>(o); 189 191 r = IntRect(text.firstRunX(), text.firstRunY(), text.boundingBoxWidth(), text.boundingBoxHeight()); 192 if (adjustForTableCells && !text.firstTextBox()) 193 adjustForTableCells = false; 190 194 } else if (o.isBox()) { 191 195 if (o.isRenderInline()) { … … 193 197 const RenderInline& inlineFlow = static_cast<const RenderInline&>(o); 194 198 r = IntRect(0, 0, inlineFlow.boundingBoxWidth(), inlineFlow.boundingBoxHeight()); 195 } else { 196 // FIXME: We can't just use the actual frameRect of the box because dump render tree dumps the "inner box" of table cells. 197 // Because of the lie we have to call y(). We would like to fix dump render tree to dump the actual dimensions of the table 198 // cell including the extra intrinsic padding. 199 const RenderBox& box = static_cast<const RenderBox&>(o); 200 r = IntRect(box.x(), box.y(), box.width(), box.height()); 201 } 202 } 199 adjustForTableCells = false; 200 } else if (o.isTableCell()) { 201 // FIXME: Deliberately dump the "inner" box of table cells, since that is what current results reflect. We'd like 202 // to clean up the results to dump both the outer box and the intrinsic padding so that both bits of information are 203 // captured by the results. 204 const RenderTableCell& cell = static_cast<const RenderTableCell&>(o); 205 r = IntRect(cell.x(), cell.y() + cell.intrinsicPaddingTop(), cell.width(), cell.height() - cell.intrinsicPaddingTop() - cell.intrinsicPaddingBottom()); 206 } else 207 r = static_cast<const RenderBox&>(o).frameRect(); 208 } 209 210 // FIXME: Temporary in order to ensure compatibility with existing layout test results. 211 if (adjustForTableCells) 212 r.move(0, -static_cast<RenderTableCell*>(o.containingBlock())->intrinsicPaddingTop()); 203 213 204 214 ts << " " << r; … … 325 335 static void writeTextRun(TextStream& ts, const RenderText& o, const InlineTextBox& run) 326 336 { 327 ts << "text run at (" << run.m_x << "," << run.m_y << ") width " << run.m_width; 337 // FIXME: Table cell adjustment is temporary until results can be updated. 338 int y = run.m_y; 339 if (o.containingBlock()->isTableCell()) 340 y -= static_cast<RenderTableCell*>(o.containingBlock())->intrinsicPaddingTop(); 341 ts << "text run at (" << run.m_x << "," << y << ") width " << run.m_width; 328 342 if (run.direction() == RTL || run.m_dirOverride) { 329 343 ts << (run.direction() == RTL ? " RTL" : " LTR");
Note: See TracChangeset
for help on using the changeset viewer.