Title: [179267] trunk/Source/WebCore
Revision
179267
Author
[email protected]
Date
2015-01-28 10:24:48 -0800 (Wed, 28 Jan 2015)

Log Message

Use an enum class for createFontFamilyValue()'s fromSystemFontID argument
https://bugs.webkit.org/show_bug.cgi?id=140981

Reviewed by Darin Adler.

Use an enum class for createFontFamilyValue()'s fromSystemFontID argument
instead of a simple enum, as suggested by Sam. This is a bit nicer.

Also, use a boolean type for CSSFontFamily.fromSystemFontID instead of
the enum type to facilitate handling. Using a enum (class) for
CSSFontFamily's fromSystemFontID member is not useful as it is always
accessed by name.

* css/CSSFontFamily.h:
* css/CSSParser.cpp:
(WebCore::CSSParser::parseSystemFont):
* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::createFontFamilyValue):
* css/CSSValuePool.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (179266 => 179267)


--- trunk/Source/WebCore/ChangeLog	2015-01-28 18:20:52 UTC (rev 179266)
+++ trunk/Source/WebCore/ChangeLog	2015-01-28 18:24:48 UTC (rev 179267)
@@ -1,5 +1,27 @@
 2015-01-28  Chris Dumez  <[email protected]>
 
+        Use an enum class for createFontFamilyValue()'s fromSystemFontID argument
+        https://bugs.webkit.org/show_bug.cgi?id=140981
+
+        Reviewed by Darin Adler.
+
+        Use an enum class for createFontFamilyValue()'s fromSystemFontID argument
+        instead of a simple enum, as suggested by Sam. This is a bit nicer.
+
+        Also, use a boolean type for CSSFontFamily.fromSystemFontID instead of
+        the enum type to facilitate handling. Using a enum (class) for
+        CSSFontFamily's fromSystemFontID member is not useful as it is always
+        accessed by name.
+
+        * css/CSSFontFamily.h:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseSystemFont):
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::createFontFamilyValue):
+        * css/CSSValuePool.h:
+
+2015-01-28  Chris Dumez  <[email protected]>
+
         Fix typo in markPagesForVistedLinkStyleRecalc()
         https://bugs.webkit.org/show_bug.cgi?id=140977
 

Modified: trunk/Source/WebCore/css/CSSFontFamily.h (179266 => 179267)


--- trunk/Source/WebCore/css/CSSFontFamily.h	2015-01-28 18:20:52 UTC (rev 179266)
+++ trunk/Source/WebCore/css/CSSFontFamily.h	2015-01-28 18:24:48 UTC (rev 179267)
@@ -39,11 +39,9 @@
 // FontDescription. This flag is used to determine if we should do the "use backslash as Yen
 // sign" hack.
 
-enum FromSystemFontIDOrNot { NotFromSystemFontID, FromSystemFontID };
-
 struct CSSFontFamily {
     String familyName;
-    FromSystemFontIDOrNot fromSystemFontID;
+    bool fromSystemFontID;
 };
 
 inline bool operator==(const CSSFontFamily& a, const CSSFontFamily& b)

Modified: trunk/Source/WebCore/css/CSSParser.cpp (179266 => 179267)


--- trunk/Source/WebCore/css/CSSParser.cpp	2015-01-28 18:20:52 UTC (rev 179266)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2015-01-28 18:24:48 UTC (rev 179267)
@@ -6320,7 +6320,7 @@
     addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontDescription.weight()), important);
     addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontDescription.specifiedSize(), CSSPrimitiveValue::CSS_PX), important);
     Ref<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
-    fontFamilyList->append(cssValuePool().createFontFamilyValue(fontDescription.familyAt(0), FromSystemFontID));
+    fontFamilyList->append(cssValuePool().createFontFamilyValue(fontDescription.familyAt(0), FromSystemFontID::Yes));
     addProperty(CSSPropertyFontFamily, WTF::move(fontFamilyList), important);
     addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSSValueNormal), important);
     addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSValueNormal), important);

Modified: trunk/Source/WebCore/css/CSSValuePool.cpp (179266 => 179267)


--- trunk/Source/WebCore/css/CSSValuePool.cpp	2015-01-28 18:20:52 UTC (rev 179266)
+++ trunk/Source/WebCore/css/CSSValuePool.cpp	2015-01-28 18:24:48 UTC (rev 179267)
@@ -119,16 +119,17 @@
     return *cache[intValue];
 }
 
-Ref<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName, FromSystemFontIDOrNot fromSystemFontID)
+Ref<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName, FromSystemFontID fromSystemFontID)
 {
     // Remove one entry at random if the cache grows too large.
     const int maximumFontFamilyCacheSize = 128;
     if (m_fontFamilyValueCache.size() >= maximumFontFamilyCacheSize)
         m_fontFamilyValueCache.remove(m_fontFamilyValueCache.begin());
 
-    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add({familyName, fromSystemFontID}, nullptr).iterator->value;
+    bool isFromSystemID = fromSystemFontID == FromSystemFontID::Yes;
+    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add({familyName, isFromSystemID}, nullptr).iterator->value;
     if (!value)
-        value = CSSPrimitiveValue::create(CSSFontFamily{familyName, fromSystemFontID});
+        value = CSSPrimitiveValue::create(CSSFontFamily{familyName, isFromSystemID});
     return *value;
 }
 

Modified: trunk/Source/WebCore/css/CSSValuePool.h (179266 => 179267)


--- trunk/Source/WebCore/css/CSSValuePool.h	2015-01-28 18:20:52 UTC (rev 179266)
+++ trunk/Source/WebCore/css/CSSValuePool.h	2015-01-28 18:24:48 UTC (rev 179267)
@@ -42,11 +42,13 @@
 
 class CSSValueList;
 
+enum class FromSystemFontID { No, Yes };
+
 class CSSValuePool {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&);
-    Ref<CSSPrimitiveValue> createFontFamilyValue(const String&, FromSystemFontIDOrNot = NotFromSystemFontID);
+    Ref<CSSPrimitiveValue> createFontFamilyValue(const String&, FromSystemFontID = FromSystemFontID::No);
     Ref<CSSInheritedValue> createInheritedValue() { return m_inheritedValue.copyRef(); }
     Ref<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue.copyRef(); }
     Ref<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.copyRef(); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to