Title: [206664] trunk/Source/WebCore
Revision
206664
Author
mmaxfi...@apple.com
Date
2016-09-30 14:11:21 -0700 (Fri, 30 Sep 2016)

Log Message

Templatize internal FontFeatureSettings class for variation font support
https://bugs.webkit.org/show_bug.cgi?id=162774

Reviewed by Alex Christensen.

Font features and font variations are similar in that they are identified
by four-character tags and an associated value. However, the value is an
int for font features and is a float for font variations. In order to
simplify code, we can use the same class for both, and use a template
argument to distinguish between the two. Then, typedefs can be used to
name them.

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj: Rename FontFeatureSettings.{cpp,h}
to FontTaggedSettings.{cpp,h}
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSFontFace.h:
* css/CSSFontFaceSource.h:
* css/CSSFontFeatureValue.cpp:
(WebCore::CSSFontFeatureValue::CSSFontFeatureValue):
* css/CSSFontFeatureValue.h:
* css/FontFace.cpp:
(WebCore::FontFace::featureSettings):
* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseFontFeatureTag):
* loader/cache/CachedFont.h:
* platform/graphics/FontDescription.h:
* platform/graphics/FontFeatureSettings.cpp:
(WebCore::FontFeature::FontFeature): Deleted.
(WebCore::FontFeature::operator==): Deleted.
(WebCore::FontFeature::operator<): Deleted.
(WebCore::FontFeatureSettings::insert): Deleted.
(WebCore::FontFeatureSettings::hash): Deleted.
* platform/graphics/FontFeatureSettings.h: Removed.
(WebCore::fontFeatureTag): Deleted.
(WebCore::FontFeatureTagHash::hash): Deleted.
(WebCore::FontFeatureTagHash::equal): Deleted.
(WebCore::FontFeatureTagHashTraits::constructDeletedValue): Deleted.
(WebCore::FontFeatureTagHashTraits::isDeletedValue): Deleted.
(WebCore::FontFeature::operator!=): Deleted.
(WebCore::FontFeature::tag): Deleted.
(WebCore::FontFeature::value): Deleted.
(WebCore::FontFeature::enabled): Deleted.
(WebCore::FontFeatureSettings::operator==): Deleted.
(WebCore::FontFeatureSettings::operator!=): Deleted.
(WebCore::FontFeatureSettings::size): Deleted.
(WebCore::FontFeatureSettings::operator[]): Deleted.
(WebCore::FontFeatureSettings::at): Deleted.
(WebCore::FontFeatureSettings::begin): Deleted.
(WebCore::FontFeatureSettings::end): Deleted.
* platform/graphics/FontTaggedSettings.cpp: Renamed from Source/WebCore/platform/graphics/FontFeatureSettings.cpp.
(WebCore::FontFeatureSettings::hash):
* platform/graphics/FontTaggedSettings.h: Added.
(WebCore::fontFeatureTag):
(WebCore::FourCharacterTagHash::hash):
(WebCore::FourCharacterTagHash::equal):
(WebCore::FourCharacterTagHashTraits::constructDeletedValue):
(WebCore::FourCharacterTagHashTraits::isDeletedValue):
(WebCore::FontTaggedSetting::operator!=):
(WebCore::FontTaggedSetting::tag):
(WebCore::FontTaggedSetting::value):
(WebCore::FontTaggedSetting::enabled):
(WebCore::FontTaggedSetting<T>::FontTaggedSetting):
(WebCore::=):
(WebCore::FontTaggedSetting<T>::operator<):
(WebCore::FontTaggedSettings::operator==):
(WebCore::FontTaggedSettings::operator!=):
(WebCore::FontTaggedSettings::isEmpty):
(WebCore::FontTaggedSettings::size):
(WebCore::FontTaggedSettings::operator[]):
(WebCore::FontTaggedSettings::at):
(WebCore::FontTaggedSettings::begin):
(WebCore::FontTaggedSettings::end):
(WebCore::FontTaggedSettings<T>::insert):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::tagEquals):
(WebCore::appendOpenTypeFeature):
* platform/graphics/mac/FontCustomPlatformData.h:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (206663 => 206664)


