Title: [152175] trunk/Source/WebCore
Revision
152175
Author
[email protected]
Date
2013-06-28 10:31:30 -0700 (Fri, 28 Jun 2013)

Log Message

Allow some LayoutPoint and LayoutSize conversions to be inlined
https://bugs.webkit.org/show_bug.cgi?id=118167

Reviewed by Ryosuke Niwa.

Construction of FloatSize from LayoutSize, and FloatPoint's move(const LayoutSize&)
and moveBy(const LayoutPoint&) were not inlined, and showed up on some profiles.

Make them inlined by removing the overloaded functions, and instead providing
conversion operators from LayoutSize to FloatSize, and LayoutPoint to FloatPoint.
Do the same to allow a LayoutRect to be converted to a FloatRect.

This is nice because it removes pollution of FloatRect, FloatPoint and FloatSize with
Layout* entirely.

Remove Qt-specific conversions on LayoutRect, LayoutPoint and LayoutSize. Qt can
convert via IntRect/FloatRect as necessary.

* platform/graphics/FloatPoint.cpp:
* platform/graphics/FloatPoint.h:
(WebCore::FloatPoint::move):
(WebCore::FloatPoint::moveBy):
* platform/graphics/FloatRect.cpp:
* platform/graphics/FloatRect.h:
* platform/graphics/FloatSize.cpp:
* platform/graphics/FloatSize.h:
* platform/graphics/LayoutPoint.h:
(WebCore::LayoutPoint::operator FloatPoint):
* platform/graphics/LayoutRect.cpp:
* platform/graphics/LayoutRect.h:
(WebCore::LayoutRect::operator FloatRect):
* platform/graphics/LayoutSize.h:
(WebCore::LayoutSize::operator FloatSize):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152174 => 152175)


--- trunk/Source/WebCore/ChangeLog	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/ChangeLog	2013-06-28 17:31:30 UTC (rev 152175)
@@ -1,3 +1,39 @@
+2013-06-28  Simon Fraser  <[email protected]>
+
+        Allow some LayoutPoint and LayoutSize conversions to be inlined
+        https://bugs.webkit.org/show_bug.cgi?id=118167
+
+        Reviewed by Ryosuke Niwa.
+
+        Construction of FloatSize from LayoutSize, and FloatPoint's move(const LayoutSize&)
+        and moveBy(const LayoutPoint&) were not inlined, and showed up on some profiles.
+        
+        Make them inlined by removing the overloaded functions, and instead providing
+        conversion operators from LayoutSize to FloatSize, and LayoutPoint to FloatPoint.
+        Do the same to allow a LayoutRect to be converted to a FloatRect.
+        
+        This is nice because it removes pollution of FloatRect, FloatPoint and FloatSize with
+        Layout* entirely.
+        
+        Remove Qt-specific conversions on LayoutRect, LayoutPoint and LayoutSize. Qt can
+        convert via IntRect/FloatRect as necessary.
+
+        * platform/graphics/FloatPoint.cpp:
+        * platform/graphics/FloatPoint.h:
+        (WebCore::FloatPoint::move):
+        (WebCore::FloatPoint::moveBy):
+        * platform/graphics/FloatRect.cpp:
+        * platform/graphics/FloatRect.h:
+        * platform/graphics/FloatSize.cpp:
+        * platform/graphics/FloatSize.h:
+        * platform/graphics/LayoutPoint.h:
+        (WebCore::LayoutPoint::operator FloatPoint):
+        * platform/graphics/LayoutRect.cpp:
+        * platform/graphics/LayoutRect.h:
+        (WebCore::LayoutRect::operator FloatRect):
+        * platform/graphics/LayoutSize.h:
+        (WebCore::LayoutSize::operator FloatSize):
+
 2013-06-28  Christophe Dumez  <[email protected]>
 
         Get rid of IsWorkerGlobalScope and ExtendsDOMGlobalObject extended attributes

Modified: trunk/Source/WebCore/Target.pri (152174 => 152175)


--- trunk/Source/WebCore/Target.pri	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/Target.pri	2013-06-28 17:31:30 UTC (rev 152175)
@@ -2859,9 +2859,6 @@
     platform/graphics/qt/FloatPointQt.cpp \
     platform/graphics/qt/FloatRectQt.cpp \
     platform/graphics/qt/FloatSizeQt.cpp \
-    platform/graphics/qt/LayoutPointQt.cpp \
-    platform/graphics/qt/LayoutRectQt.cpp \
-    platform/graphics/qt/LayoutSizeQt.cpp \
     platform/graphics/qt/GradientQt.cpp \
     platform/graphics/qt/GraphicsContextQt.cpp \
     platform/graphics/qt/IconQt.cpp \

Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatPoint.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -30,8 +30,6 @@
 #include "AffineTransform.h"
 #include "FloatConversion.h"
 #include "IntPoint.h"
