Title: [98931] trunk/Source/WebCore
Revision
98931
Author
[email protected]
Date
2011-10-31 18:09:03 -0700 (Mon, 31 Oct 2011)

Log 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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98930 => 98931)


--- trunk/Source/WebCore/ChangeLog	2011-11-01 01:06:00 UTC (rev 98930)
+++ trunk/Source/WebCore/ChangeLog	2011-11-01 01:09:03 UTC (rev 98931)
@@ -1,3 +1,41 @@
+2011-10-31  Levi Weintraub  <[email protected]>
+
+        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
+
 2011-10-31  Peter Kasting  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=70666

Modified: trunk/Source/WebCore/platform/graphics/RoundedRect.cpp (98930 => 98931)


--- trunk/Source/WebCore/platform/graphics/RoundedRect.cpp	2011-11-01 01:06:00 UTC (rev 98930)
+++ trunk/Source/WebCore/platform/graphics/RoundedRect.cpp	2011-11-01 01:09:03 UTC (rev 98931)
@@ -46,45 +46,45 @@
     // If either radius on a corner becomes zero, reset both radii on that corner.
     m_topLeft.scale(factor);
     if (!m_topLeft.width() || !m_topLeft.height())
-        m_topLeft = LayoutSize();
+        m_topLeft = IntSize();
     m_topRight.scale(factor);
     if (!m_topRight.width() || !m_topRight.height())
-        m_topRight = LayoutSize();
+        m_topRight = IntSize();
     m_bottomLeft.scale(factor);
     if (!m_bottomLeft.width() || !m_bottomLeft.height())
-        m_bottomLeft = LayoutSize();
+        m_bottomLeft = IntSize();
     m_bottomRight.scale(factor);
     if (!m_bottomRight.width() || !m_bottomRight.height())
-        m_bottomRight = LayoutSize();
+        m_bottomRight = IntSize();
 
 }
 
-void RoundedRect::Radii::expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth)
+void RoundedRect::Radii::expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth)
 {
-    m_topLeft.setWidth(max<LayoutUnit>(0, m_topLeft.width() + leftWidth));
-    m_topLeft.setHeight(max<LayoutUnit>(0, m_topLeft.height() + topWidth));
+    m_topLeft.setWidth(max<int>(0, m_topLeft.width() + leftWidth));
+    m_topLeft.setHeight(max<int>(0, m_topLeft.height() + topWidth));
 
-    m_topRight.setWidth(max<LayoutUnit>(0, m_topRight.width() + rightWidth));
-    m_topRight.setHeight(max<LayoutUnit>(0, m_topRight.height() + topWidth));
+    m_topRight.setWidth(max<int>(0, m_topRight.width() + rightWidth));
+    m_topRight.setHeight(max<int>(0, m_topRight.height() + topWidth));
 
-    m_bottomLeft.setWidth(max<LayoutUnit>(0, m_bottomLeft.width() + leftWidth));
-    m_bottomLeft.setHeight(max<LayoutUnit>(0, m_bottomLeft.height() + bottomWidth));
+    m_bottomLeft.setWidth(max<int>(0, m_bottomLeft.width() + leftWidth));
+    m_bottomLeft.setHeight(max<int>(0, m_bottomLeft.height() + bottomWidth));
 
-    m_bottomRight.setWidth(max<LayoutUnit>(0, m_bottomRight.width() + rightWidth));
-    m_bottomRight.setHeight(max<LayoutUnit>(0, m_bottomRight.height() + bottomWidth));
+    m_bottomRight.setWidth(max<int>(0, m_bottomRight.width() + rightWidth));
+    m_bottomRight.setHeight(max<int>(0, m_bottomRight.height() + bottomWidth));
 }
 
-void RoundedRect::inflateWithRadii(LayoutUnit size)
+void RoundedRect::inflateWithRadii(int size)
 {
-    LayoutRect old = m_rect;
+    IntRect old = m_rect;
 
     m_rect.inflate(size);
     // Considering the inflation factor of shorter size to scale the radii seems appropriate here
     float factor;
     if (m_rect.width() < m_rect.height())
-        factor = old.width() ? (float)m_rect.width() / old.width() : 0;
+        factor = old.width() ? (float)m_rect.width() / old.width() : int(0);
     else
-        factor = old.height() ? (float)m_rect.height() / old.height() : 0;
+        factor = old.height() ? (float)m_rect.height() / old.height() : int(0);
 
     m_radii.scale(factor);
 }
@@ -112,33 +112,33 @@
 {
     if (excludeLogicalLeftEdge) {
         if (isHorizontal)
-            m_bottomLeft = LayoutSize();
+            m_bottomLeft = IntSize();
         else
-            m_topRight = LayoutSize();
-        m_topLeft = LayoutSize();
+            m_topRight = IntSize();
+        m_topLeft = IntSize();
     }
         
     if (excludeLogicalRightEdge) {
         if (isHorizontal)
-            m_topRight = LayoutSize();
+            m_topRight = IntSize();
         else
-            m_bottomLeft = LayoutSize();
-        m_bottomRight = LayoutSize();
+            m_bottomLeft = IntSize();
+        m_bottomRight = IntSize();
     }
 }
 
-RoundedRect::RoundedRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height)
+RoundedRect::RoundedRect(int x, int y, int width, int height)
     : m_rect(x, y, width, height)
 {
 }
 