--- trunk/Source/WebCore/CMakeLists.txt	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-09-30 21:11:21 UTC (rev 206664)
@@ -2204,7 +2204,7 @@
     platform/graphics/FontCascade.cpp
     platform/graphics/FontCascadeFonts.cpp
     platform/graphics/FontDescription.cpp
-    platform/graphics/FontFeatureSettings.cpp
+    platform/graphics/FontTaggedSettings.cpp
     platform/graphics/FontGenericFamilies.cpp
     platform/graphics/FontPlatformData.cpp
     platform/graphics/FontRanges.cpp

Modified: trunk/Source/WebCore/ChangeLog (206663 => 206664)


--- trunk/Source/WebCore/ChangeLog	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/ChangeLog	2016-09-30 21:11:21 UTC (rev 206664)
@@ -1,3 +1,86 @@
+2016-09-30  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Templatize internal FontFeatureSettings class for variation font support
+        https://bugs.webkit.org/show_bug.cgi?id=162774
+
+        Reviewed by Alex Christensen.
+
+        Font features and font variations are similar in that they are identified
+        by four-character tags and an associated value. However, the value is an
+        int for font features and is a float for font variations. In order to
+        simplify code, we can use the same class for both, and use a template
+        argument to distinguish between the two. Then, typedefs can be used to
+        name them.
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj: Rename FontFeatureSettings.{cpp,h}
+        to FontTaggedSettings.{cpp,h}
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSFontFace.h:
+        * css/CSSFontFaceSource.h:
+        * css/CSSFontFeatureValue.cpp:
+        (WebCore::CSSFontFeatureValue::CSSFontFeatureValue):
+        * css/CSSFontFeatureValue.h:
+        * css/FontFace.cpp:
+        (WebCore::FontFace::featureSettings):
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseFontFeatureTag):
+        * loader/cache/CachedFont.h:
+        * platform/graphics/FontDescription.h:
+        * platform/graphics/FontFeatureSettings.cpp:
+        (WebCore::FontFeature::FontFeature): Deleted.
+        (WebCore::FontFeature::operator==): Deleted.
+        (WebCore::FontFeature::operator<): Deleted.
+        (WebCore::FontFeatureSettings::insert): Deleted.
+        (WebCore::FontFeatureSettings::hash): Deleted.
+        * platform/graphics/FontFeatureSettings.h: Removed.
+        (WebCore::fontFeatureTag): Deleted.
+        (WebCore::FontFeatureTagHash::hash): Deleted.
+        (WebCore::FontFeatureTagHash::equal): Deleted.
+        (WebCore::FontFeatureTagHashTraits::constructDeletedValue): Deleted.
+        (WebCore::FontFeatureTagHashTraits::isDeletedValue): Deleted.
+        (WebCore::FontFeature::operator!=): Deleted.
+        (WebCore::FontFeature::tag): Deleted.
+        (WebCore::FontFeature::value): Deleted.
+        (WebCore::FontFeature::enabled): Deleted.
+        (WebCore::FontFeatureSettings::operator==): Deleted.
+        (WebCore::FontFeatureSettings::operator!=): Deleted.
+        (WebCore::FontFeatureSettings::size): Deleted.
+        (WebCore::FontFeatureSettings::operator[]): Deleted.
+        (WebCore::FontFeatureSettings::at): Deleted.
+        (WebCore::FontFeatureSettings::begin): Deleted.
+        (WebCore::FontFeatureSettings::end): Deleted.
+        * platform/graphics/FontTaggedSettings.cpp: Renamed from Source/WebCore/platform/graphics/FontFeatureSettings.cpp.
+        (WebCore::FontFeatureSettings::hash):
+        * platform/graphics/FontTaggedSettings.h: Added.
+        (WebCore::fontFeatureTag):
+        (WebCore::FourCharacterTagHash::hash):
+        (WebCore::FourCharacterTagHash::equal):
+        (WebCore::FourCharacterTagHashTraits::constructDeletedValue):
+        (WebCore::FourCharacterTagHashTraits::isDeletedValue):
+        (WebCore::FontTaggedSetting::operator!=):
+        (WebCore::FontTaggedSetting::tag):
+        (WebCore::FontTaggedSetting::value):
+        (WebCore::FontTaggedSetting::enabled):
+        (WebCore::FontTaggedSetting<T>::FontTaggedSetting):
+        (WebCore::=):
+        (WebCore::FontTaggedSetting<T>::operator<):
+        (WebCore::FontTaggedSettings::operator==):
+        (WebCore::FontTaggedSettings::operator!=):
+        (WebCore::FontTaggedSettings::isEmpty):
+        (WebCore::FontTaggedSettings::size):
+        (WebCore::FontTaggedSettings::operator[]):
+        (WebCore::FontTaggedSettings::at):
+        (WebCore::FontTaggedSettings::begin):
+        (WebCore::FontTaggedSettings::end):
+        (WebCore::FontTaggedSettings<T>::insert):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::tagEquals):
+        (WebCore::appendOpenTypeFeature):
+        * platform/graphics/mac/FontCustomPlatformData.h:
+
 2016-09-30  Chris Dumez  <cdu...@apple.com>
 
         Fragment serialization should always use 'xml:' prefix for attributes in XML namespace

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206663 => 206664)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-09-30 21:11:21 UTC (rev 206664)
@@ -1874,8 +1874,8 @@
 		4A5A2ADC161E7E00005889DD /* WebSocketExtensionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */; };
 		4A6E9FC313C17D1D0046A7F8 /* CSSFontFeatureValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC113C17D1D0046A7F8 /* CSSFontFeatureValue.cpp */; };
 		4A6E9FC413C17D1D0046A7F8 /* CSSFontFeatureValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC213C17D1D0046A7F8 /* CSSFontFeatureValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */; };
