Title: [97583] trunk/Source/WebCore
Revision
97583
Author
[email protected]
Date
2011-10-16 21:27:09 -0700 (Sun, 16 Oct 2011)

Log Message

Inline CSSPrimitiveValue::isQuirkValue() as non-virtual function
https://bugs.webkit.org/show_bug.cgi?id=64865

Patch by David Barr <[email protected]> on 2011-10-16
Reviewed by Darin Adler.

Based on profiling and patch from:
Tamas Czene <[email protected]>

This is expected to produce a small performance progression.
Additional memory overhead is avoided by using spare bits.
CSSQuirkPrimitiveValue is removed as it becomes just a factory.

* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.order:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValidPrimitive):
* css/CSSParserValues.cpp:
(WebCore::CSSParserValue::createCSSValue):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::createAllowingMarginQuirk):
Moved from CSSQuirkPrimitiveValue::create.
(WebCore::CSSPrimitiveValue::isQuirkValue):
* css/CSSQuirkPrimitiveValue.h: Removed.
* css/SVGCSSParser.cpp:
(WebCore::CSSParser::parseSVGValue):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97582 => 97583)


--- trunk/Source/WebCore/ChangeLog	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/ChangeLog	2011-10-17 04:27:09 UTC (rev 97583)
@@ -1,3 +1,36 @@
+2011-10-16  David Barr  <[email protected]>
+
+        Inline CSSPrimitiveValue::isQuirkValue() as non-virtual function
+        https://bugs.webkit.org/show_bug.cgi?id=64865
+
+        Reviewed by Darin Adler.
+
+        Based on profiling and patch from:
+        Tamas Czene <[email protected]>
+
+        This is expected to produce a small performance progression.
+        Additional memory overhead is avoided by using spare bits.
+        CSSQuirkPrimitiveValue is removed as it becomes just a factory.
+
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * WebCore.order:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValidPrimitive):
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserValue::createCSSValue):
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::createAllowingMarginQuirk):
+        Moved from CSSQuirkPrimitiveValue::create.
+        (WebCore::CSSPrimitiveValue::isQuirkValue):
+        * css/CSSQuirkPrimitiveValue.h: Removed.
+        * css/SVGCSSParser.cpp:
+        (WebCore::CSSParser::parseSVGValue):
+
 2011-10-16  Kentaro Hara  <[email protected]>
 
         Generate XMLHttpRequest constructor for JSC by [Constructor] IDL

Modified: trunk/Source/WebCore/GNUmakefile.list.am (97582 => 97583)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-10-17 04:27:09 UTC (rev 97583)
@@ -993,7 +993,6 @@
 	Source/WebCore/css/CSSPropertyLonghand.h \
 	Source/WebCore/css/CSSPropertySourceData.cpp \
 	Source/WebCore/css/CSSPropertySourceData.h \
-	Source/WebCore/css/CSSQuirkPrimitiveValue.h \
 	Source/WebCore/css/CSSReflectionDirection.h \
 	Source/WebCore/css/CSSReflectValue.cpp \
 	Source/WebCore/css/CSSReflectValue.h \

Modified: trunk/Source/WebCore/WebCore.gypi (97582 => 97583)


--- trunk/Source/WebCore/WebCore.gypi	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/WebCore.gypi	2011-10-17 04:27:09 UTC (rev 97583)
@@ -2380,7 +2380,6 @@
             'css/CSSPropertyLonghand.cpp',
             'css/CSSPropertyLonghand.h',
             'css/CSSPropertySourceData.cpp',
-            'css/CSSQuirkPrimitiveValue.h',
             'css/CSSReflectValue.cpp',
             'css/CSSRule.cpp',
             'css/CSSRule.h',

Modified: trunk/Source/WebCore/WebCore.order (97582 => 97583)


--- trunk/Source/WebCore/WebCore.order	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/WebCore.order	2011-10-17 04:27:09 UTC (rev 97583)
@@ -3243,7 +3243,6 @@
 __ZN7WebCore16CSSStyleSelector22checkForTextSizeAdjustEv
 __ZN7WebCore16CSSStyleSelector27checkForGenericFamilyChangeEPNS_11RenderStyleES2_
 __ZN7WebCore16CSSStyleSelector18checkForZoomChangeEPNS_11RenderStyleES2_