-RoundedRect::RoundedRect(const LayoutRect& rect, const Radii& radii)
+RoundedRect::RoundedRect(const IntRect& rect, const Radii& radii)
     : m_rect(rect)
     , m_radii(radii)
 {
 }
 
-RoundedRect::RoundedRect(const LayoutRect& rect, const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight)
+RoundedRect::RoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
     : m_rect(rect)
     , m_radii(topLeft, topRight, bottomLeft, bottomRight)
 {

Modified: trunk/Source/WebCore/platform/graphics/RoundedRect.h (98930 => 98931)


--- trunk/Source/WebCore/platform/graphics/RoundedRect.h	2011-11-01 01:06:00 UTC (rev 98930)
+++ trunk/Source/WebCore/platform/graphics/RoundedRect.h	2011-11-01 01:09:03 UTC (rev 98931)
@@ -27,7 +27,7 @@
 #ifndef RoundedRect_h
 #define RoundedRect_h
 
-#include "LayoutTypes.h"
+#include "IntRect.h"
 
 namespace WebCore {
 
@@ -37,7 +37,7 @@
     class Radii {
     public:
         Radii() {}
-        Radii(const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight)
+        Radii(const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight)
             : m_topLeft(topLeft)
             , m_topRight(topRight)
             , m_bottomLeft(bottomLeft)
@@ -45,14 +45,14 @@
         {
         }
 
-        void setTopLeft(const LayoutSize& size) { m_topLeft = size; }
-        void setTopRight(const LayoutSize& size) { m_topRight = size; }
-        void setBottomLeft(const LayoutSize& size) { m_bottomLeft = size; }
-        void setBottomRight(const LayoutSize& size) { m_bottomRight = size; }
-        const LayoutSize& topLeft() const { return m_topLeft; }
-        const LayoutSize& topRight() const { return m_topRight; }
-        const LayoutSize& bottomLeft() const { return m_bottomLeft; }
-        const LayoutSize& bottomRight() const { return m_bottomRight; }
+        void setTopLeft(const IntSize& size) { m_topLeft = size; }
+        void setTopRight(const IntSize& size) { m_topRight = size; }
+        void setBottomLeft(const IntSize& size) { m_bottomLeft = size; }
+        void setBottomRight(const IntSize& size) { m_bottomRight = size; }
+        const IntSize& topLeft() const { return m_topLeft; }
+        const IntSize& topRight() const { return m_topRight; }
+        const IntSize& bottomLeft() const { return m_bottomLeft; }
+        const IntSize& bottomRight() const { return m_bottomRight; }
 
         bool isZero() const;
 
@@ -60,35 +60,35 @@
         void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
 
         void scale(float factor);
-        void expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth);
-        void expand(LayoutUnit size) { expand(size, size, size, size); }
-        void shrink(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
-        void shrink(LayoutUnit size) { shrink(size, size, size, size); }
+        void expand(int topWidth, int bottomWidth, int leftWidth, int rightWidth);
+        void expand(int size) { expand(size, size, size, size); }
+        void shrink(int topWidth, int bottomWidth, int leftWidth, int rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
+        void shrink(int size) { shrink(size, size, size, size); }
 
     private:
-        LayoutSize m_topLeft;
-        LayoutSize m_topRight;
-        LayoutSize m_bottomLeft;
-        LayoutSize m_bottomRight;
+        IntSize m_topLeft;
+        IntSize m_topRight;
+        IntSize m_bottomLeft;
+        IntSize m_bottomRight;
     };
 
-    explicit RoundedRect(const LayoutRect&, const Radii& = Radii());
-    RoundedRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height);
-    RoundedRect(const LayoutRect&, const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight);
+    explicit RoundedRect(const IntRect&, const Radii& = Radii());
+    RoundedRect(int x, int y, int width, int height);
+    RoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
 
-    const LayoutRect& rect() const { return m_rect; }
+    const IntRect& rect() const { return m_rect; }
     const Radii& radii() const { return m_radii; }
     bool isRounded() const { return !m_radii.isZero(); }
     bool isEmpty() const { return m_rect.isEmpty(); }
 
-    void setRect(const LayoutRect& rect) { m_rect = rect; }
+    void setRect(const IntRect& rect) { m_rect = rect; }
     void setRadii(const Radii& radii) { m_radii = radii; }
 
-    void move(const LayoutSize& size) { m_rect.move(size); }
-    void inflate(LayoutUnit size) { m_rect.inflate(size);  }
-    void inflateWithRadii(LayoutUnit size);
-    void expandRadii(LayoutUnit size) { m_radii.expand(size); }
-    void shrinkRadii(LayoutUnit size) { m_radii.shrink(size); }
+    void move(const IntSize& size) { m_rect.move(size); }
+    void inflate(int size) { m_rect.inflate(size);  }
+    void inflateWithRadii(int size);
+    void expandRadii(int size) { m_radii.expand(size); }
+    void shrinkRadii(int size) { m_radii.shrink(size); }
 
     void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
     void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
@@ -96,7 +96,7 @@
     bool isRenderable() const;
 
 private:
-    LayoutRect m_rect;
+    IntRect m_rect;
     Radii m_radii;
 };
 

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h (98930 => 98931)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h	2011-11-01 01:06:00 UTC (rev 98930)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.h	2011-11-01 01:09:03 UTC (rev 98931)
@@ -25,6 +25,7 @@
 #define SVGRenderSupport_h
 
 #if ENABLE(SVG)
+#include "LayoutTypes.h"
 #include "PaintInfo.h"
 
 namespace WebCore {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to