-		4A6E9FC813C17D570046A7F8 /* FontFeatureSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		4A6E9FC713C17D570046A7F8 /* FontTaggedSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC513C17D570046A7F8 /* FontTaggedSettings.cpp */; };
+		4A6E9FC813C17D570046A7F8 /* FontTaggedSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC613C17D570046A7F8 /* FontTaggedSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4A8C96EB0BE69032004EEFF0 /* FrameSelectionMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */; };
 		4A9CC81716BB9AC600EC645A /* CSSDefaultStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A9CC81516BB9AC600EC645A /* CSSDefaultStyleSheets.cpp */; };
 		4A9CC81816BB9AC600EC645A /* CSSDefaultStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A9CC81616BB9AC600EC645A /* CSSDefaultStyleSheets.h */; };
@@ -8872,8 +8872,8 @@
 		4A5A2ADA161E7E00005889DD /* WebSocketExtensionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSocketExtensionParser.h; sourceTree = "<group>"; };
 		4A6E9FC113C17D1D0046A7F8 /* CSSFontFeatureValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFeatureValue.cpp; sourceTree = "<group>"; };
 		4A6E9FC213C17D1D0046A7F8 /* CSSFontFeatureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFeatureValue.h; sourceTree = "<group>"; };
-		4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureSettings.cpp; sourceTree = "<group>"; };
-		4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = FontFeatureSettings.h; sourceTree = "<group>"; };
+		4A6E9FC513C17D570046A7F8 /* FontTaggedSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontTaggedSettings.cpp; sourceTree = "<group>"; };
+		4A6E9FC613C17D570046A7F8 /* FontTaggedSettings.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = FontTaggedSettings.h; sourceTree = "<group>"; };
 		4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameSelectionMac.mm; sourceTree = "<group>"; };
 		4A9CC81516BB9AC600EC645A /* CSSDefaultStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSDefaultStyleSheets.cpp; sourceTree = "<group>"; };
 		4A9CC81616BB9AC600EC645A /* CSSDefaultStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSDefaultStyleSheets.h; sourceTree = "<group>"; };
@@ -20676,8 +20676,8 @@
 				B2C3DA570D006CD600EF6F26 /* FontCascadeFonts.h */,
 				37ACCE620DA2AA960089E602 /* FontDescription.cpp */,
 				B2C3DA550D006CD600EF6F26 /* FontDescription.h */,
