summaryrefslogtreecommitdiffstats
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cairo/cairo/src/cairo-mutex-impl-private.h23
-rw-r--r--gfx/gl/GLContextProviderEGL.cpp2
-rw-r--r--gfx/gl/GLLibraryEGL.cpp8
-rw-r--r--gfx/gl/GLLibraryEGL.h20
-rw-r--r--gfx/layers/Compositor.cpp4
-rw-r--r--gfx/layers/apz/src/APZCTreeManager.cpp1
-rw-r--r--gfx/layers/ipc/LayerTransactionChild.cpp9
-rw-r--r--gfx/skia/skia/src/core/SkMask.cpp7
-rw-r--r--gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp5
-rw-r--r--gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp9
-rw-r--r--gfx/tests/mochitest/test_acceleration.html2
-rw-r--r--gfx/thebes/gfxAndroidPlatform.cpp22
-rw-r--r--gfx/thebes/gfxFontConstants.h3
-rw-r--r--gfx/thebes/gfxFontFamilyList.h1
-rw-r--r--gfx/thebes/gfxHarfBuzzShaper.cpp30
-rw-r--r--gfx/thebes/gfxPlatform.cpp9
-rw-r--r--gfx/thebes/gfxPlatformFontList.cpp65
-rw-r--r--gfx/thebes/gfxPlatformFontList.h11
-rw-r--r--gfx/thebes/gfxPlatformGtk.cpp20
-rw-r--r--gfx/thebes/gfxPlatformMac.cpp23
-rw-r--r--gfx/thebes/gfxTextRun.cpp20
-rw-r--r--gfx/thebes/gfxTextRun.h3
-rwxr-xr-xgfx/thebes/gfxWindowsPlatform.cpp26
-rw-r--r--gfx/thebes/moz.build10
24 files changed, 171 insertions, 162 deletions
diff --git a/gfx/cairo/cairo/src/cairo-mutex-impl-private.h b/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
index 25223f3ea..6c67f6ebb 100644
--- a/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
+++ b/gfx/cairo/cairo/src/cairo-mutex-impl-private.h
@@ -36,6 +36,7 @@
* Carl D. Worth <cworth@cworth.org>
* Mathias Hasselmann <mathias.hasselmann@gmx.de>
* Behdad Esfahbod <behdad@behdad.org>
+ * Mark Straver <moonchild@palemoon.org>
*/
#ifndef CAIRO_MUTEX_IMPL_PRIVATE_H
@@ -178,24 +179,24 @@
#elif defined(_WIN32) /******************************************************/
#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as ETO_PDY */
-#if !defined(WINVER) || (WINVER < 0x0500)
-# define WINVER 0x0500
+/* We require Windows 7 features */
+#if !defined(WINVER) || (WINVER < 0x0601)
+# define WINVER 0x0601
#endif
-#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
-# define _WIN32_WINNT 0x0500
+#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0601)
+# define _WIN32_WINNT 0x0601
#endif
# include <windows.h>
- typedef CRITICAL_SECTION cairo_mutex_impl_t;
+ typedef SRWLOCK cairo_mutex_impl_t;
# define CAIRO_MUTEX_IMPL_WIN32 1
-# define CAIRO_MUTEX_IMPL_LOCK(mutex) EnterCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) LeaveCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_INIT(mutex) InitializeCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_FINI(mutex) DeleteCriticalSection (&(mutex))
-# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER { NULL, 0, 0, NULL, NULL, 0 }
+# define CAIRO_MUTEX_IMPL_LOCK(mutex) AcquireSRWLockExclusive (&(mutex))
+# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) ReleaseSRWLockExclusive (&(mutex))
+# define CAIRO_MUTEX_IMPL_INIT(mutex) InitializeSRWLock (&(mutex))
+# define CAIRO_MUTEX_IMPL_FINI(mutex) CAIRO_MUTEX_IMPL_NOOP
+# define CAIRO_MUTEX_IMPL_NIL_INITIALIZER SRWLOCK_INIT
#elif defined __OS2__ /******************************************************/
diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp
index ca972e0f3..086f35ad7 100644
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -23,7 +23,7 @@
#ifdef ANDROID
#include <android/log.h>
- #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
+ #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Android" , ## args)
#endif
#define GLES2_LIB "libGLESv2.so"
diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp
index 130bce119..22be44ed6 100644
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -33,9 +33,6 @@ namespace gl {
StaticMutex GLLibraryEGL::sMutex;
GLLibraryEGL sEGLLibrary;
-#ifdef MOZ_B2G
-MOZ_THREAD_LOCAL(EGLContext) GLLibraryEGL::sCurrentContext;
-#endif
// should match the order of EGLExtensions, and be null-terminated.
static const char* sEGLExtensionNames[] = {
@@ -305,11 +302,6 @@ GLLibraryEGL::EnsureInitialized(bool forceAccel, nsACString* const out_failureId
mozilla::ScopedGfxFeatureReporter reporter("EGL");
-#ifdef MOZ_B2G
- if (!sCurrentContext.init())
- MOZ_CRASH("GFX: Tls init failed");
-#endif
-
#ifdef XP_WIN
if (!mEGLLibrary) {
// On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and
diff --git a/gfx/gl/GLLibraryEGL.h b/gfx/gl/GLLibraryEGL.h
index fa6ea748b..88fce067e 100644
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -656,32 +656,12 @@ public:
static void AfterGLCall(const char* glFunction);
#endif
-#ifdef MOZ_B2G
- EGLContext CachedCurrentContext() {
- return sCurrentContext.get();
- }
- void UnsetCachedCurrentContext() {
- sCurrentContext.set(nullptr);
- }
- void SetCachedCurrentContext(EGLContext aCtx) {
- sCurrentContext.set(aCtx);
- }
- bool CachedCurrentContextMatches() {
- return sCurrentContext.get() == fGetCurrentContext();
- }
-
-private:
- static MOZ_THREAD_LOCAL(EGLContext) sCurrentContext;
-public:
-
-#else
EGLContext CachedCurrentContext() {
return nullptr;
}
void UnsetCachedCurrentContext() {}
void SetCachedCurrentContext(EGLContext aCtx) { }
bool CachedCurrentContextMatches() { return true; }
-#endif
private:
bool mInitialized;
diff --git a/gfx/layers/Compositor.cpp b/gfx/layers/Compositor.cpp
index ce7eb9008..b623b8de9 100644
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -173,9 +173,7 @@ Compositor::DrawDiagnosticsInternal(DiagnosticFlags aFlags,
const gfx::Matrix4x4& aTransform,
uint32_t aFlashCounter)
{
-#ifdef MOZ_B2G
- int lWidth = 4;
-#elif defined(ANDROID)
+#if defined(ANDROID)
int lWidth = 10;
#else
int lWidth = 2;
diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp
index 857ae5958..f54326360 100644
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -1145,6 +1145,7 @@ APZCTreeManager::UpdateWheelTransaction(LayoutDeviceIntPoint aRefPoint,
case eMouseUp:
case eMouseDown:
case eMouseDoubleClick:
+ case eMouseAuxClick:
case eMouseClick:
case eContextMenu:
case eDrop:
diff --git a/gfx/layers/ipc/LayerTransactionChild.cpp b/gfx/layers/ipc/LayerTransactionChild.cpp
index 8b60d3b51..f07e2c27f 100644
--- a/gfx/layers/ipc/LayerTransactionChild.cpp
+++ b/gfx/layers/ipc/LayerTransactionChild.cpp
@@ -72,15 +72,6 @@ void
LayerTransactionChild::ActorDestroy(ActorDestroyReason why)
{
mDestroyed = true;
-#ifdef MOZ_B2G
- // Due to poor lifetime management of gralloc (and possibly shmems) we will
- // crash at some point in the future when we get destroyed due to abnormal
- // shutdown. Its better just to crash here. On desktop though, we have a chance
- // of recovering.
- if (why == AbnormalShutdown) {
- NS_RUNTIMEABORT("ActorDestroy by IPC channel failure at LayerTransactionChild");
- }
-#endif
}
} // namespace layers
diff --git a/gfx/skia/skia/src/core/SkMask.cpp b/gfx/skia/skia/src/core/SkMask.cpp
index 111508074..b40b94974 100644
--- a/gfx/skia/skia/src/core/SkMask.cpp
+++ b/gfx/skia/skia/src/core/SkMask.cpp
@@ -43,7 +43,12 @@ uint8_t* SkMask::AllocImage(size_t size) {
#ifdef TRACK_SKMASK_LIFETIME
SkDebugf("SkMask::AllocImage %d\n", gCounter++);
#endif
- return (uint8_t*)sk_malloc_throw(SkAlign4(size));
+ size_t aligned_size = std::numeric_limits<size_t>::max();
+ size_t adjustment = 3;
+ if (size + adjustment > size) {
+ aligned_size = (size + adjustment) & ~adjustment;
+ }
+ return static_cast<uint8_t*>(sk_malloc_throw(aligned_size));
}
/** We explicitly use this allocator for SkBimap pixels, so that we can
diff --git a/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp b/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp
index e3f30b0c1..993e1c59d 100644
--- a/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp
+++ b/gfx/skia/skia/src/gpu/GrBufferAllocPool.cpp
@@ -14,6 +14,7 @@
#include "GrResourceProvider.h"
#include "GrTypes.h"
+#include "SkSafeMath.h"
#include "SkTraceEvent.h"
#ifdef SK_DEBUG
@@ -335,7 +336,7 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
SkASSERT(startVertex);
size_t offset = 0; // assign to suppress warning
- void* ptr = INHERITED::makeSpace(vertexSize * vertexCount,
+ void* ptr = INHERITED::makeSpace(SkSafeMath::Mul(vertexSize, vertexCount),
vertexSize,
buffer,
&offset);
@@ -360,7 +361,7 @@ void* GrIndexBufferAllocPool::makeSpace(int indexCount,
SkASSERT(startIndex);
size_t offset = 0; // assign to suppress warning
- void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t),
+ void* ptr = INHERITED::makeSpace(SkSafeMath::Mul(indexCount, sizeof(uint16_t)),
sizeof(uint16_t),
buffer,
&offset);
diff --git a/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index 9d73cf4f1..ec6c99c6e 100644
--- a/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -828,6 +828,13 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
int lineCount = lines.count() / 2;
int conicCount = conics.count() / 3;
+ int quadAndConicCount = conicCount + quadCount;
+
+ static constexpr int kMaxLines = SK_MaxS32 / kLineSegNumVertices;
+ static constexpr int kMaxQuadsAndConics = SK_MaxS32 / kQuadNumVertices;
+ if (lineCount > kMaxLines || quadAndConicCount > kMaxQuadsAndConics) {
+ return;
+ }
// do lines first
if (lineCount) {
@@ -899,7 +906,7 @@ void AAHairlineBatch::onPrepareDraws(Target* target) const {
ref_quads_index_buffer(target->resourceProvider()));
size_t vertexStride = sizeof(BezierVertex);
- int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * conicCount;
+ int vertexCount = kQuadNumVertices * quadAndConicCount;
void *vertices = target->makeVertexSpace(vertexStride, vertexCount,
&vertexBuffer, &firstVertex);
diff --git a/gfx/tests/mochitest/test_acceleration.html b/gfx/tests/mochitest/test_acceleration.html
index 0475a9590..cb1fcd39b 100644
--- a/gfx/tests/mochitest/test_acceleration.html
+++ b/gfx/tests/mochitest/test_acceleration.html
@@ -98,7 +98,7 @@ switch(osName)
break;
default:
- if (xr.OS == "Android" && xr.widgetToolkit != "gonk") {
+ if (xr.OS == "Android") {
isnot(acceleratedWindows, 0, "Acceleration enabled on Android");
} else {
is(acceleratedWindows, 0, "Acceleration not supported on '" + osName + "'");
diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp
index f587737b5..76427d88c 100644
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -21,6 +21,7 @@
#include "nsIScreenManager.h"
#include "nsILocaleService.h"
#include "nsServiceManagerUtils.h"
+#include "nsUnicodeProperties.h"
#include "gfxPrefs.h"
#include "cairo.h"
#include "VsyncSource.h"
@@ -32,6 +33,7 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
+using namespace mozilla::unicode;
static FT_Library gPlatformFTLibrary = nullptr;
@@ -168,19 +170,17 @@ gfxAndroidPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
static const char kNotoSansCJKJP[] = "Noto Sans CJK JP";
static const char kNotoColorEmoji[] = "Noto Color Emoji";
- if (aNextCh == 0xfe0fu) {
- // if char is followed by VS16, try for a color emoji glyph
- aFontList.AppendElement(kNotoColorEmoji);
+ EmojiPresentation emoji = GetEmojiPresentation(aCh);
+ if (emoji != EmojiPresentation::TextOnly) {
+ if (aNextCh == kVariationSelector16 ||
+ (aNextCh != kVariationSelector15 &&
+ emoji == EmojiPresentation::EmojiDefault)) {
+ // if char is followed by VS16, try for a color emoji glyph
+ aFontList.AppendElement(kNotoColorEmoji);
+ }
}
- if (!IS_IN_BMP(aCh)) {
- uint32_t p = aCh >> 16;
- if (p == 1) { // try color emoji font, unless VS15 (text style) present
- if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
- aFontList.AppendElement(kNotoColorEmoji);
- }
- }
- } else {
+ if (IS_IN_BMP(aCh)) {
// try language-specific "Droid Sans *" and "Noto Sans *" fonts for
// certain blocks, as most devices probably have these
uint8_t block = (aCh >> 8) & 0xff;
diff --git a/gfx/thebes/gfxFontConstants.h b/gfx/thebes/gfxFontConstants.h
index 5aa1eb0c7..3eae49ee1 100644
--- a/gfx/thebes/gfxFontConstants.h
+++ b/gfx/thebes/gfxFontConstants.h
@@ -222,13 +222,14 @@ enum {
#define NS_FONT_SUB_SUPER_SMALL_SIZE (20.0)
#define NS_FONT_SUB_SUPER_LARGE_SIZE (45.0)
-// pref lang id's for font prefs
+// pref lang ids for font prefs
enum eFontPrefLang {
#define FONT_PREF_LANG(enum_id_, str_, atom_id_) eFontPrefLang_ ## enum_id_
#include "gfxFontPrefLangList.h"
#undef FONT_PREF_LANG
, eFontPrefLang_CJKSet // special code for CJK set
+ , eFontPrefLang_Emoji // special code for emoji presentation
, eFontPrefLang_First = eFontPrefLang_Western
, eFontPrefLang_Last = eFontPrefLang_Others
, eFontPrefLang_Count = (eFontPrefLang_Last - eFontPrefLang_First + 1)
diff --git a/gfx/thebes/gfxFontFamilyList.h b/gfx/thebes/gfxFontFamilyList.h
index e240102e0..9d1a3cf49 100644
--- a/gfx/thebes/gfxFontFamilyList.h
+++ b/gfx/thebes/gfxFontFamilyList.h
@@ -38,6 +38,7 @@ enum FontFamilyType : uint32_t {
// special
eFamily_moz_variable,
eFamily_moz_fixed,
+ eFamily_moz_emoji,
eFamily_generic_first = eFamily_serif,
eFamily_generic_last = eFamily_fantasy,
diff --git a/gfx/thebes/gfxHarfBuzzShaper.cpp b/gfx/thebes/gfxHarfBuzzShaper.cpp
index 1f472f88d..4b9dbbc14 100644
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -12,20 +12,14 @@
#include "mozilla/Sprintf.h"
#include "nsUnicodeProperties.h"
#include "nsUnicodeScriptCodes.h"
-#include "nsUnicodeNormalizer.h"
#include "harfbuzz/hb.h"
#include "harfbuzz/hb-ot.h"
-#if ENABLE_INTL_API // ICU is available: we'll use it for Unicode composition
- // and decomposition in preference to nsUnicodeNormalizer.
#include "unicode/unorm.h"
#include "unicode/utext.h"
-#define MOZ_HB_SHAPER_USE_ICU_NORMALIZATION 1
+
static const UNormalizer2 * sNormalizer = nullptr;
-#else
-#undef MOZ_HB_SHAPER_USE_ICU_NORMALIZATION
-#endif
#include <algorithm>
@@ -1091,8 +1085,6 @@ HBUnicodeCompose(hb_unicode_funcs_t *ufuncs,
hb_codepoint_t *ab,
void *user_data)
{
-#if MOZ_HB_SHAPER_USE_ICU_NORMALIZATION
-
if (sNormalizer) {
UChar32 ch = unorm2_composePair(sNormalizer, a, b);
if (ch >= 0) {
@@ -1101,14 +1093,6 @@ HBUnicodeCompose(hb_unicode_funcs_t *ufuncs,
}
}
-#else // no ICU available, use the old nsUnicodeNormalizer
-
- if (nsUnicodeNormalizer::Compose(a, b, ab)) {
- return true;
- }
-
-#endif
-
return false;
}
@@ -1129,8 +1113,6 @@ HBUnicodeDecompose(hb_unicode_funcs_t *ufuncs,
}
#endif
-#if MOZ_HB_SHAPER_USE_ICU_NORMALIZATION
-
if (!sNormalizer) {
return false;
}
@@ -1162,12 +1144,6 @@ HBUnicodeDecompose(hb_unicode_funcs_t *ufuncs,
utext_close(&text);
return *b != 0 || *a != ab;
-
-#else // no ICU available, use the old nsUnicodeNormalizer
-
- return nsUnicodeNormalizer::DecomposeNonRecursively(ab, a, b);
-
-#endif
}
static void
@@ -1250,11 +1226,9 @@ gfxHarfBuzzShaper::Initialize()
HBUnicodeDecompose,
nullptr, nullptr);
-#if MOZ_HB_SHAPER_USE_ICU_NORMALIZATION
UErrorCode error = U_ZERO_ERROR;
sNormalizer = unorm2_getNFCInstance(&error);
- NS_ASSERTION(U_SUCCESS(error), "failed to get ICU normalizer");
-#endif
+ MOZ_ASSERT(U_SUCCESS(error), "failed to get ICU normalizer");
}
gfxFontEntry *entry = mFont->GetFontEntry();
diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp
index a468592fe..4db7bc29f 100644
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2399,11 +2399,10 @@ gfxPlatform::GetTilesSupportInfo(mozilla::widget::InfoObject& aObj)
/*static*/ bool
gfxPlatform::AsyncPanZoomEnabled()
{
-#if !defined(MOZ_B2G) && !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT)
- // For XUL applications (everything but B2G on mobile and desktop, and
- // Firefox on Android) we only want to use APZ when E10S is enabled. If
- // we ever get input events off the main thread we can consider relaxing
- // this requirement.
+#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT)
+ // For XUL applications (everything but Firefox on Android) we only want
+ // to use APZ when E10S is enabled. If we ever get input events off the
+ // main thread we can consider relaxing this requirement.
if (!BrowserTabsRemoteAutostart()) {
return false;
}
diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp
index 01394db14..e12f4e197 100644
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -869,28 +869,54 @@ gfxPlatformFontList::ResolveGenericFontNames(
nsIAtom* langGroup = GetLangGroupForPrefLang(aPrefLang);
NS_ASSERTION(langGroup, "null lang group for pref lang");
+ gfxPlatformFontList::GetFontFamiliesFromGenericFamilies(genericFamilies,
+ langGroup,
+ aGenericFamilies);
+
+#if 0 // dump out generic mappings
+ printf("%s ===> ", prefFontName.get());
+ for (uint32_t k = 0; k < aGenericFamilies->Length(); k++) {
+ if (k > 0) printf(", ");
+ printf("%s", NS_ConvertUTF16toUTF8(aGenericFamilies[k]->Name()).get());
+ }
+ printf("\n");
+#endif
+}
+
+void
+gfxPlatformFontList::ResolveEmojiFontNames(
+ nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies)
+{
+ // emoji preference has no lang name
+ AutoTArray<nsString,4> genericFamilies;
+
+ nsAutoCString prefFontListName("font.name-list.emoji");
+ gfxFontUtils::AppendPrefsFontList(prefFontListName.get(), genericFamilies);
+
+ gfxPlatformFontList::GetFontFamiliesFromGenericFamilies(genericFamilies,
+ nullptr,
+ aGenericFamilies);
+}
+
+void
+gfxPlatformFontList::GetFontFamiliesFromGenericFamilies(
+ nsTArray<nsString>& aGenericNameFamilies,
+ nsIAtom* aLangGroup,
+ nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies)
+{
// lookup and add platform fonts uniquely
- for (const nsString& genericFamily : genericFamilies) {
+ for (const nsString& genericFamily : aGenericNameFamilies) {
gfxFontStyle style;
- style.language = langGroup;
+ style.language = aLangGroup;
style.systemFont = false;
AutoTArray<gfxFontFamily*,10> families;
- FindAndAddFamilies(genericFamily, &families, &style);
+ FindAndAddFamilies(genericFamily, &families, &style, 1.0);
for (gfxFontFamily* f : families) {
if (!aGenericFamilies->Contains(f)) {
aGenericFamilies->AppendElement(f);
}
}
}
-
-#if 0 // dump out generic mappings
- printf("%s ===> ", prefFontName.get());
- for (uint32_t k = 0; k < aGenericFamilies->Length(); k++) {
- if (k > 0) printf(", ");
- printf("%s", NS_ConvertUTF16toUTF8(aGenericFamilies[k]->Name()).get());
- }
- printf("\n");
-#endif
}
nsTArray<RefPtr<gfxFontFamily>>*
@@ -902,6 +928,17 @@ gfxPlatformFontList::GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType,
aGenericType = eFamily_monospace;
}
+ if (aGenericType == eFamily_moz_emoji) {
+ // Emoji font has no lang
+ PrefFontList* prefFonts = mEmojiPrefFont.get();
+ if (MOZ_UNLIKELY(!prefFonts)) {
+ prefFonts = new PrefFontList;
+ ResolveEmojiFontNames(prefFonts);
+ mEmojiPrefFont.reset(prefFonts);
+ }
+ return prefFonts;
+ }
+
PrefFontList* prefFonts =
mLangGroupPrefFonts[aPrefLang][aGenericType].get();
if (MOZ_UNLIKELY(!prefFonts)) {
@@ -1180,6 +1217,10 @@ gfxPlatformFontList::AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen,
mozilla::FontFamilyType
gfxPlatformFontList::GetDefaultGeneric(eFontPrefLang aLang)
{
+ if (aLang == eFontPrefLang_Emoji) {
+ return eFamily_moz_emoji;
+ }
+
// initialize lang group pref font defaults (i.e. serif/sans-serif)
if (MOZ_UNLIKELY(mDefaultGenericsLangGroup.IsEmpty())) {
mDefaultGenericsLangGroup.AppendElements(ArrayLength(gPrefLangNames));
diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h
index c16994d8c..d77c12059 100644
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -380,6 +380,15 @@ protected:
eFontPrefLang aPrefLang,
nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies);
+ void
+ ResolveEmojiFontNames(nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies);
+
+ void
+ GetFontFamiliesFromGenericFamilies(
+ nsTArray<nsString>& aGenericFamilies,
+ nsIAtom* aLangGroup,
+ nsTArray<RefPtr<gfxFontFamily>>* aFontFamilies);
+
virtual nsresult InitFontListForPlatform() = 0;
void ApplyWhitelist();
@@ -436,6 +445,8 @@ protected:
eFontPrefLang_First,
eFontPrefLang_Count> mLangGroupPrefFonts;
+ mozilla::UniquePtr<PrefFontList> mEmojiPrefFont;
+
// when system-wide font lookup fails for a character, cache it to skip future searches
gfxSparseBitSet mCodepointsWithNoFonts;
diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp
index 1fb3bc4fd..be75332d6 100644
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -240,9 +240,14 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
Script aRunScript,
nsTArray<const char*>& aFontList)
{
- if (aNextCh == 0xfe0fu) {
- // if char is followed by VS16, try for a color emoji glyph
- aFontList.AppendElement(kFontTwemojiMozilla);
+ EmojiPresentation emoji = GetEmojiPresentation(aCh);
+ if (emoji != EmojiPresentation::TextOnly) {
+ if (aNextCh == kVariationSelector16 ||
+ (aNextCh != kVariationSelector15 &&
+ emoji == EmojiPresentation::EmojiDefault)) {
+ // if char is followed by VS16, try for a color emoji glyph
+ aFontList.AppendElement(kFontTwemojiMozilla);
+ }
}
aFontList.AppendElement(kFontDejaVuSerif);
@@ -250,15 +255,6 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
aFontList.AppendElement(kFontDejaVuSans);
aFontList.AppendElement(kFontFreeSans);
- if (!IS_IN_BMP(aCh)) {
- uint32_t p = aCh >> 16;
- if (p == 1) { // try color emoji font, unless VS15 (text style) present
- if (aNextCh != 0xfe0fu && aNextCh != 0xfe0eu) {
- aFontList.AppendElement(kFontTwemojiMozilla);
- }
- }
- }
-
// add fonts for CJK ranges
// xxx - this isn't really correct, should use the same CJK font ordering
// as the pref font code
diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp
index 3216f0f07..79684dd19 100644
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -18,6 +18,7 @@
#include "nsTArray.h"
#include "mozilla/Preferences.h"
#include "mozilla/VsyncDispatcher.h"
+#include "nsUnicodeProperties.h"
#include "qcms.h"
#include "gfx2DGlue.h"
@@ -29,6 +30,7 @@
using namespace mozilla;
using namespace mozilla::gfx;
+using namespace mozilla::unicode;
// cribbed from CTFontManager.h
enum {
@@ -195,23 +197,24 @@ gfxPlatformMac::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
Script aRunScript,
nsTArray<const char*>& aFontList)
{
- if (aNextCh == 0xfe0f) {
- aFontList.AppendElement(kFontAppleColorEmoji);
+ EmojiPresentation emoji = GetEmojiPresentation(aCh);
+ if (emoji != EmojiPresentation::TextOnly) {
+ if (aNextCh == kVariationSelector16 ||
+ (aNextCh != kVariationSelector15 &&
+ emoji == EmojiPresentation::EmojiDefault)) {
+ // if char is followed by VS16, try for a color emoji glyph
+ aFontList.AppendElement(kFontAppleColorEmoji);
+ }
}
aFontList.AppendElement(kFontLucidaGrande);
if (!IS_IN_BMP(aCh)) {
uint32_t p = aCh >> 16;
- uint32_t b = aCh >> 8;
if (p == 1) {
- if (b >= 0x1f0 && b < 0x1f7) {
- aFontList.AppendElement(kFontAppleColorEmoji);
- } else {
- aFontList.AppendElement(kFontAppleSymbols);
- aFontList.AppendElement(kFontSTIXGeneral);
- aFontList.AppendElement(kFontGeneva);
- }
+ aFontList.AppendElement(kFontAppleSymbols);
+ aFontList.AppendElement(kFontSTIXGeneral);
+ aFontList.AppendElement(kFontGeneva);
} else if (p == 2) {
// OSX installations with MS Office may have these fonts
aFontList.AppendElement(kFontMingLiUExtB);
diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp
index 6718eed01..1702cab66 100644
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -2813,7 +2813,7 @@ gfxFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, uint32_t aNextCh,
return nullptr;
// 2. search pref fonts
- RefPtr<gfxFont> font = WhichPrefFontSupportsChar(aCh);
+ RefPtr<gfxFont> font = WhichPrefFontSupportsChar(aCh, aNextCh);
if (font) {
*aMatchType = gfxTextRange::kPrefsFallback;
return font.forget();
@@ -3081,15 +3081,25 @@ gfxFontGroup::ContainsUserFont(const gfxUserFontEntry* aUserFont)
}
already_AddRefed<gfxFont>
-gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
+gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh, uint32_t aNextCh)
{
RefPtr<gfxFont> font;
- // get the pref font list if it hasn't been set up already
- uint32_t unicodeRange = FindCharUnicodeRange(aCh);
+ eFontPrefLang charLang;
gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList();
- eFontPrefLang charLang = pfl->GetFontPrefLangFor(unicodeRange);
+ EmojiPresentation emoji = GetEmojiPresentation(aCh);
+ if ((emoji != EmojiPresentation::TextOnly &&
+ (aNextCh == kVariationSelector16 ||
+ (emoji == EmojiPresentation::EmojiDefault &&
+ aNextCh != kVariationSelector15)))) {
+ charLang = eFontPrefLang_Emoji;
+ } else {
+ // get the pref font list if it hasn't been set up already
+ uint32_t unicodeRange = FindCharUnicodeRange(aCh);
+ charLang = pfl->GetFontPrefLangFor(unicodeRange);
+ }
+
// if the last pref font was the first family in the pref list, no need to recheck through a list of families
if (mLastPrefFont && charLang == mLastPrefLang &&
mLastPrefFirstFont && mLastPrefFont->HasCharacter(aCh)) {
diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h
index 0e44456ae..c3673785c 100644
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -917,7 +917,8 @@ public:
protected:
// search through pref fonts for a character, return nullptr if no matching pref font
- already_AddRefed<gfxFont> WhichPrefFontSupportsChar(uint32_t aCh);
+ already_AddRefed<gfxFont> WhichPrefFontSupportsChar(uint32_t aCh,
+ uint32_t aNextCh);
already_AddRefed<gfxFont>
WhichSystemFontSupportsChar(uint32_t aCh, uint32_t aNextCh,
diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp
index af4d932a9..c68f622c6 100755
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -13,6 +13,7 @@
#include "gfxWindowsSurface.h"
#include "nsUnicharUtils.h"
+#include "nsUnicodeProperties.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
@@ -81,6 +82,7 @@ using namespace mozilla::gfx;
using namespace mozilla::layers;
using namespace mozilla::widget;
using namespace mozilla::image;
+using namespace mozilla::unicode;
IDWriteRenderingParams* GetDwriteRenderingParams(bool aGDI)
{
@@ -669,9 +671,15 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
Script aRunScript,
nsTArray<const char*>& aFontList)
{
- if (aNextCh == 0xfe0fu) {
- aFontList.AppendElement(kFontSegoeUIEmoji);
- aFontList.AppendElement(kFontTwemojiMozilla);
+ EmojiPresentation emoji = GetEmojiPresentation(aCh);
+ if (emoji != EmojiPresentation::TextOnly) {
+ if (aNextCh == kVariationSelector16 ||
+ (aNextCh != kVariationSelector15 &&
+ emoji == EmojiPresentation::EmojiDefault)) {
+ // if char is followed by VS16, try for a color emoji glyph
+ // XXX: For Win8+ native, aFontList.AppendElement(kFontSegoeUIEmoji);
+ aFontList.AppendElement(kFontTwemojiMozilla);
+ }
}
// Arial is used as the default fallback for system fallback
@@ -680,17 +688,7 @@ gfxWindowsPlatform::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
if (!IS_IN_BMP(aCh)) {
uint32_t p = aCh >> 16;
if (p == 1) { // SMP plane
- if (aNextCh == 0xfe0eu) {
- aFontList.AppendElement(kFontSegoeUISymbol);
- aFontList.AppendElement(kFontSegoeUIEmoji);
- aFontList.AppendElement(kFontTwemojiMozilla);
- } else {
- if (aNextCh != 0xfe0fu) {
- aFontList.AppendElement(kFontSegoeUIEmoji);
- aFontList.AppendElement(kFontTwemojiMozilla);
- }
- aFontList.AppendElement(kFontSegoeUISymbol);
- }
+ aFontList.AppendElement(kFontSegoeUISymbol);
aFontList.AppendElement(kFontEbrima);
aFontList.AppendElement(kFontNirmalaUI);
aFontList.AppendElement(kFontCambriaMath);
diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build
index 227b2b875..e253d7891 100644
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -223,12 +223,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
'DeviceManagerDx.cpp',
]
-# We prefer to use ICU for normalization functions, but currently it is only
-# available if we're building with the Intl API enabled:
-if CONFIG['ENABLE_INTL_API']:
- USE_LIBS += [
- 'icu',
- ]
+# We use ICU for normalization functions
+USE_LIBS += [
+ 'icu',
+]
include('/ipc/chromium/chromium-config.mozbuild')