Changeset 98931 in webkit


Ignore:
Timestamp:
Oct 31, 2011 6:09:03 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Switch RoundedRect back to integers
https://bugs.webkit.org/show_bug.cgi?id=71238

Reviewed by Darin Adler.

Changing RoundedRect back to ints from LayoutUnits. As further testing has shown, this graphics-
focused class should maintain values aligned to pixel boundaries, and therefor kept as integers.

No new tests -- no change in behavior.

  • platform/graphics/RoundedRect.cpp:

(WebCore::RoundedRect::Radii::scale):
(WebCore::RoundedRect::Radii::expand):
(WebCore::RoundedRect::inflateWithRadii):
(WebCore::RoundedRect::Radii::excludeLogicalEdges):
(WebCore::RoundedRect::RoundedRect):

  • platform/graphics/RoundedRect.h:

(WebCore::RoundedRect::Radii::Radii):
(WebCore::RoundedRect::Radii::setTopLeft):
(WebCore::RoundedRect::Radii::setTopRight):
(WebCore::RoundedRect::Radii::setBottomLeft):
(WebCore::RoundedRect::Radii::setBottomRight):
(WebCore::RoundedRect::Radii::topLeft):
(WebCore::RoundedRect::Radii::topRight):
(WebCore::RoundedRect::Radii::bottomLeft):
(WebCore::RoundedRect::Radii::bottomRight):
(WebCore::RoundedRect::Radii::expand):
(WebCore::RoundedRect::Radii::shrink):
(WebCore::RoundedRect::rect):
(WebCore::RoundedRect::setRect):
(WebCore::RoundedRect::move):
(WebCore::RoundedRect::inflate):
(WebCore::RoundedRect::expandRadii):
(WebCore::RoundedRect::shrinkRadii):

  • rendering/svg/SVGRenderSupport.h: Adding missing LayoutTypes.h include
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98930 r98931  
     12011-10-31  Levi Weintraub  <leviw@chromium.org>
     2
     3        Switch RoundedRect back to integers
     4        https://bugs.webkit.org/show_bug.cgi?id=71238
     5
     6        Reviewed by Darin Adler.
     7
     8        Changing RoundedRect back to ints from LayoutUnits. As further testing has shown, this graphics-
     9        focused class should maintain values aligned to pixel boundaries, and therefor kept as integers.
     10
     11        No new tests -- no change in behavior.
     12
     13        * platform/graphics/RoundedRect.cpp:
     14        (WebCore::RoundedRect::Radii::scale):
     15        (WebCore::RoundedRect::Radii::expand):
     16        (WebCore::RoundedRect::inflateWithRadii):
     17        (WebCore::RoundedRect::Radii::excludeLogicalEdges):
     18        (WebCore::RoundedRect::RoundedRect):
     19        * platform/graphics/RoundedRect.h:
     20        (WebCore::RoundedRect::Radii::Radii):
     21        (WebCore::RoundedRect::Radii::setTopLeft):
     22        (WebCore::RoundedRect::Radii::setTopRight):
     23        (WebCore::RoundedRect::Radii::setBottomLeft):
     24        (WebCore::RoundedRect::Radii::setBottomRight):
     25        (WebCore::RoundedRect::Radii::topLeft):
     26        (WebCore::RoundedRect::Radii::topRight):
     27        (WebCore::RoundedRect::Radii::bottomLeft):
     28        (WebCore::RoundedRect::Radii::bottomRight):
     29        (WebCore::RoundedRect::Radii::expand):
     30        (WebCore::RoundedRect::Radii::shrink):
     31        (WebCore::RoundedRect::rect):
     32        (WebCore::RoundedRect::setRect):
     33        (WebCore::RoundedRect::move):
     34        (WebCore::RoundedRect::inflate):
     35        (WebCore::RoundedRect::expandRadii):
     36        (WebCore::RoundedRect::shrinkRadii):
     37        * rendering/svg/SVGRenderSupport.h: Adding missing LayoutTypes.h include
     38
    1392011-10-31  Peter Kasting  <pkasting@google.com>
    240
  • trunk/Source/WebCore/platform/graphics/RoundedRect.cpp

    r95901 r98931  
    4747    m_topLeft.scale(factor);
    4848    if (!m_topLeft.width() || !m_topLeft.height())
    49         m_topLeft = LayoutSize();
     49        m_topLeft = IntSize();
    5050    m_topRight.scale(factor);
    5151    if (!m_topRight.width() || !m_topRight.height())
    52         m_topRight = LayoutSize();
     52        m_topRight = IntSize();
    5353    m_bottomLeft.scale(factor);
    5454    if (!m_bottomLeft.width() || !m_bottomLeft.height())
    55         m_bottomLeft = LayoutSize();
     55        m_bottomLeft = IntSize();
    5656    m_bottomRight.scale(factor);
    5757    if (!m_bottomRight.width() || !m_bottomRight.height())
    58         m_bottomRight = LayoutSize();
     58        m_bottomRight = IntSize();
    5959
    6060}
    6161
    62 void RoundedRect::Radii::expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth)
     62void RoundedRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth)
    6363{
    64     m_topLeft.setWidth(max<LayoutUnit>(0, m_topLeft.width() + leftWidth));
    65     m_topLeft.setHeight(max<LayoutUnit>(0, m_topLeft.height() + topWidth));
     64    m_topLeft.setWidth(max<int>(0, m_topLeft.width() + leftWidth));
     65    m_topLeft.setHeight(max<int>(0, m_topLeft.height() + topWidth));
    6666
    67     m_topRight.setWidth(max<LayoutUnit>(0, m_topRight.width() + rightWidth));
    68     m_topRight.setHeight(max<LayoutUnit>(0, m_topRight.height() + topWidth));
     67    m_topRight.setWidth(max<int>(0, m_topRight.width() + rightWidth));
     68    m_topRight.setHeight(max<int>(0, m_topRight.height() + topWidth));
    6969
    70     m_bottomLeft.setWidth(max<LayoutUnit>(0, m_bottomLeft.width() + leftWidth));
    71     m_bottomLeft.setHeight(max<LayoutUnit>(0, m_bottomLeft.height() + bottomWidth));
     70    m_bottomLeft.setWidth(max<int>(0, m_bottomLeft.width() + leftWidth));
     71    m_bottomLeft.setHeight(max<int>(0, m_bottomLeft.height() + bottomWidth));
    7272
    73     m_bottomRight.setWidth(max<LayoutUnit>(0, m_bottomRight.width() + rightWidth));
    74     m_bottomRight.setHeight(max<LayoutUnit>(0, m_bottomRight.height() + bottomWidth));
     73    m_bottomRight.setWidth(max<int>(0, m_bottomRight.width() + rightWidth));
     74    m_bottomRight.setHeight(max<int>(0, m_bottomRight.height() + bottomWidth));
    7575}
    7676
    77 void RoundedRect::inflateWithRadii(LayoutUnit size)
     77void RoundedRect::inflateWithRadii(int size)
    7878{
    79     LayoutRect old = m_rect;
     79    IntRect old = m_rect;
    8080
    8181    m_rect.inflate(size);
     
    8383    float factor;
    8484    if (m_rect.width() < m_rect.height())
    85         factor = old.width() ? (float)m_rect.width() / old.width() : 0;
     85        factor = old.width() ? (float)m_rect.width() / old.width() : int(0);
    8686    else
    87         factor = old.height() ? (float)m_rect.height() / old.height() : 0;
     87        factor = old.height() ? (float)m_rect.height() / old.height() : int(0);
    8888
    8989    m_radii.scale(factor);
     
    113113    if (excludeLogicalLeftEdge) {
    114114        if (isHorizontal)
    115             m_bottomLeft = LayoutSize();
     115            m_bottomLeft = IntSize();
    116116        else
    117             m_topRight = LayoutSize();
    118         m_topLeft = LayoutSize();
     117            m_topRight = IntSize();
     118        m_topLeft = IntSize();
    119119    }
    120120       
    121121    if (excludeLogicalRightEdge) {
    122122        if (isHorizontal)
    123             m_topRight = LayoutSize();
     123            m_topRight = IntSize();
    124124        else
    125             m_bottomLeft = LayoutSize();
    126         m_bottomRight = LayoutSize();
     125            m_bottomLeft = IntSize();
     126        m_bottomRight = IntSize();
    127127    }
    128128}
    129129
    130 RoundedRect::RoundedRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height)
     130RoundedRect::RoundedRect(int x, int y, int width, int height)
    131131    : m_rect(x, y, width, height)
    132132{
    133133}
    134134
    135 RoundedRect::RoundedRect(const LayoutRect& rect, const Radii& radii)
     135RoundedRect::RoundedRect(const IntRect& rect, const Radii& radii)
    136136    : m_rect(rect)
    137137    , m_radii(radii)
     
    139139}
    140140
    141 RoundedRect::RoundedRect(const LayoutRect& rect, const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight)
     141RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
    142142    : m_rect(rect)
    143143    , m_radii(topLeft, topRight, bottomLeft, bottomRight)
  • trunk/Source/WebCore/platform/graphics/RoundedRect.h

    r95901 r98931  
    2828#define RoundedRect_h
    2929
    30 #include "LayoutTypes.h"
     30#include "IntRect.h"
    3131
    3232namespace WebCore {
     
    3838    public:
    3939        Radii() {}
    40         Radii(const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight)
     40        Radii(const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
    4141            : m_topLeft(topLeft)
    4242            , m_topRight(topRight)
     
    4646        }
    4747
    48         void setTopLeft(const LayoutSize& size) { m_topLeft = size; }
    49         void setTopRight(const LayoutSize& size) { m_topRight = size; }
    50         void setBottomLeft(const LayoutSize& size) { m_bottomLeft = size; }
    51         void setBottomRight(const LayoutSize& size) { m_bottomRight = size; }
    52         const LayoutSize& topLeft() const { return m_topLeft; }
    53         const LayoutSize& topRight() const { return m_topRight; }
    54         const LayoutSize& bottomLeft() const { return m_bottomLeft; }
    55         const LayoutSize& bottomRight() const { return m_bottomRight; }
     48        void setTopLeft(const IntSize& size) { m_topLeft = size; }
     49        void setTopRight(const IntSize& size) { m_topRight = size; }
     50        void setBottomLeft(const IntSize& size) { m_bottomLeft = size; }
     51        void setBottomRight(const IntSize& size) { m_bottomRight = size; }
     52        const IntSize& topLeft() const { return m_topLeft; }
     53        const IntSize& topRight() const { return m_topRight; }
     54        const IntSize& bottomLeft() const { return m_bottomLeft; }
     55        const IntSize& bottomRight() const { return m_bottomRight; }
    5656
    5757        bool isZero() const;
     
    6161
    6262        void scale(float factor);
    63         void expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth);
    64         void expand(LayoutUnit size) { expand(size, size, size, size); }
    65         void shrink(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
    66         void shrink(LayoutUnit size) { shrink(size, size, size, size); }
     63        void expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth);
     64        void expand(int size) { expand(size, size, size, size); }
     65        void shrink(int topWidth, int bottomWidth, int leftWidth, int rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
     66        void shrink(int size) { shrink(size, size, size, size); }
    6767
    6868    private:
    69         LayoutSize m_topLeft;
    70         LayoutSize m_topRight;
    71         LayoutSize m_bottomLeft;
    72         LayoutSize m_bottomRight;
     69        IntSize m_topLeft;
     70        IntSize m_topRight;
     71        IntSize m_bottomLeft;
     72        IntSize m_bottomRight;
    7373    };
    7474
    75     explicit RoundedRect(const LayoutRect&, const Radii& = Radii());
    76     RoundedRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height);
    77     RoundedRect(const LayoutRect&, const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight);
     75    explicit RoundedRect(const IntRect&, const Radii& = Radii());
     76    RoundedRect(int x, int y, int width, int height);
     77    RoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
    7878
    79     const LayoutRect& rect() const { return m_rect; }
     79    const IntRect& rect() const { return m_rect; }
    8080    const Radii& radii() const { return m_radii; }
    8181    bool isRounded() const { return !m_radii.isZero(); }
    8282    bool isEmpty() const { return m_rect.isEmpty(); }
    8383
    84     void setRect(const LayoutRect& rect) { m_rect = rect; }
     84    void setRect(const IntRect& rect) { m_rect = rect; }
    8585    void setRadii(const Radii& radii) { m_radii = radii; }
    8686
    87     void move(const LayoutSize& size) { m_rect.move(size); }
    88     void inflate(LayoutUnit size) { m_rect.inflate(size);  }
    89     void inflateWithRadii(LayoutUnit size);
    90     void expandRadii(LayoutUnit size) { m_radii.expand(size); }
    91     void shrinkRadii(LayoutUnit size) { m_radii.shrink(size); }
     87    void move(const IntSize& size) { m_rect.move(size); }
     88    void inflate(int size) { m_rect.inflate(size);  }
     89    void inflateWithRadii(int size);
     90    void expandRadii(int size) { m_radii.expand(size); }
     91    void shrinkRadii(int size) { m_radii.shrink(size); }
    9292
    9393    void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
     
    9797
    9898private:
    99     LayoutRect m_rect;
     99    IntRect m_rect;
    100100    Radii m_radii;
    101101};
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h

    r96558 r98931  
    2626
    2727#if ENABLE(SVG)
     28#include "LayoutTypes.h"
    2829#include "PaintInfo.h"
    2930
Note: See TracChangeset for help on using the changeset viewer.