-__ZN7WebCore22CSSQuirkPrimitiveValue12isQuirkValueEv
 __ZN7WebCore11RenderStyle16setLetterSpacingEi
 __ZN7WebCore11RenderStyle14setWordSpacingEi
 __ZNK7WebCore19ApplyPropertyLengthILNS_10LengthAutoE0ELNS_15LengthIntrinsicE0ELNS_18LengthMinIntrinsicE0ELNS_10LengthNoneE0ELNS_15LengthUndefinedE0EE10applyValueEPNS_16CSSStyleSelectorEPNS_8CSSValueE
@@ -26363,7 +26362,6 @@
 __ZN3WTF10makeStringIPKccNS_6StringEEES3_T_T0_T1_
 __ZN3WTF13tryMakeStringIPKccNS_6StringEEENS_10PassRefPtrINS_10StringImplEEET_T0_T1_
 __ZNK7WebCore15GraphicsContext25imageInterpolationQualityEv
-__ZN7WebCore22CSSQuirkPrimitiveValueD0Ev
 __ZN7WebCore20jsSVGSVGElementStyleEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
 __ZN7WebCore16JSSVGPathElement3putEPN3JSC9ExecStateERKNS1_10IdentifierENS1_7JSValueERNS1_15PutPropertySlotE
 __ZN3JSC9lookupPutIN7WebCore16JSSVGPathElementEEEbPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEPKNS_9HashTableEPT_

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (97582 => 97583)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-10-17 04:27:09 UTC (rev 97583)
@@ -33274,10 +33274,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\css\CSSQuirkPrimitiveValue.h"
-				>
-			</File>
-			<File
 				RelativePath="..\css\CSSReflectionDirection.h"
 				>
 			</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (97582 => 97583)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-17 04:27:09 UTC (rev 97583)
@@ -3459,7 +3459,6 @@
 		A80E6CE70A1989CA007FB8C5 /* CSSFontFaceRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80E6CBD0A1989CA007FB8C5 /* CSSFontFaceRule.cpp */; };
 		A80E6CE80A1989CA007FB8C5 /* ShadowValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CBE0A1989CA007FB8C5 /* ShadowValue.h */; };
 		A80E6CE90A1989CA007FB8C5 /* CSSValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CBF0A1989CA007FB8C5 /* CSSValueList.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		A80E6CEA0A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CC00A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h */; };
 		A80E6CEB0A1989CA007FB8C5 /* CSSImportRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80E6CC10A1989CA007FB8C5 /* CSSImportRule.cpp */; };
 		A80E6CEC0A1989CA007FB8C5 /* FontFamilyValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80E6CC20A1989CA007FB8C5 /* FontFamilyValue.cpp */; };
 		A80E6CED0A1989CA007FB8C5 /* FontValue.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CC30A1989CA007FB8C5 /* FontValue.h */; };
@@ -10635,7 +10634,6 @@
 		A80E6CBD0A1989CA007FB8C5 /* CSSFontFaceRule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceRule.cpp; sourceTree = "<group>"; };
 		A80E6CBE0A1989CA007FB8C5 /* ShadowValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ShadowValue.h; sourceTree = "<group>"; };
 		A80E6CBF0A1989CA007FB8C5 /* CSSValueList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSValueList.h; sourceTree = "<group>"; };
-		A80E6CC00A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSQuirkPrimitiveValue.h; sourceTree = "<group>"; };
 		A80E6CC10A1989CA007FB8C5 /* CSSImportRule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSImportRule.cpp; sourceTree = "<group>"; };
 		A80E6CC20A1989CA007FB8C5 /* FontFamilyValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilyValue.cpp; sourceTree = "<group>"; };
 		A80E6CC30A1989CA007FB8C5 /* FontValue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontValue.h; sourceTree = "<group>"; };
@@ -20579,7 +20577,6 @@
 				BCEA4789097CAAC80094C9E4 /* CSSPropertyNames.in */,
 				82E3D8DC122EA0D1003AE5BC /* CSSPropertySourceData.cpp */,
 				82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */,
