Changeset 109378 in webkit
- Timestamp:
- Mar 1, 2012 11:33:44 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109372 r109378 1 2012-03-01 Levi Weintraub <leviw@chromium.org> 2 3 Add roundToInt method for LayoutUnits 4 https://bugs.webkit.org/show_bug.cgi?id=79283 5 6 Reviewed by Eric Seidel. 7 8 Adding a roundToInt method that rounds a LayoutUnit to the nearest integer. This 9 only has an effect once we switch to sub-pixel positioning. Points and offsets 10 are rounded for painting and hit testing. 11 12 No new tests. No change in behavior. 13 14 * dom/MouseRelatedEvent.cpp: 15 (WebCore::MouseRelatedEvent::offsetX): 16 (WebCore::MouseRelatedEvent::offsetY): 17 * html/shadow/MediaControlElements.cpp: 18 (WebCore::MediaControlTextTrackContainerElement::updateSizes): 19 * rendering/LayoutState.cpp: 20 (WebCore::LayoutState::computeLineGridPaginationOrigin): 21 * rendering/LayoutTypes.h: 22 (WebCore::roundToInt): Stub until we switch to sub-pixel LayoutUnits. 23 (WebCore): 24 * rendering/RenderBlock.cpp: 25 (WebCore::RenderBlock::pageLogicalTopForOffset): 26 * rendering/RenderBlock.h: 27 (WebCore::RenderBlock::pixelSnappedLogicalLeftOffsetForLine): Correcting to use the 28 pixel snapped methods on FloatingObjects and removing the fixme. 29 (WebCore::RenderBlock::pixelSnappedLogicalTopForFloat): Ditto. 30 (WebCore::RenderBlock::pixelSnappedLogicalBottomForFloat): Ditto. 31 (WebCore::RenderBlock::pixelSnappedLogicalLeftForFloat): Ditto. 32 (WebCore::RenderBlock::pixelSnappedLogicalRightForFloat): Ditto. 33 (WebCore::RenderBlock::pixelSnappedLogicalWidthForFloat): Ditto. 34 * rendering/RenderBlockLineLayout.cpp: 35 (WebCore::LineWidth::updateAvailableWidth): 36 (WebCore::RenderBlock::computeInlineDirectionPositionsForLine): Using 37 pixelSnappedLogicalLeft/RightOffsetForLine convenience methods for line layout. When 38 we switch to sub-pixel positioning, we still pixel snap blocks before painting them, 39 but text is rendered using floats. We need to ensure the text is laid out using the 40 actual pixel width of the containing block to avoid bleeding out of the block. 41 * rendering/RenderBoxModelObject.h: Moving the fixme to pixelSnappedWidth/Height and 42 adding the necessary rounding for Left/Top. 43 (WebCore::RenderBoxModelObject::pixelSnappedOffsetLeft): 44 (WebCore::RenderBoxModelObject::pixelSnappedOffsetTop): 45 * rendering/RenderLayer.cpp: 46 (WebCore::RenderLayer::scrollRectToVisible): 47 * rendering/RenderListBox.cpp: 48 (WebCore::RenderListBox::scrollHeight): Rounding the height for scrollHeight. Scrolling 49 always uses rounded values. 50 * rendering/svg/RenderSVGRoot.cpp: 51 (WebCore::RenderSVGRoot::localToParentTransform): Similar to the line box tree, since 52 SVG renders using floats, we need to start with pixel snapped values from the render 53 tree or we'll end up with the contents not properly aligned to the rest of the page. 54 * rendering/svg/SVGRenderSupport.cpp: 55 (WebCore::SVGRenderSupport::prepareToRenderSVGContent): 56 1 57 2012-03-01 Pavel Feldman <pfeldman@chromium.org> 2 58 -
trunk/Source/WebCore/dom/MouseRelatedEvent.cpp
r101111 r109378 215 215 if (!m_hasCachedRelativePosition) 216 216 computeRelativePosition(); 217 return m_offsetLocation.x();217 return roundToInt(m_offsetLocation.x()); 218 218 } 219 219 … … 222 222 if (!m_hasCachedRelativePosition) 223 223 computeRelativePosition(); 224 return m_offsetLocation.y();224 return roundToInt(m_offsetLocation.y()); 225 225 } 226 226 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r107899 r109378 1212 1212 if (bottom != m_bottom) { 1213 1213 m_bottom = bottom; 1214 setInlineStyleProperty(CSSPropertyBottom, String::number( bottom) + "px");1214 setInlineStyleProperty(CSSPropertyBottom, String::number(roundToInt(bottom)) + "px"); 1215 1215 } 1216 1216 } -
trunk/Source/WebCore/rendering/LayoutState.cpp
r109157 r109378 279 279 // Shift to the next highest line grid multiple past the page logical top. Cache the delta 280 280 // between this new value and the page logical top as the pagination origin. 281 LayoutUnit remainder = (pageLogicalTop - firstLineTopWithLeading) % gridLineHeight;281 LayoutUnit remainder = roundToInt(pageLogicalTop - firstLineTopWithLeading) % roundToInt(gridLineHeight); 282 282 LayoutUnit paginationDelta = gridLineHeight - remainder; 283 283 if (isHorizontalWritingMode) -
trunk/Source/WebCore/rendering/LayoutTypes.h
r108719 r109378 99 99 } 100 100 101 inline int roundToInt(LayoutUnit value) 102 { 103 return value; 104 } 105 101 106 inline LayoutUnit roundedLayoutUnit(float value) 102 107 { -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r109367 r109378 6674 6674 if (!pageLogicalHeight) 6675 6675 return 0; 6676 return cumulativeOffset - (cumulativeOffset - firstPageLogicalTop) % pageLogicalHeight;6676 return cumulativeOffset - roundToInt(cumulativeOffset - firstPageLogicalTop) % roundToInt(pageLogicalHeight); 6677 6677 } 6678 6678 return enclosingRenderFlowThread()->regionLogicalTopForLine(cumulativeOffset); -
trunk/Source/WebCore/rendering/RenderBlock.h
r109367 r109378 183 183 int pixelSnappedLogicalLeftOffsetForLine(LayoutUnit position, bool firstLine) const 184 184 { 185 return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), firstLine, 0);185 return roundToInt(logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(position), firstLine, 0)); 186 186 } 187 187 … … 637 637 LayoutUnit logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); } 638 638 639 // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318.640 int pixelSnappedLogical TopForFloat(const FloatingObject* child) const { return logicalTopForFloat(child); }641 int pixelSnappedLogical BottomForFloat(const FloatingObject* child) const { return logicalBottomForFloat(child); }642 int pixelSnappedLogical LeftForFloat(const FloatingObject* child) const { return logicalLeftForFloat(child); }643 int pixelSnappedLogical RightForFloat(const FloatingObject* child) const { return logicalRightForFloat(child); }639 int pixelSnappedLogicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->pixelSnappedY() : child->pixelSnappedX(); } 640 int pixelSnappedLogicalBottomForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->pixelSnappedMaxY() : child->pixelSnappedMaxX(); } 641 int pixelSnappedLogicalLeftForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->pixelSnappedX() : child->pixelSnappedY(); } 642 int pixelSnappedLogicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->pixelSnappedMaxX() : child->pixelSnappedMaxY(); } 643 int pixelSnappedLogicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->pixelSnappedWidth() : child->pixelSnappedHeight(); } 644 644 645 645 void setLogicalTopForFloat(FloatingObject* child, LayoutUnit logicalTop) -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r109104 r109378 115 115 inline void LineWidth::updateAvailableWidth() 116 116 { 117 int height = m_block->logicalHeight();118 m_left = m_block-> logicalLeftOffsetForLine(height, m_isFirstLine);119 m_right = m_block-> logicalRightOffsetForLine(height, m_isFirstLine);117 LayoutUnit height = m_block->logicalHeight(); 118 m_left = m_block->pixelSnappedLogicalLeftOffsetForLine(height, m_isFirstLine); 119 m_right = m_block->pixelSnappedLogicalRightOffsetForLine(height, m_isFirstLine); 120 120 121 121 computeAvailableWidthFromLeftAndRight(); … … 760 760 { 761 761 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWithBreak()); 762 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), lineInfo.isFirstLine());763 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), lineInfo.isFirstLine()) - logicalLeft;762 float logicalLeft = pixelSnappedLogicalLeftOffsetForLine(logicalHeight(), lineInfo.isFirstLine()); 763 float availableLogicalWidth = pixelSnappedLogicalRightOffsetForLine(logicalHeight(), lineInfo.isFirstLine()) - logicalLeft; 764 764 765 765 bool needsWordSpacing = false; -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r109367 r109378 61 61 virtual LayoutUnit offsetHeight() const = 0; 62 62 63 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } 64 int pixelSnappedOffsetTop() const { return roundToInt(offsetTop()); } 63 65 // FIXME: The implementation for these functions will change once we move to subpixel layout. See bug 60318. 64 int pixelSnappedOffsetLeft() const { return offsetLeft(); }65 int pixelSnappedOffsetTop() const { return offsetTop(); }66 66 int pixelSnappedOffsetWidth() const; 67 67 int pixelSnappedOffsetHeight() const; -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r109125 r109378 1548 1548 LayoutRect r = getRectToExpose(layerBounds, exposeRect, alignX, alignY); 1549 1549 1550 LayoutUnit xOffset= r.x() - absPos.x();1551 LayoutUnit yOffset= r.y() - absPos.y();1550 LayoutUnit adjustedX = r.x() - absPos.x(); 1551 LayoutUnit adjustedY = r.y() - absPos.y(); 1552 1552 // Adjust offsets if they're outside of the allowable range. 1553 xOffset = max<LayoutUnit>(0, min(scrollWidth() - layerBounds.width(), xOffset)); 1554 yOffset = max<LayoutUnit>(0, min(scrollHeight() - layerBounds.height(), yOffset)); 1553 adjustedX = max<LayoutUnit>(0, min(scrollWidth() - layerBounds.width(), adjustedX)); 1554 adjustedY = max<LayoutUnit>(0, min(scrollHeight() - layerBounds.height(), adjustedY)); 1555 1556 int xOffset = roundToInt(adjustedX); 1557 int yOffset = roundToInt(adjustedY); 1555 1558 1556 1559 if (xOffset != scrollXOffset() || yOffset != scrollYOffset()) { … … 1579 1582 LayoutRect exposeRect = getRectToExpose(viewRect, rect, alignX, alignY); 1580 1583 1581 LayoutUnit xOffset = exposeRect.x();1582 LayoutUnit yOffset = exposeRect.y();1584 int xOffset = roundToInt(exposeRect.x()); 1585 int yOffset = roundToInt(exposeRect.y()); 1583 1586 // Adjust offsets if they're outside of the allowable range. 1584 1587 xOffset = max<LayoutUnit>(0, min(frameView->contentsWidth(), xOffset)); -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r107880 r109378 652 652 int RenderListBox::scrollHeight() const 653 653 { 654 return max(pixelSnappedClientHeight(), listHeight());654 return max(pixelSnappedClientHeight(), roundToInt(listHeight())); 655 655 } 656 656 -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r109273 r109378 337 337 m_localToParentTransform = m_localToBorderBoxTransform; 338 338 if (x()) 339 m_localToParentTransform.setE(m_localToParentTransform.e() + x());339 m_localToParentTransform.setE(m_localToParentTransform.e() + roundToInt(x())); 340 340 if (y()) 341 m_localToParentTransform.setF(m_localToParentTransform.f() + y());341 m_localToParentTransform.setF(m_localToParentTransform.f() + roundToInt(y())); 342 342 return m_localToParentTransform; 343 343 } -
trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp
r108699 r109378 112 112 if (shadow) { 113 113 paintInfo.context->clip(repaintRect); 114 paintInfo.context->setShadow(IntSize( shadow->x(), shadow->y()), shadow->blur(), shadow->color(), style->colorSpace());114 paintInfo.context->setShadow(IntSize(roundToInt(shadow->x()), roundToInt(shadow->y())), shadow->blur(), shadow->color(), style->colorSpace()); 115 115 paintInfo.context->beginTransparencyLayer(1); 116 116 }
Note: See TracChangeset
for help on using the changeset viewer.