-#include "LayoutPoint.h"
-#include "LayoutSize.h"
 #include "TransformationMatrix.h"
 #include <limits>
 #include <math.h>
@@ -42,10 +40,6 @@
 {
 }
 
-FloatPoint::FloatPoint(const LayoutPoint& p) : m_x(p.x()), m_y(p.y())
-{
-}
-
 void FloatPoint::normalize()
 {
     float tempLength = length();
@@ -66,18 +60,6 @@
     return sqrtf(lengthSquared());
 }
 
-void FloatPoint::move(const LayoutSize& size)
-{
-    m_x += size.width();
-    m_y += size.height();
-}
-
-void FloatPoint::moveBy(const LayoutPoint& point)
-{
-    m_x += point.x();
-    m_y += point.y();
-}
-
 FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
 {
     double newX, newY;

Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatPoint.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -64,15 +64,12 @@
 class TransformationMatrix;
 class IntPoint;
 class IntSize;
-class LayoutPoint;
-class LayoutSize;
 
 class FloatPoint {
 public:
     FloatPoint() : m_x(0), m_y(0) { }
     FloatPoint(float x, float y) : m_x(x), m_y(y) { }
     FloatPoint(const IntPoint&);
-    FloatPoint(const LayoutPoint&);
     explicit FloatPoint(const FloatSize& size) : m_x(size.width()), m_y(size.height()) { }
 
     static FloatPoint zero() { return FloatPoint(); }
@@ -99,7 +96,6 @@
         m_x += a.width();
         m_y += a.height();
     }
-    void move(const LayoutSize&);
     void move(const FloatSize& a)
     {
         m_x += a.width();
@@ -110,7 +106,6 @@
         m_x += a.x();
         m_y += a.y();
     }
-    void moveBy(const LayoutPoint&);
     void moveBy(const FloatPoint& a)
     {
         m_x += a.x();

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -29,7 +29,6 @@
 
 #include "FloatConversion.h"
 #include "IntRect.h"
-#include "LayoutRect.h"
 #include <algorithm>
 #include <math.h>
 #include <wtf/MathExtras.h>
@@ -43,10 +42,6 @@
 {
 }
 
-FloatRect::FloatRect(const LayoutRect& r) : m_location(r.location()), m_size(r.size())
-{
-}
-
 FloatRect FloatRect::narrowPrecision(double x, double y, double width, double height)
 {
     return FloatRect(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y), narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatRect.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -62,7 +62,6 @@
 
 namespace WebCore {
 
-class LayoutRect;
 class IntRect;
 class IntPoint;
 
@@ -79,7 +78,6 @@
     FloatRect(float x, float y, float width, float height)
         : m_location(FloatPoint(x, y)), m_size(FloatSize(width, height)) { }
     FloatRect(const IntRect&);
-    FloatRect(const LayoutRect&);
 
     static FloatRect narrowPrecision(double x, double y, double width, double height);
 

Modified: trunk/Source/WebCore/platform/graphics/FloatSize.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatSize.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatSize.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -29,7 +29,6 @@
 
 #include "FloatConversion.h"
 #include "IntSize.h"
-#include "LayoutSize.h"
 #include <limits>
 #include <math.h>
 
@@ -41,10 +40,6 @@
 {
 }
 
-FloatSize::FloatSize(const LayoutSize& size) : m_width(size.width()), m_height(size.height())
-{
-}
-
 float FloatSize::diagonalLength() const
 {
     return sqrtf(diagonalLengthSquared());

Modified: trunk/Source/WebCore/platform/graphics/FloatSize.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/FloatSize.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/FloatSize.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -60,14 +60,12 @@
 namespace WebCore {
 
 class IntSize;
-class LayoutSize;
 
 class FloatSize {
 public:
     FloatSize() : m_width(0), m_height(0) { }
     FloatSize(float width, float height) : m_width(width), m_height(height) { }
     FloatSize(const IntSize&);
-    FloatSize(const LayoutSize&);
 
     static FloatSize narrowPrecision(double width, double height);
 

Modified: trunk/Source/WebCore/platform/graphics/LayoutPoint.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/LayoutPoint.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -35,14 +35,6 @@
 #include "LayoutSize.h"
 #include <wtf/MathExtras.h>
 
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QPoint;
-class QPointF;
-QT_END_NAMESPACE
-#endif
-
 namespace WebCore {
 
 class LayoutPoint {
@@ -89,13 +81,9 @@
     {
         return LayoutPoint(m_y, m_x);
     }
+    
+    operator FloatPoint() const { return FloatPoint(m_x, m_y); }
 
-#if PLATFORM(QT)
-    explicit LayoutPoint(const QPoint&);
-    explicit LayoutPoint(const QPointF&);
-    operator QPointF() const;
-#endif
-
 private:
     LayoutUnit m_x, m_y;
 };

Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/LayoutRect.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -31,8 +31,6 @@
 #include "config.h"
 #include "LayoutRect.h"
 
-#include "FloatRect.h"
-#include "LayoutUnit.h"
 #include <algorithm>
 
 using std::max;

Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/LayoutRect.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -31,19 +31,12 @@
 #ifndef LayoutRect_h
 #define LayoutRect_h
 
+#include "FloatRect.h"
 #include "IntRect.h"
 #include "LayoutBoxExtent.h"
 #include "LayoutPoint.h"
 #include <wtf/Vector.h>
 
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QRect;
-class QRectF;
-QT_END_NAMESPACE
-#endif
-
 namespace WebCore {
 
 class FloatRect;
@@ -175,13 +168,9 @@
         // Return a rect that is slightly smaller than the true max rect to allow pixelSnapping to round up to the nearest IntRect without overflowing.
         return LayoutRect(LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMax(), LayoutUnit::nearlyMax());
     }
+    
+    operator FloatRect() const { return FloatRect(m_location, m_size); }
 
-#if PLATFORM(QT)
-    explicit LayoutRect(const QRect&);
-    explicit LayoutRect(const QRectF&);
-    operator QRectF() const;
-#endif
-
 private:
     LayoutPoint m_location;
     LayoutSize m_size;

Modified: trunk/Source/WebCore/platform/graphics/LayoutSize.h (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/LayoutSize.h	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/LayoutSize.h	2013-06-28 17:31:30 UTC (rev 152175)
@@ -35,14 +35,6 @@
 #include "IntSize.h"
 #include "LayoutUnit.h"
 
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QSize;
-class QSizeF;
-QT_END_NAMESPACE
-#endif
-
 namespace WebCore {
 
 class LayoutPoint;
@@ -120,11 +112,7 @@
         return LayoutSize(m_height, m_width);
     }
 
-#if PLATFORM(QT)
-    explicit LayoutSize(const QSize&);
-    explicit LayoutSize(const QSizeF&);
-    operator QSizeF() const;
-#endif
+    operator FloatSize() const { return FloatSize(m_width, m_height); }
 
 private:
     LayoutUnit m_width, m_height;

Deleted: trunk/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/qt/LayoutPointQt.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "LayoutPoint.h"
-
-#include <QPoint>
-#include <QPointF>
-
-namespace WebCore {
-
-LayoutPoint::LayoutPoint(const QPoint& point)
-    : m_x(point.x())
-    , m_y(point.y())
-{
-}
-
-LayoutPoint::LayoutPoint(const QPointF& point)
-    : m_x(point.x())
-    , m_y(point.y())
-{
-}
-
-LayoutPoint::operator QPointF() const
-{
-    return QPointF(m_x, m_y);
-}
-
-} // namespace

Deleted: trunk/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/qt/LayoutRectQt.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -1,45 +0,0 @@
-/*
-    Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "LayoutRect.h"
-
-#include <QRect>
-#include <QRectF>
-
-namespace WebCore {
-
-LayoutRect::LayoutRect(const QRect& r)
-    : m_location(r.topLeft())
-    , m_size(r.width(), r.height())
-{
-}
-
-LayoutRect::LayoutRect(const QRectF& r)
-    : m_location(r.topLeft())
-    , m_size(r.width(), r.height())
-{
-}
-
-LayoutRect::operator QRectF() const
-{
-    return QRectF(x(), y(), width(), height());
-}
-
-} // namespace

Deleted: trunk/Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp (152174 => 152175)


--- trunk/Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp	2013-06-28 17:13:41 UTC (rev 152174)
+++ trunk/Source/WebCore/platform/graphics/qt/LayoutSizeQt.cpp	2013-06-28 17:31:30 UTC (rev 152175)
@@ -1,46 +0,0 @@
-/*
-    Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#include "LayoutSize.h"
-
-#include <QSize>
-#include <QSizeF>
-
-namespace WebCore {
-
-LayoutSize::LayoutSize(const QSize& size)
-    : m_width(size.width())
-    , m_height(size.height())
-{
-}
-
-LayoutSize::LayoutSize(const QSizeF& size)
-    : m_width(size.width())
-    , m_height(size.height())
-{
-}
-
-LayoutSize::operator QSizeF() const
-{
-    return QSizeF(width(), height());
-}
-
-} // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to