-				4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */,
-				4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */,
+				4A6E9FC513C17D570046A7F8 /* FontTaggedSettings.cpp */,
+				4A6E9FC613C17D570046A7F8 /* FontTaggedSettings.h */,
 				E44EE3A617576E5500EEE8CF /* FontGenericFamilies.cpp */,
 				E44EE3A717576E5500EEE8CF /* FontGenericFamilies.h */,
 				0845680712B90DA600960A9F /* FontMetrics.h */,
@@ -24518,7 +24518,7 @@
 				B2C3DA660D006CD600EF6F26 /* FontDescription.h in Headers */,
 				1C6626111C6E7CA600AB527C /* FontFace.h in Headers */,
 				1C24EEA51C729CE40080F8FC /* FontFaceSet.h in Headers */,
-				4A6E9FC813C17D570046A7F8 /* FontFeatureSettings.h in Headers */,
+				4A6E9FC813C17D570046A7F8 /* FontTaggedSettings.h in Headers */,
 				0845680812B90DA600960A9F /* FontMetrics.h in Headers */,
 				B5320D6B122A24E9002D1440 /* FontPlatformData.h in Headers */,
 				371F4FFC0D25E7F300ECE0D5 /* FontRanges.h in Headers */,
@@ -28193,7 +28193,7 @@
 				37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */,
 				1C6626101C6E7CA600AB527C /* FontFace.cpp in Sources */,
 				1C24EEA41C729CE40080F8FC /* FontFaceSet.cpp in Sources */,
-				4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */,
+				4A6E9FC713C17D570046A7F8 /* FontTaggedSettings.cpp in Sources */,
 				E44EE3A817577EBD00EEE8CF /* FontGenericFamilies.cpp in Sources */,
 				84B62685133138F90095A489 /* FontPlatformData.cpp in Sources */,
 				B5320D6C122A24E9002D1440 /* FontPlatformDataCocoa.mm in Sources */,

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (206663 => 206664)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -53,7 +53,7 @@
 #include "CursorList.h"
 #include "Document.h"
 #include "ExceptionCode.h"
-#include "FontFeatureSettings.h"
+#include "FontTaggedSettings.h"
 #include "HTMLFrameOwnerElement.h"
 #include "Pair.h"
 #include "PseudoElement.h"
@@ -2876,7 +2876,7 @@
                 return cssValuePool.createIdentifierValue(CSSValueNormal);
             RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
             for (auto& feature : featureSettings)
-                list->append(CSSFontFeatureValue::create(FontFeatureTag(feature.tag()), feature.value()));
+                list->append(CSSFontFeatureValue::create(FontTag(feature.tag()), feature.value()));
             return list;
         }
 #if ENABLE(CSS_GRID_LAYOUT)

Modified: trunk/Source/WebCore/css/CSSFontFace.h (206663 => 206664)


--- trunk/Source/WebCore/css/CSSFontFace.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/CSSFontFace.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "CSSFontFaceRule.h"
-#include "FontFeatureSettings.h"
+#include "FontTaggedSettings.h"
 #include "TextFlags.h"
 #include "Timer.h"
 #include <memory>

Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (206663 => 206664)


--- trunk/Source/WebCore/css/CSSFontFaceSource.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -38,11 +38,13 @@
 class Font;
 struct FontCustomPlatformData;
 class FontDescription;
-class FontFeatureSettings;
 struct FontVariantSettings;
 class SVGFontFaceElement;
 class SharedBuffer;
 
