Changeset 99019 in webkit


Ignore:
Timestamp:
Nov 1, 2011 5:55:49 PM (12 years ago)
Author:
eae@chromium.org
Message:

Switch background/border image back to Int
https://bugs.webkit.org/show_bug.cgi?id=71240

Reviewed by Darin Adler.

Switch background- and border-image rendering back to int to align with
device pixels.

No new tests.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
(WebCore::calculateAdjustedInnerBorder):

  • rendering/RenderBoxModelObject.h:

(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99018 r99019  
     12011-11-01  Emil A Eklund  <eae@chromium.org>
     2
     3        Switch background/border image back to Int
     4        https://bugs.webkit.org/show_bug.cgi?id=71240
     5
     6        Reviewed by Darin Adler.
     7
     8        Switch background- and border-image rendering back to int to align with
     9        device pixels.
     10
     11        No new tests.
     12
     13        * rendering/RenderBoxModelObject.cpp:
     14        (WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
     15        (WebCore::RenderBoxModelObject::calculateFillTileSize):
     16        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment):
     17        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip):
     18        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase):
     19        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
     20        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     21        (WebCore::calculateAdjustedInnerBorder):
     22        * rendering/RenderBoxModelObject.h:
     23        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin):
     24        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin):
     25        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect):
     26        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect):
     27        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase):
     28        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase):
     29        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize):
     30        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize):
     31
    1322011-11-01  Mark Hahnenberg  <mhahnenberg@apple.com>
    233
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r98852 r99019  
    834834}
    835835
    836 LayoutSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const LayoutSize& positioningAreaSize) const
    837 {
    838     LayoutUnit resolvedWidth = 0;
    839     LayoutUnit resolvedHeight = 0;
     836IntSize RenderBoxModelObject::calculateImageIntrinsicDimensions(StyleImage* image, const IntSize& positioningAreaSize) const
     837{
     838    int resolvedWidth = 0;
     839    int resolvedHeight = 0;
    840840    FloatSize intrinsicRatio;
    841841
     
    851851        // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
    852852        if (intrinsicWidth.isFixed())
    853             resolvedWidth = static_cast<LayoutUnit>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
     853            resolvedWidth = static_cast<int>(ceilf(intrinsicWidth.value() * style()->effectiveZoom()));
    854854        if (intrinsicHeight.isFixed())
    855             resolvedHeight = static_cast<LayoutUnit>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
     855            resolvedHeight = static_cast<int>(ceilf(intrinsicHeight.value() * style()->effectiveZoom()));
    856856    }
    857857
     
    860860    // _explicitely_ says that percentage values for the width/height attributes do NOT define intrinsic dimensions.
    861861    if (resolvedWidth > 0 && resolvedHeight > 0)
    862         return LayoutSize(resolvedWidth, resolvedHeight);
     862        return IntSize(resolvedWidth, resolvedHeight);
    863863
    864864    // If the image has one of either an intrinsic width or an intrinsic height:
     
    880880}
    881881
    882 LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const LayoutSize& positioningAreaSize) const
     882IntSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLayer, const IntSize& positioningAreaSize) const
    883883{
    884884    StyleImage* image = fillLayer->image();
    885885    EFillSizeType type = fillLayer->size().type;
    886886
    887     LayoutSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
     887    IntSize imageIntrinsicSize = calculateImageIntrinsicDimensions(image, positioningAreaSize);
    888888
    889889    switch (type) {
    890890        case SizeLength: {
    891             LayoutUnit w = positioningAreaSize.width();
    892             LayoutUnit h = positioningAreaSize.height();
     891            int w = positioningAreaSize.width();
     892            int h = positioningAreaSize.height();
    893893
    894894            Length layerWidth = fillLayer->size().size.width();
     
    919919            }
    920920           
    921             return LayoutSize(max<LayoutUnit>(1, w), max<LayoutUnit>(1, h));
     921            return IntSize(max(1, w), max(1, h));
    922922        }
    923923        case SizeNone: {
     
    936936                ? static_cast<float>(positioningAreaSize.height()) / imageIntrinsicSize.height() : 1;
    937937            float scaleFactor = type == Contain ? min(horizontalScaleFactor, verticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor);
    938             return LayoutSize(max<LayoutUnit>(1, imageIntrinsicSize.width() * scaleFactor), max<LayoutUnit>(1, imageIntrinsicSize.height() * scaleFactor));
     938            return IntSize(max(1, static_cast<int>(imageIntrinsicSize.width() * scaleFactor)), max(1, static_cast<int>(imageIntrinsicSize.height() * scaleFactor)));
    939939       }
    940940    }
    941941
    942942    ASSERT_NOT_REACHED();
    943     return LayoutSize();
     943    return IntSize();
    944944}
    945945
     
    957957}
    958958
    959 void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
    960 {
    961     m_phase.move(max<LayoutUnit>(attachmentPoint.x() - m_destRect.x(), 0), max<LayoutUnit>(attachmentPoint.y() - m_destRect.y(), 0));
    962 }
    963 
    964 void RenderBoxModelObject::BackgroundImageGeometry::clip(const LayoutRect& clipRect)
     959void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const IntPoint& attachmentPoint)
     960{
     961    IntPoint alignedPoint = attachmentPoint;
     962    m_phase.move(max(alignedPoint.x() - m_destRect.x(), 0), max(alignedPoint.y() - m_destRect.y(), 0));
     963}
     964
     965void RenderBoxModelObject::BackgroundImageGeometry::clip(const IntRect& clipRect)
    965966{
    966967    m_destRect.intersect(clipRect);
    967968}
    968969
    969 LayoutPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
    970 {
    971     LayoutPoint phase = m_phase;
     970IntPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
     971{
     972    IntPoint phase = m_phase;
    972973    phase += m_destRect.location() - m_destOrigin;
    973974    return phase;
     
    979980    LayoutUnit left = 0;
    980981    LayoutUnit top = 0;
    981     LayoutSize positioningAreaSize;
     982    IntSize positioningAreaSize;
    982983
    983984    // Determine the background positioning area and set destRect to the background painting area.
     
    10281029    }
    10291030
    1030     LayoutSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
     1031    IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
    10311032    fillLayer->image()->setContainerSizeForRenderer(this, fillTileSize, style()->effectiveZoom());
    10321033    geometry.setTileSize(fillTileSize);
     
    10371038    LayoutUnit xPosition = fillLayer->xPosition().calcMinValue(positioningAreaSize.width() - geometry.tileSize().width(), true);
    10381039    if (backgroundRepeatX == RepeatFill)
    1039         geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : 0);
     1040        geometry.setPhaseX(geometry.tileSize().width() ? layoutMod(geometry.tileSize().width() - (xPosition + left), geometry.tileSize().width()) : LayoutUnit(0));
    10401041    else
    10411042        geometry.setNoRepeatX(xPosition + left);
     
    10431044    LayoutUnit yPosition = fillLayer->yPosition().calcMinValue(positioningAreaSize.height() - geometry.tileSize().height(), true);
    10441045    if (backgroundRepeatY == RepeatFill)
    1045         geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : 0);
     1046        geometry.setPhaseY(geometry.tileSize().height() ? layoutMod(geometry.tileSize().height() - (yPosition + top), geometry.tileSize().height()) : LayoutUnit(0));
    10461047    else
    10471048        geometry.setNoRepeatY(yPosition + top);
     
    10901091    LayoutRect borderImageRect = LayoutRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
    10911092
    1092     LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
     1093    IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size());
    10931094
    10941095    // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
    1095     LayoutSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
     1096    IntSize containerSize = imageSize.isEmpty() ? borderImageRect.size() : imageSize;
    10961097    styleImage->setContainerSizeForRenderer(this, containerSize, style->effectiveZoom());
    10971098
    1098     LayoutUnit imageWidth = imageSize.width();
    1099     LayoutUnit imageHeight = imageSize.height();
    1100 
    1101     LayoutUnit topSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
    1102     LayoutUnit rightSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
    1103     LayoutUnit bottomSlice = min<LayoutUnit>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
    1104     LayoutUnit leftSlice = min<LayoutUnit>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
     1099    int imageWidth = imageSize.width();
     1100    int imageHeight = imageSize.height();
     1101
     1102    int topSlice = min<int>(imageHeight, ninePieceImage.imageSlices().top().calcValue(imageHeight));
     1103    int rightSlice = min<int>(imageWidth, ninePieceImage.imageSlices().right().calcValue(imageWidth));
     1104    int bottomSlice = min<int>(imageHeight, ninePieceImage.imageSlices().bottom().calcValue(imageHeight));
     1105    int leftSlice = min<int>(imageWidth, ninePieceImage.imageSlices().left().calcValue(imageWidth));
    11051106
    11061107    ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
     
    11161117    // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f < 1, then all W are reduced by
    11171118    // multiplying them by f.
    1118     int borderSideWidth = max(1, leftWidth + rightWidth);
    1119     int borderSideHeight = max(1, topWidth + bottomWidth);
     1119    LayoutUnit borderSideWidth = max<LayoutUnit>(1, leftWidth + rightWidth);
     1120    LayoutUnit borderSideHeight = max<LayoutUnit>(1, topWidth + bottomWidth);
    11201121    float borderSideScaleFactor = min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight);
    11211122    if (borderSideScaleFactor < 1) {
     
    11641165        // Paint the left edge.
    11651166        // Have to scale and tile into the border rect.
    1166         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
     1167        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
    11671168                                        destinationHeight),
    1168                                         LayoutRect(0, topSlice, leftSlice, sourceHeight),
     1169                                        IntRect(0, topSlice, leftSlice, sourceHeight),
    11691170                                        FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
    11701171    }
     
    11851186
    11861187        // Paint the right edge.
    1187         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
     1188        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
    11881189                                        destinationHeight),
    1189                                         LayoutRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
     1190                                        IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
    11901191                                        FloatSize(rightSideScale, rightSideScale),
    11911192                                        Image::StretchTile, (Image::TileRule)vRule, op);
     
    11941195    // Paint the top edge.
    11951196    if (drawTop)
    1196         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
    1197                                         LayoutRect(leftSlice, 0, sourceWidth, topSlice),
     1197        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
     1198                                        IntRect(leftSlice, 0, sourceWidth, topSlice),
    11981199                                        FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
    11991200
    12001201    // Paint the bottom edge.
    12011202    if (drawBottom)
    1202         graphicsContext->drawTiledImage(image.get(), colorSpace, LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
     1203        graphicsContext->drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
    12031204                                        destinationWidth, bottomWidth),
    1204                                         LayoutRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
     1205                                        IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
    12051206                                        FloatSize(bottomSideScale, bottomSideScale),
    12061207                                        (Image::TileRule)hRule, Image::StretchTile, op);
     
    12291230       
    12301231        graphicsContext->drawTiledImage(image.get(), colorSpace,
    1231             LayoutRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
    1232             LayoutRect(leftSlice, topSlice, sourceWidth, sourceHeight),
     1232            IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
     1233            IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
    12331234            middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op);
    12341235    }
     
    23472348    // for an edge is zero, so we can shift the arc towards the zero radius corner.
    23482349    RoundedRect::Radii newRadii = innerBorder.radii();
    2349     LayoutRect newRect = innerBorder.rect();
     2350    IntRect newRect = innerBorder.rect();
    23502351
    23512352    float overshoot;
     
    23612362                newRect.move(-overshoot, 0);
    23622363        }
    2363         newRadii.setBottomLeft(LayoutSize(0, 0));
    2364         newRadii.setBottomRight(LayoutSize(0, 0));
    2365         maxRadii = max<LayoutUnit>(newRadii.topLeft().height(), newRadii.topRight().height());
     2364        newRadii.setBottomLeft(IntSize(0, 0));
     2365        newRadii.setBottomRight(IntSize(0, 0));
     2366        maxRadii = max(newRadii.topLeft().height(), newRadii.topRight().height());
    23662367        if (maxRadii > newRect.height())
    23672368            newRect.setHeight(maxRadii);
     
    23762377                newRect.move(-overshoot, 0);
    23772378        }
    2378         newRadii.setTopLeft(LayoutSize(0, 0));
    2379         newRadii.setTopRight(LayoutSize(0, 0));
    2380         maxRadii = max<LayoutUnit>(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
     2379        newRadii.setTopLeft(IntSize(0, 0));
     2380        newRadii.setTopRight(IntSize(0, 0));
     2381        maxRadii = max(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
    23812382        if (maxRadii > newRect.height()) {
    23822383            newRect.move(0, newRect.height() - maxRadii);
     
    23932394                newRect.move(0, -overshoot);
    23942395        }
    2395         newRadii.setTopRight(LayoutSize(0, 0));
    2396         newRadii.setBottomRight(LayoutSize(0, 0));
    2397         maxRadii = max<LayoutUnit>(newRadii.topLeft().width(), newRadii.bottomLeft().width());
     2396        newRadii.setTopRight(IntSize(0, 0));
     2397        newRadii.setBottomRight(IntSize(0, 0));
     2398        maxRadii = max(newRadii.topLeft().width(), newRadii.bottomLeft().width());
    23982399        if (maxRadii > newRect.width())
    23992400            newRect.setWidth(maxRadii);
     
    24082409                newRect.move(0, -overshoot);
    24092410        }
    2410         newRadii.setTopLeft(LayoutSize(0, 0));
    2411         newRadii.setBottomLeft(LayoutSize(0, 0));
    2412         maxRadii = max<LayoutUnit>(newRadii.topRight().width(), newRadii.bottomRight().width());
     2411        newRadii.setTopLeft(IntSize(0, 0));
     2412        newRadii.setBottomLeft(IntSize(0, 0));
     2413        maxRadii = max(newRadii.topRight().width(), newRadii.bottomRight().width());
    24132414        if (maxRadii > newRect.width()) {
    24142415            newRect.move(newRect.width() - maxRadii, 0);
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r98852 r99019  
    138138    class BackgroundImageGeometry {
    139139    public:
    140         LayoutPoint destOrigin() const { return m_destOrigin; }
    141         void setDestOrigin(const LayoutPoint& destOrigin)
     140        IntPoint destOrigin() const { return m_destOrigin; }
     141        void setDestOrigin(const IntPoint& destOrigin)
    142142        {
    143143            m_destOrigin = destOrigin;
    144144        }
    145145       
    146         LayoutRect destRect() const { return m_destRect; }
    147         void setDestRect(const LayoutRect& destRect)
     146        IntRect destRect() const { return m_destRect; }
     147        void setDestRect(const IntRect& destRect)
    148148        {
    149149            m_destRect = destRect;
     
    151151
    152152        // Returns the phase relative to the destination rectangle.
    153         LayoutPoint relativePhase() const;
    154        
    155         LayoutPoint phase() const { return m_phase; }   
    156         void setPhase(const LayoutPoint& phase)
     153        IntPoint relativePhase() const;
     154       
     155        IntPoint phase() const { return m_phase; }   
     156        void setPhase(const IntPoint& phase)
    157157        {
    158158            m_phase = phase;
    159159        }
    160160
    161         LayoutSize tileSize() const { return m_tileSize; }   
    162         void setTileSize(const LayoutSize& tileSize)
     161        IntSize tileSize() const { return m_tileSize; }   
     162        void setTileSize(const IntSize& tileSize)
    163163        {
    164164            m_tileSize = tileSize;
     
    171171        void setNoRepeatY(int yOffset);
    172172       
    173         void useFixedAttachment(const LayoutPoint& attachmentPoint);
    174        
    175         void clip(const LayoutRect&);
     173        void useFixedAttachment(const IntPoint& attachmentPoint);
     174       
     175        void clip(const IntRect&);
    176176    private:
    177         LayoutRect m_destRect;
    178         LayoutPoint m_destOrigin;
    179         LayoutPoint m_phase;
    180         LayoutSize m_tileSize;
     177        IntRect m_destRect;
     178        IntPoint m_destOrigin;
     179        IntPoint m_phase;
     180        IntSize m_tileSize;
    181181    };
    182182
     
    196196    virtual bool isBoxModelObject() const { return true; }
    197197
    198     LayoutSize calculateFillTileSize(const FillLayer*, const LayoutSize& scaledPositioningAreaSize) const;
    199     LayoutSize calculateImageIntrinsicDimensions(StyleImage*, const LayoutSize& scaledPositioningAreaSize) const;
     198    IntSize calculateFillTileSize(const FillLayer*, const IntSize& scaledPositioningAreaSize) const;
     199    IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaledPositioningAreaSize) const;
    200200
    201201    RoundedRect getBackgroundRoundedRect(const LayoutRect&, InlineFlowBox*, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
Note: See TracChangeset for help on using the changeset viewer.