<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[188088] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/188088">188088</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2015-08-06 16:31:53 -0700 (Thu, 06 Aug 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Make FontDescriptionKey sensitive to FontFeatureSettings
https://bugs.webkit.org/show_bug.cgi?id=147751
Reviewed by Anders Carlsson.
Just like how FontDescription hashes should be sensitive to locale, they should
also be sensitive to font features.
This patch also fixes operator== for FontDescriptionKey, which was previously
comparing hashes for equality instead of the underlying data. Comparing hashes
for equality is useless inside hashmaps.
This is in preparation for implementing font-feature-settings.
No new tests because there is no behavior change.
* platform/graphics/FontCache.cpp:
(WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
(WebCore::FontPlatformDataCacheKey::isHashTableDeletedValue):
(WebCore::FontPlatformDataCacheKey::hashTableDeletedSize): Deleted.
* platform/graphics/FontCache.h:
(WebCore::FontDescriptionKey::FontDescriptionKey):
(WebCore::FontDescriptionKey::operator==):
(WebCore::FontDescriptionKey::operator!=):
(WebCore::FontDescriptionKey::isHashTableDeletedValue):
(WebCore::FontDescriptionKey::computeHash):
* platform/graphics/FontFeatureSettings.cpp:
(WebCore::FontFeature::hash):
(WebCore::FontFeatureSettings::hash):
* platform/graphics/FontFeatureSettings.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCachecpp">trunk/Source/WebCore/platform/graphics/FontCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCacheh">trunk/Source/WebCore/platform/graphics/FontCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontFeatureSettingscpp">trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontFeatureSettingsh">trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (188087 => 188088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-06 23:31:45 UTC (rev 188087)
+++ trunk/Source/WebCore/ChangeLog        2015-08-06 23:31:53 UTC (rev 188088)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-08-06 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Make FontDescriptionKey sensitive to FontFeatureSettings
+ https://bugs.webkit.org/show_bug.cgi?id=147751
+
+ Reviewed by Anders Carlsson.
+
+ Just like how FontDescription hashes should be sensitive to locale, they should
+ also be sensitive to font features.
+
+ This patch also fixes operator== for FontDescriptionKey, which was previously
+ comparing hashes for equality instead of the underlying data. Comparing hashes
+ for equality is useless inside hashmaps.
+
+ This is in preparation for implementing font-feature-settings.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
+ (WebCore::FontPlatformDataCacheKey::isHashTableDeletedValue):
+ (WebCore::FontPlatformDataCacheKey::hashTableDeletedSize): Deleted.
+ * platform/graphics/FontCache.h:
+ (WebCore::FontDescriptionKey::FontDescriptionKey):
+ (WebCore::FontDescriptionKey::operator==):
+ (WebCore::FontDescriptionKey::operator!=):
+ (WebCore::FontDescriptionKey::isHashTableDeletedValue):
+ (WebCore::FontDescriptionKey::computeHash):
+ * platform/graphics/FontFeatureSettings.cpp:
+ (WebCore::FontFeature::hash):
+ (WebCore::FontFeatureSettings::hash):
+ * platform/graphics/FontFeatureSettings.h:
+
</ins><span class="cx"> 2015-08-06 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge SQLStatement into SQLStatementBackend
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (188087 => 188088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-08-06 23:31:45 UTC (rev 188087)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp        2015-08-06 23:31:53 UTC (rev 188088)
</span><span class="lines">@@ -105,9 +105,12 @@
</span><span class="cx"> , m_family(family)
</span><span class="cx"> { }
</span><span class="cx">
</span><del>- FontPlatformDataCacheKey(HashTableDeletedValueType) : m_fontDescriptionKey(hashTableDeletedSize()) { }
- bool isHashTableDeletedValue() const { return m_fontDescriptionKey.size == hashTableDeletedSize(); }
</del><ins>+ explicit FontPlatformDataCacheKey(HashTableDeletedValueType t)
+ : m_fontDescriptionKey(t)
+ { }
</ins><span class="cx">
</span><ins>+ bool isHashTableDeletedValue() const { return m_fontDescriptionKey.isHashTableDeletedValue(); }
+
</ins><span class="cx"> bool operator==(const FontPlatformDataCacheKey& other) const
</span><span class="cx"> {
</span><span class="cx"> return equalIgnoringCase(m_family, other.m_family) && m_fontDescriptionKey == other.m_fontDescriptionKey;
</span><span class="lines">@@ -115,9 +118,6 @@
</span><span class="cx">
</span><span class="cx"> FontDescriptionKey m_fontDescriptionKey;
</span><span class="cx"> AtomicString m_family;
</span><del>-
-private:
- static unsigned hashTableDeletedSize() { return 0xFFFFFFFFU; }
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct FontPlatformDataCacheKeyHash {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (188087 => 188088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.h        2015-08-06 23:31:45 UTC (rev 188087)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h        2015-08-06 23:31:53 UTC (rev 188088)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><ins>+#include <wtf/text/AtomicStringHash.h>
</ins><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -67,18 +68,40 @@
</span><span class="cx">
</span><span class="cx"> // This key contains the FontDescription fields other than family that matter when fetching FontDatas (platform fonts).
</span><span class="cx"> struct FontDescriptionKey {
</span><del>- explicit FontDescriptionKey(unsigned size = 0)
- : size(size)
- , weight(0)
- , flags(0)
- , localeHash(0)
- { }
</del><ins>+ FontDescriptionKey() = default;
+
</ins><span class="cx"> FontDescriptionKey(const FontDescription& description)
</span><del>- : size(description.computedPixelSize())
- , weight(description.weight())
- , flags(makeFlagKey(description))
- , localeHash(description.locale().isNull() ? 0 : description.locale().impl()->existingHash())
</del><ins>+ : m_size(description.computedPixelSize())
+ , m_weight(description.weight())
+ , m_flags(makeFlagKey(description))
+ , m_locale(description.locale())
+ , m_featureSettings(description.featureSettings())
</ins><span class="cx"> { }
</span><ins>+
+ explicit FontDescriptionKey(WTF::HashTableDeletedValueType)
+ : m_size(cHashTableDeletedSize)
+ { }
+
+ bool operator==(const FontDescriptionKey& other) const
+ {
+ return m_size == other.m_size && m_weight == other.m_weight && m_flags == other.m_flags && m_locale == other.m_locale
+ && ((m_featureSettings == other.m_featureSettings) || (m_featureSettings && other.m_featureSettings && m_featureSettings.get() == other.m_featureSettings.get()));
+ }
+
+ bool operator!=(const FontDescriptionKey& other) const
+ {
+ return !(*this == other);
+ }
+
+ bool isHashTableDeletedValue() const { return m_size == cHashTableDeletedSize; }
+
+ inline unsigned computeHash() const
+ {
+ unsigned toHash[] = {m_size, m_weight, m_flags, m_locale.isNull() ? 0 : m_locale.impl()->existingHash(), m_featureSettings ? m_featureSettings->hash() : 0};
+ return StringHasher::hashMemory(toHash, sizeof(toHash));
+ }
+
+private:
</ins><span class="cx"> static unsigned makeFlagKey(const FontDescription& description)
</span><span class="cx"> {
</span><span class="cx"> static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags");
</span><span class="lines">@@ -91,22 +114,14 @@
</span><span class="cx"> | static_cast<unsigned>(description.italic()) << 1
</span><span class="cx"> | static_cast<unsigned>(description.renderingMode());
</span><span class="cx"> }
</span><del>- bool operator==(const FontDescriptionKey& other) const
- {
- return size == other.size && weight == other.weight && flags == other.flags && localeHash == other.localeHash;
- }
- bool operator!=(const FontDescriptionKey& other) const
- {
- return !(*this == other);
- }
- inline unsigned computeHash() const
- {
- return StringHasher::hashMemory<sizeof(FontDescriptionKey)>(this);
- }
- unsigned size;
- unsigned weight;
- unsigned flags;
- unsigned localeHash; // FIXME: Here, and every client of us, makes hashes of hashes.
</del><ins>+
+ static const unsigned cHashTableDeletedSize = 0xFFFFFFFFU;
+
+ unsigned m_size { 0 };
+ unsigned m_weight { 0 };
+ unsigned m_flags { 0 };
+ AtomicString m_locale;
+ RefPtr<FontFeatureSettings> m_featureSettings;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class FontCache {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontFeatureSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp (188087 => 188088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp        2015-08-06 23:31:45 UTC (rev 188087)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp        2015-08-06 23:31:53 UTC (rev 188088)
</span><span class="lines">@@ -26,6 +26,8 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "FontFeatureSettings.h"
</span><span class="cx">
</span><ins>+#include <wtf/text/AtomicStringHash.h>
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> FontFeature::FontFeature(const AtomicString& tag, int value)
</span><span class="lines">@@ -44,6 +46,11 @@
</span><span class="cx"> return (m_tag.impl() < other.m_tag.impl()) || (m_tag.impl() == other.m_tag.impl() && m_value < other.m_value);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+unsigned FontFeature::hash() const
+{
+ return WTF::PairHash<AtomicString, unsigned>::hash(std::make_pair(m_tag, m_value));
+}
+
</ins><span class="cx"> Ref<FontFeatureSettings> FontFeatureSettings::create()
</span><span class="cx"> {
</span><span class="cx"> return adoptRef(*new FontFeatureSettings);
</span><span class="lines">@@ -60,4 +67,12 @@
</span><span class="cx"> m_list.insert(i, WTF::move(feature));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+unsigned FontFeatureSettings::hash() const
+{
+ unsigned result = 0;
+ for (size_t i = 0; i < size(); ++i)
+ result = WTF::pairIntHash(result, at(i).hash());
+ return result;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontFeatureSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h (188087 => 188088)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h        2015-08-06 23:31:45 UTC (rev 188087)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h        2015-08-06 23:31:53 UTC (rev 188088)
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx"> const AtomicString& tag() const { return m_tag; }
</span><span class="cx"> int value() const { return m_value; }
</span><span class="cx">
</span><ins>+ unsigned hash() const;
+
</ins><span class="cx"> private:
</span><span class="cx"> AtomicString m_tag;
</span><span class="cx"> const int m_value { 0 };
</span><span class="lines">@@ -59,6 +61,8 @@
</span><span class="cx"> const FontFeature& operator[](int index) const { return m_list[index]; }
</span><span class="cx"> const FontFeature& at(size_t index) const { return m_list.at(index); }
</span><span class="cx">
</span><ins>+ unsigned hash() const;
+
</ins><span class="cx"> private:
</span><span class="cx"> FontFeatureSettings() { }
</span><span class="cx"> Vector<FontFeature> m_list;
</span></span></pre>
</div>
</div>
</body>
</html>