+template <typename T> class FontTaggedSettings;
+typedef FontTaggedSettings<int> FontFeatureSettings;
+
 class CSSFontFaceSource final : public CachedFontClient {
     WTF_MAKE_FAST_ALLOCATED;
 public:

Modified: trunk/Source/WebCore/css/CSSFontFeatureValue.cpp (206663 => 206664)


--- trunk/Source/WebCore/css/CSSFontFeatureValue.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/CSSFontFeatureValue.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-CSSFontFeatureValue::CSSFontFeatureValue(FontFeatureTag&& tag, int value)
+CSSFontFeatureValue::CSSFontFeatureValue(FontTag&& tag, int value)
     : CSSValue(FontFeatureClass)
     , m_tag(WTFMove(tag))
     , m_value(value)

Modified: trunk/Source/WebCore/css/CSSFontFeatureValue.h (206663 => 206664)


--- trunk/Source/WebCore/css/CSSFontFeatureValue.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/CSSFontFeatureValue.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -27,18 +27,18 @@
 #define CSSFontFeatureValue_h
 
 #include "CSSValue.h"
-#include "FontFeatureSettings.h"
+#include "FontTaggedSettings.h"
 
 namespace WebCore {
 
 class CSSFontFeatureValue final : public CSSValue {
 public:
-    static Ref<CSSFontFeatureValue> create(FontFeatureTag&& tag, int value)
+    static Ref<CSSFontFeatureValue> create(FontTag&& tag, int value)
     {
         return adoptRef(*new CSSFontFeatureValue(WTFMove(tag), value));
     }
 
-    const FontFeatureTag& tag() const { return m_tag; }
+    const FontTag& tag() const { return m_tag; }
     int value() const { return m_value; }
     String customCSSText() const;
 
@@ -45,9 +45,9 @@
     bool equals(const CSSFontFeatureValue&) const;
 
 private:
-    CSSFontFeatureValue(FontFeatureTag&&, int);
+    CSSFontFeatureValue(FontTag&&, int);
 
-    FontFeatureTag m_tag;
+    FontTag m_tag;
     const int m_value;
 };
 

Modified: trunk/Source/WebCore/css/FontFace.cpp (206663 => 206664)


--- trunk/Source/WebCore/css/FontFace.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/FontFace.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -343,7 +343,7 @@
         return ASCIILiteral("normal");
     RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
     for (auto& feature : m_backing->featureSettings())
-        list->append(CSSFontFeatureValue::create(FontFeatureTag(feature.tag()), feature.value()));
+        list->append(CSSFontFeatureValue::create(FontTag(feature.tag()), feature.value()));
     return list->cssText();
 }
 

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (206663 => 206664)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -10570,7 +10570,7 @@
     // Feature tag name comes first
     if (value->unit != CSSPrimitiveValue::CSS_STRING)
         return false;
-    FontFeatureTag tag;
+    FontTag tag;
     if (value->string.length() != tag.size())
         return false;
     for (unsigned i = 0; i < tag.size(); ++i) {

Modified: trunk/Source/WebCore/loader/cache/CachedFont.h (206663 => 206664)


--- trunk/Source/WebCore/loader/cache/CachedFont.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/loader/cache/CachedFont.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -35,12 +35,14 @@
 
 class CachedResourceLoader;
 class FontDescription;
-class FontFeatureSettings;
 class FontPlatformData;
 class SVGDocument;
 class SVGFontElement;
 struct FontCustomPlatformData;
 
+template <typename T> class FontTaggedSettings;
+typedef FontTaggedSettings<int> FontFeatureSettings;
+
 class CachedFont : public CachedResource {
 public:
     CachedFont(CachedResourceRequest&&, SessionID, Type = FontResource);

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (206663 => 206664)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -26,7 +26,7 @@
 #define FontDescription_h
 
 #include "CSSValueKeywords.h"
-#include "FontFeatureSettings.h"
+#include "FontTaggedSettings.h"
 #include "TextFlags.h"
 #include "WebKitFontFamilyNames.h"
 #include <unicode/uscript.h>

Deleted: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp (206663 => 206664)


--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. 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 APPLE INC. ``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 APPLE INC. OR
- * CONTRIBUTORS 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 "FontFeatureSettings.h"
-
-#include <wtf/text/AtomicStringHash.h>
-
-namespace WebCore {
-
-FontFeature::FontFeature(const FontFeatureTag& tag, int value)
-    : m_tag(tag)
-    , m_value(value)
-{
-}
-
-FontFeature::FontFeature(FontFeatureTag&& tag, int value)
-    : m_tag(WTFMove(tag))
-    , m_value(value)
-{
-}
-
-bool FontFeature::operator==(const FontFeature& other) const
-{
-    return m_tag == other.m_tag && m_value == other.m_value;
-}
-
-bool FontFeature::operator<(const FontFeature& other) const
-{
-    return (m_tag < other.m_tag) || (m_tag == other.m_tag && m_value < other.m_value);
-}
-
-void FontFeatureSettings::insert(FontFeature&& feature)
-{
-    // This vector will almost always have 0 or 1 items in it. Don't bother with the overhead of a binary search or a hash set.
-    size_t i;
-    for (i = 0; i < m_list.size(); ++i) {
-        if (feature < m_list[i])
-            break;
-    }
-    m_list.insert(i, WTFMove(feature));
-}
-
-unsigned FontFeatureSettings::hash() const
-{
-    IntegerHasher hasher;
-    for (auto& feature : m_list) {
-        hasher.add(FontFeatureTagHash::hash(feature.tag()));
-        hasher.add(feature.value());
-    }
-    return hasher.hash();
-}
-
-}

Deleted: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h (206663 => 206664)


--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. 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 APPLE INC. ``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 APPLE INC. OR
- * CONTRIBUTORS 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.
- */
-
-#ifndef FontFeatureSettings_h
-#define FontFeatureSettings_h
-
-#include <array>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-
-namespace WebCore {
-
-typedef std::array<char, 4> FontFeatureTag;
-
-inline FontFeatureTag fontFeatureTag(const char arr[4]) { return {{ arr[0], arr[1], arr[2], arr[3] }}; }
-
-struct FontFeatureTagHash {
-    static unsigned hash(const FontFeatureTag& characters) { return (characters[0] << 24) | (characters[1] << 16) | (characters[2] << 8) | characters[3]; }
-    static bool equal(const FontFeatureTag& a, const FontFeatureTag& b) { return a == b; }
-    static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-#define _0xFF static_cast<char>(0xFF)
-struct FontFeatureTagHashTraits : WTF::GenericHashTraits<FontFeatureTag> {
-    static const bool emptyValueIsZero = true;
-    static void constructDeletedValue(FontFeatureTag& slot) { new (NotNull, std::addressof(slot)) FontFeatureTag({{ _0xFF, _0xFF, _0xFF, _0xFF }}); }
-    static bool isDeletedValue(const FontFeatureTag& value) { return value == FontFeatureTag({{ _0xFF, _0xFF, _0xFF, _0xFF }}); }
-};
-#undef _0xFF
-
-class FontFeature {
-public:
-    FontFeature() = delete;
-    FontFeature(const FontFeatureTag&, int value);
-    FontFeature(FontFeatureTag&&, int value);
-
-    bool operator==(const FontFeature& other) const;
-    bool operator!=(const FontFeature& other) const { return !(*this == other); }
-    bool operator<(const FontFeature& other) const;
-
-    const FontFeatureTag& tag() const { return m_tag; }
-    int value() const { return m_value; }
-    bool enabled() const { return value(); }
-
-private:
-    FontFeatureTag m_tag;
-    int m_value;
-};
-
-class FontFeatureSettings {
-public:
-    void insert(FontFeature&&);
-    bool operator==(const FontFeatureSettings& other) const { return m_list == other.m_list; }
-    bool operator!=(const FontFeatureSettings& other) const { return !(*this == other); }
-
-    size_t size() const { return m_list.size(); }
-    const FontFeature& operator[](int index) const { return m_list[index]; }
-    const FontFeature& at(size_t index) const { return m_list.at(index); }
-
-    Vector<FontFeature>::const_iterator begin() const { return m_list.begin(); }
-    Vector<FontFeature>::const_iterator end() const { return m_list.end(); }
-
-    unsigned hash() const;
-
-private:
-    Vector<FontFeature> m_list;
-};
-
-}
-
-#endif // FontFeatureSettings_h

Copied: trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp (from rev 206663, trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp) (0 => 206664)


--- trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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 "FontTaggedSettings.h"
+
+#include "TextStream.h"
+
+#include <wtf/text/AtomicStringHash.h>
+
+namespace WebCore {
+
+template <>
+unsigned FontFeatureSettings::hash() const
+{
+    IntegerHasher hasher;
+    for (auto& feature : m_list) {
+        hasher.add(FourCharacterTagHash::hash(feature.tag()));
+        hasher.add(feature.value());
+    }
+    return hasher.hash();
+}
+
+}

Added: trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h (0 => 206664)


--- trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. 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 APPLE INC. ``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 APPLE INC. OR
+ * CONTRIBUTORS 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.
+ */
+
+#pragma once
+
+#include <array>
+#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class TextStream;
+
+typedef std::array<char, 4> FontTag;
+
+inline FontTag fontFeatureTag(const char arr[4]) { return {{ arr[0], arr[1], arr[2], arr[3] }}; }
+
+struct FourCharacterTagHash {
+    static unsigned hash(const FontTag& characters) { return (characters[0] << 24) | (characters[1] << 16) | (characters[2] << 8) | characters[3]; }
+    static bool equal(const FontTag& a, const FontTag& b) { return a == b; }
+    static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
+const char ff = static_cast<char>(0xFF);
+struct FourCharacterTagHashTraits : WTF::GenericHashTraits<FontTag> {
+    static const bool emptyValueIsZero = true;
+    static void constructDeletedValue(FontTag& slot) { new (NotNull, std::addressof(slot)) FontTag({{ ff, ff, ff, ff }}); }
+    static bool isDeletedValue(const FontTag& value) { return value == FontTag({{ ff, ff, ff, ff }}); }
+};
+
+template <typename T>
+class FontTaggedSetting {
+public:
+    FontTaggedSetting() = delete;
+    FontTaggedSetting(const FontTag&, T value);
+    FontTaggedSetting(FontTag&&, T value);
+
+    bool operator==(const FontTaggedSetting<T>& other) const;
+    bool operator!=(const FontTaggedSetting<T>& other) const { return !(*this == other); }
+    bool operator<(const FontTaggedSetting<T>& other) const;
+
+    const FontTag& tag() const { return m_tag; }
+    T value() const { return m_value; }
+    bool enabled() const { return value(); }
+
+private:
+    FontTag m_tag;
+    T m_value;
+};
+
+template <typename T>
+FontTaggedSetting<T>::FontTaggedSetting(const FontTag& tag, T value)
+    : m_tag(tag)
+    , m_value(value)
+{
+}
+
+template <typename T>
+FontTaggedSetting<T>::FontTaggedSetting(FontTag&& tag, T value)
+    : m_tag(WTFMove(tag))
+    , m_value(value)
+{
+}
+
+template <typename T>
+bool FontTaggedSetting<T>::operator==(const FontTaggedSetting<T>& other) const
+{
+    return m_tag == other.m_tag && m_value == other.m_value;
+}
+
+template <typename T>
+bool FontTaggedSetting<T>::operator<(const FontTaggedSetting<T>& other) const
+{
+    return (m_tag < other.m_tag) || (m_tag == other.m_tag && m_value < other.m_value);
+}
+
+template <typename T>
+class FontTaggedSettings {
+public:
+    void insert(FontTaggedSetting<T>&&);
+    bool operator==(const FontTaggedSettings<T>& other) const { return m_list == other.m_list; }
+    bool operator!=(const FontTaggedSettings<T>& other) const { return !(*this == other); }
+
+    bool isEmpty() const { return !size(); }
+    size_t size() const { return m_list.size(); }
+    const FontTaggedSetting<T>& operator[](int index) const { return m_list[index]; }
+    const FontTaggedSetting<T>& at(size_t index) const { return m_list.at(index); }
+
+    typename Vector<FontTaggedSetting<T>>::const_iterator begin() const { return m_list.begin(); }
+    typename Vector<FontTaggedSetting<T>>::const_iterator end() const { return m_list.end(); }
+
+    unsigned hash() const;
+
+private:
+    Vector<FontTaggedSetting<T>> m_list;
+};
+
+template <typename T>
+void FontTaggedSettings<T>::insert(FontTaggedSetting<T>&& feature)
+{
+    // This vector will almost always have 0 or 1 items in it. Don't bother with the overhead of a binary search or a hash set.
+    size_t i;
+    for (i = 0; i < m_list.size(); ++i) {
+        if (!(feature < m_list[i]))
+            break;
+    }
+    if (i < m_list.size() && feature.tag() == m_list[i].tag())
+        m_list.remove(i);
+    m_list.insert(i, WTFMove(feature));
+}
+
+typedef FontTaggedSetting<int> FontFeature;
+typedef FontTaggedSettings<int> FontFeatureSettings;
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (206663 => 206664)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2016-09-30 21:11:21 UTC (rev 206664)
@@ -47,7 +47,7 @@
     CFArrayAppendValue(features, feature.get());
 }
 
-static inline bool tagEquals(FontFeatureTag tag, const char comparison[4])
+static inline bool tagEquals(FontTag tag, const char comparison[4])
 {
     return equalIgnoringASCIICase(tag.data(), comparison, 4);
 }
@@ -133,7 +133,7 @@
 
 static inline void appendOpenTypeFeature(CFMutableArrayRef features, const FontFeature& feature)
 {
-    RetainPtr<CFStringRef> featureKey = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(feature.tag().data()), feature.tag().size() * sizeof(FontFeatureTag::value_type), kCFStringEncodingASCII, false));
+    RetainPtr<CFStringRef> featureKey = adoptCF(CFStringCreateWithBytes(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(feature.tag().data()), feature.tag().size() * sizeof(FontTag::value_type), kCFStringEncodingASCII, false));
     int rawFeatureValue = feature.value();
     RetainPtr<CFNumberRef> featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &rawFeatureValue));
     CFTypeRef featureDictionaryKeys[] = { kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue };
@@ -142,7 +142,7 @@
     CFArrayAppendValue(features, featureDictionary.get());
 }
 
-typedef HashMap<FontFeatureTag, int, FontFeatureTagHash, FontFeatureTagHashTraits> FeaturesMap;
+typedef HashMap<FontTag, int, FourCharacterTagHash, FourCharacterTagHashTraits> FeaturesMap;
 
 static FeaturesMap computeFeatureSettingsFromVariants(const FontVariantSettings& variantSettings)
 {

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h (206663 => 206664)


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h	2016-09-30 21:03:27 UTC (rev 206663)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h	2016-09-30 21:11:21 UTC (rev 206664)
@@ -33,10 +33,12 @@
 namespace WebCore {
 
 class FontDescription;
-class FontFeatureSettings;
 class FontPlatformData;
 class SharedBuffer;
 
+template <typename T> class FontTaggedSettings;
+typedef FontTaggedSettings<int> FontFeatureSettings;
+
 struct FontCustomPlatformData {
     WTF_MAKE_NONCOPYABLE(FontCustomPlatformData); WTF_MAKE_FAST_ALLOCATED;
 public:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to