Changeset 112977 in webkit


Ignore:
Timestamp:
Apr 2, 2012 7:44:44 PM (12 years ago)
Author:
eae@chromium.org
Message:

Fix usage of LayoutUnits and pixel snapping in RenderLayer
https://bugs.webkit.org/show_bug.cgi?id=82498

Reviewed by Julien Chaffraix.

Fix usage of subpixel types and snapping/rounding in RenderLayer in
preparation for turning on subpixel layout.

No new tests, no change in functionality.

  • rendering/LayoutTypes.h:

(WebCore::pixelSnappedIntSize):
Add no-op implementation of pixelSnappedIntSize, will be replaced with a
real implementation once we make the switch.

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateLayerPosition):
Snap RenderBox size when updating the size of the layer.

(WebCore::RenderLayer::resize):
Round position when setting the inline style during resize operation.

(WebCore::RenderLayer::scrollCornerRect):
Remove unnecessary pixelSnappedIntRect call.

(WebCore::RenderLayer::positionOverflowControls):
Remove unnecessary pixelSnappedIntRect call.

(WebCore::RenderLayer::scrollWidth):
(WebCore::RenderLayer::scrollHeight):
Fix implementation of scrollWidth and Height to pixel snap the values.

(WebCore::RenderLayer::computeScrollDimensions):
(WebCore::RenderLayer::paintResizer):
(WebCore::RenderLayer::hitTestOverflowControls):
Remove unnecessary pixelSnappedIntRect calls.

(WebCore::RenderLayer::paintLayerContents):
Pixel snap values just before painting (instead of earlier on).

