Changeset 122641 in webkit


Ignore:
Timestamp:
Jul 13, 2012 4:23:40 PM (12 years ago)
Author:
eae@chromium.org
Message:

Use LayoutBoxExtent for image outsets
https://bugs.webkit.org/show_bug.cgi?id=91166

Reviewed by Tony Chang.

Change RenderStyle and calling code to use LayoutBoxExtent for image
outsets and remove text direction and writing mode versions of the
outline getters from RenderStyle as LayoutBoxExtent provides the same
functionality.

No new tests, no change in functionality.

  • platform/graphics/FractionalLayoutBoxExtent.h:
  • platform/graphics/FractionalLayoutBoxExtent.cpp:

(WebCore::FractionalLayoutBoxExtent::logicalTop):
(WebCore::FractionalLayoutBoxExtent::logicalBottom):
Add logicalTop and logicalBottom methods to go with the existing
logicalLeft and logicalRight ones.

  • platform/graphics/FractionalLayoutRect.h:

(WebCore::FractionalLayoutRect::expand):
Add FractionalLayoutBoxExtent version of expand method.

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::addBorderOutsetVisualOverflow):
Change implementation to use the new FractionalLayoutBoxExtent version of
borderImageOutsets and the logicalTop/Bottom/Left/Right methods.

(WebCore::clipRectForNinePieceImageStrip):
Change implementation to use the new FractionalLayoutBoxExtent version of
borderImageOutsets.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::maskClipRect):
Change implementation to use the new FractionalLayoutBoxExtent version of
borderImageOutsets and the new FractionalLayoutRect::expand method.

(WebCore::RenderBox::addVisualEffectOverflow):
Change implementation to use the new FractionalLayoutBoxExtent version of
borderImageOutsets.

  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintNinePieceImage):
Change implementation to use the new FractionalLayoutBoxExtent version of
borderImageOutsets and the new FractionalLayoutRect::expand method.

  • rendering/style/RenderStyle.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::imageOutsets):
Change getImageOutsets to return a FractionalLayoutBoxExtent object and
rename to imageOutsets to match the webkit naming convention for getters.