-				A80E6CC00A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h */,
 				9362640A0DE1137D009D5A00 /* CSSReflectionDirection.h */,
 				BC5A12DD0DC0414800C9AFAD /* CSSReflectValue.cpp */,
 				BC5A12DE0DC0414800C9AFAD /* CSSReflectValue.h */,
@@ -21856,7 +21853,6 @@
 				0F6ECD450F252F3700BDE271 /* CSSPropertyLonghand.h in Headers */,
 				656580F409D12B20000E61D7 /* CSSPropertyNames.h in Headers */,
 				82E3D8DF122EA0D1003AE5BC /* CSSPropertySourceData.h in Headers */,
-				A80E6CEA0A1989CA007FB8C5 /* CSSQuirkPrimitiveValue.h in Headers */,
 				9362640B0DE1137D009D5A00 /* CSSReflectionDirection.h in Headers */,
 				BC5A12E00DC0414800C9AFAD /* CSSReflectValue.h in Headers */,
 				A80E6D0D0A1989CA007FB8C5 /* CSSRule.h in Headers */,

Modified: trunk/Source/WebCore/css/CSSParser.cpp (97582 => 97583)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-10-17 04:27:09 UTC (rev 97583)
@@ -47,7 +47,6 @@
 #include "CSSProperty.h"
 #include "CSSPropertyNames.h"
 #include "CSSPropertySourceData.h"
-#include "CSSQuirkPrimitiveValue.h"
 #include "CSSReflectValue.h"
 #include "CSSRuleList.h"
 #include "CSSSelector.h"
@@ -809,7 +808,7 @@
     if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
         return createPrimitiveNumericValue(value);
     if (value->unit >= CSSParserValue::Q_EMS)
-        return CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
+        return CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS);
     return 0;
 }
 

Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (97582 => 97583)


--- trunk/Source/WebCore/css/CSSParserValues.cpp	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp	2011-10-17 04:27:09 UTC (rev 97583)
@@ -23,7 +23,6 @@
 
 #include "CSSPrimitiveValue.h"
 #include "CSSFunctionValue.h"
-#include "CSSQuirkPrimitiveValue.h"
 #include "CSSSelector.h"
 #include "CSSSelectorList.h"
 
@@ -83,7 +82,7 @@
     else if (unit >= CSSPrimitiveValue::CSS_TURN && unit <= CSSPrimitiveValue::CSS_REMS) // CSS3 Values and Units
         parsedValue = CSSPrimitiveValue::create(fValue, (CSSPrimitiveValue::UnitTypes)unit);
     else if (unit >= CSSParserValue::Q_EMS)
-        parsedValue = CSSQuirkPrimitiveValue::create(fValue, CSSPrimitiveValue::CSS_EMS);
+        parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(fValue, CSSPrimitiveValue::CSS_EMS);
     return parsedValue;
 }
     

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (97582 => 97583)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2011-10-17 04:27:09 UTC (rev 97583)
@@ -167,12 +167,14 @@
 CSSPrimitiveValue::CSSPrimitiveValue()
     : m_type(0)
     , m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
 }
 
 CSSPrimitiveValue::CSSPrimitiveValue(int ident)
     : m_type(CSS_IDENT)
     , m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
     m_value.ident = ident;
 }
@@ -180,6 +182,7 @@
 CSSPrimitiveValue::CSSPrimitiveValue(double num, UnitTypes type)
     : m_type(type)
     , m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
     ASSERT(isfinite(num));
     m_value.num = num;
@@ -188,6 +191,7 @@
 CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitTypes type)
     : m_type(type)
     , m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
     if ((m_value.string = str.impl()))
         m_value.string->ref();
@@ -196,12 +200,14 @@
 CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color)
     : m_type(CSS_RGBCOLOR)
     , m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
     m_value.rgbcolor = color;
 }
 
 CSSPrimitiveValue::CSSPrimitiveValue(const Length& length)
     : m_hasCachedCSSText(false)