(WebCore::RenderLayer::hitTest):
(WebCore::RenderLayer::hitTestContents):
Change to use subpixel types.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112973 r112977  
     12012-04-02  Emil A Eklund  <eae@chromium.org>
     2
     3        Fix usage of LayoutUnits and pixel snapping in RenderLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=82498
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Fix usage of subpixel types and snapping/rounding in RenderLayer in
     9        preparation for turning on subpixel layout.
     10
     11        No new tests, no change in functionality.
     12
     13        * rendering/LayoutTypes.h:
     14        (WebCore::pixelSnappedIntSize):
     15        Add no-op implementation of pixelSnappedIntSize, will be replaced with a
     16        real implementation once we make the switch.
     17       
     18        * rendering/RenderLayer.cpp:
     19        (WebCore::RenderLayer::updateLayerPosition):
     20        Snap RenderBox size when updating the size of the layer.
     21       
     22        (WebCore::RenderLayer::resize):
     23        Round position when setting the inline style during resize operation.
     24
     25        (WebCore::RenderLayer::scrollCornerRect):
     26        Remove unnecessary pixelSnappedIntRect call.
     27       
     28        (WebCore::RenderLayer::positionOverflowControls):
     29        Remove unnecessary pixelSnappedIntRect call.
     30       
     31        (WebCore::RenderLayer::scrollWidth):
     32        (WebCore::RenderLayer::scrollHeight):
     33        Fix implementation of scrollWidth and Height to pixel snap the values.
     34         
     35        (WebCore::RenderLayer::computeScrollDimensions):
     36        (WebCore::RenderLayer::paintResizer):
     37        (WebCore::RenderLayer::hitTestOverflowControls):
     38        Remove unnecessary pixelSnappedIntRect calls.
     39       
     40        (WebCore::RenderLayer::paintLayerContents):
     41        Pixel snap values just before painting (instead of earlier on).
     42
     43        (WebCore::RenderLayer::hitTest):
     44        (WebCore::RenderLayer::hitTestContents):
     45        Change to use subpixel types.
     46
    1472012-04-02  Abhishek Arya  <inferno@chromium.org>
    248
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r110983 r112977  
    7676
    7777inline int snapSizeToPixel(LayoutUnit size, LayoutUnit location)
     78{
     79    UNUSED_PARAM(location);
     80    return size;
     81}
     82
     83inline IntSize pixelSnappedIntSize(LayoutSize size, LayoutPoint location)
    7884{
    7985    UNUSED_PARAM(location);
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r112919 r112977  
    766766        localPoint += inlineBoundingBoxOffset;
    767767    } else if (RenderBox* box = renderBox()) {
    768         setSize(box->size());
     768        // FIXME: Is snapping the size really needed here for the RenderBox case?
     769        setSize(pixelSnappedIntSize(box->size(), box->location()));
    769770        localPoint += box->topLeftLocationOffset();
    770771    }
     
    18571858        LayoutUnit baseWidth = renderer->width() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingWidth());
    18581859        baseWidth = baseWidth / zoomFactor;
    1859         styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(baseWidth + difference.width()) + "px", false);
     1860        styledElement->setInlineStyleProperty(CSSPropertyWidth, String::number(roundToInt(baseWidth + difference.width())) + "px", false);
    18601861    }
    18611862
     
    18681869        LayoutUnit baseHeight = renderer->height() - (isBoxSizingBorder ? zeroLayoutUnit : renderer->borderAndPaddingHeight());
    18691870        baseHeight = baseHeight / zoomFactor;
    1870         styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(baseHeight + difference.height()) + "px", false);
     1871        styledElement->setInlineStyleProperty(CSSPropertyHeight, String::number(roundToInt(baseHeight + difference.height())) + "px", false);
    18711872    }
    18721873
     
    19781979    bool hasResizer = renderer()->style()->resize() != RESIZE_NONE;
    19791980    if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
    1980         return cornerRect(this, pixelSnappedIntRect(renderBox()->borderBoxRect()));
     1981        return cornerRect(this, renderBox()->borderBoxRect());
    19811982    return IntRect();
    19821983}
     
    23022303        return;
    23032304
    2304     const IntRect borderBox = pixelSnappedIntRect(box->borderBoxRect());
     2305    const IntRect borderBox = box->borderBoxRect();
    23052306    const IntRect& scrollCorner = scrollCornerRect();
    23062307    IntRect absBounds(borderBox.location() + offsetFromLayer, borderBox.size());
     
    23492350int RenderLayer::scrollWidth()
    23502351{
     2352    ASSERT(renderBox());
    23512353    if (m_scrollDimensionsDirty)
    23522354        computeScrollDimensions();
    2353     return m_scrollSize.width();
     2355    return snapSizeToPixel(m_scrollSize.width(), renderBox()->clientLeft());
    23542356}
    23552357
    23562358int RenderLayer::scrollHeight()
    23572359{
     2360    ASSERT(renderBox());
    23582361    if (m_scrollDimensionsDirty)
    23592362        computeScrollDimensions();
    2360     return m_scrollSize.height();
     2363    return snapSizeToPixel(m_scrollSize.height(), renderBox()->clientTop());
    23612364}
    23622365
     
    24052408    m_scrollSize.setWidth(overflowRight() - overflowLeft());
    24062409    m_scrollSize.setHeight(overflowBottom() - overflowTop());
    2407    
     2410
    24082411    setScrollOrigin(IntPoint(-m_scrollOverflow.width(), -m_scrollOverflow.height()));
    24092412
     
    26342637    ASSERT(box);
    26352638
    2636     IntRect absRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
     2639    IntRect absRect = resizerCornerRect(this, box->borderBoxRect());
    26372640    absRect.moveBy(paintOffset);
    26382641    if (!absRect.intersects(damageRect))
     
    26892692    IntRect resizeControlRect;
    26902693    if (renderer()->style()->resize() != RESIZE_NONE) {
    2691         resizeControlRect = resizerCornerRect(this, pixelSnappedIntRect(box->borderBoxRect()));
     2694        resizeControlRect = resizerCornerRect(this, box->borderBoxRect());
    26922695        if (resizeControlRect.contains(localPoint))
    26932696            return true;
     
    30203023           
    30213024            // Paint the background.
    3022             PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
     3025            PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseBlockBackground, false, paintingRootForRenderer, region, 0);
    30233026            renderer()->paint(paintInfo, paintOffset);
    30243027
     
    30453048            }
    30463049           
    3047             PaintInfo paintInfo(context, clipRectToApply.rect(),
     3050            PaintInfo paintInfo(context, pixelSnappedIntRect(clipRectToApply.rect()),
    30483051                                selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
    30493052                                forceBlackText, paintingRootForRenderer, region, 0);
     
    30673070        if (shouldPaintOutline && !outlineRect.isEmpty()) {
    30683071            // Paint our own outline
    3069             PaintInfo paintInfo(context, outlineRect.rect(), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
     3072            PaintInfo paintInfo(context, pixelSnappedIntRect(outlineRect.rect()), PaintPhaseSelfOutline, false, paintingRootForRenderer, region, 0);
    30703073            clipToRect(rootLayer, context, paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
    30713074            renderer()->paint(paintInfo, paintOffset);
     
    30853088
    30863089        // Paint the mask.
    3087         PaintInfo paintInfo(context, damageRect.rect(), PaintPhaseMask, false, paintingRootForRenderer, region, 0);
     3090        PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseMask, false, paintingRootForRenderer, region, 0);
    30883091        renderer()->paint(paintInfo, paintOffset);
    30893092       
     
    32673270    renderer()->document()->updateLayout();
    32683271   
    3269     IntRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();
     3272    LayoutRect hitTestArea = renderer()->isRenderFlowThread() ? toRenderFlowThread(renderer())->borderBoxRect() : renderer()->view()->documentRect();
    32703273    if (!request.ignoreClipping())
    3271         hitTestArea.intersect(pixelSnappedIntRect(frameVisibleRect(renderer())));
     3274        hitTestArea.intersect(frameVisibleRect(renderer()));
    32723275
    32733276    RenderLayer* insideLayer = hitTestLayer(this, 0, request, result, hitTestArea, result.point(), false);
     
    35593562{
    35603563    if (!renderer()->hitTest(request, result, hitTestPoint,
    3561                             toPoint(layerBounds.location() - renderBoxLocation()),
     3564                            toLayoutPoint(layerBounds.location() - renderBoxLocation()),
    35623565                            hitTestFilter)) {
    35633566        // It's wrong to set innerNode, but then claim that you didn't hit anything, unless it is
Note: See TracChangeset for help on using the changeset viewer.