Remove getBorderImageHorizontalOutsets, getBorderImageVerticalOutsets,
getBorderImageInlineDirectionOutsets, getImageHorizontalOutsets,
getImageVerticalOutsets and getBorderImageBlockDirectionOutsets methods
as the same functionality is provided by FractionalLayoutBoxExtent.

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122639 r122641  
     12012-07-13  Emil A Eklund  <eae@chromium.org>
     2
     3        Use LayoutBoxExtent for image outsets
     4        https://bugs.webkit.org/show_bug.cgi?id=91166
     5
     6        Reviewed by Tony Chang.
     7
     8        Change RenderStyle and calling code to use LayoutBoxExtent for image
     9        outsets and remove text direction and writing mode versions of the
     10        outline getters from RenderStyle as LayoutBoxExtent provides the same
     11        functionality.
     12
     13        No new tests, no change in functionality.
     14
     15        * platform/graphics/FractionalLayoutBoxExtent.h:
     16        * platform/graphics/FractionalLayoutBoxExtent.cpp:
     17        (WebCore::FractionalLayoutBoxExtent::logicalTop):
     18        (WebCore::FractionalLayoutBoxExtent::logicalBottom):
     19        Add logicalTop and logicalBottom methods to go with the existing
     20        logicalLeft and logicalRight ones.
     21
     22        * platform/graphics/FractionalLayoutRect.h:
     23        (WebCore::FractionalLayoutRect::expand):
     24        Add FractionalLayoutBoxExtent version of expand method.
     25
     26        * rendering/InlineFlowBox.cpp:
     27        (WebCore::InlineFlowBox::addBorderOutsetVisualOverflow):
     28        Change implementation to use the new FractionalLayoutBoxExtent version of
     29        borderImageOutsets and the logicalTop/Bottom/Left/Right methods.
     30       
     31        (WebCore::clipRectForNinePieceImageStrip):
     32        Change implementation to use the new FractionalLayoutBoxExtent version of
     33        borderImageOutsets.
     34       
     35        * rendering/RenderBox.cpp:
     36        (WebCore::RenderBox::maskClipRect):
     37        Change implementation to use the new FractionalLayoutBoxExtent version of
     38        borderImageOutsets and the new FractionalLayoutRect::expand method.
     39       
     40        (WebCore::RenderBox::addVisualEffectOverflow):
     41        Change implementation to use the new FractionalLayoutBoxExtent version of
     42        borderImageOutsets.
     43       
     44        * rendering/RenderBoxModelObject.cpp:
     45        (WebCore::RenderBoxModelObject::paintNinePieceImage):
     46        Change implementation to use the new FractionalLayoutBoxExtent version of
     47        borderImageOutsets and the new FractionalLayoutRect::expand method.
     48
     49        * rendering/style/RenderStyle.h:
     50        * rendering/style/RenderStyle.cpp:
     51        (WebCore::RenderStyle::imageOutsets):
     52        Change getImageOutsets to return a FractionalLayoutBoxExtent object and
     53        rename to imageOutsets to match the webkit naming convention for getters.
     54
     55        Remove getBorderImageHorizontalOutsets, getBorderImageVerticalOutsets,
     56        getBorderImageInlineDirectionOutsets, getImageHorizontalOutsets,
     57        getImageVerticalOutsets and getBorderImageBlockDirectionOutsets methods
     58        as the same functionality is provided by FractionalLayoutBoxExtent.
     59
    1602012-07-13  David Hyatt  <hyatt@apple.com>
    261
  • trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.cpp

    r118076 r122641  
    3535
    3636namespace WebCore {
     37
     38FractionalLayoutUnit FractionalLayoutBoxExtent::logicalTop(const RenderStyle* style) const
     39{
     40    return style->isHorizontalWritingMode() ? m_top : m_left;
     41}
     42
     43FractionalLayoutUnit FractionalLayoutBoxExtent::logicalBottom(const RenderStyle* style) const
     44{
     45    return style->isHorizontalWritingMode() ? m_bottom : m_right;
     46}
    3747
    3848FractionalLayoutUnit FractionalLayoutBoxExtent::logicalLeft(const RenderStyle* style) const
  • trunk/Source/WebCore/platform/graphics/FractionalLayoutBoxExtent.h

    r118076 r122641  
    5454    inline void setLeft(FractionalLayoutUnit value) { m_left = value; }
    5555
     56    FractionalLayoutUnit logicalTop(const RenderStyle*) const;
     57    FractionalLayoutUnit logicalBottom(const RenderStyle*) const;
    5658    FractionalLayoutUnit logicalLeft(const RenderStyle*) const;
    5759    FractionalLayoutUnit logicalRight(const RenderStyle*) const;
  • trunk/Source/WebCore/platform/graphics/FractionalLayoutRect.h

    r116767 r122641  
    3232#define FractionalLayoutRect_h
    3333
     34#include "FractionalLayoutBoxExtent.h"
    3435#include "FractionalLayoutPoint.h"
    3536#include "IntRect.h"
     
    100101
    101102    void expand(const FractionalLayoutSize& size) { m_size += size; }
     103    void expand(const FractionalLayoutBoxExtent& box)
     104    {
     105        m_location.move(-box.left(), -box.top());
     106        m_size.expand(box.left() + box.right(), box.top() + box.bottom());
     107    }
    102108    void expand(FractionalLayoutUnit dw, FractionalLayoutUnit dh) { m_size.expand(dw, dh); }
    103109    void contract(const FractionalLayoutSize& size) { m_size -= size; }
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r121123 r122641  
    789789    if (!style->hasBorderImageOutsets())
    790790        return;
    791    
    792     LayoutUnit borderOutsetLogicalTop;
    793     LayoutUnit borderOutsetLogicalBottom;
    794     style->getBorderImageBlockDirectionOutsets(borderOutsetLogicalTop, borderOutsetLogicalBottom);
     791
     792    FractionalLayoutBoxExtent borderOutsets = style->borderImageOutsets();
     793
     794    LayoutUnit borderOutsetLogicalTop = borderOutsets.logicalTop(style);
     795    LayoutUnit borderOutsetLogicalBottom = borderOutsets.logicalBottom(style);
     796    LayoutUnit borderOutsetLogicalLeft = borderOutsets.logicalLeft(style);
     797    LayoutUnit borderOutsetLogicalRight = borderOutsets.logicalRight(style);
    795798
    796799    // Similar to how glyph overflow works, if our lines are flipped, then it's actually the opposite border that applies, since
     
    801804    LayoutUnit logicalTopVisualOverflow = min(pixelSnappedLogicalTop() - outsetLogicalTop, logicalVisualOverflow.y());
    802805    LayoutUnit logicalBottomVisualOverflow = max(pixelSnappedLogicalBottom() + outsetLogicalBottom, logicalVisualOverflow.maxY());
    803    
    804     LayoutUnit borderOutsetLogicalLeft;
    805     LayoutUnit borderOutsetLogicalRight;
    806     style->getBorderImageInlineDirectionOutsets(borderOutsetLogicalLeft, borderOutsetLogicalRight);
    807806
    808807    LayoutUnit outsetLogicalLeft = includeLogicalLeftEdge() ? borderOutsetLogicalLeft : ZERO_LAYOUT_UNIT;
     
    11881187    LayoutRect clipRect(paintRect);
    11891188    RenderStyle* style = box->renderer()->style();
    1190     LayoutUnit topOutset;
    1191     LayoutUnit rightOutset;
    1192     LayoutUnit bottomOutset;
    1193     LayoutUnit leftOutset;
    1194     style->getImageOutsets(image, topOutset, rightOutset, bottomOutset, leftOutset);
     1189    LayoutBoxExtent outsets = style->imageOutsets(image);
    11951190    if (box->isHorizontal()) {
    1196         clipRect.setY(paintRect.y() - topOutset);
    1197         clipRect.setHeight(paintRect.height() + topOutset + bottomOutset);
     1191        clipRect.setY(paintRect.y() - outsets.top());
     1192        clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom());
    11981193        if (box->includeLogicalLeftEdge()) {
    1199             clipRect.setX(paintRect.x() - leftOutset);
    1200             clipRect.setWidth(paintRect.width() + leftOutset);
     1194            clipRect.setX(paintRect.x() - outsets.left());
     1195            clipRect.setWidth(paintRect.width() + outsets.left());
    12011196        }
    12021197        if (box->includeLogicalRightEdge())
    1203             clipRect.setWidth(clipRect.width() + rightOutset);
     1198            clipRect.setWidth(clipRect.width() + outsets.right());
    12041199    } else {
    1205         clipRect.setX(paintRect.x() - leftOutset);
    1206         clipRect.setWidth(paintRect.width() + leftOutset + rightOutset);
     1200        clipRect.setX(paintRect.x() - outsets.left());
     1201        clipRect.setWidth(paintRect.width() + outsets.left() + outsets.right());
    12071202        if (box->includeLogicalLeftEdge()) {
    1208             clipRect.setY(paintRect.y() - topOutset);
    1209             clipRect.setHeight(paintRect.height() + topOutset);
     1203            clipRect.setY(paintRect.y() - outsets.top());
     1204            clipRect.setHeight(paintRect.height() + outsets.top());
    12101205        }
    12111206        if (box->includeLogicalRightEdge())
    1212             clipRect.setHeight(clipRect.height() + bottomOutset);
     1207            clipRect.setHeight(clipRect.height() + outsets.bottom());
    12131208    }
    12141209    return clipRect;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r122639 r122641  
    935935       
    936936        // Apply outsets to the border box.
    937         LayoutUnit topOutset;
    938         LayoutUnit rightOutset;
    939         LayoutUnit bottomOutset;
    940         LayoutUnit leftOutset;
    941         style()->getMaskBoxImageOutsets(topOutset, rightOutset, bottomOutset, leftOutset);
    942          
    943         borderImageRect.setX(borderImageRect.x() - leftOutset);
    944         borderImageRect.setY(borderImageRect.y() - topOutset);
    945         borderImageRect.setWidth(borderImageRect.width() + leftOutset + rightOutset);
    946         borderImageRect.setHeight(borderImageRect.height() + topOutset + bottomOutset);
    947 
     937        borderImageRect.expand(style()->maskBoxImageOutsets());
    948938        return borderImageRect;
    949939    }
     
    35863576    // Now compute border-image-outset overflow.
    35873577    if (style()->hasBorderImageOutsets()) {
    3588         LayoutUnit borderOutsetLeft;
    3589         LayoutUnit borderOutsetRight;
    3590         LayoutUnit borderOutsetTop;
    3591         LayoutUnit borderOutsetBottom;
    3592         style()->getBorderImageOutsets(borderOutsetTop, borderOutsetRight, borderOutsetBottom, borderOutsetLeft);
     3578        LayoutBoxExtent borderOutsets = style()->borderImageOutsets();
    35933579       
    35943580        // In flipped blocks writing modes, the physical sides are inverted. For example in vertical-rl, the right
    35953581        // border is at the lower x coordinate value.
    3596         overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHorizontal) ? borderOutsetLeft : borderOutsetRight));
    3597         overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHorizontal) ? borderOutsetRight : borderOutsetLeft));
    3598         overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHorizontal) ? borderOutsetTop : borderOutsetBottom));
    3599         overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isHorizontal) ? borderOutsetBottom : borderOutsetTop));
     3582        overflowMinX = min(overflowMinX, borderBox.x() - ((!isFlipped || isHorizontal) ? borderOutsets.left() : borderOutsets.right()));
     3583        overflowMaxX = max(overflowMaxX, borderBox.maxX() + ((!isFlipped || isHorizontal) ? borderOutsets.right() : borderOutsets.left()));
     3584        overflowMinY = min(overflowMinY, borderBox.y() - ((!isFlipped || !isHorizontal) ? borderOutsets.top() : borderOutsets.bottom()));
     3585        overflowMaxY = max(overflowMaxY, borderBox.maxY() + ((!isFlipped || !isHorizontal) ? borderOutsets.bottom() : borderOutsets.top()));
    36003586    }
    36013587
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r121296 r122641  
    12351235    // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function
    12361236    // doesn't have any understanding of the zoom that is in effect on the tile.
    1237     LayoutUnit topOutset;
    1238     LayoutUnit rightOutset;
    1239     LayoutUnit bottomOutset;
    1240     LayoutUnit leftOutset;
    1241     style->getImageOutsets(ninePieceImage, topOutset, rightOutset, bottomOutset, leftOutset);
    1242 
    1243     LayoutUnit topWithOutset = rect.y() - topOutset;
    1244     LayoutUnit bottomWithOutset = rect.maxY() + bottomOutset;
    1245     LayoutUnit leftWithOutset = rect.x() - leftOutset;
    1246     LayoutUnit rightWithOutset = rect.maxX() + rightOutset;
    1247     IntRect borderImageRect = pixelSnappedIntRect(leftWithOutset, topWithOutset, rightWithOutset - leftWithOutset, bottomWithOutset - topWithOutset);
     1237    LayoutRect rectWithOutsets = rect;
     1238    rectWithOutsets.expand(style->imageOutsets(ninePieceImage));
     1239    IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets);
    12481240
    12491241    IntSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size(), DoNotScaleByEffectiveZoom);
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r121127 r122641  
    14791479#endif
    14801480
    1481 void RenderStyle::getImageOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
    1482 {
    1483     top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
    1484     right = NinePieceImage::computeOutset(image.outset().right(), borderRightWidth());
    1485     bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
    1486     left = NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth());
    1487 }
    1488 
    1489 void RenderStyle::getImageHorizontalOutsets(const NinePieceImage& image, LayoutUnit& left, LayoutUnit& right) const
    1490 {
    1491     right = NinePieceImage::computeOutset(image.outset().right(), borderRightWidth());
    1492     left = NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth());
    1493 }
    1494 
    1495 void RenderStyle::getImageVerticalOutsets(const NinePieceImage& image, LayoutUnit& top, LayoutUnit& bottom) const
    1496 {
    1497     top = NinePieceImage::computeOutset(image.outset().top(), borderTopWidth());
    1498     bottom = NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth());
     1481LayoutBoxExtent RenderStyle::imageOutsets(const NinePieceImage& image) const
     1482{
     1483    return LayoutBoxExtent(NinePieceImage::computeOutset(image.outset().top(), borderTopWidth()),
     1484                           NinePieceImage::computeOutset(image.outset().right(), borderRightWidth()),
     1485                           NinePieceImage::computeOutset(image.outset().bottom(), borderBottomWidth()),
     1486                           NinePieceImage::computeOutset(image.outset().left(), borderLeftWidth()));
    14991487}
    15001488
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r122264 r122641  
    441441    }
    442442   
    443     void getImageOutsets(const NinePieceImage&, LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const;
     443    LayoutBoxExtent imageOutsets(const NinePieceImage&) const;
    444444    bool hasBorderImageOutsets() const
    445445    {
    446446        return borderImage().hasImage() && borderImage().outset().nonZero();
    447447    }
    448     void getBorderImageOutsets(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
    449     {
    450         return getImageOutsets(borderImage(), top, right, bottom, left);
    451     }
    452     void getBorderImageHorizontalOutsets(LayoutUnit& left, LayoutUnit& right) const
    453     {
    454         return getImageHorizontalOutsets(borderImage(), left, right);
    455     }
    456     void getBorderImageVerticalOutsets(LayoutUnit& top, LayoutUnit& bottom) const
    457     {
    458         return getImageVerticalOutsets(borderImage(), top, bottom);
    459     }
    460     void getBorderImageInlineDirectionOutsets(LayoutUnit& logicalLeft, LayoutUnit& logicalRight) const
    461     {
    462         return getImageInlineDirectionOutsets(borderImage(), logicalLeft, logicalRight);
    463     }
    464     void getBorderImageBlockDirectionOutsets(LayoutUnit& logicalTop, LayoutUnit& logicalBottom) const
    465     {
    466         return getImageBlockDirectionOutsets(borderImage(), logicalTop, logicalBottom);
    467     }
    468    
    469     void getMaskBoxImageOutsets(LayoutUnit& top, LayoutUnit& right, LayoutUnit& bottom, LayoutUnit& left) const
    470     {
    471         return getImageOutsets(maskBoxImage(), top, right, bottom, left);
     448    LayoutBoxExtent borderImageOutsets() const
     449    {
     450        return imageOutsets(borderImage());
     451    }
     452
     453    LayoutBoxExtent maskBoxImageOutsets() const
     454    {
     455        return imageOutsets(maskBoxImage());
    472456    }
    473457
     
    17551739    }
    17561740
    1757     // Helpers for obtaining border image outsets for overflow.
    1758     void getImageHorizontalOutsets(const NinePieceImage&, LayoutUnit& left, LayoutUnit& right) const;
    1759     void getImageVerticalOutsets(const NinePieceImage&, LayoutUnit& top, LayoutUnit& bottom) const;
    1760     void getImageInlineDirectionOutsets(const NinePieceImage& image, LayoutUnit& logicalLeft, LayoutUnit& logicalRight) const
    1761     {
    1762         return isHorizontalWritingMode() ? getImageHorizontalOutsets(image, logicalLeft, logicalRight) : getImageVerticalOutsets(image, logicalLeft, logicalRight);
    1763     }
    1764     void getImageBlockDirectionOutsets(const NinePieceImage& image, LayoutUnit& logicalTop, LayoutUnit& logicalBottom) const
    1765     {
    1766         return isHorizontalWritingMode() ? getImageVerticalOutsets(image, logicalTop, logicalBottom) : getImageHorizontalOutsets(image, logicalTop, logicalBottom);
    1767     }
    1768 
    17691741    // Color accessors are all private to make sure callers use visitedDependentColor instead to access them.
    17701742    Color invalidColor() const { static Color invalid; return invalid; }
Note: See TracChangeset for help on using the changeset viewer.