+    , m_isQuirkValue(false)
 {
     switch (length.type()) {
         case Auto:

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (97582 => 97583)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2011-10-17 04:27:09 UTC (rev 97583)
@@ -52,6 +52,7 @@
 
 class CSSPrimitiveValue : public CSSValue {
 public:
+    static const int UnitTypesBits = 8;
     enum UnitTypes {
         CSS_UNKNOWN = 0,
         CSS_NUMBER = 1,
@@ -132,6 +133,17 @@
         return adoptRef(new CSSPrimitiveValue(value));
     }
 
+    // This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
+    // The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em.
+    // When the quirky value is used, if you're in quirks mode, the margin will collapse away
+    // inside a table cell.
+    static PassRefPtr<CSSPrimitiveValue> createAllowingMarginQuirk(double value, UnitTypes type)
+    {
+        CSSPrimitiveValue* quirkValue = new CSSPrimitiveValue(value, type);
+        quirkValue->m_isQuirkValue = true;
+        return adoptRef(quirkValue);
+    }
+
     virtual ~CSSPrimitiveValue();
 
     void cleanup();
@@ -199,7 +211,7 @@
     virtual bool parseString(const String&, bool = false);
     virtual String cssText() const;
 
-    virtual bool isQuirkValue() { return false; }
+    bool isQuirkValue() { return m_isQuirkValue; }
 
     virtual void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
 
@@ -243,8 +255,9 @@
 
     virtual unsigned short cssValueType() const;
 
-    signed m_type : 31;
+    signed m_type : UnitTypesBits;
     mutable unsigned m_hasCachedCSSText : 1;
+    unsigned m_isQuirkValue : 1;
     union {
         int ident;
         double num;

Deleted: trunk/Source/WebCore/css/CSSQuirkPrimitiveValue.h (97582 => 97583)


--- trunk/Source/WebCore/css/CSSQuirkPrimitiveValue.h	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/CSSQuirkPrimitiveValue.h	2011-10-17 04:27:09 UTC (rev 97583)
@@ -1,50 +0,0 @@
-/*
- * (C) 1999-2003 Lars Knoll ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef CSSQuirkPrimitiveValue_h
-#define CSSQuirkPrimitiveValue_h
-
-#include "CSSPrimitiveValue.h"
-
-namespace WebCore {
-
-// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
-// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em.
-// When the quirky value is used, if you're in quirks mode, the margin will collapse away
-// inside a table cell.
-class CSSQuirkPrimitiveValue : public CSSPrimitiveValue {
-public:
-    static PassRefPtr<CSSQuirkPrimitiveValue> create(double value, UnitTypes type)
-    {
-        return adoptRef(new CSSQuirkPrimitiveValue(value, type));
-    }
-
-private:
-    CSSQuirkPrimitiveValue(double num, UnitTypes type)
-        : CSSPrimitiveValue(num, type)
-    {
-    }
-
-    virtual bool isQuirkValue() { return true; }
-};
-
-} // namespace WebCore
-
-#endif // CSSQuirkPrimitiveValue_h

Modified: trunk/Source/WebCore/css/SVGCSSParser.cpp (97582 => 97583)


--- trunk/Source/WebCore/css/SVGCSSParser.cpp	2011-10-17 04:03:37 UTC (rev 97582)
+++ trunk/Source/WebCore/css/SVGCSSParser.cpp	2011-10-17 04:27:09 UTC (rev 97583)
@@ -28,7 +28,6 @@
 #include "CSSParser.h"
 #include "CSSProperty.h"
 #include "CSSPropertyNames.h"
-#include "CSSQuirkPrimitiveValue.h"
 #include "CSSValueKeywords.h"
 #include "CSSValueList.h"
 #include "RenderTheme.h"
@@ -307,7 +306,7 @@
         else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
             parsedValue = CSSPrimitiveValue::create(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
         else if (value->unit >= CSSParserValue::Q_EMS)
-            parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
+            parsedValue = CSSPrimitiveValue::createAllowingMarginQuirk(value->fValue, CSSPrimitiveValue::CSS_EMS);
         m_valueList->next();
     }
     if (!parsedValue || (m_valueList->current() && !inShorthand()))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to