summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stransky <stransky@fedoraproject.org>2007-12-18 14:33:32 +0000
committerMartin Stransky <stransky@fedoraproject.org>2007-12-18 14:33:32 +0000
commitbede30df0baea7e8e1e2f6d108a73e051cd64fc3 (patch)
treea7a6155e74c936ee389ec0edd95c6ace2d6d9d00
parent...and put back all of the prefs (diff)
downloadlibrewolf-fedora-ff-bede30df0baea7e8e1e2f6d108a73e051cd64fc3.tar.gz
librewolf-fedora-ff-bede30df0baea7e8e1e2f6d108a73e051cd64fc3.tar.bz2
librewolf-fedora-ff-bede30df0baea7e8e1e2f6d108a73e051cd64fc3.zip
- moved to XUL Runner and updated to 3.0b3pre
- removed firefox-devel package, gecko-libs is provided by xulrunner-devel now.
-rw-r--r--.cvsignore1
-rw-r--r--firefox-0.7.3-psfonts.patch28
-rwxr-xr-xfirefox-1.1-default-applications.patch32
-rwxr-xr-xfirefox-1.1-uriloader.patch459
-rw-r--r--firefox-1.5-bullet-bill.patch23
-rw-r--r--firefox-1.5-pango-cursor-position-more.patch19
-rw-r--r--firefox-1.5-pango-cursor-position.patch52
-rw-r--r--firefox-1.5-pango-justified-range.patch53
-rw-r--r--firefox-1.5-pango-underline.patch39
-rw-r--r--firefox-1.5-theme-change.patch263
-rw-r--r--firefox-1.5-xft-rangewidth.patch283
-rw-r--r--firefox-2.0-dnd.patch949
-rw-r--r--firefox-2.0-enable-debug.patch12
-rw-r--r--firefox-2.0-pango-ligatures.patch1932
-rw-r--r--firefox-2.0-pango-printing.patch4586
-rw-r--r--firefox-2.0-startup-notify.patch1296
-rw-r--r--firefox-2.0.0.4-undo-uriloader.patch97
-rwxr-xr-xfirefox-mozconfig8
-rw-r--r--firefox-path.patch260
-rw-r--r--firefox.spec227
-rw-r--r--sources2
21 files changed, 56 insertions, 10565 deletions
diff --git a/.cvsignore b/.cvsignore
index f0e1ad8..3caf8f1 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,2 +1,3 @@
firefox-2.0.0.10-source.tar.bz2
firefox-langpacks-2.0.0.10-20071123.tar.bz2
+firefox-20071215.tar.bz2
diff --git a/firefox-0.7.3-psfonts.patch b/firefox-0.7.3-psfonts.patch
deleted file mode 100644
index 10a08e9..0000000
--- a/firefox-0.7.3-psfonts.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- mozilla/modules/libpref/src/init/all.js.foo 2004-06-18 13:16:32.000000000 -0400
-+++ mozilla/modules/libpref/src/init/all.js 2004-06-18 13:17:28.000000000 -0400
-@@ -1776,8 +1776,10 @@
- pref("print.postscript.nativefont.ar", "");
- pref("print.postscript.nativefont.el", "");
- pref("print.postscript.nativefont.he", "");
--pref("print.postscript.nativefont.ja", "");
--pref("print.postscript.nativefont.ko", "");
-+pref("print.postscript.nativecode.ja", "euc-jp");
-+pref("print.postscript.nativefont.ja", "Ryumin-Light-EUC-H");
-+pref("print.postscript.nativecode.ko", "euc-kr");
-+pref("print.postscript.nativefont.ko", "Baekmuk-Gulim-KSC-EUC-H");
- pref("print.postscript.nativefont.th", "");
- pref("print.postscript.nativefont.tr", "");
- pref("print.postscript.nativefont.x-baltic", "");
-@@ -1786,8 +1788,10 @@
- pref("print.postscript.nativefont.x-unicode", "");
- pref("print.postscript.nativefont.x-user-def", "");
- pref("print.postscript.nativefont.x-western", "");
--pref("print.postscript.nativefont.zh-CN", "");
--pref("print.postscript.nativefont.zh-TW", "");
-+pref("print.postscript.nativecode.zh-CN", "gb18030");
-+pref("print.postscript.nativefont.zh-CN", "MSungGBK-Light-GBK2K-H");
-+pref("print.postscript.nativecode.zh-TW", "big5");
-+pref("print.postscript.nativefont.zh-TW", "ShanHeiSun-Light-B5-H");
- pref("print.postscript.nativefont.zh-HK", "");
-
- # XP_UNIX
diff --git a/firefox-1.1-default-applications.patch b/firefox-1.1-default-applications.patch
deleted file mode 100755
index 1666ff6..0000000
--- a/firefox-1.1-default-applications.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-Index: browser/components/shell/src/nsGNOMEShellService.h
-===================================================================
-RCS file: /cvsroot/mozilla/browser/components/shell/src/nsGNOMEShellService.h,v
-retrieving revision 1.2.4.1
-diff -d -u -p -r1.2.4.1 nsGNOMEShellService.h
---- browser/components/shell/src/nsGNOMEShellService.h 15 Jul 2004 20:43:55 -0000 1.2.4.1
-+++ browser/components/shell/src/nsGNOMEShellService.h 15 Oct 2004 20:39:56 -0000
-@@ -43,7 +43,7 @@
- class nsGNOMEShellService : public nsIShellService
- {
- public:
-- nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) { }
-+ nsGNOMEShellService() : mCheckedThisSession(PR_TRUE) { }
-
- NS_DECL_ISUPPORTS
- NS_DECL_NSISHELLSERVICE
-Index: browser/components/preferences/main.xul
-===================================================================
-RCS file: /cvsroot/mozilla/browser/components/preferences/main.xul,v
-retrieving revision 1.3.2.6
-diff -d -u -p -r1.3.2.6 main.xul
---- browser/components/preferences/main.xul 13 Sep 2006 03:01:38 -0000 1.3.2.6
-+++ browser/components/preferences/main.xul 7 Oct 2006 19:58:16 -0000
-@@ -193,7 +193,7 @@
- </radiogroup>
- </groupbox>
-
--#ifdef HAVE_SHELL_SERVICE
-+#if 0
- <!-- System Defaults -->
- <groupbox id="systemDefaultsGroup" orient="horizontal">
- <caption label="&systemDefaults.label;"/>
diff --git a/firefox-1.1-uriloader.patch b/firefox-1.1-uriloader.patch
deleted file mode 100755
index 08c7e96..0000000
--- a/firefox-1.1-uriloader.patch
+++ /dev/null
@@ -1,459 +0,0 @@
-Index: uriloader/exthandler/Makefile.in
-===================================================================
-RCS file: /cvsroot/mozilla/uriloader/exthandler/Makefile.in,v
-retrieving revision 1.60
-diff -d -u -p -r1.60 Makefile.in
---- uriloader/exthandler/Makefile.in 2 May 2005 16:30:03 -0000 1.60
-+++ uriloader/exthandler/Makefile.in 21 Jul 2005 03:07:39 -0000
-@@ -102,7 +102,7 @@ endif
- LOCAL_INCLUDES = -I$(srcdir)
-
- ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
--OSHELPER += nsGNOMERegistry.cpp
-+OSHELPER += nsMIMEInfoUnix.cpp nsGNOMERegistry.cpp
- endif
-
- ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
-Index: uriloader/exthandler/unix/nsGNOMERegistry.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/uriloader/exthandler/unix/nsGNOMERegistry.cpp,v
-retrieving revision 1.10
-diff -d -u -p -r1.10 nsGNOMERegistry.cpp
---- uriloader/exthandler/unix/nsGNOMERegistry.cpp 16 Oct 2004 13:46:17 -0000 1.10
-+++ uriloader/exthandler/unix/nsGNOMERegistry.cpp 21 Jul 2005 03:07:40 -0000
-@@ -42,7 +42,7 @@
- #include "nsString.h"
- #include "nsIComponentManager.h"
- #include "nsILocalFile.h"
--#include "nsMIMEInfoImpl.h"
-+#include "nsMIMEInfoUnix.h"
- #include "nsAutoPtr.h"
-
- #include <glib.h>
-@@ -56,12 +56,12 @@ typedef struct _GConfClient GConfClient;
- typedef struct _GnomeProgram GnomeProgram;
- typedef struct _GnomeModuleInfo GnomeModuleInfo;
-
--typedef struct {
-+struct GnomeVFSMimeApplication {
- char *id;
- char *name;
- char *command;
- /* there is more here, but we don't need it */
--} GnomeVFSMimeApplication;
-+};
-
- typedef GConfClient * (*_gconf_client_get_default_fn)();
- typedef gchar * (*_gconf_client_get_string_fn)(GConfClient *,
-@@ -264,7 +264,7 @@ nsGNOMERegistry::GetAppDescForScheme(con
- }
-
-
--/* static */ already_AddRefed<nsMIMEInfoBase>
-+/* static */ already_AddRefed<nsMIMEInfoUnix>
- nsGNOMERegistry::GetFromExtension(const char *aFileExt)
- {
- if (!gconfLib)
-@@ -286,7 +286,7 @@ nsGNOMERegistry::GetFromExtension(const
- return GetFromType(mimeType);
- }
-
--/* static */ already_AddRefed<nsMIMEInfoBase>
-+/* static */ already_AddRefed<nsMIMEInfoUnix>
- nsGNOMERegistry::GetFromType(const char *aMIMEType)
- {
- if (!gconfLib)
-@@ -296,9 +296,11 @@ nsGNOMERegistry::GetFromType(const char
- if (!handlerApp)
- return nsnull;
-
-- nsRefPtr<nsMIMEInfoImpl> mimeInfo = new nsMIMEInfoImpl(aMIMEType);
-+ nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix(aMIMEType);
- NS_ENSURE_TRUE(mimeInfo, nsnull);
-
-+ mimeInfo->SetDefaultGnomeVFSMimeApplication(handlerApp);
-+
- // Get the list of extensions and append then to the mimeInfo.
- GList *extensions = _gnome_vfs_mime_get_extensions_list(aMIMEType);
- for (GList *extension = extensions; extension; extension = extension->next)
-@@ -320,11 +322,21 @@ nsGNOMERegistry::GetFromType(const char
- return nsnull;
- }
-
-- gchar *commandPath = g_find_program_in_path(nativeCommand);
-+ gchar **argv;
-+ gboolean res = g_shell_parse_argv(nativeCommand, NULL, &argv, NULL);
-+ if (!res) {
-+ NS_ERROR("Could not convert helper app command to filesystem encoding");
-+ _gnome_vfs_mime_application_free(handlerApp);
-+ return nsnull;
-+ }
-+
-+ gchar *commandPath = g_find_program_in_path(argv[0]);
-
- g_free(nativeCommand);
-+ g_strfreev(argv);
-
- if (!commandPath) {
-+ NS_WARNING("could not find command in path");
- _gnome_vfs_mime_application_free(handlerApp);
- return nsnull;
- }
-@@ -342,7 +354,7 @@ nsGNOMERegistry::GetFromType(const char
-
- _gnome_vfs_mime_application_free(handlerApp);
-
-- nsMIMEInfoBase* retval;
-+ nsMIMEInfoUnix* retval;
- NS_ADDREF((retval = mimeInfo));
- return retval;
- }
-Index: uriloader/exthandler/unix/nsGNOMERegistry.h
-===================================================================
-RCS file: /cvsroot/mozilla/uriloader/exthandler/unix/nsGNOMERegistry.h,v
-retrieving revision 1.3
-diff -d -u -p -r1.3 nsGNOMERegistry.h
---- uriloader/exthandler/unix/nsGNOMERegistry.h 16 Oct 2004 13:46:17 -0000 1.3
-+++ uriloader/exthandler/unix/nsGNOMERegistry.h 21 Jul 2005 03:07:40 -0000
-@@ -35,10 +35,13 @@
- *
- * ***** END LICENSE BLOCK ***** */
-
-+#ifndef nsGNOMERegistry_h__
-+#define nsGNOMERegistry_h__
-+
- #include "nsIURI.h"
- #include "nsCOMPtr.h"
-
--class nsMIMEInfoBase;
-+class nsMIMEInfoUnix;
-
- class nsGNOMERegistry
- {
-@@ -52,7 +55,9 @@ class nsGNOMERegistry
- static void GetAppDescForScheme(const nsACString& aScheme,
- nsAString& aDesc);
-
-- static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const char *aFileExt);
-+ static already_AddRefed<nsMIMEInfoUnix> GetFromExtension(const char *aFileExt);
-
-- static already_AddRefed<nsMIMEInfoBase> GetFromType(const char *aMIMEType);
-+ static already_AddRefed<nsMIMEInfoUnix> GetFromType(const char *aMIMEType);
- };
-+
-+#endif // nsGNOMERegistry_h__
-Index: uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
-===================================================================
-RCS file: uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
-diff -N uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ uriloader/exthandler/unix/nsMIMEInfoUnix.cpp 21 Jul 2005 03:07:40 -0000
-@@ -0,0 +1,196 @@
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org Code.
-+ *
-+ * The Initial Developer of the Original Code is
-+ * Red Hat, Inc.
-+ * Portions created by the Initial Developer are Copyright (C) 2005
-+ * the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ * Christopher Aillon <caillon@redhat.com> (Original author)
-+ *
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#include "nsMIMEInfoUnix.h"
-+#include "prlink.h"
-+#include "prmem.h"
-+#include <glib.h>
-+#include <glib-object.h>
-+
-+static PRLibrary *gnomeLib;
-+static PRLibrary *vfsLib;
-+
-+typedef struct _GnomeProgram GnomeProgram;
-+typedef struct _GnomeModuleInfo GnomeModuleInfo;
-+
-+typedef enum {
-+ GNOME_VFS_OK // there's more but we don't care about them.
-+} GnomeVFSResult;
-+
-+typedef GnomeVFSResult (*_gnome_vfs_mime_application_launch_fn)
-+ (GnomeVFSMimeApplication *app,
-+ GList *uris);
-+typedef void (*_gnome_vfs_mime_application_free_fn)(GnomeVFSMimeApplication *);
-+typedef GnomeVFSMimeApplication * (*_gnome_vfs_mime_application_copy_fn)(GnomeVFSMimeApplication *);
-+typedef GnomeProgram * (*_gnome_program_init_fn)(const char *, const char *,
-+ const GnomeModuleInfo *, int,
-+ char **, const char *, ...);
-+typedef const char * (*_gnome_vfs_mime_application_get_name_fn)(GnomeVFSMimeApplication *);
-+typedef const GnomeModuleInfo * (*_libgnome_module_info_get_fn)();
-+typedef GnomeProgram * (*_gnome_program_get_fn)();
-+typedef char * (*_gnome_vfs_make_uri_from_input_fn)(const char *);
-+
-+#define DECL_FUNC_PTR(func) static _##func##_fn _##func
-+
-+DECL_FUNC_PTR(gnome_vfs_mime_application_launch);
-+DECL_FUNC_PTR(gnome_vfs_mime_application_free);
-+DECL_FUNC_PTR(gnome_vfs_mime_application_copy);
-+DECL_FUNC_PTR(gnome_vfs_mime_application_get_name);
-+DECL_FUNC_PTR(gnome_program_init);
-+DECL_FUNC_PTR(gnome_program_get);
-+DECL_FUNC_PTR(libgnome_module_info_get);
-+DECL_FUNC_PTR(gnome_vfs_make_uri_from_input);
-+
-+static PRLibrary *
-+LoadVersionedLibrary(const char* libName, const char* libVersion)
-+{
-+ char *platformLibName = PR_GetLibraryName(nsnull, libName);
-+ nsCAutoString versionLibName(platformLibName);
-+ versionLibName.Append(libVersion);
-+ PR_Free(platformLibName);
-+ return PR_LoadLibrary(versionLibName.get());
-+}
-+
-+static void
-+Cleanup()
-+{
-+ // Unload all libraries
-+ if (gnomeLib)
-+ PR_UnloadLibrary(gnomeLib);
-+ if (vfsLib)
-+ PR_UnloadLibrary(vfsLib);
-+
-+ gnomeLib = vfsLib = nsnull;
-+}
-+
-+static void
-+InitGnomeVFS()
-+{
-+ static PRBool initialized = PR_FALSE;
-+
-+ if (initialized)
-+ return;
-+
-+ #define ENSURE_LIB(lib) \
-+ PR_BEGIN_MACRO \
-+ if (!lib) { \
-+ Cleanup(); \
-+ return; \
-+ } \
-+ PR_END_MACRO
-+
-+ #define GET_LIB_FUNCTION(lib, func, failure) \
-+ PR_BEGIN_MACRO \
-+ _##func = (_##func##_fn) PR_FindFunctionSymbol(lib##Lib, #func); \
-+ if (!_##func) { \
-+ failure; \
-+ } \
-+ PR_END_MACRO
-+
-+ // Attempt to open libgnome
-+ gnomeLib = LoadVersionedLibrary("gnome-2", ".0");
-+ ENSURE_LIB(gnomeLib);
-+
-+ GET_LIB_FUNCTION(gnome, gnome_program_init, return Cleanup());
-+ GET_LIB_FUNCTION(gnome, libgnome_module_info_get, return Cleanup());
-+ GET_LIB_FUNCTION(gnome, gnome_program_get, return Cleanup());
-+
-+ // Attempt to open libgnomevfs
-+ vfsLib = LoadVersionedLibrary("gnomevfs-2", ".0");
-+ ENSURE_LIB(vfsLib);
-+
-+ GET_LIB_FUNCTION(vfs, gnome_vfs_mime_application_launch, /* do nothing */);
-+ GET_LIB_FUNCTION(vfs, gnome_vfs_make_uri_from_input, return Cleanup());
-+ GET_LIB_FUNCTION(vfs, gnome_vfs_mime_application_get_name, return Cleanup());
-+ GET_LIB_FUNCTION(vfs, gnome_vfs_mime_application_free, return Cleanup());
-+ GET_LIB_FUNCTION(vfs, gnome_vfs_mime_application_copy, return Cleanup());
-+
-+ // Initialize GNOME, if it's not already initialized. It's not
-+ // necessary to tell GNOME about our actual command line arguments.
-+
-+ if (!_gnome_program_get()) {
-+ char *argv[1] = { "gecko" };
-+ _gnome_program_init("Gecko", "1.0", _libgnome_module_info_get(),
-+ 1, argv, NULL);
-+ }
-+
-+ // Note: after GNOME has been initialized, do not ever unload these
-+ // libraries. They register atexit handlers, so if they are unloaded, we'll
-+ // crash on exit.
-+}
-+
-+void
-+nsMIMEInfoUnix::SetDefaultGnomeVFSMimeApplication(GnomeVFSMimeApplication* app)
-+{
-+ if (_gnome_vfs_mime_application_copy && _gnome_vfs_mime_application_free) {
-+ mDefaultVFSApplication = _gnome_vfs_mime_application_copy(app);
-+
-+ mPreferredAction = nsIMIMEInfo::useSystemDefault;
-+
-+ const gchar * name = _gnome_vfs_mime_application_get_name(mDefaultVFSApplication);
-+ if (name)
-+ mDefaultAppDescription = NS_ConvertUTF8toUCS2(name);
-+ }
-+}
-+
-+nsMIMEInfoUnix::~nsMIMEInfoUnix()
-+{
-+ if (mDefaultVFSApplication)
-+ _gnome_vfs_mime_application_free(mDefaultVFSApplication);
-+}
-+
-+nsresult
-+nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile* aFile)
-+{
-+ NS_ENSURE_ARG_POINTER(aFile);
-+
-+ InitGnomeVFS();
-+
-+ if (_gnome_vfs_mime_application_launch && mDefaultVFSApplication) {
-+ nsCAutoString nativePath;
-+ aFile->GetNativePath(nativePath);
-+
-+ gchar *uri = _gnome_vfs_make_uri_from_input(nativePath.get());
-+
-+ GList *uris = NULL;
-+ uris = g_list_append(uris, uri);
-+
-+ GnomeVFSResult result = _gnome_vfs_mime_application_launch(mDefaultVFSApplication, uris);
-+
-+ g_free(uri);
-+ g_list_free(uris);
-+
-+ if (result != GNOME_VFS_OK)
-+ return NS_ERROR_FAILURE;
-+
-+ return NS_OK;
-+ }
-+
-+ if (!mDefaultApplication)
-+ return NS_ERROR_FILE_NOT_FOUND;
-+
-+ return LaunchWithIProcess(mDefaultApplication, aFile);
-+}
-Index: uriloader/exthandler/unix/nsMIMEInfoUnix.h
-===================================================================
-RCS file: uriloader/exthandler/unix/nsMIMEInfoUnix.h
-diff -N uriloader/exthandler/unix/nsMIMEInfoUnix.h
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ uriloader/exthandler/unix/nsMIMEInfoUnix.h 21 Jul 2005 03:07:40 -0000
-@@ -0,0 +1,50 @@
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org Code.
-+ *
-+ * The Initial Developer of the Original Code is
-+ * Red Hat, Inc.
-+ * Portions created by the Initial Developer are Copyright (C) 2005
-+ * the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ * Christopher Aillon <caillon@redhat.com> (Original author)
-+ *
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#ifndef nsMimeInfoUnix_h__
-+#define nsMimeInfoUnix_h__
-+
-+#include "nsMIMEInfoImpl.h"
-+
-+struct GnomeVFSMimeApplication;
-+
-+class nsMIMEInfoUnix : public nsMIMEInfoImpl
-+{
-+public:
-+ nsMIMEInfoUnix(const char* aType = "") : nsMIMEInfoImpl(aType), mDefaultVFSApplication(nsnull) {}
-+ nsMIMEInfoUnix(const nsACString& aMIMEType) : nsMIMEInfoImpl(aMIMEType) {};
-+
-+ virtual ~nsMIMEInfoUnix();
-+
-+ void SetDefaultGnomeVFSMimeApplication(GnomeVFSMimeApplication *app);
-+
-+protected:
-+ virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile* aFile);
-+
-+ GnomeVFSMimeApplication *mDefaultVFSApplication;
-+};
-+
-+#endif // nsMimeInfoUnix_h__
-Index: uriloader/exthandler/unix/nsOSHelperAppService.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp,v
-retrieving revision 1.58
-diff -d -u -p -r1.58 nsOSHelperAppService.cpp
---- uriloader/exthandler/unix/nsOSHelperAppService.cpp 25 Oct 2004 07:46:01 -0000 1.58
-+++ uriloader/exthandler/unix/nsOSHelperAppService.cpp 21 Jul 2005 03:07:40 -0000
-@@ -44,6 +44,7 @@
- #include "nsOSHelperAppService.h"
- #ifdef MOZ_WIDGET_GTK2
- #include "nsGNOMERegistry.h"
-+#include "nsMIMEInfoUnix.h"
- #endif
- #include "nsISupports.h"
- #include "nsString.h"
-@@ -1486,6 +1487,17 @@ nsOSHelperAppService::GetFromType(const
-
- LOG(("Here we do a mimetype lookup for '%s'\n", aMIMEType.get()));
-
-+#ifdef MOZ_WIDGET_GTK2
-+ // Look in GNOME registry first since it is the preferred method in GNOME,
-+ // should trump the mailcap entry
-+ LOG(("Looking in GNOME registry\n"));
-+ nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType.get()).get();
-+ if (gnomeInfo) {
-+ LOG(("Got MIMEInfo from GNOME registry\n"));
-+ return gnomeInfo;
-+ }
-+#endif
-+
- // extract the major and minor types
- NS_ConvertASCIItoUTF16 mimeType(aMIMEType);
- nsAString::const_iterator start_iter, end_iter,
-@@ -1522,21 +1534,6 @@ nsOSHelperAppService::GetFromType(const
- mozillaFlags,
- PR_TRUE);
-
--
-- if (handler.IsEmpty() && extensions.IsEmpty() &&
-- mailcap_description.IsEmpty() && mime_types_description.IsEmpty()) {
-- // No useful data yet
--
--#ifdef MOZ_WIDGET_GTK2
-- LOG(("Looking in GNOME registry\n"));
-- nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType.get()).get();
-- if (gnomeInfo) {
-- LOG(("Got MIMEInfo from GNOME registry\n"));
-- return gnomeInfo;
-- }
--#endif
-- }
--
- if (handler.IsEmpty() && mailcap_description.IsEmpty()) {
- DoLookUpHandlerAndDescription(majorType,
- minorType,
diff --git a/firefox-1.5-bullet-bill.patch b/firefox-1.5-bullet-bill.patch
deleted file mode 100644
index 7108eb4..0000000
--- a/firefox-1.5-bullet-bill.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-Index: mozilla/editor/libeditor/text/nsTextEditRules.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/editor/libeditor/text/nsTextEditRules.cpp,v
-retrieving revision 1.195
-diff -d -u -p -r1.195 nsTextEditRules.cpp
---- mozilla/editor/libeditor/text/nsTextEditRules.cpp 16 Jun 2005 13:10:56 -0000 1.195
-+++ mozilla/editor/libeditor/text/nsTextEditRules.cpp 4 Oct 2006 16:02:19 -0000
-@@ -1390,13 +1390,13 @@ nsTextEditRules::EchoInsertionToPWBuff(P
- // manage the password buffer
- mPasswordText.Insert(*aOutString, aStart);
-
-- // change the output to '*' only
-+ // change the output to 'U+2022' only
- PRInt32 length = aOutString->Length();
- PRInt32 i;
- aOutString->Truncate();
- for (i=0; i<length; i++)
- {
-- aOutString->Append(PRUnichar('*'));
-+ aOutString->Append(PRUnichar(0x2022));
- }
-
- return NS_OK;
diff --git a/firefox-1.5-pango-cursor-position-more.patch b/firefox-1.5-pango-cursor-position-more.patch
deleted file mode 100644
index ef5b967..0000000
--- a/firefox-1.5-pango-cursor-position-more.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-diff -pruN -x '.moz*' -x .deps -x 'firefox*' -x '*.mk' -x 'config*' -x dist -x build -x toolkit -x '*o' -x '*a' -x '*html' mozilla.orig/layout/generic/nsTextFrame.cpp mozilla/layout/generic/nsTextFrame.cpp
---- mozilla.orig/layout/generic/nsTextFrame.cpp 2006-08-26 13:33:35.000000000 +0900
-+++ mozilla/layout/generic/nsTextFrame.cpp 2006-12-13 20:54:32.000000000 +0900
-@@ -4261,12 +4261,10 @@ nsTextFrame::GetPointFromOffset(nsPresCo
- if (tc) {
- totalLength = tc->Text()->GetLength(); // raw value which includes whitespace
- }
-- if ((hitLength == textLength) && (inOffset = mContentLength) &&
-- (mContentOffset + mContentLength == totalLength)) {
-- // no need to re-measure when at the end of the last-in-flow
-- }
-+ if (hitLength > 0)
-+ inRendContext->GetRangeWidth(paintBuffer.mBuffer, textLength, 0, hitLength, (PRUint32&)width);
- else
-- inRendContext->GetWidth(paintBuffer.mBuffer, hitLength, width);
-+ width = 0;
- }
- if ((hitLength == textLength) && (TEXT_TRIMMED_WS & mState)) {
- //
diff --git a/firefox-1.5-pango-cursor-position.patch b/firefox-1.5-pango-cursor-position.patch
deleted file mode 100644
index d287fd3..0000000
--- a/firefox-1.5-pango-cursor-position.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-Index: mozilla/gfx/src/gtk/nsFontMetricsPango.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/gtk/nsFontMetricsPango.cpp,v
-retrieving revision 1.24
-diff -d -u -p -6 -r1.24 nsFontMetricsPango.cpp
---- mozilla/gfx/src/gtk/nsFontMetricsPango.cpp 25 Aug 2006 01:02:34 -0000 1.24
-+++ mozilla/gfx/src/gtk/nsFontMetricsPango.cpp 6 Sep 2006 07:01:49 -0000
-@@ -948,13 +948,12 @@ nsFontMetricsPango::GetClusterInfo(const
- PRInt32
- nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
- nsPoint aPt)
- {
- int trailing = 0;
- int inx = 0;
-- gboolean found = FALSE;
- const gchar *curChar;
- PRInt32 retval = 0;
-
- float f = mDeviceContext->AppUnitsToDevUnits();
-
- PangoLayout *layout = pango_layout_new(mPangoContext);
-@@ -974,28 +973,18 @@ nsFontMetricsPango::GetPosition(const PR
- }
-
- // Set up the pango layout
- pango_layout_set_text(layout, text, strlen(text));
- FixupSpaceWidths(layout, text);
-
-- found = pango_layout_xy_to_index(layout, localX, localY,
-- &inx, &trailing);
-+ pango_layout_xy_to_index(layout, localX, localY,
-+ &inx, &trailing);
-
- // Convert the index back to the utf-16 index
- curChar = text;
-
-- // Jump to the end if it's not found.
-- if (!found) {
-- if (inx == 0)
-- retval = 0;
-- else if (trailing)
-- retval = aLength;
--
-- goto loser;
-- }
--
- for (PRUint32 curOffset=0; curOffset < aLength;
- curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-
- // Check for a match before checking for a surrogate pair
- if (curChar - text == inx) {
- retval = curOffset;
diff --git a/firefox-1.5-pango-justified-range.patch b/firefox-1.5-pango-justified-range.patch
deleted file mode 100644
index 7614d0e..0000000
--- a/firefox-1.5-pango-justified-range.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-diff -pruN -x '.moz*' -x .deps -x 'thunderbird*' -x '*.mk' -x 'config*' -x dist -x build -x toolkit -x '*o' -x '*a' -x '*html' -x 'firefox*' mozilla.orig/layout/generic/nsTextFrame.cpp mozilla/layout/generic/nsTextFrame.cpp
---- mozilla.orig/layout/generic/nsTextFrame.cpp 2006-12-20 12:15:38.000000000 +0900
-+++ mozilla/layout/generic/nsTextFrame.cpp 2006-12-20 21:29:39.000000000 +0900
-@@ -2973,15 +2973,16 @@ nsTextFrame::RenderString(nsIRenderingCo
-
- nsIFontMetrics* lastFont = aTextStyle.mLastFont;
- PRInt32 pendingCount;
-- PRUnichar* runStart = bp;
-+ PRUnichar* runStart = bp, *top = aBuffer;
- nscoord charWidth, width = 0;
- PRInt32 countSoFar = 0;
-+ PRUint32 offset;
- // Save the color we want to use for the text, since calls to
- // PaintTextDecorations in this method will call SetColor() on the rendering
- // context.
- nscolor textColor;
- aRenderingContext.GetColor(textColor);
-- for (; --aLength >= 0; aBuffer++) {
-+ for (offset = 0; offset < aLength; aBuffer++, offset++) {
- nsIFontMetrics* nextFont;
- nscoord glyphWidth = 0;
- PRUnichar ch = *aBuffer;
-@@ -3038,7 +3039,7 @@ nsTextFrame::RenderString(nsIRenderingCo
- else if (ch == ' ') {
- glyphWidth += aTextStyle.mSpaceWidth + aTextStyle.mWordSpacing + aTextStyle.mLetterSpacing;
- }
-- else if (IS_HIGH_SURROGATE(ch) && aLength > 0 &&
-+ else if (IS_HIGH_SURROGATE(ch) && (offset + 1) < aLength &&
- IS_LOW_SURROGATE(*(aBuffer+1))) {
-
- // special handling for surrogate pair
-@@ -3046,7 +3047,7 @@ nsTextFrame::RenderString(nsIRenderingCo
- glyphWidth += charWidth + aTextStyle.mLetterSpacing;
- // copy the surrogate low
- *bp++ = ch;
-- --aLength;
-+ offset++;
- aBuffer++;
- ch = *aBuffer;
- // put the width into the space buffer
-@@ -3058,10 +3059,10 @@ nsTextFrame::RenderString(nsIRenderingCo
- glyphWidth = 0;
- }
- else {
-- aRenderingContext.GetWidth(ch, charWidth);
-+ aRenderingContext.GetRangeWidth(top, aLength, offset, offset + 1, (PRUint32&)charWidth);
- glyphWidth += charWidth + aTextStyle.mLetterSpacing;
- }
-- if (justifying && (!isEndOfLine || aLength > 0)
-+ if (justifying && (!isEndOfLine || (offset + 1) < aLength)
- && IsJustifiableCharacter(ch, isCJ)) {
- glyphWidth += aTextStyle.mExtraSpacePerJustifiableCharacter;
- if ((PRUint32)--aTextStyle.mNumJustifiableCharacterToRender
diff --git a/firefox-1.5-pango-underline.patch b/firefox-1.5-pango-underline.patch
deleted file mode 100644
index c6b8649..0000000
--- a/firefox-1.5-pango-underline.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff -pruN -x '.moz*' -x .deps -x 'thunderbird*' -x '*.mk' -x 'config*' -x dist -x build -x toolkit -x '*o' -x '*a' -x '*html' mozilla.orig/layout/generic/nsTextFrame.cpp mozilla/layout/generic/nsTextFrame.cpp
---- mozilla.orig/layout/generic/nsTextFrame.cpp 2006-12-20 12:53:26.000000000 +0900
-+++ mozilla/layout/generic/nsTextFrame.cpp 2006-12-20 15:43:14.000000000 +0900
-@@ -2097,11 +2097,11 @@ nsTextFrame::PaintTextDecorations(nsIRen
- nsRect rect = GetRect();
- while(aDetails){
- const nscoord* sp= aSpacing;
-- PRInt32 startOffset = 0;
-- PRInt32 textWidth = 0;
-- PRInt32 start = PR_MAX(0,(aDetails->mStart - (PRInt32)aIndex));
-- PRInt32 end = PR_MIN((PRInt32)aLength,(aDetails->mEnd - (PRInt32)aIndex));
-- PRInt32 i;
-+ PRUint32 startOffset = 0;
-+ PRUint32 textWidth = 0;
-+ PRInt32 start = PR_MAX(0,(aDetails->mStart - (PRInt32)aIndex));
-+ PRInt32 end = PR_MIN((PRInt32)aLength,(aDetails->mEnd - (PRInt32)aIndex));
-+ PRInt32 i;
- if ((start < end) && ((aLength - start) > 0))
- {
- //aDetails allready processed to have offsets from frame start not content offsets
-@@ -2117,7 +2117,7 @@ nsTextFrame::PaintTextDecorations(nsIRen
- }
- }
- else
-- aRenderingContext.GetWidth(aText, start, startOffset);
-+ aRenderingContext.GetRangeWidth(aText, aLength, 0, start, startOffset);
- }
- if (sp){
- for (i = start; i < end;i ++){
-@@ -2125,8 +2125,7 @@ nsTextFrame::PaintTextDecorations(nsIRen
- }
- }
- else
-- aRenderingContext.GetWidth(aText + start,
-- PRUint32(end - start), textWidth);
-+ aRenderingContext.GetRangeWidth(aText, aLength, start, end, textWidth);
-
- }
- nscoord offset, size;
diff --git a/firefox-1.5-theme-change.patch b/firefox-1.5-theme-change.patch
deleted file mode 100644
index 375f06f..0000000
--- a/firefox-1.5-theme-change.patch
+++ /dev/null
@@ -1,263 +0,0 @@
-Index: layout/base/nsPresContext.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/layout/base/nsPresContext.cpp,v
-retrieving revision 3.288.12.2.4.1
-diff -d -u -p -r3.288.12.2.4.1 nsPresContext.cpp
---- layout/base/nsPresContext.cpp 21 Apr 2006 23:30:50 -0000 3.288.12.2.4.1
-+++ layout/base/nsPresContext.cpp 26 Sep 2006 19:26:40 -0000
-@@ -73,6 +73,9 @@
- #include "nsIDOMDocument.h"
- #include "nsAutoPtr.h"
- #include "nsEventStateManager.h"
-+#include "nsIEventQueue.h"
-+#include "nsIEventQueueService.h"
-+
- #ifdef IBMBIDI
- #include "nsBidiPresUtils.h"
- #endif // IBMBIDI
-@@ -267,6 +270,7 @@ nsPresContext::~nsPresContext()
- NS_IF_RELEASE(mDeviceContext);
- NS_IF_RELEASE(mLookAndFeel);
- NS_IF_RELEASE(mLangGroup);
-+ NS_IF_RELEASE(mEventQueueService);
- }
-
- NS_IMPL_ISUPPORTS2(nsPresContext, nsPresContext, nsIObserver)
-@@ -285,6 +289,17 @@ static const char* const kGenericFont[]
- ".fantasy."
- };
-
-+// Set to true when LookAndFeelChanged needs to be called. This is used
-+// because the look and feel is a service, so there's no need to notify it from
-+// more than one prescontext.
-+static PRBool sLookAndFeelChanged;
-+
-+// Set to true when ThemeChanged needs to be called on mTheme. This is used
-+// because mTheme is a service, so there's no need to notify it from more than
-+// one prescontext.
-+static PRBool sThemeChanged;
-+
-+
- void
- nsPresContext::GetFontPreferences()
- {
-@@ -709,6 +724,9 @@ nsPresContext::Init(nsIDeviceContext* aD
- this);
- #endif
-
-+ rv = CallGetService(NS_EVENTQUEUESERVICE_CONTRACTID, &mEventQueueService);
-+ NS_ENSURE_SUCCESS(rv, rv);
-+
- // Initialize our state from the user preferences
- GetUserPreferences();
-
-@@ -1180,33 +1198,126 @@ nsPresContext::GetTheme()
- void
- nsPresContext::ThemeChanged()
- {
-+ if (!mPendingThemeChanged) {
-+ sLookAndFeelChanged = PR_TRUE;
-+ sThemeChanged = PR_TRUE;
-+
-+ nsCOMPtr<nsIEventQueue> eventQ;
-+ mEventQueueService->
-+ GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
-+ getter_AddRefs(eventQ));
-+ if (!eventQ) {
-+ return;
-+ }
-+
-+ PLEvent* evt = new PLEvent();
-+ if (!evt) {
-+ return;
-+ }
-+
-+ PL_InitEvent(evt, this, nsPresContext::ThemeChangedInternal,
-+ nsPresContext::DestroyThemeChangeEvt);
-+
-+ // After this point, event destruction will release |this|
-+ NS_ADDREF_THIS();
-+
-+ nsresult rv = eventQ->PostEvent(evt);
-+ if (NS_FAILED(rv)) {
-+ PL_DestroyEvent(evt);
-+ } else {
-+ mPendingThemeChanged = PR_TRUE;
-+ }
-+ }
-+}
-+
-+void* PR_CALLBACK
-+nsPresContext::ThemeChangedInternal(PLEvent *aEvent)
-+{
-+ nsPresContext* pc = NS_STATIC_CAST(nsPresContext*, aEvent->owner);
-+
-+ pc->mPendingThemeChanged = PR_FALSE;
-+
- // Tell the theme that it changed, so it can flush any handles to stale theme
- // data.
-- if (mTheme)
-- mTheme->ThemeChanged();
-+ if (pc->mTheme && sThemeChanged) {
-+ pc->mTheme->ThemeChanged();
-+ sThemeChanged = PR_FALSE;
-+ }
-
- // Clear all cached nsILookAndFeel colors.
-- if (mLookAndFeel)
-- mLookAndFeel->LookAndFeelChanged();
-+ if (pc->mLookAndFeel && sLookAndFeelChanged) {
-+ pc->mLookAndFeel->LookAndFeelChanged();
-+ sLookAndFeelChanged = PR_FALSE;
-+ }
-
- // We have to clear style data because the assumption of style rule
- // immutability has been violated since any style rule that uses
- // system colors or fonts (and probably -moz-appearance as well) has
- // changed.
-- nsPresContext::ClearStyleDataAndReflow();
-+ pc->ClearStyleDataAndReflow();
-+
-+ return nsnull;
-+}
-+
-+
-+void PR_CALLBACK
-+nsPresContext::DestroyThemeChangeEvt(PLEvent* aEvent)
-+{
-+ nsPresContext* pc = NS_STATIC_CAST(nsPresContext*, aEvent->owner);
-+ NS_RELEASE(pc);
-+ delete aEvent;
- }
-
- void
- nsPresContext::SysColorChanged()
- {
-- if (mLookAndFeel) {
-+ if (!mPendingSysColorChanged) {
-+ sLookAndFeelChanged = PR_TRUE;
-+
-+ nsCOMPtr<nsIEventQueue> eventQ;
-+ mEventQueueService->
-+ GetSpecialEventQueue(nsIEventQueueService::UI_THREAD_EVENT_QUEUE,
-+ getter_AddRefs(eventQ));
-+ if (!eventQ) {
-+ return;
-+ }
-+
-+ PLEvent* evt = new PLEvent();
-+ if (!evt) {
-+ return;
-+ }
-+
-+ PL_InitEvent(evt, this, nsPresContext::SysColorChangedInternal,
-+ nsPresContext::DestroySysColorChangeEvt);
-+
-+ // After this point, event destruction will release |this|
-+ NS_ADDREF_THIS();
-+
-+ nsresult rv = eventQ->PostEvent(evt);
-+ if (NS_FAILED(rv)) {
-+ PL_DestroyEvent(evt);
-+ } else {
-+ mPendingSysColorChanged = PR_TRUE;
-+ }
-+ }
-+}
-+
-+void* PR_CALLBACK
-+nsPresContext::SysColorChangedInternal(PLEvent *aEvent)
-+{
-+ nsPresContext* pc = NS_STATIC_CAST(nsPresContext*, aEvent->owner);
-+
-+ pc->mPendingSysColorChanged = PR_FALSE;
-+
-+ if (pc->mLookAndFeel && sLookAndFeelChanged) {
- // Don't use the cached values for the system colors
-- mLookAndFeel->LookAndFeelChanged();
-+ pc->mLookAndFeel->LookAndFeelChanged();
-+ sLookAndFeelChanged = PR_FALSE;
- }
--
-+
- // Reset default background and foreground colors for the document since
- // they may be using system colors
-- GetDocumentColorPreferences();
-+ pc->GetDocumentColorPreferences();
-
- // Clear out all of the style data since it may contain RGB values
- // which originated from system colors.
-@@ -1222,7 +1333,17 @@ nsPresContext::SysColorChanged()
- // data without reflowing/updating views will lead to incorrect change hints
- // later, because when generating change hints, any style structs which have
- // been cleared and not reread are assumed to not be used at all.
-- ClearStyleDataAndReflow();
-+ pc->ClearStyleDataAndReflow();
-+
-+ return nsnull;
-+}
-+
-+void PR_CALLBACK
-+nsPresContext::DestroySysColorChangeEvt(PLEvent* aEvent)
-+{
-+ nsPresContext* pc = NS_STATIC_CAST(nsPresContext*, aEvent->owner);
-+ NS_RELEASE(pc);
-+ delete aEvent;
- }
-
- void
-Index: layout/base/nsPresContext.h
-===================================================================
-RCS file: /cvsroot/mozilla/layout/base/nsPresContext.h,v
-retrieving revision 3.150.4.2
-diff -d -u -p -r3.150.4.2 nsPresContext.h
---- layout/base/nsPresContext.h 29 Aug 2005 16:15:39 -0000 3.150.4.2
-+++ layout/base/nsPresContext.h 26 Sep 2006 19:26:40 -0000
-@@ -56,6 +56,7 @@
- #include "nsCRT.h"
- #include "nsIPrintSettings.h"
- #include "nsPropertyTable.h"
-+#include "plevent.h"
- #ifdef IBMBIDI
- class nsBidiPresUtils;
- #endif // IBMBIDI
-@@ -76,6 +77,7 @@ class nsIAtom;
- class nsIEventStateManager;
- class nsIURI;
- class nsILookAndFeel;
-+class nsIEventQueueService;
- class nsICSSPseudoComparator;
- class nsIAtom;
- struct nsStyleStruct;
-@@ -627,6 +629,14 @@ public:
- const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
-
- protected:
-+ static NS_HIDDEN_(void*) PR_CALLBACK ThemeChangedInternal(PLEvent* aEvent);
-+ static NS_HIDDEN_(void*) PR_CALLBACK SysColorChangedInternal(PLEvent* aEvent);
-+ static NS_HIDDEN_(void) PR_CALLBACK DestroyThemeChangeEvt(PLEvent* aEvent);
-+ static NS_HIDDEN_(void) PR_CALLBACK DestroySysColorChangeEvt(PLEvent* aEvent);
-+
-+ friend void* PR_CALLBACK ThemeChangedInternal(PLEvent* aEvent);
-+ friend void* PR_CALLBACK SysColorChangedInternal(PLEvent* aEvent);
-+
- NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
- NS_HIDDEN_(void) GetDocumentColorPreferences();
-
-@@ -654,6 +664,7 @@ protected:
- // from gfx back to layout.
- nsIEventStateManager* mEventManager; // [STRONG]
- nsILookAndFeel* mLookAndFeel; // [STRONG]
-+ nsIEventQueueService *mEventQueueService; // [STRONG]
- nsIAtom* mMedium; // initialized by subclass ctors;
- // weak pointer to static atom
-
-@@ -724,6 +735,8 @@ protected:
- unsigned mCanPaginatedScroll : 1;
- unsigned mDoScaledTwips : 1;
- unsigned mEnableJapaneseTransform : 1;
-+ unsigned mPendingSysColorChanged : 1;
-+ unsigned mPendingThemeChanged : 1;
- #ifdef IBMBIDI
- unsigned mIsVisual : 1;
- unsigned mIsBidiSystem : 1;
diff --git a/firefox-1.5-xft-rangewidth.patch b/firefox-1.5-xft-rangewidth.patch
deleted file mode 100644
index 1ecc5f2..0000000
--- a/firefox-1.5-xft-rangewidth.patch
+++ /dev/null
@@ -1,283 +0,0 @@
-diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp mozilla/gfx/src/gtk/nsFontMetricsXft.cpp
---- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.cpp 2006-04-25 08:58:36.000000000 +0900
-+++ mozilla/gfx/src/gtk/nsFontMetricsXft.cpp 2007-02-08 01:50:05.000000000 +0900
-@@ -227,10 +227,14 @@ static nsresult EnumFontsXft (nsIAto
-
- static void ConvertCharToUCS4 (const char *aString,
- PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- nsAutoFcChar32Buffer &aOutBuffer,
- PRUint32 *aOutLen);
- static void ConvertUnicharToUCS4 (const PRUnichar *aString,
- PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- nsAutoFcChar32Buffer &aOutBuffer,
- PRUint32 *aOutLen);
- static nsresult ConvertUCS4ToCustom (FcChar32 *aSrc, PRUint32 aSrcLen,
-@@ -507,7 +511,7 @@ nsFontMetricsXft::GetWidth(const PRUnich
- return NS_OK;
- }
-
-- gint rawWidth = RawGetWidth(aString, aLength);
-+ gint rawWidth = RawGetWidth(aString, aLength, 0, aLength);
-
- float f;
- f = mDeviceContext->DevUnitsToAppUnits();
-@@ -533,7 +537,7 @@ nsFontMetricsXft::GetTextDimensions(cons
- return NS_OK;
-
- nsresult rv;
-- rv = EnumerateGlyphs(aString, aLength,
-+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
- &nsFontMetricsXft::TextDimensionsCallback,
- &aDimensions);
-
-@@ -608,7 +612,7 @@ nsFontMetricsXft::DrawString(const char
- nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
- data.drawBuffer = &drawBuffer;
-
-- return EnumerateGlyphs(aString, aLength,
-+ return EnumerateGlyphs(aString, aLength, 0, aLength,
- &nsFontMetricsXft::DrawStringCallback, &data);
- }
-
-@@ -638,7 +642,7 @@ nsFontMetricsXft::DrawString(const PRUni
- nsAutoDrawSpecBuffer drawBuffer(data.draw, &data.color);
- data.drawBuffer = &drawBuffer;
-
-- return EnumerateGlyphs(aString, aLength,
-+ return EnumerateGlyphs(aString, aLength, 0, aLength,
- &nsFontMetricsXft::DrawStringCallback, &data);
- }
-
-@@ -662,7 +666,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
- data.firstTime = PR_TRUE;
-
- nsresult rv;
-- rv = EnumerateGlyphs(aString, aLength,
-+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
- &nsFontMetricsXft::BoundingMetricsCallback, &data);
- NS_ENSURE_SUCCESS(rv, rv);
-
-@@ -700,7 +704,7 @@ nsFontMetricsXft::GetBoundingMetrics(con
- data.firstTime = PR_TRUE;
-
- nsresult rv;
-- rv = EnumerateGlyphs(aString, aLength,
-+ rv = EnumerateGlyphs(aString, aLength, 0, aLength,
- &nsFontMetricsXft::BoundingMetricsCallback, &data);
- NS_ENSURE_SUCCESS(rv, rv);
-
-@@ -758,7 +762,17 @@ nsFontMetricsXft::GetRangeWidth(const PR
- PRUint32 aEnd,
- PRUint32 &aWidth)
- {
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ if (!aLength) {
-+ aWidth = 0;
-+ return NS_OK;
-+ }
-+
-+ gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
-+ float f = mDeviceContext->DevUnitsToAppUnits();
-+
-+ aWidth = NSToCoordRound(rawWidth * f);
-+
-+ return NS_OK;
- }
-
- nsresult
-@@ -768,7 +782,17 @@ nsFontMetricsXft::GetRangeWidth(const ch
- PRUint32 aEnd,
- PRUint32 &aWidth)
- {
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ if (!aLength) {
-+ aWidth = 0;
-+ return NS_OK;
-+ }
-+
-+ gint rawWidth = RawGetWidth(aText, aLength, aStart, aEnd);
-+ float f = mDeviceContext->DevUnitsToAppUnits();
-+
-+ aWidth = NSToCoordRound(rawWidth * f);
-+
-+ return NS_OK;
- }
-
- PRUint32
-@@ -850,12 +874,12 @@ nsFontMetricsXft::CacheFontMetrics(void)
- // mSpaceWidth (width of a space)
- gint rawWidth;
- PRUnichar unispace(' ');
-- rawWidth = RawGetWidth(&unispace, 1);
-+ rawWidth = RawGetWidth(&unispace, 1, 0, 1);
- mSpaceWidth = NSToCoordRound(rawWidth * f);
-
- // mAveCharWidth (width of an 'average' char)
- PRUnichar xUnichar('x');
-- rawWidth = RawGetWidth(&xUnichar, 1);
-+ rawWidth = RawGetWidth(&xUnichar, 1, 0, 1);
- mAveCharWidth = NSToCoordRound(rawWidth * f);
-
- // mXHeight (height of an 'x' character)
-@@ -1226,12 +1250,27 @@ nsFontMetricsXft::DoMatch(PRBool aMatchA
- }
-
- gint
--nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength)
-+nsFontMetricsXft::RawGetWidth(const PRUnichar* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
-+{
-+ nscoord width = 0;
-+ nsresult rv;
-+
-+ rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
-+ &nsFontMetricsXft::GetWidthCallback, &width);
-+
-+ if (NS_FAILED(rv))
-+ width = 0;
-+
-+ return width;
-+}
-+
-+gint
-+nsFontMetricsXft::RawGetWidth(const char* aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd)
- {
- nscoord width = 0;
- nsresult rv;
-
-- rv = EnumerateGlyphs(aString, aLength,
-+ rv = EnumerateGlyphs(aString, aLength, aStart, aEnd,
- &nsFontMetricsXft::GetWidthCallback, &width);
-
- if (NS_FAILED(rv))
-@@ -1457,6 +1496,8 @@ nsFontMetricsXft::EnumerateXftGlyphs(con
- nsresult
- nsFontMetricsXft::EnumerateGlyphs(const PRUnichar *aString,
- PRUint32 aLen,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- GlyphEnumeratorCallback aCallback,
- void *aCallbackData)
- {
-@@ -1465,7 +1506,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
-
- NS_ENSURE_TRUE(aLen, NS_OK);
-
-- ConvertUnicharToUCS4(aString, aLen, charBuffer, &len);
-+ ConvertUnicharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
- if (!len)
- return NS_ERROR_OUT_OF_MEMORY;
-
-@@ -1475,6 +1516,8 @@ nsFontMetricsXft::EnumerateGlyphs(const
- nsresult
- nsFontMetricsXft::EnumerateGlyphs(const char *aString,
- PRUint32 aLen,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- GlyphEnumeratorCallback aCallback,
- void *aCallbackData)
- {
-@@ -1484,7 +1527,7 @@ nsFontMetricsXft::EnumerateGlyphs(const
- NS_ENSURE_TRUE(aLen, NS_OK);
-
- // Convert the incoming string into an array of UCS4 chars
-- ConvertCharToUCS4(aString, aLen, charBuffer, &len);
-+ ConvertCharToUCS4(aString, aLen, aStart, aEnd, charBuffer, &len);
- if (!len)
- return NS_ERROR_OUT_OF_MEMORY;
-
-@@ -2343,7 +2386,7 @@ EnumFontsXft(nsIAtom* aLangGroup, const
-
- /* static */
- void
--ConvertCharToUCS4(const char *aString, PRUint32 aLength,
-+ConvertCharToUCS4(const char *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
- nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
- {
- *aOutLen = 0;
-@@ -2352,19 +2395,21 @@ ConvertCharToUCS4(const char *aString, P
- if (!aOutBuffer.EnsureElemCapacity(aLength))
- return;
- outBuffer = aOutBuffer.get();
-+ if (aEnd > aLength)
-+ aEnd = aLength;
-
-- for (PRUint32 i = 0; i < aLength; ++i) {
-- outBuffer[i] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
-+ for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
-+ outBuffer[i - aStart] = PRUint8(aString[i]); // to convert char >= 0x80 correctly
- }
-
-- *aOutLen = aLength;
-+ *aOutLen = aEnd - aStart;
- }
-
- // Convert the incoming string into an array of UCS4 chars
-
- /* static */
- void
--ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,
-+ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength, PRUint32 aStart, PRUint32 aEnd,
- nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
- {
- *aOutLen = 0;
-@@ -2378,7 +2423,7 @@ ConvertUnicharToUCS4(const PRUnichar *aS
-
- // Walk the passed in string looking for surrogates to convert to
- // their full ucs4 representation.
-- for (PRUint32 i = 0; i < aLength; ++i) {
-+ for (PRUint32 i = aStart; i < aLength && i < aEnd; ++i) {
- PRUnichar c = aString[i];
-
- // Optimized for the non-surrogate case
-@@ -2693,12 +2738,12 @@ ConvertUCS4ToCustom(FcChar32 *aSrc, PRU
- #endif
- // Convert 16bit custom font codes to UCS4
- ConvertUnicharToUCS4(NS_REINTERPRET_CAST(PRUnichar *, med),
-- medLen >> 1, aResult, &aDestLen);
-+ medLen >> 1, 0, medLen >> 1, aResult, &aDestLen);
- rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
- }
- else {
- // Convert 8bit custom font codes to UCS4
-- ConvertCharToUCS4(med, medLen, aResult, &aDestLen);
-+ ConvertCharToUCS4(med, medLen, 0, medLen, aResult, &aDestLen);
- rv = aDestLen ? rv : NS_ERROR_OUT_OF_MEMORY;
- }
-
-diff -pruN -x '.moz*' -x .libs -x .deps -x dist -x 'config*' -x 'firefox*' -x '*a' -x '*so' -x '*o' -x build -x '*html' mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h mozilla/gfx/src/gtk/nsFontMetricsXft.h
---- mozilla.orig/gfx/src/gtk/nsFontMetricsXft.h 2005-05-03 05:48:30.000000000 +0900
-+++ mozilla/gfx/src/gtk/nsFontMetricsXft.h 2007-02-08 01:38:27.000000000 +0900
-@@ -259,7 +259,13 @@ private:
- void DoMatch (PRBool aMatchAll);
-
- gint RawGetWidth (const PRUnichar* aString,
-- PRUint32 aLength);
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd);
-+ gint RawGetWidth (const char* aString,
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd);
- nsresult SetupMiniFont (void);
- nsresult DrawUnknownGlyph (FcChar32 aChar,
- nscoord aX,
-@@ -272,10 +278,14 @@ private:
- void *aCallbackData);
- nsresult EnumerateGlyphs (const char *aString,
- PRUint32 aLen,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- GlyphEnumeratorCallback aCallback,
- void *aCallbackData);
- nsresult EnumerateGlyphs (const PRUnichar *aString,
- PRUint32 aLen,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
- GlyphEnumeratorCallback aCallback,
- void *aCallbackData);
- void PrepareToDraw (nsRenderingContextGTK *aContext,
diff --git a/firefox-2.0-dnd.patch b/firefox-2.0-dnd.patch
deleted file mode 100644
index 3730ed5..0000000
--- a/firefox-2.0-dnd.patch
+++ /dev/null
@@ -1,949 +0,0 @@
-Index: widget/src/gtk2/nsClipboard.cpp
-===================================================================
-RCS file: /export/src/cvs/mozilla1.7/mozilla/widget/src/gtk2/nsClipboard.cpp,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 nsClipboard.cpp
---- widget/src/gtk2/nsClipboard.cpp 2004/04/13 06:46:17 1.1.1.1
-+++ widget/src/gtk2/nsClipboard.cpp 2004/04/13 08:22:00
-@@ -73,7 +73,7 @@
- GdkEventSelection *aEvent,
- nsClipboard *aClipboard);
-
--static void
-+void
- ConvertHTMLtoUCS2 (guchar *data,
- PRInt32 dataLength,
- PRUnichar **unicodeData,
-@@ -473,7 +473,6 @@
- // utf-8.
-
- PRInt32 whichClipboard;
--
- // which clipboard?
- if (aSelectionData->selection == GDK_SELECTION_PRIMARY)
- whichClipboard = kSelectionClipboard;
-@@ -547,16 +546,8 @@
- * Byte Order Mark (BOM)). Adding BOM can help other app to
- * detect mozilla use UCS2 encoding when copy-paste.
- */
-- guchar *buffer = (guchar *)
-- nsMemory::Alloc((len * sizeof(guchar)) + sizeof(PRUnichar));
-- if (!buffer)
-- return;
-- PRUnichar prefix = 0xFEFF;
-- memcpy(buffer, &prefix, sizeof(prefix));
-- memcpy(buffer + sizeof(prefix), primitive_data, len);
-- nsMemory::Free((guchar *)primitive_data);
-- primitive_data = (guchar *)buffer;
-- len += sizeof(prefix);
-+ addBOM(NS_REINTERPRET_CAST(guchar **, &primitive_data),
-+ NS_REINTERPRET_CAST(gint *, &len));
- }
-
- gtk_selection_data_set(aSelectionData, aSelectionData->target,
-@@ -736,6 +727,22 @@
- return;
- }
- str.AssignLiteral("UNKNOWN");
-+}
-+
-+void addBOM(guchar **data, gint *len)
-+{
-+ guchar* indata = *data;
-+ gint inlen = *len;
-+ guchar *buffer = (guchar *)
-+ nsMemory::Alloc((inlen * sizeof(guchar)) + sizeof(PRUnichar));
-+ if (!buffer)
-+ return;
-+ PRUnichar prefix = 0xFEFF;
-+ memcpy(buffer, &prefix, sizeof(prefix));
-+ memcpy(buffer + sizeof(prefix), indata, inlen);
-+ nsMemory::Free((guchar *)indata);
-+ *data = (guchar *)buffer;
-+ *len += sizeof(prefix);
- }
-
- static void
-Index: widget/src/gtk2/nsClipboard.h
-===================================================================
-RCS file: /export/src/cvs/mozilla1.7/mozilla/widget/src/gtk2/nsClipboard.h,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 nsClipboard.h
---- widget/src/gtk2/nsClipboard.h 2004/04/13 06:46:17 1.1.1.1
-+++ widget/src/gtk2/nsClipboard.h 2004/04/13 08:22:00
-@@ -87,4 +87,6 @@
-
- };
-
-+void addBOM(guchar **data, gint *len);
-+
- #endif /* __nsClipboard_h_ */
-Index: widget/src/gtk2/nsDragService.cpp
-===================================================================
-RCS file: /export/src/cvs/mozilla1.7/mozilla/widget/src/gtk2/nsDragService.cpp,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 nsDragService.cpp
---- widget/src/gtk2/nsDragService.cpp 2004/04/13 06:46:17 1.1.1.1
-+++ widget/src/gtk2/nsDragService.cpp 2004/04/13 08:22:00
-@@ -41,6 +41,8 @@
- #include <gtk/gtkinvisible.h>
- #include <gdk/gdkx.h>
- #include "nsCRT.h"
-+#include "nsString.h"
-+#include "nsReadableUtils.h"
-
-
- static PRLogModuleInfo *sDragLm = NULL;
-@@ -49,6 +51,9 @@
- static const char gMozUrlType[] = "_NETSCAPE_URL";
- static const char gTextUriListType[] = "text/uri-list";
-
-+static const char gPlainTextUTF16[] = "text/plain;charset=utf-16";
-+static const char gPlainTextUTF8[] = "text/plain;charset=utf-8";
-+
- NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
- NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
- NS_IMPL_QUERY_INTERFACE4(nsDragService,
-@@ -57,6 +62,10 @@
- nsIDragSessionGTK,
- nsIObserver)
-
-+void addBOM(guchar **data, gint *len);
-+void ConvertHTMLtoUCS2(guchar * data, PRInt32 dataLength,
-+ PRUnichar** unicodeData, PRInt32& outUnicodeLen);
-+
- static void
- invisibleSourceDragEnd(GtkWidget *aWidget,
- GdkDragContext *aContext,
-@@ -70,6 +79,38 @@
- guint32 aTime,
- gpointer aData);
-
-+struct AutoConvertTargetPair {
-+ const char * internal; // the drag data receiving side
-+ const char * outside; // the drag data providing side
-+ TargetConverter out2in;
-+ TargetConverter in2out;
-+};
-+
-+//converters
-+static void utf8_to_ucs2 (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen);
-+static void ucs2_to_text (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen);
-+static void text_to_ucs2 (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen);
-+
-+// The table used to match an internal target to an outside target
-+// the entry comes early has high priority in matching
-+static const AutoConvertTargetPair autoConvertPair[] = {
-+ {kUnicodeMime, "UTF8_STRING", utf8_to_ucs2, ucs2_to_text},
-+ {kUnicodeMime, "COMPOUND_TEXT", utf8_to_ucs2, ucs2_to_text},
-+ {kUnicodeMime, "TEXT", utf8_to_ucs2, ucs2_to_text},
-+ {kUnicodeMime, "STRING", utf8_to_ucs2, ucs2_to_text},
-+ {kUnicodeMime, kTextMime, text_to_ucs2, ucs2_to_text},
-+ {kUnicodeMime, gPlainTextUTF16, NULL, NULL},
-+ {kUnicodeMime, gPlainTextUTF8, text_to_ucs2, ucs2_to_text},
-+
-+ {kURLMime, gTextUriListType, NULL, ucs2_to_text},
-+ {kURLMime, gMozUrlType, text_to_ucs2, ucs2_to_text},
-+
-+ {NULL, NULL, NULL, NULL},
-+};
-+
- nsDragService::nsDragService()
- {
- // We have to destroy the hidden widget before the event loop stops
-@@ -92,7 +133,7 @@
-
- // set up our logging module
- if (!sDragLm)
-- sDragLm = PR_NewLogModule("nsDragService");
-+ sDragLm = PR_NewLogModule("nsDragService");
- PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::nsDragService"));
- mTargetWidget = 0;
- mTargetDragContext = 0;
-@@ -101,6 +142,8 @@
- mTargetDragDataReceived = PR_FALSE;
- mTargetDragData = 0;
- mTargetDragDataLen = 0;
-+ mTargetDragGdkAtom = 0;
-+ mTargetConverter = NULL;
- }
-
- nsDragService::~nsDragService()
-@@ -173,6 +216,16 @@
- event.button.window = mHiddenWidget->window;
- event.button.time = nsWindow::mLastButtonPressTime;
-
-+ event.button.send_event = 0;
-+ event.button.x = 0;
-+ event.button.y = 0;
-+ event.button.state = 0;
-+ event.button.button = 0;
-+ event.button.device = 0;
-+ event.button.x_root = 0;
-+ event.button.y_root = 0;
-+
-+
- // start our drag.
- GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
- sourceList,
-@@ -291,7 +344,7 @@
- NS_IMETHODIMP
- nsDragService::GetNumDropItems(PRUint32 * aNumItems)
- {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::GetNumDropItems"));
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("==nsDragService::GetNumDropItems==\n"));
- PRBool isList = IsTargetContextList();
- if (isList)
- mSourceDataItems->Count(aNumItems);
-@@ -303,8 +356,9 @@
- *aNumItems = CountTextUriListItems(data, mTargetDragDataLen);
- } else
- *aNumItems = 1;
-+ TargetResetData();
- }
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("%d items", *aNumItems));
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("%d items\n", *aNumItems));
- return NS_OK;
- }
-
-@@ -360,7 +414,7 @@
- PRUint32 tmpDataLen = 0;
- PR_LOG(sDragLm, PR_LOG_DEBUG,
- ("trying to get transfer data for %s\n",
-- (const char *)flavorStr));
-+ (const char *)flavorStr));
- rv = item->GetTransferData(flavorStr,
- getter_AddRefs(data),
- &tmpDataLen);
-@@ -387,6 +441,7 @@
- // Now walk down the list of flavors. When we find one that is
- // actually present, copy out the data into the transferable in that
- // format. SetTransferData() implicitly handles conversions.
-+
- for ( i = 0; i < cnt; ++i ) {
- nsCOMPtr<nsISupports> genericWrapper;
- flavorList->GetElementAt(i,getter_AddRefs(genericWrapper));
-@@ -399,118 +454,58 @@
- GdkAtom gdkFlavor = gdk_atom_intern(flavorStr, FALSE);
- PR_LOG(sDragLm, PR_LOG_DEBUG,
- ("looking for data in type %s, gdk flavor %ld\n",
-- NS_STATIC_CAST(const char*,flavorStr), gdkFlavor));
-+ NS_STATIC_CAST(const char*,flavorStr), gdkFlavor));
- PRBool dataFound = PR_FALSE;
- if (gdkFlavor) {
- GetTargetDragData(gdkFlavor);
- }
- if (mTargetDragData) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("dataFound = PR_TRUE\n"));
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("dataFound = PR_TRUE for %s\n", gdk_atom_name(mTargetDragGdkAtom)));
- dataFound = PR_TRUE;
-- }
-- else {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("dataFound = PR_FALSE\n"));
-- // if we are looking for text/unicode and we fail to find it
-- // on the clipboard first, try again with text/plain. If that
-- // is present, convert it to unicode.
-- if ( strcmp(flavorStr, kUnicodeMime) == 0 ) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("we were looking for text/unicode... \
-- trying again with text/plain\n"));
-- gdkFlavor = gdk_atom_intern(kTextMime, FALSE);
-- GetTargetDragData(gdkFlavor);
-- if (mTargetDragData) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("Got textplain data\n"));
-- const char* castedText =
-- NS_REINTERPRET_CAST(char*, mTargetDragData);
-- PRUnichar* convertedText = nsnull;
-- PRInt32 convertedTextLen = 0;
-- nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode(
-- castedText, mTargetDragDataLen,
-- &convertedText, &convertedTextLen);
-- if ( convertedText ) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("successfully converted plain text \
-- to unicode.\n"));
-- // out with the old, in with the new
-- g_free(mTargetDragData);
-- mTargetDragData = convertedText;
-- mTargetDragDataLen = convertedTextLen * 2;
-- dataFound = PR_TRUE;
-- } // if plain text data on clipboard
-- } // if plain text flavor present
-- } // if looking for text/unicode
--
-- // if we are looking for text/x-moz-url and we failed to find
-- // it on the clipboard, try again with text/uri-list, and then
-- // _NETSCAPE_URL
-- if (strcmp(flavorStr, kURLMime) == 0) {
-+
-+ // we need to do extra work for text/uri-list
-+ if (mTargetDragGdkAtom ==
-+ gdk_atom_intern(gTextUriListType, FALSE)) {
- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("we were looking for text/x-moz-url...\
-- trying again with text/uri-list\n"));
-- gdkFlavor = gdk_atom_intern(gTextUriListType, FALSE);
-- GetTargetDragData(gdkFlavor);
-- if (mTargetDragData) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("Got text/uri-list data\n"));
-- const char *data =
-- NS_REINTERPRET_CAST(char*, mTargetDragData);
-- PRUnichar* convertedText = nsnull;
-- PRInt32 convertedTextLen = 0;
-+ ("Converting text/uri-list data\n"));
-+ const char *data =
-+ NS_REINTERPRET_CAST(char*, mTargetDragData);
-+ PRUnichar* convertedText = nsnull;
-+ PRInt32 convertedTextLen = 0;
-
-- GetTextUriListItem(data, mTargetDragDataLen, aItemIndex,
-- &convertedText, &convertedTextLen);
-+ GetTextUriListItem(data, mTargetDragDataLen, aItemIndex,
-+ &convertedText, &convertedTextLen);
-
-- if ( convertedText ) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("successfully converted \
-- _NETSCAPE_URL to unicode.\n"));
-- // out with the old, in with the new
-- g_free(mTargetDragData);
-- mTargetDragData = convertedText;
-- mTargetDragDataLen = convertedTextLen * 2;
-- dataFound = PR_TRUE;
-- }
-- }
-- else {
-+ if (convertedText) {
- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("failed to get text/uri-list data\n"));
-+ ("successfully converted \
-+ %s to unicode.\n", gTextUriListType));
-+ // out with the old, in with the new
-+ g_free(mTargetDragData);
-+ mTargetDragData = convertedText;
-+ mTargetDragDataLen = convertedTextLen * 2;
- }
-- if (!dataFound) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("we were looking for text/x-moz-url...\
-- trying again with _NETSCAP_URL\n"));
-- gdkFlavor = gdk_atom_intern(gMozUrlType, FALSE);
-- GetTargetDragData(gdkFlavor);
-- if (mTargetDragData) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("Got _NETSCAPE_URL data\n"));
-- const char* castedText =
-- NS_REINTERPRET_CAST(char*, mTargetDragData);
-- PRUnichar* convertedText = nsnull;
-- PRInt32 convertedTextLen = 0;
-- nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode(castedText, mTargetDragDataLen, &convertedText, &convertedTextLen);
-- if ( convertedText ) {
-- PR_LOG(sDragLm,
-- PR_LOG_DEBUG,
-- ("successfully converted _NETSCAPE_URL \
-- to unicode.\n"));
-- // out with the old, in with the new
-- g_free(mTargetDragData);
-- mTargetDragData = convertedText;
-- mTargetDragDataLen = convertedTextLen * 2;
-- dataFound = PR_TRUE;
-- }
-- }
-- else {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("failed to get _NETSCAPE_URL data\n"));
-- }
-- }
- }
--
-- } // else we try one last ditch effort to find our data
--
-+ // Convert text/html into our unicode format
-+ else if (mTargetDragGdkAtom ==
-+ gdk_atom_intern(kHTMLMime, FALSE)) {
-+ PRUnichar* htmlBody= nsnull;
-+ PRInt32 htmlBodyLen = 0;
-+
-+ ConvertHTMLtoUCS2(NS_STATIC_CAST(guchar*, mTargetDragData),
-+ mTargetDragDataLen,
-+ &htmlBody, htmlBodyLen);
-+ if (!htmlBodyLen)
-+ break;
-+ g_free(mTargetDragData);
-+ mTargetDragData = (void *)htmlBody;
-+ mTargetDragDataLen = htmlBodyLen * 2;
-+ }
-+ }
-+ else {
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("dataFound = PR_FALSE\n"));
-+ }
- if (dataFound) {
- // the DOM only wants LF, so convert from MacOS line endings
- // to DOM line endings.
-@@ -542,7 +537,7 @@
- nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
- PRBool *_retval)
- {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported %s",
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::IsDataFlavorSupported %s\n",
- aDataFlavor));
- if (!_retval)
- return NS_ERROR_INVALID_ARG;
-@@ -595,7 +590,7 @@
- currentFlavor->ToString(getter_Copies(flavorStr));
- PR_LOG(sDragLm, PR_LOG_DEBUG,
- ("checking %s against %s\n",
-- (const char *)flavorStr, aDataFlavor));
-+ (const char *)flavorStr, aDataFlavor));
- if (strcmp(flavorStr, aDataFlavor) == 0) {
- PR_LOG(sDragLm, PR_LOG_DEBUG,
- ("boioioioiooioioioing!\n"));
-@@ -609,50 +604,9 @@
- return NS_OK;
- }
-
-- // check the target context vs. this flavor, one at a time
-- GList *tmp;
-- for (tmp = mTargetDragContext->targets; tmp; tmp = tmp->next) {
-- GdkAtom atom = (GdkAtom)GPOINTER_TO_INT(tmp->data);
-- gchar *name = NULL;
-- name = gdk_atom_name(atom);
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("checking %s against %s\n", name, aDataFlavor));
-- if (name && (strcmp(name, aDataFlavor) == 0)) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("good!\n"));
-- *_retval = PR_TRUE;
-- }
-- // check for automatic text/uri-list -> text/x-moz-url mapping
-- if (*_retval == PR_FALSE &&
-- name &&
-- (strcmp(name, gTextUriListType) == 0) &&
-- (strcmp(aDataFlavor, kURLMime) == 0)) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("good! ( it's text/uri-list and \
-- we're checking against text/x-moz-url )\n"));
-- *_retval = PR_TRUE;
-- }
-- // check for automatic _NETSCAPE_URL -> text/x-moz-url mapping
-- if (*_retval == PR_FALSE &&
-- name &&
-- (strcmp(name, gMozUrlType) == 0) &&
-- (strcmp(aDataFlavor, kURLMime) == 0)) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("good! ( it's _NETSCAPE_URL and \
-- we're checking against text/x-moz-url )\n"));
-- *_retval = PR_TRUE;
-- }
-- // check for auto text/plain -> text/unicode mapping
-- if (*_retval == PR_FALSE &&
-- name &&
-- (strcmp(name, kTextMime) == 0) &&
-- (strcmp(aDataFlavor, kUnicodeMime) == 0)) {
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("good! ( it's text plain and we're checking \
-- against text/unicode )\n"));
-- *_retval = PR_TRUE;
-- }
-- g_free(name);
-- }
-+ if (LookupFlavorInTargetList(aDataFlavor) ||
-+ LookupMatchedOutsideTarget(aDataFlavor, NULL, NULL))
-+ *_retval = PR_TRUE;
- return NS_OK;
- }
-
-@@ -691,14 +645,14 @@
- // notify the dragger if we can drop
- switch (mDragAction) {
- case DRAGDROP_ACTION_COPY:
-- action = GDK_ACTION_COPY;
-- break;
-+ action = GDK_ACTION_COPY;
-+ break;
- case DRAGDROP_ACTION_LINK:
-- action = GDK_ACTION_LINK;
-- break;
-+ action = GDK_ACTION_LINK;
-+ break;
- default:
-- action = GDK_ACTION_MOVE;
-- break;
-+ action = GDK_ACTION_MOVE;
-+ break;
- }
- gdk_drag_status(aContext, action, aTime);
- }
-@@ -719,12 +673,23 @@
- guint32 aTime)
- {
- PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetDataReceived"));
-- TargetResetData();
-+ NS_ASSERTION(mTargetDragData == 0, "Data area is NOT empty!!\n");
-+ NS_ASSERTION(mTargetDragDataLen == 0, "Data area is NOT empty!!\n");
-+
- mTargetDragDataReceived = PR_TRUE;
- if (aSelectionData->length > 0) {
-- mTargetDragDataLen = aSelectionData->length;
-- mTargetDragData = g_malloc(mTargetDragDataLen);
-- memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen);
-+ if (mTargetDragGdkAtom && mTargetConverter) {
-+ // need Converting
-+ (*mTargetConverter)((const char*)aSelectionData->data,
-+ aSelectionData->length,
-+ (char **)&mTargetDragData,
-+ &mTargetDragDataLen);
-+ }
-+ else {
-+ mTargetDragDataLen = aSelectionData->length;
-+ mTargetDragData = g_malloc(mTargetDragDataLen);
-+ memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen);
-+ }
- }
- else {
- PR_LOG(sDragLm, PR_LOG_DEBUG,
-@@ -781,13 +746,31 @@
- void
- nsDragService::GetTargetDragData(GdkAtom aFlavor)
- {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("getting data flavor %d\n", aFlavor));
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("mLastWidget is %p and mLastContext is %p\n",
-- mTargetWidget, mTargetDragContext));
-+ const char *flavorStr = gdk_atom_name(aFlavor);
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("GetTargetData with flavor %s\n", flavorStr));
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("mLastWidget is %p, mLastContext is %p\n",
-+ (void*)mTargetWidget, (void*)mTargetDragContext));
- // reset our target data areas
- TargetResetData();
-- gtk_drag_get_data(mTargetWidget, mTargetDragContext, aFlavor, mTargetTime);
--
-+ // if it is a direct match
-+ if (LookupFlavorInTargetList(flavorStr)) {
-+ gtk_drag_get_data(mTargetWidget, mTargetDragContext,
-+ aFlavor, mTargetTime);
-+ mTargetDragGdkAtom = aFlavor;
-+
-+ }
-+ // if it is a auto converting match
-+ else if (LookupMatchedOutsideTarget(flavorStr,
-+ &mTargetDragGdkAtom,
-+ &mTargetConverter))
-+ gtk_drag_get_data(mTargetWidget, mTargetDragContext,
-+ mTargetDragGdkAtom, mTargetTime);
-+ else {
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("Cannot request target %s\n",
-+ flavorStr));
-+ return;
-+ }
- PR_LOG(sDragLm, PR_LOG_DEBUG, ("about to start inner iteration."));
- PRTime entryTime = PR_Now();
- while (!mTargetDragDataReceived && mDoingDrag) {
-@@ -807,9 +791,11 @@
- mTargetDragDataReceived = PR_FALSE;
- // make sure to free old data if we have to
- if (mTargetDragData)
-- g_free(mTargetDragData);
-+ g_free(mTargetDragData);
- mTargetDragData = 0;
- mTargetDragDataLen = 0;
-+ mTargetDragGdkAtom = 0;
-+ mTargetConverter = NULL;
- }
-
- GtkTargetList *
-@@ -841,7 +827,7 @@
- listTarget->info = (guint)listAtom;
- PR_LOG(sDragLm, PR_LOG_DEBUG,
- ("automatically adding target %s with id %ld\n",
-- listTarget->target, listAtom));
-+ listTarget->target, listAtom));
- targetArray.AppendElement(listTarget);
-
- // check what flavours are supported so we can decide what other
-@@ -861,7 +847,7 @@
- ++flavorIndex ) {
- nsCOMPtr<nsISupports> genericWrapper;
- flavorList->GetElementAt(flavorIndex,
-- getter_AddRefs(genericWrapper));
-+ getter_AddRefs(genericWrapper));
- nsCOMPtr<nsISupportsCString> currentFlavor;
- currentFlavor = do_QueryInterface(genericWrapper);
- if (currentFlavor) {
-@@ -908,51 +894,27 @@
- if (currentFlavor) {
- nsXPIDLCString flavorStr;
- currentFlavor->ToString(getter_Copies(flavorStr));
-- // get the atom
-- GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
-- GtkTargetEntry *target =
-- (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
-- target->target = g_strdup(flavorStr);
-- target->flags = 0;
-- target->info = GPOINTER_TO_UINT(atom);
-+ //add the target itself
-+ GtkTargetEntry *target = CreateGtkTargetFor(flavorStr);
- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("adding target %s with id %ld\n",
-- target->target, atom));
-+ ("+++adding importable target %s\n",
-+ target->target));
- targetArray.AppendElement(target);
-- // Check to see if this is text/unicode.
-- // If it is, add text/plain
-- // since we automatically support text/plain
-- // if we support text/unicode.
-- if (strcmp(flavorStr, kUnicodeMime) == 0) {
-- // get the atom for the unicode string
-- GdkAtom plainAtom =
-- gdk_atom_intern(kTextMime, FALSE);
-- GtkTargetEntry *plainTarget =
-- (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
-- plainTarget->target = g_strdup(kTextMime);
-- plainTarget->flags = 0;
-- plainTarget->info = GPOINTER_TO_UINT(plainAtom);
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("automatically adding target %s with \
-- id %ld\n", plainTarget->target, plainAtom));
-- targetArray.AppendElement(plainTarget);
-- }
-- // Check to see if this is the x-moz-url type.
-- // If it is, add _NETSCAPE_URL
-- // this is a type used by everybody.
-- if (strcmp(flavorStr, kURLMime) == 0) {
-- // get the atom name for it
-- GdkAtom urlAtom =
-- gdk_atom_intern(gMozUrlType, FALSE);
-- GtkTargetEntry *urlTarget =
-- (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
-- urlTarget->target = g_strdup(gMozUrlType);
-- urlTarget->flags = 0;
-- urlTarget->info = GPOINTER_TO_UINT(urlAtom);
-- PR_LOG(sDragLm, PR_LOG_DEBUG,
-- ("automatically adding target %s with \
-- id %ld\n", urlTarget->target, urlAtom));
-- targetArray.AppendElement(urlTarget);
-+
-+ //add the auto convert targets
-+ PRUint16 convIndex = 0;
-+ while (autoConvertPair[convIndex].internal &&
-+ autoConvertPair[convIndex].outside) {
-+ if (!strcmp(autoConvertPair[convIndex].internal,
-+ flavorStr)) {
-+ target = CreateGtkTargetFor( \
-+ autoConvertPair[convIndex].outside);
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ (" ++auto adding target %s\n",
-+ target->target));
-+ targetArray.AppendElement(target);
-+ }
-+ ++convIndex;
- }
- }
- } // foreach flavor in item
-@@ -965,11 +927,11 @@
- if (targetCount) {
- // allocate space to create the list of valid targets
- targets =
-- (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry) * targetCount);
-+ (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry) * targetCount);
- PRUint32 targetIndex;
- for ( targetIndex = 0; targetIndex < targetCount; ++targetIndex) {
- GtkTargetEntry *disEntry =
-- (GtkTargetEntry *)targetArray.ElementAt(targetIndex);
-+ (GtkTargetEntry *)targetArray.ElementAt(targetIndex);
- // this is a string reference but it will be freed later.
- targets[targetIndex].target = disEntry->target;
- targets[targetIndex].flags = disEntry->flags;
-@@ -979,7 +941,7 @@
- // clean up the target list
- for (PRUint32 cleanIndex = 0; cleanIndex < targetCount; ++cleanIndex) {
- GtkTargetEntry *thisTarget =
-- (GtkTargetEntry *)targetArray.ElementAt(cleanIndex);
-+ (GtkTargetEntry *)targetArray.ElementAt(cleanIndex);
- g_free(thisTarget->target);
- g_free(thisTarget);
- }
-@@ -1067,7 +1029,7 @@
- guint aInfo,
- guint32 aTime)
- {
-- PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::SourceDataGet"));
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("\nnsDragService::SourceDataGet"));
- GdkAtom atom = (GdkAtom)aInfo;
- nsXPIDLCString mimeFlavor;
- gchar *typeName = 0;
-@@ -1104,22 +1066,18 @@
- nsCOMPtr<nsITransferable> item;
- item = do_QueryInterface(genericItem);
- if (item) {
-- // if someone was asking for text/plain, lookup unicode instead so
-- // we can convert it.
-- PRBool needToDoConversionToPlainText = PR_FALSE;
-+ TargetConverter converter = NULL;
- const char* actualFlavor = mimeFlavor;
-- if (strcmp(mimeFlavor,kTextMime) == 0) {
-- actualFlavor = kUnicodeMime;
-- needToDoConversionToPlainText = PR_TRUE;
-- }
-- // if someone was asking for _NETSCAPE_URL we need to convert to
-- // plain text but we also need to look for x-moz-url
-- else if (strcmp(mimeFlavor, gMozUrlType) == 0) {
-- actualFlavor = kURLMime;
-- needToDoConversionToPlainText = PR_TRUE;
-+ PRUint32 convIndex = 0;
-+ while (autoConvertPair[convIndex].outside &&
-+ autoConvertPair[convIndex].internal) {
-+ if (!strcmp(mimeFlavor, autoConvertPair[convIndex].outside)) {
-+ actualFlavor = autoConvertPair[convIndex].internal;
-+ converter = autoConvertPair[convIndex].in2out;
-+ break;
-+ }
-+ ++convIndex;
- }
-- else
-- actualFlavor = mimeFlavor;
-
- PRUint32 tmpDataLen = 0;
- void *tmpData = NULL;
-@@ -1131,18 +1089,24 @@
- if (NS_SUCCEEDED(rv)) {
- nsPrimitiveHelpers::CreateDataFromPrimitive (actualFlavor, data,
- &tmpData, tmpDataLen);
-+
-+ if (strcmp(actualFlavor, kHTMLMime) == 0) {
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("add BOM prefix for %s\n",
-+ kHTMLMime));
-+ addBOM(NS_REINTERPRET_CAST(guchar **, &tmpData),
-+ NS_REINTERPRET_CAST(gint *, &tmpDataLen));
-+ }
-+
- // if required, do the extra work to convert unicode to plain
- // text and replace the output values with the plain text.
-- if (needToDoConversionToPlainText) {
-+ if (converter) {
- char* plainTextData = nsnull;
- PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*,
- tmpData);
-- PRInt32 plainTextLen = 0;
-- nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText(
-- castedUnicode,
-- tmpDataLen / 2,
-- &plainTextData,
-- &plainTextLen);
-+ PRUint32 plainTextLen = 0;
-+ (*converter)((const char*)castedUnicode, tmpDataLen,
-+ &plainTextData, &plainTextLen);
-+
- if (tmpData) {
- // this was not allocated using glib
- free(tmpData);
-@@ -1190,3 +1154,149 @@
- dragService->SourceEndDrag();
- }
-
-+PRBool
-+nsDragService::LookupFlavorInTargetList(const char *aDataFlavor)
-+{
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("nsDragService::LookupFlavorInTargetList,"
-+ "checking %s \n", aDataFlavor));
-+
-+ if (!mTargetDragContext || !aDataFlavor)
-+ return PR_FALSE;
-+
-+ GList *targetList = mTargetDragContext->targets;
-+ while (targetList) {
-+ GdkAtom atom = (GdkAtom)GPOINTER_TO_INT(targetList->data);
-+ gchar *atomName = gdk_atom_name(atom);
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("checking %s against %s\n", aDataFlavor, atomName));
-+ if (atomName && (strcmp(atomName, aDataFlavor) == 0)) {
-+ PR_LOG(sDragLm, PR_LOG_DEBUG, ("good!\n"));
-+ g_free(atomName);
-+ return PR_TRUE;
-+ }
-+ targetList = targetList->next;
-+ }
-+ return PR_FALSE;
-+}
-+
-+PRBool
-+nsDragService::LookupMatchedOutsideTarget(const char *aDataFlavor,
-+ GdkAtom *aAtom,
-+ TargetConverter *aConverter)
-+{
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("nsDragService::LookupMatchedOutsideTarget,"
-+ "checking %s \n", aDataFlavor));
-+
-+ if (!mTargetDragContext || !aDataFlavor)
-+ return PR_FALSE;
-+
-+ gint index = 0;
-+ while (autoConvertPair[index].internal &&
-+ autoConvertPair[index].outside) {
-+ if (!strcmp(autoConvertPair[index].internal, aDataFlavor) &&
-+ LookupFlavorInTargetList(autoConvertPair[index].outside)) {
-+ if (aConverter)
-+ *aConverter = autoConvertPair[index].out2in;
-+ if (aAtom)
-+ *aAtom = gdk_atom_intern(autoConvertPair[index].outside,
-+ FALSE);
-+ return PR_TRUE;
-+ }
-+ ++index;
-+ }
-+ return PR_FALSE;
-+}
-+
-+PRBool
-+nsDragService::LookupMatchedInternalTarget(const char *aDataFlavor,
-+ GdkAtom *aAtom,
-+ TargetConverter *aConverter)
-+{
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("nsDragService::LookupMatchedInternalTarget,"
-+ "checking %s \n", aDataFlavor));
-+
-+ if (!mTargetDragContext || !aDataFlavor)
-+ return PR_FALSE;
-+
-+ gint index = 0;
-+ while (autoConvertPair[index].internal &&
-+ autoConvertPair[index].outside) {
-+ if (!strcmp(autoConvertPair[index].outside, aDataFlavor) &&
-+ LookupFlavorInTargetList(autoConvertPair[index].internal)) {
-+ if (aConverter)
-+ *aConverter = autoConvertPair[index].in2out;
-+ if (aAtom)
-+ *aAtom = gdk_atom_intern(autoConvertPair[index].internal,
-+ FALSE);
-+ return PR_TRUE;
-+ }
-+ ++index;
-+ }
-+ return PR_FALSE;
-+}
-+
-+GtkTargetEntry *
-+nsDragService::CreateGtkTargetFor(const char *aFlavorStr)
-+{
-+ // get the atom
-+ GdkAtom atom = gdk_atom_intern(aFlavorStr, FALSE);
-+ GtkTargetEntry *target =
-+ (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
-+ NS_ASSERTION(target, "No enough mem");
-+
-+ target->target = g_strdup(aFlavorStr);
-+ target->flags = 0;
-+ target->info = GPOINTER_TO_UINT(atom);
-+
-+ return target;
-+}
-+
-+//converters
-+
-+// static
-+void
-+utf8_to_ucs2 (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen)
-+{
-+ nsAutoString ucs2string = NS_ConvertUTF8toUCS2(aDataIn);
-+ *aDataOut = (char *)ToNewUnicode(ucs2string);
-+ *aDataOutLen = ucs2string.Length() * 2;
-+
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("AutoConverting: utf8 ---> unicode.\n"));
-+
-+}
-+
-+//static
-+void
-+ucs2_to_text (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen)
-+{
-+ nsPrimitiveHelpers::
-+ ConvertUnicodeToPlatformPlainText((PRUnichar *)aDataIn,
-+ int(aDataInLen / 2),
-+ aDataOut, (PRInt32 *)aDataOutLen);
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("AutoConverting: ucs2 ---> platform text.\n"));
-+}
-+
-+//static
-+void
-+text_to_ucs2 (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen)
-+{
-+ PRUnichar *convertedText = nsnull;
-+ PRInt32 convertedTextLen = 0;
-+ nsPrimitiveHelpers::
-+ ConvertPlatformPlainTextToUnicode(aDataIn, aDataInLen,
-+ &convertedText, &convertedTextLen);
-+ if (convertedText) {
-+ PR_LOG(sDragLm, PR_LOG_DEBUG,
-+ ("AutoConverting: plain text ---> unicode.\n"));
-+ *aDataOut = NS_REINTERPRET_CAST(char*, convertedText);
-+ *aDataOutLen = convertedTextLen * 2;
-+ }
-+}
-Index: widget/src/gtk2/nsDragService.h
-===================================================================
-RCS file: /export/src/cvs/mozilla1.7/mozilla/widget/src/gtk2/nsDragService.h,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 nsDragService.h
---- widget/src/gtk2/nsDragService.h 2004/04/13 06:46:17 1.1.1.1
-+++ widget/src/gtk2/nsDragService.h 2004/04/13 08:22:00
-@@ -33,6 +33,8 @@
- #include "nsIObserver.h"
- #include <gtk/gtk.h>
-
-+typedef void (*TargetConverter) (const char *aDataIn, unsigned int aDataInLen,
-+ char **aDataOut, unsigned int *aDataOutLen);
-
- /**
- * Native GTK DragService wrapper
-@@ -64,7 +66,8 @@
- NS_IMETHOD GetNumDropItems (PRUint32 * aNumItems);
- NS_IMETHOD GetData (nsITransferable * aTransferable,
- PRUint32 aItemIndex);
-- NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval);
-+ NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor,
-+ PRBool *_retval);
-
- // nsIDragSessionGTK
-
-@@ -112,6 +115,9 @@
- // last data received and its length
- void *mTargetDragData;
- PRUint32 mTargetDragDataLen;
-+ GdkAtom mTargetDragGdkAtom; // the real target we asked for
-+ TargetConverter mTargetConverter; //
-+
- // is the current target drag context contain a list?
- PRBool IsTargetContextList(void);
- // this will get the native data from the last target given a
-@@ -129,7 +135,17 @@
- // get a list of the sources in gtk's format
- GtkTargetList *GetSourceList(void);
-
-+ // check if a flavor supported by source target list
-+ PRBool LookupFlavorInTargetList(const char *aDataFlavor);
-+ PRBool LookupMatchedOutsideTarget(const char *aDataFlavor,
-+ GdkAtom *aAtom,
-+ TargetConverter *aConverter);
-+ PRBool LookupMatchedInternalTarget(const char *aDataFlavor,
-+ GdkAtom *aAtom,
-+ TargetConverter *aConverter);
-+
-+ GtkTargetEntry *CreateGtkTargetFor(const char *aFlavorStr);
-+
- };
-
- #endif // nsDragService_h__
--
diff --git a/firefox-2.0-enable-debug.patch b/firefox-2.0-enable-debug.patch
deleted file mode 100644
index 256b674..0000000
--- a/firefox-2.0-enable-debug.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -up mozilla/browser/app/Makefile.in.old mozilla/browser/app/Makefile.in
---- mozilla/browser/app/Makefile.in.old 2006-08-29 04:03:07.000000000 +0200
-+++ mozilla/browser/app/Makefile.in 2007-09-26 15:08:35.000000000 +0200
-@@ -238,7 +238,7 @@ libs:: firefox
- $(INSTALL) $< $(DIST)/bin
-
- install:: firefox
-- $(SYSINSTALL) $< $(DESTDIR)$(bindir)
-+ $(SYSINSTALL) $< $(DESTDIR)$(mozappdir)
-
- GARBAGE += firefox
- GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/, firefox.js)
diff --git a/firefox-2.0-pango-ligatures.patch b/firefox-2.0-pango-ligatures.patch
deleted file mode 100644
index cfd1da7..0000000
--- a/firefox-2.0-pango-ligatures.patch
+++ /dev/null
@@ -1,1932 +0,0 @@
---- mozilla.back/gfx/src/gtk/nsFontMetricsPango.cpp.orig 2007-06-28 14:44:31.000000000 +0200
-+++ mozilla.back/gfx/src/gtk/nsFontMetricsPango.cpp 2007-06-28 15:48:04.000000000 +0200
-@@ -21,6 +21,8 @@
- * are Copyright (C) 2004 the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
-+ * Christopher Blizzard <blizzard@mozilla.org>
-+ * Behdad Esfahbod <behdad@behdad.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
-@@ -36,6 +38,10 @@
- *
- * ***** END LICENSE BLOCK ***** */
-
-+#define PANGO_ENABLE_BACKEND
-+
-+#include "nsFontMetricsPango.h"
-+
- #include <strings.h>
- #include "nsFont.h"
- #include "nsIDeviceContext.h"
-@@ -43,27 +49,37 @@
- #include "nsIPref.h"
- #include "nsServiceManagerUtils.h"
-
--#define PANGO_ENABLE_BACKEND
--#define PANGO_ENABLE_ENGINE
--
--#include "nsFontMetricsPango.h"
--#include "nsRenderingContextGTK.h"
--#include "nsDeviceContextGTK.h"
- #include "nsFontConfigUtils.h"
-
- #include "nsUnicharUtils.h"
- #include "nsQuickSort.h"
- #include "nsFontConfigUtils.h"
-+#include "mozilla-decoder.h"
-+
-+#define FORCE_PR_LOG
-+#include "prlog.h"
-+
-
- #include <fontconfig/fontconfig.h>
-+#include <freetype/tttables.h>
-+
-+#include <pango/pango.h>
-+#include <pango/pangofc-font.h>
-+
-+#ifdef PSPANGO
-+#include <pango/pangoft2.h>
-+#include "nsRenderingContextPS.h"
-+#include "nsDeviceContextPS.h"
-+#include "nsType1.h"
-+#else
- #include <gdk/gdk.h>
- #include <gdk/gdkx.h>
--#include <freetype/tttables.h>
-+#include "nsRenderingContextGTK.h"
-+#include "nsDeviceContextGTK.h"
-+#endif
-+
-
--#include "mozilla-decoder.h"
-
--#define FORCE_PR_LOG
--#include "prlog.h"
-
- // Globals
-
-@@ -108,6 +124,49 @@ static nsresult EnumFontsPango (nsI
- PRUint32* aCount, PRUnichar*** aResult);
- static int CompareFontNames (const void* aArg1, const void* aArg2,
- void* aClosure);
-+static void utf16_to_utf8 (const PRUnichar* aString, PRUint32 aLength,
-+ char *&text, gint &text_len);
-+
-+#ifdef PSPANGO
-+static void
-+default_substitute (FcPattern *pattern,
-+ gpointer data)
-+{
-+ FcPatternDel (pattern, FC_HINTING);
-+ FcPatternAddBool (pattern, FC_HINTING, 0);
-+}
-+#endif
-+
-+static PangoFontMap *
-+get_fontmap (void)
-+{
-+ static PangoFontMap *fontmap = NULL;
-+
-+ if (!fontmap) {
-+#ifdef PSPANGO
-+ fontmap = pango_ft2_font_map_new ();
-+ pango_ft2_font_map_set_resolution ((PangoFT2FontMap *)fontmap, 72., 72.);
-+ pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, default_substitute, NULL, NULL);
-+#else
-+ PangoContext* context = gdk_pango_context_get ();
-+ fontmap = pango_context_get_font_map (context);
-+ g_object_unref (context);
-+#endif
-+ }
-+
-+ return fontmap;
-+}
-+
-+static PangoContext *
-+get_context (void)
-+{
-+#ifdef PSPANGO
-+ return pango_ft2_font_map_create_context ((PangoFT2FontMap *) get_fontmap ());
-+#else
-+ return gdk_pango_context_get();
-+#endif
-+}
-+
-
- nsFontMetricsPango::nsFontMetricsPango()
- {
-@@ -169,14 +228,20 @@ nsFontMetricsPango::Init(const nsFont& a
- mLangGroup = aLangGroup;
-
- // Hang on to the device context
-+#ifdef PSPANGO
-+ mDeviceContext = (nsDeviceContextPS *)aContext;
-+#else
- mDeviceContext = aContext;
-+#endif
-
- mPointSize = NSTwipsToFloatPoints(mFont.size);
-
-+#ifndef PSPANGO
- // Make sure to clamp the pixel size to something reasonable so we
- // don't make the X server blow up.
- nscoord screenPixels = gdk_screen_height();
- mPointSize = PR_MIN((screenPixels - 1) * FONT_MAX_FONT_SCALE, mPointSize);
-+#endif
-
- // enumerate over the font names passed in
- mFont.EnumerateFamilies(nsFontMetricsPango::EnumFontCallback, this);
-@@ -329,7 +394,7 @@ nsFontMetricsPango::CacheFontMetrics(voi
-
- // mPangoSpaceWidth
- PangoLayout *layout = pango_layout_new(mPangoContext);
-- pango_layout_set_text(layout, " ", 1);
-+ pango_layout_set_text(layout, " ", -1);
- int pswidth, psheight;
- pango_layout_get_size(layout, &pswidth, &psheight);
- mPangoSpaceWidth = pswidth;
-@@ -337,14 +402,14 @@ nsFontMetricsPango::CacheFontMetrics(voi
-
- // mSpaceWidth (width of a space)
- nscoord tmpWidth;
-- GetWidth(" ", 1, tmpWidth, NULL);
-+ GetWidth(" ", 1, tmpWidth CONTEXT_ARG_NULL);
- mSpaceWidth = tmpWidth;
-
- // mAveCharWidth (width of an 'average' char)
- // XftTextExtents16(GDK_DISPLAY(), xftFont, &xUnichar, 1, &extents);
- //rawWidth = extents.width;
- //mAveCharWidth = NSToCoordRound(rawWidth * f);
-- GetWidth("x", 1, tmpWidth, NULL);
-+ GetWidth("x", 1, tmpWidth CONTEXT_ARG_NULL);
- mAveCharWidth = tmpWidth;
-
- // mXHeight (height of an 'x' character)
-@@ -460,130 +525,96 @@ nsFontMetricsPango::GetFontHandle(nsFont
-
- // nsIFontMetricsPango impl
-
--nsresult
--nsFontMetricsPango::GetWidth(const char* aString, PRUint32 aLength,
-- nscoord& aWidth,
-- nsRenderingContextGTK *aContext)
-+#ifdef PSPANGO
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength)
- {
-- PangoLayout *layout = pango_layout_new(mPangoContext);
--
-- pango_layout_set_text(layout, aString, aLength);
-+ return GetWidth (String, (PRUint32) aLength, aWidth CONTEXT_ARG_NULL);
-+}
-
-- if (mPangoSpaceWidth)
-- FixupSpaceWidths(layout, aString);
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength)
-+{
-+ return GetWidth (aString, (PRUint32)aLength, aWidth, NULL CONTEXT_ARG_NULL);
-+}
-+#endif
-
-+nsresult
-+nsFontMetricsPango::GetWidth(const char* aString, PRUint32 aLength,
-+ nscoord& aWidth
-+ CONTEXT_ARG_DEF)
-+{
- int width, height;
--
-+ PangoLayout *layout = GetLayout(aString, aLength);
- pango_layout_get_size(layout, &width, &height);
--
- g_object_unref(layout);
-
-- float f;
-- f = mDeviceContext->DevUnitsToAppUnits();
-+ float f = mDeviceContext->DevUnitsToAppUnits();
- aWidth = NSToCoordRound(width * f / PANGO_SCALE);
-
-- // printf("GetWidth (char *) %d\n", aWidth);
--
- return NS_OK;
- }
-
- nsresult
- nsFontMetricsPango::GetWidth(const PRUnichar* aString, PRUint32 aLength,
-- nscoord& aWidth, PRInt32 *aFontID,
-- nsRenderingContextGTK *aContext)
-+ nscoord& aWidth, PRInt32 *aFontID
-+ CONTEXT_ARG_DEF)
- {
-- nsresult rv = NS_OK;
-- PangoLayout *layout = pango_layout_new(mPangoContext);
--
-- gchar *text = g_utf16_to_utf8(aString, aLength,
-- NULL, NULL, NULL);
--
-- if (!text) {
-- aWidth = 0;
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetWidth invalid unicode to follow");
-- DUMP_PRUNICHAR(aString, aLength)
--#endif
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
--
- gint width, height;
--
-- pango_layout_set_text(layout, text, strlen(text));
-- FixupSpaceWidths(layout, text);
-+ PangoLayout *layout = GetLayout(aString, aLength);
- pango_layout_get_size(layout, &width, &height);
-+ g_object_unref(layout);
-
-- float f;
-- f = mDeviceContext->DevUnitsToAppUnits();
-+ float f = mDeviceContext->DevUnitsToAppUnits();
- aWidth = NSToCoordRound(width * f / PANGO_SCALE);
-
-- // printf("GetWidth %d\n", aWidth);
--
-- loser:
-- g_free(text);
-- g_object_unref(layout);
--
-- return rv;
-+ return NS_OK;
- }
-
-
- nsresult
--nsFontMetricsPango::GetTextDimensions(const PRUnichar* aString,
-+nsFontMetricsPango::GetTextDimensions(const char* aString,
- PRUint32 aLength,
-- nsTextDimensions& aDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext)
-+ nsTextDimensions& aDimensions
-+ CONTEXT_ARG_DEF)
- {
-- nsresult rv = NS_OK;
--
-- PangoLayout *layout = pango_layout_new(mPangoContext);
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ PangoLayoutLine *line = pango_layout_get_line(layout, 0);
-
-- gchar *text = g_utf16_to_utf8(aString, aLength,
-- NULL, NULL, NULL);
--
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetTextDimensions invalid unicode to follow");
-- DUMP_PRUNICHAR(aString, aLength)
--#endif
-- aDimensions.width = 0;
-- aDimensions.ascent = 0;
-- aDimensions.descent = 0;
--
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
--
-+ PangoRectangle logical;
-+ pango_layout_line_get_extents(line, NULL, &logical);
-+ g_object_unref(layout);
-
-- pango_layout_set_text(layout, text, strlen(text));
-- FixupSpaceWidths(layout, text);
-+ float P2T = mDeviceContext->DevUnitsToAppUnits();
-
-- // Get the logical extents
-- PangoLayoutLine *line;
-- if (pango_layout_get_line_count(layout) != 1) {
-- printf("Warning: more than one line!\n");
-- }
-- line = pango_layout_get_line(layout, 0);
-+ aDimensions.ascent = NSToCoordRound(PANGO_ASCENT(logical) * P2T / PANGO_SCALE);
-+ aDimensions.descent = NSToCoordRound(PANGO_DESCENT(logical) * P2T / PANGO_SCALE);
-+ aDimensions.width = NSToCoordRound(logical.width * P2T / PANGO_SCALE);
-
-- PangoRectangle rect;
-- pango_layout_line_get_extents(line, NULL, &rect);
-+ return NS_OK;
-+}
-
-- float P2T;
-- P2T = mDeviceContext->DevUnitsToAppUnits();
-+nsresult
-+nsFontMetricsPango::GetTextDimensions(const PRUnichar* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions,
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF)
-+{
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ PangoLayoutLine *line = pango_layout_get_line(layout, 0);
-
-- aDimensions.width = NSToCoordRound(rect.width * P2T / PANGO_SCALE);
-- aDimensions.ascent = NSToCoordRound(PANGO_ASCENT(rect) * P2T / PANGO_SCALE);
-- aDimensions.descent = NSToCoordRound(PANGO_DESCENT(rect) * P2T / PANGO_SCALE);
-+ PangoRectangle logical;
-+ pango_layout_line_get_extents(line, NULL, &logical);
-+ g_object_unref(layout);
-
-- // printf("GetTextDimensions %d %d %d\n", aDimensions.width,
-- //aDimensions.ascent, aDimensions.descent);
-+ float P2T = mDeviceContext->DevUnitsToAppUnits();
-
-- loser:
-- g_free(text);
-- g_object_unref(layout);
-+ aDimensions.ascent = NSToCoordRound(PANGO_ASCENT(logical) * P2T / PANGO_SCALE);
-+ aDimensions.descent = NSToCoordRound(PANGO_DESCENT(logical) * P2T / PANGO_SCALE);
-+ aDimensions.width = NSToCoordRound(logical.width * P2T / PANGO_SCALE);
-
-- return rv;
-+ return NS_OK;
- }
-
- nsresult
-@@ -595,13 +626,13 @@ nsFontMetricsPango::GetTextDimensions(co
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
- nsTextDimensions& aLastWordDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext)
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF)
- {
-
- return GetTextDimensionsInternal(aString, aLength, aAvailWidth, aBreaks,
- aNumBreaks, aDimensions, aNumCharsFit,
-- aLastWordDimensions, aContext);
-+ aLastWordDimensions CONTEXT_ARG_PASS);
-
- }
-
-@@ -614,8 +645,8 @@ nsFontMetricsPango::GetTextDimensions(co
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
- nsTextDimensions& aLastWordDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext)
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF)
- {
- nsresult rv = NS_OK;
- PRInt32 curBreak = 0;
-@@ -623,23 +654,15 @@ nsFontMetricsPango::GetTextDimensions(co
-
- PRInt32 *utf8Breaks = new PRInt32[aNumBreaks];
-
-- gchar *text = g_utf16_to_utf8(aString, (PRInt32)aLength,
-- NULL, NULL, NULL);
-+ gchar* text;
-+ gint text_len;
-+ utf16_to_utf8 (aString, aLength, text, text_len);
-
- curChar = text;
-
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetWidth invalid unicode to follow");
-- DUMP_PRUNICHAR(aString, (PRUint32)aLength)
--#endif
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
--
- // Covert the utf16 break offsets to utf8 break offsets
- for (PRInt32 curOffset=0; curOffset < aLength;
-- curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+ curOffset++, curChar = g_utf8_next_char(curChar)) {
- if (aBreaks[curBreak] == curOffset) {
- utf8Breaks[curBreak] = curChar - text;
- curBreak++;
-@@ -653,10 +676,10 @@ nsFontMetricsPango::GetTextDimensions(co
- utf8Breaks[curBreak] = curChar - text;
-
- #if 0
-- if (strlen(text) != aLength) {
-- printf("Different lengths for utf16 %d and utf8 %d\n", aLength, strlen(text));
-+ if (text_len != aLength) {
-+ printf("Different lengths for utf16 %d and utf8 %d\n", aLength, text_len);
- DUMP_PRUNICHAR(aString, aLength)
-- DUMP_PRUNICHAR(text, strlen(text))
-+ DUMP_PRUNICHAR(text, text_len)
- for (PRInt32 i = 0; i < aNumBreaks; ++i) {
- printf(" break %d utf16 %d utf8 %d\n", i, aBreaks[i], utf8Breaks[i]);
- }
-@@ -666,9 +689,9 @@ nsFontMetricsPango::GetTextDimensions(co
- // We'll use curBreak to indicate which of the breaks end up being
- // used for the break point for this line.
- curBreak = 0;
-- rv = GetTextDimensionsInternal(text, strlen(text), aAvailWidth, utf8Breaks,
-+ rv = GetTextDimensionsInternal(text, text_len, aAvailWidth, utf8Breaks,
- aNumBreaks, aDimensions, aNumCharsFit,
-- aLastWordDimensions, aContext);
-+ aLastWordDimensions CONTEXT_ARG_PASS);
-
- // Figure out which of the breaks we ended up using to convert
- // back to utf16 - start from the end.
-@@ -681,200 +704,365 @@ nsFontMetricsPango::GetTextDimensions(co
- }
- }
-
-- loser:
-- if (text)
-- g_free(text);
-+ g_free(text);
-
- delete[] utf8Breaks;
-
- return rv;
- }
-
--nsresult
--nsFontMetricsPango::DrawString(const char *aString, PRUint32 aLength,
-- nscoord aX, nscoord aY,
-- const nscoord* aSpacing,
-- nsRenderingContextGTK *aContext,
-- nsDrawingSurfaceGTK *aSurface)
-+#ifdef PSPANGO
-+
-+typedef struct _nsPSPangoRenderer nsPSPangoRenderer;
-+typedef struct _nsPSPangoRendererClass nsPSPangoRendererClass;
-+
-+struct _nsPSPangoRenderer
- {
-- PangoLayout *layout = pango_layout_new(mPangoContext);
-+ PangoRenderer parent_instance;
-+ nsRenderingContextPS *psContext;
-+ nsFontMetricsPSPango *psPangoFontMetrics;
-+ float zoom;
-+};
-
-- pango_layout_set_text(layout, aString, aLength);
-- FixupSpaceWidths(layout, aString);
-+struct _nsPSPangoRendererClass
-+{
-+ PangoRendererClass parent_class;
-+};
-
-- int x = aX;
-- int y = aY;
-+#define _PS_TYPE_PANGO_RENDERER (_ps_pango_renderer_get_type())
-+#define _PS_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRenderer))
-+#define _PS_IS_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), _PS_TYPE_PANGO_RENDERER))
-+#define _PS_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRendererClass))
-+#define _PS_IS_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), _PS_TYPE_PANGO_RENDERER))
-+#define _PS_PANGO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRendererClass))
-
-- aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+G_DEFINE_TYPE (_nsPSPangoRenderer, _ps_pango_renderer, PANGO_TYPE_RENDERER)
-
-- PangoLayoutLine *line;
-- if (pango_layout_get_line_count(layout) != 1) {
-- printf("Warning: more than one line!\n");
-- }
-- line = pango_layout_get_line(layout, 0);
-+static PangoRenderer *
-+get_renderer (void)
-+{
-+ static PangoRenderer *renderer = NULL;
-
-- aContext->UpdateGC();
-- GdkGC *gc = aContext->GetGC();
-+ if (!renderer)
-+ renderer = (PangoRenderer *) g_object_new (_PS_TYPE_PANGO_RENDERER, NULL);
-
-- if (aSpacing && *aSpacing) {
-- DrawStringSlowly(aString, NULL, aLength, aSurface->GetDrawable(),
-- gc, x, y, line, aSpacing);
-- }
-- else {
-- gdk_draw_layout_line(aSurface->GetDrawable(), gc,
-- x, y,
-- line);
-- }
-+ return renderer;
-+}
-
-- g_object_unref(gc);
-- g_object_unref(layout);
-+static void
-+_ps_pango_renderer_draw_glyphs (PangoRenderer *renderer,
-+ PangoFont *font,
-+ PangoGlyphString *glyphs,
-+ int x,
-+ int y);
-
-- // printf("DrawString (char *)\n");
-+static void
-+_ps_pango_renderer_class_init (nsPSPangoRendererClass *klass)
-+{
-+ PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);
-+
-+ renderer_class->draw_glyphs = _ps_pango_renderer_draw_glyphs;
-+}
-
-- return NS_OK;
-+static void
-+_ps_pango_renderer_init (nsPSPangoRenderer *renderer)
-+{
-+}
-+
-+class nsPangoType1Generator : public nsPSFontGenerator {
-+public:
-+ nsPangoType1Generator();
-+ ~nsPangoType1Generator();
-+ nsresult Init(PangoFont *aFont);
-+ void GeneratePSFont(FILE* aFile);
-+
-+protected:
-+ PangoFont *mFont;
-+};
-+
-+nsPangoType1Generator::nsPangoType1Generator()
-+{
- }
-
- nsresult
--nsFontMetricsPango::DrawString(const PRUnichar* aString, PRUint32 aLength,
-- nscoord aX, nscoord aY,
-- PRInt32 aFontID,
-- const nscoord* aSpacing,
-- nsRenderingContextGTK *aContext,
-- nsDrawingSurfaceGTK *aSurface)
-+nsPangoType1Generator::Init(PangoFont *aFont)
-+ {
-+ NS_ENSURE_TRUE(aFont, NS_ERROR_FAILURE);
-+ mFont = aFont;
-+ g_object_ref (mFont);
-+ return NS_OK;
-+}
-+
-+nsPangoType1Generator::~nsPangoType1Generator()
- {
-- nsresult rv = NS_OK;
-- int x = aX;
-- int y = aY;
-+ g_object_unref (mFont);
-+ mFont = nsnull;
-+}
-
-- aContext->UpdateGC();
-- GdkGC *gc = aContext->GetGC();
-+void nsPangoType1Generator::GeneratePSFont(FILE* aFile)
-+{
-+ FT_Face face = pango_fc_font_lock_face ((PangoFcFont *) mFont);
-
-- PangoLayout *layout = pango_layout_new(mPangoContext);
-+ if (face == nsnull)
-+ return;
-
-- gchar *text = g_utf16_to_utf8(aString, aLength,
-- NULL, NULL, NULL);
-+ int wmode = 0;
-+ if (mGlyphSubset->Count())
-+ FT2SubsetToType1FontSet(face, mGlyphSubset, wmode, aFile);
-
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::DrawString invalid unicode to follow");
-- DUMP_PRUNICHAR(aString, aLength)
--#endif
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
-+ pango_fc_font_unlock_face ((PangoFcFont *) mFont);
-+}
-
-- pango_layout_set_text(layout, text, strlen(text));
-- FixupSpaceWidths(layout, text);
-+typedef struct
-+{
-+ nsCString *FontNameBase;
-+ nsCStringKey *key;
-+ int font_size;
-+} PSPangoFontData;
-
-- aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+static void
-+ps_pango_font_data_destroy (PSPangoFontData *data)
-+{
-+ delete data->key;
-+ delete data->FontNameBase;
-+ g_free (data);
-+}
-
-- PangoLayoutLine *line;
-- if (pango_layout_get_line_count(layout) != 1) {
-- printf("Warning: more than one line!\n");
-- }
-- line = pango_layout_get_line(layout, 0);
-+static void
-+_ps_pango_renderer_draw_glyphs (PangoRenderer *renderer,
-+ PangoFont *font,
-+ PangoGlyphString *glyphs,
-+ int x,
-+ int y)
-+{
-+ if (!glyphs->num_glyphs)
-+ return;
-
-- if (aSpacing && *aSpacing) {
-- DrawStringSlowly(text, aString, aLength, aSurface->GetDrawable(),
-- gc, x, y, line, aSpacing);
-- }
-- else {
-- gdk_draw_layout_line(aSurface->GetDrawable(), gc,
-- x, y,
-- line);
-- }
-+ static GQuark data_quark = 0;
-+ if (!data_quark)
-+ data_quark = g_quark_from_static_string ("ps-pango-font-data");
-
-- loser:
-+ PSPangoFontData *data;
-+ if (!(data = (PSPangoFontData *) g_object_get_qdata (G_OBJECT (font), data_quark)))
-+ {
-+ data = g_new (PSPangoFontData, 1);
-
-- g_free(text);
-- g_object_unref(gc);
-- g_object_unref(layout);
-+ FT_Face face = pango_fc_font_lock_face ((PangoFcFont *) font);
-+ if (face == nsnull)
-+ return;
-+ int wmode = 0;
-+ data->FontNameBase = new nsCString ();
-+ if (NS_FAILED(FT2ToType1FontName(face, wmode, *data->FontNameBase))) {
-+ g_free (data);
-+ pango_fc_font_unlock_face ((PangoFcFont *) font);
-+ return;
-+ }
-+ pango_fc_font_unlock_face ((PangoFcFont *) font);
-
-- // printf("DrawString\n");
-+ PangoFontDescription *desc = pango_font_describe (font);
-+ data->font_size = pango_font_description_get_size (desc);
-+ pango_font_description_free (desc);
-+
-+ data->key = new nsCStringKey (*data->FontNameBase);
-+
-+ g_object_set_qdata_full (G_OBJECT (font), data_quark, data, (GDestroyNotify) ps_pango_font_data_destroy);
-+ }
-+
-+ nsPSPangoRenderer *ps_renderer = (nsPSPangoRenderer *)renderer;
-+ nsRenderingContextPS *aContext = ps_renderer->psContext;
-+ nsFontMetricsPSPango *metrics = ps_renderer->psPangoFontMetrics;
-+ nsDeviceContextPS* dc = NS_REINTERPRET_CAST (nsDeviceContextPS*, metrics->GetDeviceContext());
-+ nsPostScriptObj* psObj = aContext->GetPostScriptObj();
-+ nsHashtable *psFGList = dc->GetPSFontGeneratorList();
-+ g_return_if_fail (psFGList);
-+ nsPSFontGenerator* psFontGen = (nsPSFontGenerator*) psFGList->Get(data->key);
-+ if (!psFontGen) {
-+ nsresult rv;
-+ psFontGen = new nsPangoType1Generator;
-+ g_return_if_fail (psFontGen);
-+ rv = ((nsPangoType1Generator*)psFontGen)->Init(font);
-+ if (NS_FAILED(rv)) {
-+ delete psFontGen;
-+ return;
-+ }
-+ psFGList->Put(data->key, (void *) psFontGen);
-+ }
-+ nscoord font_size = NSToCoordRound (ps_renderer->zoom * data->font_size / PANGO_SCALE);
-+
-+ g_return_if_fail (aContext);
-+ g_return_if_fail (psObj);
-+
-+ nscoord aX = NSToCoordRound(ps_renderer->zoom * x / PANGO_SCALE);
-+ nscoord aY = NSToCoordRound(ps_renderer->zoom * y / PANGO_SCALE);
-+ psObj->moveto(aX, aY);
-+
-+ PRInt32 currSubFont, prevSubFont = -1;
-+ PRUint32 i;
-+ PangoGlyphString gl;
-+
-+ gl.glyphs = glyphs->glyphs;
-+ gl.num_glyphs = 0;
-+ currSubFont = prevSubFont;
-+ for (i = 0; i < glyphs->num_glyphs; ++i) {
-+ PangoGlyph glyph = glyphs->glyphs[i].glyph;
-+
-+ if (glyph != PANGO_GLYPH_EMPTY)
-+ currSubFont = psFontGen->AddToGlyphSubset(glyph > 0x0fffffff ? 0 : glyph);
-+
-+ if (prevSubFont != currSubFont) {
-+ if (prevSubFont != -1)
-+ psObj->show(&gl, ps_renderer->zoom, psFontGen, prevSubFont);
-+
-+ psObj->setfont(*data->FontNameBase, (PRUint32) font_size, currSubFont);
-+ prevSubFont = currSubFont;
-+ gl.glyphs = glyphs->glyphs + i;
-+ gl.num_glyphs = 0;
-+ }
-
-- return rv;
-+ gl.num_glyphs++;
-+ }
-+
-+ if (prevSubFont != -1)
-+ psObj->show(&gl, ps_renderer->zoom, psFontGen, prevSubFont);
- }
-+#endif
-+
-+static void
-+draw_layout_line (int x, int y,
-+ PangoLayoutLine *line,
-+ nsFontMetricsPango *fm
-+ CONTEXT_AND_SURFACE_ARG_DEF)
-+{
-+#ifdef PSPANGO
-+ PangoRenderer *renderer = get_renderer ();
-+ nsPSPangoRenderer *ps_renderer = (nsPSPangoRenderer *)renderer;
-+ ps_renderer->psContext = aContext;
-+ ps_renderer->psPangoFontMetrics = fm;
-+ nsDeviceContextPS* dc = NS_REINTERPRET_CAST (nsDeviceContextPS*, fm->GetDeviceContext());
-+ ps_renderer->zoom = dc->DevUnitsToAppUnits();
-+
-+ pango_renderer_draw_layout_line (renderer, line,
-+ NSToCoordRound (x * PANGO_SCALE / ps_renderer->zoom),
-+ NSToCoordRound (y * PANGO_SCALE / ps_renderer->zoom));
-+#else
-+ aContext->UpdateGC();
-+ GdkGC *gc = aContext->GetGC();
-+ gdk_draw_layout_line(aSurface->GetDrawable(), gc, x, y, line);
-+ g_object_unref(gc);
-+#endif
-+}
-+
-
--#ifdef MOZ_MATHML
- nsresult
--nsFontMetricsPango::GetBoundingMetrics(const char *aString, PRUint32 aLength,
-- nsBoundingMetrics &aBoundingMetrics,
-- nsRenderingContextGTK *aContext)
-+nsFontMetricsPango::DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ const nscoord* aSpacing
-+ CONTEXT_AND_SURFACE_ARG_DEF)
- {
-- printf("GetBoundingMetrics (char *)\n");
-- return NS_ERROR_FAILURE;
-+ int x = aX;
-+ int y = aY;
-+
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ PangoLayoutLine *line = pango_layout_get_line(layout, 0);
-+
-+ ApplySpacing(aString, aLength, line, aSpacing);
-+ draw_layout_line(x, y, line, this CONTEXT_AND_SURFACE_ARG_PASS);
-+
-+ g_object_unref(layout);
-+
-+ return NS_OK;
- }
-
- nsresult
--nsFontMetricsPango::GetBoundingMetrics(const PRUnichar *aString,
-- PRUint32 aLength,
-- nsBoundingMetrics &aBoundingMetrics,
-- PRInt32 *aFontID,
-- nsRenderingContextGTK *aContext)
-+nsFontMetricsPango::DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ PRInt32 aFontID,
-+ const nscoord* aSpacing
-+ CONTEXT_AND_SURFACE_ARG_DEF)
- {
-- nsresult rv = NS_OK;
-- PangoLayout *layout = pango_layout_new(mPangoContext);
-+ int x = aX;
-+ int y = aY;
-
-- gchar *text = g_utf16_to_utf8(aString, aLength,
-- NULL, NULL, NULL);
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetBoundingMetrics invalid unicode to follow");
-- DUMP_PRUNICHAR(aString, aLength)
--#endif
-- aBoundingMetrics.Clear();
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ PangoLayoutLine *line = pango_layout_get_line(layout, 0);
-
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
-+ ApplySpacing(aString, aLength, line, aSpacing);
-+ draw_layout_line(x, y, line, this CONTEXT_AND_SURFACE_ARG_PASS);
-
-- pango_layout_set_text(layout, text, -1);
-- FixupSpaceWidths(layout, text);
-+ g_object_unref(layout);
-+
-+ return NS_OK;
-+}
-
-- PangoLayoutLine *line;
-- if (pango_layout_get_line_count(layout) != 1) {
-- printf("Warning: more than one line!\n");
-- }
-- line = pango_layout_get_line(layout, 0);
-+
-+#ifdef MOZ_MATHML
-+void
-+nsFontMetricsPango::GetBoundingMetricsInternal(PangoLayout *aLayout,
-+ nsBoundingMetrics &aBoundingMetrics
-+ CONTEXT_ARG_DEF)
-+{
-+ PangoLayoutLine *line = pango_layout_get_line(aLayout, 0);
-
- // Get the ink and logical extents
- PangoRectangle ink, logical;
- pango_layout_line_get_extents(line, &ink, &logical);
-
-- float P2T;
-- P2T = mDeviceContext->DevUnitsToAppUnits();
-+ float P2T = mDeviceContext->DevUnitsToAppUnits();
-
- aBoundingMetrics.leftBearing = NSToCoordRound(PANGO_LBEARING(ink) * P2T / PANGO_SCALE);
- aBoundingMetrics.rightBearing = NSToCoordRound(PANGO_RBEARING(ink) * P2T / PANGO_SCALE);
- aBoundingMetrics.ascent = NSToCoordRound(PANGO_ASCENT(ink) * P2T / PANGO_SCALE);
- aBoundingMetrics.descent = NSToCoordRound(PANGO_DESCENT(ink) * P2T / PANGO_SCALE);
- aBoundingMetrics.width = NSToCoordRound(logical.width * P2T / PANGO_SCALE);
-+}
-
-- loser:
-- g_free(text);
-+nsresult
-+nsFontMetricsPango::GetBoundingMetrics(const char *aString, PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics
-+ CONTEXT_ARG_DEF)
-+{
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ GetBoundingMetricsInternal (layout, aBoundingMetrics CONTEXT_ARG_PASS);
- g_object_unref(layout);
-
-- return rv;
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPango::GetBoundingMetrics(const PRUnichar *aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics,
-+ PRInt32 *aFontID
-+ CONTEXT_ARG_DEF)
-+{
-+ PangoLayout *layout = GetLayout(aString, aLength);
-+ GetBoundingMetricsInternal (layout, aBoundingMetrics CONTEXT_ARG_PASS);
-+ g_object_unref(layout);
-+
-+ return NS_OK;
- }
-
- #endif /* MOZ_MATHML */
-
-+#ifndef PSPANGO
- GdkFont*
- nsFontMetricsPango::GetCurrentGDKFont(void)
- {
- return nsnull;
- }
-+#endif
-
- nsresult
- nsFontMetricsPango::SetRightToLeftText(PRBool aIsRTL)
- {
- if (aIsRTL) {
- if (!mRTLPangoContext) {
-- mRTLPangoContext = gdk_pango_context_get();
-+ mRTLPangoContext = get_context();
- pango_context_set_base_dir(mRTLPangoContext, PANGO_DIRECTION_RTL);
--
-- gdk_pango_context_set_colormap(mRTLPangoContext, gdk_rgb_get_cmap());
- pango_context_set_language(mRTLPangoContext, GetPangoLanguage(mLangGroup));
- pango_context_set_font_description(mRTLPangoContext, mPangoFontDesc);
- }
-@@ -899,34 +1087,18 @@ nsFontMetricsPango::GetClusterInfo(const
- PRUint32 aLength,
- PRUint8 *aClusterStarts)
- {
-- nsresult rv = NS_OK;
- PangoLogAttr *attrs = NULL;
- gint n_attrs = 0;
-- PangoLayout *layout = pango_layout_new(mPangoContext);
--
-- // Convert the incoming UTF-16 to UTF-8
-- gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
-
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetWidth invalid unicode to follow");
-- DUMP_PRUNICHAR(aText, aLength)
--#endif
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
--
-- // Set up the pango layout
-- pango_layout_set_text(layout, text, strlen(text));
-- FixupSpaceWidths(layout, text);
-+ PangoLayout *layout = GetLayout(aText, aLength);
-+ pango_layout_get_log_attrs(layout, &attrs, &n_attrs);
-+ g_object_unref(layout);
-
- // Convert back to UTF-16 while filling in the cluster info
- // structure.
-- pango_layout_get_log_attrs(layout, &attrs, &n_attrs);
--
- for (PRUint32 pos = 0; pos < aLength; pos++) {
- if (IS_HIGH_SURROGATE(aText[pos])) {
-- aClusterStarts[pos] = 1;
-+ aClusterStarts[pos] = 1;//FIXME: shouldn't this be zero?! --be
- pos++;
- }
- else {
-@@ -934,56 +1106,34 @@ nsFontMetricsPango::GetClusterInfo(const
- }
- }
-
-- loser:
-- if (attrs)
-- g_free(attrs);
-- if (text)
-- g_free(text);
-- if (layout)
-- g_object_unref(layout);
-+ g_free(attrs);
-
-- return rv;
-+ return NS_OK;
- }
-
- PRInt32
--nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
-- nsPoint aPt)
-+nsFontMetricsPango::GetPosition(const PRUnichar *aText, PRUint32 aLength, nsPoint aPt)
- {
- int trailing = 0;
- int inx = 0;
-- const gchar *curChar;
- PRInt32 retval = 0;
-
- float f = mDeviceContext->AppUnitsToDevUnits();
-
-- PangoLayout *layout = pango_layout_new(mPangoContext);
- PRUint32 localX = (PRUint32)(aPt.x * PANGO_SCALE * f);
- PRUint32 localY = (PRUint32)(aPt.y * PANGO_SCALE * f);
-
-- // Convert the incoming UTF-16 to UTF-8
-- gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
--
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetWidth invalid unicode to follow");
-- DUMP_PRUNICHAR(aText, aLength)
--#endif
-- retval = -1;
-- goto loser;
-- }
--
-- // Set up the pango layout
-- pango_layout_set_text(layout, text, strlen(text));
-- FixupSpaceWidths(layout, text);
-+ PangoLayout *layout = GetLayout(aText, aLength);
-
- pango_layout_xy_to_index(layout, localX, localY,
- &inx, &trailing);
-
- // Convert the index back to the utf-16 index
-- curChar = text;
-+ const gchar *text = pango_layout_get_text (layout);
-+ const gchar *curChar = text;
-
- for (PRUint32 curOffset=0; curOffset < aLength;
-- curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+ curOffset++, curChar = g_utf8_next_char(curChar)) {
-
- // Check for a match before checking for a surrogate pair
- if (curChar - text == inx) {
-@@ -1006,13 +1156,9 @@ nsFontMetricsPango::GetPosition(const PR
- trailing--;
- }
-
-- loser:
-- if (text)
-- g_free(text);
-- if (layout)
-- g_object_unref(layout);
-+ g_object_unref(layout);
-
-- return retval;
-+ return retval;
- }
-
- nsresult
-@@ -1022,28 +1168,21 @@ nsFontMetricsPango::GetRangeWidth(const
- PRUint32 aEnd,
- PRUint32 &aWidth)
- {
-- nsresult rv = NS_OK;
- PRUint32 utf8Start = 0;
- PRUint32 utf8End = 0;
-
- aWidth = 0;
-
- // Convert the incoming UTF-16 to UTF-8
-- gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
-- gchar *curChar = text;
-
-- if (!text) {
--#ifdef DEBUG
-- NS_WARNING("nsFontMetricsPango::GetWidth invalid unicode to follow");
-- DUMP_PRUNICHAR(aText, aLength)
--#endif
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
-+ gchar* text;
-+ gint text_len;
-+ utf16_to_utf8 (aText, aLength, text, text_len);
-+ gchar *curChar = text;
-
- // Convert the utf16 offsets into utf8 offsets
- for (PRUint32 curOffset = 0; curOffset < aLength;
-- curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+ curOffset++, curChar = g_utf8_next_char(curChar)) {
-
- if (curOffset == aStart)
- utf8Start = curChar - text;
-@@ -1057,15 +1196,13 @@ nsFontMetricsPango::GetRangeWidth(const
-
- // Special case where the end index is the same as the length
- if (aLength == aEnd)
-- utf8End = strlen(text);
-+ utf8End = text_len;
-
-- rv = GetRangeWidth(text, strlen(text), utf8Start, utf8End, aWidth);
-+ GetRangeWidth(text, text_len, utf8Start, utf8End, aWidth);
-
-- loser:
-- if (text)
-- g_free(text);
-+ g_free(text);
-
-- return rv;
-+ return NS_OK;
- }
-
- nsresult
-@@ -1075,43 +1212,26 @@ nsFontMetricsPango::GetRangeWidth(const
- PRUint32 aEnd,
- PRUint32 &aWidth)
- {
-- nsresult rv = NS_OK;
- int *ranges = NULL;
- int n_ranges = 0;
- float f;
-
- aWidth = 0;
-
-- PangoLayout *layout = pango_layout_new(mPangoContext);
--
-- if (!aText) {
-- rv = NS_ERROR_FAILURE;
-- goto loser;
-- }
--
-- pango_layout_set_text(layout, aText, aLength);
-- FixupSpaceWidths(layout, aText);
--
-- PangoLayoutLine *line;
-- if (pango_layout_get_line_count(layout) != 1) {
-- printf("Warning: more than one line!\n");
-- }
-- line = pango_layout_get_line(layout, 0);
-+ PangoLayout *layout = GetLayout(aText, aLength);
-+ PangoLayoutLine *line = pango_layout_get_line(layout, 0);
-
- pango_layout_line_get_x_ranges(line, aStart, aEnd, &ranges, &n_ranges);
-
- aWidth = (ranges[((n_ranges - 1) * 2) + 1] - ranges[0]);
-
- f = mDeviceContext-> DevUnitsToAppUnits();
-- aWidth = nscoord(aWidth * f / PANGO_SCALE);
-+ aWidth = NSToCoordRound(aWidth * f / PANGO_SCALE);
-
-- loser:
-- if (ranges)
-- g_free(ranges);
-- if (layout)
-- g_object_unref(layout);
-+ g_free(ranges);
-+ g_object_unref(layout);
-
-- return rv;
-+ return NS_OK;
- }
-
- /* static */
-@@ -1134,7 +1254,7 @@ nsFontMetricsPango::FamilyExists(nsIDevi
- NS_ConvertUTF16toUTF8 name(aName);
-
- nsresult rv = NS_ERROR_FAILURE;
-- PangoContext *context = gdk_pango_context_get();
-+ PangoContext *context = get_context();
- PangoFontFamily **familyList;
- int n;
-
-@@ -1233,16 +1353,13 @@ nsFontMetricsPango::RealizeFont(void)
-
- // Now that we have the font description set up, create the
- // context.
-- mLTRPangoContext = gdk_pango_context_get();
-+ mLTRPangoContext = get_context();
- mPangoContext = mLTRPangoContext;
-
- // Make sure to set the base direction to LTR - if layout needs to
- // render RTL text it will use ::SetRightToLeftText()
- pango_context_set_base_dir(mPangoContext, PANGO_DIRECTION_LTR);
-
-- // Set the color map so we can draw later.
-- gdk_pango_context_set_colormap(mPangoContext, gdk_rgb_get_cmap());
--
- // Set the pango language now that we have a context
- pango_context_set_language(mPangoContext, GetPangoLanguage(mLangGroup));
-
-@@ -1280,79 +1397,268 @@ nsFontMetricsPango::EnumFontCallback(con
- * This is only used when there's per-character spacing happening.
- * Well, really it can be either line or character spacing but it's
- * just turtles all the way down!
-+ *
-+ * To do it correctly (ligatures, etc) we need machinery that is private
-+ * in Pango. IMPORT IT:
-+ */
-+
-+#define _PangoGlyphItemIter _nsFontMetricsPangoGlyphItemIter
-+#define PangoGlyphItemIter nsFontMetricsPangoGlyphItemIter
-+
-+#define LTR(glyph_item) (((glyph_item)->item->analysis.level % 2) == 0)
-+
-+/* Structure holding state when we're iterating over a GlyphItem.
-+ * start_index/cluster_end (and range_start/range_end in
-+ * apply_attrs()) are offsets into the text, so note the difference
-+ * of glyph_item->item->offset between them and clusters in the
-+ * log_clusters[] array.
- */
-+typedef struct _PangoGlyphItemIter PangoGlyphItemIter;
-+
-+struct _PangoGlyphItemIter
-+{
-+ PangoGlyphItem *glyph_item;
-+ const gchar *text;
-+
-+ int start_glyph;
-+ int start_index;
-+ int start_char;
-+
-+ int end_glyph;
-+ int end_index;
-+ int end_char;
-+};
-+
-+/**
-+ * _pango_glyph_item_iter_next_cluster:
-+ * @iter: a #PangoGlyphItemIter
-+ *
-+ * Advances the iterator to the next cluster in the glyph item.
-+ *
-+ * Return value: %TRUE if the iterator was advanced, %FALSE if we were already on the
-+ * last cluster.
-+ **/
-+static gboolean
-+_pango_glyph_item_iter_next_cluster (PangoGlyphItemIter *iter)
-+{
-+ int glyph_index = iter->end_glyph;
-+ PangoGlyphString *glyphs = iter->glyph_item->glyphs;
-+ PangoItem *item = iter->glyph_item->item;
-+
-+ if (LTR (iter->glyph_item))
-+ {
-+ if (glyph_index == glyphs->num_glyphs)
-+ return FALSE;
-+ }
-+ else
-+ {
-+ if (glyph_index < 0)
-+ return FALSE;
-+ }
-+
-+ iter->start_glyph = iter->end_glyph;
-+ iter->start_index = iter->end_index;
-+ iter->start_char = iter->end_char;
-+
-+ if (LTR (iter->glyph_item))
-+ {
-+ while (TRUE)
-+ {
-+ glyph_index++;
-+
-+ if (glyph_index == glyphs->num_glyphs)
-+ {
-+ iter->end_index = item->offset + item->length;
-+ iter->end_char = item->num_chars;
-+ break;
-+ }
-+
-+ if (item->offset + glyphs->log_clusters[glyph_index] != iter->start_index)
-+ {
-+ iter->end_index = item->offset + glyphs->log_clusters[glyph_index];
-+ iter->end_char += g_utf8_strlen (iter->text + iter->start_index,
-+ iter->end_index - iter->start_index);
-+ break;
-+ }
-+ }
-+ }
-+ else /* RTL */
-+ {
-+ while (TRUE)
-+ {
-+ glyph_index--;
-+
-+ if (glyph_index < 0)
-+ {
-+ iter->end_index = item->offset + item->length;
-+ iter->end_char = item->num_chars;
-+ break;
-+ }
-+
-+ if (item->offset + glyphs->log_clusters[glyph_index] != iter->start_index)
-+ {
-+ iter->end_index = item->offset + glyphs->log_clusters[glyph_index];
-+ iter->end_char += g_utf8_strlen (iter->text + iter->start_index,
-+ iter->end_index - iter->start_index);
-+ break;
-+ }
-+ }
-+ }
-+
-+ iter->end_glyph = glyph_index;
-+ return TRUE;
-+}
-+
-+/**
-+ * _pango_glyph_item_iter_init_start:
-+ * @iter: pointer to a #PangoGlyphItemIter structure
-+ * @glyph_item: the glyph item that the iter points into
-+ * @text: text corresponding to the glyph item
-+ *
-+ * Initializes a #PangoGlyphItemIter structure to point to the
-+ * first cluster in a glyph item.
-+ *
-+ * Return value: %FALSE if there are no clusters in the glyph item;
-+ * in this case, the state of the iter is undefined.
-+ **/
-+static gboolean
-+_pango_glyph_item_iter_init_start (PangoGlyphItemIter *iter,
-+ PangoGlyphItem *glyph_item,
-+ const char *text)
-+{
-+ iter->glyph_item = glyph_item;
-+ iter->text = text;
-+
-+ if (LTR (glyph_item))
-+ iter->end_glyph = 0;
-+ else
-+ iter->end_glyph = glyph_item->glyphs->num_glyphs - 1;
-+
-+ iter->end_index = glyph_item->item->offset;
-+ iter->end_char = 0;
-+
-+ /* Advance onto the first cluster of the glyph item */
-+ return _pango_glyph_item_iter_next_cluster (iter);
-+}
-+
-
- void
--nsFontMetricsPango::DrawStringSlowly(const gchar *aText,
-- const PRUnichar *aOrigString,
-- PRUint32 aLength,
-- GdkDrawable *aDrawable,
-- GdkGC *aGC, gint aX, gint aY,
-- PangoLayoutLine *aLine,
-- const nscoord *aSpacing)
--{
-- float app2dev;
-- app2dev = mDeviceContext->AppUnitsToDevUnits();
-- gint offset = 0;
-+nsFontMetricsPango::ApplySpacing(const gchar *aText,
-+ PRUint32 aLength,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing)
-+{
-+ if (!(aSpacing && *aSpacing))
-+ return;
-+
-+ float app2dev = mDeviceContext->AppUnitsToDevUnits();
-
- /*
- * We walk the list of glyphs returned in each layout run,
- * matching up the glyphs with the characters in the source text.
- * We use the aSpacing argument to figure out where to place those
-- * glyphs. It's important to note that since the string we're
-- * working with is in UTF-8 while the spacing argument assumes
-- * that offset will be part of the UTF-16 string. Logical
-- * attributes in pango are in byte offsets in the UTF-8 string, so
-- * we need to store the offsets based on the UTF-8 string.
-+ * glyphs.
- */
-- nscoord *utf8spacing = new nscoord[strlen(aText)];
-+ for (GSList *tmpList = aLine->runs; tmpList && tmpList->data;
-+ tmpList = tmpList->next) {
-+ PangoGlyphItem *glyph_item = (PangoGlyphItem *)tmpList->data;
-+ PangoGlyphItemIter iter;
-+ gboolean have_cluster;
-+ PangoGlyphInfo *glyphs = glyph_item->glyphs->glyphs;
-+ int residualWidth = 0;
-+
-+ for (have_cluster = _pango_glyph_item_iter_init_start (&iter, glyph_item, aText);
-+ have_cluster;
-+ have_cluster = _pango_glyph_item_iter_next_cluster (&iter))
-+ {
-+ int clusterOldWidth = 0;
-+ int clusterNewWidth = 0;
-+ int dir = iter.start_glyph < iter.end_glyph ? +1 : -1;
-+ gboolean has_zero_width = FALSE;
-+
-+ for (const char *p = iter.text + iter.start_index;
-+ p < iter.text + iter.end_index;
-+ p = g_utf8_next_char (p))
-+ clusterNewWidth += aSpacing[p - iter.text];
-+
-+ clusterNewWidth = (gint)(clusterNewWidth * app2dev * PANGO_SCALE);
-+
-+ for (gint i = iter.start_glyph; i != iter.end_glyph; i += dir) {
-+ if (!glyphs[i].geometry.width)
-+ has_zero_width = TRUE;
-+ clusterOldWidth += glyphs[i].geometry.width;
-+ }
-+
-+ /* if a zero-width glyph exists, don't touch the glyph widths.
-+ * required for combining marks. ff thinks they have a width.
-+ * instead, we charge the difference to the next space glyph. */
-+ if (has_zero_width) {
-+ residualWidth += clusterNewWidth - clusterOldWidth;
-+ continue;
-+ }
-
-- if (aOrigString) {
-- const gchar *curChar = aText;
-- bzero(utf8spacing, sizeof(nscoord) * strlen(aText));
--
-- // Covert the utf16 spacing offsets to utf8 spacing offsets
-- for (PRUint32 curOffset=0; curOffset < aLength;
-- curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-- utf8spacing[curChar - aText] = aSpacing[curOffset];
-+ /* If a space glyph is found, charge it whatever residual we
-+ * have accumulated so far. */
-+ if (iter.end_index - iter.start_index == 1 &&
-+ *(iter.text + iter.start_index) == ' ') {
-+ clusterNewWidth += residualWidth;
-+ residualWidth = 0;
-+ }
-+
-+#ifndef PSPANGO
-+ /* do some hinting for display */
-+
-+ if (clusterOldWidth % PANGO_SCALE == 0 && clusterNewWidth % PANGO_SCALE != 0) {
-+ int tmp = clusterNewWidth;
-+ clusterNewWidth = PANGO_PIXELS (clusterNewWidth) * PANGO_SCALE;
-+ residualWidth += tmp - clusterNewWidth;
-+ }
-+#endif
-
-- if (IS_HIGH_SURROGATE(aOrigString[curOffset]))
-- curOffset++;
-+ /* find the first non-zero-width glyph and adjust its width */
-+ for (gint i = iter.start_glyph; i != iter.end_glyph; i += dir)
-+ if (glyphs[i].geometry.width) {
-+ glyphs[i].geometry.width += clusterNewWidth - clusterOldWidth;
-+ break;
-+ }
- }
- }
-- else {
-- memcpy(utf8spacing, aSpacing, (sizeof(nscoord *) * aLength));
-- }
-+}
-
-- gint curRun = 0;
-+void
-+nsFontMetricsPango::ApplySpacing(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing)
-+{
-+ if (!(aSpacing && *aSpacing))
-+ return;
-
-- for (GSList *tmpList = aLine->runs; tmpList && tmpList->data;
-- tmpList = tmpList->next, curRun++) {
-- PangoLayoutRun *layoutRun = (PangoLayoutRun *)tmpList->data;
-- gint tmpOffset = 0;
-+ const char *utf8Text = pango_layout_get_text (aLine->layout);
-+ int utf8Text_len = aLine->start_index + aLine->length;
-
-- /* printf(" Rendering run %d: \"%s\"\n", curRun,
-- &aText[layoutRun->item->offset]); */
-+ /* Since the string we're
-+ * working with is in UTF-8 while the spacing argument assumes
-+ * that offset will be part of the UTF-16 string. Logical
-+ * attributes in pango are in byte offsets in the UTF-8 string, so
-+ * we need to store the offsets based on the UTF-8 string.
-+ */
-+ nscoord *utf8spacing = g_new0 (nscoord, utf8Text_len);
-
-- for (gint i=0; i < layoutRun->glyphs->num_glyphs; i++) {
-- /* printf("glyph %d offset %d orig width %d new width %d\n", i,
-- * layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset,
-- * layoutRun->glyphs->glyphs[i].geometry.width,
-- * (gint)(utf8spacing[layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset] * app2dev * PANGO_SCALE));
-- */
-- gint thisOffset = (gint)(utf8spacing[layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset]
-- * app2dev * PANGO_SCALE);
-- layoutRun->glyphs->glyphs[i].geometry.width = thisOffset;
-- tmpOffset += thisOffset;
-- }
-+ const gchar *curChar = utf8Text + aLine->start_index;
-
-- /* printf(" rendering at X coord %d\n", aX + offset); */
-- offset += tmpOffset;
-+ // Covert the utf16 spacing offsets to utf8 spacing offsets
-+ for (PRUint32 curOffset=0; curOffset < aLength;
-+ curOffset++, curChar = g_utf8_next_char(curChar)) {
-+ utf8spacing[curChar - utf8Text] = aSpacing[curOffset];
-+
-+ if (IS_HIGH_SURROGATE(aText[curOffset]))
-+ curOffset++;
- }
-
-- gdk_draw_layout_line(aDrawable, aGC, aX, aY, aLine);
-+ ApplySpacing (utf8Text, utf8Text_len, aLine, utf8spacing);
-
-- delete[] utf8spacing;
-+ g_free (utf8spacing);
- }
-
- nsresult
-@@ -1363,8 +1669,8 @@ nsFontMetricsPango::GetTextDimensionsInt
- PRInt32 aNumBreaks,
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
-- nsTextDimensions& aLastWordDimensions,
-- nsRenderingContextGTK *aContext)
-+ nsTextDimensions& aLastWordDimensions
-+ CONTEXT_ARG_DEF)
- {
- NS_PRECONDITION(aBreaks[aNumBreaks - 1] == aLength, "invalid break array");
-
-@@ -1410,7 +1716,7 @@ nsFontMetricsPango::GetTextDimensionsInt
- // All the characters should fit
- numChars = aLength - start;
- breakIndex = aNumBreaks - 1;
-- }
-+ }
- else {
- breakIndex = prevBreakState_BreakIndex;
- while (((breakIndex + 1) < aNumBreaks) &&
-@@ -1431,7 +1737,7 @@ nsFontMetricsPango::GetTextDimensionsInt
- if ((1 == numChars) && (aString[start] == ' '))
- GetSpaceWidth(twWidth);
- else if (numChars > 0)
-- GetWidth(&aString[start], numChars, twWidth, aContext);
-+ GetWidth(&aString[start], numChars, twWidth CONTEXT_ARG_PASS);
-
- // See if the text fits
- PRBool textFits = (twWidth + width) <= aAvailWidth;
-@@ -1481,8 +1787,7 @@ nsFontMetricsPango::GetTextDimensionsInt
- if ((1 == numChars) && (aString[start] == ' '))
- GetSpaceWidth(twWidth);
- else if (numChars > 0)
-- GetWidth(&aString[start], numChars, twWidth,
-- aContext);
-+ GetWidth(&aString[start], numChars, twWidth CONTEXT_ARG_PASS);
- width -= twWidth;
- aNumCharsFit = start;
- breakIndex--;
-@@ -1504,9 +1809,16 @@ nsFontMetricsPango::GetTextDimensionsInt
- }
-
- void
--nsFontMetricsPango::FixupSpaceWidths (PangoLayout *aLayout,
-- const char *aString)
-+nsFontMetricsPango::FixupSpaceWidths (PangoLayout *aLayout)
- {
-+ if (!mPangoSpaceWidth)
-+ return;
-+
-+ const char *aString = pango_layout_get_text (aLayout);
-+
-+ if (pango_layout_get_line_count(aLayout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
- PangoLayoutLine *line = pango_layout_get_line(aLayout, 0);
-
- gint curRun = 0;
-@@ -1523,6 +1835,107 @@ nsFontMetricsPango::FixupSpaceWidths (Pa
- }
- }
-
-+PangoLayout*
-+nsFontMetricsPango::GetLayout (const PRUnichar* aText,
-+ PRUint32 aLength)
-+{
-+ gchar* text;
-+ gint length;
-+ utf16_to_utf8 (aText, aLength, text, length);
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+ pango_layout_set_text (layout, text, length);
-+ FixupSpaceWidths (layout);
-+
-+ g_free ((gpointer) text);
-+
-+ return layout;
-+}
-+
-+PangoLayout*
-+nsFontMetricsPango::GetLayout (const gchar* aText,
-+ PRInt32 aLength)
-+{
-+ gboolean has_nul = FALSE;
-+ int i;
-+
-+ for (i = 0; i < aLength; i++)
-+ if (!aText[i]) {
-+ has_nul = TRUE;
-+ break;
-+ }
-+
-+ if (has_nul) {
-+ /* Pango doesn't correctly handle nuls. We convert them to 0xff. */
-+
-+ char *p = (char *) g_memdup (aText, aLength);
-+
-+ /* don't need to reset i */
-+ for (; i < aLength; i++)
-+ if (!p[i])
-+ p[i] = (char) 0xff;
-+
-+ aText = p;
-+ }
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+ pango_layout_set_text (layout, aText, aLength);
-+ FixupSpaceWidths (layout);
-+
-+ if (has_nul)
-+ g_free ((gpointer) aText);
-+
-+ return layout;
-+}
-+
-+static void
-+utf16_to_utf8 (const PRUnichar* aText, PRUint32 aLength, char *&text, gint &length)
-+{
-+ gboolean need_copy = FALSE;
-+ int i;
-+
-+ for (i = 0; i < aLength; i++) {
-+ if (!aText[i] || IS_LOW_SURROGATE (aText[i]))
-+ need_copy = TRUE;
-+ else if (IS_HIGH_SURROGATE (aText[i])) {
-+ if (i < aLength - 1 && IS_LOW_SURROGATE (aText[i+1]))
-+ i++;
-+ else
-+ need_copy = TRUE;
-+ }
-+ }
-+
-+ if (need_copy) {
-+
-+ /* Pango doesn't correctly handle nuls. We convert them to 0xff. */
-+ /* Also "validate" UTF-16 text to make sure conversion doesn't fail. */
-+
-+ PRUnichar *p = (PRUnichar *) g_memdup (aText, aLength * sizeof (aText[0]));
-+
-+ /* don't need to reset i */
-+ for (i = 0; i < aLength; i++) {
-+ if (!p[i] || IS_LOW_SURROGATE (p[i]))
-+ p[i] = 0xFFFD;
-+ else if (IS_HIGH_SURROGATE (p[i])) {
-+ if (i < aLength - 1 && IS_LOW_SURROGATE (aText[i+1]))
-+ i++;
-+ else
-+ p[i] = 0xFFFD;
-+ }
-+ }
-+
-+ aText = p;
-+ }
-+
-+ glong items_written;
-+ text = g_utf16_to_utf8 (aText, aLength, NULL, &items_written, NULL);
-+ length = items_written;
-+
-+ if (need_copy)
-+ g_free ((gpointer) aText);
-+
-+}
-+
- /* static */
- PangoLanguage *
- GetPangoLanguage(nsIAtom *aLangGroup)
---- mozilla.back/gfx/src/gtk/nsFontMetricsPango.h.orig 2006-06-30 01:18:34.000000000 +0200
-+++ mozilla.back/gfx/src/gtk/nsFontMetricsPango.h 2007-06-28 15:16:39.000000000 +0200
-@@ -37,17 +37,53 @@
- *
- * ***** END LICENSE BLOCK ***** */
-
-+
- #include "nsIFontMetrics.h"
- #include "nsIFontEnumerator.h"
- #include "nsCRT.h"
- #include "nsIAtom.h"
- #include "nsString.h"
- #include "nsVoidArray.h"
-+
-+#ifdef PSPANGO
-+#include "nsFontMetricsPS.h"
-+#else
- #include "nsIFontMetricsGTK.h"
-+#endif
-
- #include <pango/pango.h>
-
--class nsFontMetricsPango : public nsIFontMetricsGTK
-+#ifdef PSPANGO
-+
-+#define CONTEXT_ARG_DEF
-+#define CONTEXT_ARG_PASS
-+#define CONTEXT_ARG_NULL
-+#define CONTEXT_AND_SURFACE_ARG_DEF , nsRenderingContextPS *aContext
-+#define CONTEXT_AND_SURFACE_ARG_PASS , aContext
-+
-+#else
-+
-+#define CONTEXT_ARG_DEF , nsRenderingContextGTK *aContext
-+#define CONTEXT_ARG_PASS , aContext
-+#define CONTEXT_ARG_NULL , NULL
-+#define CONTEXT_AND_SURFACE_ARG_DEF , nsRenderingContextGTK *aContext, nsDrawingSurfaceGTK *aSurface
-+#define CONTEXT_AND_SURFACE_ARG_PASS , aContext, aSurface
-+
-+#endif
-+
-+
-+#ifdef PSPANGO
-+
-+#define nsFontMetricsPango nsFontMetricsPSPango
-+#define PSPANGO_PARENT_CLASS nsFontMetricsPS
-+
-+#else
-+
-+#define PSPANGO_PARENT_CLASS nsIFontMetricsGTK
-+
-+#endif
-+
-+class nsFontMetricsPango : public PSPANGO_PARENT_CLASS
- {
- public:
- nsFontMetricsPango();
-@@ -136,20 +172,30 @@ public:
-
- PRInt32 GetMaxStringLength() { return mMaxStringLength; }
-
-- // nsIFontMetricsGTK (calls from the font rendering layer)
-- virtual nsresult GetWidth(const char* aString, PRUint32 aLength,
-- nscoord& aWidth,
-- nsRenderingContextGTK *aContext);
-- virtual nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
-- nscoord& aWidth, PRInt32 *aFontID,
-- nsRenderingContextGTK *aContext);
-+ // nsIFontMetrics (calls from the font rendering layer)
-
-- virtual nsresult GetTextDimensions(const PRUnichar* aString,
-+#ifdef PSPANGO
-+ NS_IMETHOD GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength);
-+ NS_IMETHOD GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength);
-+#endif
-+
-+ NS_METHOD GetWidth(const char* aString, PRUint32 aLength,
-+ nscoord& aWidth
-+ CONTEXT_ARG_DEF);
-+ NS_METHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord& aWidth, PRInt32 *aFontID
-+ CONTEXT_ARG_DEF);
-+
-+ NS_METHOD GetTextDimensions(const char* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions
-+ CONTEXT_ARG_DEF);
-+ NS_METHOD GetTextDimensions(const PRUnichar* aString,
- PRUint32 aLength,
- nsTextDimensions& aDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext);
-- virtual nsresult GetTextDimensions(const char* aString,
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF);
-+ NS_METHOD GetTextDimensions(const char* aString,
- PRInt32 aLength,
- PRInt32 aAvailWidth,
- PRInt32* aBreaks,
-@@ -157,9 +203,9 @@ public:
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
- nsTextDimensions& aLastWordDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext);
-- virtual nsresult GetTextDimensions(const PRUnichar* aString,
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF);
-+ NS_METHOD GetTextDimensions(const PRUnichar* aString,
- PRInt32 aLength,
- PRInt32 aAvailWidth,
- PRInt32* aBreaks,
-@@ -167,38 +213,37 @@ public:
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
- nsTextDimensions& aLastWordDimensions,
-- PRInt32* aFontID,
-- nsRenderingContextGTK *aContext);
-+ PRInt32* aFontID
-+ CONTEXT_ARG_DEF);
-
-- virtual nsresult DrawString(const char *aString, PRUint32 aLength,
-+ NS_METHOD DrawString(const char *aString, PRUint32 aLength,
- nscoord aX, nscoord aY,
-- const nscoord* aSpacing,
-- nsRenderingContextGTK *aContext,
-- nsDrawingSurfaceGTK *aSurface);
-- virtual nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ const nscoord* aSpacing
-+ CONTEXT_AND_SURFACE_ARG_DEF);
-+
-+ NS_METHOD DrawString(const PRUnichar* aString, PRUint32 aLength,
- nscoord aX, nscoord aY,
- PRInt32 aFontID,
-- const nscoord* aSpacing,
-- nsRenderingContextGTK *aContext,
-- nsDrawingSurfaceGTK *aSurface);
-+ const nscoord* aSpacing
-+ CONTEXT_AND_SURFACE_ARG_DEF);
-
- #ifdef MOZ_MATHML
-- virtual nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
-- nsBoundingMetrics &aBoundingMetrics,
-- nsRenderingContextGTK *aContext);
-- virtual nsresult GetBoundingMetrics(const PRUnichar *aString,
-+ NS_METHOD GetBoundingMetrics(const char *aString, PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics
-+ CONTEXT_ARG_DEF);
-+ NS_METHOD GetBoundingMetrics(const PRUnichar *aString,
- PRUint32 aLength,
- nsBoundingMetrics &aBoundingMetrics,
-- PRInt32 *aFontID,
-- nsRenderingContextGTK *aContext);
-+ PRInt32 *aFontID
-+ CONTEXT_ARG_DEF);
- #endif /* MOZ_MATHML */
--
-+#ifndef PSPANGO
- virtual GdkFont* GetCurrentGDKFont(void);
--
-- virtual nsresult SetRightToLeftText(PRBool aIsRTL);
-+#endif
- virtual PRBool GetRightToLeftText();
--
-- virtual nsresult GetClusterInfo(const PRUnichar *aText,
-+ NS_METHOD SetRightToLeftText(PRBool aIsRTL);
-+
-+ NS_METHOD GetClusterInfo(const PRUnichar *aText,
- PRUint32 aLength,
- PRUint8 *aClusterStarts);
-
-@@ -206,32 +251,35 @@ public:
- PRUint32 aLength,
- nsPoint aPt);
-
-- virtual nsresult GetRangeWidth(const PRUnichar *aText,
-+ NS_METHOD GetRangeWidth(const PRUnichar *aText,
- PRUint32 aLength,
- PRUint32 aStart,
- PRUint32 aEnd,
- PRUint32 &aWidth);
-
-- virtual nsresult GetRangeWidth(const char *aText,
-+ NS_METHOD GetRangeWidth(const char *aText,
- PRUint32 aLength,
- PRUint32 aStart,
- PRUint32 aEnd,
- PRUint32 &aWidth);
-
- // get hints for the font
-- static PRUint32 GetHints (void);
-+#ifndef PSPANGO
-+ static
-+#endif
-+ PRUint32 GetHints (void);
-
- // drawing surface methods
- static nsresult FamilyExists (nsIDeviceContext *aDevice,
- const nsString &aName);
-
-+
- private:
-
- // generic font metrics class bits
- nsCStringArray mFontList;
- nsAutoVoidArray mFontIsGeneric;
-
-- nsIDeviceContext *mDeviceContext;
- nsCOMPtr<nsIAtom> mLangGroup;
- nsCString *mGenericFont;
- float mPointSize;
-@@ -246,6 +294,9 @@ private:
- PangoAttrList *mPangoAttrList;
- PRBool mIsRTL;
-
-+#ifndef PSPANGO
-+ nsIDeviceContext *mDeviceContext;
-+
- // Cached font metrics
- nscoord mXHeight;
- nscoord mSuperscriptOffset;
-@@ -263,6 +314,7 @@ private:
- nscoord mMaxDescent;
- nscoord mMaxAdvance;
- nscoord mSpaceWidth;
-+#endif
- nscoord mPangoSpaceWidth;
- nscoord mAveCharWidth;
- PRInt32 mMaxStringLength;
-@@ -274,13 +326,14 @@ private:
- static PRBool EnumFontCallback(const nsString &aFamily,
- PRBool aIsGeneric, void *aData);
-
-- void DrawStringSlowly(const gchar *aText,
-- const PRUnichar *aOrigString,
-- PRUint32 aLength,
-- GdkDrawable *aDrawable,
-- GdkGC *aGC, gint aX, gint aY,
-- PangoLayoutLine *aLine,
-- const nscoord *aSpacing);
-+ void ApplySpacing(const gchar *aText,
-+ PRUint32 aLength,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing);
-+ void ApplySpacing(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing);
-
- nsresult GetTextDimensionsInternal(const gchar* aString,
- PRInt32 aLength,
-@@ -289,10 +342,20 @@ private:
- PRInt32 aNumBreaks,
- nsTextDimensions& aDimensions,
- PRInt32& aNumCharsFit,
-- nsTextDimensions& aLastWordDimensions,
-- nsRenderingContextGTK *aContext);
-+ nsTextDimensions& aLastWordDimensions
-+ CONTEXT_ARG_DEF);
-+#ifdef MOZ_MATHML
-+ void GetBoundingMetricsInternal(PangoLayout *aLayout,
-+ nsBoundingMetrics &aBoundingMetrics
-+ CONTEXT_ARG_DEF);
-+#endif /* MOZ_MATHML */
-+
-+ void FixupSpaceWidths (PangoLayout *aLayout);
-
-- void FixupSpaceWidths (PangoLayout *aLayout, const char *aString);
-+ PangoLayout* GetLayout (const PRUnichar* aText,
-+ PRUint32 aLength);
-+ PangoLayout* GetLayout (const gchar* aText,
-+ PRInt32 aLength);
- };
-
- class nsFontEnumeratorPango : public nsIFontEnumerator
diff --git a/firefox-2.0-pango-printing.patch b/firefox-2.0-pango-printing.patch
deleted file mode 100644
index 0490892..0000000
--- a/firefox-2.0-pango-printing.patch
+++ /dev/null
@@ -1,4586 +0,0 @@
-Patch for Firefox 1.5.0.7 to add support for printing via Pango.
-This also implements printing MathML via Pango, and prints bitmap
-fonts too.
-
-Authors:
- Behdad Esfahbod
- Chris Blizzard
- Akira TAGOH
-
-Index: gfx/src/freetype/nsFreeType.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/freetype/nsFreeType.cpp,v
-retrieving revision 1.28
-diff -u -p -d -r1.28 nsFreeType.cpp
---- gfx/src/freetype/nsFreeType.cpp 13 Jul 2005 18:21:10 -0000 1.28
-+++ gfx/src/freetype/nsFreeType.cpp 23 Oct 2006 17:37:09 -0000
-@@ -123,6 +123,8 @@ FtFuncList nsFreeType2::FtFuncs [] = {
- // #endif
- {"FT_Get_First_Char", NS_FT2_OFFSET(nsFT_Get_First_Char), PR_FALSE},
- {"FT_Get_Next_Char", NS_FT2_OFFSET(nsFT_Get_Next_Char), PR_FALSE},
-+ {"FT_Has_PS_Glyph_Names", NS_FT2_OFFSET(nsFT_Has_PS_Glyph_Names), PR_FALSE},
-+ {"FT_Get_Glyph_Name", NS_FT2_OFFSET(nsFT_Get_Glyph_Name), PR_TRUE},
- {nsnull, 0, 0}
- };
-
-@@ -388,6 +390,22 @@ nsFreeType2::GetNextChar(FT_Face face, F
- }
-
- NS_IMETHODIMP
-+nsFreeType2::HasPSGlyphNames(FT_Face face, FT_Int *result)
-+{
-+ // call the FreeType2 function via the function pointer
-+ *result = nsFT_Has_PS_Glyph_Names(face);
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFreeType2::GetGlyphName(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max)
-+{
-+ // call the FreeType2 function via the function pointer
-+ FT_Error error = nsFT_Get_Glyph_Name(face, glyph_index, buffer, buffer_max);
-+ return error ? NS_ERROR_FAILURE : NS_OK;
-+}
-+
-+NS_IMETHODIMP
- nsFreeType2::SupportsExtFunc(PRBool *res)
- {
- *res = gHasExtFunc;
-Index: gfx/src/freetype/nsFreeType.h
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/freetype/nsFreeType.h,v
-retrieving revision 1.18
-diff -u -p -d -r1.18 nsFreeType.h
---- gfx/src/freetype/nsFreeType.h 1 May 2005 17:36:19 -0000 1.18
-+++ gfx/src/freetype/nsFreeType.h 23 Oct 2006 17:37:09 -0000
-@@ -52,6 +52,7 @@
- #include FT_CACHE_H
- #include FT_CACHE_IMAGE_H
- #include FT_TRUETYPE_TABLES_H
-+#include FT_TYPE1_TABLES_H
- #include "nsIFreeType2.h"
-
- typedef struct FT_FaceRec_* FT_Face;
-@@ -138,6 +139,8 @@ typedef FT_Error (*FT_Glyph_To_Bitmap_t)
-
- typedef FT_ULong (*FT_Get_First_Char_t)(FT_Face, FT_UInt*);
- typedef FT_ULong (*FT_Get_Next_Char_t)(FT_Face, FT_ULong, FT_UInt*);
-+typedef FT_Int (*FT_Has_PS_Glyph_Names_t)(FT_Face);
-+typedef FT_Error (*FT_Get_Glyph_Name_t)(FT_Face, FT_UInt, FT_Pointer, FT_UInt);
-
- class nsFreeTypeFace;
-
-@@ -193,11 +196,13 @@ protected:
- // #endif
- FT_Get_First_Char_t nsFT_Get_First_Char;
- FT_Get_Next_Char_t nsFT_Get_Next_Char;
-+ FT_Has_PS_Glyph_Names_t nsFT_Has_PS_Glyph_Names;
-+ FT_Get_Glyph_Name_t nsFT_Get_Glyph_Name;
-
- // this array needs to be big enough to hold all the function pointers
- // plus one extra for the null at the end
- // #ifdef MOZ_SVG
-- static FtFuncList FtFuncs[24];
-+ static FtFuncList FtFuncs[28];
- // #else
- // static FtFuncList FtFuncs[20];
- // #endif
-Index: gfx/src/ps/Makefile.in
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/Makefile.in,v
-retrieving revision 1.57.8.1
-diff -d -u -p -r1.57.8.1 Makefile.in
---- gfx/src/ps/Makefile.in 17 Jun 2006 15:16:14 -0000 1.57.8.1
-+++ gfx/src/ps/Makefile.in 24 Oct 2006 18:36:45 -0000
-@@ -98,6 +98,15 @@ EXTRA_DSO_LDOPTS = \
- $(MOZ_UNICHARUTIL_LIBS) \
- $(NULL)
-
-+ifdef MOZ_ENABLE_PANGO
-+CPPSRCS += \
-+ nsFontMetricsPSPango.cpp \
-+ mozilla-ps-decoder.cpp
-+EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS)
-+CXXFLAGS += $(MOZ_PANGO_CFLAGS)
-+CFLAGS += $(MOZ_PANGO_CFLAGS)
-+endif
-+
- ifdef MOZ_ENABLE_XFT
- EXTRA_DSO_LDOPTS += \
- $(MOZ_XFT_LIBS) \
-@@ -105,7 +114,7 @@ EXTRA_DSO_LDOPTS += \
- $(NULL)
- endif
-
--ifneq (,$(MOZ_ENABLE_FREETYPE2)$(MOZ_ENABLE_XFT))
-+ifneq (,$(MOZ_ENABLE_FREETYPE2)$(MOZ_ENABLE_XFT)$(MOZ_ENABLE_PANGO))
- CPPSRCS += \
- nsType1.cpp \
- $(NULL)
-Index: gfx/src/ps/mozilla-ps-decoder.cpp
-===================================================================
-RCS file: gfx/src/ps/mozilla-ps-decoder.cpp
-diff -N gfx/src/ps/mozilla-ps-decoder.cpp
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ gfx/src/ps/mozilla-ps-decoder.cpp 23 Oct 2006 17:37:10 -0000
-@@ -0,0 +1,376 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-+/* vim:expandtab:shiftwidth=4:tabstop=4:
-+ */
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is Christopher Blizzard
-+ * <blizzard@mozilla.org>. Portions created by the Initial Developer
-+ * are Copyright (C) 2004 the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either the GNU General Public License Version 2 or later (the "GPL"), or
-+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#define PANGO_ENABLE_BACKEND
-+#define PANGO_ENABLE_ENGINE
-+
-+#include "mozilla-ps-decoder.h"
-+#include <pango/pangofc-fontmap.h>
-+#include <pango/pangofc-font.h>
-+
-+#include "nsString.h"
-+#include "nsIPersistentProperties2.h"
-+#include "nsNetUtil.h"
-+#include "nsReadableUtils.h"
-+#include "nsICharsetConverterManager.h"
-+#include "nsICharRepresentable.h"
-+#include "nsCompressedCharMap.h"
-+
-+#undef DEBUG_CUSTOM_ENCODER
-+
-+G_DEFINE_TYPE (MozillaPSDecoder, mozilla_ps_decoder, PANGO_TYPE_FC_DECODER)
-+
-+MozillaPSDecoder *mozilla_ps_decoder_new (void);
-+
-+static FcCharSet *mozilla_ps_decoder_get_charset (PangoFcDecoder *decoder,
-+ PangoFcFont *fcfont);
-+static PangoGlyph mozilla_ps_decoder_get_glyph (PangoFcDecoder *decoder,
-+ PangoFcFont *fcfont,
-+ guint32 wc);
-+
-+static PangoFcDecoder *mozilla_find_ps_decoder (FcPattern *pattern,
-+ gpointer user_data);
-+
-+typedef struct _MozillaPSDecoderPrivate MozillaPSDecoderPrivate;
-+
-+#define MOZILLA_PS_DECODER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MOZILLA_TYPE_DECODER, MozillaPSDecoderPrivate))
-+
-+struct _MozillaPSDecoderPrivate {
-+ char *family;
-+ char *encoder;
-+ char *cmap;
-+ gboolean is_wide;
-+ FcCharSet *charset;
-+ nsCOMPtr<nsIUnicodeEncoder> uEncoder;
-+};
-+
-+static nsICharsetConverterManager *gCharsetManager = NULL;
-+
-+static NS_DEFINE_CID(kCharsetConverterManagerCID,
-+ NS_ICHARSETCONVERTERMANAGER_CID);
-+
-+// Hash tables that hold the custom encodings and custom cmaps used in
-+// various fonts.
-+static GHashTable *encoder_hash = NULL;
-+static GHashTable *cmap_hash = NULL;
-+static GHashTable *wide_hash = NULL;
-+
-+void
-+mozilla_ps_decoder_init (MozillaPSDecoder *decoder)
-+{
-+}
-+
-+void
-+mozilla_ps_decoder_class_init (MozillaPSDecoderClass *klass)
-+{
-+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
-+ PangoFcDecoderClass *parent_class = PANGO_FC_DECODER_CLASS (klass);
-+
-+ /* object_class->finalize = test_finalize; */
-+
-+ parent_class->get_charset = mozilla_ps_decoder_get_charset;
-+ parent_class->get_glyph = mozilla_ps_decoder_get_glyph;
-+
-+ g_type_class_add_private (object_class, sizeof (MozillaPSDecoderPrivate));
-+}
-+
-+MozillaPSDecoder *
-+mozilla_ps_decoder_new(void)
-+{
-+ return (MozillaPSDecoder *)g_object_new(MOZILLA_TYPE_DECODER, NULL);
-+}
-+
-+#ifdef DEBUG_CUSTOM_ENCODER
-+void
-+dump_hash(char *key, char *val, void *arg)
-+{
-+ printf("%s -> %s\n", key, val);
-+}
-+#endif
-+
-+/**
-+ * mozilla_ps_decoders_init:
-+ *
-+ * #mozilla_ps_decoders_init:
-+ *
-+ * This initializes all of the application-specific custom decoders
-+ * that Mozilla uses. This should only be called once during the
-+ * lifetime of the application.
-+ *
-+ * Return value: zero on success, not zero on failure.
-+ *
-+ **/
-+
-+int
-+mozilla_ps_decoders_init(PangoFontMap *fontmap)
-+{
-+ static PRBool initialized = PR_FALSE;
-+ if (initialized)
-+ return 0;
-+
-+ if (!PANGO_IS_FC_FONT_MAP (fontmap))
-+ return -1;
-+
-+ encoder_hash = g_hash_table_new(g_str_hash, g_str_equal);
-+ cmap_hash = g_hash_table_new(g_str_hash, g_str_equal);
-+ wide_hash = g_hash_table_new(g_str_hash, g_str_equal);
-+
-+ PRBool dumb = PR_FALSE;
-+ nsCOMPtr<nsIPersistentProperties> props;
-+ nsCOMPtr<nsISimpleEnumerator> encodeEnum;
-+
-+ NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(props),
-+ NS_LITERAL_CSTRING("resource://gre/res/fonts/pangoFontEncoding.properties"));
-+
-+ if (!props)
-+ goto loser;
-+
-+ // Enumerate the properties in this file and figure out all of the
-+ // fonts for which we have custom encodings.
-+ props->Enumerate(getter_AddRefs(encodeEnum));
-+ if (!encodeEnum)
-+ goto loser;
-+
-+ while (encodeEnum->HasMoreElements(&dumb), dumb) {
-+ nsCOMPtr<nsIPropertyElement> prop;
-+ encodeEnum->GetNext(getter_AddRefs(prop));
-+ if (!prop)
-+ goto loser;
-+
-+ nsCAutoString name;
-+ prop->GetKey(name);
-+ nsAutoString value;
-+ prop->GetValue(value);
-+
-+ if (!StringBeginsWith(name, NS_LITERAL_CSTRING("encoding."))) {
-+ printf("string doesn't begin with encoding?\n");
-+ continue;
-+ }
-+
-+ name = Substring(name, 9);
-+
-+ if (StringEndsWith(name, NS_LITERAL_CSTRING(".ttf"))) {
-+ name = Substring(name, 0, name.Length() - 4);
-+
-+ // Strip off a .wide if it's there.
-+ if (StringEndsWith(value, NS_LITERAL_STRING(".wide"))) {
-+ g_hash_table_insert(wide_hash, g_strdup(name.get()),
-+ g_strdup("wide"));
-+ value = Substring(value, 0, name.Length() - 5);
-+ }
-+
-+ g_hash_table_insert(encoder_hash,
-+ g_strdup(name.get()),
-+ g_strdup(NS_ConvertUTF16toUTF8(value).get()));
-+ }
-+ else if (StringEndsWith(name, NS_LITERAL_CSTRING(".ftcmap"))) {
-+ name = Substring(name, 0, name.Length() - 7);
-+ g_hash_table_insert(cmap_hash,
-+ g_strdup(name.get()),
-+ g_strdup(NS_ConvertUTF16toUTF8(value).get()));
-+ }
-+ else {
-+ printf("unknown suffix used for mapping\n");
-+ }
-+ }
-+
-+ pango_fc_font_map_add_decoder_find_func(PANGO_FC_FONT_MAP(fontmap),
-+ mozilla_find_ps_decoder,
-+ NULL,
-+ NULL);
-+
-+ initialized = PR_TRUE;
-+
-+#ifdef DEBUG_CUSTOM_ENCODER
-+ printf("*** encoders\n");
-+ g_hash_table_foreach(encoder_hash, (GHFunc)dump_hash, NULL);
-+
-+ printf("*** cmaps\n");
-+ g_hash_table_foreach(cmap_hash, (GHFunc)dump_hash, NULL);
-+#endif
-+
-+ return 0;
-+
-+ loser:
-+ return -1;
-+}
-+
-+static FcCharSet *
-+mozilla_ps_decoder_get_charset (PangoFcDecoder *decoder,
-+ PangoFcFont *fcfont)
-+{
-+ MozillaPSDecoderPrivate *priv = MOZILLA_PS_DECODER_GET_PRIVATE(decoder);
-+
-+ if (priv->charset)
-+ return priv->charset;
-+
-+ // First time this has been accessed. Populate the charset.
-+ priv->charset = FcCharSetCreate();
-+
-+ if (!gCharsetManager) {
-+ CallGetService(kCharsetConverterManagerCID, &gCharsetManager);
-+ }
-+
-+ nsCOMPtr<nsIUnicodeEncoder> encoder;
-+ nsCOMPtr<nsICharRepresentable> represent;
-+
-+ if (!gCharsetManager)
-+ goto end;
-+
-+ gCharsetManager->GetUnicodeEncoderRaw(priv->encoder, getter_AddRefs(encoder));
-+ if (!encoder)
-+ goto end;
-+
-+ encoder->SetOutputErrorBehavior(encoder->kOnError_Replace, nsnull, '?');
-+
-+ priv->uEncoder = encoder;
-+
-+ represent = do_QueryInterface(encoder);
-+ if (!represent)
-+ goto end;
-+
-+ PRUint32 map[UCS2_MAP_LEN];
-+ memset(map, 0, sizeof(map));
-+
-+ represent->FillInfo(map);
-+
-+ for (int i = 0; i < NUM_UNICODE_CHARS; i++) {
-+ if (IS_REPRESENTABLE(map, i))
-+ FcCharSetAddChar(priv->charset, i);
-+ }
-+
-+ end:
-+ return priv->charset;
-+}
-+
-+static PangoGlyph
-+mozilla_ps_decoder_get_glyph (PangoFcDecoder *decoder,
-+ PangoFcFont *fcfont,
-+ guint32 wc)
-+{
-+ MozillaPSDecoderPrivate *priv = MOZILLA_PS_DECODER_GET_PRIVATE(decoder);
-+
-+ PangoGlyph retval = 0;
-+ PRUnichar inchar = wc;
-+ PRInt32 inlen = 1;
-+ char outchar[2] = {0,0};
-+ PRInt32 outlen = 2;
-+
-+ priv->uEncoder->Convert(&inchar, &inlen, outchar, &outlen);
-+ if (outlen != 1) {
-+ printf("Warning: mozilla_ps_decoder_get_glyph doesn't support more than one character conversions.\n");
-+ return 0;
-+ }
-+
-+ FT_Face face = pango_fc_font_lock_face(fcfont);
-+
-+#ifdef DEBUG_CUSTOM_ENCODER
-+ char *filename;
-+ FcPatternGetString(fcfont->font_pattern, FC_FILE, 0, (FcChar8 **)&filename);
-+ printf("filename is %s\n", filename);
-+#endif
-+
-+ // Make sure to set the right charmap before trying to get the
-+ // glyph
-+ if (priv->cmap) {
-+ if (!strcmp(priv->cmap, "mac_roman")) {
-+ FT_Select_Charmap(face, ft_encoding_apple_roman);
-+ }
-+ else if (!strcmp(priv->cmap, "unicode")) {
-+ FT_Select_Charmap(face, ft_encoding_unicode);
-+ }
-+ else {
-+ printf("Warning: Invalid charmap entry for family %s\n",
-+ priv->family);
-+ }
-+ }
-+
-+ // Standard 8 bit to glyph translation
-+ if (!priv->is_wide) {
-+ FcChar32 blah = PRUint8(outchar[0]);
-+ retval = FT_Get_Char_Index(face, blah);
-+#ifdef DEBUG_CUSTOM_ENCODER
-+ printf("wc 0x%x outchar[0] 0x%x index 0x%x retval 0x%x face %p\n",
-+ wc, outchar[0], blah, retval, (void *)face);
-+#endif
-+ }
-+ else {
-+ printf("Warning: We don't support .wide fonts!\n");
-+ retval = 0;
-+ }
-+
-+ pango_fc_font_unlock_face(fcfont);
-+
-+ return retval;
-+}
-+
-+static PangoFcDecoder *
-+mozilla_find_ps_decoder (FcPattern *pattern, gpointer user_data)
-+{
-+ // Compare the family name of the font that's been opened to see
-+ // if we have a custom decoder.
-+ const char *orig = NULL;
-+ FcPatternGetString(pattern, FC_FAMILY, 0, (FcChar8 **)&orig);
-+
-+ nsCAutoString family;
-+ family.Assign(orig);
-+
-+ family.StripWhitespace();
-+ ToLowerCase(family);
-+
-+ char *encoder = (char *)g_hash_table_lookup(encoder_hash, family.get());
-+ if (!encoder)
-+ return NULL;
-+
-+ MozillaPSDecoder *decoder = mozilla_ps_decoder_new();
-+
-+ MozillaPSDecoderPrivate *priv = MOZILLA_PS_DECODER_GET_PRIVATE(decoder);
-+
-+ priv->family = g_strdup(family.get());
-+ priv->encoder = g_strdup(encoder);
-+
-+ char *cmap = (char *)g_hash_table_lookup(cmap_hash, family.get());
-+ if (cmap)
-+ priv->cmap = g_strdup(cmap);
-+
-+ char *wide = (char *)g_hash_table_lookup(wide_hash, family.get());
-+ if (wide)
-+ priv->is_wide = TRUE;
-+
-+ return PANGO_FC_DECODER(decoder);
-+}
-Index: gfx/src/ps/mozilla-ps-decoder.h
-===================================================================
-RCS file: gfx/src/ps/mozilla-ps-decoder.h
-diff -N gfx/src/ps/mozilla-ps-decoder.h
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ gfx/src/ps/mozilla-ps-decoder.h 23 Oct 2006 17:37:10 -0000
-@@ -0,0 +1,72 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-+/* vim:expandtab:shiftwidth=4:tabstop=4:
-+ */
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is Christopher Blizzard
-+ * <blizzard@mozilla.org>. Portions created by the Initial Developer
-+ * are Copyright (C) 2004 the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either the GNU General Public License Version 2 or later (the "GPL"), or
-+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#ifndef _MOZILLA_PS_DECODER_H
-+#define _MOZILLA_PS_DECODER_H
-+
-+#include <pango/pangofc-decoder.h>
-+
-+G_BEGIN_DECLS
-+
-+#define MOZILLA_TYPE_DECODER (mozilla_ps_decoder_get_type())
-+#define MOZILLA_PS_DECODER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOZILLA_TYPE_DECODER, MozillaPSDecoder))
-+#define MOZILLA_IS_DECODER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOZILLA_TYPE_DECODER))
-+
-+typedef struct _MozillaPSDecoder MozillaPSDecoder;
-+typedef struct _MozillaPSDecoderClass MozillaPSDecoderClass;
-+
-+#define MOZILLA_PS_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOZILLA_TYPE_DECODER, MozillaPSDecoderClass))
-+#define MOZILLA_IS_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOZILLA_TYPE_DECODER))
-+#define MOZILLA_PS_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOZILLA_TYPE_DECODER, MozillaPSDecoderClass))
-+
-+struct _MozillaPSDecoder
-+{
-+ PangoFcDecoder parent_instance;
-+};
-+
-+struct _MozillaPSDecoderClass
-+{
-+ PangoFcDecoderClass parent_class;
-+};
-+
-+GType mozilla_ps_decoder_get_type (void);
-+int mozilla_ps_decoders_init (PangoFontMap *fontmap);
-+
-+G_END_DECLS
-+
-+#endif /*_MOZILLA_PS_DECODER_H */
-Index: gfx/src/ps/nsDeviceContextPS.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsDeviceContextPS.cpp,v
-retrieving revision 1.73
-diff -u -p -d -r1.73 nsDeviceContextPS.cpp
---- gfx/src/ps/nsDeviceContextPS.cpp 21 May 2005 15:33:08 -0000 1.73
-+++ gfx/src/ps/nsDeviceContextPS.cpp 23 Oct 2006 17:37:10 -0000
-@@ -58,12 +58,15 @@
- #include "nsIPref.h"
- #include "nsString.h"
- #include "nsFontMetricsPS.h"
-+#ifdef MOZ_ENABLE_PANGO
-+#include "nsFontMetricsPSPango.h"
-+#endif
- #include "nsPostScriptObj.h"
- #include "nspr.h"
- #include "nsILanguageAtomService.h"
- #include "nsPrintJobPS.h"
- #include "nsPrintJobFactoryPS.h"
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- #include "nsType1.h"
- #endif
-
-@@ -223,7 +226,7 @@ nsDeviceContextPS::InitDeviceContextPS(n
-
- nsresult rv;
- nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- if (NS_SUCCEEDED(rv)) {
- rv = pref->GetBoolPref("font.FreeType2.printing", &mFTPEnable);
- if (NS_FAILED(rv))
-@@ -469,7 +472,7 @@ NS_IMETHODIMP nsDeviceContextPS::EndDocu
- NS_ASSERTION(submitFP, "No print job submission handle");
-
- // Start writing the print job to the job handler
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- mPSObj->write_prolog(submitFP, mFTPEnable);
- #else
- mPSObj->write_prolog(submitFP);
-@@ -550,15 +553,52 @@ public:
- virtual nsresult CreateFontMetricsInstance(nsIFontMetrics** aResult);
- };
-
-+#if defined(MOZ_ENABLE_PANGO)
-+PRBool
-+NS_IsPangoEnabled(void)
-+{
-+ static PRBool beenHere;
-+ static PRBool pangoEnabled;
-+
-+ if (!beenHere) {
-+ beenHere = PR_TRUE;
-+
-+ char *val = PR_GetEnv("MOZ_DISABLE_PANGO");
-+ pangoEnabled = !(val);
-+
-+ if (pangoEnabled) {
-+ nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID);
-+ if (prefService)
-+ prefService->SetDefaultCharPref("general.useragent.extra.pango",
-+ "pango-text");
-+ }
-+ }
-+
-+ return pangoEnabled;
-+}
-+#endif
-
- nsresult nsFontCachePS::CreateFontMetricsInstance(nsIFontMetrics** aResult)
- {
- NS_PRECONDITION(aResult, "null out param");
-- nsIFontMetrics *fm = new nsFontMetricsPS();
-- if (!fm)
-- return NS_ERROR_OUT_OF_MEMORY;
-- NS_ADDREF(fm);
-- *aResult = fm;
-+#ifdef MOZ_ENABLE_PANGO
-+ if (NS_IsPangoEnabled())
-+ {
-+ nsIFontMetrics *fm = new nsFontMetricsPSPango();
-+ if (!fm)
-+ return NS_ERROR_OUT_OF_MEMORY;
-+ NS_ADDREF(fm);
-+ *aResult = fm;
-+ }
-+ else
-+#endif
-+ {
-+ nsIFontMetrics *fm = new nsFontMetricsPS();
-+ if (!fm)
-+ return NS_ERROR_OUT_OF_MEMORY;
-+ NS_ADDREF(fm);
-+ *aResult = fm;
-+ }
- return NS_OK;
- }
-
-Index: gfx/src/ps/nsFontMetricsPS.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsFontMetricsPS.cpp,v
-retrieving revision 1.57.16.2
-diff -u -p -d -r1.57.16.2 nsFontMetricsPS.cpp
---- gfx/src/ps/nsFontMetricsPS.cpp 7 May 2006 02:01:25 -0000 1.57.16.2
-+++ gfx/src/ps/nsFontMetricsPS.cpp 23 Oct 2006 17:37:11 -0000
-@@ -461,6 +461,239 @@ nsFontMetricsPS :: GetStringWidth(const
- return NS_OK;
- }
-
-+nsresult
-+nsFontMetricsPS::DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ nsPostScriptObj* psObj = aContext->GetPostScriptObj();
-+ // When FT2 printing is enabled, we don't need to set langgroup
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+ if (!NS_REINTERPRET_CAST(nsDeviceContextPS *, GetDeviceContext())->mFTPEnable) {
-+#endif
-+ nsCOMPtr<nsIAtom> langGroup;
-+ GetLangGroup(getter_AddRefs(langGroup));
-+ psObj->setlanggroup(langGroup);
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+ }
-+#endif
-+
-+ if (aLength == 0)
-+ return NS_OK;
-+ nsFontPS* fontPS = nsFontPS::FindFont(aString[0], Font(), this);
-+ NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
-+ fontPS->SetupFont(aContext);
-+
-+ PRUint32 i, start = 0;
-+ for (i=0; i<aLength; i++) {
-+ nsFontPS* fontThisChar;
-+ fontThisChar = nsFontPS::FindFont(aString[i], Font(), this);
-+ NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
-+ if (fontThisChar != fontPS) {
-+ // draw text up to this point
-+ aX += DrawString(aString+start, i-start, aX, aY, fontPS,
-+ aSpacing?aSpacing+start:nsnull, aContext);
-+ start = i;
-+
-+ // setup for following text
-+ fontPS = fontThisChar;
-+ fontPS->SetupFont(aContext);
-+ }
-+ }
-+
-+ // draw the last part
-+ if (aLength-start)
-+ DrawString(aString+start, aLength-start, aX, aY, fontPS,
-+ aSpacing?aSpacing+start:nsnull, aContext);
-+
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPS::DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ PRInt32 aFontID,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ nsPostScriptObj* psObj = aContext->GetPostScriptObj();
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+ // When FT2 printing is enabled, we don't need to set langgroup
-+ if (!NS_REINTERPRET_CAST(nsDeviceContextPS *, GetDeviceContext())->mFTPEnable) {
-+#endif
-+ nsCOMPtr<nsIAtom> langGroup = nsnull;
-+ GetLangGroup(getter_AddRefs(langGroup));
-+ psObj->setlanggroup(langGroup);
-+#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-+ }
-+#endif
-+
-+ /* build up conversion table */
-+ psObj->preshow(aString, aLength);
-+
-+ if (aLength == 0)
-+ return NS_OK;
-+ nsFontPS* fontPS = nsFontPS::FindFont(aString[0], Font(), this);
-+ NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
-+ fontPS->SetupFont(aContext);
-+
-+ PRUint32 i, start = 0;
-+ for (i=0; i<aLength; i++) {
-+ nsFontPS* fontThisChar;
-+ fontThisChar = nsFontPS::FindFont(aString[i], Font(), this);
-+ NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
-+ if (fontThisChar != fontPS) {
-+ // draw text up to this point
-+ aX += DrawString(aString+start, i-start, aX, aY, fontPS,
-+ aSpacing?aSpacing+start:nsnull, aContext);
-+ start = i;
-+
-+ // setup for following text
-+ fontPS = fontThisChar;
-+ fontPS->SetupFont(aContext);
-+ }
-+ }
-+
-+ // draw the last part
-+ if (aLength-start)
-+ DrawString(aString+start, aLength-start, aX, aY, fontPS,
-+ aSpacing?aSpacing+start:nsnull, aContext);
-+
-+ return NS_OK;
-+}
-+
-+PRInt32
-+nsFontMetricsPS::DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY, nsFontPS* aFontPS,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ nscoord width = 0;
-+ PRInt32 x = aX;
-+ PRInt32 y = aY;
-+
-+ PRInt32 dxMem[500];
-+ PRInt32* dx0 = 0;
-+ if (aSpacing) {
-+ dx0 = dxMem;
-+ if (aLength > 500) {
-+ dx0 = new PRInt32[aLength];
-+ NS_ENSURE_TRUE(dx0, NS_ERROR_OUT_OF_MEMORY);
-+ }
-+ aContext->GetTranMatrix()->ScaleXCoords(aSpacing, aLength, dx0);
-+ }
-+
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+ width = aFontPS->DrawString(aContext, x, y, aString, aLength);
-+
-+ if ((aSpacing) && (dx0 != dxMem)) {
-+ delete [] dx0;
-+ }
-+
-+ return width;
-+}
-+
-+
-+PRInt32
-+nsFontMetricsPS::DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord &aX, nscoord &aY, nsFontPS* aFontPS,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ nscoord width = 0;
-+ PRInt32 x = aX;
-+ PRInt32 y = aY;
-+
-+ if (aSpacing) {
-+ // Slow, but accurate rendering
-+ const PRUnichar* end = aString + aLength;
-+ while (aString < end){
-+ x = aX;
-+ y = aY;
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+ aFontPS->DrawString(aContext, x, y, aString, 1);
-+ aX += *aSpacing++;
-+ aString++;
-+ }
-+ width = aX;
-+ } else {
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+ width = aFontPS->DrawString(aContext, x, y, aString, aLength);
-+ }
-+
-+ return width;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPS::GetTextDimensions(const char* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID)
-+{
-+ NS_NOTYETIMPLEMENTED("nsFontMetricsPS::GetTextDimensions");
-+ return NS_ERROR_NOT_IMPLEMENTED;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPS::GetTextDimensions(const PRUnichar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID)
-+{
-+ NS_NOTYETIMPLEMENTED("nsFontMetricsPS::GetTextDimensions");
-+ return NS_ERROR_NOT_IMPLEMENTED;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPS :: GetTextDimensions(const char* aString, PRUint32 aLength,
-+ nsTextDimensions& aDimensions)
-+{
-+ GetStringWidth(aString, aDimensions.width, aLength);
-+ GetMaxAscent(aDimensions.ascent);
-+ GetMaxDescent(aDimensions.descent);
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPS :: GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
-+ nsTextDimensions& aDimensions, PRInt32* aFontID)
-+{
-+ GetStringWidth(aString, aDimensions.width, aLength);
-+ //XXX temporary - bug 96609
-+ GetMaxAscent(aDimensions.ascent);
-+ GetMaxDescent(aDimensions.descent);
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPS::GetBoundingMetrics(const char* aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics& aBoundingMetrics)
-+{
-+ return NS_ERROR_NOT_IMPLEMENTED;
-+}
-+
-+nsresult
-+nsFontMetricsPS::GetBoundingMetrics(const PRUnichar* aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics,
-+ PRInt32 *aFontID)
-+{
-+ return NS_ERROR_NOT_IMPLEMENTED;
-+}
-+
-+
- nsFontPS*
- nsFontPS::FindFont(char aChar, const nsFont& aFont,
- nsFontMetricsPS* aFontMetrics)
-@@ -1128,23 +1361,38 @@ nsFontPSXft::DrawString(nsRenderingConte
- PRUint32 start = 0;
- PRUint32 i;
-
-+ FT_Face face = getFTFace();
-+ if (!face) {
-+ NS_WARNING("Failed to get FT Face in nsFontPSXft::DrawString\n");
-+ return 0;
-+ }
-+
-+ nsValueArray glyphs(PR_UINT16_MAX);
-+
- // XXX : ignore surrogate pairs for now
-- nsString *subSet = mPSFontGenerator->GetSubset();
- for (i = 0; i < aLength; ++i) {
-- currSubFont = mPSFontGenerator->AddToSubset(aString[i]);
-+ PRUint32 glyph = FT_Get_Char_Index(face, aString[i]);
-+ currSubFont = mPSFontGenerator->AddToGlyphSubset(glyph);
-+
-+ // Check if we need to render the current string
- if (prevSubFont != currSubFont) {
-- if (prevSubFont != -1)
-- psObj->show(&aString[start], i - start, *subSet, prevSubFont);
-+ if (prevSubFont != -1) {
-+ psObj->show(&glyphs, mPSFontGenerator, prevSubFont);
-+ }
- NS_ASSERTION(!mFontNameBase.IsEmpty(),
- "font base name shouldn't be empty");
- psObj->setfont(mFontNameBase, mHeight, currSubFont);
- prevSubFont = currSubFont;
- start = i;
-+ glyphs.Clear();
- }
-+
-+ glyphs.AppendValue(glyph);
- }
-
-- if (prevSubFont != -1)
-- psObj->show(&aString[start], i - start, *subSet, prevSubFont);
-+ if (prevSubFont != -1) {
-+ psObj->show(&glyphs, mPSFontGenerator, prevSubFont);
-+ }
-
- return GetWidth(aString, aLength);
- }
-@@ -2278,10 +2526,13 @@ nsFontPSFreeType::GetBoundingMetrics(con
- // Implementation of nsPSFontGenerator
- nsPSFontGenerator::nsPSFontGenerator()
- {
-+ mGlyphSubset = new nsValueArray(PR_UINT16_MAX, 40);
- }
-
- nsPSFontGenerator::~nsPSFontGenerator()
- {
-+ if (mGlyphSubset)
-+ delete mGlyphSubset;
- }
-
- void nsPSFontGenerator::GeneratePSFont(FILE* aFile)
-@@ -2289,24 +2540,29 @@ void nsPSFontGenerator::GeneratePSFont(F
- NS_ERROR("should never call nsPSFontGenerator::GeneratePSFont");
- }
-
--// Add a Unicode character to mSubset which will be divided into
--// multiple chunks (subfonts) of 255 (kSubFontSize) characters each.
--// Each chunk will be converted to a Type 1 font. Return the index of
--// a subfont (chunk) this character belongs to.
-+// Add a glyph offset to mSubset which will be divided into multiple
-+// chunks (subfonts) of 255 (kSubFontSize) glyphs each. Each chunk
-+// will then be converted into a Type 1 font. Return the index of a
-+// subfont (chunk) this glyph belongs to.
- PRInt32
--nsPSFontGenerator::AddToSubset(PRUnichar aChar)
-+nsPSFontGenerator::AddToGlyphSubset(PRUint32 aGlyph)
- {
-- PRInt32 index = mSubset.FindChar(aChar);
-- if (index == kNotFound) {
-- mSubset.Append(aChar);
-- index = mSubset.Length() - 1;
-+ nsValueArrayIndex index = mGlyphSubset->IndexOf(aGlyph);
-+ if (index == NSVALUEARRAY_INVALID) {
-+ mGlyphSubset->AppendValue(aGlyph);
-+ index = mGlyphSubset->Count() - 1;
- }
-+
- return index / kSubFontSize;
- }
-
--nsString *nsPSFontGenerator::GetSubset()
-+PRInt32
-+nsPSFontGenerator::InSubsetIndexOf(PRUint32 aGlyph)
- {
-- return &mSubset;
-+ nsValueArrayIndex index = mGlyphSubset->IndexOf(aGlyph);
-+ if (index == NSVALUEARRAY_INVALID)
-+ return 0;
-+ return (index % kSubFontSize) + 1;
- }
-
- #ifdef MOZ_ENABLE_XFT
-@@ -2353,8 +2609,8 @@ void nsXftType1Generator::GeneratePSFont
- }
-
- int wmode = 0;
-- if (!mSubset.IsEmpty())
-- FT2SubsetToType1FontSet(face, mSubset, wmode, aFile);
-+ if (mGlyphSubset->Count())
-+ FT2SubsetToType1FontSet(face, mGlyphSubset, wmode, aFile);
- }
-
- #else
-@@ -2402,8 +2658,8 @@ void nsFT2Type1Generator::GeneratePSFont
- return;
-
- int wmode = 0;
-- if (!mSubset.IsEmpty())
-- FT2SubsetToType1FontSet(face, mSubset, wmode, aFile);
-+ if (mGlyphSubset->Count())
-+ FT2SubsetToType1FontSet(face, mGlyphSubset, wmode, aFile);
- }
-
- #endif //MOZ_ENABLE_FREETYPE2
-Index: gfx/src/ps/nsFontMetricsPS.h
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsFontMetricsPS.h,v
-retrieving revision 1.31
-diff -u -p -d -r1.31 nsFontMetricsPS.h
---- gfx/src/ps/nsFontMetricsPS.h 28 Jun 2005 18:29:10 -0000 1.31
-+++ gfx/src/ps/nsFontMetricsPS.h 23 Oct 2006 17:37:11 -0000
-@@ -66,6 +66,7 @@
- #endif
- #include "nsVoidArray.h"
- #include "nsHashtable.h"
-+#include "nsValueArray.h"
-
- class nsPSFontGenerator;
- class nsDeviceContextPS;
-@@ -108,6 +109,65 @@ public:
- NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
- NS_IMETHOD GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength);
- NS_IMETHOD GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength);
-+
-+ NS_IMETHOD GetTextDimensions(const char* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions);
-+ NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions,
-+ PRInt32* aFontID);
-+ NS_IMETHOD GetTextDimensions(const char* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID);
-+ NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID);
-+#ifdef MOZ_MATHML
-+ NS_IMETHOD GetBoundingMetrics(const char *aString, PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics);
-+ NS_IMETHOD GetBoundingMetrics(const PRUnichar *aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics,
-+ PRInt32 *aFontID);
-+#endif /* MOZ_MATHML */
-+
-+ NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+ NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ PRInt32 aFontID,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+
-+protected:
-+ PRInt32 DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY, nsFontPS* aFontPS,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+ PRInt32 DrawString(const PRUnichar *aString, PRUint32 aLength,
-+ nscoord &aX, nscoord &aY, nsFontPS* aFontPS,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+
-+public:
-+
-+ virtual PRUint32 GetHints (void) { return 0; }
-+
-
- inline void SetXHeight(nscoord aXHeight) { mXHeight = aXHeight; };
- inline void SetSuperscriptOffset(nscoord aSuperscriptOffset) { mSuperscriptOffset = aSuperscriptOffset; };
-@@ -455,16 +515,14 @@ public:
- nsPSFontGenerator();
- virtual ~nsPSFontGenerator();
- virtual void GeneratePSFont(FILE* aFile);
-- PRInt32 AddToSubset(PRUnichar aChar);
-- nsString *GetSubset();
-+ PRInt32 AddToGlyphSubset(PRUint32 aGlyph);
-+ PRInt32 InSubsetIndexOf(PRUint32 aGlyph);
-
- // 256 (PS type 1 encoding vector size) - 1 (1 is for mandatory /.notdef)
- const static PRUint16 kSubFontSize;
-
- protected:
-- // XXX To support non-BMP characters, we may have to use
-- // nsValueArray with PRUint32
-- nsString mSubset;
-+ nsValueArray *mGlyphSubset;
- };
-
-
-Index: gfx/src/ps/nsFontMetricsPSPango.cpp
-===================================================================
-RCS file: gfx/src/ps/nsFontMetricsPSPango.cpp
-diff -N gfx/src/ps/nsFontMetricsPSPango.cpp
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ gfx/src/ps/nsFontMetricsPSPango.cpp 23 Oct 2006 17:37:13 -0000
-@@ -0,0 +1,2107 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-+/* vim:expandtab:shiftwidth=4:tabstop=4:
-+ */
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is Christopher Blizzard
-+ * <blizzard@mozilla.org>. Portions created by the Initial Developer
-+ * are Copyright (C) 2004 the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ * Christopher Blizzard <blizzard@mozilla.org>
-+ * Behdad Esfahbod <behdad@behdad.org>
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either the GNU General Public License Version 2 or later (the "GPL"), or
-+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#include <strings.h>
-+#include "nsFont.h"
-+#include "nsIDeviceContext.h"
-+#include "nsICharsetConverterManager.h"
-+#include "nsIPref.h"
-+#include "nsServiceManagerUtils.h"
-+
-+#define PANGO_ENABLE_BACKEND
-+#define PANGO_ENABLE_ENGINE
-+
-+#include "nsFontMetricsPSPango.h"
-+#include "nsRenderingContextPS.h"
-+#include "nsDeviceContextPS.h"
-+#include "nsFontConfigUtils.h"
-+
-+#include "nsPrintfCString.h"
-+#include "nsUnicharUtils.h"
-+#include "nsQuickSort.h"
-+#include "nsFontConfigUtils.h"
-+
-+#include <fontconfig/fontconfig.h>
-+#include <pango/pangoft2.h>
-+#include <freetype/tttables.h>
-+#include "nsType1.h"
-+
-+#include "mozilla-ps-decoder.h"
-+
-+#define FORCE_PR_LOG
-+#include "prlog.h"
-+
-+// Globals
-+
-+static PRLogModuleInfo *gPangoFontLog;
-+static int gNumInstances;
-+
-+
-+static void
-+default_substitute (FcPattern *pattern,
-+ gpointer data)
-+{
-+ FcPatternDel (pattern, FC_HINTING);
-+ FcPatternAddBool (pattern, FC_HINTING, 0);
-+}
-+
-+static PangoFontMap *
-+get_fontmap (void)
-+{
-+ static PangoFontMap *fontmap = NULL;
-+
-+ if (!fontmap) {
-+ fontmap = pango_ft2_font_map_new ();
-+ pango_ft2_font_map_set_resolution ((PangoFT2FontMap *)fontmap, 72., 72.);
-+ pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, default_substitute, NULL, NULL);
-+ }
-+
-+ return fontmap;
-+}
-+
-+static PangoContext *
-+get_context (void)
-+{
-+ return pango_ft2_font_map_create_context ((PangoFT2FontMap *) get_fontmap ());
-+}
-+
-+// Defines
-+
-+// This is the scaling factor that we keep fonts limited to against
-+// the display size. If a pixel size is requested that is more than
-+// this factor larger than the height of the display, it's clamped to
-+// that value instead of the requested size.
-+#define FONT_MAX_FONT_SCALE 2
-+
-+static NS_DEFINE_CID(kCharsetConverterManagerCID,
-+ NS_ICHARSETCONVERTERMANAGER_CID);
-+
-+#ifdef DEBUG
-+#define DUMP_PRUNICHAR(ustr, ulen) for (PRUint32 llen=0;llen<ulen;llen++) \
-+ printf("0x%x ", ustr[llen]); \
-+ printf("\n");
-+#endif
-+
-+// rounding and truncation functions for a Freetype floating point number
-+// (FT26Dot6) stored in a 32bit integer with high 26 bits for the integer
-+// part and low 6 bits for the fractional part.
-+#define MOZ_FT_ROUND(x) (((x) + 32) & ~63) // 63 = 2^6 - 1
-+#define MOZ_FT_TRUNC(x) ((x) >> 6)
-+#define CONVERT_DESIGN_UNITS_TO_PIXELS(v, s) \
-+ MOZ_FT_TRUNC(MOZ_FT_ROUND(FT_MulFix((v) , (s))))
-+
-+// Static function decls
-+
-+static PangoLanguage *GetPangoLanguage(nsIAtom *aLangGroup);
-+
-+static void FreeGlobals (void);
-+
-+static PangoStyle CalculateStyle (PRUint8 aStyle);
-+static PangoWeight CalculateWeight (PRUint16 aWeight);
-+
-+static nsresult EnumFontsPango (nsIAtom* aLangGroup, const char* aGeneric,
-+ PRUint32* aCount, PRUnichar*** aResult);
-+static int CompareFontNames (const void* aArg1, const void* aArg2,
-+ void* aClosure);
-+
-+nsFontMetricsPSPango::nsFontMetricsPSPango()
-+{
-+ if (!gPangoFontLog)
-+ gPangoFontLog = PR_NewLogModule("PangoFont");
-+
-+ gNumInstances++;
-+
-+ mPangoFontDesc = nsnull;
-+ mPangoContext = nsnull;
-+ mLTRPangoContext = nsnull;
-+ mRTLPangoContext = nsnull;
-+ mPangoAttrList = nsnull;
-+ mIsRTL = PR_FALSE;
-+ mPangoSpaceWidth = 0;
-+
-+ static PRBool initialized = PR_FALSE;
-+ if (initialized)
-+ return;
-+
-+ // Initialized the custom decoders
-+ if (!mozilla_ps_decoders_init(get_fontmap ()))
-+ initialized = PR_TRUE;
-+}
-+
-+nsFontMetricsPSPango::~nsFontMetricsPSPango()
-+{
-+ if (mDeviceContext)
-+ mDeviceContext->FontMetricsDeleted(this);
-+
-+ if (mPangoFontDesc)
-+ pango_font_description_free(mPangoFontDesc);
-+
-+ if (mLTRPangoContext)
-+ g_object_unref(mLTRPangoContext);
-+
-+ if (mRTLPangoContext)
-+ g_object_unref(mRTLPangoContext);
-+
-+ if (mPangoAttrList)
-+ pango_attr_list_unref(mPangoAttrList);
-+
-+ // XXX clean up all the pango objects
-+
-+ if (--gNumInstances == 0)
-+ FreeGlobals();
-+}
-+
-+
-+NS_IMPL_ISUPPORTS1(nsFontMetricsPSPango, nsIFontMetrics)
-+
-+// nsIFontMetrics impl
-+
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::Init(const nsFont& aFont, nsIAtom* aLangGroup,
-+ nsIDeviceContext *aContext)
-+{
-+ mFont = aFont;
-+ mLangGroup = aLangGroup;
-+
-+ // Hang on to the device context
-+ mDeviceContext = aContext;
-+
-+ mPointSize = NSTwipsToFloatPoints(mFont.size);
-+
-+ // enumerate over the font names passed in
-+ mFont.EnumerateFamilies(nsFontMetricsPSPango::EnumFontCallback, this);
-+
-+ nsCOMPtr<nsIPref> prefService;
-+ prefService = do_GetService(NS_PREF_CONTRACTID);
-+ if (!prefService)
-+ return NS_ERROR_FAILURE;
-+
-+ nsXPIDLCString value;
-+ const char* langGroup;
-+ mLangGroup->GetUTF8String(&langGroup);
-+
-+ // Set up the default font name if it's not set
-+ if (!mGenericFont) {
-+ nsCAutoString name("font.default.");
-+ name.Append(langGroup);
-+ prefService->CopyCharPref(name.get(), getter_Copies(value));
-+
-+ if (value.get())
-+ mDefaultFont = value.get();
-+ else
-+ mDefaultFont = "serif";
-+
-+ mGenericFont = &mDefaultFont;
-+ }
-+
-+ // set up the minimum sizes for fonts
-+ if (mLangGroup) {
-+ nsCAutoString name("font.min-size.");
-+
-+ if (mGenericFont->Equals("monospace"))
-+ name.Append("fixed");
-+ else
-+ name.Append("variable");
-+
-+ name.Append(char('.'));
-+ name.Append(langGroup);
-+
-+ PRInt32 minimumInt = 0;
-+ float minimum;
-+ nsresult res;
-+ res = prefService->GetIntPref(name.get(), &minimumInt);
-+ if (NS_FAILED(res))
-+ prefService->GetDefaultIntPref(name.get(), &minimumInt);
-+
-+ if (minimumInt < 0)
-+ minimumInt = 0;
-+
-+ minimum = minimumInt;
-+
-+ // The minimum size is specified in pixels, not in points.
-+ // Convert the size from pixels to points.
-+ minimum = NSTwipsToFloatPoints(NSFloatPixelsToTwips(minimum, mDeviceContext->DevUnitsToAppUnits()));
-+ if (mPointSize < minimum)
-+ mPointSize = minimum;
-+ }
-+
-+ // Make sure that the pixel size is at least greater than zero
-+ if (mPointSize < 1) {
-+#ifdef DEBUG
-+ printf("*** Warning: nsFontMetricsPSPango created with point size %f\n",
-+ mPointSize);
-+#endif
-+ mPointSize = 1;
-+ }
-+
-+ nsresult rv = RealizeFont();
-+ if (NS_FAILED(rv))
-+ return rv;
-+
-+ // Cache font metrics for the 'x' character
-+ return CacheFontMetrics();
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::CacheFontMetrics(void)
-+{
-+ // Get our scale factor
-+ float f;
-+ float val;
-+ f = mDeviceContext->DevUnitsToAppUnits();
-+
-+ mPangoAttrList = pango_attr_list_new();
-+
-+ GList *items = pango_itemize(mPangoContext,
-+ "a", 0, 1, mPangoAttrList, NULL);
-+
-+ if (!items)
-+ return NS_ERROR_FAILURE;
-+
-+ guint nitems = g_list_length(items);
-+ if (nitems != 1)
-+ return NS_ERROR_FAILURE;
-+
-+ PangoItem *item = (PangoItem *)items->data;
-+ PangoFcFont *fcfont = PANGO_FC_FONT(item->analysis.font);
-+ if (!fcfont)
-+ return NS_ERROR_FAILURE;
-+
-+ // Get our font face
-+ FT_Face face;
-+ face = pango_fc_font_lock_face(fcfont);
-+ if (!face)
-+ return NS_ERROR_NOT_AVAILABLE;
-+
-+ TT_OS2 *os2;
-+ os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
-+
-+ // mEmHeight (size in pixels of EM height)
-+ int size;
-+ if (FcPatternGetInteger(fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) !=
-+ FcResultMatch) {
-+ size = 12;
-+ }
-+ mEmHeight = PR_MAX(1, nscoord(size * f));
-+
-+ // mMaxAscent
-+ val = MOZ_FT_TRUNC(face->size->metrics.ascender);
-+ mMaxAscent = NSToIntRound(val * f);
-+
-+ // mMaxDescent
-+ val = -MOZ_FT_TRUNC(face->size->metrics.descender);
-+ mMaxDescent = NSToIntRound(val * f);
-+
-+ nscoord lineHeight = mMaxAscent + mMaxDescent;
-+
-+ // mLeading (needs ascent and descent and EM height)
-+ if (lineHeight > mEmHeight)
-+ mLeading = lineHeight - mEmHeight;
-+ else
-+ mLeading = 0;
-+
-+ // mMaxHeight (needs ascent and descent)
-+ mMaxHeight = lineHeight;
-+
-+ // mEmAscent (needs maxascent, EM height, ascent and descent)
-+ mEmAscent = nscoord(mMaxAscent * mEmHeight / lineHeight);
-+
-+ // mEmDescent (needs EM height and EM ascent
-+ mEmDescent = mEmHeight - mEmAscent;
-+
-+ // mMaxAdvance
-+ val = MOZ_FT_TRUNC(face->size->metrics.max_advance);
-+ mMaxAdvance = NSToIntRound(val * f);
-+
-+ // mPangoSpaceWidth
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+ pango_layout_set_text(layout, " ", 1);
-+ int pswidth, psheight;
-+ pango_layout_get_size(layout, &pswidth, &psheight);
-+ mPangoSpaceWidth = pswidth;
-+ g_object_unref(layout);
-+
-+ // mSpaceWidth (width of a space)
-+ nscoord tmpWidth;
-+ GetWidth(" ", 1, tmpWidth);
-+ mSpaceWidth = tmpWidth;
-+
-+ // mAveCharWidth (width of an 'average' char)
-+ // XftTextExtents16(GDK_DISPLAY(), xftFont, &xUnichar, 1, &extents);
-+ //rawWidth = extents.width;
-+ //mAveCharWidth = NSToCoordRound(rawWidth * f);
-+ GetWidth("x", 1, tmpWidth);
-+ mAveCharWidth = tmpWidth;
-+
-+ // mXHeight (height of an 'x' character)
-+ if (pango_fc_font_has_char(fcfont, 'x')) {
-+ PangoRectangle rect;
-+ PangoGlyph glyph = pango_fc_font_get_glyph (fcfont, 'x');
-+ pango_font_get_glyph_extents (PANGO_FONT (fcfont), glyph, &rect, NULL);
-+ mXHeight = NSToIntRound(rect.height * f / PANGO_SCALE);
-+ }
-+ else {
-+ // 56% of ascent, best guess for non-true type or asian fonts
-+ mXHeight = nscoord(((float)mMaxAscent) * 0.56 * f);
-+ }
-+
-+ // mUnderlineOffset (offset for underlines)
-+ val = CONVERT_DESIGN_UNITS_TO_PIXELS(face->underline_position,
-+ face->size->metrics.y_scale);
-+ if (val) {
-+ mUnderlineOffset = NSToIntRound(val * f);
-+ }
-+ else {
-+ mUnderlineOffset =
-+ -NSToIntRound(PR_MAX(1, floor(0.1 *
-+ MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
-+ }
-+
-+ // mUnderlineSize (thickness of an underline)
-+ val = CONVERT_DESIGN_UNITS_TO_PIXELS(face->underline_thickness,
-+ face->size->metrics.y_scale);
-+ if (val) {
-+ mUnderlineSize = nscoord(PR_MAX(f, NSToIntRound(val * f)));
-+ }
-+ else {
-+ mUnderlineSize =
-+ NSToIntRound(PR_MAX(1,
-+ floor(0.05 * MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
-+ }
-+
-+ // mSuperscriptOffset
-+ if (os2 && os2->ySuperscriptYOffset) {
-+ val = CONVERT_DESIGN_UNITS_TO_PIXELS(os2->ySuperscriptYOffset,
-+ face->size->metrics.y_scale);
-+ mSuperscriptOffset = nscoord(PR_MAX(f, NSToIntRound(val * f)));
-+ }
-+ else {
-+ mSuperscriptOffset = mXHeight;
-+ }
-+
-+ // mSubscriptOffset
-+ if (os2 && os2->ySubscriptYOffset) {
-+ val = CONVERT_DESIGN_UNITS_TO_PIXELS(os2->ySubscriptYOffset,
-+ face->size->metrics.y_scale);
-+ // some fonts have the incorrect sign.
-+ val = (val < 0) ? -val : val;
-+ mSubscriptOffset = nscoord(PR_MAX(f, NSToIntRound(val * f)));
-+ }
-+ else {
-+ mSubscriptOffset = mXHeight;
-+ }
-+
-+ // mStrikeoutOffset
-+ mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
-+
-+ // mStrikeoutSize
-+ mStrikeoutSize = mUnderlineSize;
-+
-+ pango_fc_font_unlock_face(fcfont);
-+
-+ /*
-+ printf("%i\n", mXHeight);
-+ printf("%i\n", mSuperscriptOffset);
-+ printf("%i\n", mSubscriptOffset);
-+ printf("%i\n", mStrikeoutOffset);
-+ printf("%i\n", mStrikeoutSize);
-+ printf("%i\n", mUnderlineOffset);
-+ printf("%i\n", mUnderlineSize);
-+ printf("%i\n", mMaxHeight);
-+ printf("%i\n", mLeading);
-+ printf("%i\n", mEmHeight);
-+ printf("%i\n", mEmAscent);
-+ printf("%i\n", mEmDescent);
-+ printf("%i\n", mMaxAscent);
-+ printf("%i\n", mMaxDescent);
-+ printf("%i\n", mMaxAdvance);
-+ printf("%i\n", mSpaceWidth);
-+ printf("%i\n", mAveCharWidth);
-+ */
-+
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::Destroy()
-+{
-+ mDeviceContext = nsnull;
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetLangGroup(nsIAtom** aLangGroup)
-+{
-+ *aLangGroup = mLangGroup;
-+ NS_IF_ADDREF(*aLangGroup);
-+
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetFontHandle(nsFontHandle &aHandle)
-+{
-+ return NS_ERROR_NOT_IMPLEMENTED;
-+}
-+
-+// nsIFontMetricsPango impl
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength)
-+{
-+ return GetWidth (String, (PRUint32) aLength, aWidth);
-+}
-+
-+NS_IMETHODIMP
-+nsFontMetricsPSPango::GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength)
-+{
-+ return GetWidth (aString, (PRUint32)aLength, aWidth);
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetWidth(const char* aString, PRUint32 aLength,
-+ nscoord& aWidth)
-+{
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ pango_layout_set_text(layout, aString, aLength);
-+
-+ if (mPangoSpaceWidth)
-+ FixupSpaceWidths(layout, aString);
-+
-+ int width, height;
-+
-+ pango_layout_get_size(layout, &width, &height);
-+
-+ g_object_unref(layout);
-+
-+ float f;
-+ f = mDeviceContext->DevUnitsToAppUnits();
-+ aWidth = NSToCoordRound(width * f / PANGO_SCALE);
-+
-+ // printf("GetWidth (char *) %d\n", aWidth);
-+
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetWidth(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord& aWidth)
-+{
-+ nsresult rv = NS_OK;
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ gchar *text = g_utf16_to_utf8(aString, aLength,
-+ NULL, NULL, NULL);
-+
-+ if (!text) {
-+ aWidth = 0;
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetWidth invalid unicode to follow");
-+ DUMP_PRUNICHAR(aString, aLength)
-+#endif
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ gint width, height;
-+
-+ pango_layout_set_text(layout, text, strlen(text));
-+ FixupSpaceWidths(layout, text);
-+ pango_layout_get_size(layout, &width, &height);
-+
-+ float f;
-+ f = mDeviceContext->DevUnitsToAppUnits();
-+ aWidth = NSToCoordRound(width * f / PANGO_SCALE);
-+
-+ // printf("GetWidth %d\n", aWidth);
-+
-+ loser:
-+ g_free(text);
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+
-+nsresult
-+nsFontMetricsPSPango :: GetTextDimensions(const char* aString, PRUint32 aLength,
-+ nsTextDimensions& aDimensions)
-+{
-+ nsresult rv = NS_OK;
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ pango_layout_set_text(layout, aString, aLength);
-+ FixupSpaceWidths(layout,aString);
-+
-+ // Get the logical extents
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ PangoRectangle rect;
-+ pango_layout_line_get_extents(line, NULL, &rect);
-+
-+ float P2T;
-+ P2T = mDeviceContext->DevUnitsToAppUnits();
-+
-+ aDimensions.width = NSToCoordRound(rect.width * P2T / PANGO_SCALE);
-+ aDimensions.ascent = NSToCoordRound(PANGO_ASCENT(rect) * P2T / PANGO_SCALE);
-+ aDimensions.descent = NSToCoordRound(PANGO_DESCENT(rect) * P2T / PANGO_SCALE);
-+
-+ // printf("GetTextDimensions %d %d %d\n", aDimensions.width,
-+ //aDimensions.ascent, aDimensions.descent);
-+
-+ loser:
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetTextDimensions(const PRUnichar* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions,
-+ PRInt32* aFontID)
-+{
-+ nsresult rv = NS_OK;
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ gchar *text = g_utf16_to_utf8(aString, aLength,
-+ NULL, NULL, NULL);
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetTextDimensions invalid unicode to follow");
-+ DUMP_PRUNICHAR(aString, aLength)
-+#endif
-+ aDimensions.width = 0;
-+ aDimensions.ascent = 0;
-+ aDimensions.descent = 0;
-+
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+
-+ pango_layout_set_text(layout, text, strlen(text));
-+ FixupSpaceWidths(layout, text);
-+
-+ // Get the logical extents
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ PangoRectangle rect;
-+ pango_layout_line_get_extents(line, NULL, &rect);
-+
-+ float P2T;
-+ P2T = mDeviceContext->DevUnitsToAppUnits();
-+
-+ aDimensions.width = NSToCoordRound(rect.width * P2T / PANGO_SCALE);
-+ aDimensions.ascent = NSToCoordRound(PANGO_ASCENT(rect) * P2T / PANGO_SCALE);
-+ aDimensions.descent = NSToCoordRound(PANGO_DESCENT(rect) * P2T / PANGO_SCALE);
-+
-+ // printf("GetTextDimensions %d %d %d\n", aDimensions.width,
-+ //aDimensions.ascent, aDimensions.descent);
-+
-+ loser:
-+ g_free(text);
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetTextDimensions(const char* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID)
-+{
-+
-+ return GetTextDimensionsInternal(aString, aLength, aAvailWidth, aBreaks,
-+ aNumBreaks, aDimensions, aNumCharsFit,
-+ aLastWordDimensions);
-+
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetTextDimensions(const PRUnichar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID)
-+{
-+ nsresult rv = NS_OK;
-+ PRInt32 curBreak = 0;
-+ gchar *curChar;
-+
-+ PRInt32 *utf8Breaks = new PRInt32[aNumBreaks];
-+
-+ gchar *text = g_utf16_to_utf8(aString, (PRInt32)aLength,
-+ NULL, NULL, NULL);
-+
-+ curChar = text;
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetWidth invalid unicode to follow");
-+ DUMP_PRUNICHAR(aString, (PRUint32)aLength)
-+#endif
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ // Covert the utf16 break offsets to utf8 break offsets
-+ for (PRInt32 curOffset=0; curOffset < aLength;
-+ curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+ if (aBreaks[curBreak] == curOffset) {
-+ utf8Breaks[curBreak] = curChar - text;
-+ curBreak++;
-+ }
-+
-+ if (IS_HIGH_SURROGATE(aString[curOffset]))
-+ curOffset++;
-+ }
-+
-+ // Always catch the last break
-+ utf8Breaks[curBreak] = curChar - text;
-+
-+#if 0
-+ if (strlen(text) != aLength) {
-+ printf("Different lengths for utf16 %d and utf8 %d\n", aLength, strlen(text));
-+ DUMP_PRUNICHAR(aString, aLength)
-+ DUMP_PRUNICHAR(text, strlen(text))
-+ for (PRInt32 i = 0; i < aNumBreaks; ++i) {
-+ printf(" break %d utf16 %d utf8 %d\n", i, aBreaks[i], utf8Breaks[i]);
-+ }
-+ }
-+#endif
-+
-+ // We'll use curBreak to indicate which of the breaks end up being
-+ // used for the break point for this line.
-+ curBreak = 0;
-+ rv = GetTextDimensionsInternal(text, strlen(text), aAvailWidth, utf8Breaks,
-+ aNumBreaks, aDimensions, aNumCharsFit,
-+ aLastWordDimensions);
-+
-+ // Figure out which of the breaks we ended up using to convert
-+ // back to utf16 - start from the end.
-+ for (PRInt32 i = aNumBreaks - 1; i >= 0; --i) {
-+ if (utf8Breaks[i] == aNumCharsFit) {
-+ // if (aNumCharsFit != aBreaks[i])
-+ // printf("Fixing utf8 -> utf16 %d -> %d\n", aNumCharsFit, aBreaks[i]);
-+ aNumCharsFit = aBreaks[i];
-+ break;
-+ }
-+ }
-+
-+ loser:
-+ if (text)
-+ g_free(text);
-+
-+ delete[] utf8Breaks;
-+
-+ return rv;
-+}
-+
-+typedef struct _nsPSPangoRenderer nsPSPangoRenderer;
-+typedef struct _nsPSPangoRendererClass nsPSPangoRendererClass;
-+
-+struct _nsPSPangoRenderer
-+{
-+ PangoRenderer parent_instance;
-+ nsRenderingContextPS *psContext;
-+ nsFontMetricsPSPango *psPangoFontMetrics;
-+ float zoom;
-+};
-+
-+struct _nsPSPangoRendererClass
-+{
-+ PangoRendererClass parent_class;
-+};
-+
-+#define _PS_TYPE_PANGO_RENDERER (_ps_pango_renderer_get_type())
-+#define _PS_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRenderer))
-+#define _PS_IS_PANGO_RENDERER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), _PS_TYPE_PANGO_RENDERER))
-+#define _PS_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRendererClass))
-+#define _PS_IS_PANGO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), _PS_TYPE_PANGO_RENDERER))
-+#define _PS_PANGO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), _PS_TYPE_PANGO_RENDERER, _nsPSPangoRendererClass))
-+
-+G_DEFINE_TYPE (_nsPSPangoRenderer, _ps_pango_renderer, PANGO_TYPE_RENDERER)
-+
-+static PangoRenderer *
-+get_renderer (void)
-+{
-+ static PangoRenderer *renderer = NULL;
-+
-+ if (!renderer)
-+ renderer = (PangoRenderer *) g_object_new (_PS_TYPE_PANGO_RENDERER, NULL);
-+
-+ return renderer;
-+}
-+
-+static void
-+_ps_pango_renderer_draw_glyphs (PangoRenderer *renderer,
-+ PangoFont *font,
-+ PangoGlyphString *glyphs,
-+ int x,
-+ int y);
-+
-+static void
-+_ps_pango_renderer_class_init (nsPSPangoRendererClass *klass)
-+{
-+ PangoRendererClass *renderer_class = PANGO_RENDERER_CLASS (klass);
-+
-+ renderer_class->draw_glyphs = _ps_pango_renderer_draw_glyphs;
-+}
-+
-+static void
-+_ps_pango_renderer_init (nsPSPangoRenderer *renderer)
-+{
-+}
-+
-+class nsPangoType1Generator : public nsPSFontGenerator {
-+public:
-+ nsPangoType1Generator();
-+ ~nsPangoType1Generator();
-+ nsresult Init(PangoFont *aFont);
-+ void GeneratePSFont(FILE* aFile);
-+
-+protected:
-+ PangoFont *mFont;
-+};
-+
-+nsPangoType1Generator::nsPangoType1Generator()
-+{
-+}
-+
-+nsresult
-+nsPangoType1Generator::Init(PangoFont *aFont)
-+{
-+ NS_ENSURE_TRUE(aFont, NS_ERROR_FAILURE);
-+ mFont = aFont;
-+ g_object_ref (mFont);
-+ return NS_OK;
-+}
-+
-+nsPangoType1Generator::~nsPangoType1Generator()
-+{
-+ g_object_unref (mFont);
-+ mFont = nsnull;
-+}
-+
-+void nsPangoType1Generator::GeneratePSFont(FILE* aFile)
-+{
-+ FT_Face face = pango_fc_font_lock_face ((PangoFcFont *) mFont);
-+
-+ if (face == nsnull)
-+ return;
-+
-+ int wmode = 0;
-+ if (mGlyphSubset->Count())
-+ FT2SubsetToType1FontSet(face, mGlyphSubset, wmode, aFile);
-+
-+ pango_fc_font_unlock_face ((PangoFcFont *) mFont);
-+}
-+
-+typedef struct
-+{
-+ nsCString *FontNameBase;
-+ nsCStringKey *key;
-+ int font_size;
-+} PSPangoFontData;
-+
-+static void
-+ps_pango_font_data_destroy (PSPangoFontData *data)
-+{
-+ delete data->key;
-+ delete data->FontNameBase;
-+ g_free (data);
-+}
-+
-+static void
-+flattenName(nsCString& aString)
-+{
-+ nsCString::iterator start, end;
-+ aString.BeginWriting(start);
-+ aString.EndWriting(end);
-+ while(start != end) {
-+ if (*start == ' ')
-+ *start= '_';
-+ else if (*start == '(')
-+ *start = '_';
-+ else if (*start == ')')
-+ *start = '_';
-+ ++start;
-+ }
-+}
-+
-+static void
-+_ps_pango_renderer_draw_glyphs (PangoRenderer *renderer,
-+ PangoFont *font,
-+ PangoGlyphString *glyphs,
-+ int x,
-+ int y)
-+{
-+ if (!glyphs->num_glyphs)
-+ return;
-+
-+ static GQuark data_quark = 0;
-+ if (!data_quark)
-+ data_quark = g_quark_from_static_string ("ps-pango-font-data");
-+
-+ PSPangoFontData *data;
-+ if (!(data = (PSPangoFontData *) g_object_get_qdata (G_OBJECT (font), data_quark)))
-+ {
-+ data = g_new (PSPangoFontData, 1);
-+
-+ FT_Face face = pango_fc_font_lock_face ((PangoFcFont *) font);
-+ if (face == nsnull)
-+ return;
-+ int wmode = 0;
-+ data->FontNameBase = new nsCString ();
-+ if (NS_FAILED(FT2ToType1FontName(face, wmode, *data->FontNameBase))) {
-+ g_free (data);
-+ pango_fc_font_unlock_face ((PangoFcFont *) font);
-+ return;
-+ }
-+ pango_fc_font_unlock_face ((PangoFcFont *) font);
-+
-+ PangoFontDescription *desc = pango_font_describe (font);
-+ data->font_size = pango_font_description_get_size (desc);
-+ pango_font_description_free (desc);
-+
-+ data->key = new nsCStringKey (*data->FontNameBase);
-+
-+ g_object_set_qdata_full (G_OBJECT (font), data_quark, data, (GDestroyNotify) ps_pango_font_data_destroy);
-+ }
-+
-+ nsPSPangoRenderer *ps_renderer = (nsPSPangoRenderer *)renderer;
-+ nsRenderingContextPS *aContext = ps_renderer->psContext;
-+ nsFontMetricsPSPango *metrics = ps_renderer->psPangoFontMetrics;
-+ nsDeviceContextPS* dc = NS_REINTERPRET_CAST (nsDeviceContextPS*, metrics->GetDeviceContext());
-+ nsPostScriptObj* psObj = aContext->GetPostScriptObj();
-+ nsHashtable *psFGList = dc->GetPSFontGeneratorList();
-+ g_return_if_fail (psFGList);
-+ nsPSFontGenerator* psFontGen = (nsPSFontGenerator*) psFGList->Get(data->key);
-+ if (!psFontGen) {
-+ nsresult rv;
-+ psFontGen = new nsPangoType1Generator;
-+ g_return_if_fail (psFontGen);
-+ rv = ((nsPangoType1Generator*)psFontGen)->Init(font);
-+ if (NS_FAILED(rv)) {
-+ delete psFontGen;
-+ return;
-+ }
-+ psFGList->Put(data->key, (void *) psFontGen);
-+ }
-+ nscoord font_size = NSToCoordRound (ps_renderer->zoom * data->font_size / PANGO_SCALE);
-+
-+ g_return_if_fail (aContext);
-+ g_return_if_fail (psObj);
-+
-+ nscoord aX = NSToCoordRound(ps_renderer->zoom * x / PANGO_SCALE);
-+ nscoord aY = NSToCoordRound(ps_renderer->zoom * y / PANGO_SCALE);
-+ psObj->moveto(aX, aY);
-+
-+ PRInt32 currSubFont, prevSubFont = -1;
-+ PRUint32 i;
-+ PangoGlyphString gl;
-+
-+ gl.glyphs = glyphs->glyphs;
-+ gl.num_glyphs = 0;
-+ for (i = 0; i < glyphs->num_glyphs; ++i) {
-+ currSubFont = psFontGen->AddToGlyphSubset(glyphs->glyphs[i].glyph >= 0x00ffffff ? 0 : glyphs->glyphs[i].glyph);
-+ if (prevSubFont != currSubFont) {
-+ if (prevSubFont != -1)
-+ psObj->show(&gl, ps_renderer->zoom, psFontGen, prevSubFont);
-+
-+
-+ psObj->setfont(*data->FontNameBase, (PRUint32) font_size, currSubFont);
-+ prevSubFont = currSubFont;
-+ gl.glyphs = glyphs->glyphs + i;
-+ gl.num_glyphs = 0;
-+ }
-+
-+ gl.num_glyphs++;
-+ }
-+
-+ if (prevSubFont != -1)
-+ psObj->show(&gl, ps_renderer->zoom, psFontGen, prevSubFont);
-+}
-+
-+static void
-+draw_layout_line (int x, int y, PangoLayoutLine *line, nsFontMetricsPSPango *aPSPangoFontMetrics, nsRenderingContextPS *aContext)
-+{
-+ PangoRenderer *renderer = get_renderer ();
-+ nsPSPangoRenderer *ps_renderer = (nsPSPangoRenderer *)renderer;
-+ ps_renderer->psContext = aContext;
-+ ps_renderer->psPangoFontMetrics = aPSPangoFontMetrics;
-+ nsDeviceContextPS* dc = NS_REINTERPRET_CAST (nsDeviceContextPS*, aPSPangoFontMetrics->GetDeviceContext());
-+ ps_renderer->zoom = dc->DevUnitsToAppUnits();
-+
-+ pango_renderer_draw_layout_line (renderer, line,
-+ NSToCoordRound (x * PANGO_SCALE / ps_renderer->zoom),
-+ NSToCoordRound (y * PANGO_SCALE / ps_renderer->zoom));
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ pango_layout_set_text(layout, aString, aLength);
-+ FixupSpaceWidths(layout, aString);
-+
-+ int x = aX;
-+ int y = aY;
-+
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ if (aSpacing && *aSpacing) {
-+ DrawStringSlowly(aString, NULL, aLength, x, y, line, aSpacing, aContext);
-+ }
-+ else {
-+ draw_layout_line (x, y, line, this, aContext);
-+ }
-+
-+ g_object_unref(layout);
-+
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ PRInt32 aFontID,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ nsresult rv = NS_OK;
-+ int x = aX;
-+ int y = aY;
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ gchar *text = g_utf16_to_utf8(aString, aLength,
-+ NULL, NULL, NULL);
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::DrawString invalid unicode to follow");
-+ DUMP_PRUNICHAR(aString, aLength)
-+#endif
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ pango_layout_set_text(layout, text, strlen(text));
-+ FixupSpaceWidths(layout, text);
-+
-+ aContext->GetTranMatrix()->TransformCoord(&x, &y);
-+
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ if (aSpacing && *aSpacing) {
-+ DrawStringSlowly(text, aString, aLength, x, y, line, aSpacing, aContext);
-+ }
-+ else {
-+ draw_layout_line (x, y, line, this, aContext);
-+ }
-+
-+ loser:
-+
-+ g_free(text);
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+#ifdef MOZ_MATHML
-+nsresult
-+nsFontMetricsPSPango::GetBoundingMetrics(const char *aString, PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics)
-+{
-+ printf("GetBoundingMetrics (char *)\n");
-+ return NS_ERROR_FAILURE;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetBoundingMetrics(const PRUnichar *aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics,
-+ PRInt32 *aFontID)
-+{
-+ nsresult rv = NS_OK;
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ gchar *text = g_utf16_to_utf8(aString, aLength,
-+ NULL, NULL, NULL);
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetBoundingMetrics invalid unicode to follow");
-+ DUMP_PRUNICHAR(aString, aLength)
-+#endif
-+ aBoundingMetrics.leftBearing = 0;
-+ aBoundingMetrics.rightBearing = 0;
-+ aBoundingMetrics.width = 0;
-+ aBoundingMetrics.ascent = 0;
-+ aBoundingMetrics.descent = 0;
-+
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ pango_layout_set_text(layout, text, -1);
-+ FixupSpaceWidths(layout, text);
-+
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ // Get the ink and logical extents
-+ PangoRectangle ink, logical;
-+ pango_layout_line_get_extents(line, &ink, &logical);
-+
-+ float P2T;
-+ P2T = mDeviceContext->DevUnitsToAppUnits();
-+
-+ aBoundingMetrics.leftBearing = NSToCoordRound(PANGO_LBEARING(ink) * P2T / PANGO_SCALE);
-+ aBoundingMetrics.rightBearing = NSToCoordRound(PANGO_RBEARING(ink) * P2T / PANGO_SCALE);
-+ aBoundingMetrics.ascent = NSToCoordRound(PANGO_ASCENT(ink) * P2T / PANGO_SCALE);
-+ aBoundingMetrics.descent = NSToCoordRound(PANGO_DESCENT(ink) * P2T / PANGO_SCALE);
-+ aBoundingMetrics.width = NSToCoordRound(logical.width * P2T / PANGO_SCALE);
-+
-+ loser:
-+ g_free(text);
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+#endif /* MOZ_MATHML */
-+
-+nsresult
-+nsFontMetricsPSPango::SetRightToLeftText(PRBool aIsRTL)
-+{
-+ if (aIsRTL) {
-+ if (!mRTLPangoContext) {
-+ mRTLPangoContext = get_context();
-+ pango_context_set_base_dir(mRTLPangoContext, PANGO_DIRECTION_RTL);
-+
-+ pango_context_set_language(mRTLPangoContext, GetPangoLanguage(mLangGroup));
-+ pango_context_set_font_description(mRTLPangoContext, mPangoFontDesc);
-+ }
-+ mPangoContext = mRTLPangoContext;
-+ }
-+ else {
-+ mPangoContext = mLTRPangoContext;
-+ }
-+
-+ mIsRTL = aIsRTL;
-+ return NS_OK;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetClusterInfo(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PRUint8 *aClusterStarts)
-+{
-+ nsresult rv = NS_OK;
-+ PangoLogAttr *attrs = NULL;
-+ gint n_attrs = 0;
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ // Convert the incoming UTF-16 to UTF-8
-+ gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetWidth invalid unicode to follow");
-+ DUMP_PRUNICHAR(aText, aLength)
-+#endif
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ // Set up the pango layout
-+ pango_layout_set_text(layout, text, strlen(text));
-+ FixupSpaceWidths(layout, text);
-+
-+ // Convert back to UTF-16 while filling in the cluster info
-+ // structure.
-+ pango_layout_get_log_attrs(layout, &attrs, &n_attrs);
-+
-+ for (PRUint32 pos = 0; pos < aLength; pos++) {
-+ if (IS_HIGH_SURROGATE(aText[pos])) {
-+ aClusterStarts[pos] = 1;
-+ pos++;
-+ }
-+ else {
-+ aClusterStarts[pos] = attrs[pos].is_cursor_position;
-+ }
-+ }
-+
-+ loser:
-+ if (attrs)
-+ g_free(attrs);
-+ if (text)
-+ g_free(text);
-+ if (layout)
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+PRInt32
-+nsFontMetricsPSPango::GetPosition(const PRUnichar *aText, PRUint32 aLength,
-+ nsPoint aPt)
-+{
-+ int trailing = 0;
-+ int inx = 0;
-+ const gchar *curChar;
-+ PRInt32 retval = 0;
-+
-+ float f = mDeviceContext->AppUnitsToDevUnits();
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+ PRUint32 localX = (PRUint32)(aPt.x * PANGO_SCALE * f);
-+ PRUint32 localY = (PRUint32)(aPt.y * PANGO_SCALE * f);
-+
-+ // Convert the incoming UTF-16 to UTF-8
-+ gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetWidth invalid unicode to follow");
-+ DUMP_PRUNICHAR(aText, aLength)
-+#endif
-+ retval = -1;
-+ goto loser;
-+ }
-+
-+ // Set up the pango layout
-+ pango_layout_set_text(layout, text, strlen(text));
-+ FixupSpaceWidths(layout, text);
-+
-+ pango_layout_xy_to_index(layout, localX, localY,
-+ &inx, &trailing);
-+
-+ // Convert the index back to the utf-16 index
-+ curChar = text;
-+
-+ for (PRUint32 curOffset=0; curOffset < aLength;
-+ curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+
-+ // Check for a match before checking for a surrogate pair
-+ if (curChar - text == inx) {
-+ retval = curOffset;
-+ break;
-+ }
-+
-+ if (IS_HIGH_SURROGATE(aText[curOffset]))
-+ curOffset++;
-+ }
-+
-+ // If there was a trailing result, advance the index pointer the
-+ // number of characters equal to the trailing result.
-+ while (trailing) {
-+ retval++;
-+ // Yes, this can make aInx > length to indicate the end of the
-+ // string.
-+ if (retval < (PRInt32)aLength && IS_HIGH_SURROGATE(aText[retval]))
-+ retval++;
-+ trailing--;
-+ }
-+
-+ loser:
-+ if (text)
-+ g_free(text);
-+ if (layout)
-+ g_object_unref(layout);
-+
-+ return retval;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetRangeWidth(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
-+ PRUint32 &aWidth)
-+{
-+ nsresult rv = NS_OK;
-+ PRUint32 utf8Start = 0;
-+ PRUint32 utf8End = 0;
-+
-+ aWidth = 0;
-+
-+ // Convert the incoming UTF-16 to UTF-8
-+ gchar *text = g_utf16_to_utf8(aText, aLength, NULL, NULL, NULL);
-+ gchar *curChar = text;
-+
-+ if (!text) {
-+#ifdef DEBUG
-+ NS_WARNING("nsFontMetricsPSPango::GetWidth invalid unicode to follow");
-+ DUMP_PRUNICHAR(aText, aLength)
-+#endif
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ // Convert the utf16 offsets into utf8 offsets
-+ for (PRUint32 curOffset = 0; curOffset < aLength;
-+ curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+
-+ if (curOffset == aStart)
-+ utf8Start = curChar - text;
-+
-+ if (curOffset == aEnd)
-+ utf8End = curChar - text;
-+
-+ if (IS_HIGH_SURROGATE(aText[curOffset]))
-+ curOffset++;
-+ }
-+
-+ // Special case where the end index is the same as the length
-+ if (aLength == aEnd)
-+ utf8End = strlen(text);
-+
-+ rv = GetRangeWidth(text, strlen(text), utf8Start, utf8End, aWidth);
-+
-+ loser:
-+ if (text)
-+ g_free(text);
-+
-+ return rv;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetRangeWidth(const char *aText,
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
-+ PRUint32 &aWidth)
-+{
-+ nsresult rv = NS_OK;
-+ int *ranges = NULL;
-+ int n_ranges = 0;
-+ float f;
-+
-+ aWidth = 0;
-+
-+ PangoLayout *layout = pango_layout_new(mPangoContext);
-+
-+ if (!aText) {
-+ rv = NS_ERROR_FAILURE;
-+ goto loser;
-+ }
-+
-+ pango_layout_set_text(layout, aText, aLength);
-+ FixupSpaceWidths(layout, aText);
-+
-+ PangoLayoutLine *line;
-+ if (pango_layout_get_line_count(layout) != 1) {
-+ printf("Warning: more than one line!\n");
-+ }
-+ line = pango_layout_get_line(layout, 0);
-+
-+ pango_layout_line_get_x_ranges(line, aStart, aEnd, &ranges, &n_ranges);
-+
-+ aWidth = (ranges[((n_ranges - 1) * 2) + 1] - ranges[0]);
-+
-+ f = mDeviceContext-> DevUnitsToAppUnits();
-+ aWidth = nscoord(aWidth * f / PANGO_SCALE);
-+
-+ loser:
-+ if (ranges)
-+ g_free(ranges);
-+ if (layout)
-+ g_object_unref(layout);
-+
-+ return rv;
-+}
-+
-+PRUint32
-+nsFontMetricsPSPango::GetHints(void)
-+{
-+ return (NS_RENDERING_HINT_BIDI_REORDERING |
-+ NS_RENDERING_HINT_ARABIC_SHAPING |
-+ NS_RENDERING_HINT_FAST_MEASURE |
-+ NS_RENDERING_HINT_REORDER_SPACED_TEXT |
-+ NS_RENDERING_HINT_TEXT_CLUSTERS);
-+}
-+
-+/* static */
-+nsresult
-+nsFontMetricsPSPango::FamilyExists(nsIDeviceContext *aDevice,
-+ const nsString &aName)
-+{
-+ // fontconfig family name is always in UTF-8
-+ NS_ConvertUTF16toUTF8 name(aName);
-+
-+ nsresult rv = NS_ERROR_FAILURE;
-+ PangoContext *context = get_context();
-+ PangoFontFamily **familyList;
-+ int n;
-+
-+ pango_context_list_families(context, &familyList, &n);
-+
-+ for (int i=0; i < n; i++) {
-+ const char *tmpname = pango_font_family_get_name(familyList[i]);
-+ if (!Compare(nsDependentCString(tmpname), name,
-+ nsCaseInsensitiveCStringComparator())) {
-+ rv = NS_OK;
-+ break;
-+ }
-+ }
-+
-+ g_free(familyList);
-+ g_object_unref(context);
-+
-+ return rv;
-+}
-+
-+// Private Methods
-+
-+nsresult
-+nsFontMetricsPSPango::RealizeFont(void)
-+{
-+ nsCString familyList;
-+ // Create and fill out the font description.
-+ mPangoFontDesc = pango_font_description_new();
-+
-+ // Add CSS names - walk the list of fonts, adding the generic as
-+ // the last font
-+ for (int i=0; i < mFontList.Count(); ++i) {
-+ // if this was a generic name, break out of the loop since we
-+ // don't want to add it to the pattern yet
-+ if (mFontIsGeneric[i])
-+ break;;
-+
-+ nsCString *familyName = mFontList.CStringAt(i);
-+ familyList.Append(familyName->get());
-+ familyList.Append(',');
-+ }
-+
-+ // If there's a generic add a pref for the generic if there's one
-+ // set.
-+ if (mGenericFont && !mFont.systemFont) {
-+ nsCString name;
-+ name += "font.name.";
-+ name += mGenericFont->get();
-+ name += ".";
-+
-+ nsString langGroup;
-+ mLangGroup->ToString(langGroup);
-+
-+ name.AppendWithConversion(langGroup);
-+
-+ nsCOMPtr<nsIPref> pref;
-+ pref = do_GetService(NS_PREF_CONTRACTID);
-+ if (pref) {
-+ nsresult rv;
-+ nsXPIDLCString value;
-+ rv = pref->GetCharPref(name.get(), getter_Copies(value));
-+
-+ // we ignore prefs that have three hypens since they are X
-+ // style prefs.
-+ if (NS_FFRECountHyphens(value) < 3) {
-+ nsCString tmpstr;
-+ tmpstr.Append(value);
-+
-+ familyList.Append(tmpstr);
-+ familyList.Append(',');
-+ }
-+ }
-+ }
-+
-+ // Add the generic if there is one.
-+ if (mGenericFont && !mFont.systemFont) {
-+ familyList.Append(mGenericFont->get());
-+ familyList.Append(',');
-+ }
-+
-+ // Set the family
-+ pango_font_description_set_family(mPangoFontDesc,
-+ familyList.get());
-+
-+ // Set the point size
-+ pango_font_description_set_size(mPangoFontDesc,
-+ (gint)(mPointSize * PANGO_SCALE));
-+
-+ // Set the style
-+ pango_font_description_set_style(mPangoFontDesc,
-+ CalculateStyle(mFont.style));
-+
-+ // Set the weight
-+ pango_font_description_set_weight(mPangoFontDesc,
-+ CalculateWeight(mFont.weight));
-+
-+ // Now that we have the font description set up, create the
-+ // context.
-+ mLTRPangoContext = get_context();
-+ mPangoContext = mLTRPangoContext;
-+
-+ // Make sure to set the base direction to LTR - if layout needs to
-+ // render RTL text it will use ::SetRightToLeftText()
-+ pango_context_set_base_dir(mPangoContext, PANGO_DIRECTION_LTR);
-+
-+ // Set the pango language now that we have a context
-+ pango_context_set_language(mPangoContext, GetPangoLanguage(mLangGroup));
-+
-+ // And attach the font description to this context
-+ pango_context_set_font_description(mPangoContext, mPangoFontDesc);
-+
-+ return NS_OK;
-+}
-+
-+/* static */
-+PRBool
-+nsFontMetricsPSPango::EnumFontCallback(const nsString &aFamily,
-+ PRBool aIsGeneric, void *aData)
-+{
-+ NS_ConvertUTF16toUTF8 name(aFamily);
-+
-+ // The newest fontconfig does the full Unicode case folding so that
-+ // we're being lazy here by calling |ToLowerCase| after converting
-+ // to UTF-8 assuming that in virtually all cases, we just have to
-+ // fold [A-Z]. (bug 223653).
-+ ToLowerCase(name);
-+ nsFontMetricsPSPango *metrics = (nsFontMetricsPSPango *)aData;
-+ metrics->mFontList.AppendCString(name);
-+ metrics->mFontIsGeneric.AppendElement((void *)aIsGeneric);
-+ if (aIsGeneric) {
-+ metrics->mGenericFont =
-+ metrics->mFontList.CStringAt(metrics->mFontList.Count() - 1);
-+ return PR_FALSE; // stop processing
-+ }
-+
-+ return PR_TRUE; // keep processing
-+}
-+
-+/*
-+ * This is only used when there's per-character spacing happening.
-+ * Well, really it can be either line or character spacing but it's
-+ * just turtles all the way down!
-+ */
-+
-+void
-+nsFontMetricsPSPango::DrawStringSlowly(const gchar *aText,
-+ const PRUnichar *aOrigString,
-+ PRUint32 aLength,
-+ gint aX, gint aY,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing,
-+ nsRenderingContextPS *aContext)
-+{
-+ float app2dev;
-+ app2dev = mDeviceContext->AppUnitsToDevUnits();
-+ gint offset = 0;
-+
-+ /*
-+ * We walk the list of glyphs returned in each layout run,
-+ * matching up the glyphs with the characters in the source text.
-+ * We use the aSpacing argument to figure out where to place those
-+ * glyphs. It's important to note that since the string we're
-+ * working with is in UTF-8 while the spacing argument assumes
-+ * that offset will be part of the UTF-16 string. Logical
-+ * attributes in pango are in byte offsets in the UTF-8 string, so
-+ * we need to store the offsets based on the UTF-8 string.
-+ */
-+ nscoord *utf8spacing = new nscoord[strlen(aText)];
-+
-+ if (aOrigString) {
-+ const gchar *curChar = aText;
-+ bzero(utf8spacing, sizeof(nscoord) * strlen(aText));
-+
-+ // Covert the utf16 spacing offsets to utf8 spacing offsets
-+ for (PRUint32 curOffset=0; curOffset < aLength;
-+ curOffset++, curChar = g_utf8_find_next_char(curChar, NULL)) {
-+ utf8spacing[curChar - aText] = aSpacing[curOffset];
-+
-+ if (IS_HIGH_SURROGATE(aOrigString[curOffset]))
-+ curOffset++;
-+ }
-+ }
-+ else {
-+ memcpy(utf8spacing, aSpacing, (sizeof(nscoord *) * aLength));
-+ }
-+
-+ gint curRun = 0;
-+
-+ for (GSList *tmpList = aLine->runs; tmpList && tmpList->data;
-+ tmpList = tmpList->next, curRun++) {
-+ PangoLayoutRun *layoutRun = (PangoLayoutRun *)tmpList->data;
-+ gint tmpOffset = 0;
-+
-+ /* printf(" Rendering run %d: \"%s\"\n", curRun,
-+ &aText[layoutRun->item->offset]); */
-+
-+ for (gint i=0; i < layoutRun->glyphs->num_glyphs; i++) {
-+ /* printf("glyph %d offset %d orig width %d new width %d\n", i,
-+ * layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset,
-+ * layoutRun->glyphs->glyphs[i].geometry.width,
-+ * (gint)(utf8spacing[layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset] * app2dev * PANGO_SCALE));
-+ */
-+ gint thisOffset = (gint)(utf8spacing[layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset]
-+ * app2dev * PANGO_SCALE);
-+ layoutRun->glyphs->glyphs[i].geometry.width = thisOffset;
-+ tmpOffset += thisOffset;
-+ }
-+
-+ /* printf(" rendering at X coord %d\n", aX + offset); */
-+ offset += tmpOffset;
-+ }
-+
-+ draw_layout_line (aX, aY, aLine, this, aContext);
-+
-+ delete[] utf8spacing;
-+}
-+
-+nsresult
-+nsFontMetricsPSPango::GetTextDimensionsInternal(const gchar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions)
-+{
-+ NS_PRECONDITION(aBreaks[aNumBreaks - 1] == aLength, "invalid break array");
-+
-+ // If we need to back up this state represents the last place
-+ // we could break. We can use this to avoid remeasuring text
-+ PRInt32 prevBreakState_BreakIndex = -1; // not known
-+ // (hasn't been computed)
-+ nscoord prevBreakState_Width = 0; // accumulated width to this point
-+
-+ // Initialize OUT parameters
-+ GetMaxAscent(aLastWordDimensions.ascent);
-+ GetMaxDescent(aLastWordDimensions.descent);
-+ aLastWordDimensions.width = -1;
-+ aNumCharsFit = 0;
-+
-+ // Iterate each character in the string and determine which font to use
-+ nscoord width = 0;
-+ PRInt32 start = 0;
-+ nscoord aveCharWidth;
-+ GetAveCharWidth(aveCharWidth);
-+
-+ while (start < aLength) {
-+ // Estimate how many characters will fit. Do that by
-+ // diving the available space by the average character
-+ // width. Make sure the estimated number of characters is
-+ // at least 1
-+ PRInt32 estimatedNumChars = 0;
-+
-+ if (aveCharWidth > 0)
-+ estimatedNumChars = (aAvailWidth - width) / aveCharWidth;
-+
-+ if (estimatedNumChars < 1)
-+ estimatedNumChars = 1;
-+
-+ // Find the nearest break offset
-+ PRInt32 estimatedBreakOffset = start + estimatedNumChars;
-+ PRInt32 breakIndex;
-+ nscoord numChars;
-+
-+ // Find the nearest place to break that is less than or equal to
-+ // the estimated break offset
-+ if (aLength <= estimatedBreakOffset) {
-+ // All the characters should fit
-+ numChars = aLength - start;
-+ breakIndex = aNumBreaks - 1;
-+ }
-+ else {
-+ breakIndex = prevBreakState_BreakIndex;
-+ while (((breakIndex + 1) < aNumBreaks) &&
-+ (aBreaks[breakIndex + 1] <= estimatedBreakOffset)) {
-+ ++breakIndex;
-+ }
-+
-+ if (breakIndex == prevBreakState_BreakIndex) {
-+ ++breakIndex; // make sure we advanced past the
-+ // previous break index
-+ }
-+
-+ numChars = aBreaks[breakIndex] - start;
-+ }
-+
-+ // Measure the text
-+ nscoord twWidth = 0;
-+ if ((1 == numChars) && (aString[start] == ' '))
-+ GetSpaceWidth(twWidth);
-+ else if (numChars > 0)
-+ GetWidth(&aString[start], numChars, twWidth);
-+
-+ // See if the text fits
-+ PRBool textFits = (twWidth + width) <= aAvailWidth;
-+
-+ // If the text fits then update the width and the number of
-+ // characters that fit
-+ if (textFits) {
-+ aNumCharsFit += numChars;
-+ width += twWidth;
-+ start += numChars;
-+
-+ // This is a good spot to back up to if we need to so remember
-+ // this state
-+ prevBreakState_BreakIndex = breakIndex;
-+ prevBreakState_Width = width;
-+ }
-+ else {
-+ // See if we can just back up to the previous saved
-+ // state and not have to measure any text
-+ if (prevBreakState_BreakIndex > 0) {
-+ // If the previous break index is just before the
-+ // current break index then we can use it
-+ if (prevBreakState_BreakIndex == (breakIndex - 1)) {
-+ aNumCharsFit = aBreaks[prevBreakState_BreakIndex];
-+ width = prevBreakState_Width;
-+ break;
-+ }
-+ }
-+
-+ // We can't just revert to the previous break state
-+ if (0 == breakIndex) {
-+ // There's no place to back up to, so even though
-+ // the text doesn't fit return it anyway
-+ aNumCharsFit += numChars;
-+ width += twWidth;
-+ break;
-+ }
-+
-+ // Repeatedly back up until we get to where the text
-+ // fits or we're all the way back to the first word
-+ width += twWidth;
-+ while ((breakIndex >= 1) && (width > aAvailWidth)) {
-+ twWidth = 0;
-+ start = aBreaks[breakIndex - 1];
-+ numChars = aBreaks[breakIndex] - start;
-+
-+ if ((1 == numChars) && (aString[start] == ' '))
-+ GetSpaceWidth(twWidth);
-+ else if (numChars > 0)
-+ GetWidth(&aString[start], numChars, twWidth);
-+ width -= twWidth;
-+ aNumCharsFit = start;
-+ breakIndex--;
-+ }
-+ break;
-+ }
-+ }
-+
-+ aDimensions.width = width;
-+ GetMaxAscent(aDimensions.ascent);
-+ GetMaxDescent(aDimensions.descent);
-+
-+ /* printf("aDimensions %d %d %d aLastWordDimensions %d %d %d aNumCharsFit %d\n",
-+ aDimensions.width, aDimensions.ascent, aDimensions.descent,
-+ aLastWordDimensions.width, aLastWordDimensions.ascent, aLastWordDimensions.descent,
-+ aNumCharsFit); */
-+
-+ return NS_OK;
-+}
-+
-+void
-+nsFontMetricsPSPango::FixupSpaceWidths (PangoLayout *aLayout,
-+ const char *aString)
-+{
-+ PangoLayoutLine *line = pango_layout_get_line(aLayout, 0);
-+
-+ gint curRun = 0;
-+
-+ for (GSList *tmpList = line->runs; tmpList && tmpList->data;
-+ tmpList = tmpList->next, curRun++) {
-+ PangoLayoutRun *layoutRun = (PangoLayoutRun *)tmpList->data;
-+
-+ for (gint i=0; i < layoutRun->glyphs->num_glyphs; i++) {
-+ gint thisOffset = (gint)layoutRun->glyphs->log_clusters[i] + layoutRun->item->offset;
-+ if (aString[thisOffset] == ' ')
-+ layoutRun->glyphs->glyphs[i].geometry.width = mPangoSpaceWidth;
-+ }
-+ }
-+}
-+
-+/* static */
-+PangoLanguage *
-+GetPangoLanguage(nsIAtom *aLangGroup)
-+{
-+ // Find the FC lang group for this lang group
-+ nsCAutoString cname;
-+ aLangGroup->ToUTF8String(cname);
-+
-+ // see if the lang group needs to be translated from mozilla's
-+ // internal mapping into fontconfig's
-+ const MozGtkLangGroup *langGroup;
-+ langGroup = NS_FindFCLangGroup(cname);
-+
-+ // if there's no lang group, just use the lang group as it was
-+ // passed to us
-+ //
-+ // we're casting away the const here for the strings - should be
-+ // safe.
-+ if (!langGroup)
-+ return pango_language_from_string(cname.get());
-+ else if (langGroup->Lang)
-+ return pango_language_from_string((char *) langGroup->Lang);
-+
-+ return pango_language_from_string("en");
-+}
-+
-+/* static */
-+void
-+FreeGlobals(void)
-+{
-+}
-+
-+/* static */
-+PangoStyle
-+CalculateStyle(PRUint8 aStyle)
-+{
-+ switch(aStyle) {
-+ case NS_FONT_STYLE_ITALIC:
-+ return PANGO_STYLE_OBLIQUE;
-+ break;
-+ case NS_FONT_STYLE_OBLIQUE:
-+ return PANGO_STYLE_OBLIQUE;
-+ break;
-+ }
-+
-+ return PANGO_STYLE_NORMAL;
-+}
-+
-+/* static */
-+PangoWeight
-+CalculateWeight (PRUint16 aWeight)
-+{
-+ /*
-+ * weights come in two parts crammed into one
-+ * integer -- the "base" weight is weight / 100,
-+ * the rest of the value is the "offset" from that
-+ * weight -- the number of steps to move to adjust
-+ * the weight in the list of supported font weights,
-+ * this value can be negative or positive.
-+ */
-+ PRInt32 baseWeight = (aWeight + 50) / 100;
-+ PRInt32 offset = aWeight - baseWeight * 100;
-+
-+ /* clip weights to range 0 to 9 */
-+ if (baseWeight < 0)
-+ baseWeight = 0;
-+ if (baseWeight > 9)
-+ baseWeight = 9;
-+
-+ /* Map from weight value to fcWeights index */
-+ static int fcWeightLookup[10] = {
-+ 0, 0, 0, 0, 1, 1, 2, 3, 3, 4,
-+ };
-+
-+ PRInt32 fcWeight = fcWeightLookup[baseWeight];
-+
-+ /*
-+ * adjust by the offset value, make sure we stay inside the
-+ * fcWeights table
-+ */
-+ fcWeight += offset;
-+
-+ if (fcWeight < 0)
-+ fcWeight = 0;
-+ if (fcWeight > 4)
-+ fcWeight = 4;
-+
-+ /* Map to final PANGO_WEIGHT value */
-+ static int fcWeights[5] = {
-+ 349,
-+ 499,
-+ 649,
-+ 749,
-+ 999
-+ };
-+
-+ return (PangoWeight)fcWeights[fcWeight];
-+}
-+
-+/* static */
-+nsresult
-+EnumFontsPango(nsIAtom* aLangGroup, const char* aGeneric,
-+ PRUint32* aCount, PRUnichar*** aResult)
-+{
-+ FcPattern *pat = NULL;
-+ FcObjectSet *os = NULL;
-+ FcFontSet *fs = NULL;
-+ nsresult rv = NS_ERROR_FAILURE;
-+
-+ PRUnichar **array = NULL;
-+ PRUint32 narray = 0;
-+ PRInt32 serif = 0, sansSerif = 0, monospace = 0, nGenerics;
-+
-+ *aCount = 0;
-+ *aResult = nsnull;
-+
-+ pat = FcPatternCreate();
-+ if (!pat)
-+ goto end;
-+
-+ os = FcObjectSetBuild(FC_FAMILY, FC_FOUNDRY, NULL);
-+ if (!os)
-+ goto end;
-+
-+ // take the pattern and add the lang group to it
-+ if (aLangGroup)
-+ NS_AddLangGroup(pat, aLangGroup);
-+
-+ // get the font list
-+ fs = FcFontList(0, pat, os);
-+
-+ if (!fs)
-+ goto end;
-+
-+ if (!fs->nfont) {
-+ rv = NS_OK;
-+ goto end;
-+ }
-+
-+ // Fontconfig supports 3 generic fonts, "serif", "sans-serif", and
-+ // "monospace", slightly different from CSS's 5.
-+ if (!aGeneric)
-+ serif = sansSerif = monospace = 1;
-+ else if (!strcmp(aGeneric, "serif"))
-+ serif = 1;
-+ else if (!strcmp(aGeneric, "sans-serif"))
-+ sansSerif = 1;
-+ else if (!strcmp(aGeneric, "monospace"))
-+ monospace = 1;
-+ else if (!strcmp(aGeneric, "cursive") || !strcmp(aGeneric, "fantasy"))
-+ serif = sansSerif = 1;
-+ else
-+ NS_NOTREACHED("unexpected generic family");
-+ nGenerics = serif + sansSerif + monospace;
-+
-+ array = NS_STATIC_CAST(PRUnichar **,
-+ nsMemory::Alloc((fs->nfont + nGenerics) * sizeof(PRUnichar *)));
-+ if (!array)
-+ goto end;
-+
-+ if (serif) {
-+ PRUnichar *name = ToNewUnicode(NS_LITERAL_STRING("serif"));
-+ if (!name)
-+ goto end;
-+ array[narray++] = name;
-+ }
-+
-+ if (sansSerif) {
-+ PRUnichar *name = ToNewUnicode(NS_LITERAL_STRING("sans-serif"));
-+ if (!name)
-+ goto end;
-+ array[narray++] = name;
-+ }
-+
-+ if (monospace) {
-+ PRUnichar *name = ToNewUnicode(NS_LITERAL_STRING("monospace"));
-+ if (!name)
-+ goto end;
-+ array[narray++] = name;
-+ }
-+
-+ for (int i=0; i < fs->nfont; ++i) {
-+ char *family;
-+
-+ // if there's no family, just move to the next iteration
-+ if (FcPatternGetString (fs->fonts[i], FC_FAMILY, 0,
-+ (FcChar8 **) &family) != FcResultMatch) {
-+ continue;
-+ }
-+
-+ // fontconfig always returns family names in UTF-8
-+ PRUnichar* name = UTF8ToNewUnicode(nsDependentCString(family));
-+
-+ if (!name)
-+ goto end;
-+
-+ array[narray++] = name;
-+ }
-+
-+ NS_QuickSort(array + nGenerics, narray - nGenerics, sizeof (PRUnichar*),
-+ CompareFontNames, nsnull);
-+
-+ *aCount = narray;
-+ if (narray)
-+ *aResult = array;
-+ else
-+ nsMemory::Free(array);
-+
-+ rv = NS_OK;
-+
-+ end:
-+ if (NS_FAILED(rv) && array) {
-+ while (narray)
-+ nsMemory::Free (array[--narray]);
-+ nsMemory::Free (array);
-+ }
-+ if (pat)
-+ FcPatternDestroy(pat);
-+ if (os)
-+ FcObjectSetDestroy(os);
-+ if (fs)
-+ FcFontSetDestroy(fs);
-+
-+ return rv;
-+}
-+
-+/* static */
-+int
-+CompareFontNames (const void* aArg1, const void* aArg2, void* aClosure)
-+{
-+ const PRUnichar* str1 = *((const PRUnichar**) aArg1);
-+ const PRUnichar* str2 = *((const PRUnichar**) aArg2);
-+
-+ return nsCRT::strcmp(str1, str2);
-+}
-+
-+
-+// nsFontEnumeratorPango class
-+
-+nsFontEnumeratorPango::nsFontEnumeratorPango()
-+{
-+}
-+
-+NS_IMPL_ISUPPORTS1(nsFontEnumeratorPango, nsIFontEnumerator)
-+
-+NS_IMETHODIMP
-+nsFontEnumeratorPango::EnumerateAllFonts(PRUint32 *aCount,
-+ PRUnichar ***aResult)
-+{
-+ NS_ENSURE_ARG_POINTER(aResult);
-+ *aResult = nsnull;
-+ NS_ENSURE_ARG_POINTER(aCount);
-+ *aCount = 0;
-+
-+ return EnumFontsPango(nsnull, nsnull, aCount, aResult);
-+}
-+
-+NS_IMETHODIMP
-+nsFontEnumeratorPango::EnumerateFonts(const char *aLangGroup,
-+ const char *aGeneric,
-+ PRUint32 *aCount,
-+ PRUnichar ***aResult)
-+{
-+ NS_ENSURE_ARG_POINTER(aResult);
-+ *aResult = nsnull;
-+ NS_ENSURE_ARG_POINTER(aCount);
-+ *aCount = 0;
-+
-+ // aLangGroup=null or "" means any (i.e., don't care)
-+ // aGeneric=null or "" means any (i.e, don't care)
-+ nsCOMPtr<nsIAtom> langGroup;
-+ if (aLangGroup && *aLangGroup)
-+ langGroup = do_GetAtom(aLangGroup);
-+ const char* generic = nsnull;
-+ if (aGeneric && *aGeneric)
-+ generic = aGeneric;
-+
-+ return EnumFontsPango(langGroup, generic, aCount, aResult);
-+}
-+
-+NS_IMETHODIMP
-+nsFontEnumeratorPango::HaveFontFor(const char *aLangGroup,
-+ PRBool *aResult)
-+{
-+ NS_ENSURE_ARG_POINTER(aResult);
-+ *aResult = PR_FALSE;
-+ NS_ENSURE_ARG_POINTER(aLangGroup);
-+
-+ *aResult = PR_TRUE; // always return true for now.
-+ // Finish me - ftang
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontEnumeratorPango::GetDefaultFont(const char *aLangGroup,
-+ const char *aGeneric,
-+ PRUnichar **aResult)
-+{
-+ NS_ENSURE_ARG_POINTER(aResult);
-+ *aResult = nsnull;
-+
-+ // Have a look at nsFontEnumeratorXft::GetDefaultFont for some
-+ // possible code for this function.
-+
-+ return NS_OK;
-+}
-+
-+NS_IMETHODIMP
-+nsFontEnumeratorPango::UpdateFontList(PRBool *_retval)
-+{
-+ *_retval = PR_FALSE; // always return false for now
-+ return NS_OK;
-+}
-Index: gfx/src/ps/nsFontMetricsPSPango.h
-===================================================================
-RCS file: gfx/src/ps/nsFontMetricsPSPango.h
-diff -N gfx/src/ps/nsFontMetricsPSPango.h
---- /dev/null 1 Jan 1970 00:00:00 -0000
-+++ gfx/src/ps/nsFontMetricsPSPango.h 23 Oct 2006 17:37:13 -0000
-@@ -0,0 +1,305 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-+/* vim:expandtab:shiftwidth=4:tabstop=4:
-+ */
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is
-+ * Christopher Blizzard <blizzard@mozilla.org>.
-+ * Portions created by the Initial Developer are Copyright (C) 2002
-+ * the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either the GNU General Public License Version 2 or later (the "GPL"), or
-+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#ifndef nsFontMetricsPSPango_h__
-+#define nsFontMetricsPSPango_h__
-+
-+#include "nsIFontMetrics.h"
-+#include "nsIFontEnumerator.h"
-+#include "nsCRT.h"
-+#include "nsIAtom.h"
-+#include "nsString.h"
-+#include "nsVoidArray.h"
-+#include "nsFontMetricsPS.h"
-+
-+#include <pango/pango.h>
-+
-+class nsRenderingContextPS;
-+class nsIDrawingSurface;
-+
-+class nsFontMetricsPSPango : public nsFontMetricsPS
-+{
-+public:
-+ nsFontMetricsPSPango();
-+ virtual ~nsFontMetricsPSPango();
-+
-+ NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
-+
-+ // nsISupports
-+ NS_DECL_ISUPPORTS
-+
-+ // nsIFontMetrics
-+ NS_IMETHOD Init (const nsFont& aFont, nsIAtom* aLangGroup,
-+ nsIDeviceContext *aContext);
-+ NS_IMETHOD Destroy();
-+ NS_IMETHOD GetLangGroup (nsIAtom** aLangGroup);
-+ NS_IMETHOD GetFontHandle (nsFontHandle &aHandle);
-+
-+ NS_IMETHOD GetXHeight (nscoord& aResult)
-+ { aResult = mXHeight; return NS_OK; };
-+
-+ NS_IMETHOD GetSuperscriptOffset (nscoord& aResult)
-+ { aResult = mSuperscriptOffset;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetSubscriptOffset (nscoord& aResult)
-+ { aResult = mSubscriptOffset;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetStrikeout (nscoord& aOffset, nscoord& aSize)
-+ { aOffset = mStrikeoutOffset;
-+ aSize = mStrikeoutSize;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetUnderline (nscoord& aOffset, nscoord& aSize)
-+ { aOffset = mUnderlineOffset;
-+ aSize = mUnderlineSize;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetHeight (nscoord &aHeight)
-+ { aHeight = mMaxHeight;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetNormalLineHeight (nscoord &aHeight)
-+ { aHeight = mEmHeight + mLeading;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetLeading (nscoord &aLeading)
-+ { aLeading = mLeading;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetEmHeight (nscoord &aHeight)
-+ { aHeight = mEmHeight;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetEmAscent (nscoord &aAscent)
-+ { aAscent = mEmAscent;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetEmDescent (nscoord &aDescent)
-+ { aDescent = mEmDescent;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetMaxHeight (nscoord &aHeight)
-+ { aHeight = mMaxHeight;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetMaxAscent (nscoord &aAscent)
-+ { aAscent = mMaxAscent;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetMaxDescent (nscoord &aDescent)
-+ { aDescent = mMaxDescent;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetMaxAdvance (nscoord &aAdvance)
-+ { aAdvance = mMaxAdvance;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetSpaceWidth (nscoord &aSpaceCharWidth)
-+ { aSpaceCharWidth = mSpaceWidth;
-+ return NS_OK; };
-+
-+ NS_IMETHOD GetAveCharWidth (nscoord &aAveCharWidth)
-+ { aAveCharWidth = mAveCharWidth;
-+ return NS_OK; };
-+
-+ // nsIFontMetricsPS (calls from the font rendering layer)
-+ NS_IMETHOD GetStringWidth(const char *String,nscoord &aWidth,nscoord aLength);
-+ NS_IMETHOD GetStringWidth(const PRUnichar *aString,nscoord &aWidth,nscoord aLength);
-+
-+ NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
-+ nscoord& aWidth);
-+ NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord& aWidth);
-+
-+ NS_IMETHOD GetTextDimensions(const char* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions);
-+ NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
-+ PRUint32 aLength,
-+ nsTextDimensions& aDimensions,
-+ PRInt32* aFontID);
-+ NS_IMETHOD GetTextDimensions(const char* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID);
-+ NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions,
-+ PRInt32* aFontID);
-+
-+ NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+ NS_IMETHOD DrawString(const PRUnichar* aString, PRUint32 aLength,
-+ nscoord aX, nscoord aY,
-+ PRInt32 aFontID,
-+ const nscoord* aSpacing,
-+ nsRenderingContextPS *aContext);
-+
-+#ifdef MOZ_MATHML
-+ NS_IMETHOD GetBoundingMetrics(const char *aString, PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics);
-+ NS_IMETHOD GetBoundingMetrics(const PRUnichar *aString,
-+ PRUint32 aLength,
-+ nsBoundingMetrics &aBoundingMetrics,
-+ PRInt32 *aFontID);
-+#endif /* MOZ_MATHML */
-+
-+ NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
-+
-+ NS_IMETHOD GetClusterInfo(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PRUint8 *aClusterStarts);
-+
-+ virtual PRInt32 GetPosition(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ nsPoint aPt);
-+
-+ NS_IMETHOD GetRangeWidth(const PRUnichar *aText,
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
-+ PRUint32 &aWidth);
-+
-+ NS_IMETHOD GetRangeWidth(const char *aText,
-+ PRUint32 aLength,
-+ PRUint32 aStart,
-+ PRUint32 aEnd,
-+ PRUint32 &aWidth);
-+
-+ // get hints for the font
-+ virtual PRUint32 GetHints (void);
-+
-+ // drawing surface methods
-+ static nsresult FamilyExists (nsIDeviceContext *aDevice,
-+ const nsString &aName);
-+
-+ inline nsIDeviceContext *GetDeviceContext() { return mDeviceContext; }
-+
-+private:
-+
-+ // generic font metrics class bits
-+ nsCStringArray mFontList;
-+ nsAutoVoidArray mFontIsGeneric;
-+
-+ nsIDeviceContext *mDeviceContext;
-+ nsCOMPtr<nsIAtom> mLangGroup;
-+ nsCString *mGenericFont;
-+ float mPointSize;
-+
-+ nsCAutoString mDefaultFont;
-+
-+ // Pango-related items
-+ PangoFontDescription *mPangoFontDesc;
-+ PangoContext *mPangoContext;
-+ PangoContext *mLTRPangoContext;
-+ PangoContext *mRTLPangoContext;
-+ PangoAttrList *mPangoAttrList;
-+ PRBool mIsRTL;
-+
-+ // Cached font metrics
-+ nscoord mXHeight;
-+ nscoord mSuperscriptOffset;
-+ nscoord mSubscriptOffset;
-+ nscoord mStrikeoutOffset;
-+ nscoord mStrikeoutSize;
-+ nscoord mUnderlineOffset;
-+ nscoord mUnderlineSize;
-+ nscoord mMaxHeight;
-+ nscoord mLeading;
-+ nscoord mEmHeight;
-+ nscoord mEmAscent;
-+ nscoord mEmDescent;
-+ nscoord mMaxAscent;
-+ nscoord mMaxDescent;
-+ nscoord mMaxAdvance;
-+ nscoord mSpaceWidth;
-+ nscoord mPangoSpaceWidth;
-+ nscoord mAveCharWidth;
-+
-+ // Private methods
-+ nsresult RealizeFont(void);
-+ nsresult CacheFontMetrics(void);
-+
-+ static PRBool EnumFontCallback(const nsString &aFamily,
-+ PRBool aIsGeneric, void *aData);
-+
-+ void DrawStringSlowly(const gchar *aText,
-+ const PRUnichar *aOrigString,
-+ PRUint32 aLength,
-+ gint aX, gint aY,
-+ PangoLayoutLine *aLine,
-+ const nscoord *aSpacing,
-+ nsRenderingContextPS *aContext);
-+
-+ nsresult GetTextDimensionsInternal(const gchar* aString,
-+ PRInt32 aLength,
-+ PRInt32 aAvailWidth,
-+ PRInt32* aBreaks,
-+ PRInt32 aNumBreaks,
-+ nsTextDimensions& aDimensions,
-+ PRInt32& aNumCharsFit,
-+ nsTextDimensions& aLastWordDimensions);
-+
-+ void FixupSpaceWidths (PangoLayout *aLayout, const char *aString);
-+};
-+
-+class nsFontEnumeratorPango : public nsIFontEnumerator
-+{
-+public:
-+ nsFontEnumeratorPango();
-+ NS_DECL_ISUPPORTS
-+ NS_DECL_NSIFONTENUMERATOR
-+};
-+
-+#endif
-+
-Index: gfx/src/ps/nsPostScriptObj.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsPostScriptObj.cpp,v
-retrieving revision 1.124
-diff -u -p -d -r1.124 nsPostScriptObj.cpp
---- gfx/src/ps/nsPostScriptObj.cpp 26 Jul 2005 15:54:18 -0000 1.124
-+++ gfx/src/ps/nsPostScriptObj.cpp 23 Oct 2006 17:37:29 -0000
-@@ -2061,31 +2061,74 @@ nsPostScriptObj::show(const PRUnichar* t
-
- #if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
- void
--nsPostScriptObj::show(const PRUnichar* aTxt, int aLen,
-- const nsAFlatString& aCharList, PRUint16 aSubFontIdx)
-+/*nsPostScriptObj::show(const PRUnichar* aTxt, int aLen,
-+ const nsAFlatString& aCharList, PRUint16 aSubFontIdx) */
-+nsPostScriptObj::show(const nsValueArray *aGlyphs, nsPSFontGenerator *aSubset,
-+ PRUint16 aSubFontIdx)
- {
-- int i;
-+ PRUint32 i;
- fputc('<', mScriptFP);
-
-- const PRUint16 subFontSize = nsPSFontGenerator::kSubFontSize;
-+ for (i = 0; i < aGlyphs->Count(); i++) {
-+ PRUint32 glyph = aGlyphs->ValueAt(i);
-+ fprintf(mScriptFP, "%02x", aSubset->InSubsetIndexOf(glyph));
-+ }
-
-- // the character repertoire of a subfont (255 characters max)
-- const nsAString& repertoire =
-- Substring(aCharList, aSubFontIdx * subFontSize,
-- PR_MIN(subFontSize,
-- aCharList.Length() - aSubFontIdx * subFontSize));
-+ fputs("> show\n", mScriptFP);
-+}
-+#endif
-
-- for (i = 0; i < aLen; i++) {
-- // XXX This is a little inefficient, but printing is not perf. critical.
-- NS_ASSERTION(repertoire.FindChar(aTxt[i]) != kNotFound,
-- "character is not covered by this subfont");
--
-- // Type 1 encoding vector has 256 slots, but the 0-th slot is
-- // reserved for /.notdef so that we use the 1st through 255th slots
-- // for actual characters (hence '+ 1')
-- fprintf(mScriptFP, "%02x", repertoire.FindChar(aTxt[i]) + 1);
-+#ifdef MOZ_ENABLE_PANGO
-+void
-+nsPostScriptObj::show(const PangoGlyphString *glyphs, float zoom,
-+ nsPSFontGenerator *aSubset, PRUint16 aSubFontIdx)
-+{
-+ PRUint32 i;
-+ int horiz = 1;
-+
-+ if (glyphs->glyphs[0].geometry.x_offset || glyphs->glyphs[0].geometry.y_offset)
-+ rmoveto (NSToCoordRound (zoom * glyphs->glyphs[0].geometry.x_offset / PANGO_SCALE),
-+ NSToCoordRound (zoom * glyphs->glyphs[0].geometry.y_offset / PANGO_SCALE));
-+
-+ fputc('<', mScriptFP);
-+
-+ for (i = 0; i < glyphs->num_glyphs; i++) {
-+ PRUint32 glyph = glyphs->glyphs[i].glyph;
-+ fprintf(mScriptFP, "%02x", aSubset->InSubsetIndexOf(glyph));
-+ if (glyphs->glyphs[i].geometry.y_offset)
-+ horiz = 0;
-+ }
-+
-+ if (horiz) {
-+ fputs(">\n[", mScriptFP);
-+ for (i = 1; i < glyphs->num_glyphs; i++) {
-+ fprintf(mScriptFP, "%d ",
-+ NSToCoordRound (zoom * (+ glyphs->glyphs[i ].geometry.x_offset
-+ + glyphs->glyphs[i-1].geometry.width
-+ - glyphs->glyphs[i-1].geometry.x_offset) / PANGO_SCALE));
-+ }
-+ fprintf(mScriptFP, "%d",
-+ NSToCoordRound (zoom * (+ glyphs->glyphs[i-1].geometry.width
-+ - glyphs->glyphs[i-1].geometry.x_offset
-+ - glyphs->glyphs[ 0].geometry.x_offset) / PANGO_SCALE));
-+ fputs("] xshow\n", mScriptFP);
-+ } else {
-+ fputs(">\n[", mScriptFP);
-+ for (i = 1; i < glyphs->num_glyphs; i++) {
-+ fprintf(mScriptFP, "%d %d ",
-+ NSToCoordRound (zoom * (+ glyphs->glyphs[i ].geometry.x_offset
-+ + glyphs->glyphs[i-1].geometry.width
-+ - glyphs->glyphs[i-1].geometry.x_offset) / PANGO_SCALE),
-+ NSToCoordRound (zoom * (+ glyphs->glyphs[i ].geometry.y_offset
-+ - glyphs->glyphs[i-1].geometry.y_offset) / PANGO_SCALE));
-+ }
-+ fprintf(mScriptFP, "%d %d",
-+ NSToCoordRound (zoom * (+ glyphs->glyphs[i-1].geometry.width
-+ - glyphs->glyphs[i-1].geometry.x_offset
-+ - glyphs->glyphs[ 0].geometry.x_offset) / PANGO_SCALE),
-+ NSToCoordRound (zoom * (- glyphs->glyphs[i-1].geometry.y_offset) / PANGO_SCALE));
-+ fputs("] xyshow\n", mScriptFP);
- }
-- fputs("> show\n", mScriptFP);
- }
- #endif
-
-@@ -2101,6 +2144,16 @@ nsPostScriptObj::moveto(nscoord x, nscoo
-
- /** ---------------------------------------------------
- * See documentation in nsPostScriptObj.h
-+ * @update 10/20/06 behdad
-+ */
-+void
-+nsPostScriptObj::rmoveto(nscoord x, nscoord y)
-+{
-+ fprintf(mScriptFP, "%d %d rmoveto\n", x, y);
-+}
-+
-+/** ---------------------------------------------------
-+ * See documentation in nsPostScriptObj.h
- * @update 2/1/99 dwc
- */
- void
-Index: gfx/src/ps/nsPostScriptObj.h
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsPostScriptObj.h,v
-retrieving revision 1.47
-diff -u -p -d -r1.47 nsPostScriptObj.h
---- gfx/src/ps/nsPostScriptObj.h 8 May 2005 15:01:20 -0000 1.47
-+++ gfx/src/ps/nsPostScriptObj.h 23 Oct 2006 17:37:30 -0000
-@@ -57,9 +57,15 @@
- #include "nsIPersistentProperties2.h"
- #include "nsTempfilePS.h"
- #include "nsEPSObjectPS.h"
-+#ifdef MOZ_ENABLE_PANGO
-+#include <pango/pango.h>
-+#endif
-+
-
-+class nsPSFontGenerator;
- class nsIImage;
- class nsIAtom;
-+class nsValueArray;
- #endif
-
- #include <stdio.h>
-@@ -217,6 +223,14 @@ public:
- */
- void moveto(nscoord aX, nscoord aY);
- /** ---------------------------------------------------
-+ * Move relative to the current point
-+ * @update 10/20/2006 behdad
-+ * @param aX X coordinate
-+ * aY Y coordinate
-+ * @return VOID
-+ */
-+ void rmoveto(nscoord aX, nscoord aY);
-+ /** ---------------------------------------------------
- * Add a line to the current path, from the current point
- * to the specified point.
- * @update 9/30/2003
-@@ -346,12 +360,24 @@ public:
- */
- void show(const PRUnichar* aText, int aLen, const char *aAlign, int aType);
- /** ---------------------------------------------------
-- * This version takes a PRUnichar string, a font subset string
-- * for freetype printing and a subfont index
-+ * This version of show takes an array of glyphs, subfont and subfont index
-+ * to render and is used for freetype and xft printing.
- * @update 2/15/2005 jshin@mailaps.org
-+ * @update 6/7/2005 blizzard@mozilla.org
- */
-- void show(const PRUnichar* aText, int aLen, const nsAFlatString& aCharList,
-+ void show(const nsValueArray *aGlyphs, nsPSFontGenerator *aSubset,
- PRUint16 aSubFontIdx);
-+ /*void show(const PRUnichar* aText, int aLen, const nsAFlatString& aCharList,
-+ PRUint16 aSubFontIdx); */
-+#ifdef MOZ_ENABLE_PANGO
-+ /** ---------------------------------------------------
-+ * This version of show takes a pango glyph string, subfont and subfont index
-+ * to render and is used for pango printing.
-+ * @update 10/20/2006 behdad@behdad.org
-+ */
-+ void show(const PangoGlyphString *glyphs, float zoom,
-+ nsPSFontGenerator *aSubset, PRUint16 aSubFontIdx);
-+#endif
- /** ---------------------------------------------------
- * set the clipping path to the current path using the winding rule
- * @update 2/1/99 dwc
-Index: gfx/src/ps/nsRenderingContextPS.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsRenderingContextPS.cpp,v
-retrieving revision 1.83
-diff -u -p -d -r1.83 nsRenderingContextPS.cpp
---- gfx/src/ps/nsRenderingContextPS.cpp 4 Mar 2005 07:39:27 -0000 1.83
-+++ gfx/src/ps/nsRenderingContextPS.cpp 23 Oct 2006 17:37:31 -0000
-@@ -251,6 +251,8 @@ nsRenderingContextPS :: GetDrawingSurfac
- NS_IMETHODIMP
- nsRenderingContextPS :: GetHints(PRUint32& aResult)
- {
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ aResult = metrics->GetHints ();
- return NS_OK;
- }
-
-@@ -1006,8 +1008,11 @@ nsRenderingContextPS::GetTextDimensions(
- nsTextDimensions& aLastWordDimensions,
- PRInt32* aFontID)
- {
-- NS_NOTYETIMPLEMENTED("nsRenderingContextPS::GetTextDimensions");
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetTextDimensions (aString, aLength, aAvailWidth, aBreaks, aNumBreaks,
-+ aDimensions, aNumCharsFit, aLastWordDimensions, aFontID);
- }
-
- NS_IMETHODIMP
-@@ -1021,43 +1026,31 @@ nsRenderingContextPS::GetTextDimensions(
- nsTextDimensions& aLastWordDimensions,
- PRInt32* aFontID)
- {
-- NS_NOTYETIMPLEMENTED("nsRenderingContextPS::GetTextDimensions");
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetTextDimensions (aString, aLength, aAvailWidth, aBreaks, aNumBreaks,
-+ aDimensions, aNumCharsFit, aLastWordDimensions, aFontID);
- }
-
- NS_IMETHODIMP
- nsRenderingContextPS :: GetTextDimensions(const char* aString, PRUint32 aLength,
- nsTextDimensions& aDimensions)
- {
-- nsresult rv = NS_ERROR_FAILURE;
--
-- if (mFontMetrics) {
-- nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-- metrics->GetStringWidth(aString, aDimensions.width, aLength);
-- metrics->GetMaxAscent(aDimensions.ascent);
-- metrics->GetMaxDescent(aDimensions.descent);
-- rv = NS_OK;
-- }
--
-- return rv;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetTextDimensions (aString, aLength, aDimensions);
- }
-
- NS_IMETHODIMP
- nsRenderingContextPS :: GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
- nsTextDimensions& aDimensions, PRInt32* aFontID)
- {
-- nsresult rv = NS_ERROR_FAILURE;
--
-- if (mFontMetrics) {
-- nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-- metrics->GetStringWidth(aString, aDimensions.width, aLength);
-- //XXX temporary - bug 96609
-- metrics->GetMaxAscent(aDimensions.ascent);
-- metrics->GetMaxDescent(aDimensions.descent);
-- rv = NS_OK;
-- }
--
-- return rv;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetTextDimensions (aString, aLength, aDimensions, aFontID);
- }
-
- /** ---------------------------------------------------
-@@ -1073,47 +1066,7 @@ nsRenderingContextPS :: DrawString(const
-
- nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
- NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
--
-- // When FT2 printing is enabled, we don't need to set langgroup
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-- if (!NS_REINTERPRET_CAST(nsDeviceContextPS *, mContext.get())->mFTPEnable) {
--#endif
-- nsCOMPtr<nsIAtom> langGroup;
-- mFontMetrics->GetLangGroup(getter_AddRefs(langGroup));
-- mPSObj->setlanggroup(langGroup);
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-- }
--#endif
--
-- if (aLength == 0)
-- return NS_OK;
-- nsFontPS* fontPS = nsFontPS::FindFont(aString[0], metrics->Font(), metrics);
-- NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
-- fontPS->SetupFont(this);
--
-- PRUint32 i, start = 0;
-- for (i=0; i<aLength; i++) {
-- nsFontPS* fontThisChar;
-- fontThisChar = nsFontPS::FindFont(aString[i], metrics->Font(), metrics);
-- NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
-- if (fontThisChar != fontPS) {
-- // draw text up to this point
-- aX += DrawString(aString+start, i-start, aX, aY, fontPS,
-- aSpacing?aSpacing+start:nsnull);
-- start = i;
--
-- // setup for following text
-- fontPS = fontThisChar;
-- fontPS->SetupFont(this);
-- }
-- }
--
-- // draw the last part
-- if (aLength-start)
-- DrawString(aString+start, aLength-start, aX, aY, fontPS,
-- aSpacing?aSpacing+start:nsnull);
--
-- return NS_OK;
-+ return metrics->DrawString (aString, aLength, aX, aY, aSpacing, this);
- }
-
- /** ---------------------------------------------------
-@@ -1129,110 +1082,7 @@ nsRenderingContextPS :: DrawString(const
-
- nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
- NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
--
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-- // When FT2 printing is enabled, we don't need to set langgroup
-- if (!NS_REINTERPRET_CAST(nsDeviceContextPS *, mContext.get())->mFTPEnable) {
--#endif
-- nsCOMPtr<nsIAtom> langGroup = nsnull;
-- mFontMetrics->GetLangGroup(getter_AddRefs(langGroup));
-- mPSObj->setlanggroup(langGroup);
--#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
-- }
--#endif
--
-- /* build up conversion table */
-- mPSObj->preshow(aString, aLength);
--
-- if (aLength == 0)
-- return NS_OK;
-- nsFontPS* fontPS = nsFontPS::FindFont(aString[0], metrics->Font(), metrics);
-- NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);
-- fontPS->SetupFont(this);
--
-- PRUint32 i, start = 0;
-- for (i=0; i<aLength; i++) {
-- nsFontPS* fontThisChar;
-- fontThisChar = nsFontPS::FindFont(aString[i], metrics->Font(), metrics);
-- NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
-- if (fontThisChar != fontPS) {
-- // draw text up to this point
-- aX += DrawString(aString+start, i-start, aX, aY, fontPS,
-- aSpacing?aSpacing+start:nsnull);
-- start = i;
--
-- // setup for following text
-- fontPS = fontThisChar;
-- fontPS->SetupFont(this);
-- }
-- }
--
-- // draw the last part
-- if (aLength-start)
-- DrawString(aString+start, aLength-start, aX, aY, fontPS,
-- aSpacing?aSpacing+start:nsnull);
--
-- return NS_OK;
--}
--
--PRInt32
--nsRenderingContextPS::DrawString(const char *aString, PRUint32 aLength,
-- nscoord &aX, nscoord &aY, nsFontPS* aFontPS,
-- const nscoord* aSpacing)
--{
-- nscoord width = 0;
-- PRInt32 x = aX;
-- PRInt32 y = aY;
--
-- PRInt32 dxMem[500];
-- PRInt32* dx0 = 0;
-- if (aSpacing) {
-- dx0 = dxMem;
-- if (aLength > 500) {
-- dx0 = new PRInt32[aLength];
-- NS_ENSURE_TRUE(dx0, NS_ERROR_OUT_OF_MEMORY);
-- }
-- mTranMatrix->ScaleXCoords(aSpacing, aLength, dx0);
-- }
--
-- mTranMatrix->TransformCoord(&x, &y);
-- width = aFontPS->DrawString(this, x, y, aString, aLength);
--
-- if ((aSpacing) && (dx0 != dxMem)) {
-- delete [] dx0;
-- }
--
-- return width;
--}
--
--
--PRInt32
--nsRenderingContextPS::DrawString(const PRUnichar *aString, PRUint32 aLength,
-- nscoord aX, nscoord aY, nsFontPS* aFontPS,
-- const nscoord* aSpacing)
--{
-- nscoord width = 0;
-- PRInt32 x = aX;
-- PRInt32 y = aY;
--
-- if (aSpacing) {
-- // Slow, but accurate rendering
-- const PRUnichar* end = aString + aLength;
-- while (aString < end){
-- x = aX;
-- y = aY;
-- mTranMatrix->TransformCoord(&x, &y);
-- aFontPS->DrawString(this, x, y, aString, 1);
-- aX += *aSpacing++;
-- aString++;
-- }
-- width = aX;
-- } else {
-- mTranMatrix->TransformCoord(&x, &y);
-- width = aFontPS->DrawString(this, x, y, aString, aLength);
-- }
--
-- return width;
-+ return metrics->DrawString (aString, aLength, aX, aY, aFontID, aSpacing, this);
- }
-
- /** ---------------------------------------------------
-@@ -1346,8 +1196,10 @@ nsRenderingContextPS::GetBoundingMetrics
- PRUint32 aLength,
- nsBoundingMetrics& aBoundingMetrics)
- {
-- // Fill me up
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetBoundingMetrics (aString, aLength, aBoundingMetrics);
- }
-
- /**
-@@ -1359,8 +1211,10 @@ nsRenderingContextPS::GetBoundingMetrics
- nsBoundingMetrics& aBoundingMetrics,
- PRInt32* aFontID)
- {
-- // Fill me up
-- return NS_ERROR_NOT_IMPLEMENTED;
-+ NS_ENSURE_TRUE(mFontMetrics, NS_ERROR_NULL_POINTER);
-+ nsFontMetricsPS *metrics = NS_REINTERPRET_CAST(nsFontMetricsPS *, mFontMetrics.get());
-+ NS_ENSURE_TRUE(metrics, NS_ERROR_FAILURE);
-+ return metrics->GetBoundingMetrics (aString, aLength, aBoundingMetrics, aFontID);
- }
- #endif /* MOZ_MATHML */
-
-Index: gfx/src/ps/nsRenderingContextPS.h
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsRenderingContextPS.h,v
-retrieving revision 1.49
-diff -u -p -d -r1.49 nsRenderingContextPS.h
---- gfx/src/ps/nsRenderingContextPS.h 20 Sep 2004 06:46:16 -0000 1.49
-+++ gfx/src/ps/nsRenderingContextPS.h 23 Oct 2006 17:37:35 -0000
-@@ -154,6 +154,10 @@ public:
- NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
- nscoord& aWidth, PRInt32 *aFontID);
-
-+ nsTransform2D *GetTranMatrix() {
-+ return mTranMatrix;
-+ }
-+
- NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
- nscoord aX, nscoord aY,
- const nscoord* aSpacing);
-@@ -164,13 +168,6 @@ public:
- NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
- PRInt32 aFontID,
- const nscoord* aSpacing);
--protected:
-- PRInt32 DrawString(const PRUnichar *aString, PRUint32 aLength,
-- nscoord aX, nscoord aY, nsFontPS* aFontPS,
-- const nscoord* aSpacing);
-- PRInt32 DrawString(const char *aString, PRUint32 aLength,
-- nscoord &aX, nscoord &aY, nsFontPS* aFontPS,
-- const nscoord* aSpacing);
- public:
-
- NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
-Index: gfx/src/ps/nsType1.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsType1.cpp,v
-retrieving revision 1.5.8.1
-diff -u -p -d -r1.5.8.1 nsType1.cpp
---- gfx/src/ps/nsType1.cpp 19 Oct 2005 08:16:22 -0000 1.5.8.1
-+++ gfx/src/ps/nsType1.cpp 23 Oct 2006 17:37:39 -0000
-@@ -73,8 +73,13 @@
- #include "nsIFreeType2.h"
- #include "nsServiceManagerUtils.h"
- #endif
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
-+#include FT_TYPE1_TABLES_H
-+#endif
- #include "nsPrintfCString.h"
- #include "nsAutoBuffer.h"
-+#include "nsValueArray.h"
-+#include "nsVoidArray.h"
-
- #define HEXASCII_LINE_LEN 64
-
-@@ -113,7 +118,7 @@ static void encryptAndHexOut(FILE *aFile
- const char *aBuf, PRInt32 aLen = -1);
- static void charStringOut(FILE* aFile, PRUint32* aPos, PRUint16* aKey,
- const char *aStr, PRUint32 aLen,
-- PRUnichar aId);
-+ const char *aGlyphName);
- static void flattenName(nsCString& aString);
-
- /* thunk a short name for this function */
-@@ -202,19 +207,30 @@ Type1EncryptString(unsigned char *aInBuf
- aOutBuf[i] = Type1Encrypt(aInBuf[i], &key);
- }
-
-+static FT_UShort
-+get_upm (FT_Face face)
-+{
-+ FT_UShort upm = face->units_per_EM;
-+
-+ if (!upm)
-+ upm = 1000; // bitmap font or something
-+
-+ return upm;
-+}
-+
- static PRBool
- sideWidthAndBearing(const FT_Vector *aEndPt, FT2PT1_info *aFti)
- {
- int aw = 0;
- int ah = 0;
-- FT_UShort upm = aFti->face->units_per_EM;
-+ FT_UShort upm = get_upm (aFti->face);
- FT_GlyphSlot slot;
- FT_Glyph glyph;
- FT_BBox bbox;
-
- slot = aFti->face->glyph;
-
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- FT_Error error = FT_Get_Glyph(slot, &glyph);
- if (error) {
- NS_ERROR("sideWidthAndBearing failed to get glyph");
-@@ -256,7 +272,7 @@ static int
- moveto(nsFT_CONST FT_Vector *aEndPt, void *aClosure)
- {
- FT2PT1_info *fti = (FT2PT1_info *)aClosure;
-- FT_UShort upm = fti->face->units_per_EM;
-+ FT_UShort upm = get_upm (fti->face);
- PRBool rslt;
-
- if (fti->elm_cnt == 0) {
-@@ -293,7 +309,7 @@ static int
- lineto(nsFT_CONST FT_Vector *aEndPt, void *aClosure)
- {
- FT2PT1_info *fti = (FT2PT1_info *)aClosure;
-- FT_UShort upm = fti->face->units_per_EM;
-+ FT_UShort upm = get_upm (fti->face);
-
- if (toCS(upm, aEndPt->x) == fti->cur_x) {
- fti->len += ecsi(&fti->buf, toCS(upm, aEndPt->y) - (int)fti->cur_y);
-@@ -320,7 +336,7 @@ conicto(nsFT_CONST FT_Vector *aControlPt
- void *aClosure)
- {
- FT2PT1_info *ftinfo = (FT2PT1_info *)aClosure;
-- FT_UShort upm = ftinfo->face->units_per_EM;
-+ FT_UShort upm = get_upm (ftinfo->face);
- double ctl_x, ctl_y;
- double cur_x, cur_y, x3, y3;
- FT_Vector aControlPt1, aControlPt2;
-@@ -353,7 +369,7 @@ cubicto(nsFT_CONST FT_Vector *aControlPt
- nsFT_CONST FT_Vector *aEndPt, void *aClosure)
- {
- FT2PT1_info *ftinfo = (FT2PT1_info *)aClosure;
-- FT_UShort upm = ftinfo->face->units_per_EM;
-+ FT_UShort upm = get_upm (ftinfo->face);
- double cur_x, cur_y, x1, y1, x2, y2, x3, y3;
-
- cur_x = ftinfo->cur_x;
-@@ -408,8 +424,55 @@ static FT_Outline_Funcs ft_outline_funcs
- 0
- };
-
-+
-+static int
-+trace_bitmap_glyph (FT_GlyphSlot slot, FT2PT1_info *fti)
-+{
-+ unsigned char *row, *byte_ptr, byte;
-+ int rows, cols;
-+ int x, y, bit_mask;
-+ int upm, x_off, y_off, x_mult, y_mult;
-+
-+ upm = get_upm (slot->face);
-+ x_off = slot->bitmap_left;
-+ y_off = slot->bitmap_top;
-+ x_mult = upm / slot->face->size->metrics.x_ppem;
-+ y_mult = upm / slot->face->size->metrics.y_ppem;
-+
-+ switch (slot->bitmap.pixel_mode) {
-+ case FT_PIXEL_MODE_MONO:
-+
-+ for (y = 0, row = slot->bitmap.buffer, rows = slot->bitmap.rows; rows; row += slot->bitmap.pitch, rows--, y++) {
-+ for (x = 0, byte_ptr = row, cols = (slot->bitmap.width + 7) / 8; cols; byte_ptr++, cols--) {
-+ byte = *byte_ptr;
-+ for (bit_mask = 128; bit_mask && x < slot->bitmap.width; bit_mask >>= 1, x++) {
-+ if (byte & bit_mask) {
-+ FT_Vector p;
-+ p.x = x_mult * (x_off + x);
-+ p.y = y_mult * (y_off - y);
-+ moveto(&p, (void *) fti);
-+ p.x += x_mult;
-+ lineto(&p, (void *) fti);
-+ p.y += y_mult;
-+ lineto(&p, (void *) fti);
-+ p.x -= x_mult;
-+ lineto(&p, (void *) fti);
-+ }
-+ }
-+ }
-+ }
-+ break;
-+
-+ default:
-+ return 1;
-+ }
-+
-+ return 0;
-+}
-+
-+
- FT_Error
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- FT2GlyphToType1CharString(FT_Face aFace, PRUint32 aGlyphID,
- int aWmode, int aLenIV, unsigned char *aBuf)
- #else
-@@ -423,7 +486,7 @@ FT2GlyphToType1CharString(nsIFreeType2 *
- unsigned char *start = aBuf;
- FT2PT1_info fti;
-
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- FT_Error error = FT_Load_Glyph(aFace, aGlyphID, flags);
- if (error) {
- NS_ERROR("failed to load aGlyphID");
-@@ -438,11 +501,6 @@ FT2GlyphToType1CharString(nsIFreeType2 *
- #endif
- slot = aFace->glyph;
-
-- if (slot->format != ft_glyph_format_outline) {
-- NS_ERROR("aGlyphID is not an outline glyph");
-- return 1;
-- }
--
- #ifdef MOZ_ENABLE_FREETYPE2
- fti.ft2 = aFt2;
- #endif
-@@ -456,18 +514,27 @@ FT2GlyphToType1CharString(nsIFreeType2 *
- for (j=0; j< aLenIV; j++) {
- fti.len += ecsi(&fti.buf, 0);
- }
--#ifdef MOZ_ENABLE_XFT
-- if (FT_Outline_Decompose(&slot->outline, &ft_outline_funcs, &fti)) {
-- NS_ERROR("error decomposing aGlyphID");
-- return 1;
-- }
-+
-+ if (slot->format == ft_glyph_format_outline) {
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
-+ if (FT_Outline_Decompose(&slot->outline, &ft_outline_funcs, &fti)) {
-+ NS_ERROR("error decomposing aGlyphID");
-+ return 1;
-+ }
- #else
-- rv = aFt2->OutlineDecompose(&slot->outline, &ft_outline_funcs, &fti);
-- if (NS_FAILED(rv)) {
-- NS_ERROR("error decomposing aGlyphID");
-- return 1;
-- }
-+ rv = aFt2->OutlineDecompose(&slot->outline, &ft_outline_funcs, &fti);
-+ if (NS_FAILED(rv)) {
-+ NS_ERROR("error decomposing aGlyphID");
-+ }
- #endif
-+ } else if (slot->format == ft_glyph_format_bitmap) {
-+ /* ok, it's a bitmap glyph. trace it! */
-+ if (trace_bitmap_glyph (slot, &fti)) {
-+ NS_ERROR("error tracing bitmap glyph");
-+ }
-+ } else {
-+ NS_ERROR("aGlyphID has unhandled format");
-+ }
-
- if (fti.elm_cnt) {
- fti.len += csc(&fti.buf, T1_CLOSEPATH);
-@@ -491,28 +558,52 @@ FT2GlyphToType1CharString(nsIFreeType2 *
- }
-
- static PRBool
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- outputType1SubFont(FT_Face aFace,
- #else
- outputType1SubFont(nsIFreeType2 *aFt2, FT_Face aFace,
- #endif
-- const nsAString &aCharIDs, const char *aFontName,
-- int aWmode, int aLenIV, FILE *aFile);
-+ nsValueArray *aGlyphs,
-+ PRUint32 aOffset, PRUint32 aLen,
-+ const char *aFontName,
-+ int aWmode, int aLenIV, FILE *aFile);
-
- nsresult
- FT2ToType1FontName(FT_Face aFace, int aWmode, nsCString& aFontName)
- {
-+ // only hash the first 10 000 bytes of the font
-+ int size = aFace->stream->size;
-+ size = size > 10000 ? 10000 : size;
-+
-+ unsigned char *data;
-+ if (aFace->stream->read) {
-+ data = (unsigned char *) malloc (size);
-+ aFace->stream->read (aFace->stream, 0, data, size);
-+ } else {
-+ data = aFace->stream->base;
-+ }
-+
-+ unsigned int data_hash = 0;
-+ int i;
-+ for (i = 0; i < size; i++)
-+ data_hash = (data_hash << 5) - data_hash + data[size];
-+
-+ if (aFace->stream->read)
-+ free (data);
-+
- aFontName = aFace->family_name;
- aFontName.AppendLiteral(".");
- aFontName += aFace->style_name;
-- aFontName += nsPrintfCString(".%ld.%d", aFace->face_index, aWmode ? 1 : 0);
-+ aFontName += nsPrintfCString(".%ld.%d.%lx.%x", aFace->face_index, aWmode ? 1 : 0,
-+ (long) aFace->stream->size, data_hash);
- flattenName(aFontName);
-+
- return NS_OK;
- }
-
- // output a subsetted truetype font converted to multiple type 1 fonts
- PRBool
--FT2SubsetToType1FontSet(FT_Face aFace, const nsString& aSubset,
-+FT2SubsetToType1FontSet(FT_Face aFace, nsValueArray *aGlyphSubset,
- int aWmode, FILE *aFile)
- {
- #ifdef MOZ_ENABLE_FREETYPE2
-@@ -527,32 +618,35 @@ FT2SubsetToType1FontSet(FT_Face aFace, c
- nsCAutoString fontNameBase;
- FT2ToType1FontName(aFace, aWmode, fontNameBase);
- PRUint32 i = 0;
-- for (; i <= aSubset.Length() / 255 ; i++) {
-+ for (; i <= aGlyphSubset->Count() / 255 ; i++) {
- nsCAutoString fontName(fontNameBase);
- fontName.AppendLiteral(".Set");
- fontName.AppendInt(i);
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- outputType1SubFont(aFace,
- #else
- outputType1SubFont(ft2, aFace,
- #endif
-- Substring(aSubset, i * 255, PR_MIN(255, aSubset.Length() - i * 255)),
-- fontName.get(), aWmode, 4, aFile);
-+ aGlyphSubset,
-+ (i * 255), PR_MIN(255, aGlyphSubset->Count() - i * 255),
-+ fontName.get(), aWmode, 4, aFile);
- }
- return PR_TRUE;
- }
-
- // output a type 1 font (with 255 characters or fewer)
- static PRBool
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- outputType1SubFont(FT_Face aFace,
- #else
- outputType1SubFont(nsIFreeType2 *aFt2, FT_Face aFace,
- #endif
-- const nsAString& aCharIDs, const char *aFontName,
-- int aWmode, int aLenIV, FILE *aFile)
-+ nsValueArray *aGlyphs,
-+ PRUint32 aOffset, PRUint32 aLen,
-+ const char *aFontName,
-+ int aWmode, int aLenIV, FILE *aFile)
- {
-- FT_UShort upm = aFace->units_per_EM;
-+ FT_UShort upm = get_upm (aFace);
-
- fprintf(aFile, "%%%%BeginResource: font %s\n"
- "%%!PS-AdobeFont-1.0-3.0 %s 1.0\n"
-@@ -573,9 +667,13 @@ outputType1SubFont(nsIFreeType2 *aFt2, F
- toCS(upm, aFace->bbox.xMax),
- toCS(upm, aFace->bbox.yMax));
-
-- nsString charIDstr(aCharIDs);
-- PRUint32 len = aCharIDs.Length();
--
-+ nsValueArray glyphs(PR_UINT16_MAX);
-+ nsCStringArray glyphnames(PR_UINT16_MAX);
-+ glyphs = *aGlyphs;
-+
-+ PRUint32 len = aLen;
-+ PRUint32 i;
-+
- if (len < 10) {
- // Add a small set of characters to the subset of the user
- // defined font to produce to make sure the font ends up
-@@ -584,25 +682,47 @@ outputType1SubFont(nsIFreeType2 *aFt2, F
- // XXX : need to check if this is true of type 1 fonts as well.
- // I suspect it's only the case of CID-keyed fonts (type 9) we used to
- // generate.
-- charIDstr.AppendLiteral("1234567890");
-+ for (i = 1; i <= 10; i++) {
-+ glyphs.AppendValue(i);
-+ }
- len += 10;
- }
-
-- const PRUnichar *charIDs = charIDstr.get();
--
-- PRUint32 i;
-+ FT_Int has_glyph_name;
-+#if defined (MOZ_ENABLE_XFT) || defined (MOZ_ENABLE_PANGO)
-+ has_glyph_name = FT_Has_PS_Glyph_Names(aFace);
-+#else
-+ has_glyph_name = aFt2->hasPSGlyphNames(aFace);
-+#endif
-
- // construct an Encoding vector : the 0th element
- // is /.notdef
-- fputs("/Encoding [\n/.notdef\n", aFile);
-- for (i = 0; i < len; ++i) {
-- fprintf(aFile, "/uni%04X", charIDs[i]);
-- if (i % 8 == 7) fputc('\n', aFile);
-+ fputs("/Encoding [\n/.notdef", aFile);
-+ for (i = aOffset; i < aOffset + aLen; ++i) {
-+ nsCString name;
-+ char buffer[256];
-+
-+ if (glyphs.ValueAt(i) == 0) {
-+ name = "/.notdef";
-+ } else if (!has_glyph_name ||
-+#if defined (MOZ_ENABLE_XFT) || defined (MOZ_ENABLE_PANGO)
-+ FT_Get_Glyph_Name(aFace, glyphs.ValueAt(i), buffer, 255) != FT_Err_Ok
-+#else
-+ NS_FAILED(aFt2->getGlyphName(aFace, glyphs.ValueAt(i), buffer, 255))
-+#endif
-+ ) {
-+ name = nsPrintfCString(256, "/idx%04X", glyphs.ValueAt(i));
-+ } else {
-+ name = nsPrintfCString(256, "/%s", buffer);
-+ }
-+ glyphnames.AppendCString(name);
-+ fprintf(aFile, name.get());
-+ if ((i-aOffset) % 8 == 6) fputc('\n', aFile);
- }
-
-- for (i = len; i < 255; ++i) {
-+ for (i = PR_MAX (0, 255 - int(aLen)); i; --i) {
- fputs("/.notdef", aFile);
-- if (i % 8 == 7) fputc('\n', aFile);
-+ if (i % 8 == 1) fputc('\n', aFile);
- }
- fputs("] def\n", aFile);
-
-@@ -630,23 +750,21 @@ outputType1SubFont(nsIFreeType2 *aFt2, F
- // get the maximum charstring length without actually filling up the buffer
- PRInt32 charStringLen;
- PRInt32 maxCharStringLen =
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV, nsnull);
- #else
- FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV, nsnull);
- #endif
-
-- PRUint32 glyphID;
--
-- for (i = 0; i < len; i++) {
--#ifdef MOZ_ENABLE_XFT
-- glyphID = FT_Get_Char_Index(aFace, charIDs[i]);
-+ for (i = aOffset; i < aOffset + aLen; i++) {
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- charStringLen =
-- FT2GlyphToType1CharString(aFace, glyphID, aWmode, aLenIV, nsnull);
-+ FT2GlyphToType1CharString(aFace, glyphs.ValueAt(i), aWmode, aLenIV,
-+ nsnull);
- #else
-- aFt2->GetCharIndex(aFace, charIDs[i], &glyphID);
- charStringLen =
-- FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode, aLenIV, nsnull);
-+ FT2GlyphToType1CharString(aFt2, aFace, glyphs.ValueAt(i), aWmode, aLenIV,
-+ nsnull);
- #endif
-
- if (charStringLen > maxCharStringLen)
-@@ -666,7 +784,7 @@ outputType1SubFont(nsIFreeType2 *aFt2, F
- len + 1).get());
-
- // output the notdef glyph
--#ifdef MOZ_ENABLE_XFT
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
- charStringLen = FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV,
- charString.get());
- #else
-@@ -676,22 +794,20 @@ outputType1SubFont(nsIFreeType2 *aFt2, F
-
- // enclose charString with "/.notdef RD ..... ND"
- charStringOut(aFile, &pos, &key, NS_REINTERPRET_CAST(const char*, charString.get()),
-- charStringLen, 0);
-+ charStringLen, "/.notdef");
-
-
- // output the charstrings for each glyph in this sub font
-- for (i = 0; i < len; i++) {
--#ifdef MOZ_ENABLE_XFT
-- glyphID = FT_Get_Char_Index(aFace, charIDs[i]);
-- charStringLen = FT2GlyphToType1CharString(aFace, glyphID, aWmode,
-+ for (i = aOffset; i < aOffset + aLen; i++) {
-+#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_PANGO)
-+ charStringLen = FT2GlyphToType1CharString(aFace, glyphs.ValueAt(i), aWmode,
- aLenIV, charString.get());
- #else
-- aFt2->GetCharIndex(aFace, charIDs[i], &glyphID);
-- charStringLen = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
-- aLenIV, charString.get());
-+ charStringLen = FT2GlyphToType1CharString(aFt2, aFace, glyphs.ValueAt(i),
-+ aWmode, aLenIV, charString.get());
- #endif
- charStringOut(aFile, &pos, &key, NS_REINTERPRET_CAST(const char*, charString.get()),
-- charStringLen, charIDs[i]);
-+ charStringLen, glyphnames.CStringAt(i - aOffset)->get());
- }
-
- // wrap up the encrypted part of the font definition
-@@ -753,15 +869,12 @@ void encryptAndHexOut(FILE *aFile, PRUin
-
- /* static */
- void charStringOut(FILE* aFile, PRUint32* aPos, PRUint16* aKey,
-- const char *aStr, PRUint32 aLen, PRUnichar aId)
-+ const char *aStr, PRUint32 aLen, const char *aGlyphName)
- {
- // use a local buffer instead of nsPrintfCString to avoid alloc.
- char buf[30];
- int oLen;
-- if (aId == 0)
-- oLen = PR_snprintf(buf, 30, "/.notdef %d RD ", aLen);
-- else
-- oLen = PR_snprintf(buf, 30, "/uni%04X %d RD ", aId, aLen);
-+ oLen = PR_snprintf(buf, 30, "%s %d RD ", aGlyphName, aLen);
-
- if (oLen >= 30) {
- NS_WARNING("buffer size exceeded. charstring will be truncated");
-Index: gfx/src/ps/nsType1.h
-===================================================================
-RCS file: /cvsroot/mozilla/gfx/src/ps/nsType1.h,v
-retrieving revision 1.5
-diff -u -p -d -r1.5 nsType1.h
---- gfx/src/ps/nsType1.h 4 Mar 2005 07:39:27 -0000 1.5
-+++ gfx/src/ps/nsType1.h 23 Oct 2006 17:37:39 -0000
-@@ -122,8 +122,9 @@ FT_Error FT2GlyphToType1CharString(nsIFr
-
- class nsString;
- class nsCString;
-+class nsValueArray;
-
--PRBool FT2SubsetToType1FontSet(FT_Face aFace, const nsString& aSubset,
-+PRBool FT2SubsetToType1FontSet(FT_Face aFace, nsValueArray *aGlyphSubset,
- int aWmode, FILE *aFile);
- nsresult FT2ToType1FontName(FT_Face aFace, int aWmode,
- nsCString& aFontName);
-Index: config/system-headers
-===================================================================
---- config/system-headers 2006-10-26 12:21:39.000000000 -0400
-+++ config/system-headers 2006-10-26 12:23:29.000000000 -0400
-@@ -199,6 +199,7 @@
- freetype/ftoutln.h
- freetype/ttnameid.h
- freetype/tttables.h
-+freetype/t1tables.h
- fribidi/fribidi.h
- FSp_fopen.h
- fstream.h
-@@ -501,6 +503,7 @@
- pango/pangofc-fontmap.h
- pango/pango-fontmap.h
- pango/pango.h
-+pango/pangoft2.h
- pango/pangoxft.h
- pango/pangox.h
- pango-types.h
-
diff --git a/firefox-2.0-startup-notify.patch b/firefox-2.0-startup-notify.patch
deleted file mode 100644
index bed9346..0000000
--- a/firefox-2.0-startup-notify.patch
+++ /dev/null
@@ -1,1296 +0,0 @@
-https://bugzilla.mozilla.org/show_bug.cgi?id=223492
-
-
-Index: configure
-===================================================================
-RCS file: /cvsroot/mozilla/configure,v
-retrieving revision 1.1492.2.121
-diff -d -u -p -r1.1492.2.121 configure
---- configure 11 Jul 2007 16:44:47 -0000 1.1492.2.121
-+++ configure 25 Sep 2007 05:12:51 -0000
-@@ -83,6 +83,8 @@ ac_help="$ac_help
- ac_help="$ac_help
- --with-qtdir=\$dir Specify Qt directory "
- ac_help="$ac_help
-+ --enable-startup-notification Enable startup-notification support (default: disabled) "
-+ac_help="$ac_help
- --enable-application=APP
- Options include:
- suite
-@@ -1067,6 +1069,7 @@ GNOMEVFS_VERSION=2.0
- GNOMEUI_VERSION=2.2.0
- GCONF_VERSION=1.2.1
- LIBGNOME_VERSION=2.0
-+STARTUP_NOTIFICATION_VERSION=0.8
-
- MISSING_X=
- for ac_prog in gawk mawk nawk awk
-@@ -12906,6 +12909,137 @@ fi # COMPILE_ENVIRONMENT
-
-
-
-+if test "$MOZ_ENABLE_GTK2"
-+then
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=
-+
-+ # Check whether --enable-startup-notification or --disable-startup-notification was given.
-+if test "${enable_startup_notification+set}" = set; then
-+ enableval="$enable_startup_notification"
-+ if test "$enableval" = "yes"; then
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=force
-+ elif test "$enableval" = "no"; then
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=
-+ else
-+ { echo "configure: error: Option, startup-notification, does not take an argument ($enableval)." 1>&2; exit 1; }
-+ fi
-+fi
-+
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
-+ then
-+
-+ succeeded=no
-+
-+ if test -z "$PKG_CONFIG"; then
-+ # Extract the first word of "pkg-config", so it can be a program name with args.
-+set dummy pkg-config; ac_word=$2
-+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-+echo "configure:12938: checking for $ac_word" >&5
-+if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
-+ echo $ac_n "(cached) $ac_c" 1>&6
-+else
-+ case "$PKG_CONFIG" in
-+ /*)
-+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
-+ ;;
-+ ?:/*)
-+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path.
-+ ;;
-+ *)
-+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
-+ ac_dummy="$PATH"
-+ for ac_dir in $ac_dummy; do
-+ test -z "$ac_dir" && ac_dir=.
-+ if test -f $ac_dir/$ac_word; then
-+ ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
-+ break
-+ fi
-+ done
-+ IFS="$ac_save_ifs"
-+ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
-+ ;;
-+esac
-+fi
-+PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
-+if test -n "$PKG_CONFIG"; then
-+ echo "$ac_t""$PKG_CONFIG" 1>&6
-+else
-+ echo "$ac_t""no" 1>&6
-+fi
-+
-+ fi
-+
-+ if test "$PKG_CONFIG" = "no" ; then
-+ echo "*** The pkg-config script could not be found. Make sure it is"
-+ echo "*** in your path, or set the PKG_CONFIG environment variable"
-+ echo "*** to the full path to pkg-config."
-+ echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
-+ else
-+ PKG_CONFIG_MIN_VERSION=0.9.0
-+ if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-+ echo $ac_n "checking for libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION""... $ac_c" 1>&6
-+echo "configure:12982: checking for libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION" >&5
-+
-+ if $PKG_CONFIG --exists "libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION" ; then
-+ echo "$ac_t""yes" 1>&6
-+ succeeded=yes
-+
-+ echo $ac_n "checking MOZ_STARTUP_NOTIFICATION_CFLAGS""... $ac_c" 1>&6
-+echo "configure:12989: checking MOZ_STARTUP_NOTIFICATION_CFLAGS" >&5
-+ MOZ_STARTUP_NOTIFICATION_CFLAGS=`$PKG_CONFIG --cflags "libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION"`
-+ echo "$ac_t""$MOZ_STARTUP_NOTIFICATION_CFLAGS" 1>&6
-+
-+ echo $ac_n "checking MOZ_STARTUP_NOTIFICATION_LIBS""... $ac_c" 1>&6
-+echo "configure:12994: checking MOZ_STARTUP_NOTIFICATION_LIBS" >&5
-+ ## don't use --libs since that can do evil things like add
-+ ## -Wl,--export-dynamic
-+ MOZ_STARTUP_NOTIFICATION_LIBS="`$PKG_CONFIG --libs-only-L \"libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION\"` `$PKG_CONFIG --libs-only-l \"libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION\"`"
-+ echo "$ac_t""$MOZ_STARTUP_NOTIFICATION_LIBS" 1>&6
-+ else
-+ MOZ_STARTUP_NOTIFICATION_CFLAGS=""
-+ MOZ_STARTUP_NOTIFICATION_LIBS=""
-+ ## If we have a custom action on failure, don't print errors, but
-+ ## do set a variable so people can do so.
-+ MOZ_STARTUP_NOTIFICATION_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION"`
-+
-+ fi
-+
-+
-+
-+ else
-+ echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
-+ echo "*** See http://www.freedesktop.org/software/pkgconfig"
-+ fi
-+ fi
-+
-+ if test $succeeded = yes; then
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=1
-+ else
-+
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
-+ then
-+ { echo "configure: error: * * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION" 1>&2; exit 1; }
-+ fi
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=
-+
-+ fi
-+
-+ fi
-+
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
-+ cat >> confdefs.h <<\EOF
-+#define MOZ_ENABLE_STARTUP_NOTIFICATION 1
-+EOF
-+
-+ fi
-+
-+ TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
-+fi
-+
-+
-+
-+
-+
-
-
-
-@@ -20426,6 +20560,9 @@ s%@MOZ_GTK2_CFLAGS@%$MOZ_GTK2_CFLAGS%g
- s%@MOZ_GTK2_LIBS@%$MOZ_GTK2_LIBS%g
- s%@HOST_MOC@%$HOST_MOC%g
- s%@MOZ_DEFAULT_TOOLKIT@%$MOZ_DEFAULT_TOOLKIT%g
-+s%@MOZ_STARTUP_NOTIFICATION_CFLAGS@%$MOZ_STARTUP_NOTIFICATION_CFLAGS%g
-+s%@MOZ_STARTUP_NOTIFICATION_LIBS@%$MOZ_STARTUP_NOTIFICATION_LIBS%g
-+s%@MOZ_ENABLE_STARTUP_NOTIFICATION@%$MOZ_ENABLE_STARTUP_NOTIFICATION%g
- s%@TK_CFLAGS@%$TK_CFLAGS%g
- s%@TK_LIBS@%$TK_LIBS%g
- s%@MOZ_ENABLE_GTK@%$MOZ_ENABLE_GTK%g
---- config/autoconf.mk.in 2006-09-14 14:07:03.000000000 -0400
-+++ config/autoconf.mk.in 2007-07-03 18:01:36.000000000 -0400
-@@ -223,6 +223,10 @@
- MOZ_GNOMEUI_CFLAGS = @MOZ_GNOMEUI_CFLAGS@
- MOZ_GNOMEUI_LIBS = @MOZ_GNOMEUI_LIBS@
-
-+MOZ_ENABLE_STARTUP_NOTIFICATION = @MOZ_ENABLE_STARTUP_NOTIFICATION@
-+MOZ_STARTUP_NOTIFICATION_CFLAGS = @MOZ_STARTUP_NOTIFICATION_CFLAGS@
-+MOZ_STARTUP_NOTIFICATION_LIBS = @MOZ_STARTUP_NOTIFICATION_LIBS@
-+
- MOZ_GNOMEVFS_CFLAGS = @MOZ_GNOMEVFS_CFLAGS@
- MOZ_GNOMEVFS_LIBS = @MOZ_GNOMEVFS_LIBS@
-
---- toolkit/components/remote/nsGTKRemoteService.cpp 2006-01-05 22:19:20.000000000 -0500
-+++ toolkit/components/remote/nsGTKRemoteService.cpp 2007-07-05 17:34:41.000000000 -0400
-@@ -50,7 +50,9 @@
-
- #include "nsIBaseWindow.h"
- #include "nsIDocShell.h"
-+#include "nsIDocument.h"
- #include "nsIDOMWindow.h"
-+#include "nsPIDOMWindow.h"
- #include "nsIGenericFactory.h"
- #include "nsILocalFile.h"
- #include "nsIObserverService.h"
-@@ -58,6 +60,8 @@
- #include "nsIServiceManager.h"
- #include "nsIWeakReference.h"
- #include "nsIWidget.h"
-+#include "nsIAppShellService.h"
-+#include "nsAppShellCID.h"
-
- #include "nsCOMPtr.h"
- #include "nsString.h"
-@@ -65,6 +69,10 @@
- #include "prenv.h"
- #include "nsCRT.h"
-
-+#ifdef MOZ_WIDGET_GTK2
-+#include "nsGTKToolkit.h"
-+#endif
-+
- #ifdef MOZ_XUL_APP
- #include "nsICommandLineRunner.h"
- #include "nsXULAppAPI.h"
-@@ -155,20 +163,46 @@
- return PL_DHASH_NEXT;
- }
-
-+static nsIWidget* GetMainWidget(nsIDOMWindow* aWindow)
-+{
-+ // get the native window for this instance
-+ nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow));
-+ NS_ENSURE_TRUE(window, nsnull);
-+ nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
-+ NS_ENSURE_TRUE(doc, nsnull);
-+ nsCOMPtr<nsISupports> container = doc->GetContainer();
-+ nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(container));
-+ NS_ENSURE_TRUE(baseWindow, nsnull);
-+
-+ nsCOMPtr<nsIWidget> mainWidget;
-+ baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
-+ return mainWidget;
-+}
-+
-+static nsGTKToolkit* GetGTKToolkit()
-+{
-+ nsCOMPtr<nsIAppShellService> svc = do_GetService(NS_APPSHELLSERVICE_CONTRACTID);
-+ if (!svc)
-+ return nsnull;
-+ nsCOMPtr<nsIDOMWindowInternal> window;
-+ svc->GetHiddenDOMWindow(getter_AddRefs(window));
-+ if (!window)
-+ return nsnull;
-+ nsIWidget* widget = GetMainWidget(window);
-+ if (!widget)
-+ return nsnull;
-+ nsIToolkit* toolkit = widget->GetToolkit();
-+ if (!toolkit)
-+ return nsnull;
-+ return NS_STATIC_CAST(nsGTKToolkit*, toolkit);
-+}
-+
-+
- NS_IMETHODIMP
- nsGTKRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
- {
- // get the native window for this instance
-- nsCOMPtr<nsIScriptGlobalObject> scriptObject
-- (do_QueryInterface(aWindow));
-- NS_ENSURE_TRUE(scriptObject, NS_ERROR_FAILURE);
--
-- nsCOMPtr<nsIBaseWindow> baseWindow
-- (do_QueryInterface(scriptObject->GetDocShell()));
-- NS_ENSURE_TRUE(baseWindow, NS_ERROR_FAILURE);
--
-- nsCOMPtr<nsIWidget> mainWidget;
-- baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
-+ nsIWidget* mainWidget = GetMainWidget(aWindow);
- NS_ENSURE_TRUE(mainWidget, NS_ERROR_FAILURE);
-
- // walk up the widget tree and find the toplevel window in the
-@@ -201,7 +235,6 @@
-
- return NS_OK;
- }
--
- NS_IMETHODIMP
- nsGTKRemoteService::Shutdown()
- {
-@@ -260,7 +293,7 @@
-
- #ifndef MOZ_XUL_APP
- const char*
--nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow)
-+nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow, PRUint32 aTimestamp)
- {
- nsresult rv;
-
-@@ -283,8 +316,60 @@
- }
-
- #else //MOZ_XUL_APP
-+
-+// Set desktop startup ID to the passed ID, if there is one, so that any created
-+// windows get created with the right window manager metadata, and any windows
-+// that get new tabs and are activated also get the right WM metadata.
-+// If there is no desktop startup ID, then use the X event's timestamp
-+// for _NET_ACTIVE_WINDOW when the window gets focused or shown.
-+static void
-+SetDesktopStartupIDOrTimestamp(const nsACString& aDesktopStartupID,
-+ PRUint32 aTimestamp) {
-+#ifdef MOZ_WIDGET_GTK2
-+ nsGTKToolkit* toolkit = GetGTKToolkit();
-+ if (!toolkit)
-+ return;
-+ if (!aDesktopStartupID.IsEmpty()) {
-+ toolkit->SetDesktopStartupID(aDesktopStartupID);
-+ } else {
-+ toolkit->SetFocusTimestamp(aTimestamp);
-+ }
-+#endif
-+}
-+
-+static PRBool
-+FindExtensionParameterInCommand(const char* aParameterName,
-+ const nsACString& aCommand,
-+ char aSeparator,
-+ nsACString* aValue)
-+{
-+ nsCAutoString searchFor;
-+ searchFor.Append(aSeparator);
-+ searchFor.Append(aParameterName);
-+ searchFor.Append('=');
-+
-+ nsACString::const_iterator start, end;
-+ aCommand.BeginReading(start);
-+ aCommand.EndReading(end);
-+ if (!FindInReadable(searchFor, start, end))
-+ return PR_FALSE;
-+
-+ nsACString::const_iterator charStart, charEnd;
-+ charStart = end;
-+ aCommand.EndReading(charEnd);
-+ nsACString::const_iterator idStart = charStart, idEnd;
-+ if (FindCharInReadable(aSeparator, charStart, charEnd)) {
-+ idEnd = charStart;
-+ } else {
-+ idEnd = charEnd;
-+ }
-+ *aValue = nsDependentCSubstring(idStart, idEnd);
-+ return PR_TRUE;
-+}
-+
- const char*
--nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow)
-+nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow,
-+ PRUint32 aTimestamp)
- {
- nsresult rv;
-
-@@ -314,6 +399,12 @@
- #endif
-
- if (!command.EqualsLiteral("ping")) {
-+ nsCAutoString desktopStartupID;
-+ nsDependentCString cmd(aCommand);
-+ FindExtensionParameterInCommand("DESKTOP_STARTUP_ID",
-+ cmd, '\n',
-+ &desktopStartupID);
-+
- char* argv[3] = {"dummyappname", "-remote", aCommand};
- rv = cmdline->Init(3, argv, nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
- if (NS_FAILED(rv))
-@@ -322,6 +413,8 @@
- if (aWindow)
- cmdline->SetWindowContext(aWindow);
-
-+ SetDesktopStartupIDOrTimestamp(desktopStartupID, aTimestamp);
-+
- rv = cmdline->Run();
- if (NS_ERROR_ABORT == rv)
- return "500 command not parseable";
-@@ -333,7 +426,8 @@
- }
-
- const char*
--nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow)
-+nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow,
-+ PRUint32 aTimestamp)
- {
- nsresult rv;
-
-@@ -364,6 +458,8 @@
- if (NS_FAILED(rv))
- return "509 internal error";
-
-+ nsCAutoString desktopStartupID;
-+
- char **argv = (char**) malloc(sizeof(char*) * argc);
- if (!argv) return "509 internal error";
-
-@@ -372,6 +468,12 @@
- for (int i = 0; i < argc; ++i) {
- argv[i] = aBuffer + TO_LITTLE_ENDIAN32(offset[i]);
-
-+ if (i == 0) {
-+ nsDependentCString cmd(argv[0]);
-+ FindExtensionParameterInCommand("DESKTOP_STARTUP_ID",
-+ cmd, ' ',
-+ &desktopStartupID);
-+ }
- #ifdef DEBUG_bsmedberg
- printf(" argv[%i]:\t%s\n", i, argv[i]);
- #endif
-@@ -386,7 +488,10 @@
- if (aWindow)
- cmdline->SetWindowContext(aWindow);
-
-+ SetDesktopStartupIDOrTimestamp(desktopStartupID, aTimestamp);
-+
- rv = cmdline->Run();
-+
- if (NS_ERROR_ABORT == rv)
- return "500 command not parseable";
-
-@@ -486,7 +591,7 @@
- return FALSE;
-
- // cool, we got the property data.
-- const char *response = HandleCommand(data, window);
-+ const char *response = HandleCommand(data, window, pevent->time);
-
- // put the property onto the window as the response
- XChangeProperty (GDK_DISPLAY(), GDK_WINDOW_XWINDOW(pevent->window),
-@@ -531,7 +636,7 @@
- return FALSE;
-
- // cool, we got the property data.
-- const char *response = HandleCommandLine(data, window);
-+ const char *response = HandleCommandLine(data, window, pevent->time);
-
- // put the property onto the window as the response
- XChangeProperty (GDK_DISPLAY(), GDK_WINDOW_XWINDOW(pevent->window),
---- toolkit/components/remote/nsGTKRemoteService.h 2005-04-04 19:11:42.000000000 -0400
-+++ toolkit/components/remote/nsGTKRemoteService.h 2007-07-03 18:01:36.000000000 -0400
-@@ -80,10 +80,12 @@
- nsIWeakReference* aData,
- void* aClosure);
-
-- static const char* HandleCommand(char* aCommand, nsIDOMWindow* aWindow);
-+ static const char* HandleCommand(char* aCommand, nsIDOMWindow* aWindow,
-+ PRUint32 aTimestamp);
-
- #ifdef MOZ_XUL_APP
-- static const char* HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow);
-+ static const char* HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow,
-+ PRUint32 aTimestamp);
- #endif
-
- static gboolean HandlePropertyChange(GtkWidget *widget,
---- toolkit/components/remote/Makefile.in 2005-04-08 00:59:36.000000000 -0400
-+++ toolkit/components/remote/Makefile.in 2007-07-05 17:45:55.000000000 -0400
-@@ -56,7 +56,9 @@
- string \
- appcomps \
- toolkitcomps \
-- appcomps \
-+ appshell \
-+ layout \
-+ content \
- xulapp \
- widget \
- gfx \
---- toolkit/library/Makefile.in 2007-04-03 10:32:27.000000000 -0400
-+++ toolkit/library/Makefile.in 2007-07-03 18:01:36.000000000 -0400
-@@ -357,6 +357,10 @@
- EXTRA_DSO_LDOPTS += $(MOZ_XPRINT_LDFLAGS)
- endif
-
-+ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
-+EXTRA_DSO_LDOPTS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
-+endif
-+
- ifdef MOZ_ENABLE_PANGO
- EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS)
- endif
---- toolkit/xre/nsAppRunner.cpp 2007-04-30 13:26:58.000000000 -0400
-+++ toolkit/xre/nsAppRunner.cpp 2007-07-05 17:48:51.000000000 -0400
-@@ -72,6 +72,7 @@
- #include "nsIComponentRegistrar.h"
- #include "nsIContentHandler.h"
- #include "nsIDialogParamBlock.h"
-+#include "nsIDocument.h"
- #include "nsIDOMWindow.h"
- #include "nsIEventQueueService.h"
- #include "nsIExtensionManager.h"
-@@ -99,6 +100,11 @@
- #ifdef XP_WIN
- #include "nsIWinAppHelper.h"
- #endif
-+#include "nsPIDOMWindow.h"
-+#include "nsIBaseWindow.h"
-+#include "nsIWidget.h"
-+#include "nsIDocShell.h"
-+#include "nsAppShellCID.h"
-
- #include "nsCRT.h"
- #include "nsCOMPtr.h"
-@@ -262,6 +268,9 @@
- #if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2)
- #include <gtk/gtk.h>
- #endif //MOZ_WIDGET_GTK || MOZ_WIDGET_GTK2
-+#if defined(MOZ_WIDGET_GTK2)
-+#include "nsGTKToolkit.h"
-+#endif
-
- #if defined(MOZ_WIDGET_QT)
- #include <qapplication.h>
-@@ -1105,7 +1114,7 @@
- // use int here instead of a PR type since it will be returned
- // from main - just to keep types consistent
- static int
--HandleRemoteArgument(const char* remote)
-+HandleRemoteArgument(const char* remote, const char* aDesktopStartupID)
- {
- nsresult rv;
- ArgResult ar;
-@@ -1146,7 +1155,7 @@
- nsXPIDLCString response;
- PRBool success = PR_FALSE;
- rv = client.SendCommand(program.get(), username, profile, remote,
-- getter_Copies(response), &success);
-+ aDesktopStartupID, getter_Copies(response), &success);
- // did the command fail?
- if (NS_FAILED(rv)) {
- PR_fprintf(PR_STDERR, "Error: Failed to send command: %s\n",
-@@ -1163,7 +1172,7 @@
- }
-
- static RemoteResult
--RemoteCommandLine()
-+RemoteCommandLine(const char* aDesktopStartupID)
- {
- nsresult rv;
- ArgResult ar;
-@@ -1195,7 +1204,7 @@
- nsXPIDLCString response;
- PRBool success = PR_FALSE;
- rv = client.SendCommandLine(program.get(), username, nsnull,
-- gArgc, gArgv,
-+ gArgc, gArgv, aDesktopStartupID,
- getter_Copies(response), &success);
- // did the command fail?
- if (NS_FAILED(rv) || !success)
-@@ -2059,6 +2068,53 @@
- #ifdef MOZ_WIDGET_GTK2
- #include "prlink.h"
- typedef void (*_g_set_application_name_fn)(const gchar *application_name);
-+typedef void (*_gtk_window_set_auto_startup_notification_fn)(gboolean setting);
-+
-+static PRFuncPtr FindFunction(const char* aName)
-+{
-+ PRLibrary *lib = nsnull;
-+ PRFuncPtr result = PR_FindFunctionSymbolAndLibrary(aName, &lib);
-+ // Since the library was already loaded, we can safely unload it here.
-+ if (lib) {
-+ PR_UnloadLibrary(lib);
-+ }
-+ return result;
-+}
-+
-+static nsIWidget* GetMainWidget(nsIDOMWindow* aWindow)
-+{
-+ // get the native window for this instance
-+ nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow));
-+ NS_ENSURE_TRUE(window, nsnull);
-+ nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
-+ NS_ENSURE_TRUE(doc, nsnull);
-+ nsCOMPtr<nsISupports> container = doc->GetContainer();
-+ nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(container));
-+ NS_ENSURE_TRUE(baseWindow, nsnull);
-+
-+ nsCOMPtr<nsIWidget> mainWidget;
-+ baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
-+ return mainWidget;
-+}
-+
-+static nsGTKToolkit* GetGTKToolkit()
-+{
-+ nsCOMPtr<nsIAppShellService> svc = do_GetService(NS_APPSHELLSERVICE_CONTRACTID);
-+ if (!svc)
-+ return nsnull;
-+ nsCOMPtr<nsIDOMWindowInternal> window;
-+ svc->GetHiddenDOMWindow(getter_AddRefs(window));
-+ if (!window)
-+ return nsnull;
-+ nsIWidget* widget = GetMainWidget(window);
-+ if (!widget)
-+ return nsnull;
-+ nsIToolkit* toolkit = widget->GetToolkit();
-+ if (!toolkit)
-+ return nsnull;
-+ return NS_STATIC_CAST(nsGTKToolkit*, toolkit);
-+}
-+
- #endif
-
- int
-@@ -2235,6 +2291,16 @@
- if (CheckArg("install"))
- gdk_rgb_set_install(TRUE);
-
-+#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_GTK2) || defined(MOZ_ENABLE_XREMOTE)
-+ // Stash DESKTOP_STARTUP_ID in malloc'ed memory becaus gtk_init will clear it.
-+#define HAVE_DESKTOP_STARTUP_ID
-+ const char* desktopStartupIDEnv = PR_GetEnv("DESKTOP_STARTUP_ID");
-+ nsCAutoString desktopStartupID;
-+ if (desktopStartupIDEnv) {
-+ desktopStartupID.Assign(desktopStartupIDEnv);
-+ }
-+#endif
-+
- // Initialize GTK+1/2 here for splash
- #if defined(MOZ_WIDGET_GTK)
- gtk_set_locale();
-@@ -2243,15 +2309,15 @@
-
- #if defined(MOZ_WIDGET_GTK2)
- // g_set_application_name () is only defined in glib2.2 and higher.
-- PRLibrary *glib2 = nsnull;
-- _g_set_application_name_fn _g_set_application_name =
-- (_g_set_application_name_fn)PR_FindFunctionSymbolAndLibrary("g_set_application_name", &glib2);
-+ _g_set_application_name_fn _g_set_application_name =
-+ (_g_set_application_name_fn)FindFunction("g_set_application_name");
- if (_g_set_application_name) {
- _g_set_application_name(gAppData->name);
- }
-- if (glib2) {
-- PR_UnloadLibrary(glib2);
-- }
-+ _gtk_window_set_auto_startup_notification_fn _gtk_window_set_auto_startup_notification =
-+ (_gtk_window_set_auto_startup_notification_fn)FindFunction("gtk_window_set_auto_startup_notification");
-+ if (_gtk_window_set_auto_startup_notification)
-+ _gtk_window_set_auto_startup_notification(PR_FALSE);
- #endif
-
- gtk_widget_set_default_visual(gdk_rgb_get_visual());
-@@ -2315,13 +2381,15 @@
- PR_fprintf(PR_STDERR, "Error: -remote requires an argument\n");
- return 1;
- }
-+ const char* desktopStartupIDPtr =
-+ desktopStartupID.IsEmpty() ? nsnull : desktopStartupID.get();
- if (ar) {
-- return HandleRemoteArgument(xremotearg);
-+ return HandleRemoteArgument(xremotearg, desktopStartupIDPtr);
- }
-
- if (!PR_GetEnv("MOZ_NO_REMOTE")) {
- // Try to remote the entire command line. If this fails, start up normally.
-- RemoteResult rr = RemoteCommandLine();
-+ RemoteResult rr = RemoteCommandLine(desktopStartupIDPtr);
- if (rr == REMOTE_FOUND)
- return 0;
- else if (rr == REMOTE_ARG_BAD)
-@@ -2533,6 +2601,13 @@
- NS_TIMELINE_LEAVE("appStartup->CreateHiddenWindow");
- NS_ENSURE_SUCCESS(rv, 1);
-
-+#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_WIDGET_GTK2)
-+ nsRefPtr<nsGTKToolkit> toolkit = GetGTKToolkit();
-+ if (toolkit && !desktopStartupID.IsEmpty()) {
-+ toolkit->SetDesktopStartupID(desktopStartupID);
-+ }
-+#endif
-+
- // Extension Compatibility Checking and Startup
- if (gAppData->flags & NS_XRE_ENABLE_EXTENSION_MANAGER) {
- nsCOMPtr<nsIExtensionManager> em(do_GetService("@mozilla.org/extensions/manager;1"));
-@@ -2713,6 +2788,21 @@
- }
- #endif
-
-+#if defined(HAVE_DESKTOP_STARTUP_ID) && defined(MOZ_TOOLKIT_GTK2)
-+ nsGTKToolkit* toolkit = GetGTKToolkit();
-+ if (toolkit) {
-+ nsCAutoString currentDesktopStartupID;
-+ toolkit->GetDesktopStartupID(&currentDesktopStartupID);
-+ if (!currentDesktopStartupID.IsEmpty()) {
-+ nsCAutoString desktopStartupEnv;
-+ desktopStartupEnv.AssignLiteral("DESKTOP_STARTUP_ID=");
-+ desktopStartupEnv.Append(currentDesktopStartupID);
-+ // Leak it with extreme prejudice!
-+ PR_SetEnv(ToNewCString(desktopStartupEnv));
-+ }
-+ }
-+#endif
-+
- rv = LaunchChild(nativeApp, appInitiatedRestart, upgraded ? -1 : 0);
- return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
- }
---- toolkit/xre/Makefile.in 2007-02-06 02:13:20.000000000 -0500
-+++ toolkit/xre/Makefile.in 2007-07-03 18:01:36.000000000 -0400
-@@ -69,6 +69,7 @@
- shellservice \
- string \
- uriloader \
-+ layout \
- widget \
- windowwatcher \
- xpcom \
---- configure.in 2007-04-03 11:40:02.000000000 -0400
-+++ configure.in 2007-07-03 18:01:36.000000000 -0400
-@@ -125,6 +125,7 @@
- GNOMEUI_VERSION=2.2.0
- GCONF_VERSION=1.2.1
- LIBGNOME_VERSION=2.0
-+STARTUP_NOTIFICATION_VERSION=0.8
-
- dnl Set various checks
- dnl ========================================================
-@@ -4156,6 +4157,41 @@
-
- AC_SUBST(MOZ_DEFAULT_TOOLKIT)
-
-+dnl ========================================================
-+dnl = startup-notification support module
-+dnl ========================================================
-+
-+if test "$MOZ_ENABLE_GTK2"
-+then
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=
-+
-+ MOZ_ARG_ENABLE_BOOL(startup-notification,
-+ [ --enable-startup-notification Enable startup-notification support (default: disabled) ],
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=force,
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=)
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
-+ then
-+ PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
-+ libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
-+ [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
-+ then
-+ AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
-+ fi
-+ MOZ_ENABLE_STARTUP_NOTIFICATION=
-+ ])
-+ fi
-+
-+ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
-+ AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
-+ fi
-+
-+ TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
-+fi
-+AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
-+AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
-+AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
-+
- AC_SUBST(GTK_CONFIG)
- AC_SUBST(TK_CFLAGS)
- AC_SUBST(TK_LIBS)
---- widget/src/gtk2/nsWindow.cpp 2007-04-19 14:46:03.000000000 -0400
-+++ widget/src/gtk2/nsWindow.cpp 2007-07-03 18:01:36.000000000 -0400
-@@ -40,7 +40,7 @@
- #include "prlink.h"
-
- #include "nsWindow.h"
--#include "nsToolkit.h"
-+#include "nsGTKToolkit.h"
- #include "nsIRenderingContext.h"
- #include "nsIRegion.h"
- #include "nsIRollupListener.h"
-@@ -58,6 +58,13 @@
- #include <gdk/gdkx.h>
- #include <gdk/gdkkeysyms.h>
-
-+#ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
-+#define SN_API_NOT_YET_FROZEN
-+#pragma GCC visibility push(default)
-+#include <startup-notification-1.0/libsn/sn.h>
-+#pragma GCC visibility pop
-+#endif
-+
- #include "gtk2xtbin.h"
-
- #include "nsIPrefService.h"
-@@ -660,6 +665,75 @@
- return NS_ERROR_NOT_IMPLEMENTED;
- }
-
-+typedef void (* SetUserTimeFunc)(GdkWindow* aWindow, guint32 aTimestamp);
-+
-+// This will become obsolete when new GTK APIs are widely supported,
-+// as described here: http://bugzilla.gnome.org/show_bug.cgi?id=347375
-+static void
-+SetUserTimeAndStartupIDForActivatedWindow(GtkWidget* aWindow)
-+{
-+ nsCOMPtr<nsIToolkit> toolkit;
-+ NS_GetCurrentToolkit(getter_AddRefs(toolkit));
-+ if (!toolkit)
-+ return;
-+
-+ nsGTKToolkit* GTKToolkit = NS_STATIC_CAST(nsGTKToolkit*,
-+ NS_STATIC_CAST(nsIToolkit*, toolkit));
-+ nsCAutoString desktopStartupID;
-+ GTKToolkit->GetDesktopStartupID(&desktopStartupID);
-+ if (desktopStartupID.IsEmpty()) {
-+ // We don't have the data we need. Fall back to an
-+ // approximation ... using the timestamp of the remote command
-+ // being received as a guess for the timestamp of the user event
-+ // that triggered it.
-+ PRUint32 timestamp = GTKToolkit->GetFocusTimestamp();
-+ if (timestamp) {
-+ gdk_window_focus(aWindow->window, timestamp);
-+ GTKToolkit->SetFocusTimestamp(0);
-+ }
-+ return;
-+ }
-+
-+#ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
-+ GdkDrawable* drawable = GDK_DRAWABLE(aWindow->window);
-+ GtkWindow* win = GTK_WINDOW(aWindow);
-+ if (!win) {
-+ NS_WARNING("Passed in widget was not a GdkWindow!");
-+ return;
-+ }
-+ GdkScreen* screen = gtk_window_get_screen(win);
-+ SnDisplay* snd =
-+ sn_display_new(gdk_x11_drawable_get_xdisplay(drawable), nsnull, nsnull);
-+ if (!snd)
-+ return;
-+ SnLauncheeContext* ctx =
-+ sn_launchee_context_new(snd, gdk_screen_get_number(screen),
-+ desktopStartupID.get());
-+ if (!ctx) {
-+ sn_display_unref(snd);
-+ return;
-+ }
-+
-+ if (sn_launchee_context_get_id_has_timestamp(ctx)) {
-+ PRLibrary* gtkLibrary;
-+ SetUserTimeFunc setUserTimeFunc = (SetUserTimeFunc)
-+ PR_FindFunctionSymbolAndLibrary("gdk_x11_window_set_user_time", &gtkLibrary);
-+ if (setUserTimeFunc) {
-+ setUserTimeFunc(aWindow->window, sn_launchee_context_get_timestamp(ctx));
-+ PR_UnloadLibrary(gtkLibrary);
-+ }
-+ }
-+
-+ sn_launchee_context_setup_window(ctx, gdk_x11_drawable_get_xid(drawable));
-+ sn_launchee_context_complete(ctx);
-+
-+ sn_launchee_context_unref(ctx);
-+ sn_display_unref(snd);
-+#endif
-+
-+ GTKToolkit->SetDesktopStartupID(EmptyCString());
-+}
-+
- NS_IMETHODIMP
- nsWindow::SetFocus(PRBool aRaise)
- {
-@@ -680,6 +754,10 @@
- // set properly.
- GtkWidget *toplevelWidget = gtk_widget_get_toplevel(owningWidget);
-
-+ if (toplevelWidget && aRaise) {
-+ SetUserTimeAndStartupIDForActivatedWindow(toplevelWidget);
-+ }
-+
- if (gRaiseWindows && aRaise && toplevelWidget &&
- !GTK_WIDGET_HAS_FOCUS(owningWidget) &&
- !GTK_WIDGET_HAS_FOCUS(toplevelWidget)) {
-@@ -1167,7 +1245,7 @@
-
- case NS_NATIVE_GRAPHIC: {
- NS_ASSERTION(nsnull != mToolkit, "NULL toolkit, unable to get a GC");
-- return (void *)NS_STATIC_CAST(nsToolkit *, mToolkit)->GetSharedGC();
-+ return (void *)NS_STATIC_CAST(nsGTKToolkit *, mToolkit)->GetSharedGC();
- break;
- }
-
-@@ -2802,13 +2880,18 @@
- // is shown.
- // XXX that may or may not be true for GTK+ 2.x
- if (mTransparencyBitmap) {
-- ApplyTransparencyBitmap();
-+ ApplyTransparencyBitmap();
- }
-
- // unset our flag now that our window has been shown
- mNeedsShow = PR_FALSE;
-
- if (mIsTopLevel) {
-+ // Set up usertime/startupID metadata for the created window.
-+ if (mWindowType != eWindowType_invisible) {
-+ SetUserTimeAndStartupIDForActivatedWindow(mShell);
-+ }
-+
- moz_drawingarea_set_visibility(mDrawingarea, aAction);
- gtk_widget_show(GTK_WIDGET(mContainer));
- gtk_widget_show(mShell);
---- widget/src/gtk2/Makefile.in 2006-06-17 11:16:14.000000000 -0400
-+++ widget/src/gtk2/Makefile.in 2007-07-03 18:01:36.000000000 -0400
-@@ -97,6 +97,7 @@
- $(MOZ_COMPONENT_LIBS) \
- -lgkgfx \
- -lgtkxtbin \
-+ $(MOZ_STARTUP_NOTIFICATION_LIBS) \
- $(XLDFLAGS) \
- $(XLIBS) \
- $(MOZ_GTK2_LIBS)
-@@ -107,14 +108,15 @@
-
- EXPORTS = \
- nsIGdkPixbufImage.h \
-+ nsGTKToolkit.h \
- mozdrawingarea.h \
- mozcontainer.h \
- $(NULL)
-
- include $(topsrcdir)/config/rules.mk
-
--CFLAGS += $(MOZ_GTK2_CFLAGS)
--CXXFLAGS += $(MOZ_GTK2_CFLAGS)
-+CFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_STARTUP_NOTIFICATION_CFLAGS)
-+CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_STARTUP_NOTIFICATION_CFLAGS)
-
- DEFINES += -DUSE_XIM
-
---- widget/src/gtk2/nsToolkit.cpp 2004-04-18 18:00:17.000000000 -0400
-+++ widget/src/gtk2/nsToolkit.cpp 2007-07-03 18:01:36.000000000 -0400
-@@ -38,7 +38,7 @@
- * ***** END LICENSE BLOCK ***** */
-
- #include "nscore.h" // needed for 'nsnull'
--#include "nsToolkit.h"
-+#include "nsGTKToolkit.h"
-
- //
- // Static thread local storage index of the Toolkit
-@@ -51,9 +51,10 @@
- // constructor
- //
- //-------------------------------------------------------------------------
--nsToolkit::nsToolkit()
-+nsGTKToolkit::nsGTKToolkit()
- {
- mSharedGC = nsnull;
-+ mFocusTimestamp = 0;
- }
-
- //-------------------------------------------------------------------------
-@@ -61,7 +62,7 @@
- // destructor
- //
- //-------------------------------------------------------------------------
--nsToolkit::~nsToolkit()
-+nsGTKToolkit::~nsGTKToolkit()
- {
- if (mSharedGC) {
- gdk_gc_unref(mSharedGC);
-@@ -77,9 +78,9 @@
- //
- //-------------------------------------------------------------------------
-
--NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
-+NS_IMPL_ISUPPORTS1(nsGTKToolkit, nsIToolkit)
-
--void nsToolkit::CreateSharedGC(void)
-+void nsGTKToolkit::CreateSharedGC(void)
- {
- GdkPixmap *pixmap;
-
-@@ -91,7 +92,7 @@
- gdk_pixmap_unref(pixmap);
- }
-
--GdkGC *nsToolkit::GetSharedGC(void)
-+GdkGC *nsGTKToolkit::GetSharedGC(void)
- {
- return gdk_gc_ref(mSharedGC);
- }
-@@ -100,7 +101,7 @@
- //
- //
- //-------------------------------------------------------------------------
--NS_IMETHODIMP nsToolkit::Init(PRThread *aThread)
-+NS_IMETHODIMP nsGTKToolkit::Init(PRThread *aThread)
- {
- CreateSharedGC();
-
-@@ -135,7 +136,7 @@
- // Create a new toolkit for this thread...
- //
- if (!toolkit) {
-- toolkit = new nsToolkit();
-+ toolkit = new nsGTKToolkit();
-
- if (!toolkit) {
- rv = NS_ERROR_OUT_OF_MEMORY;
---- widget/src/xremoteclient/mozilla-xremote-client.cpp 2005-04-04 15:08:51.000000000 -0400
-+++ widget/src/xremoteclient/mozilla-xremote-client.cpp 2007-07-03 18:01:36.000000000 -0400
-@@ -40,6 +40,7 @@
- #include <stdlib.h>
- #include <string.h>
- #include <plgetopt.h>
-+#include <prenv.h>
- #ifdef MOZ_WIDGET_PHOTON
- #include "PhRemoteClient.h"
- #else
-@@ -99,7 +100,7 @@
- // send the command - it doesn't get any easier than this
- PRBool success = PR_FALSE;
- char *error = 0;
-- rv = client.SendCommand(browser, username, profile, command,
-+ rv = client.SendCommand(browser, username, profile, command, nsnull,
- &error, &success);
-
- // failed to send command
---- widget/src/xremoteclient/XRemoteClient.cpp 2006-03-30 03:01:13.000000000 -0500
-+++ widget/src/xremoteclient/XRemoteClient.cpp 2007-07-03 18:01:36.000000000 -0400
-@@ -173,6 +173,7 @@
- nsresult
- XRemoteClient::SendCommand (const char *aProgram, const char *aUsername,
- const char *aProfile, const char *aCommand,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aWindowFound)
- {
- PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XRemoteClient::SendCommand"));
-@@ -198,7 +199,7 @@
-
- if (NS_SUCCEEDED(rv)) {
- // send our command
-- rv = DoSendCommand(w, aCommand, aResponse, &destroyed);
-+ rv = DoSendCommand(w, aCommand, aDesktopStartupID, aResponse, &destroyed);
-
- // if the window was destroyed, don't bother trying to free the
- // lock.
-@@ -217,6 +218,7 @@
- XRemoteClient::SendCommandLine (const char *aProgram, const char *aUsername,
- const char *aProfile,
- PRInt32 argc, char **argv,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aWindowFound)
- {
- PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XRemoteClient::SendCommandLine"));
-@@ -242,7 +244,7 @@
-
- if (NS_SUCCEEDED(rv)) {
- // send our command
-- rv = DoSendCommandLine(w, argc, argv, aResponse, &destroyed);
-+ rv = DoSendCommandLine(w, argc, argv, aDesktopStartupID, aResponse, &destroyed);
-
- // if the window was destroyed, don't bother trying to free the
- // lock.
-@@ -643,6 +645,7 @@
-
- nsresult
- XRemoteClient::DoSendCommand(Window aWindow, const char *aCommand,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aDestroyed)
- {
- *aDestroyed = PR_FALSE;
-@@ -651,9 +654,28 @@
- ("(writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x)\n",
- aCommand, (unsigned int) aWindow));
-
-+ // We add the DESKTOP_STARTUP_ID setting as an extra line of
-+ // the command string. Firefox ignores all lines but the first.
-+ static char desktopStartupPrefix[] = "\nDESKTOP_STARTUP_ID=";
-+
-+ PRInt32 len = strlen(aCommand);
-+ if (aDesktopStartupID) {
-+ len += sizeof(desktopStartupPrefix) - 1 + strlen(aDesktopStartupID);
-+ }
-+ char* buffer = (char*)malloc(len + 1);
-+ if (!buffer)
-+ return NS_ERROR_OUT_OF_MEMORY;
-+
-+ strcpy(buffer, aCommand);
-+ if (aDesktopStartupID) {
-+ strcat(buffer, desktopStartupPrefix);
-+ strcat(buffer, aDesktopStartupID);
-+ }
-+
- XChangeProperty (mDisplay, aWindow, mMozCommandAtom, XA_STRING, 8,
-- PropModeReplace, (unsigned char *)aCommand,
-- strlen(aCommand));
-+ PropModeReplace, (unsigned char *)buffer, len);
-+
-+ free(buffer);
-
- if (!WaitForResponse(aWindow, aResponse, aDestroyed, mMozCommandAtom))
- return NS_ERROR_FAILURE;
-@@ -663,7 +685,7 @@
-
- /* like strcpy, but return the char after the final null */
- static char*
--estrcpy(char* s, char* d)
-+estrcpy(const char* s, char* d)
- {
- while (*s)
- *d++ = *s++;
-@@ -674,6 +696,7 @@
-
- nsresult
- XRemoteClient::DoSendCommandLine(Window aWindow, PRInt32 argc, char **argv,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aDestroyed)
- {
- int i;
-@@ -690,9 +713,16 @@
- // [argc][offsetargv0][offsetargv1...]<workingdir>\0<argv[0]>\0argv[1]...\0
- // (offset is from the beginning of the buffer)
-
-+ static char desktopStartupPrefix[] = " DESKTOP_STARTUP_ID=";
-+
- PRInt32 argvlen = strlen(cwdbuf);
-- for (i = 0; i < argc; ++i)
-- argvlen += strlen(argv[i]);
-+ for (i = 0; i < argc; ++i) {
-+ PRInt32 len = strlen(argv[i]);
-+ if (i == 0 && aDesktopStartupID) {
-+ len += sizeof(desktopStartupPrefix) - 1 + strlen(aDesktopStartupID);
-+ }
-+ argvlen += len;
-+ }
-
- PRInt32* buffer = (PRInt32*) malloc(argvlen + argc + 1 +
- sizeof(PRInt32) * (argc + 1));
-@@ -708,6 +738,10 @@
- for (int i = 0; i < argc; ++i) {
- buffer[i + 1] = TO_LITTLE_ENDIAN32(bufend - ((char*) buffer));
- bufend = estrcpy(argv[i], bufend);
-+ if (i == 0 && aDesktopStartupID) {
-+ bufend = estrcpy(desktopStartupPrefix, bufend - 1);
-+ bufend = estrcpy(aDesktopStartupID, bufend - 1);
-+ }
- }
-
- #ifdef DEBUG_bsmedberg
---- widget/src/xremoteclient/nsRemoteClient.h 2005-04-04 15:08:51.000000000 -0400
-+++ widget/src/xremoteclient/nsRemoteClient.h 2007-07-03 18:01:36.000000000 -0400
-@@ -76,6 +76,10 @@
- * @param aCommand This is the command that is passed to the server.
- * Please see the additional information located at:
- * http://www.mozilla.org/unix/remote.html
-+ *
-+ * @param aDesktopStartupID the contents of the DESKTOP_STARTUP_ID environment
-+ * variable defined by the Startup Notification specification
-+ * http://standards.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt
- *
- * @param aResponse If there is a response, it will be here. This
- * includes error messages. The string is allocated using stdlib
-@@ -85,11 +89,16 @@
- */
- virtual nsresult SendCommand(const char *aProgram, const char *aUsername,
- const char *aProfile, const char *aCommand,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aSucceeded) = 0;
-
- /**
- * Send a complete command line to a running instance.
- *
-+ * @param aDesktopStartupID the contents of the DESKTOP_STARTUP_ID environment
-+ * variable defined by the Startup Notification specification
-+ * http://standards.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt
-+ *
- * @see sendCommand
- * @param argc The number of command-line arguments.
- *
-@@ -97,6 +106,7 @@
- virtual nsresult SendCommandLine(const char *aProgram, const char *aUsername,
- const char *aProfile,
- PRInt32 argc, char **argv,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aSucceeded) = 0;
- };
-
---- widget/src/xremoteclient/XRemoteClient.h 2006-03-30 03:01:13.000000000 -0500
-+++ widget/src/xremoteclient/XRemoteClient.h 2007-07-03 18:01:36.000000000 -0400
-@@ -48,10 +48,12 @@
- virtual nsresult Init();
- virtual nsresult SendCommand(const char *aProgram, const char *aUsername,
- const char *aProfile, const char *aCommand,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aSucceeded);
- virtual nsresult SendCommandLine(const char *aProgram, const char *aUsername,
- const char *aProfile,
- PRInt32 argc, char **argv,
-+ const char* aDesktopStartupID,
- char **aResponse, PRBool *aSucceeded);
- void Shutdown();
-
-@@ -67,10 +69,12 @@
- PRBool aSupportsCommandLine);
- nsresult DoSendCommand (Window aWindow,
- const char *aCommand,
-+ const char* aDesktopStartupID,
- char **aResponse,
- PRBool *aDestroyed);
- nsresult DoSendCommandLine(Window aWindow,
- PRInt32 argc, char **argv,
-+ const char* aDesktopStartupID,
- char **aResponse,
- PRBool *aDestroyed);
- PRBool WaitForResponse (Window aWindow, char **aResponse,
---- /dev/null 2007-07-05 17:03:04.116204904 -0400
-+++ widget/src/gtk2/nsGTKToolkit.h 2007-07-03 18:01:36.000000000 -0400
-@@ -0,0 +1,87 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-+/* vim:expandtab:shiftwidth=4:tabstop=4:
-+ */
-+/* ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is
-+ * Netscape Communications Corporation.
-+ * Portions created by the Initial Developer are Copyright (C) 1998
-+ * the Initial Developer. All Rights Reserved.
-+ *
-+ * Contributor(s):
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either the GNU General Public License Version 2 or later (the "GPL"), or
-+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#ifndef GTKTOOLKIT_H
-+#define GTKTOOLKIT_H
-+
-+#include "nsIToolkit.h"
-+#include "nsString.h"
-+#include <gtk/gtk.h>
-+
-+/**
-+ * Wrapper around the thread running the message pump.
-+ * The toolkit abstraction is necessary because the message pump must
-+ * execute within the same thread that created the widget under Win32.
-+ */
-+
-+class nsGTKToolkit : public nsIToolkit
-+{
-+public:
-+ nsGTKToolkit();
-+ virtual ~nsGTKToolkit();
-+
-+ NS_DECL_ISUPPORTS
-+
-+ NS_IMETHOD Init(PRThread *aThread);
-+
-+ void CreateSharedGC(void);
-+ GdkGC *GetSharedGC(void);
-+
-+ /**
-+ * Get/set our value of DESKTOP_STARTUP_ID. When non-empty, this is applied
-+ * to the next toplevel window to be shown or focused (and then immediately
-+ * cleared).
-+ */
-+ void SetDesktopStartupID(const nsACString& aID) { mDesktopStartupID = aID; }
-+ void GetDesktopStartupID(nsACString* aID) { *aID = mDesktopStartupID; }
-+
-+ /**
-+ * Get/set the timestamp value to be used, if non-zero, to focus the
-+ * next top-level window to be shown or focused (upon which it is cleared).
-+ */
-+ void SetFocusTimestamp(PRUint32 aTimestamp) { mFocusTimestamp = aTimestamp; }
-+ PRUint32 GetFocusTimestamp() { return mFocusTimestamp; }
-+
-+private:
-+ GdkGC *mSharedGC;
-+ nsCString mDesktopStartupID;
-+ PRUint32 mFocusTimestamp;
-+};
-+
-+#endif // GTKTOOLKIT_H
diff --git a/firefox-2.0.0.4-undo-uriloader.patch b/firefox-2.0.0.4-undo-uriloader.patch
deleted file mode 100644
index f2c419b..0000000
--- a/firefox-2.0.0.4-undo-uriloader.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-Index: mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp
-===================================================================
-RCS file: /cvsroot/mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp,v
-retrieving revision 1.58.20.1
-retrieving revision 1.58
-diff -d -u -p -r1.58.20.1 -r1.58
---- mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp 16 Apr 2007 18:54:53 -0000 1.58.20.1
-+++ mozilla/uriloader/exthandler/unix/nsOSHelperAppService.cpp 25 Oct 2004 07:46:01 -0000 1.58
-@@ -1506,8 +1506,13 @@ nsOSHelperAppService::GetFromType(const
-
- nsDependentSubstring majorType(majorTypeStart, majorTypeEnd);
- nsDependentSubstring minorType(minorTypeStart, minorTypeEnd);
-+ nsAutoString extensions, mime_types_description;
-+ LookUpExtensionsAndDescription(majorType,
-+ minorType,
-+ extensions,
-+ mime_types_description);
-+
-
-- // First check the user's private mailcap file
- nsAutoString mailcap_description, handler, mozillaFlags;
- DoLookUpHandlerAndDescription(majorType,
- minorType,
-@@ -1516,46 +1521,23 @@ nsOSHelperAppService::GetFromType(const
- mailcap_description,
- mozillaFlags,
- PR_TRUE);
--
-- LOG(("Private Handler/Description results: handler='%s', description='%s'\n",
-- NS_LossyConvertUTF16toASCII(handler).get(),
-- NS_LossyConvertUTF16toASCII(mailcap_description).get()));
-
-+
-+ if (handler.IsEmpty() && extensions.IsEmpty() &&
-+ mailcap_description.IsEmpty() && mime_types_description.IsEmpty()) {
-+ // No useful data yet
-+
- #ifdef MOZ_WIDGET_GTK2
-- nsMIMEInfoBase *gnomeInfo = nsnull;
-- if (handler.IsEmpty()) {
-- // No useful data yet. Check the GNOME registry. Unfortunately, newer
-- // GNOME versions no longer have type-to-extension mappings, so we might
-- // get back a MIMEInfo without any extensions set. In that case we'll have
-- // to look in our mime.types files for the extensions.
- LOG(("Looking in GNOME registry\n"));
-- gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType.get()).get();
-- if (gnomeInfo && gnomeInfo->HasExtensions()) {
-- LOG(("Got MIMEInfo from GNOME registry, and it has extensions set\n"));
-+ nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType.get()).get();
-+ if (gnomeInfo) {
-+ LOG(("Got MIMEInfo from GNOME registry\n"));
- return gnomeInfo;
- }
-- }
- #endif
--
-- // Now look up our extensions
-- nsAutoString extensions, mime_types_description;
-- LookUpExtensionsAndDescription(majorType,
-- minorType,
-- extensions,
-- mime_types_description);
--
--#ifdef MOZ_WIDGET_GTK2
-- if (gnomeInfo) {
-- LOG(("Got MIMEInfo from GNOME registry without extensions; setting them "
-- "to %s\n", NS_LossyConvertUTF16toASCII(extensions).get()));
--
-- NS_ASSERTION(!gnomeInfo->HasExtensions(), "How'd that happen?");
-- gnomeInfo->SetFileExtensions(NS_ConvertUTF16toUTF8(extensions));
-- return gnomeInfo;
- }
--#endif
-
-- if (handler.IsEmpty()) {
-+ if (handler.IsEmpty() && mailcap_description.IsEmpty()) {
- DoLookUpHandlerAndDescription(majorType,
- minorType,
- typeOptions,
-@@ -1565,7 +1547,7 @@ nsOSHelperAppService::GetFromType(const
- PR_FALSE);
- }
-
-- if (handler.IsEmpty()) {
-+ if (handler.IsEmpty() && mailcap_description.IsEmpty()) {
- DoLookUpHandlerAndDescription(majorType,
- NS_LITERAL_STRING("*"),
- typeOptions,
-@@ -1575,7 +1557,7 @@ nsOSHelperAppService::GetFromType(const
- PR_TRUE);
- }
-
-- if (handler.IsEmpty()) {
-+ if (handler.IsEmpty() && mailcap_description.IsEmpty()) {
- DoLookUpHandlerAndDescription(majorType,
- NS_LITERAL_STRING("*"),
- typeOptions,
diff --git a/firefox-mozconfig b/firefox-mozconfig
index 84cb769..eb6b433 100755
--- a/firefox-mozconfig
+++ b/firefox-mozconfig
@@ -6,21 +6,23 @@ ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-jpeg
ac_add_options --with-system-zlib
-ac_add_options --with-system-png
+#ac_add_options --with-system-png
ac_add_options --with-pthreads
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-installer
ac_add_options --enable-optimize="$RPM_OPT_FLAGS"
ac_add_options --enable-xinerama
-ac_add_options --enable-default-toolkit=gtk2
+ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --disable-xprint
ac_add_options --disable-strip
+ac_add_options --disable-system-cairo
ac_add_options --enable-pango
-ac_add_options --enable-system-cairo
ac_add_options --enable-svg
ac_add_options --enable-canvas
ac_add_options --enable-startup-notification
+ac_add_options --with-libxul-sdk=/usr/lib64/xulrunner-sdk-1.9pre
+ac_add_options --enable-libxul
export BUILD_OFFICIAL=1
export MOZILLA_OFFICIAL=1
diff --git a/firefox-path.patch b/firefox-path.patch
deleted file mode 100644
index c18f385..0000000
--- a/firefox-path.patch
+++ /dev/null
@@ -1,260 +0,0 @@
---- mozilla/toolkit/xre/nsAppRunner.h.old 2007-09-25 18:01:56.000000000 +0200
-+++ mozilla/toolkit/xre/nsAppRunner.h 2007-09-25 18:02:23.000000000 +0200
-@@ -48,7 +48,8 @@
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/toolkit/mozapps/update/src/updater/updater.cpp.old mozilla/toolkit/mozapps/update/src/updater/updater.cpp
---- mozilla/toolkit/mozapps/update/src/updater/updater.cpp.old 2007-09-25 18:00:26.000000000 +0200
-+++ mozilla/toolkit/mozapps/update/src/updater/updater.cpp 2007-09-25 18:00:53.000000000 +0200
-@@ -107,7 +107,8 @@ void LaunchChild(int argc, char **argv);
- # elif defined(CCHMAXPATH)
- # define MAXPATHLEN CCHMAXPATH
- # else
--# define MAXPATHLEN 1024
-+# include <limits.h>
-+# define MAXPATHLEN PATH_MAX
- # endif
- #endif
-
-diff -up mozilla/mailnews/import/comm4x/src/nsComm4xProfile.cpp.old mozilla/mailnews/import/comm4x/src/nsComm4xProfile.cpp
---- mozilla/mailnews/import/comm4x/src/nsComm4xProfile.cpp.old 2007-09-25 17:58:43.000000000 +0200
-+++ mozilla/mailnews/import/comm4x/src/nsComm4xProfile.cpp 2007-09-25 17:59:22.000000000 +0200
-@@ -70,7 +70,8 @@
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/xpcom/io/SpecialSystemDirectory.cpp.old mozilla/xpcom/io/SpecialSystemDirectory.cpp
---- mozilla/xpcom/io/SpecialSystemDirectory.cpp.old 2007-09-25 18:04:25.000000000 +0200
-+++ mozilla/xpcom/io/SpecialSystemDirectory.cpp 2007-09-25 18:04:48.000000000 +0200
-@@ -109,7 +109,8 @@
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/xpcom/obsolete/nsFileSpecUnix.cpp.old mozilla/xpcom/obsolete/nsFileSpecUnix.cpp
---- mozilla/xpcom/obsolete/nsFileSpecUnix.cpp.old 2006-11-28 01:18:37.000000000 +0100
-+++ mozilla/xpcom/obsolete/nsFileSpecUnix.cpp 2007-09-25 18:05:49.000000000 +0200
-@@ -79,7 +79,8 @@
- #endif
-
- #ifndef MAXPATHLEN
--#define MAXPATHLEN 1024 /* Guessing this is okay. Works for SCO. */
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX /* Guessing this is okay. Works for SCO. */
- #endif
-
- #if defined(__QNX__)
-diff -up mozilla/xpcom/build/nsXPCOMPrivate.h.old mozilla/xpcom/build/nsXPCOMPrivate.h
---- mozilla/xpcom/build/nsXPCOMPrivate.h.old 2007-09-25 18:02:58.000000000 +0200
-+++ mozilla/xpcom/build/nsXPCOMPrivate.h 2007-09-25 18:03:15.000000000 +0200
-@@ -252,7 +252,8 @@ NS_GetFrozenFunctions(XPCOMFunctions *en
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/dbm/include/mcom_db.h.old mozilla/dbm/include/mcom_db.h
---- mozilla/dbm/include/mcom_db.h.old 2007-09-25 17:57:09.000000000 +0200
-+++ mozilla/dbm/include/mcom_db.h 2007-09-25 17:57:49.000000000 +0200
-@@ -214,7 +214,8 @@
- #endif /* __DBINTERFACE_PRIVATE */
-
- #ifdef SCO
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
-
- #include <fcntl.h>
-diff -up mozilla/browser/components/migration/src/nsProfileMigrator.cpp.old mozilla/browser/components/migration/src/nsProfileMigrator.cpp
---- mozilla/browser/components/migration/src/nsProfileMigrator.cpp.old 2007-09-25 17:55:11.000000000 +0200
-+++ mozilla/browser/components/migration/src/nsProfileMigrator.cpp 2007-09-25 18:07:56.000000000 +0200
-@@ -73,7 +73,8 @@
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp.old mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp
---- mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp.old 2007-09-25 17:53:36.000000000 +0200
-+++ mozilla/browser/components/migration/src/nsDogbertProfileMigrator.cpp 2007-09-25 18:07:37.000000000 +0200
-@@ -35,6 +35,7 @@
- *
- * ***** END LICENSE BLOCK ***** */
-
-+
- #include "nsAppDirectoryServiceDefs.h"
- #include "nsBrowserProfileMigratorUtils.h"
- #include "nsCRT.h"
-@@ -66,7 +67,8 @@
- #elif defined(CCHMAXPATH)
- #define MAXPATHLEN CCHMAXPATH
- #else
--#define MAXPATHLEN 1024
-+#include <limits.h>
-+#define MAXPATHLEN PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/nsprpub/config/nsinstall.c.old mozilla/nsprpub/config/nsinstall.c
-diff -up mozilla/js/src/jsfile.c.old mozilla/js/src/jsfile.c
---- mozilla/js/src/jsfile.c.old 2006-07-26 20:55:08.000000000 +0200
-+++ mozilla/js/src/jsfile.c 2007-09-25 18:22:52.000000000 +0200
-@@ -105,7 +105,8 @@
- #define utfstring "binary"
- #define unicodestring "unicode"
-
--#define MAX_PATH_LENGTH 1024
-+#include <limits.h>
-+#define MAX_PATH_LENGTH PATH_MAX
- #define MODE_SIZE 256
- #define NUMBER_SIZE 32
- #define MAX_LINE_LENGTH 256
-diff -up mozilla/webshell/tests/viewer/nsViewerApp.cpp.old mozilla/webshell/tests/viewer/nsViewerApp.cpp
---- mozilla/webshell/tests/viewer/nsViewerApp.cpp.old 2007-09-25 18:34:51.000000000 +0200
-+++ mozilla/webshell/tests/viewer/nsViewerApp.cpp 2007-09-25 18:35:33.000000000 +0200
-@@ -692,7 +692,8 @@ nsViewerApp::OpenWindow(PRUint32 aNewChr
-
- #if !defined(XP_WIN) && !defined(XP_OS2)
- #ifndef XP_MAC
--#define _MAX_PATH 512
-+#include <limits.h>
-+#define _MAX_PATH PATH_MAX
- #endif
- #endif
-
-diff -up mozilla/xpcom/typelib/xpidl/xpidl_java.c.old mozilla/xpcom/typelib/xpidl/xpidl_java.c
---- mozilla/xpcom/typelib/xpidl/xpidl_java.c.old 2007-09-25 18:38:52.000000000 +0200
-+++ mozilla/xpcom/typelib/xpidl/xpidl_java.c 2007-09-25 18:39:17.000000000 +0200
-@@ -44,6 +44,7 @@
- #include "xpidl.h"
- #include <ctype.h>
- #include <glib.h>
-+#include <limits.h>
-
- #ifdef XP_WIN
- #include <windef.h>
-diff -up mozilla/widget/src/xremoteclient/XRemoteClient.cpp.old mozilla/widget/src/xremoteclient/XRemoteClient.cpp
---- mozilla/widget/src/xremoteclient/XRemoteClient.cpp.old 2007-09-25 18:14:08.000000000 +0200
-+++ mozilla/widget/src/xremoteclient/XRemoteClient.cpp 2007-09-25 18:36:55.000000000 +0200
-@@ -76,7 +76,8 @@
- #endif
-
- #ifndef MAX_PATH
--#define MAX_PATH 1024
-+#include <limits.h>
-+#define MAX_PATH PATH_MAX
- #endif
-
- #define ARRAY_LENGTH(array_) (sizeof(array_)/sizeof(array_[0]))
-diff -up mozilla/modules/libreg/src/reg.c.old mozilla/modules/libreg/src/reg.c
---- mozilla/modules/libreg/src/reg.c.old 2007-09-25 18:25:02.000000000 +0200
-+++ mozilla/modules/libreg/src/reg.c 2007-09-25 18:27:46.000000000 +0200
-@@ -96,7 +96,8 @@
- #define MAX_PATH PATH_MAX
- #elif defined(XP_UNIX)
- #ifndef MAX_PATH
--#define MAX_PATH 1024
-+#include <limits.h>
-+#define MAX_PATH PATH_MAX
- #endif
- #elif defined(XP_OS2)
- #ifndef MAX_PATH
-diff -up mozilla/directory/c-sdk/config/pathsub.h.old mozilla/directory/c-sdk/config/pathsub.h
---- mozilla/directory/c-sdk/config/pathsub.h.old 2006-02-03 15:41:18.000000000 +0100
-+++ mozilla/directory/c-sdk/config/pathsub.h 2007-09-25 18:48:58.000000000 +0200
-@@ -50,7 +50,7 @@
- #endif
-
- #ifndef PATH_MAX
--#define PATH_MAX 1024
-+#error "PATH_MAX is not defined!"
- #endif
-
- /*
-diff -up mozilla/config/pathsub.h.old mozilla/config/pathsub.h
---- mozilla/config/pathsub.h.old 2004-04-18 16:17:25.000000000 +0200
-+++ mozilla/config/pathsub.h 2007-09-25 18:48:13.000000000 +0200
-@@ -46,7 +46,7 @@
- #include <sys/types.h>
-
- #ifndef PATH_MAX
--#define PATH_MAX 1024
-+#error "PATH_MAX is not defined!"
- #endif
-
- /*
-diff -up mozilla/modules/libjar/nsZipArchive.cpp.old mozilla/modules/libjar/nsZipArchive.cpp
---- mozilla/modules/libjar/nsZipArchive.cpp.old 2006-09-13 20:32:37.000000000 +0200
-+++ mozilla/modules/libjar/nsZipArchive.cpp 2007-09-25 18:51:00.000000000 +0200
-@@ -121,7 +121,7 @@ char * strdup(const char *src)
- # define S_IFLNK 0120000
- # endif
- # ifndef PATH_MAX
--# define PATH_MAX 1024
-+# include <limits.h>
- # endif
- #endif /* XP_UNIX */
-
-diff -up mozilla/nsprpub/config/pathsub.h.old mozilla/nsprpub/config/pathsub.h
---- mozilla/nsprpub/config/pathsub.h.old 2004-04-25 17:00:34.000000000 +0200
-+++ mozilla/nsprpub/config/pathsub.h 2007-09-25 18:57:51.000000000 +0200
-@@ -50,7 +50,7 @@
- #endif
-
- #ifndef PATH_MAX
--#define PATH_MAX 1024
-+#error "PATH_MAX is not defined!"
- #endif
-
- /*
-diff -up mozilla/gfx/src/gtk/nsPrintdGTK.h.old mozilla/gfx/src/gtk/nsPrintdGTK.h
---- mozilla/gfx/src/gtk/nsPrintdGTK.h.old 2004-04-17 23:52:29.000000000 +0200
-+++ mozilla/gfx/src/gtk/nsPrintdGTK.h 2007-09-25 18:56:48.000000000 +0200
-@@ -63,7 +63,7 @@ PR_BEGIN_EXTERN_C
- #ifdef _POSIX_PATH_MAX
- #define PATH_MAX _POSIX_PATH_MAX
- #else
--#define PATH_MAX 256
-+#error "PATH_MAX is not defined!"
- #endif
- #endif
-
-diff -up mozilla/security/coreconf/nsinstall/pathsub.h.old mozilla/security/coreconf/nsinstall/pathsub.h
---- mozilla/security/coreconf/nsinstall/pathsub.h.old 2004-04-25 17:02:18.000000000 +0200
-+++ mozilla/security/coreconf/nsinstall/pathsub.h 2007-09-25 19:00:35.000000000 +0200
-@@ -49,7 +49,7 @@
- #endif
-
- #ifndef PATH_MAX
--#define PATH_MAX 1024
-+#error "PATH_MAX is not defined!"
- #endif
-
- /*
diff --git a/firefox.spec b/firefox.spec
index a8a7e6a..7c8a898 100644
--- a/firefox.spec
+++ b/firefox.spec
@@ -1,28 +1,25 @@
%define homepage http://start.fedoraproject.org/
%define default_bookmarks_file %{_datadir}/bookmarks/default-bookmarks.html
%define desktop_file_utils_version 0.9
-%define nspr_version 4.6
-%define nss_version 3.11.1
-%define cairo_version 0.5
%define builddir %{_builddir}/mozilla
-%define build_devel_package 1
+%define mozappdir %{_libdir}/%{name}-3.0b3pre
-%define official_branding 1
+%define official_branding 0
Summary: Mozilla Firefox Web browser
Name: firefox
-Version: 2.0.0.10
-Release: 5%{?dist}
+Version: 3.0
+Release: 0.beta2.1%{?dist}
URL: http://www.mozilla.org/projects/firefox/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Group: Applications/Internet
%if %{official_branding}
%define tarball firefox-%{version}-source.tar.bz2
%else
-%define tarball firefox-2.0rc3-source.tar.bz2
+%define tarball firefox-20071215.tar.bz2
%endif
Source0: %{tarball}
-Source2: firefox-langpacks-%{version}-20071123.tar.bz2
+Source2: firefox-langpacks-2.0.0.10-20071123.tar.bz2
Source10: firefox-mozconfig
Source11: firefox-mozconfig-branded
Source12: firefox-redhat-default-prefs.js
@@ -36,35 +33,9 @@ Source101: add-gecko-provides.in
# build patches
Patch1: firefox-2.0-link-layout.patch
-
-# customization patches
-Patch21: firefox-0.7.3-psfonts.patch
-Patch22: firefox-1.1-default-applications.patch
-
-# local bugfixes
-Patch40: firefox-1.5-bullet-bill.patch
-Patch41: firefox-2.0.0.4-undo-uriloader.patch
-Patch42: firefox-1.1-uriloader.patch
Patch43: firefox-2.0-getstartpage.patch
-
-# font system fixes
-Patch83: firefox-1.5-pango-cursor-position.patch
-Patch84: firefox-2.0-pango-printing.patch
-Patch85: firefox-2.0-pango-ligatures.patch
-Patch86: firefox-1.5-pango-cursor-position-more.patch
-Patch87: firefox-1.5-pango-justified-range.patch
-Patch88: firefox-1.5-pango-underline.patch
-Patch89: firefox-1.5-xft-rangewidth.patch
-
-
-# Other
-Patch102: firefox-1.5-theme-change.patch
Patch104: firefox-1.5-ppc64.patch
-Patch105: firefox-2.0-dnd.patch
-Patch110: firefox-2.0-startup-notify.patch
-Patch111: firefox-path.patch
-Patch112: firefox-2.0-enable-debug.patch
%if %{official_branding}
# Required by Mozilla Corporation
@@ -79,11 +50,6 @@ Patch112: firefox-2.0-enable-debug.patch
# ---------------------------------------------------
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: nspr-devel >= %{nspr_version}
-BuildRequires: nss-devel >= %{nss_version}
-BuildRequires: cairo-devel >= %{cairo_version}
-BuildRequires: libpng-devel, libjpeg-devel
-BuildRequires: zlib-devel, zip
BuildRequires: libIDL-devel
BuildRequires: desktop-file-utils
BuildRequires: gtk2-devel
@@ -97,70 +63,30 @@ BuildRequires: libXt-devel
BuildRequires: libXrender-devel
BuildRequires: system-bookmarks
BuildRequires: startup-notification-devel
+BuildRequires: xulrunner-devel >= 1.9-0.beta2
-Requires: nspr >= %{nspr_version}
-Requires: nss >= %{nss_version}
Requires: desktop-file-utils >= %{desktop_file_utils_version}
-Requires: system-bookmarks
+Requires: xulrunner, system-bookmarks
Obsoletes: mozilla <= 37:1.7.13
Provides: webclient
-%define mozappdir %{_libdir}/firefox-%{version}
-%define _use_internal_dependency_generator 0
-%if %{build_devel_package}
-%define __find_provides %{_builddir}/add-gecko-provides
-%else
+%define _use_internal_dependency_generator 0
%define __find_requires %{SOURCE100}
-%endif
%description
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
-%if %{build_devel_package}
-%package devel
-Summary: Development files for Firefox
-Group: Development/Libraries
-Obsoletes: mozilla-devel
-Requires: firefox = %{version}-%{release}
-Requires: nspr-devel >= %{nspr_version}
-Requires: nss-devel >= %{nss_version}
-
-%description devel
-Development files for Firefox. This package exists temporarily.
-When xulrunner has reached version 1.0, firefox-devel will be
-removed in favor of xulrunner-devel.
-%endif
-
#---------------------------------------------------------------------
%prep
%setup -q -n mozilla
%patch1 -p1 -b .link-layout
-%patch21 -p1 -b .psfonts
-%patch22 -p0 -b .default-applications
-
-%patch40 -p1 -b .bullet-bill
-%patch41 -p1 -b .undo-uriloader
-%patch42 -p0 -b .uriloader
-%patch43 -p1 -b .getstartpage
-
-%patch83 -p1 -b .pango-cursor-position
-%patch84 -p0 -b .pango-printing
-%patch85 -p1 -b .pango-ligatures
-%patch86 -p1 -b .pango-cursor-position-more
-%patch87 -p1 -b .pango-justified-range
-%patch88 -p1 -b .pango-underline
-%patch89 -p1 -b .nopangoxft2
+%patch43 -p1 -b .getstartpage
-%patch102 -p0 -b .theme-change
%patch104 -p1 -b .ppc64
-%patch105 -p0 -b .dnd
-#%patch110 -p0 -b .startup-notify
-%patch111 -p1 -b .path
-%patch112 -p1 -b .debug
# For branding specific patches.
@@ -182,7 +108,7 @@ removed in favor of xulrunner-devel.
%endif
# set up our default bookmarks
-%{__cp} %{default_bookmarks_file} $RPM_BUILD_DIR/mozilla/profile/defaults/bookmarks.html
+#%{__cp} %{default_bookmarks_file} $RPM_BUILD_DIR/mozilla/profile/defaults/bookmarks.html
#---------------------------------------------------------------------
@@ -202,7 +128,10 @@ export LIBDIR='%{_libdir}'
%define moz_make_flags %{?_smp_mflags}
%endif
-export LDFLAGS="-Wl,-rpath,%{mozappdir}"
+INTERNAL_GECKO="3.0b3pre"
+MOZ_APP_DIR=%{_libdir}/%{name}-${INTERNAL_GECKO}
+
+export LDFLAGS="-Wl,-rpath,$MOZ_APP_DIR"
export MAKE="gmake %{moz_make_flags}"
make -f client.mk build
@@ -211,7 +140,6 @@ make -f client.mk build
%install
%{__rm} -rf $RPM_BUILD_ROOT
-
DESTDIR=$RPM_BUILD_ROOT make install
%{__mkdir_p} $RPM_BUILD_ROOT{%{_libdir},%{_bindir},%{_datadir}/applications,%{_datadir}/icons/hicolor/48x48/apps},
@@ -225,6 +153,7 @@ desktop-file-install --vendor mozilla \
%{SOURCE20}
# set up the firefox start script
+%{__rm} -rf $RPM_BUILD_ROOT%{_bindir}/firefox
%{__cat} %{SOURCE21} | %{__sed} -e 's,FIREFOX_VERSION,%{version},g' > \
$RPM_BUILD_ROOT%{_bindir}/firefox
%{__chmod} 755 $RPM_BUILD_ROOT%{_bindir}/firefox
@@ -240,46 +169,43 @@ pref("startup.homepage_welcome_url", "%{homepage}");
EOF
# place the preferences
-%{__cp} rh-default-prefs $RPM_BUILD_ROOT/%{mozappdir}/greprefs/all-redhat.js
-%{__cp} rh-default-prefs $RPM_BUILD_ROOT/%{mozappdir}/defaults/pref/all-redhat.js
-%{__rm} rh-default-prefs
+#%{__cp} rh-default-prefs $RPM_BUILD_ROOT/%{mozappdir}/greprefs/all-redhat.js
+#%{__cp} rh-default-prefs $RPM_BUILD_ROOT/%{mozappdir}/defaults/pref/all-redhat.js
+#%{__rm} rh-default-prefs
# set up our default bookmarks
-%{__rm} -f $RPM_BUILD_ROOT%{mozappdir}/defaults/profile/bookmarks.html
-ln -s %{default_bookmarks_file} $RPM_BUILD_ROOT%{mozappdir}/defaults/profile/bookmarks.html
+%{__rm} -f $RPM_BUILD_ROOT/%{mozappdir}/defaults/profile/bookmarks.html
+ln -s %{default_bookmarks_file} $RPM_BUILD_ROOT/%{mozappdir}/defaults/profile/bookmarks.html
%{__cat} %{SOURCE50} | %{__sed} -e 's,FFDIR,%{mozappdir},g' -e 's,LIBDIR,%{_libdir},g' > \
- $RPM_BUILD_ROOT%{mozappdir}/firefox-xremote-client
+ $RPM_BUILD_ROOT/%{mozappdir}/firefox-xremote-client
-%{__chmod} 755 $RPM_BUILD_ROOT%{mozappdir}/firefox-xremote-client
+%{__chmod} 755 $RPM_BUILD_ROOT/%{mozappdir}/firefox-xremote-client
%{__install} -p -D -m 644 %{SOURCE23} $RPM_BUILD_ROOT%{_mandir}/man1/firefox.1
-%{__rm} -f $RPM_BUILD_ROOT%{mozappdir}/firefox-config
+%{__rm} -f $RPM_BUILD_ROOT/%{mozappdir}/firefox-config
-cd $RPM_BUILD_ROOT%{mozappdir}/chrome
-find . -name "*" -type d -maxdepth 1 -exec %{__rm} -rf {} \;
-cd -
+#cd $RPM_BUILD_ROOT/%{mozappdir}/chrome
+#find . -name "*" -type d -maxdepth 1 -exec %{__rm} -rf {} \;
+#cd -
-%{__cat} > $RPM_BUILD_ROOT%{mozappdir}/defaults/pref/firefox-l10n.js << EOF
-pref("general.useragent.locale", "chrome://global/locale/intl.properties");
-EOF
-%{__chmod} 644 $RPM_BUILD_ROOT%{mozappdir}/defaults/pref/firefox-l10n.js
+#%{__cat} > $RPM_BUILD_ROOT/%{mozappdir}/defaults/pref/firefox-l10n.js << EOF
+#pref("general.useragent.locale", "chrome://global/locale/intl.properties");
+#EOF
+#%{__chmod} 644 $RPM_BUILD_ROOT/%{mozappdir}/defaults/pref/firefox-l10n.js
-%{__mkdir_p} $RPM_BUILD_ROOT%{mozappdir}/chrome/icons/default/
+%{__mkdir_p} $RPM_BUILD_ROOT/%{mozappdir}/chrome/icons/default/
%{__cp} other-licenses/branding/%{name}/default.xpm \
- $RPM_BUILD_ROOT%{mozappdir}/chrome/icons/default/
+ $RPM_BUILD_ROOT/%{mozappdir}/chrome/icons/default/
%{__cp} other-licenses/branding/%{name}/default.xpm \
- $RPM_BUILD_ROOT%{mozappdir}/icons/
-
-# own mozilla plugin dir (#135050)
-%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/mozilla/plugins
+ $RPM_BUILD_ROOT/%{mozappdir}/icons/
# Install langpacks
-%{__mkdir_p} $RPM_BUILD_ROOT%{mozappdir}/extensions
+%{__mkdir_p} $RPM_BUILD_ROOT/%{mozappdir}/extensions
%{__tar} xjf %{SOURCE2}
for langpack in `ls firefox-langpacks/*.xpi`; do
language=`basename $langpack .xpi`
- extensiondir=$RPM_BUILD_ROOT%{mozappdir}/extensions/langpack-$language@firefox.mozilla.org
+ extensiondir=$RPM_BUILD_ROOT/%{mozappdir}/extensions/langpack-$language@firefox.mozilla.org
%{__mkdir_p} $extensiondir
unzip $langpack -d $extensiondir
find $extensiondir -type f | xargs chmod 644
@@ -303,48 +229,17 @@ for langpack in `ls firefox-langpacks/*.xpi`; do
done
%{__rm} -rf firefox-langpacks
-# Prepare our devel package
-%if %{build_devel_package}
-%{__mkdir_p} $RPM_BUILD_ROOT/%{_includedir}/firefox-%{version}
-%{__mkdir_p} $RPM_BUILD_ROOT/%{_datadir}/idl/firefox-%{version}
-%{__mkdir_p} $RPM_BUILD_ROOT/%{_libdir}/pkgconfig
-%{__cp} -rL dist/include/* \
- $RPM_BUILD_ROOT/%{_includedir}/firefox-%{version}
-%{__cp} -rL dist/idl/* \
- $RPM_BUILD_ROOT/%{_datadir}/idl/firefox-%{version}
-install -c -m 755 dist/bin/xpcshell \
- dist/bin/xpidl \
- dist/bin/xpt_dump \
- dist/bin/xpt_link \
- $RPM_BUILD_ROOT/%{mozappdir}
-install -c -m 644 build/unix/*.pc \
- $RPM_BUILD_ROOT/%{_libdir}/pkgconfig
-%endif
-
-# GRE stuff
-#%ifarch x86_64 ia64 ppc64 s390x
-#%define gre_conf_file gre64.conf
-#%else
-#%define gre_conf_file gre.conf
-#%endif
-#
-#%{__mkdir_p} $RPM_BUILD_ROOT/etc/gre.d/
-#%{__cat} > $RPM_BUILD_ROOT/etc/gre.d/%{gre_conf_file} << EOF
-#[%{version}]
-#GRE_PATH=%{mozappdir}
-#EOF
-
GECKO_VERSION=$(./config/milestone.pl --topsrcdir='.')
%{__cat} %{SOURCE101} | %{__sed} -e "s/@GECKO_VERSION@/$GECKO_VERSION/g" > \
%{_builddir}/add-gecko-provides
chmod 700 %{_builddir}/add-gecko-provides
# Copy over the LICENSE
-install -c -m 644 LICENSE $RPM_BUILD_ROOT%{mozappdir}
+install -c -m 644 LICENSE $RPM_BUILD_ROOT/%{mozappdir}
# ghost files
-touch $RPM_BUILD_ROOT%{mozappdir}/components/compreg.dat
-touch $RPM_BUILD_ROOT%{mozappdir}/components/xpti.dat
+touch $RPM_BUILD_ROOT/%{mozappdir}/components/compreg.dat
+touch $RPM_BUILD_ROOT/%{mozappdir}/components/xpti.dat
#---------------------------------------------------------------------
@@ -379,20 +274,14 @@ fi
%files
%defattr(-,root,root,-)
%{_bindir}/firefox
-%exclude %{_bindir}/firefox-config
+#%exclude %{_bindir}/firefox-config
%{_mandir}/man1/*
%{_datadir}/applications/mozilla-%{name}.desktop
%{_datadir}/icons/hicolor/48x48/apps/firefox.png
-%{_libdir}/mozilla
-#%dir /etc/gre.d
-#/etc/gre.d/%{gre_conf_file}
-
%dir %{mozappdir}
%doc %{mozappdir}/LICENSE
%{mozappdir}/*.properties
%{mozappdir}/chrome
-%{mozappdir}/chrome.manifest
-%{mozappdir}/dictionaries
%dir %{mozappdir}/components
%ghost %{mozappdir}/components/compreg.dat
%ghost %{mozappdir}/components/xpti.dat
@@ -401,44 +290,26 @@ fi
%attr(644, root, root) %{mozappdir}/components/*.js
%{mozappdir}/defaults
%{mozappdir}/extensions
-%{mozappdir}/greprefs
%{mozappdir}/icons
-%{mozappdir}/init.d
-%{mozappdir}/plugins
-%{mozappdir}/res
%{mozappdir}/searchplugins
-%{mozappdir}/*.so
%{mozappdir}/firefox
-%{mozappdir}/firefox-bin
%{mozappdir}/firefox-xremote-client
-%{mozappdir}/mozilla-xremote-client
%{mozappdir}/run-mozilla.sh
-%{mozappdir}/regxpcom
+%{mozappdir}/application.ini
+%{mozappdir}/modules/distribution.js
+%{mozappdir}/removed-files
+%{mozappdir}/.autoreg
# XXX See if these are needed still
%{mozappdir}/updater*
-%if %{build_devel_package}
-%files devel
-%defattr(-,root,root)
-%{_datadir}/idl/firefox-%{version}
-%{_includedir}/firefox-%{version}
-%{mozappdir}/TestGtkEmbed
-%{mozappdir}/xpcshell
-%{mozappdir}/xpicleanup
-%{mozappdir}/xpidl
-%{mozappdir}/xpt_dump
-%{mozappdir}/xpt_link
-%{_libdir}/pkgconfig/firefox-xpcom.pc
-%{_libdir}/pkgconfig/firefox-plugin.pc
-%{_libdir}/pkgconfig/firefox-js.pc
-%{_libdir}/pkgconfig/firefox-gtkmozembed.pc
-%exclude %{_libdir}/pkgconfig/firefox-nspr.pc
-%exclude %{_libdir}/pkgconfig/firefox-nss.pc
-%endif
-
#---------------------------------------------------------------------
%changelog
+* Tue Dec 18 2007 Martin Stransky <stransky@redhat.com> 3.0-0.beta2.1
+- moved to XUL Runner and updated to 3.0b3pre
+- removed firefox-devel package, gecko-libs is provided
+ by xulrunner-devel now.
+
* Thu Dec 13 2007 Christopher Aillon <caillon@redhat.com> 2.0.0.10-5
- Fix the getStartPage method to not return blank.
Patch by pspencer@fields.utoronto.ca
diff --git a/sources b/sources
index b95dad4..f927876 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
-5c2f13d6a27f462ec6b862dafca22e7b firefox-2.0.0.10-source.tar.bz2
368295c3958e2f8f7e7d404b9876f43f firefox-langpacks-2.0.0.10-20071123.tar.bz2
+8ad6a163eeb962482130cbcfaf891e26 firefox-20071215.tar.bz2
bgstack15