WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for committing
bug-167061-20170122133939.patch (text/plain), 8.40 KB, created by
Myles C. Maxfield
on 2017-01-22 13:41:35 PST
(
hide
)
Description:
Patch for committing
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2017-01-22 13:41:35 PST
Size:
8.40 KB
patch
obsolete
>Subversion Revision: 211028 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 282cae4e4078628d475463f7e7f1b04806e9d753..cfaa66934d3a48ef7334e8182951f1ae1352dd86 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,36 @@ >+2017-01-22 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Cocoa] Unify FontPlatformData's hashing and equality operators >+ https://bugs.webkit.org/show_bug.cgi?id=167061 >+ >+ Reviewed by Darin Adler. >+ >+ On iOS, we were using CFEqual() and CFHash(), while on macOS >+ we were using pointer hashing and pointer equality. Instead, >+ we should be consistent about these operators. >+ >+ Right now, FontPlatformData holds two internal CTFontRefs, and >+ switching to these higher-level CFEqual() and CFHash() >+ functions is required for eliminating one of these two >+ internal font objects. >+ >+ No new tests because there is no behavior change. >+ >+ * platform/graphics/FontPlatformData.h: >+ (WebCore::FontPlatformData::hash): Deleted. >+ * platform/graphics/cocoa/FontPlatformDataCocoa.mm: >+ (WebCore::FontPlatformData::hash): >+ (WebCore::FontPlatformData::platformIsEqual): >+ (WebCore::cascadeToLastResortAttributesDictionary): >+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp: >+ (WebCore::FontPlatformData::hash): >+ * platform/graphics/win/FontPlatformDataCGWin.cpp: >+ (WebCore::FontPlatformData::hash): >+ * platform/graphics/win/FontPlatformDataCairoWin.cpp: >+ (WebCore::FontPlatformData::hash): >+ * platform/graphics/win/FontPlatformDataDirect2D.cpp: >+ (WebCore::FontPlatformData::hash): >+ > 2017-01-20 Dean Jackson <dino@apple.com> > > [WebGL] Do not allow GPU muxing on some old Mac hardware >diff --git a/Source/WebCore/platform/graphics/FontPlatformData.h b/Source/WebCore/platform/graphics/FontPlatformData.h >index ad382f415a3b510efe413bef7a9dacf1df9c3889..b154b65d4a9690c2b24fbcd39d1494be9213e6de 100644 >--- a/Source/WebCore/platform/graphics/FontPlatformData.h >+++ b/Source/WebCore/platform/graphics/FontPlatformData.h >@@ -172,25 +172,7 @@ public: > FcFontSet* fallbacks() const; > #endif > >- unsigned hash() const >- { >-#if USE(CAIRO) >- return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont.get()); >-#elif PLATFORM(WIN) >- return m_font ? m_font->hash() : 0; >-#elif PLATFORM(COCOA) >- uintptr_t flags = static_cast<uintptr_t>(m_isHashTableDeletedValue << 5 | m_textRenderingMode << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique); >-#if USE(APPKIT) >- uintptr_t fontHash = (uintptr_t)m_font.get(); >-#else >- uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get())); >-#endif >- uintptr_t hashCodes[3] = { fontHash, m_widthVariant, flags }; >- return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); >-#else >-#error "Unsupported configuration" >-#endif >- } >+ unsigned hash() const; > > bool operator==(const FontPlatformData& other) const > { >diff --git a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm >index e22e3269c3ab004dc117f9a5414e2dbcc0d3c251..1cfd3ebdc1b31200abf8f0cd91922b659d7e7243 100644 >--- a/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm >@@ -58,18 +58,27 @@ FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBol > #endif > } > >+unsigned FontPlatformData::hash() const >+{ >+ uintptr_t flags = static_cast<uintptr_t>(m_widthVariant << 6 | m_isHashTableDeletedValue << 5 | m_textRenderingMode << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique); >+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 >+ uintptr_t fontHash = reinterpret_cast<uintptr_t>(m_font.get()); >+#else >+ uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get())); >+#endif >+ uintptr_t hashCodes[] = { fontHash, flags }; >+ return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); >+} >+ > bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const > { >- bool result = false; >- if (m_font || other.m_font) { >-#if PLATFORM(IOS) >- result = m_font && other.m_font && CFEqual(m_font.get(), other.m_font.get()); >+ if (!m_font || !other.m_font) >+ return m_font == other.m_font; >+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200 >+ return m_font == other.m_font; > #else >- result = m_font == other.m_font; >+ return CFEqual(m_font.get(), other.m_font.get()); > #endif >- return result; >- } >- return true; > } > > CTFontRef FontPlatformData::registeredFont() const >@@ -109,11 +118,11 @@ static CFDictionaryRef cascadeToLastResortAttributesDictionary() > > RetainPtr<CTFontDescriptorRef> lastResort = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0)); > >- const void* descriptors[] = { lastResort.get() }; >+ CFTypeRef descriptors[] = { lastResort.get() }; > RetainPtr<CFArrayRef> array = adoptCF(CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks)); > >- const void* keys[] = { kCTFontCascadeListAttribute }; >- const void* values[] = { array.get() }; >+ CFTypeRef keys[] = { kCTFontCascadeListAttribute }; >+ CFTypeRef values[] = { array.get() }; > attributes = CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); > > return attributes; >diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >index 84e1ba115079fb755f86fb1f8755022bc4ba9c49..b8ec73c8e0cae89d7a6ad5784a337d5c05bcecd8 100644 >--- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >+++ b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >@@ -280,6 +280,11 @@ bool FontPlatformData::isFixedPitch() const > return m_fixedWidth; > } > >+unsigned FontPlatformData::hash() const >+{ >+ return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont.get()); >+} >+ > bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const > { > // FcPatternEqual does not support null pointers as arguments. >diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp >index 8920071966b9108860b787a624bfb67c6fbb7ef4..a8453417f91291e16ba0e7e98707b2a6ac37c752 100644 >--- a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp >+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp >@@ -129,6 +129,11 @@ FontPlatformData::FontPlatformData(GDIObject<HFONT> hfont, CGFontRef font, float > { > } > >+unsigned FontPlatformData::hash() const >+{ >+ return m_font ? m_font->hash() : 0; >+} >+ > bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const > { > return m_font == other.m_font >diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp >index f888994514a3dc8626c1d40e1e9834c50097d925..e63a122a22515e120aa68dc63191823ecbdfd8ed 100644 >--- a/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp >+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp >@@ -85,6 +85,11 @@ FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fon > cairo_font_options_destroy(options); > } > >+unsigned FontPlatformData::hash() const >+{ >+ return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont.get()); >+} >+ > bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const > { > return m_font == other.m_font >diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp >index d464dca0290be3076dce75ecd026691132c5dcaa..e0f424d69774624abf0f249a624c74413b991fc5 100644 >--- a/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp >+++ b/Source/WebCore/platform/graphics/win/FontPlatformDataDirect2D.cpp >@@ -104,6 +104,11 @@ static bool fontsAreEqual(IDWriteFont* a, IDWriteFont* b) > return true; > } > >+unsigned FontPlatformData::hash() const >+{ >+ return m_font ? m_font->hash() : 0; >+} >+ > bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const > { > return m_font == other.m_font
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 167061
:
298872
|
298873
|
298874
|
298877
|
298878
|
298879
|
298882
| 299482