Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (123829 => 123830)
--- trunk/Source/WebCore/CMakeLists.txt 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-07-27 02:30:31 UTC (rev 123830)
@@ -2081,6 +2081,7 @@
rendering/style/StyleVisualData.cpp
rendering/style/SVGRenderStyle.cpp
rendering/style/SVGRenderStyleDefs.cpp
+ rendering/style/WrapShapes.cpp
rendering/svg/RenderSVGBlock.cpp
rendering/svg/RenderSVGContainer.cpp
Modified: trunk/Source/WebCore/ChangeLog (123829 => 123830)
--- trunk/Source/WebCore/ChangeLog 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/ChangeLog 2012-07-27 02:30:31 UTC (rev 123830)
@@ -1,3 +1,39 @@
+2012-07-26 Anish Bhayani <anish.bhay...@gmail.com>
+
+ De-virtualize WrapShape classes
+ https://bugs.webkit.org/show_bug.cgi?id=90998
+
+ Reviewed by Andreas Kling.
+
+ The destructor for WrapShapes classes did not need to use a virtual
+ pointer. WrapShapes.cpp is created to cast the WrapShape destructor
+ to the subclass type saving memory and avoiding virtual calls.
+
+ There are existing tests that cover the validity of shapes. The
+ added changes merely change the destructor of the shape objects
+ which is also tested by LayoutTests/fast/exclusions.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * Target.pri:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/style/WrapShapes.cpp: Added.
+ (WebCore):
+ (WebCore::WrapShape::destroy):
+ * rendering/style/WrapShapes.h:
+ (WebCore::WrapShape::deref):
+ (WrapShape):
+ (WebCore::WrapShape::type):
+ (WebCore::WrapShape::setType):
+ (WrapShapeRectangle):
+ (WebCore::WrapShapeRectangle::WrapShapeRectangle):
+ (WebCore::WrapShapeCircle::WrapShapeCircle):
+ (WebCore::WrapShapeEllipse::WrapShapeEllipse):
+ (WebCore::WrapShapePolygon::WrapShapePolygon):
+ (WrapShapePolygon):
+
2012-07-26 Sheriff Bot <webkit.review....@gmail.com>
Unreviewed, rolling out r123808.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (123829 => 123830)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-07-27 02:30:31 UTC (rev 123830)
@@ -4131,6 +4131,7 @@
Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp \
Source/WebCore/rendering/style/SVGRenderStyleDefs.h \
Source/WebCore/rendering/style/SVGRenderStyle.h \
+ Source/WebCore/rendering/style/WrapShapes.cpp \
Source/WebCore/rendering/style/WrapShapes.h \
Source/WebCore/rendering/svg/RenderSVGBlock.cpp \
Source/WebCore/rendering/svg/RenderSVGBlock.h \
Modified: trunk/Source/WebCore/Target.pri (123829 => 123830)
--- trunk/Source/WebCore/Target.pri 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/Target.pri 2012-07-27 02:30:31 UTC (rev 123830)
@@ -1207,6 +1207,7 @@
rendering/style/StyleSurroundData.cpp \
rendering/style/StyleTransformData.cpp \
rendering/style/StyleVisualData.cpp \
+ rendering/style/WrapShapes.cpp \
storage/StorageTask.cpp \
storage/StorageThread.cpp \
storage/Storage.cpp \
@@ -2384,6 +2385,7 @@
rendering/style/StyleVisualData.h \
rendering/style/SVGRenderStyleDefs.h \
rendering/style/SVGRenderStyle.h \
+ rendering/style/WrapShapes.h \
rendering/svg/RenderSVGBlock.h \
rendering/svg/RenderSVGContainer.h \
rendering/svg/RenderSVGEllipse.h \
Modified: trunk/Source/WebCore/WebCore.gypi (123829 => 123830)
--- trunk/Source/WebCore/WebCore.gypi 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/WebCore.gypi 2012-07-27 02:30:31 UTC (rev 123830)
@@ -605,6 +605,7 @@
'rendering/style/StyleTransformData.h',
'rendering/style/StyleVariableData.h',
'rendering/style/StyleVisualData.h',
+ 'rendering/style/WrapShapes.h',
'rendering/svg/SVGResourcesCache.h',
'workers/WorkerRunLoop.h',
'workers/WorkerThread.h',
@@ -4890,6 +4891,7 @@
'rendering/style/StyleSurroundData.cpp',
'rendering/style/StyleTransformData.cpp',
'rendering/style/StyleVisualData.cpp',
+ 'rendering/style/WrapShapes.cpp',
'rendering/svg/SVGInlineFlowBox.cpp',
'rendering/svg/SVGInlineFlowBox.h',
'rendering/svg/SVGInlineTextBox.cpp',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (123829 => 123830)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-07-27 02:30:31 UTC (rev 123830)
@@ -46267,6 +46267,14 @@
RelativePath="..\rendering\style\SVGRenderStyleDefs.h"
>
</File>
+ <File
+ RelativePath="..\rendering\style\WrapShapes.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\rendering\style\WrapShapes.h"
+ >
+ </File>
</Filter>
<Filter
Name="svg"
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (123829 => 123830)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-07-27 02:30:31 UTC (rev 123830)
@@ -6193,6 +6193,7 @@
F5122C901547FA1B0028A93B /* PagePopupDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = F5122C8F1547FA1B0028A93B /* PagePopupDriver.h */; };
F5142C69123F12B000F5BD4C /* LocalizedNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = F5142C68123F12B000F5BD4C /* LocalizedNumber.h */; };
F52AD5E41534245F0059FBE6 /* EmptyClients.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */; };
+ F553B89315BE26C000B134C9 /* WrapShapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F553B89215BE26C000B134C9 /* WrapShapes.cpp */; };
F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55B3D791251F12D003EF269 /* BaseTextInputType.cpp */; };
F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = F55B3D7A1251F12D003EF269 /* BaseTextInputType.h */; };
F55B3DAF1251F12D003EF269 /* ButtonInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55B3D7B1251F12D003EF269 /* ButtonInputType.cpp */; };
@@ -13524,6 +13525,7 @@
F523D30302DE4476018635CA /* Range.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Range.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F523D30402DE4476018635CA /* Range.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Range.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
F52AD5E31534245F0059FBE6 /* EmptyClients.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmptyClients.cpp; sourceTree = "<group>"; };
+ F553B89215BE26C000B134C9 /* WrapShapes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WrapShapes.cpp; path = style/WrapShapes.cpp; sourceTree = "<group>"; };
F55B3D791251F12D003EF269 /* BaseTextInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseTextInputType.cpp; sourceTree = "<group>"; };
F55B3D7A1251F12D003EF269 /* BaseTextInputType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTextInputType.h; sourceTree = "<group>"; };
F55B3D7B1251F12D003EF269 /* ButtonInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonInputType.cpp; sourceTree = "<group>"; };
@@ -20377,6 +20379,7 @@
BC2274750E8366E200E7F975 /* SVGRenderStyle.h */,
BC2274760E8366E200E7F975 /* SVGRenderStyleDefs.cpp */,
BC2274770E8366E200E7F975 /* SVGRenderStyleDefs.h */,
+ F553B89215BE26C000B134C9 /* WrapShapes.cpp */,
FDB51CF4159CD70300E227C5 /* WrapShapes.h */,
);
name = style;
@@ -28396,6 +28399,7 @@
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
C3CF17A415B0063F00276D39 /* IdTargetObserver.cpp in Sources */,
C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */,
+ F553B89315BE26C000B134C9 /* WrapShapes.cpp in Sources */,
1059457315B42953004D37FD /* JSMicroDataItemValueCustom.cpp in Sources */,
1059457715B42A0D004D37FD /* JSMicroDataItemValue.cpp in Sources */,
1059459715B42A8E004D37FD /* PropertyNodeList.cpp in Sources */,
Added: trunk/Source/WebCore/rendering/style/WrapShapes.cpp (0 => 123830)
--- trunk/Source/WebCore/rendering/style/WrapShapes.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/style/WrapShapes.cpp 2012-07-27 02:30:31 UTC (rev 123830)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "WrapShapes.h"
+
+namespace WebCore {
+
+void WrapShape::destroy()
+{
+ switch (m_type) {
+ case WRAP_SHAPE_RECTANGLE:
+ delete static_cast<WrapShapeRectangle*>(this);
+ return;
+ case WRAP_SHAPE_CIRCLE:
+ delete static_cast<WrapShapeCircle*>(this);
+ return;
+ case WRAP_SHAPE_ELLIPSE:
+ delete static_cast<WrapShapeEllipse*>(this);
+ return;
+ case WRAP_SHAPE_POLYGON:
+ delete static_cast<WrapShapePolygon*>(this);
+ return;
+ }
+ ASSERT_NOT_REACHED();
+}
+
+}
Modified: trunk/Source/WebCore/rendering/style/WrapShapes.h (123829 => 123830)
--- trunk/Source/WebCore/rendering/style/WrapShapes.h 2012-07-27 01:48:24 UTC (rev 123829)
+++ trunk/Source/WebCore/rendering/style/WrapShapes.h 2012-07-27 02:30:31 UTC (rev 123830)
@@ -13,7 +13,7 @@
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
@@ -32,10 +32,12 @@
#include "Length.h"
#include "WindRule.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
-class WrapShape : public RefCounted<WrapShape> {
+class WrapShape : public WTF::RefCountedBase {
public:
enum Type {
WRAP_SHAPE_RECTANGLE = 1,
@@ -43,12 +45,23 @@
WRAP_SHAPE_ELLIPSE = 3,
WRAP_SHAPE_POLYGON = 4
};
+
+ void deref()
+ {
+ if (derefBase())
+ destroy();
+ }
- virtual Type type() const = 0;
- virtual ~WrapShape() { }
+ Type type() const { return m_type; }
protected:
- WrapShape() { }
+ WrapShape(Type type)
+ : m_type(type)
+ { }
+
+private:
+ void destroy();
+ Type m_type;
};
class WrapShapeRectangle : public WrapShape {
@@ -68,12 +81,11 @@
void setHeight(Length height) { m_height = height; }
void setCornerRadiusX(Length radiusX) { m_cornerRadiusX = radiusX; }
void setCornerRadiusY(Length radiusY) { m_cornerRadiusY = radiusY; }
-
- virtual Type type() const { return WRAP_SHAPE_RECTANGLE; }
-
+
private:
WrapShapeRectangle()
- : m_cornerRadiusX(Undefined)
+ : WrapShape(WRAP_SHAPE_RECTANGLE)
+ , m_cornerRadiusX(Undefined)
, m_cornerRadiusY(Undefined)
{ }
@@ -97,9 +109,10 @@
void setCenterY(Length centerY) { m_centerY = centerY; }
void setRadius(Length radius) { m_radius = radius; }
- virtual Type type() const { return WRAP_SHAPE_CIRCLE; }
private:
- WrapShapeCircle() { }
+ WrapShapeCircle()
+ : WrapShape(WRAP_SHAPE_CIRCLE)
+ { }
Length m_centerX;
Length m_centerY;
@@ -120,9 +133,10 @@
void setRadiusX(Length radiusX) { m_radiusX = radiusX; }
void setRadiusY(Length radiusY) { m_radiusY = radiusY; }
- virtual Type type() const { return WRAP_SHAPE_ELLIPSE; }
private:
- WrapShapeEllipse() { }
+ WrapShapeEllipse()
+ : WrapShape(WRAP_SHAPE_ELLIPSE)
+ { }
Length m_centerX;
Length m_centerY;
@@ -142,10 +156,10 @@
void setWindRule(WindRule windRule) { m_windRule = windRule; }
void appendPoint(Length x, Length y) { m_values.append(x); m_values.append(y); }
- virtual Type type() const { return WRAP_SHAPE_POLYGON; }
private:
WrapShapePolygon()
- : m_windRule(RULE_NONZERO)
+ : WrapShape(WRAP_SHAPE_POLYGON)
+ , m_windRule(RULE_NONZERO)
{ }
WindRule m_windRule;