⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 89625 in webkit


Ignore:
Timestamp:
Jun 23, 2011, 3:15:00 PM (15 years ago)
Author:
eae@chromium.org
Message:

2011-06-23 Emil A Eklund <eae@chromium.org>

Reviewed by Eric Seidel.

FloatRect should implement the same methods as IntRect
https://bugs.webkit.org/show_bug.cgi?id=63273

Add missing methods from IntRect to FloatRect in preparation for moving
the rendering tree over to floats.

  • platform/graphics/FloatPoint.h: (WebCore::FloatPoint::expandedTo): (WebCore::FloatPoint::transposedPoint):
  • platform/graphics/FloatRect.h: (WebCore::FloatRect::move): (WebCore::FloatRect::expand): (WebCore::FloatRect::contract): (WebCore::FloatRect::shiftXEdgeTo): (WebCore::FloatRect::shiftMaxXEdgeTo): (WebCore::FloatRect::shiftYEdgeTo): (WebCore::FloatRect::shiftMaxYEdgeTo): (WebCore::FloatRect::minXMinYCorner): (WebCore::FloatRect::maxXMinYCorner): (WebCore::FloatRect::minXMaxYCorner): (WebCore::FloatRect::maxXMaxYCorner): (WebCore::FloatRect::transposedRect):
  • platform/graphics/FloatSize.h: (WebCore::FloatSize::expand): (WebCore::FloatSize::transposedSize):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89624 r89625  
     12011-06-23  Emil A Eklund  <eae@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        FloatRect should implement the same methods as IntRect
     6        https://bugs.webkit.org/show_bug.cgi?id=63273
     7       
     8        Add missing methods from IntRect to FloatRect in preparation for moving
     9        the rendering tree over to floats.
     10
     11        * platform/graphics/FloatPoint.h:
     12        (WebCore::FloatPoint::expandedTo):
     13        (WebCore::FloatPoint::transposedPoint):
     14        * platform/graphics/FloatRect.h:
     15        (WebCore::FloatRect::move):
     16        (WebCore::FloatRect::expand):
     17        (WebCore::FloatRect::contract):
     18        (WebCore::FloatRect::shiftXEdgeTo):
     19        (WebCore::FloatRect::shiftMaxXEdgeTo):
     20        (WebCore::FloatRect::shiftYEdgeTo):
     21        (WebCore::FloatRect::shiftMaxYEdgeTo):
     22        (WebCore::FloatRect::minXMinYCorner):
     23        (WebCore::FloatRect::maxXMinYCorner):
     24        (WebCore::FloatRect::minXMaxYCorner):
     25        (WebCore::FloatRect::maxXMaxYCorner):
     26        (WebCore::FloatRect::transposedRect):
     27        * platform/graphics/FloatSize.h:
     28        (WebCore::FloatSize::expand):
     29        (WebCore::FloatSize::transposedSize):
     30
    1312011-06-23  Emil A Eklund  <eae@chromium.org>
    232
  • trunk/Source/WebCore/platform/graphics/FloatPoint.h

    r89496 r89625  
    124124    {
    125125        return FloatPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));
    126     }   
     126    }
     127
     128    FloatPoint transposedPoint() const
     129    {
     130        return FloatPoint(m_y, m_x);
     131    }
    127132
    128133#if USE(CG) || USE(SKIA_ON_MAC_CHROME)
  • trunk/Source/WebCore/platform/graphics/FloatRect.h

    r89496 r89625  
    107107
    108108    void move(const FloatSize& delta) { m_location += delta; }
     109    void moveBy(const FloatPoint& delta) { m_location.move(delta.x(), delta.y()); }
    109110    void move(float dx, float dy) { m_location.move(dx, dy); }
    110     void moveBy(const FloatPoint& delta) { m_location.move(delta.x(), delta.y()); }
     111
     112    void expand(const FloatSize& size) { m_size += size; }
     113    void expand(float dw, float dh) { m_size.expand(dw, dh); }
     114    void contract(const FloatSize& size) { m_size -= size; }
     115    void contract(float dw, float dh) { m_size.expand(-dw, -dh); }
     116
     117    void shiftXEdgeTo(float edge)
     118    {
     119        float delta = edge - x();
     120        setX(edge);
     121        setWidth(std::max(0.0f, width() - delta));
     122    }
     123    void shiftMaxXEdgeTo(float edge)
     124    {
     125        float delta = edge - maxX();
     126        setWidth(std::max(0.0f, width() + delta));
     127    }
     128    void shiftYEdgeTo(float edge)
     129    {
     130        float delta = edge - y();
     131        setY(edge);
     132        setHeight(std::max(0.0f, height() - delta));
     133    }
     134    void shiftMaxYEdgeTo(float edge)
     135    {
     136        float delta = edge - maxY();
     137        setHeight(std::max(0.0f, height() + delta));
     138    }
     139
     140    FloatPoint minXMinYCorner() const { return m_location; } // typically topLeft
     141    FloatPoint maxXMinYCorner() const { return FloatPoint(m_location.x() + m_size.width(), m_location.y()); } // typically topRight
     142    FloatPoint minXMaxYCorner() const { return FloatPoint(m_location.x(), m_location.y() + m_size.height()); } // typically bottomLeft
     143    FloatPoint maxXMaxYCorner() const { return FloatPoint(m_location.x() + m_size.width(), m_location.y() + m_size.height()); } // typically bottomRight
    111144
    112145    bool intersects(const FloatRect&) const;
     
    135168    void scale(float sx, float sy);
    136169
     170    FloatRect transposedRect() const { return FloatRect(m_location.transposedPoint(), m_size.transposedSize()); }
     171
    137172    // Re-initializes this rectangle to fit the sets of passed points.
    138173    void fitToPoints(const FloatPoint& p0, const FloatPoint& p1);
  • trunk/Source/WebCore/platform/graphics/FloatSize.h

    r89496 r89625  
    6666    float aspectRatio() const { return m_width / m_height; }
    6767
     68    void expand(float width, float height)
     69    {
     70        m_width += width;
     71        m_height += height;
     72    }
     73
    6874    void scale(float s) { scale(s, s); }
    6975
     
    9096    {
    9197        return m_width * m_width + m_height * m_height;
     98    }
     99
     100    FloatSize transposedSize() const
     101    {
     102        return FloatSize(m_height, m_width);
    92103    }
    93104
Note: See TracChangeset for help on using the changeset viewer.