mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Merge Places and mozilla-central
This commit is contained in:
commit
49621889c6
@ -91,29 +91,20 @@ include $(topsrcdir)/config/rules.mk
|
||||
else
|
||||
# Build a binary bootstrapping with XRE_main
|
||||
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
PROGRAM = $(MOZ_APP_NAME)$(BIN_SUFFIX)
|
||||
else
|
||||
PROGRAM = $(MOZ_APP_NAME)-bin$(BIN_SUFFIX)
|
||||
endif
|
||||
|
||||
CPPSRCS = nsBrowserApp.cpp
|
||||
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
|
||||
|
||||
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
|
||||
LIBS += $(DIST)/bin/XUL
|
||||
TK_LIBS := $(TK_LIBS)
|
||||
else
|
||||
EXTRA_DSO_LIBS += xul
|
||||
endif
|
||||
DEFINES += -DXPCOM_GLUE
|
||||
STL_FLAGS=
|
||||
|
||||
LIBS += \
|
||||
$(STATIC_COMPONENTS_LINKER_PATH) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_JPROF
|
||||
@ -194,18 +185,9 @@ endif
|
||||
|
||||
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
|
||||
$(MOZ_APP_NAME):: $(topsrcdir)/build/unix/mozilla.in $(GLOBAL_DEPS)
|
||||
cat $< | sed -e "s|%MOZAPPDIR%|$(installdir)|" \
|
||||
-e "s|%MOZ_APP_DISPLAYNAME%|$(MOZ_APP_DISPLAYNAME)|" > $@
|
||||
chmod +x $@
|
||||
libs::
|
||||
cp -p $(MOZ_APP_NAME)$(BIN_SUFFIX) $(DIST)/bin/$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)
|
||||
|
||||
libs:: $(MOZ_APP_NAME)
|
||||
$(INSTALL) $< $(DIST)/bin
|
||||
|
||||
install:: $(MOZ_APP_NAME)
|
||||
$(SYSINSTALL) $< $(DESTDIR)$(bindir)
|
||||
|
||||
GARBAGE += $(MOZ_APP_NAME)
|
||||
GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/, firefox.js)
|
||||
|
||||
endif
|
||||
@ -273,7 +255,7 @@ libs repackage:: $(PROGRAM) application.ini
|
||||
rsync -a $(DIST)/bin/ $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)
|
||||
$(RM) $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/mangle $(DIST)/$(APP_NAME).app/Contents/$(APPFILES)/shlibsign
|
||||
ifdef LIBXUL_SDK
|
||||
cp $(LIBXUL_DIST)/bin/$(XR_STUB_NAME) $(DIST)/$(APP_NAME).app/Contents/MacOS/firefox-bin
|
||||
cp $(LIBXUL_DIST)/bin/$(XR_STUB_NAME) $(DIST)/$(APP_NAME).app/Contents/MacOS/firefox
|
||||
else
|
||||
$(RM) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM)
|
||||
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
|
@ -143,7 +143,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>firefox-bin</string>
|
||||
<string>firefox</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>%APP_NAME% %APP_VERSION%</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
|
@ -36,6 +36,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsXPCOMGlue.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
@ -44,6 +45,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
@ -54,11 +56,14 @@
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
// we want to use the DLL blocklist if possible
|
||||
#define XRE_WANT_DLL_BLOCKLIST
|
||||
// we want a wmain entry point
|
||||
#include "nsWindowsWMain.cpp"
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#include "BinaryPath.h"
|
||||
|
||||
#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
|
||||
|
||||
static void Output(const char *fmt, ... )
|
||||
{
|
||||
@ -85,12 +90,12 @@ static PRBool IsArg(const char* arg, const char* s)
|
||||
{
|
||||
if (*++arg == '-')
|
||||
++arg;
|
||||
return !PL_strcasecmp(arg, s);
|
||||
return !strcasecmp(arg, s);
|
||||
}
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
if (*arg == '/')
|
||||
return !PL_strcasecmp(++arg, s);
|
||||
return !strcasecmp(++arg, s);
|
||||
#endif
|
||||
|
||||
return PR_FALSE;
|
||||
@ -106,22 +111,46 @@ public:
|
||||
~ScopedLogging() { NS_LogTerm(); }
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ScopedLogging log;
|
||||
XRE_GetFileFromPathType XRE_GetFileFromPath;
|
||||
XRE_CreateAppDataType XRE_CreateAppData;
|
||||
XRE_FreeAppDataType XRE_FreeAppData;
|
||||
#ifdef XRE_HAS_DLL_BLOCKLIST
|
||||
XRE_SetupDllBlocklistType XRE_SetupDllBlocklist;
|
||||
#endif
|
||||
XRE_mainType XRE_main;
|
||||
|
||||
static const nsDynamicFunctionLoad kXULFuncs[] = {
|
||||
{ "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
|
||||
{ "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
|
||||
{ "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
|
||||
#ifdef XRE_HAS_DLL_BLOCKLIST
|
||||
{ "XRE_SetupDllBlocklist", (NSFuncPtr*) &XRE_SetupDllBlocklist },
|
||||
#endif
|
||||
{ "XRE_main", (NSFuncPtr*) &XRE_main },
|
||||
{ nsnull, nsnull }
|
||||
};
|
||||
|
||||
static int do_main(const char *exePath, int argc, char* argv[])
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> appini;
|
||||
nsresult rv = XRE_GetBinaryPath(argv[0], getter_AddRefs(appini));
|
||||
#ifdef XP_WIN
|
||||
// exePath comes from mozilla::BinaryPath::Get, which returns a UTF-8
|
||||
// encoded path, so it is safe to convert it
|
||||
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), PR_FALSE,
|
||||
getter_AddRefs(appini));
|
||||
#else
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(exePath), PR_FALSE,
|
||||
getter_AddRefs(appini));
|
||||
#endif
|
||||
if (NS_FAILED(rv)) {
|
||||
Output("Couldn't calculate the application directory.");
|
||||
return 255;
|
||||
}
|
||||
|
||||
appini->SetNativeLeafName(NS_LITERAL_CSTRING("application.ini"));
|
||||
|
||||
// Allow firefox.exe to launch XULRunner apps via -app <application.ini>
|
||||
// Note that -app must be the *first* argument.
|
||||
char *appEnv = nsnull;
|
||||
const char *appDataFile = PR_GetEnv("XUL_APP_FILE");
|
||||
const char *appDataFile = getenv("XUL_APP_FILE");
|
||||
if (appDataFile && *appDataFile) {
|
||||
rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -141,8 +170,12 @@ int main(int argc, char* argv[])
|
||||
return 255;
|
||||
}
|
||||
|
||||
appEnv = PR_smprintf("XUL_APP_FILE=%s", argv[2]);
|
||||
PR_SetEnv(appEnv);
|
||||
char appEnv[MAXPATHLEN];
|
||||
snprintf(appEnv, MAXPATHLEN, "XUL_APP_FILE=%s", argv[2]);
|
||||
if (putenv(appEnv)) {
|
||||
Output("Couldn't set %s.\n", appEnv);
|
||||
return 255;
|
||||
}
|
||||
argv[2] = argv[0];
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
@ -157,7 +190,62 @@ int main(int argc, char* argv[])
|
||||
|
||||
int result = XRE_main(argc, argv, appData);
|
||||
XRE_FreeAppData(appData);
|
||||
if (appEnv)
|
||||
PR_smprintf_free(appEnv);
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char exePath[MAXPATHLEN];
|
||||
|
||||
nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath);
|
||||
if (NS_FAILED(rv)) {
|
||||
Output("Couldn't calculate the application directory.\n");
|
||||
return 255;
|
||||
}
|
||||
|
||||
char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
|
||||
if (!lastSlash || (lastSlash - exePath > MAXPATHLEN - sizeof(XPCOM_DLL) - 1))
|
||||
return 255;
|
||||
|
||||
strcpy(++lastSlash, XPCOM_DLL);
|
||||
|
||||
#ifdef XP_WIN
|
||||
// GetProcessIoCounters().ReadOperationCount seems to have little to
|
||||
// do with actual read operations. It reports 0 or 1 at this stage
|
||||
// in the program. Luckily 1 coincides with when prefetch is
|
||||
// enabled. If Windows prefetch didn't happen we can do our own
|
||||
// faster dll preloading.
|
||||
IO_COUNTERS ioCounters;
|
||||
if (GetProcessIoCounters(GetCurrentProcess(), &ioCounters)
|
||||
&& !ioCounters.ReadOperationCount)
|
||||
#endif
|
||||
{
|
||||
XPCOMGlueEnablePreload();
|
||||
}
|
||||
|
||||
|
||||
rv = XPCOMGlueStartup(exePath);
|
||||
if (NS_FAILED(rv)) {
|
||||
Output("Couldn't load XPCOM.\n");
|
||||
return 255;
|
||||
}
|
||||
|
||||
rv = XPCOMGlueLoadXULFunctions(kXULFuncs);
|
||||
if (NS_FAILED(rv)) {
|
||||
Output("Couldn't load XRE functions.\n");
|
||||
return 255;
|
||||
}
|
||||
|
||||
#ifdef XRE_HAS_DLL_BLOCKLIST
|
||||
XRE_SetupDllBlocklist();
|
||||
#endif
|
||||
|
||||
int result;
|
||||
{
|
||||
ScopedLogging log;
|
||||
result = do_main(exePath, argc, argv);
|
||||
}
|
||||
|
||||
XPCOMGlueShutdown();
|
||||
return result;
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
#version {
|
||||
margin-top: 10px;
|
||||
-moz-margin-start: 0;
|
||||
-moz-user-select: text;
|
||||
-moz-user-focus: normal;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
#distribution,
|
||||
|
@ -70,7 +70,7 @@ function init(aEvent)
|
||||
if (/a\d+$/.test(version)) {
|
||||
let buildID = Services.appinfo.appBuildID;
|
||||
let buildDate = buildID.slice(0,4) + "-" + buildID.slice(4,6) + "-" + buildID.slice(6,8);
|
||||
document.getElementById("version").value += " (" + buildDate + ")";
|
||||
document.getElementById("version").textContent += " (" + buildDate + ")";
|
||||
}
|
||||
|
||||
#ifdef MOZ_OFFICIAL_BRANDING
|
||||
|
@ -76,7 +76,7 @@
|
||||
<hbox id="clientBox">
|
||||
<vbox id="leftBox" flex="1"/>
|
||||
<vbox id="rightBox" flex="1">
|
||||
#expand <label id="version" value="__MOZ_APP_VERSION__"/>
|
||||
#expand <label id="version">__MOZ_APP_VERSION__</label>
|
||||
<label id="distribution" class="text-blurb"/>
|
||||
<label id="distributionId" class="text-blurb"/>
|
||||
|
||||
|
@ -74,11 +74,11 @@ let AllTabs = {
|
||||
*/
|
||||
register: function register(eventName, callback) {
|
||||
// Either add additional callbacks or create the first entry
|
||||
let listeners = eventListeners[eventName];
|
||||
let listeners = eventListeners[events[eventName]];
|
||||
if (listeners)
|
||||
listeners.push(callback);
|
||||
else
|
||||
eventListeners[eventName] = [callback];
|
||||
eventListeners[events[eventName]] = [callback];
|
||||
},
|
||||
|
||||
/**
|
||||
@ -93,7 +93,7 @@ let AllTabs = {
|
||||
*/
|
||||
unregister: function unregister(eventName, callback) {
|
||||
// Nothing to remove for this event
|
||||
let listeners = eventListeners[eventName];
|
||||
let listeners = eventListeners[events[eventName]];
|
||||
if (!listeners)
|
||||
return;
|
||||
|
||||
@ -114,31 +114,50 @@ __defineGetter__("browserWindows", function browserWindows() {
|
||||
return browserWindows;
|
||||
});
|
||||
|
||||
let events = ["attrModified", "close", "move", "open", "select", "pinned", "unpinned"];
|
||||
let events = {
|
||||
attrModified: "TabAttrModified",
|
||||
close: "TabClose",
|
||||
move: "TabMove",
|
||||
open: "TabOpen",
|
||||
select: "TabSelect",
|
||||
pinned: "TabPinned",
|
||||
unpinned: "TabUnpinned"
|
||||
};
|
||||
let eventListeners = {};
|
||||
|
||||
function registerBrowserWindow(browserWindow) {
|
||||
events.forEach(function(eventName) {
|
||||
let tabEvent = "Tab" + eventName[0].toUpperCase() + eventName.slice(1);
|
||||
browserWindow.addEventListener(tabEvent, function(event) {
|
||||
// Make sure we've gotten listeners before trying to call
|
||||
let listeners = eventListeners[eventName];
|
||||
if (!listeners)
|
||||
return;
|
||||
for each (let event in events)
|
||||
browserWindow.addEventListener(event, tabEventListener, true);
|
||||
|
||||
let tab = event.target;
|
||||
browserWindow.addEventListener("unload", unregisterBrowserWindow, false);
|
||||
}
|
||||
|
||||
// Make a copy of the listeners, so it can't change as we call back
|
||||
listeners.slice().forEach(function(callback) {
|
||||
try {
|
||||
callback(tab, event);
|
||||
}
|
||||
// Don't let failing callbacks stop us but report the failure
|
||||
catch(ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
function unregisterBrowserWindow(unloadEvent) {
|
||||
let browserWindow = unloadEvent.currentTarget;
|
||||
|
||||
for each (let event in events)
|
||||
browserWindow.removeEventListener(event, tabEventListener, true);
|
||||
|
||||
browserWindow.removeEventListener("unload", unregisterBrowserWindow, false);
|
||||
}
|
||||
|
||||
function tabEventListener(event) {
|
||||
// Make sure we've gotten listeners before trying to call
|
||||
let listeners = eventListeners[event.type];
|
||||
if (!listeners)
|
||||
return;
|
||||
|
||||
let tab = event.target;
|
||||
|
||||
// Make a copy of the listeners, so it can't change as we call back
|
||||
listeners.slice().forEach(function (callback) {
|
||||
try {
|
||||
callback(tab, event);
|
||||
}
|
||||
// Don't let failing callbacks stop us but report the failure
|
||||
catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2904,7 +2904,7 @@ SessionStoreService.prototype = {
|
||||
// instead of gotoIndex. See bug 597315.
|
||||
browser.webNavigation.sessionHistory.getEntryAtIndex(activeIndex, true);
|
||||
browser.webNavigation.sessionHistory.
|
||||
QueryInterface(Ci.nsISHistory_2_0_BRANCH).reloadCurrentEntry();
|
||||
QueryInterface(Ci.nsISHistory).reloadCurrentEntry();
|
||||
}
|
||||
catch (ex) {
|
||||
// ignore page load errors
|
||||
|
@ -78,6 +78,8 @@ components/xpcom.xpt
|
||||
components/xpti.dat
|
||||
components/xptitemp.dat
|
||||
components/nsMicrosummaryService.js
|
||||
D3DCompiler_42.dll
|
||||
d3dx9_42.dll
|
||||
defaults/pref/all.js
|
||||
defaults/pref/bug259708.js
|
||||
defaults/pref/bug307259.js
|
||||
@ -93,6 +95,13 @@ defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/
|
||||
defaults/profile/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}/install.rdf
|
||||
defaults/profile/search.rdf
|
||||
#ifndef SHIP_FEEDBACK
|
||||
# In the average case, this directory is only used by Test Pilot, and will get
|
||||
# removed by the updater. In some cases (eg, partner builds), distribution/
|
||||
# will have other files and/or directories in it. In these cases, the updater
|
||||
# will print a non-fatal error and continue on, because we're not appending
|
||||
# '*' to force a recursive removal.
|
||||
distribution/
|
||||
distribution/extensions/
|
||||
distribution/extensions/testpilot@labs.mozilla.com.xpi
|
||||
#endif
|
||||
extensions/talkback@mozilla.org/
|
||||
@ -265,7 +274,6 @@ res/ua.css
|
||||
res/unixcharset.properties
|
||||
res/viewsource.css
|
||||
res/wincharset.properties
|
||||
searchplugins/
|
||||
searchplugins/DRAE.gif
|
||||
searchplugins/DRAE.png
|
||||
searchplugins/DRAE.src
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIFastLoadService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIFileChannel.h"
|
||||
|
@ -151,7 +151,6 @@ MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
|
||||
MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
|
||||
MOZ_MORK = @MOZ_MORK@
|
||||
MOZ_MORKREADER = @MOZ_MORKREADER@
|
||||
MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
|
||||
MOZ_OGG = @MOZ_OGG@
|
||||
MOZ_RAW = @MOZ_RAW@
|
||||
MOZ_SYDNEYAUDIO = @MOZ_SYDNEYAUDIO@
|
||||
|
16
configure.in
16
configure.in
@ -4768,7 +4768,6 @@ MOZ_MORK=
|
||||
MOZ_MORKREADER=1
|
||||
MOZ_AUTH_EXTENSION=1
|
||||
MOZ_NO_ACTIVEX_SUPPORT=1
|
||||
MOZ_NO_FAST_LOAD=
|
||||
MOZ_OGG=1
|
||||
MOZ_RAW=
|
||||
MOZ_SYDNEYAUDIO=
|
||||
@ -5723,21 +5722,6 @@ if test "$NS_PRINTING"; then
|
||||
AC_DEFINE(NS_PRINT_PREVIEW)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Disable Fast Load
|
||||
dnl ========================================================
|
||||
MOZ_ARG_DISABLE_BOOL(xpcom-fastload,
|
||||
[ --disable-xpcom-fastload
|
||||
Disable XPCOM fastload support],
|
||||
MOZ_NO_FAST_LOAD=1,
|
||||
MOZ_NO_FAST_LOAD=)
|
||||
|
||||
AC_SUBST(MOZ_NO_FAST_LOAD)
|
||||
|
||||
if test -n "$MOZ_NO_FAST_LOAD"; then
|
||||
AC_DEFINE(MOZ_NO_FAST_LOAD)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Enable Raw Codecs
|
||||
dnl ========================================================
|
||||
|
@ -113,7 +113,6 @@ XPIDLSRCS = \
|
||||
nsISelectionListener.idl \
|
||||
nsISelectionPrivate.idl \
|
||||
nsIScriptLoaderObserver.idl \
|
||||
nsISyncLoadDOMService.idl \
|
||||
nsIDroppedLinkHandler.idl \
|
||||
nsIScriptEventHandler.idl \
|
||||
nsIScriptEventManager.idl \
|
||||
|
@ -228,13 +228,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define NS_SYNCLOADDOMSERVICE_CID \
|
||||
{ /* 0e4e7d00-f71a-439f-9178-1a71ff11b55f */ \
|
||||
0x0e4e7d00, 0xf71a, 0x439f, \
|
||||
{0x91, 0x78, 0x1a, 0x71, 0xff, 0x11, 0xb5, 0x5f} }
|
||||
#define NS_SYNCLOADDOMSERVICE_CONTRACTID \
|
||||
"@mozilla.org/content/syncload-dom-service;1"
|
||||
|
||||
#define NS_EVENTLISTENERSERVICE_CID \
|
||||
{ /* baa34652-f1f1-4185-b224-244ee82a413a */ \
|
||||
0xbaa34652, 0xf1f1, 0x4185, \
|
||||
|
@ -48,6 +48,8 @@
|
||||
{ 0x09dec26b, 0x1ab7, 0x4ff0, \
|
||||
{ 0xa1, 0x67, 0x7f, 0x22, 0x9c, 0xaa, 0xc3, 0x04 } }
|
||||
|
||||
class nsIDOMFontFaceList;
|
||||
|
||||
class nsIRange : public nsIDOMRange {
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRANGE_IID)
|
||||
@ -123,6 +125,9 @@ public:
|
||||
NS_IMETHOD SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) = 0;
|
||||
NS_IMETHOD CloneRange(nsIDOMRange** aNewRange) = 0;
|
||||
|
||||
// To support the font inspector API
|
||||
NS_IMETHOD GetUsedFontFaces(nsIDOMFontFaceList** aResult) = 0;
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsINode> mRoot;
|
||||
nsCOMPtr<nsINode> mStartParent;
|
||||
|
@ -1,101 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <sicking@bigfoot.com> (Original author)
|
||||
*
|
||||
* 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 "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIPrincipal;
|
||||
interface nsIDOMDocument;
|
||||
interface nsIChannel;
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* **** NOTICE **** *
|
||||
* *
|
||||
* *
|
||||
* This interface is DEPRECATED! *
|
||||
* You should instead use XMLHttpRequest which now works both from *
|
||||
* Javascript and C++. *
|
||||
* *
|
||||
* Additionally, synchronous network loads are evil. Any delays *
|
||||
* from the server will appear as a hang in the mozilla UI. *
|
||||
* Therefore, they should be avoided as much as possible. *
|
||||
* *
|
||||
* Don't make me come over there!! *
|
||||
* *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* The nsISyncDOMLoadService interface can be used to synchronously load
|
||||
* a document.
|
||||
*
|
||||
* @deprecated use XMLHttpRequest instead
|
||||
*/
|
||||
|
||||
[deprecated, scriptable, uuid(8095998d-ae1c-4cfa-9b43-0973e5d77eb0)]
|
||||
interface nsISyncLoadDOMService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Synchronously load the document from the specified channel.
|
||||
*
|
||||
* @param aChannel The channel to load the document from.
|
||||
* @param aLoaderPrincipal Principal of loading document. For security
|
||||
* checks null if no securitychecks should be done
|
||||
*
|
||||
* @returns The document loaded from the URI.
|
||||
*/
|
||||
nsIDOMDocument loadDocument(in nsIChannel aChannel,
|
||||
in nsIPrincipal aLoaderPrincipal);
|
||||
|
||||
nsIDOMDocument loadDocumentAsXML(in nsIChannel aChannel,
|
||||
in nsIPrincipal aLoaderPrincipal);
|
||||
|
||||
/**
|
||||
* Synchronously load an XML document from the specified
|
||||
* channel. The channel must be possible to open synchronously.
|
||||
*
|
||||
* @param aChannel The channel to load the document from.
|
||||
* @param aLoaderPrincipal Principal of loading document. For security
|
||||
* checks null if no securitychecks should be done
|
||||
*
|
||||
* @returns The document loaded from the URI.
|
||||
*/
|
||||
nsIDOMDocument loadLocalDocument(in nsIChannel aChannel,
|
||||
in nsIPrincipal aLoaderPrincipal);
|
||||
};
|
@ -1904,9 +1904,10 @@ public:
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
if (tabChild && tabChild->GetInnerManager()) {
|
||||
tabChild->GetInnerManager()->
|
||||
ReceiveMessage(static_cast<nsPIDOMEventTarget*>(tabChild), mMessage,
|
||||
PR_FALSE, mJSON, nsnull, nsnull);
|
||||
nsFrameScriptCx cx(static_cast<nsPIDOMEventTarget*>(tabChild), tabChild);
|
||||
nsRefPtr<nsFrameMessageManager> mm = tabChild->GetInnerManager();
|
||||
mm->ReceiveMessage(static_cast<nsPIDOMEventTarget*>(tabChild), mMessage,
|
||||
PR_FALSE, mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -462,6 +462,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
||||
}
|
||||
}
|
||||
}
|
||||
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;
|
||||
return mParentManager ? mParentManager->ReceiveMessage(aTarget, aMessage,
|
||||
aSync, aJSON, aObjectsArray,
|
||||
aJSONRetVal, mContext) : NS_OK;
|
||||
@ -601,11 +602,18 @@ nsFrameScriptExecutor::DidCreateCx()
|
||||
void
|
||||
nsFrameScriptExecutor::DestroyCx()
|
||||
{
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->ReleaseJSContext(mCx, PR_TRUE);
|
||||
} else {
|
||||
JS_DestroyContext(mCx);
|
||||
if (mCxStackRefCnt) {
|
||||
mDelayedCxDestroy = PR_TRUE;
|
||||
return;
|
||||
}
|
||||
mDelayedCxDestroy = PR_FALSE;
|
||||
if (mCx) {
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->ReleaseJSContext(mCx, PR_TRUE);
|
||||
} else {
|
||||
JS_DestroyContext(mCx);
|
||||
}
|
||||
}
|
||||
mCx = nsnull;
|
||||
mGlobal = nsnull;
|
||||
|
@ -201,7 +201,9 @@ class nsFrameScriptExecutor
|
||||
public:
|
||||
static void Shutdown();
|
||||
protected:
|
||||
nsFrameScriptExecutor() : mCx(nsnull)
|
||||
friend class nsFrameScriptCx;
|
||||
nsFrameScriptExecutor() : mCx(nsnull), mCxStackRefCnt(0),
|
||||
mDelayedCxDestroy(PR_FALSE)
|
||||
{ MOZ_COUNT_CTOR(nsFrameScriptExecutor); }
|
||||
~nsFrameScriptExecutor()
|
||||
{ MOZ_COUNT_DTOR(nsFrameScriptExecutor); }
|
||||
@ -213,11 +215,32 @@ protected:
|
||||
nsCycleCollectionTraversalCallback &cb);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobal;
|
||||
JSContext* mCx;
|
||||
PRUint32 mCxStackRefCnt;
|
||||
PRPackedBool mDelayedCxDestroy;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
static nsDataHashtable<nsStringHashKey, nsFrameScriptExecutorJSObjectHolder*>* sCachedScripts;
|
||||
static nsRefPtr<nsScriptCacheCleaner> sScriptCacheCleaner;
|
||||
};
|
||||
|
||||
class nsFrameScriptCx
|
||||
{
|
||||
public:
|
||||
nsFrameScriptCx(nsISupports* aOwner, nsFrameScriptExecutor* aExec)
|
||||
: mOwner(aOwner), mExec(aExec)
|
||||
{
|
||||
++(mExec->mCxStackRefCnt);
|
||||
}
|
||||
~nsFrameScriptCx()
|
||||
{
|
||||
if (--(mExec->mCxStackRefCnt) == 0 &&
|
||||
mExec->mDelayedCxDestroy) {
|
||||
mExec->DestroyCx();
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsFrameScriptExecutor* mExec;
|
||||
};
|
||||
|
||||
class nsScriptCacheCleaner : public nsIObserver
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -68,8 +68,8 @@ bool SendSyncMessageToParent(void* aCallbackData,
|
||||
async->Run();
|
||||
}
|
||||
if (tabChild->mChromeMessageManager) {
|
||||
tabChild->mChromeMessageManager->ReceiveMessage(owner, aMessage, PR_TRUE,
|
||||
aJSON, nsnull, aJSONRetVal);
|
||||
nsRefPtr<nsFrameMessageManager> mm = tabChild->mChromeMessageManager;
|
||||
mm->ReceiveMessage(owner, aMessage, PR_TRUE, aJSON, nsnull, aJSONRetVal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -85,9 +85,9 @@ public:
|
||||
{
|
||||
mTabChild->mASyncMessages.RemoveElement(this);
|
||||
if (mTabChild->mChromeMessageManager) {
|
||||
mTabChild->mChromeMessageManager->ReceiveMessage(mTabChild->mOwner, mMessage,
|
||||
PR_FALSE,
|
||||
mJSON, nsnull, nsnull);
|
||||
nsRefPtr<nsFrameMessageManager> mm = mTabChild->mChromeMessageManager;
|
||||
mm->ReceiveMessage(mTabChild->mOwner, mMessage, PR_FALSE,
|
||||
mJSON, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsClientRect.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "nsTextFrame.h"
|
||||
#include "nsFontFaceList.h"
|
||||
|
||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aInstancePtrResult);
|
||||
@ -2236,3 +2237,62 @@ nsRange::GetClientRects(nsIDOMClientRectList** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRange::GetUsedFontFaces(nsIDOMFontFaceList** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
NS_ENSURE_TRUE(mStartParent, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startContainer = do_QueryInterface(mStartParent);
|
||||
nsCOMPtr<nsIDOMNode> endContainer = do_QueryInterface(mEndParent);
|
||||
|
||||
// Flush out layout so our frames are up to date.
|
||||
nsIDocument* doc = mStartParent->GetOwnerDoc();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
|
||||
doc->FlushPendingNotifications(Flush_Frames);
|
||||
|
||||
// Recheck whether we're still in the document
|
||||
NS_ENSURE_TRUE(mStartParent->IsInDoc(), NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsRefPtr<nsFontFaceList> fontFaceList = new nsFontFaceList();
|
||||
|
||||
RangeSubtreeIterator iter;
|
||||
nsresult rv = iter.Init(this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
while (!iter.IsDone()) {
|
||||
// only collect anything if the range is not collapsed
|
||||
nsCOMPtr<nsIDOMNode> node(iter.GetCurrentNode());
|
||||
iter.Next();
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
|
||||
if (!content) {
|
||||
continue;
|
||||
}
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (content->IsNodeOfType(nsINode::eTEXT)) {
|
||||
if (node == startContainer) {
|
||||
PRInt32 offset = startContainer == endContainer ?
|
||||
mEndOffset : content->GetText()->GetLength();
|
||||
nsLayoutUtils::GetFontFacesForText(frame, mStartOffset, offset,
|
||||
PR_TRUE, fontFaceList);
|
||||
continue;
|
||||
}
|
||||
if (node == endContainer) {
|
||||
nsLayoutUtils::GetFontFacesForText(frame, 0, mEndOffset,
|
||||
PR_TRUE, fontFaceList);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
nsLayoutUtils::GetFontFacesForFrames(frame, fontFaceList);
|
||||
}
|
||||
|
||||
fontFaceList.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -98,6 +98,8 @@ public:
|
||||
virtual nsresult SetEnd(nsINode* aParent, PRInt32 aOffset);
|
||||
virtual nsresult CloneRange(nsIRange** aNewRange) const;
|
||||
|
||||
NS_IMETHOD GetUsedFontFaces(nsIDOMFontFaceList** aResult);
|
||||
|
||||
// nsIMutationObserver methods
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
||||
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "nsSyncLoadService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
@ -64,13 +63,13 @@
|
||||
* This class manages loading a single XML document
|
||||
*/
|
||||
|
||||
class nsSyncLoader : public nsIDOMLoadListener,
|
||||
class nsSyncLoader : public nsIStreamListener,
|
||||
public nsIChannelEventSink,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
nsSyncLoader() : mLoading(PR_FALSE), mLoadSuccess(PR_FALSE) {}
|
||||
nsSyncLoader() : mLoading(PR_FALSE) {}
|
||||
virtual ~nsSyncLoader();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -79,14 +78,8 @@ public:
|
||||
PRBool aChannelIsSync, PRBool aForceToXML,
|
||||
nsIDOMDocument** aResult);
|
||||
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
// nsIDOMLoadListener
|
||||
NS_IMETHOD Load(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Unload(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Abort(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Error(nsIDOMEvent* aEvent);
|
||||
NS_FORWARD_NSISTREAMLISTENER(mListener->)
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
|
||||
NS_DECL_NSICHANNELEVENTSINK
|
||||
|
||||
@ -97,8 +90,9 @@ private:
|
||||
nsresult PushSyncStream(nsIStreamListener* aListener);
|
||||
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
PRPackedBool mLoading;
|
||||
PRPackedBool mLoadSuccess;
|
||||
nsresult mAsyncLoadStatus;
|
||||
};
|
||||
|
||||
class nsForceXMLListener : public nsIStreamListener
|
||||
@ -156,8 +150,8 @@ nsSyncLoader::~nsSyncLoader()
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS5(nsSyncLoader,
|
||||
nsIDOMLoadListener,
|
||||
nsIDOMEventListener,
|
||||
nsIStreamListener,
|
||||
nsIRequestObserver,
|
||||
nsIChannelEventSink,
|
||||
nsIInterfaceRequestor,
|
||||
nsISupportsWeakReference)
|
||||
@ -222,24 +216,9 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
|
||||
if (aLoaderPrincipal) {
|
||||
listener = new nsCORSListenerProxy(listener, aLoaderPrincipal,
|
||||
mChannel, PR_FALSE, &rv);
|
||||
NS_ENSURE_TRUE(listener, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Register as a load listener on the document
|
||||
nsCOMPtr<nsPIDOMEventTarget> target = do_QueryInterface(document);
|
||||
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
|
||||
|
||||
nsWeakPtr requestWeak = do_GetWeakReference(static_cast<nsIDOMLoadListener*>(this));
|
||||
nsLoadListenerProxy* proxy = new nsLoadListenerProxy(requestWeak);
|
||||
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// This will addref the proxy
|
||||
rv = target->AddEventListenerByIID(static_cast<nsIDOMEventListener*>(proxy),
|
||||
NS_GET_IID(nsIDOMLoadListener));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mLoadSuccess = PR_FALSE;
|
||||
if (aChannelIsSync) {
|
||||
rv = PushSyncStream(listener);
|
||||
}
|
||||
@ -248,23 +227,17 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
|
||||
}
|
||||
|
||||
http = do_QueryInterface(mChannel);
|
||||
if (mLoadSuccess && http) {
|
||||
if (NS_SUCCEEDED(rv) && http) {
|
||||
PRBool succeeded;
|
||||
mLoadSuccess = NS_SUCCEEDED(http->GetRequestSucceeded(&succeeded)) &&
|
||||
succeeded;
|
||||
if (NS_FAILED(http->GetRequestSucceeded(&succeeded)) || !succeeded) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
mChannel = nsnull;
|
||||
|
||||
// This will release the proxy. Don't use the errorvalue from this since
|
||||
// we're more interested in the errorvalue from the loading
|
||||
target->RemoveEventListenerByIID(static_cast<nsIDOMEventListener*>(proxy),
|
||||
NS_GET_IID(nsIDOMLoadListener));
|
||||
|
||||
// check that the load succeeded
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ENSURE_TRUE(mLoadSuccess, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_TRUE(document->GetRootElement(), NS_ERROR_FAILURE);
|
||||
|
||||
return CallQueryInterface(document, aResult);
|
||||
@ -273,8 +246,12 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
|
||||
nsresult
|
||||
nsSyncLoader::PushAsyncStream(nsIStreamListener* aListener)
|
||||
{
|
||||
mListener = aListener;
|
||||
|
||||
mAsyncLoadStatus = NS_OK;
|
||||
|
||||
// Start reading from the channel
|
||||
nsresult rv = mChannel->AsyncOpen(aListener, nsnull);
|
||||
nsresult rv = mChannel->AsyncOpen(this, nsnull);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// process events until we're finished.
|
||||
@ -288,10 +265,14 @@ nsSyncLoader::PushAsyncStream(nsIStreamListener* aListener)
|
||||
}
|
||||
}
|
||||
|
||||
mListener = nsnull;
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Note that if AsyncOpen failed that's ok -- the only caller of
|
||||
// this method nulls out mChannel immediately after we return.
|
||||
|
||||
return rv;
|
||||
|
||||
return mAsyncLoadStatus;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -303,61 +284,31 @@ nsSyncLoader::PushSyncStream(nsIStreamListener* aListener)
|
||||
|
||||
mLoading = PR_TRUE;
|
||||
rv = nsSyncLoadService::PushSyncStreamToListener(in, aListener, mChannel);
|
||||
|
||||
mLoading = PR_FALSE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// nsIDOMEventListener
|
||||
nsresult
|
||||
nsSyncLoader::HandleEvent(nsIDOMEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoader::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
return mListener->OnStartRequest(aRequest, aContext);
|
||||
}
|
||||
|
||||
// nsIDOMLoadListener
|
||||
nsresult
|
||||
nsSyncLoader::Load(nsIDOMEvent* aEvent)
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoader::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext,
|
||||
nsresult aStatusCode)
|
||||
{
|
||||
if (mLoading) {
|
||||
mLoading = PR_FALSE;
|
||||
mLoadSuccess = PR_TRUE;
|
||||
if (NS_SUCCEEDED(mAsyncLoadStatus) && NS_FAILED(aStatusCode)) {
|
||||
mAsyncLoadStatus = aStatusCode;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSyncLoader::BeforeUnload(nsIDOMEvent* aEvent)
|
||||
{
|
||||
// Like, whatever.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSyncLoader::Unload(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSyncLoader::Abort(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (mLoading) {
|
||||
mLoading = PR_FALSE;
|
||||
nsresult rv = mListener->OnStopRequest(aRequest, aContext, aStatusCode);
|
||||
if (NS_SUCCEEDED(mAsyncLoadStatus) && NS_FAILED(rv)) {
|
||||
mAsyncLoadStatus = rv;
|
||||
}
|
||||
mLoading = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSyncLoader::Error(nsIDOMEvent* aEvent)
|
||||
{
|
||||
if (mLoading) {
|
||||
mLoading = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -381,50 +332,6 @@ nsSyncLoader::GetInterface(const nsIID & aIID,
|
||||
return QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsSyncLoadService,
|
||||
nsISyncLoadDOMService)
|
||||
|
||||
static nsresult
|
||||
LoadFromChannel(nsIChannel* aChannel, nsIPrincipal *aLoaderPrincipal,
|
||||
PRBool aChannelIsSync, PRBool aForceToXML,
|
||||
nsIDOMDocument** aResult)
|
||||
{
|
||||
nsRefPtr<nsSyncLoader> loader = new nsSyncLoader();
|
||||
if (!loader) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return loader->LoadDocument(aChannel, aLoaderPrincipal, aChannelIsSync,
|
||||
aForceToXML, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoadService::LoadDocument(nsIChannel* aChannel,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
nsIDOMDocument** aResult)
|
||||
{
|
||||
return LoadFromChannel(aChannel, aLoaderPrincipal, PR_FALSE, PR_FALSE,
|
||||
aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoadService::LoadDocumentAsXML(nsIChannel* aChannel,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
nsIDOMDocument** aResult)
|
||||
{
|
||||
return LoadFromChannel(aChannel, aLoaderPrincipal, PR_FALSE, PR_TRUE,
|
||||
aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSyncLoadService::LoadLocalDocument(nsIChannel* aChannel,
|
||||
nsIPrincipal* aLoaderPrincipal,
|
||||
nsIDOMDocument** aResult)
|
||||
{
|
||||
return LoadFromChannel(aChannel, aLoaderPrincipal, PR_TRUE, PR_TRUE,
|
||||
aResult);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsSyncLoadService::LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal,
|
||||
@ -446,8 +353,10 @@ nsSyncLoadService::LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal,
|
||||
(NS_SUCCEEDED(aURI->SchemeIs("resource", &isResource)) &&
|
||||
isResource);
|
||||
|
||||
return LoadFromChannel(channel, aLoaderPrincipal, isSync, aForceToXML,
|
||||
aResult);
|
||||
nsRefPtr<nsSyncLoader> loader = new nsSyncLoader();
|
||||
return loader->LoadDocument(channel, aLoaderPrincipal, isSync,
|
||||
aForceToXML, aResult);
|
||||
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -44,18 +44,19 @@
|
||||
#ifndef nsSyncLoadService_h__
|
||||
#define nsSyncLoadService_h__
|
||||
|
||||
#include "nsISyncLoadDOMService.h"
|
||||
#include "nscore.h"
|
||||
|
||||
class nsIInputStream;
|
||||
class nsILoadGroup;
|
||||
class nsIStreamListener;
|
||||
class nsIURI;
|
||||
class nsIPrincipal;
|
||||
class nsIDOMDocument;
|
||||
class nsIChannel;
|
||||
|
||||
class nsSyncLoadService : public nsISyncLoadDOMService
|
||||
class nsSyncLoadService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISYNCLOADDOMSERVICE
|
||||
|
||||
/**
|
||||
* Synchronously load the document from the specified URI.
|
||||
*
|
||||
|
@ -1065,7 +1065,7 @@ nsWebSocket::SetProtocol(const nsString& aProtocol)
|
||||
PRUint32 length = aProtocol.Length();
|
||||
PRUint32 i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
if (aProtocol[i] < static_cast<PRUnichar>(0x0020) ||
|
||||
if (aProtocol[i] < static_cast<PRUnichar>(0x0021) ||
|
||||
aProtocol[i] > static_cast<PRUnichar>(0x007E)) {
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
@ -9,30 +9,30 @@ def web_socket_do_extra_handshake(request):
|
||||
# must set request.ws_protocol to the selected version from ws_requested_protocols
|
||||
request.ws_protocol = request.ws_requested_protocols[0]
|
||||
|
||||
if request.ws_protocol == "test 2.1":
|
||||
if request.ws_protocol == "test-2.1":
|
||||
time.sleep(5)
|
||||
pass
|
||||
elif request.ws_protocol == "test 9":
|
||||
elif request.ws_protocol == "test-9":
|
||||
time.sleep(5)
|
||||
pass
|
||||
elif request.ws_protocol == "test 10":
|
||||
elif request.ws_protocol == "test-10":
|
||||
time.sleep(5)
|
||||
pass
|
||||
elif request.ws_protocol == "test 19":
|
||||
raise ValueError('Aborting (test 19)')
|
||||
elif request.ws_protocol == "test 20" or request.ws_protocol == "test 17":
|
||||
elif request.ws_protocol == "test-19":
|
||||
raise ValueError('Aborting (test-19)')
|
||||
elif request.ws_protocol == "test-20" or request.ws_protocol == "test-17":
|
||||
time.sleep(10)
|
||||
pass
|
||||
elif request.ws_protocol == "test 22":
|
||||
elif request.ws_protocol == "test-22":
|
||||
time.sleep(60)
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
def web_socket_transfer_data(request):
|
||||
if request.ws_protocol == "test 2.1" or request.ws_protocol == "test 2.2":
|
||||
if request.ws_protocol == "test-2.1" or request.ws_protocol == "test-2.2":
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 6":
|
||||
elif request.ws_protocol == "test-6":
|
||||
resp = "wrong message"
|
||||
if msgutil.receive_message(request) == "1":
|
||||
resp = "2"
|
||||
@ -46,7 +46,7 @@ def web_socket_transfer_data(request):
|
||||
resp = "あいうえお"
|
||||
msgutil.send_message(request, resp.decode('utf-8'))
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 7":
|
||||
elif request.ws_protocol == "test-7":
|
||||
try:
|
||||
while not request.client_terminated:
|
||||
msgutil.receive_message(request)
|
||||
@ -59,29 +59,29 @@ def web_socket_transfer_data(request):
|
||||
msgutil.send_message(request, "server data")
|
||||
time.sleep(30)
|
||||
msgutil.close_connection(request, True)
|
||||
elif request.ws_protocol == "test 10":
|
||||
elif request.ws_protocol == "test-10":
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 11":
|
||||
elif request.ws_protocol == "test-11":
|
||||
resp = "wrong message"
|
||||
if msgutil.receive_message(request) == "client data":
|
||||
resp = "server data"
|
||||
msgutil.send_message(request, resp.decode('utf-8'))
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 12":
|
||||
elif request.ws_protocol == "test-12":
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 13":
|
||||
elif request.ws_protocol == "test-13":
|
||||
# first one binary message containing the byte 0x61 ('a')
|
||||
request.connection.write('\xff\x01\x61')
|
||||
# after a bad utf8 message
|
||||
request.connection.write('\x01\x61\xff')
|
||||
msgutil.close_connection(request)
|
||||
elif request.ws_protocol == "test 14":
|
||||
elif request.ws_protocol == "test-14":
|
||||
msgutil.close_connection(request)
|
||||
msgutil.send_message(request, "server data")
|
||||
elif request.ws_protocol == "test 15":
|
||||
elif request.ws_protocol == "test-15":
|
||||
msgutil.close_connection(request, True)
|
||||
return
|
||||
elif request.ws_protocol == "test 17" or request.ws_protocol == "test 21":
|
||||
elif request.ws_protocol == "test-17" or request.ws_protocol == "test-21":
|
||||
time.sleep(5)
|
||||
resp = "wrong message"
|
||||
if msgutil.receive_message(request) == "client data":
|
||||
@ -90,7 +90,7 @@ def web_socket_transfer_data(request):
|
||||
time.sleep(5)
|
||||
msgutil.close_connection(request)
|
||||
time.sleep(5)
|
||||
elif request.ws_protocol == "test 20":
|
||||
elif request.ws_protocol == "test-20":
|
||||
msgutil.send_message(request, "server data")
|
||||
msgutil.close_connection(request)
|
||||
while not request.client_terminated:
|
||||
|
@ -189,9 +189,9 @@ function test1()
|
||||
// is empty
|
||||
function test2()
|
||||
{
|
||||
var ws1 = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 2.1");
|
||||
var ws1 = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-2.1");
|
||||
current_test--; // CreateTestWS incremented this
|
||||
var ws2 = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 2.2");
|
||||
var ws2 = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-2.2");
|
||||
|
||||
var ws2CanConnect = false;
|
||||
|
||||
@ -204,7 +204,7 @@ function test2()
|
||||
|
||||
ws2.onopen = function()
|
||||
{
|
||||
ok(ws2CanConnect, "shouldn't connect yet in test 2!");
|
||||
ok(ws2CanConnect, "shouldn't connect yet in test-2!");
|
||||
doTest(3);
|
||||
}
|
||||
}
|
||||
@ -224,10 +224,10 @@ function test4()
|
||||
{
|
||||
try {
|
||||
var ws = CreateTestWS("file_websocket");
|
||||
ok(false, "test 4 failed");
|
||||
ok(false, "test-4 failed");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "test 4 failed");
|
||||
ok(true, "test-4 failed");
|
||||
}
|
||||
doTest(5);
|
||||
}
|
||||
@ -249,12 +249,20 @@ function test5()
|
||||
catch (e) {
|
||||
ok(true, "couldn't accept any not printable ASCII character in the protocol parameter");
|
||||
}
|
||||
current_test--; // CreateTestWS incremented this
|
||||
try {
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 5");
|
||||
ok(false, "U+0020 not acceptable in protocol parameter");
|
||||
}
|
||||
catch (e) {
|
||||
ok(true, "U+0020 not acceptable in protocol parameter");
|
||||
}
|
||||
doTest(6);
|
||||
}
|
||||
|
||||
function test6()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 6");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-6");
|
||||
var counter = 1;
|
||||
ws.onopen = function()
|
||||
{
|
||||
@ -263,7 +271,7 @@ function test6()
|
||||
ws.onmessage = function(e)
|
||||
{
|
||||
if (counter == 5) {
|
||||
ok(e.data == "あいうえお", "test 6 counter 5 data ok");
|
||||
ok(e.data == "あいうえお", "test-6 counter 5 data ok");
|
||||
ws.close();
|
||||
doTest(7);
|
||||
} else {
|
||||
@ -286,7 +294,7 @@ function test7()
|
||||
current_test++;
|
||||
doTest(8);
|
||||
|
||||
// var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 7");
|
||||
// var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-7");
|
||||
// ws.onopen = function()
|
||||
// {
|
||||
// ws.close();
|
||||
@ -300,7 +308,7 @@ function test7()
|
||||
|
||||
function test8()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 8");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-8");
|
||||
ws.onopen = function()
|
||||
{
|
||||
ws.close();
|
||||
@ -314,7 +322,7 @@ function test8()
|
||||
|
||||
function test9()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 9");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-9");
|
||||
ws.onopen = shouldNotOpen;
|
||||
ws.onclose = function(e)
|
||||
{
|
||||
@ -327,7 +335,7 @@ function test9()
|
||||
|
||||
function test10()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 10");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-10");
|
||||
ws.onclose = shouldCloseCleanly;
|
||||
|
||||
try {
|
||||
@ -345,25 +353,25 @@ function test10()
|
||||
|
||||
function test11()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 11");
|
||||
ok(ws.readyState == 0, "create bad readyState in test 11!");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-11");
|
||||
ok(ws.readyState == 0, "create bad readyState in test-11!");
|
||||
ws.onopen = function()
|
||||
{
|
||||
ok(ws.readyState == 1, "open bad readyState in test 11!");
|
||||
ok(ws.readyState == 1, "open bad readyState in test-11!");
|
||||
ws.send("client data");
|
||||
}
|
||||
ws.onmessage = function(e)
|
||||
{
|
||||
ok(e.data == "server data", "bad received message in test 11!");
|
||||
ok(e.data == "server data", "bad received message in test-11!");
|
||||
ws.close();
|
||||
|
||||
// this ok() is disabled due to a race condition - it state may have
|
||||
// advanced through 2 (closing) and into 3 (closed) before it is evald
|
||||
// ok(ws.readyState == 2, "onmessage bad readyState in test 11!");
|
||||
// ok(ws.readyState == 2, "onmessage bad readyState in test-11!");
|
||||
}
|
||||
ws.onclose = function(e)
|
||||
{
|
||||
ok(ws.readyState == 3, "onclose bad readyState in test 11!");
|
||||
ok(ws.readyState == 3, "onclose bad readyState in test-11!");
|
||||
shouldCloseCleanly(e);
|
||||
doTest(12);
|
||||
}
|
||||
@ -371,7 +379,7 @@ function test11()
|
||||
|
||||
function test12()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 12");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-12");
|
||||
ws.onopen = function()
|
||||
{
|
||||
try {
|
||||
@ -384,7 +392,7 @@ function test12()
|
||||
}
|
||||
ws.close();
|
||||
|
||||
// there isnt really a server implementation of test 12, so just
|
||||
// there isnt really a server implementation of test-12, so just
|
||||
// ignore an error
|
||||
ws.onerror = function()
|
||||
{
|
||||
@ -400,7 +408,7 @@ function test13()
|
||||
// protocol stack typically closes down after reporting a protocol level error - trying
|
||||
// to resync is too dangerous
|
||||
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 13");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-13");
|
||||
ws._timesCalledOnError = 0;
|
||||
ws.onerror = function()
|
||||
{
|
||||
@ -415,7 +423,7 @@ function test13()
|
||||
|
||||
function test14()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 14");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-14");
|
||||
ws.onmessage = function()
|
||||
{
|
||||
ok(false, "shouldn't received message after the server sent the close frame");
|
||||
@ -429,7 +437,7 @@ function test14()
|
||||
|
||||
function test15()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 15");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-15");
|
||||
ws.onclose = function(e)
|
||||
{
|
||||
shouldCloseNotCleanly(e);
|
||||
@ -445,7 +453,7 @@ function test15()
|
||||
|
||||
function test16()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 16");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-16");
|
||||
ws.onopen = function()
|
||||
{
|
||||
ws.close();
|
||||
@ -469,7 +477,7 @@ var status_test17 = "not started";
|
||||
|
||||
window._test17 = function()
|
||||
{
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 17");
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-17");
|
||||
local_ws._testNumber = "local17";
|
||||
local_ws._testNumber = current_test++;
|
||||
|
||||
@ -489,14 +497,14 @@ window._test17 = function()
|
||||
|
||||
local_ws.onmessage = function(e)
|
||||
{
|
||||
ok(e.data == "server data", "Bad message in test 17");
|
||||
ok(e.data == "server data", "Bad message in test-17");
|
||||
status_test17 = "got message";
|
||||
forcegc();
|
||||
};
|
||||
|
||||
local_ws.onclose = function(e)
|
||||
{
|
||||
ok(status_test17 == "got message", "Didn't got message in test 17!");
|
||||
ok(status_test17 == "got message", "Didn't got message in test-17!");
|
||||
shouldCloseCleanly(e);
|
||||
status_test17 = "closed";
|
||||
forcegc();
|
||||
@ -531,7 +539,7 @@ function test18()
|
||||
|
||||
function test19()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 19");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-19");
|
||||
ws.onopen = shouldNotOpen;
|
||||
ws.onclose = function(e)
|
||||
{
|
||||
@ -542,7 +550,7 @@ function test19()
|
||||
|
||||
window._test20 = function()
|
||||
{
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 20");
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-20");
|
||||
local_ws._testNumber = "local20";
|
||||
local_ws._testNumber = current_test++;
|
||||
|
||||
@ -571,7 +579,7 @@ var timeoutTest21;
|
||||
|
||||
window._test21 = function()
|
||||
{
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 21");
|
||||
var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-21");
|
||||
local_ws._testNumber = current_test++;
|
||||
|
||||
local_ws.onopen = function(e)
|
||||
@ -579,7 +587,7 @@ window._test21 = function()
|
||||
e.target.send("client data");
|
||||
timeoutTest21 = setTimeout(function()
|
||||
{
|
||||
ok(false, "Didn't received message on test 21!");
|
||||
ok(false, "Didn't received message on test-21!");
|
||||
}, 15000);
|
||||
forcegc();
|
||||
e.target.onopen = null;
|
||||
@ -594,7 +602,7 @@ window._test21 = function()
|
||||
local_ws.onmessage = function(e)
|
||||
{
|
||||
clearTimeout(timeoutTest21);
|
||||
ok(e.data == "server data", "Bad message in test 21");
|
||||
ok(e.data == "server data", "Bad message in test-21");
|
||||
forcegc();
|
||||
e.target.onmessage = null;
|
||||
forcegc();
|
||||
@ -618,7 +626,7 @@ function test21()
|
||||
|
||||
function test22()
|
||||
{
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test 22");
|
||||
var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-22");
|
||||
ws.onopen = shouldNotOpen;
|
||||
ws.onclose = function(e)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ _TEST_FILES_0 = \
|
||||
image_green-redirect^headers^ \
|
||||
test_drawImageIncomplete.html \
|
||||
test_canvas_font_setter.html \
|
||||
test_2d.clearRect.image.offscreen.html \
|
||||
test_2d.composite.canvas.destination-atop.html \
|
||||
test_2d.composite.canvas.destination-in.html \
|
||||
test_2d.composite.canvas.source-in.html \
|
||||
@ -86,6 +87,7 @@ _TEST_FILES_0 = \
|
||||
test_canvas_strokeStyle_getter.html \
|
||||
test_bug613794.html \
|
||||
test_drawImage_edge_cases.html \
|
||||
test_shadow_operators.html \
|
||||
$(NULL)
|
||||
|
||||
ifneq (1_Linux,$(MOZ_SUITE)_$(OS_ARCH))
|
||||
|
43
content/canvas/test/test_2d.clearRect.image.offscreen.html
Normal file
43
content/canvas/test/test_2d.clearRect.image.offscreen.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="doTest()">
|
||||
<p id="display">
|
||||
<canvas id="c" width="1" height="1"></canvas>
|
||||
<img id="img" src="image_green-1x1.png">
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
var c = document.getElementById("c");
|
||||
var ctx = c.getContext("2d");
|
||||
var img = document.getElementById("img");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function doTest() {
|
||||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
ctx.drawImage(img, -1, 0);
|
||||
ctx.clearRect(0, 0, 1, 1);
|
||||
|
||||
var data = ctx.getImageData(0, 0, 1, 1).data;
|
||||
is(data[0], 0, "Red channel should be 0");
|
||||
is(data[1], 0, "Green channel should be 0");
|
||||
is(data[2], 0, "Blue channel should be 0")
|
||||
is(data[3], 0, "Alpha channel should be 0");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
91
content/canvas/test/test_shadow_operators.html
Normal file
91
content/canvas/test/test_shadow_operators.html
Normal file
@ -0,0 +1,91 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display">
|
||||
<canvas id="c" width="2" height="2"></canvas>
|
||||
<canvas id="c2" width="2" height="2"></canvas>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function isPixel(ctx, x,y, r,g,b,a, d) {
|
||||
var pos = x + "," + y;
|
||||
var colour = r + "," + g + "," + b + "," + a;
|
||||
var pixel = ctx.getImageData(x, y, 1, 1);
|
||||
var pr = pixel.data[0],
|
||||
pg = pixel.data[1],
|
||||
pb = pixel.data[2],
|
||||
pa = pixel.data[3];
|
||||
ok(r-d <= pr && pr <= r+d &&
|
||||
g-d <= pg && pg <= g+d &&
|
||||
b-d <= pb && pb <= b+d &&
|
||||
a-d <= pa && pa <= a+d,
|
||||
"pixel "+pos+" of "+ctx.canvas.id+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
|
||||
}
|
||||
|
||||
function isSamePixel(ctx,ctx2, x,y, d) {
|
||||
var pos = x + "," + y;
|
||||
var pixel = ctx.getImageData(x, y, 1, 1);
|
||||
var pixel2 = ctx2.getImageData(x, y, 1, 1);
|
||||
var pr = pixel.data[0],
|
||||
pg = pixel.data[1],
|
||||
pb = pixel.data[2],
|
||||
pa = pixel.data[3];
|
||||
var r = pixel2.data[0],
|
||||
g = pixel2.data[1],
|
||||
b = pixel2.data[2],
|
||||
a = pixel2.data[3];
|
||||
var colour = r + "," + g + "," + b + "," + a;
|
||||
ok(r-d <= pr && pr <= r+d &&
|
||||
g-d <= pg && pg <= g+d &&
|
||||
b-d <= pb && pb <= b+d &&
|
||||
a-d <= pa && pa <= a+d,
|
||||
"pixel "+pos+" of "+ctx.canvas.id+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
|
||||
}
|
||||
|
||||
var c = document.getElementById("c");
|
||||
var ctx = c.getContext("2d");
|
||||
|
||||
ctx.shadowColor = "rgb(0,255,0)";
|
||||
|
||||
// Test that shadows with zero blur and offset are drawn
|
||||
ctx.fillStyle = "rgba(0,0,255,0.5)";
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
isPixel(ctx, 0,0, 0,85,170,192, 1);
|
||||
|
||||
// Test that non-OVER operators do not draw shadows
|
||||
var c2 = document.getElementById("c2");
|
||||
var ctx2 = c2.getContext("2d");
|
||||
var operators = ["source-atop", "source-in", "source-out", "destination-atop",
|
||||
"destination-in", "destination-out", "destination-over", "lighter", "copy",
|
||||
"xor"];
|
||||
|
||||
ctx.shadowOffsetX = ctx.shadowOffsetY = 1;
|
||||
for (var i = 0; i < operators.length; ++i) {
|
||||
ctx.fillStyle = "red";
|
||||
ctx.fillRect(0, 0, 2, 2);
|
||||
ctx.globalCompositeOperation = operators[i];
|
||||
ctx.fillStyle = "blue";
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
|
||||
ctx2.fillStyle = "red";
|
||||
ctx2.fillRect(0, 0, 2, 2);
|
||||
ctx2.globalCompositeOperation = operators[i];
|
||||
ctx2.fillStyle = "blue";
|
||||
ctx2.fillRect(0, 0, 1, 1);
|
||||
|
||||
isSamePixel(ctx,ctx2, 1,1, 0);
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -266,18 +266,7 @@ NS_IMPL_BOOL_ATTR(nsHTMLSharedElement, Compact, compact)
|
||||
NS_IMPL_URI_ATTR(nsHTMLSharedElement, Cite, cite)
|
||||
|
||||
// nsIDOMHTMLHeadElement
|
||||
// Deprecated and not exposed to script, but has to be implemented in order to
|
||||
// not break binary compat.
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSharedElement::GetProfile(nsAString& aValue)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSharedElement::SetProfile(const nsAString& aValue)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Empty
|
||||
|
||||
// nsIDOMHTMLHtmlElement
|
||||
NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Version, version)
|
||||
|
@ -1405,7 +1405,7 @@ nsIAtom* nsSVGElement::GetEventNameForAttr(nsIAtom* aAttr)
|
||||
}
|
||||
|
||||
nsSVGSVGElement *
|
||||
nsSVGElement::GetCtx()
|
||||
nsSVGElement::GetCtx() const
|
||||
{
|
||||
nsIContent* ancestor = GetFlattenedTreeParent();
|
||||
|
||||
@ -1425,7 +1425,7 @@ nsSVGElement::GetCtx()
|
||||
}
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
nsSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
|
||||
{
|
||||
return aMatrix;
|
||||
}
|
||||
|
@ -152,13 +152,13 @@ public:
|
||||
// Gets the element that establishes the rectangular viewport against which
|
||||
// we should resolve percentage lengths (our "coordinate context"). Returns
|
||||
// nsnull for outer <svg> or SVG without an <svg> parent (invalid SVG).
|
||||
nsSVGSVGElement* GetCtx();
|
||||
nsSVGSVGElement* GetCtx() const;
|
||||
|
||||
/**
|
||||
* Returns aMatrix post-multiplied by the transform from the userspace
|
||||
* established by this element to the userspace established by its parent.
|
||||
*/
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const;
|
||||
|
||||
// Setter for to set the current <animateMotion> transformation
|
||||
// Only visible for nsSVGGraphicElement, so it's a no-op here, and that
|
||||
|
@ -108,14 +108,15 @@ NS_IMETHODIMP nsSVGForeignObjectElement::GetHeight(nsIDOMSVGAnimatedLength * *aH
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
nsSVGForeignObjectElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
|
||||
{
|
||||
// 'transform' attribute:
|
||||
gfxMatrix matrix = nsSVGForeignObjectElementBase::PrependLocalTransformTo(aMatrix);
|
||||
|
||||
// now translate by our 'x' and 'y':
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
const_cast<nsSVGForeignObjectElement*>(this)->
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
return gfxMatrix().Translate(gfxPoint(x, y)) * matrix;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGForeignObjectElementBase::)
|
||||
|
||||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const;
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* name) const;
|
||||
|
@ -184,7 +184,7 @@ nsSVGGraphicElement::IsEventName(nsIAtom* aName)
|
||||
}
|
||||
|
||||
gfxMatrix
|
||||
nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
nsSVGGraphicElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
|
||||
{
|
||||
gfxMatrix result(aMatrix);
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
||||
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const;
|
||||
virtual void SetAnimateMotionTransform(const gfxMatrix* aMatrix);
|
||||
|
||||
protected:
|
||||
|
@ -952,22 +952,22 @@ nsSVGSVGElement::IsEventName(nsIAtom* aName)
|
||||
// resolve percentage lengths. (It can only be used to resolve
|
||||
// 'em'/'ex'-valued units).
|
||||
inline float
|
||||
ComputeSynthesizedViewBoxDimension(nsSVGLength2& aLength,
|
||||
ComputeSynthesizedViewBoxDimension(const nsSVGLength2& aLength,
|
||||
float aViewportLength,
|
||||
nsSVGSVGElement* aSelf)
|
||||
const nsSVGSVGElement* aSelf)
|
||||
{
|
||||
if (aLength.IsPercentage()) {
|
||||
return aViewportLength * aLength.GetAnimValInSpecifiedUnits() / 100.0f;
|
||||
}
|
||||
|
||||
return aLength.GetAnimValue(aSelf);
|
||||
return aLength.GetAnimValue(const_cast<nsSVGSVGElement*>(aSelf));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// public helpers:
|
||||
|
||||
gfxMatrix
|
||||
nsSVGSVGElement::GetViewBoxTransform()
|
||||
nsSVGSVGElement::GetViewBoxTransform() const
|
||||
{
|
||||
// Do we have an override preserveAspectRatio value?
|
||||
const SVGPreserveAspectRatio* overridePARPtr =
|
||||
@ -1178,11 +1178,11 @@ nsSVGSVGElement::GetLength(PRUint8 aCtxType)
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
nsSVGSVGElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
|
||||
{
|
||||
if (IsInner()) {
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
const_cast<nsSVGSVGElement*>(this)->GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
return GetViewBoxTransform() * gfxMatrix().Translate(gfxPoint(x, y)) * aMatrix;
|
||||
}
|
||||
|
||||
@ -1272,7 +1272,7 @@ nsSVGSVGElement::GetPreserveAspectRatio()
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsSVGSVGElement::ShouldSynthesizeViewBox()
|
||||
nsSVGSVGElement::ShouldSynthesizeViewBox() const
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!HasValidViewbox(),
|
||||
"Should only be called if we lack a viewBox");
|
||||
@ -1361,7 +1361,7 @@ nsSVGSVGElement::ClearImageOverridePreserveAspectRatio()
|
||||
}
|
||||
|
||||
const SVGPreserveAspectRatio*
|
||||
nsSVGSVGElement::GetImageOverridePreserveAspectRatio()
|
||||
nsSVGSVGElement::GetImageOverridePreserveAspectRatio() const
|
||||
{
|
||||
void* valPtr = GetProperty(nsGkAtoms::overridePreserveAspectRatio);
|
||||
#ifdef DEBUG
|
||||
|
@ -192,7 +192,7 @@ public:
|
||||
#endif // MOZ_SMIL
|
||||
|
||||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const;
|
||||
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
virtual void DidChangeEnum(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
virtual void DidChangeViewBox(PRBool aDoSetAttr);
|
||||
@ -205,7 +205,7 @@ public:
|
||||
float GetLength(PRUint8 mCtxType);
|
||||
|
||||
// public helpers:
|
||||
gfxMatrix GetViewBoxTransform();
|
||||
gfxMatrix GetViewBoxTransform() const;
|
||||
PRBool HasValidViewbox() const { return mViewBox.IsValid(); }
|
||||
|
||||
// This services any pending notifications for the transform on on this root
|
||||
@ -232,13 +232,13 @@ private:
|
||||
// particular) have access.
|
||||
void SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR);
|
||||
void ClearImageOverridePreserveAspectRatio();
|
||||
const SVGPreserveAspectRatio* GetImageOverridePreserveAspectRatio();
|
||||
const SVGPreserveAspectRatio* GetImageOverridePreserveAspectRatio() const;
|
||||
|
||||
// Returns PR_TRUE if we should synthesize a viewBox for ourselves (that is,
|
||||
// if we're the outermost <svg> in an image document, and we're not currently
|
||||
// being painted by an <svg:image> element). This method also assumes that we
|
||||
// lack a valid viewBox attribute.
|
||||
PRBool ShouldSynthesizeViewBox();
|
||||
PRBool ShouldSynthesizeViewBox() const;
|
||||
|
||||
protected:
|
||||
// nsSVGElement overrides
|
||||
@ -253,7 +253,7 @@ protected:
|
||||
|
||||
// implementation helpers:
|
||||
|
||||
PRBool IsRoot() {
|
||||
PRBool IsRoot() const {
|
||||
NS_ASSERTION((IsInDoc() && !GetParent()) ==
|
||||
(GetOwnerDoc() && (GetOwnerDoc()->GetRootElement() == this)),
|
||||
"Can't determine if we're root");
|
||||
@ -264,7 +264,7 @@ protected:
|
||||
* Returns true if this is an SVG <svg> element that is the child of
|
||||
* another non-foreignObject SVG element.
|
||||
*/
|
||||
PRBool IsInner() {
|
||||
PRBool IsInner() const {
|
||||
const nsIContent *parent = GetFlattenedTreeParent();
|
||||
return parent && parent->GetNameSpaceID() == kNameSpaceID_SVG &&
|
||||
parent->Tag() != nsGkAtoms::foreignObject;
|
||||
|
@ -37,6 +37,9 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsSVGTextContentElement.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/* readonly attribute nsIDOMSVGAnimatedLength textLength; */
|
||||
NS_IMETHODIMP nsSVGTextContentElement::GetTextLength(nsIDOMSVGAnimatedLength * *aTextLength)
|
||||
@ -143,8 +146,8 @@ NS_IMETHODIMP nsSVGTextContentElement::GetRotationOfChar(PRUint32 charnum, float
|
||||
/* long getCharNumAtPosition (in nsIDOMSVGPoint point); */
|
||||
NS_IMETHODIMP nsSVGTextContentElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_retval)
|
||||
{
|
||||
// null check when implementing - this method can be used by scripts!
|
||||
if (!point)
|
||||
nsCOMPtr<DOMSVGPoint> p = do_QueryInterface(point);
|
||||
if (!p)
|
||||
return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
|
||||
|
||||
*_retval = -1;
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "SVGNumberList.h"
|
||||
#include "SVGAnimatedNumberList.h"
|
||||
#include "DOMSVGAnimatedNumberList.h"
|
||||
#include "DOMSVGPoint.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -323,7 +324,8 @@ nsSVGTextElement::GetRotationOfChar(PRUint32 charnum, float *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsSVGTextElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_retval)
|
||||
{
|
||||
if (!point)
|
||||
nsCOMPtr<DOMSVGPoint> p = do_QueryInterface(point);
|
||||
if (!p)
|
||||
return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
|
||||
|
||||
*_retval = -1;
|
||||
|
@ -480,14 +480,14 @@ nsSVGUseElement::UnlinkSource()
|
||||
// nsSVGElement methods
|
||||
|
||||
/* virtual */ gfxMatrix
|
||||
nsSVGUseElement::PrependLocalTransformTo(const gfxMatrix &aMatrix)
|
||||
nsSVGUseElement::PrependLocalTransformTo(const gfxMatrix &aMatrix) const
|
||||
{
|
||||
// 'transform' attribute:
|
||||
gfxMatrix matrix = nsSVGUseElementBase::PrependLocalTransformTo(aMatrix);
|
||||
|
||||
// now translate by our 'x' and 'y':
|
||||
float x, y;
|
||||
GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
const_cast<nsSVGUseElement*>(this)->GetAnimatedLengthValues(&x, &y, nsnull);
|
||||
return matrix.PreMultiply(gfxMatrix().Translate(gfxPoint(x, y)));
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
void DestroyAnonymousContent();
|
||||
|
||||
// nsSVGElement specializations:
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix);
|
||||
virtual gfxMatrix PrependLocalTransformTo(const gfxMatrix &aMatrix) const;
|
||||
virtual void DidChangeLength(PRUint8 aAttrEnum, PRBool aDoSetAttr);
|
||||
virtual void DidChangeString(PRUint8 aAttrEnum);
|
||||
virtual void DidAnimateString(PRUint8 aAttrEnum);
|
||||
|
@ -50,8 +50,6 @@
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIFastLoadService.h"
|
||||
#include "nsIFastLoadFileControl.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIObjectInputStream.h"
|
||||
#include "nsIObjectOutputStream.h"
|
||||
|
@ -3913,6 +3913,8 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
|
||||
case NS_ERROR_DOCUMENT_NOT_CACHED:
|
||||
// Doc failed to load because we are offline and the cache does not
|
||||
// contain a copy of the document.
|
||||
case NS_ERROR_OFFLINE:
|
||||
// Doc failed to load because we are offline
|
||||
error.AssignLiteral("netOffline");
|
||||
break;
|
||||
case NS_ERROR_DOCUMENT_IS_PRINTMODE:
|
||||
@ -6278,6 +6280,7 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
|
||||
aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE ||
|
||||
aStatus == NS_ERROR_NET_INTERRUPT ||
|
||||
aStatus == NS_ERROR_NET_RESET ||
|
||||
aStatus == NS_ERROR_OFFLINE ||
|
||||
aStatus == NS_ERROR_MALWARE_URI ||
|
||||
aStatus == NS_ERROR_PHISHING_URI ||
|
||||
aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
|
||||
|
@ -60,7 +60,7 @@ interface nsISimpleEnumerator;
|
||||
#define NS_SHISTORY_CONTRACTID "@mozilla.org/browser/shistory;1"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(9883609F-CDD8-4d83-9B55-868FF08AD433)]
|
||||
[scriptable, uuid(ef2c9bcb-96b8-4095-933a-cb1c506f2c58)]
|
||||
interface nsISHistory: nsISupports
|
||||
{
|
||||
/**
|
||||
@ -177,10 +177,6 @@ interface nsISHistory: nsISupports
|
||||
* @see do_QueryInterface()
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator SHistoryEnumerator;
|
||||
};
|
||||
|
||||
[scriptable, uuid(ac8b3eb3-2051-4cce-8303-d6e7938501dd)]
|
||||
interface nsISHistory_2_0_BRANCH: nsISHistory
|
||||
{
|
||||
void reloadCurrentEntry();
|
||||
void reloadCurrentEntry();
|
||||
};
|
||||
|
@ -164,7 +164,6 @@ NS_INTERFACE_MAP_BEGIN(nsSHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISHistory_2_0_BRANCH)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -62,7 +62,7 @@ class nsIDocShell;
|
||||
class nsSHEnumerator;
|
||||
class nsSHistoryObserver;
|
||||
class nsSHistory: public PRCList,
|
||||
public nsISHistory_2_0_BRANCH,
|
||||
public nsISHistory,
|
||||
public nsISHistoryInternal,
|
||||
public nsIWebNavigation
|
||||
{
|
||||
@ -73,7 +73,6 @@ public:
|
||||
NS_DECL_NSISHISTORY
|
||||
NS_DECL_NSISHISTORYINTERNAL
|
||||
NS_DECL_NSIWEBNAVIGATION
|
||||
NS_DECL_NSISHISTORY_2_0_BRANCH
|
||||
|
||||
// One time initialization method called upon docshell module construction
|
||||
static nsresult Startup();
|
||||
|
@ -122,3 +122,7 @@ interface nsIDOMRange;
|
||||
interface nsIDOMCRMFObject;
|
||||
interface nsIDOMCrypto;
|
||||
interface nsIDOMPkcs11;
|
||||
|
||||
// Used font face (for inspector)
|
||||
interface nsIDOMFontFace;
|
||||
interface nsIDOMFontFaceList;
|
||||
|
@ -50,8 +50,7 @@
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(0d91b09d-0de9-4d9b-a53d-ce9b4c462f5a)]
|
||||
[scriptable, uuid(1be0672a-edfd-49b8-81e3-e68641029133)]
|
||||
interface nsIDOMHTMLHeadElement : nsIDOMHTMLElement
|
||||
{
|
||||
[noscript] attribute DOMString profile;
|
||||
};
|
||||
|
@ -77,6 +77,7 @@
|
||||
#if defined(ANDROID) || defined(LINUX)
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include "nsSystemInfo.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_PERMISSIONS
|
||||
@ -219,8 +220,17 @@ ContentParent::OnChannelConnected(int32 pid)
|
||||
nice = atoi(relativeNicenessStr);
|
||||
}
|
||||
|
||||
if (nice != 0) {
|
||||
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
||||
/* make the GUI thread have higher priority on single-cpu devices */
|
||||
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
|
||||
if (infoService) {
|
||||
PRInt32 cpus;
|
||||
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
|
||||
if (NS_FAILED(rv)) {
|
||||
cpus = 1;
|
||||
}
|
||||
if (nice != 0 && cpus == 1) {
|
||||
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -145,6 +145,7 @@ TabChild::Init()
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(TabChild)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome2)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
@ -754,9 +755,11 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
|
||||
const nsString& aJSON)
|
||||
{
|
||||
if (mTabChildGlobal) {
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get())->
|
||||
ReceiveMessage(static_cast<nsPIDOMEventTarget*>(mTabChildGlobal),
|
||||
aMessage, PR_FALSE, aJSON, nsnull, nsnull);
|
||||
nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
|
||||
nsRefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
mm->ReceiveMessage(static_cast<nsPIDOMEventTarget*>(mTabChildGlobal),
|
||||
aMessage, PR_FALSE, aJSON, nsnull, nsnull);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -587,7 +587,8 @@ TabParent::ReceiveMessage(const nsString& aMessage,
|
||||
{
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
||||
nsFrameMessageManager* manager = frameLoader->GetFrameMessageManager();
|
||||
nsRefPtr<nsFrameMessageManager> manager =
|
||||
frameLoader->GetFrameMessageManager();
|
||||
JSContext* ctx = manager->GetJSContext();
|
||||
JSAutoRequest ar(ctx);
|
||||
PRUint32 len = 0; //TODO: obtain a real value in bug 572685
|
||||
|
@ -146,6 +146,7 @@ PluginProcessChild::Init()
|
||||
protectCurrentDirectory = false;
|
||||
}
|
||||
if (protectCurrentDirectory) {
|
||||
SanitizeEnvironmentVariables();
|
||||
NS_SetDllDirectory(L"");
|
||||
}
|
||||
|
||||
|
@ -49,17 +49,15 @@
|
||||
#include "nsIEditor.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsITextServicesFilter.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsEditorSpellCheck)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsEditorSpellCheck)
|
||||
@ -187,19 +185,8 @@ nsEditorSpellCheck::InitSpellChecker(nsIEditor* aEditor, PRBool aEnableSelection
|
||||
|
||||
// Tell the spellchecker what dictionary to use:
|
||||
|
||||
nsString dictName;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && prefBranch) {
|
||||
nsCOMPtr<nsIPrefLocalizedString> prefString;
|
||||
rv = prefBranch->GetComplexValue("spellchecker.dictionary",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(prefString));
|
||||
if (NS_SUCCEEDED(rv) && prefString)
|
||||
prefString->ToString(getter_Copies(dictName));
|
||||
}
|
||||
nsAdoptingString dictName =
|
||||
Preferences::GetLocalizedString("spellchecker.dictionary");
|
||||
|
||||
if (dictName.IsEmpty())
|
||||
{
|
||||
@ -472,29 +459,17 @@ nsEditorSpellCheck::UninitSpellChecker()
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SaveDefaultDictionary()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
PRUnichar *dictName = nsnull;
|
||||
nsresult rv = GetCurrentDictionary(&dictName);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
{
|
||||
PRUnichar *dictName = nsnull;
|
||||
rv = GetCurrentDictionary(&dictName);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && dictName && *dictName) {
|
||||
nsCOMPtr<nsISupportsString> prefString =
|
||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && prefString) {
|
||||
prefString->SetData(nsDependentString(dictName));
|
||||
rv = prefBranch->SetComplexValue("spellchecker.dictionary",
|
||||
NS_GET_IID(nsISupportsString),
|
||||
prefString);
|
||||
}
|
||||
}
|
||||
if (dictName)
|
||||
nsMemory::Free(dictName);
|
||||
if (NS_SUCCEEDED(rv) && dictName && *dictName) {
|
||||
rv = Preferences::SetString("spellchecker.dictionary", dictName);
|
||||
}
|
||||
|
||||
if (dictName) {
|
||||
nsMemory::Free(dictName);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,6 @@
|
||||
#include "nsPIDOMEventTarget.h"
|
||||
#include "nsIMEStateManager.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
@ -116,6 +114,7 @@
|
||||
#include "nsTextEditUtils.h"
|
||||
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
|
||||
#define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
|
||||
@ -128,6 +127,7 @@ static PRBool gNoisy = PR_FALSE;
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
// Defined in nsEditorRegistration.cpp
|
||||
extern nsIParserService *sParserService;
|
||||
@ -378,13 +378,7 @@ nsEditor::GetDesiredSpellCheckState()
|
||||
}
|
||||
|
||||
// Check user preferences
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
PRInt32 spellcheckLevel = 1;
|
||||
if (NS_SUCCEEDED(rv) && prefBranch) {
|
||||
prefBranch->GetIntPref("layout.spellcheckDefault", &spellcheckLevel);
|
||||
}
|
||||
PRInt32 spellcheckLevel = Preferences::GetInt("layout.spellcheckDefault", 1);
|
||||
|
||||
if (spellcheckLevel == 0) {
|
||||
return PR_FALSE; // Spellchecking forced off globally
|
||||
|
@ -54,12 +54,11 @@
|
||||
#include "nsIDOMNSUIEvent.h"
|
||||
#include "nsIPrivateTextEvent.h"
|
||||
#include "nsIEditorMailSupport.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsIServiceManager.h"
|
||||
@ -77,6 +76,8 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
class nsAutoEditorKeypressOperation {
|
||||
public:
|
||||
nsAutoEditorKeypressOperation(nsEditor *aEditor, nsIDOMNSEvent *aEvent)
|
||||
@ -400,56 +401,49 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||
// middle-mouse click (paste);
|
||||
if (button == 1)
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && prefBranch)
|
||||
if (Preferences::GetBool("middlemouse.paste", PR_FALSE))
|
||||
{
|
||||
PRBool doMiddleMousePaste = PR_FALSE;;
|
||||
rv = prefBranch->GetBoolPref("middlemouse.paste", &doMiddleMousePaste);
|
||||
if (NS_SUCCEEDED(rv) && doMiddleMousePaste)
|
||||
{
|
||||
// Set the selection to the point under the mouse cursor:
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
if (NS_FAILED(nsuiEvent->GetRangeParent(getter_AddRefs(parent))))
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PRInt32 offset = 0;
|
||||
if (NS_FAILED(nsuiEvent->GetRangeOffset(&offset)))
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
// Set the selection to the point under the mouse cursor:
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
if (NS_FAILED(nsuiEvent->GetRangeParent(getter_AddRefs(parent))))
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
PRInt32 offset = 0;
|
||||
if (NS_FAILED(nsuiEvent->GetRangeOffset(&offset)))
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
if (NS_SUCCEEDED(mEditor->GetSelection(getter_AddRefs(selection))))
|
||||
(void)selection->Collapse(parent, offset);
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
if (NS_SUCCEEDED(mEditor->GetSelection(getter_AddRefs(selection))))
|
||||
(void)selection->Collapse(parent, offset);
|
||||
|
||||
// If the ctrl key is pressed, we'll do paste as quotation.
|
||||
// Would've used the alt key, but the kde wmgr treats alt-middle specially.
|
||||
PRBool ctrlKey = PR_FALSE;
|
||||
mouseEvent->GetCtrlKey(&ctrlKey);
|
||||
// If the ctrl key is pressed, we'll do paste as quotation.
|
||||
// Would've used the alt key, but the kde wmgr treats alt-middle specially.
|
||||
PRBool ctrlKey = PR_FALSE;
|
||||
mouseEvent->GetCtrlKey(&ctrlKey);
|
||||
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor;
|
||||
if (ctrlKey)
|
||||
mailEditor = do_QueryInterface(static_cast<nsIEditor*>(mEditor));
|
||||
nsCOMPtr<nsIEditorMailSupport> mailEditor;
|
||||
if (ctrlKey)
|
||||
mailEditor = do_QueryInterface(static_cast<nsIEditor*>(mEditor));
|
||||
|
||||
PRInt32 clipboard;
|
||||
PRInt32 clipboard;
|
||||
|
||||
#if defined(XP_OS2) || defined(XP_WIN32)
|
||||
clipboard = nsIClipboard::kGlobalClipboard;
|
||||
clipboard = nsIClipboard::kGlobalClipboard;
|
||||
#else
|
||||
clipboard = nsIClipboard::kSelectionClipboard;
|
||||
clipboard = nsIClipboard::kSelectionClipboard;
|
||||
#endif
|
||||
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation(clipboard);
|
||||
else
|
||||
mEditor->Paste(clipboard);
|
||||
if (mailEditor)
|
||||
mailEditor->PasteAsQuotation(clipboard);
|
||||
else
|
||||
mEditor->Paste(clipboard);
|
||||
|
||||
// Prevent the event from propagating up to be possibly handled
|
||||
// again by the containing window:
|
||||
mouseEvent->StopPropagation();
|
||||
mouseEvent->PreventDefault();
|
||||
// Prevent the event from propagating up to be possibly handled
|
||||
// again by the containing window:
|
||||
mouseEvent->StopPropagation();
|
||||
mouseEvent->PreventDefault();
|
||||
|
||||
// We processed the event, whether drop/paste succeeded or not
|
||||
return NS_OK;
|
||||
}
|
||||
// We processed the event, whether drop/paste succeeded or not
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -58,14 +58,14 @@
|
||||
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsIDOMRGBColor.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define BLACK_BG_RGB_TRIGGER 0xd0
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -503,14 +503,8 @@ nsHTMLEditor::AddPositioningOffset(PRInt32 & aX, PRInt32 & aY)
|
||||
{
|
||||
// Get the positioning offset
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
|
||||
PRInt32 positioningOffset = 0;
|
||||
if (NS_SUCCEEDED(res) && prefBranch) {
|
||||
res = prefBranch->GetIntPref("editor.positioning.offset", &positioningOffset);
|
||||
if (NS_FAILED(res)) // paranoia
|
||||
positioningOffset = 0;
|
||||
}
|
||||
PRInt32 positioningOffset =
|
||||
Preferences::GetInt("editor.positioning.offset", 0);
|
||||
|
||||
aX += positioningOffset;
|
||||
aY += positioningOffset;
|
||||
|
@ -40,9 +40,6 @@
|
||||
#include "nsHTMLEditor.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsHTMLEditUtils.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "ChangeCSSInlineStyleTxn.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -57,6 +54,9 @@
|
||||
#include "nsColor.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static
|
||||
void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString,
|
||||
@ -302,12 +302,7 @@ nsHTMLCSSUtils::nsHTMLCSSUtils(nsHTMLEditor* aEditor)
|
||||
, mIsCSSPrefChecked(PR_FALSE)
|
||||
{
|
||||
// let's retrieve the value of the "CSS editing" pref
|
||||
nsresult result = NS_OK;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||
if (NS_SUCCEEDED(result) && prefBranch) {
|
||||
prefBranch->GetBoolPref("editor.use_css", &mIsCSSPrefChecked);
|
||||
}
|
||||
mIsCSSPrefChecked = Preferences::GetBool("editor.use_css", mIsCSSPrefChecked);
|
||||
}
|
||||
|
||||
nsHTMLCSSUtils::~nsHTMLCSSUtils()
|
||||
@ -650,60 +645,42 @@ nsHTMLCSSUtils::IsCSSInvertable(nsIAtom *aProperty, const nsAString *aAttribute)
|
||||
}
|
||||
|
||||
// Get the default browser background color if we need it for GetCSSBackgroundColorState
|
||||
nsresult
|
||||
void
|
||||
nsHTMLCSSUtils::GetDefaultBackgroundColor(nsAString & aColor)
|
||||
{
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aColor.AssignLiteral("#ffffff");
|
||||
nsXPIDLCString returnColor;
|
||||
if (prefBranch) {
|
||||
PRBool useCustomColors;
|
||||
result = prefBranch->GetBoolPref("editor.use_custom_colors", &useCustomColors);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (useCustomColors) {
|
||||
result = prefBranch->GetCharPref("editor.background_color",
|
||||
getter_Copies(returnColor));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
else {
|
||||
PRBool useSystemColors;
|
||||
result = prefBranch->GetBoolPref("browser.display.use_system_colors", &useSystemColors);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (!useSystemColors) {
|
||||
result = prefBranch->GetCharPref("browser.display.background_color",
|
||||
getter_Copies(returnColor));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
if (Preferences::GetBool("editor.use_custom_colors", PR_FALSE)) {
|
||||
nsresult rv = Preferences::GetString("editor.background_color", &aColor);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to get editor.background_color");
|
||||
aColor.AssignLiteral("#ffffff"); // Default to white
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (returnColor) {
|
||||
CopyASCIItoUTF16(returnColor, aColor);
|
||||
|
||||
if (Preferences::GetBool("browser.display.use_system_colors", PR_FALSE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
Preferences::GetString("browser.display.background_color", &aColor);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to get browser.display.background_color");
|
||||
aColor.AssignLiteral("#ffffff"); // Default to white
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the default length unit used for CSS Indent/Outdent
|
||||
nsresult
|
||||
void
|
||||
nsHTMLCSSUtils::GetDefaultLengthUnit(nsAString & aLengthUnit)
|
||||
{
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
aLengthUnit.AssignLiteral("px");
|
||||
if (NS_SUCCEEDED(result) && prefBranch) {
|
||||
nsXPIDLCString returnLengthUnit;
|
||||
result = prefBranch->GetCharPref("editor.css.default_length_unit",
|
||||
getter_Copies(returnLengthUnit));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (returnLengthUnit) {
|
||||
CopyASCIItoUTF16(returnLengthUnit, aLengthUnit);
|
||||
}
|
||||
nsresult rv =
|
||||
Preferences::GetString("editor.css.default_length_unit", &aLengthUnit);
|
||||
// XXX Why don't you validate the pref value?
|
||||
if (NS_FAILED(rv)) {
|
||||
aLengthUnit.AssignLiteral("px");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Unfortunately, CSSStyleDeclaration::GetPropertyCSSValue is not yet implemented...
|
||||
|
@ -177,13 +177,13 @@ public:
|
||||
*
|
||||
* @param aColor [OUT] the default color as it is defined in prefs
|
||||
*/
|
||||
nsresult GetDefaultBackgroundColor(nsAString & aColor);
|
||||
void GetDefaultBackgroundColor(nsAString & aColor);
|
||||
|
||||
/** Get the default length unit used for CSS Indent/Outdent
|
||||
*
|
||||
* @param aLengthUnit [OUT] the default length unit as it is defined in prefs
|
||||
*/
|
||||
nsresult GetDefaultLengthUnit(nsAString & aLengthUnit);
|
||||
void GetDefaultLengthUnit(nsAString & aLengthUnit);
|
||||
|
||||
/** asnwers true if the element aElement carries an ID or a class
|
||||
*
|
||||
|
@ -121,8 +121,6 @@
|
||||
// Misc
|
||||
#include "TextEditorTest.h"
|
||||
#include "nsEditorUtils.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIContentFilter.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "plbase64.h"
|
||||
@ -131,6 +129,9 @@
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
const PRUnichar nbsp = 160;
|
||||
|
||||
@ -1125,31 +1126,24 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
|
||||
(*aTransferable)->AddDataFlavor(kHTMLMime);
|
||||
(*aTransferable)->AddDataFlavor(kFileMime);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
PRInt32 clipboardPasteOrder = 1; // order of image-encoding preference
|
||||
|
||||
if (prefs)
|
||||
switch (Preferences::GetInt("clipboard.paste_image_type", 1))
|
||||
{
|
||||
prefs->GetIntPref("clipboard.paste_image_type", &clipboardPasteOrder);
|
||||
switch (clipboardPasteOrder)
|
||||
{
|
||||
case 0: // prefer JPEG over PNG over GIF encoding
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
break;
|
||||
case 1: // prefer PNG over JPEG over GIF encoding (default)
|
||||
default:
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
break;
|
||||
case 2: // prefer GIF over JPEG over PNG encoding
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
break;
|
||||
}
|
||||
case 0: // prefer JPEG over PNG over GIF encoding
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
break;
|
||||
case 1: // prefer PNG over JPEG over GIF encoding (default)
|
||||
default:
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
break;
|
||||
case 2: // prefer GIF over JPEG over PNG encoding
|
||||
(*aTransferable)->AddDataFlavor(kGIFImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kJPEGImageMime);
|
||||
(*aTransferable)->AddDataFlavor(kPNGImageMime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
(*aTransferable)->AddDataFlavor(kUnicodeMime);
|
||||
|
@ -64,8 +64,6 @@
|
||||
#include "nsIRangeUtils.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIRange.h"
|
||||
|
||||
@ -82,6 +80,10 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
//const static char* kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE";
|
||||
//const static char* kMOZEditorBogusNodeValue="TRUE";
|
||||
|
||||
@ -241,26 +243,15 @@ nsHTMLEditRules::Init(nsPlaintextEditor *aEditor)
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// cache any prefs we care about
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
static const char kPrefName[] =
|
||||
"editor.html.typing.returnInEmptyListItemClosesList";
|
||||
nsAdoptingCString returnInEmptyLIKillsList =
|
||||
Preferences::GetCString(kPrefName);
|
||||
|
||||
char *returnInEmptyLIKillsList = 0;
|
||||
res = prefBranch->GetCharPref("editor.html.typing.returnInEmptyListItemClosesList",
|
||||
&returnInEmptyLIKillsList);
|
||||
// only when "false", becomes FALSE. Otherwise (including empty), TRUE.
|
||||
// XXX Why was this pref designed as a string and not bool?
|
||||
mReturnInEmptyLIKillsList = !returnInEmptyLIKillsList.EqualsLiteral("false");
|
||||
|
||||
if (NS_SUCCEEDED(res) && returnInEmptyLIKillsList)
|
||||
{
|
||||
if (!strncmp(returnInEmptyLIKillsList, "false", 5))
|
||||
mReturnInEmptyLIKillsList = PR_FALSE;
|
||||
else
|
||||
mReturnInEmptyLIKillsList = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mReturnInEmptyLIKillsList = PR_TRUE;
|
||||
}
|
||||
|
||||
// make a utility range for use by the listenter
|
||||
mUtilRange = do_CreateInstance("@mozilla.org/content/range;1");
|
||||
NS_ENSURE_TRUE(mUtilRange, NS_ERROR_NULL_POINTER);
|
||||
|
@ -60,13 +60,14 @@
|
||||
|
||||
#include "nsPoint.h"
|
||||
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
class nsHTMLEditUtils;
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
@ -554,19 +555,8 @@ nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
||||
mActivatedHandle->SetAttribute(NS_LITERAL_STRING("_moz_activated"), NS_LITERAL_STRING("true"));
|
||||
|
||||
// do we want to preserve ratio or not?
|
||||
PRBool preserveRatio = nsHTMLEditUtils::IsImage(mResizedObject);
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
|
||||
if (NS_SUCCEEDED(result) && prefBranch && preserveRatio) {
|
||||
result = prefBranch->GetBoolPref("editor.resizing.preserve_ratio", &preserveRatio);
|
||||
if (NS_FAILED(result)) {
|
||||
// just in case Anvil does not update its prefs file
|
||||
// and because it really does not make sense to me to allow free
|
||||
// resizing on corners without a modifier key
|
||||
preserveRatio = PR_TRUE;
|
||||
}
|
||||
}
|
||||
PRBool preserveRatio = nsHTMLEditUtils::IsImage(mResizedObject) &&
|
||||
Preferences::GetBool("editor.resizing.preserve_ratio", PR_TRUE);
|
||||
|
||||
// the way we change the position/size of the shadow depends on
|
||||
// the handle
|
||||
@ -609,6 +599,7 @@ nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
|
||||
mResizedObjectHeight);
|
||||
|
||||
// add a mouse move listener to the editor
|
||||
nsresult result = NS_OK;
|
||||
if (!mMouseMotionListenerP) {
|
||||
mMouseMotionListenerP = new ResizerMouseMotionListener(this);
|
||||
if (!mMouseMotionListenerP) {
|
||||
|
@ -71,8 +71,6 @@
|
||||
|
||||
// Misc
|
||||
#include "nsEditorUtils.h" // nsAutoEditBatch, nsAutoRules
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsContentCID.h"
|
||||
#include "nsInternetCiter.h"
|
||||
@ -1143,12 +1141,8 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
||||
// We may reset mWrapToWindow here, based on the pref's current value.
|
||||
if (IsMailEditor())
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
prefBranch->GetBoolPref("mail.compose.wrap_to_window_width",
|
||||
&mWrapToWindow);
|
||||
mWrapToWindow =
|
||||
Preferences::GetBool("mail.compose.wrap_to_window_width", mWrapToWindow);
|
||||
}
|
||||
|
||||
// and now we're ready to set the new whitespace/wrapping style.
|
||||
|
@ -58,8 +58,6 @@
|
||||
#include "nsEditorUtils.h"
|
||||
#include "EditTxn.h"
|
||||
#include "nsEditProperty.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -70,6 +68,10 @@
|
||||
// for IBMBIDI
|
||||
#include "nsFrameSelection.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
|
||||
@ -157,13 +159,8 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor)
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
||||
PRBool deleteBidiImmediately = PR_FALSE;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res))
|
||||
prefBranch->GetBoolPref("bidi.edit.delete_immediately",
|
||||
&deleteBidiImmediately);
|
||||
mDeleteBidiImmediately = deleteBidiImmediately;
|
||||
mDeleteBidiImmediately =
|
||||
Preferences::GetBool("bidi.edit.delete_immediately", PR_FALSE);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ abstract public class GeckoApp
|
||||
mLibLoadThread.join();
|
||||
} catch (InterruptedException ie) {}
|
||||
surfaceView.mSplashStatusMsg =
|
||||
getResources().getString(R.string.splash_screen_label);
|
||||
getResources().getString(R.string.splash_screen_loading);
|
||||
surfaceView.drawSplashScreen();
|
||||
// unpack files in the components directory
|
||||
try {
|
||||
@ -260,10 +260,10 @@ abstract public class GeckoApp
|
||||
new File(getApplication().getPackageResourcePath()).lastModified()
|
||||
>= libxulFile.lastModified()))
|
||||
surfaceView.mSplashStatusMsg =
|
||||
getResources().getString(R.string.splash_screen_installing);
|
||||
getResources().getString(R.string.splash_screen_installing_libs);
|
||||
else
|
||||
surfaceView.mSplashStatusMsg =
|
||||
getResources().getString(R.string.splash_screen_label);
|
||||
getResources().getString(R.string.splash_screen_loading);
|
||||
mLibLoadThread.start();
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class GeckoInputConnection
|
||||
|
||||
// 2. Make a guess about what the text actually is
|
||||
if (mComposing && extract.selectionEnd > extract.text.length())
|
||||
extract.text = extract.text.subSequence(0, mCompositionStart) + mComposingText;
|
||||
extract.text = extract.text.subSequence(0, Math.min(extract.text.length(), mCompositionStart)) + mComposingText;
|
||||
|
||||
// 3. If all else fails, make sure our selection indexes make sense
|
||||
extract.selectionStart = Math.min(extract.selectionStart, extract.text.length());
|
||||
|
@ -132,6 +132,40 @@ class GeckoSurfaceView
|
||||
* Called on main thread
|
||||
*/
|
||||
|
||||
public void draw(SurfaceHolder holder, ByteBuffer buffer) {
|
||||
if (buffer == null || buffer.capacity() != (mWidth * mHeight * 2))
|
||||
return;
|
||||
|
||||
synchronized (mSoftwareBuffer) {
|
||||
if (buffer != mSoftwareBuffer || mSoftwareBufferCopy == null)
|
||||
return;
|
||||
|
||||
Canvas c = holder.lockCanvas();
|
||||
if (c == null)
|
||||
return;
|
||||
mSoftwareBufferCopy.copyPixelsFromBuffer(buffer);
|
||||
c.drawBitmap(mSoftwareBufferCopy, 0, 0, null);
|
||||
holder.unlockCanvasAndPost(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(SurfaceHolder holder, Bitmap bitmap) {
|
||||
if (bitmap == null ||
|
||||
bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight)
|
||||
return;
|
||||
|
||||
synchronized (mSoftwareBitmap) {
|
||||
if (bitmap != mSoftwareBitmap)
|
||||
return;
|
||||
|
||||
Canvas c = holder.lockCanvas();
|
||||
if (c == null)
|
||||
return;
|
||||
c.drawBitmap(bitmap, 0, 0, null);
|
||||
holder.unlockCanvasAndPost(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
if (mShowingSplashScreen)
|
||||
drawSplashScreen(holder, width, height);
|
||||
@ -142,14 +176,15 @@ class GeckoSurfaceView
|
||||
Log.w("GeckoAppJava", "surfaceChanged while mInDrawing is true!");
|
||||
}
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
if (width == 0 || height == 0) {
|
||||
mSoftwareBitmap = null;
|
||||
mSoftwareBuffer = null;
|
||||
else if (mSoftwareBuffer == null ||
|
||||
mSoftwareBuffer.capacity() < (width * height * 2) ||
|
||||
mWidth != width || mHeight != height)
|
||||
mSoftwareBuffer = ByteBuffer.allocateDirect(width * height * 2);
|
||||
boolean doSyncDraw = mDrawMode == DRAW_2D &&
|
||||
mSoftwareBuffer != null &&
|
||||
mSoftwareBufferCopy = null;
|
||||
}
|
||||
|
||||
boolean doSyncDraw =
|
||||
mDrawMode == DRAW_2D &&
|
||||
(mSoftwareBitmap != null || mSoftwareBuffer != null) &&
|
||||
GeckoApp.checkLaunchState(GeckoApp.LaunchState.GeckoRunning);
|
||||
mSyncDraw = doSyncDraw;
|
||||
|
||||
@ -167,7 +202,7 @@ class GeckoSurfaceView
|
||||
metrics.widthPixels, metrics.heightPixels);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
|
||||
if (mSoftwareBuffer != null)
|
||||
if (mSoftwareBitmap != null || mSoftwareBuffer != null)
|
||||
GeckoAppShell.scheduleRedraw();
|
||||
|
||||
if (!doSyncDraw) {
|
||||
@ -182,18 +217,17 @@ class GeckoSurfaceView
|
||||
mSurfaceLock.unlock();
|
||||
}
|
||||
|
||||
ByteBuffer bb = null;
|
||||
Object syncDrawObject = null;
|
||||
try {
|
||||
bb = mSyncBuf.take();
|
||||
Object syncObject = mSyncDraws.take();
|
||||
} catch (InterruptedException ie) {
|
||||
Log.e("GeckoAppJava", "Threw exception while getting sync buf: ", ie);
|
||||
Log.e("GeckoAppJava", "Threw exception while getting sync draw bitmap/buffer: ", ie);
|
||||
}
|
||||
if (bb != null && bb.capacity() == (width * height * 2)) {
|
||||
mSoftwareBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.RGB_565);
|
||||
mSoftwareBitmap.copyPixelsFromBuffer(bb);
|
||||
Canvas c = holder.lockCanvas();
|
||||
c.drawBitmap(mSoftwareBitmap, 0, 0, null);
|
||||
holder.unlockCanvasAndPost(c);
|
||||
if (syncDrawObject != null) {
|
||||
if (syncDrawObject instanceof Bitmap)
|
||||
draw(holder, (Bitmap)syncDrawObject);
|
||||
else
|
||||
draw(holder, (ByteBuffer)syncDrawObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,11 +243,37 @@ class GeckoSurfaceView
|
||||
Log.i("GeckoAppJava", "surface destroyed");
|
||||
mSurfaceValid = false;
|
||||
mSoftwareBuffer = null;
|
||||
mSoftwareBufferCopy = null;
|
||||
mSoftwareBitmap = null;
|
||||
GeckoEvent e = new GeckoEvent(GeckoEvent.SURFACE_DESTROYED);
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
}
|
||||
|
||||
public Bitmap getSoftwareDrawBitmap() {
|
||||
if (mSoftwareBitmap == null ||
|
||||
mSoftwareBitmap.getHeight() != mHeight ||
|
||||
mSoftwareBitmap.getWidth() != mWidth) {
|
||||
mSoftwareBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.RGB_565);
|
||||
}
|
||||
|
||||
mDrawMode = DRAW_2D;
|
||||
return mSoftwareBitmap;
|
||||
}
|
||||
|
||||
public ByteBuffer getSoftwareDrawBuffer() {
|
||||
// We store pixels in 565 format, so two bytes per pixel (explaining
|
||||
// the * 2 in the following check/allocation)
|
||||
if (mSoftwareBuffer == null ||
|
||||
mSoftwareBuffer.capacity() != (mWidth * mHeight * 2)) {
|
||||
mSoftwareBuffer = ByteBuffer.allocateDirect(mWidth * mHeight * 2);
|
||||
}
|
||||
|
||||
if (mSoftwareBufferCopy == null ||
|
||||
mSoftwareBufferCopy.getHeight() != mHeight ||
|
||||
mSoftwareBufferCopy.getWidth() != mWidth) {
|
||||
mSoftwareBufferCopy = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.RGB_565);
|
||||
}
|
||||
|
||||
mDrawMode = DRAW_2D;
|
||||
return mSoftwareBuffer;
|
||||
}
|
||||
@ -290,19 +350,19 @@ class GeckoSurfaceView
|
||||
* unless you're in SurfaceChanged, in which case the canvas was already
|
||||
* locked. Surface lock -> Canvas lock will lead to AB-BA deadlocks.
|
||||
*/
|
||||
public void draw2D(ByteBuffer buffer, int stride) {
|
||||
// mSurfaceLock ensures that we get mSyncDraw/mSoftwareBuffer/etc.
|
||||
public void draw2D(Bitmap bitmap, int width, int height) {
|
||||
// mSurfaceLock ensures that we get mSyncDraw/mSoftwareBitmap/etc.
|
||||
// set correctly before determining whether we should do a sync draw
|
||||
mSurfaceLock.lock();
|
||||
try {
|
||||
if (mSyncDraw) {
|
||||
if (buffer != mSoftwareBuffer || stride != (mWidth * 2))
|
||||
if (bitmap != mSoftwareBitmap || width != mWidth || height != mHeight)
|
||||
return;
|
||||
mSyncDraw = false;
|
||||
try {
|
||||
mSyncBuf.put(buffer);
|
||||
mSyncDraws.put(bitmap);
|
||||
} catch (InterruptedException ie) {
|
||||
Log.e("GeckoAppJava", "Threw exception while getting sync buf: ", ie);
|
||||
Log.e("GeckoAppJava", "Threw exception while getting sync draws queue: ", ie);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -310,29 +370,28 @@ class GeckoSurfaceView
|
||||
mSurfaceLock.unlock();
|
||||
}
|
||||
|
||||
if (buffer != mSoftwareBuffer || stride != (mWidth * 2))
|
||||
return;
|
||||
Canvas c = getHolder().lockCanvas();
|
||||
if (c == null)
|
||||
return;
|
||||
if (buffer != mSoftwareBuffer || stride != (mWidth * 2)) {
|
||||
/* We're screwed. Fill it with white and hope it isn't too noticable
|
||||
* This could potentially happen if this function is called
|
||||
* right before mSurfaceLock is locked in SurfaceChanged.
|
||||
* However, I've never actually seen this code get hit.
|
||||
*/
|
||||
c.drawARGB(255, 255, 255, 255);
|
||||
getHolder().unlockCanvasAndPost(c);
|
||||
return;
|
||||
draw(getHolder(), bitmap);
|
||||
}
|
||||
|
||||
public void draw2D(ByteBuffer buffer, int stride) {
|
||||
mSurfaceLock.lock();
|
||||
try {
|
||||
if (mSyncDraw) {
|
||||
if (buffer != mSoftwareBuffer || stride != (mWidth * 2))
|
||||
return;
|
||||
mSyncDraw = false;
|
||||
try {
|
||||
mSyncDraws.put(buffer);
|
||||
} catch (InterruptedException ie) {
|
||||
Log.e("GeckoAppJava", "Threw exception while getting sync bitmaps queue: ", ie);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
mSurfaceLock.unlock();
|
||||
}
|
||||
if (mSoftwareBitmap == null ||
|
||||
mSoftwareBitmap.getHeight() != mHeight ||
|
||||
mSoftwareBitmap.getWidth() != mWidth) {
|
||||
mSoftwareBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.RGB_565);
|
||||
}
|
||||
mSoftwareBitmap.copyPixelsFromBuffer(mSoftwareBuffer);
|
||||
c.drawBitmap(mSoftwareBitmap, 0, 0, null);
|
||||
getHolder().unlockCanvasAndPost(c);
|
||||
|
||||
draw(getHolder(), buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -631,12 +690,13 @@ class GeckoSurfaceView
|
||||
boolean mIMELandscapeFS;
|
||||
|
||||
// Software rendering
|
||||
ByteBuffer mSoftwareBuffer;
|
||||
Bitmap mSoftwareBitmap;
|
||||
ByteBuffer mSoftwareBuffer;
|
||||
Bitmap mSoftwareBufferCopy;
|
||||
|
||||
Geocoder mGeocoder;
|
||||
Address mLastGeoAddress;
|
||||
|
||||
final SynchronousQueue<ByteBuffer> mSyncBuf = new SynchronousQueue<ByteBuffer>();
|
||||
final SynchronousQueue<Object> mSyncDraws = new SynchronousQueue<Object>();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
<!ENTITY splash_screen_label "loading">
|
||||
<!ENTITY splash_screen_installing "installing libraries\u2026">
|
||||
|
||||
<!ENTITY splash_screen_loading "Loading">
|
||||
<!ENTITY splash_screen_installing_libs "Installing libraries\u2026">
|
||||
<!ENTITY splash_firstrun "Setting up &brandShortName;\u2026">
|
||||
|
||||
<!ENTITY no_space_to_start_error "There is not enough space available for &brandShortName; to start.">
|
||||
<!ENTITY error_loading_file "An error occurred when trying to load files required to run &brandShortName;">
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
#includesubst @STRINGSPATH@
|
||||
]>
|
||||
<resources>
|
||||
<string name="splash_screen_label">&splash_screen_label;</string>
|
||||
<string name="splash_screen_installing">&splash_screen_installing;</string>
|
||||
<string name="splash_screen_loading">&splash_screen_loading;</string>
|
||||
<string name="splash_screen_installing_libs">&splash_screen_installing_libs;</string>
|
||||
<string name="splash_firstrun">&splash_firstrun;</string>
|
||||
<string name="no_space_to_start_error">&no_space_to_start_error;</string>
|
||||
<string name="error_loading_file">&error_loading_file;</string>
|
||||
|
@ -527,9 +527,6 @@ nsWindowWatcher::OpenWindowJSInternal(nsIDOMWindow *aParent,
|
||||
nameSpecified = PR_FALSE;
|
||||
if (aName) {
|
||||
CopyUTF8toUTF16(aName, name);
|
||||
#ifdef DEBUG
|
||||
CheckWindowName(name);
|
||||
#endif
|
||||
nameSpecified = PR_TRUE;
|
||||
}
|
||||
|
||||
@ -1406,31 +1403,6 @@ nsWindowWatcher::URIfromURL(const char *aURL,
|
||||
return NS_NewURI(aURI, aURL, baseURI);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Check for an illegal name e.g. frame3.1
|
||||
This just prints a warning message an continues; we open the window anyway,
|
||||
(see bug 32898). */
|
||||
void nsWindowWatcher::CheckWindowName(nsString& aName)
|
||||
{
|
||||
nsReadingIterator<PRUnichar> scan;
|
||||
nsReadingIterator<PRUnichar> endScan;
|
||||
|
||||
aName.EndReading(endScan);
|
||||
for (aName.BeginReading(scan); scan != endScan; ++scan)
|
||||
if (!nsCRT::IsAsciiAlpha(*scan) && !nsCRT::IsAsciiDigit(*scan) &&
|
||||
*scan != '_') {
|
||||
|
||||
// Don't use js_ReportError as this will cause the application
|
||||
// to shut down (JS_ASSERT calls abort()) See bug 32898
|
||||
nsCAutoString warn;
|
||||
warn.AssignLiteral("Illegal character in window name ");
|
||||
AppendUTF16toUTF8(aName, warn);
|
||||
NS_WARNING(warn.get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
#define NS_CALCULATE_CHROME_FLAG_FOR(feature, flag) \
|
||||
prefBranch->GetBoolPref(feature, &forceEnable); \
|
||||
if (forceEnable && !(aDialog && isChrome) && \
|
||||
|
@ -118,9 +118,6 @@ protected:
|
||||
static nsresult URIfromURL(const char *aURL,
|
||||
nsIDOMWindow *aParent,
|
||||
nsIURI **aURI);
|
||||
#ifdef DEBUG
|
||||
static void CheckWindowName(nsString& aName);
|
||||
#endif
|
||||
|
||||
static PRUint32 CalculateChromeFlags(const char *aFeatures,
|
||||
PRBool aFeaturesSpecified,
|
||||
|
@ -30,8 +30,6 @@ cairo-version-fixes.patch: fix up cairo-version.c/cairo-version.h for in-place b
|
||||
|
||||
win32-ddb-dib.patch: fix for bug 455513; not upstream yet pending feebdack
|
||||
|
||||
wince-fixes.patch: stubs out win32 functions we use but are not supported on win32. Also implements ExtSelectClipRgn in terms of other functions available on wince.
|
||||
|
||||
win32-vertically-offset-glyph.patch: bug 454098; vertical positioning errors when drawing glyph runs including delta-y offsets on screen via GDI
|
||||
|
||||
ignore-rank0.patch: bug 474886; Not redrawing the background when changing page on flickr
|
||||
|
@ -166,7 +166,6 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
DEFINES += -DDISABLE_SOME_FLOATING_POINT
|
||||
CSRCS += cairo-win32-surface.c
|
||||
|
||||
ifndef WINCE
|
||||
ifdef MOZ_ENABLE_DWRITE_FONT
|
||||
CPPSRCS += cairo-dwrite-font.cpp
|
||||
endif
|
||||
@ -174,9 +173,6 @@ ifdef MOZ_ENABLE_D2D_SURFACE
|
||||
CPPSRCS += cairo-d2d-surface.cpp
|
||||
endif
|
||||
CSRCS += cairo-win32-font.c
|
||||
else
|
||||
EXPORTS_cairo += cairo-ddraw.h
|
||||
endif
|
||||
|
||||
ifdef NS_PRINTING
|
||||
CSRCS += cairo-win32-printing-surface.c
|
||||
|
@ -1,41 +0,0 @@
|
||||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 NVIDIA Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-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/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is NVIDIA Corporation.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef _CAIRO_DDRAW_H_
|
||||
#define _CAIRO_DDRAW_H_
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#endif /* _CAIRO_DDRAW_H_ */
|
@ -216,24 +216,6 @@ _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
|
||||
cairo_bool_t
|
||||
_cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
#ifdef WINCE
|
||||
|
||||
// These are the required stubs for windows mobile
|
||||
#define ETO_GLYPH_INDEX 0
|
||||
#define ETO_PDY 0
|
||||
#define HALFTONE COLORONCOLOR
|
||||
#define GM_ADVANCED 2
|
||||
#define MWT_IDENTITY 1
|
||||
|
||||
inline int SetGraphicsMode(HDC hdc, int iMode) {return 1;}
|
||||
inline int GetGraphicsMode(HDC hdc) {return 1;} /*GM_COMPATIBLE*/
|
||||
inline void GdiFlush() {}
|
||||
inline BOOL SetWorldTransform(HDC hdc, CONST XFORM *lpXform) { return FALSE; }
|
||||
inline BOOL GetWorldTransform(HDC hdc, LPXFORM lpXform ) { return FALSE; }
|
||||
inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { return 1; }
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
|
||||
cairo_int_status_t
|
||||
|
@ -784,25 +784,9 @@ _cairo_win32_surface_set_clip_region (void *abstract_surface,
|
||||
if (!gdi_region)
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
#ifndef WINCE
|
||||
/* AND the new region into our DC */
|
||||
if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR)
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region");
|
||||
#else
|
||||
// The ExtSelectClipRgn function combines the specified
|
||||
// region with the current clipping region using the
|
||||
// specified mode. Here we do similar using basic
|
||||
// functions available on WINCE.
|
||||
{
|
||||
HRGN currentClip, newClip;
|
||||
GetClipRgn(surface->dc, ¤tClip);
|
||||
|
||||
if (CombineRgn(newClip, currentClip, gdi_region, RGN_AND) != ERROR) {
|
||||
SelectClipRgn(surface->dc, newClip);
|
||||
DeleteObject(newClip);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DeleteObject (gdi_region);
|
||||
}
|
||||
@ -1494,6 +1478,49 @@ categorize_solid_dest_operator (cairo_operator_t op,
|
||||
return DO_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_win32_surface_fill_rectangles_stretchdib (HDC dc,
|
||||
const cairo_color_t *color,
|
||||
cairo_rectangle_int_t *rect,
|
||||
int num_rects)
|
||||
{
|
||||
BITMAPINFO bi;
|
||||
int pixel = ((color->alpha_short >> 8) << 24) |
|
||||
((color->red_short >> 8) << 16) |
|
||||
((color->green_short >> 8) << 8) |
|
||||
(color->blue_short >> 8);
|
||||
int i;
|
||||
|
||||
/* Experiments suggest that it's impossible to use FillRect to set the alpha value
|
||||
of a Win32 HDC for a transparent window. So instead we use StretchDIBits of a single
|
||||
pixel, which does work. */
|
||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.bmiHeader.biWidth = 1;
|
||||
bi.bmiHeader.biHeight = 1;
|
||||
bi.bmiHeader.biSizeImage = 0;
|
||||
bi.bmiHeader.biXPelsPerMeter = PELS_72DPI;
|
||||
bi.bmiHeader.biYPelsPerMeter = PELS_72DPI;
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biClrUsed = 0;
|
||||
bi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
for (i = 0; i < num_rects; i++) {
|
||||
if (!StretchDIBits (dc,
|
||||
/* dst x,y,w,h */
|
||||
rect[i].x, rect[i].y, rect[i].width, rect[i].height,
|
||||
/* src x,y,w,h */
|
||||
0, 0, 1, 1,
|
||||
&pixel,
|
||||
&bi,
|
||||
DIB_RGB_COLORS,
|
||||
SRCCOPY))
|
||||
return _cairo_win32_print_gdi_error ("_cairo_win32_surface_fill_rectangles_stretchdib(StretchDIBits)");
|
||||
}
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
_cairo_win32_surface_fill_rectangles (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
@ -1507,16 +1534,19 @@ _cairo_win32_surface_fill_rectangles (void *abstract_surface,
|
||||
HBRUSH new_brush;
|
||||
int i;
|
||||
|
||||
/* XXXperf If it's not RGB24, we need to do a little more checking
|
||||
* to figure out when we can use GDI. We don't have that checking
|
||||
* anywhere at the moment, so just bail and use the fallback
|
||||
* paths. */
|
||||
if (surface->format != CAIRO_FORMAT_RGB24)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
status = _cairo_win32_surface_set_clip_region (surface, NULL);
|
||||
if (status)
|
||||
return status;
|
||||
return status;
|
||||
|
||||
if (surface->format == CAIRO_FORMAT_ARGB32 &&
|
||||
(surface->flags & CAIRO_WIN32_SURFACE_CAN_STRETCHDIB) &&
|
||||
(op == CAIRO_OPERATOR_SOURCE ||
|
||||
(op == CAIRO_OPERATOR_OVER && color->alpha_short >= 0xff00))) {
|
||||
return _cairo_win32_surface_fill_rectangles_stretchdib (surface->dc,
|
||||
color, rects, num_rects);
|
||||
}
|
||||
if (surface->format != CAIRO_FORMAT_RGB24)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
/* Optimize for no destination alpha (surface->pixman_image is non-NULL for all
|
||||
* surfaces with alpha.)
|
||||
@ -1591,7 +1621,7 @@ _cairo_win32_surface_show_glyphs (void *surface,
|
||||
cairo_clip_t *clip,
|
||||
int *remaining_glyphs)
|
||||
{
|
||||
#if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE)
|
||||
#ifdef CAIRO_HAS_WIN32_FONT
|
||||
if (scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE) {
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
return _cairo_dwrite_show_glyphs_on_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip);
|
||||
|
@ -1,64 +0,0 @@
|
||||
diff --git a/gfx/cairo/cairo/src/cairo-win32-private.h b/gfx/cairo/cairo/src/cairo-win32-private.h
|
||||
--- a/gfx/cairo/cairo/src/cairo-win32-private.h
|
||||
+++ b/gfx/cairo/cairo/src/cairo-win32-private.h
|
||||
@@ -194,4 +194,22 @@
|
||||
cairo_bool_t
|
||||
_cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
+#ifdef WINCE
|
||||
+
|
||||
+// These are the required stubs for windows mobile
|
||||
+#define ETO_GLYPH_INDEX 0
|
||||
+#define ETO_PDY 0
|
||||
+#define HALFTONE COLORONCOLOR
|
||||
+#define GM_ADVANCED 2
|
||||
+#define MWT_IDENTITY 1
|
||||
+
|
||||
+inline int SetGraphicsMode(HDC hdc, int iMode) {return 1;}
|
||||
+inline int GetGraphicsMode(HDC hdc) {return 1;} /*GM_COMPATIBLE*/
|
||||
+inline void GdiFlush() {}
|
||||
+inline BOOL SetWorldTransform(HDC hdc, CONST XFORM *lpXform) { return FALSE; }
|
||||
+inline BOOL GetWorldTransform(HDC hdc, LPXFORM lpXform ) { return FALSE; }
|
||||
+inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { return 1; }
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
#endif /* CAIRO_WIN32_PRIVATE_H */
|
||||
diff --git a/gfx/cairo/cairo/src/cairo-win32-surface.c b/gfx/cairo/cairo/src/cairo-win32-surface.c
|
||||
--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
|
||||
+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
|
||||
@@ -1591,8 +1591,25 @@
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
/* AND the new region into our DC */
|
||||
+
|
||||
+#ifndef WINCE
|
||||
if (ExtSelectClipRgn (surface->dc, gdi_region, RGN_AND) == ERROR)
|
||||
status = _cairo_win32_print_gdi_error ("_cairo_win32_surface_set_clip_region");
|
||||
+#else
|
||||
+ // The ExtSelectClipRgn function combines the specified
|
||||
+ // region with the current clipping region using the
|
||||
+ // specified mode. Here we do similar using basic
|
||||
+ // functions available on WINCE.
|
||||
+ {
|
||||
+ HRGN currentClip, newClip;
|
||||
+ GetClipRgn(surface->dc, ¤tClip);
|
||||
+
|
||||
+ if (CombineRgn(newClip, currentClip, gdi_region, RGN_AND) != ERROR) {
|
||||
+ SelectClipRgn(surface->dc, newClip);
|
||||
+ DeleteObject(newClip);
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
DeleteObject (gdi_region);
|
||||
}
|
||||
@@ -1629,7 +1646,7 @@
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
int *remaining_glyphs)
|
||||
{
|
||||
-#if CAIRO_HAS_WIN32_FONT
|
||||
+#if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE)
|
||||
cairo_win32_surface_t *dst = surface;
|
||||
|
||||
WORD glyph_buf_stack[STACK_GLYPH_SIZE];
|
@ -335,9 +335,14 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
|
||||
gfxMatrix matrix;
|
||||
DebugOnly<bool> is2D = container->GetEffectiveTransform().Is2D(&matrix);
|
||||
// See DefaultComputeEffectiveTransforms below
|
||||
NS_ASSERTION(is2D && !matrix.HasNonIntegerTranslation(),
|
||||
"Non-integer-translation transform with clipped child should have forced intermediate surface");
|
||||
scissor.MoveBy(nsIntPoint(PRInt32(matrix.x0), PRInt32(matrix.y0)));
|
||||
NS_ASSERTION(is2D && matrix.PreservesAxisAlignedRectangles(),
|
||||
"Non preserves axis aligned transform with clipped child should have forced intermediate surface");
|
||||
gfxRect r(scissor.x, scissor.y, scissor.width, scissor.height);
|
||||
gfxRect trScissor = matrix.TransformBounds(r);
|
||||
trScissor.Round();
|
||||
if (!gfxUtils::GfxRectToIntRect(trScissor, &scissor)) {
|
||||
return nsIntRect(currentClip.TopLeft(), nsIntSize(0, 0));
|
||||
}
|
||||
|
||||
// Find the nearest ancestor with an intermediate surface
|
||||
do {
|
||||
@ -408,7 +413,11 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const gfx3DMatrix& aTransformT
|
||||
useIntermediateSurface = PR_FALSE;
|
||||
gfxMatrix contTransform;
|
||||
if (!mEffectiveTransform.Is2D(&contTransform) ||
|
||||
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
|
||||
!contTransform.PreservesAxisAlignedRectangles()) {
|
||||
#else
|
||||
contTransform.HasNonIntegerTranslation()) {
|
||||
#endif
|
||||
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
|
||||
const nsIntRect *clipRect = child->GetEffectiveClipRect();
|
||||
/* We can't (easily) forward our transform to children with a non-empty clip
|
||||
|
@ -1,131 +1,323 @@
|
||||
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
||||
// Copyright (c) 2011 Mozilla Foundation. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "name.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "cff.h"
|
||||
#include "ots.h"
|
||||
|
||||
// name - Naming Table
|
||||
// http://www.microsoft.com/opentype/otspec/name.htm
|
||||
|
||||
namespace { // misc local helper functions
|
||||
|
||||
inline bool
|
||||
valid_in_ps_name(char c) {
|
||||
return (c > 0x20 && c < 0x7f && !std::strchr("[](){}<>/%", c));
|
||||
}
|
||||
|
||||
inline bool
|
||||
check_ps_name_ascii(std::string& name) {
|
||||
for (unsigned int i = 0; i < name.size(); ++i) {
|
||||
if (!valid_in_ps_name(name[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool
|
||||
check_ps_name_utf16_be(std::string& name) {
|
||||
for (unsigned int i = 0; i < name.size(); i += 2) {
|
||||
if (name[i] != 0) {
|
||||
return false;
|
||||
}
|
||||
if (!valid_in_ps_name(name[i+1])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
assign_to_utf16_be_from_ascii(std::string& target, const std::string& source) {
|
||||
target.resize(source.size() * 2);
|
||||
for (unsigned int i = 0, j = 0; i < source.size(); i++) {
|
||||
target[j++] = '\0';
|
||||
target[j++] = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
namespace ots {
|
||||
|
||||
bool ots_name_parse(OpenTypeFile *, const uint8_t *, size_t) {
|
||||
return true;
|
||||
}
|
||||
bool ots_name_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
|
||||
Buffer table(data, length);
|
||||
|
||||
bool ots_name_should_serialise(OpenTypeFile *) {
|
||||
return true;
|
||||
}
|
||||
OpenTypeNAME *name = new OpenTypeNAME;
|
||||
file->name = name;
|
||||
|
||||
bool ots_name_serialise(OTSStream *out, OpenTypeFile *file) {
|
||||
// NAME is a required table, but we don't want anything to do with it. Thus,
|
||||
// we don't bother parsing it and we just serialise an empty name table.
|
||||
uint16_t format;
|
||||
if (!table.ReadU16(&format) || format > 1) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
const char* kStrings[] = {
|
||||
"Derived font data", // 0: copyright
|
||||
"OTS derived font", // 1: the name the user sees
|
||||
"Unspecified", // 2: face weight
|
||||
"UniqueID", // 3: unique id
|
||||
"OTS derivied font", // 4: human readable name
|
||||
"1.000", // 5: version
|
||||
"False", // 6: postscript name
|
||||
NULL, // 7: trademark data
|
||||
"OTS", // 8: foundary
|
||||
"OTS", // 9: designer
|
||||
uint16_t count;
|
||||
if (!table.ReadU16(&count)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
uint16_t stringOffset;
|
||||
if (!table.ReadU16(&stringOffset) || stringOffset > length) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
const char* stringBase = (const char*)data + stringOffset;
|
||||
|
||||
NameRecord prevRec;
|
||||
bool sortRequired = false;
|
||||
|
||||
// Read all the names, discarding any with invalid IDs,
|
||||
// and any where the offset/length would be outside the table.
|
||||
// A stricter alternative would be to reject the font if there
|
||||
// are invalid name records, but it's not clear that is necessary.
|
||||
for (unsigned int i = 0; i < count; ++i) {
|
||||
NameRecord rec;
|
||||
uint16_t nameLength, nameOffset;
|
||||
if (!table.ReadU16(&rec.platformID) ||
|
||||
!table.ReadU16(&rec.encodingID) ||
|
||||
!table.ReadU16(&rec.languageID) ||
|
||||
!table.ReadU16(&rec.nameID) ||
|
||||
!table.ReadU16(&nameLength) ||
|
||||
!table.ReadU16(&nameOffset)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
// check platform & encoding, discard names with unknown values
|
||||
switch (rec.platformID) {
|
||||
case 0: // Unicode
|
||||
if (rec.encodingID > 6) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 1: // Macintosh
|
||||
if (rec.encodingID > 32) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 2: // ISO
|
||||
if (rec.encodingID > 2) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 3: // Windows: IDs 7 to 9 are "reserved"
|
||||
if (rec.encodingID > 6 && rec.encodingID != 10) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 4: // Custom (OTF Windows NT compatibility)
|
||||
if (rec.encodingID > 255) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default: // unknown platform
|
||||
continue;
|
||||
}
|
||||
|
||||
if (size_t(stringOffset) + nameOffset + nameLength > length) {
|
||||
continue;
|
||||
}
|
||||
rec.text.resize(nameLength);
|
||||
rec.text.assign(stringBase + nameOffset, nameLength);
|
||||
|
||||
if (rec.nameID == 6) {
|
||||
// PostScript name: check that it is valid, if not then discard it
|
||||
if (rec.platformID == 1) {
|
||||
if (file->cff && !file->cff->name.empty()) {
|
||||
rec.text = file->cff->name;
|
||||
} else if (!check_ps_name_ascii(rec.text)) {
|
||||
continue;
|
||||
}
|
||||
} else if (rec.platformID == 0 || rec.platformID == 3) {
|
||||
if (file->cff && !file->cff->name.empty()) {
|
||||
assign_to_utf16_be_from_ascii(rec.text, file->cff->name);
|
||||
} else if (!check_ps_name_utf16_be(rec.text)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
if (!(prevRec < rec)) {
|
||||
sortRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
name->names.push_back(rec);
|
||||
prevRec = rec;
|
||||
}
|
||||
|
||||
if (format == 1) {
|
||||
// extended name table format with language tags
|
||||
uint16_t langTagCount;
|
||||
if (!table.ReadU16(&langTagCount)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
for (unsigned int i = 0; i < langTagCount; ++i) {
|
||||
uint16_t tagLength, tagOffset;
|
||||
if (!table.ReadU16(&tagLength) || !table.ReadU16(&tagOffset)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
if (size_t(stringOffset) + tagOffset + tagLength > length) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
std::string tag(stringBase + tagOffset, tagLength);
|
||||
name->langTags.push_back(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (table.offset() > stringOffset) {
|
||||
// the string storage apparently overlapped the name/tag records;
|
||||
// consider this font to be badly broken
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
// check existence of required name strings (synthesize if necessary)
|
||||
// [0 - copyright - skip]
|
||||
// 1 - family
|
||||
// 2 - subfamily
|
||||
// [3 - unique ID - skip]
|
||||
// 4 - full name
|
||||
// 5 - version
|
||||
// 6 - postscript name
|
||||
const unsigned int kStdNameCount = 7;
|
||||
const char* kStdNames[kStdNameCount] = {
|
||||
NULL,
|
||||
"OTS derived font",
|
||||
"Unspecified",
|
||||
NULL,
|
||||
"OTS derived font",
|
||||
"1.000",
|
||||
"OTS-derived-font"
|
||||
};
|
||||
static const size_t kStringsLen = sizeof(kStrings) / sizeof(kStrings[0]);
|
||||
|
||||
// The spec says that "In CFF OpenType fonts, these two name strings, when
|
||||
// translated to ASCII, must also be identical to the font name as stored in
|
||||
// the CFF's Name INDEX." And actually, Mac OS X's font parser requires that.
|
||||
if (file->cff && !file->cff->name.empty()) {
|
||||
kStrings[6] = file->cff->name.c_str();
|
||||
kStdNames[6] = file->cff->name.c_str();
|
||||
}
|
||||
|
||||
unsigned num_strings = 0;
|
||||
for (unsigned i = 0; i < kStringsLen; ++i) {
|
||||
if (kStrings[i]) num_strings++;
|
||||
}
|
||||
|
||||
if (!out->WriteU16(0) || // version
|
||||
// Magic numbers:
|
||||
// 6: This entry (U16 * 3 = 6 bytes)
|
||||
// 2: Mac Roman & Windows Roman = 2 types
|
||||
// 12: Each string entry (U16 * 6 = 12 bytes)
|
||||
!out->WriteU16(num_strings * 2) || // count
|
||||
!out->WriteU16(6 + num_strings * 2 * 12)) { // string data offset
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
unsigned current_offset = 0;
|
||||
for (unsigned i = 0; i < kStringsLen; ++i) {
|
||||
if (!kStrings[i]) continue;
|
||||
|
||||
// string length in UTF-8 (ASCII).
|
||||
size_t len = std::strlen(kStrings[i]);
|
||||
|
||||
if (!out->WriteU16(1) || // Mac
|
||||
!out->WriteU16(0) || // Roman
|
||||
!out->WriteU16(0) || // English
|
||||
!out->WriteU16(i) ||
|
||||
!out->WriteU16(len) ||
|
||||
!out->WriteU16(current_offset)) {
|
||||
return OTS_FAILURE();
|
||||
// scan the names to check whether the required "standard" ones are present;
|
||||
// if not, we'll add our fixed versions here
|
||||
bool macName[kStdNameCount] = { 0 };
|
||||
bool winName[kStdNameCount] = { 0 };
|
||||
for (std::vector<NameRecord>::iterator nameIter = name->names.begin();
|
||||
nameIter != name->names.end(); nameIter++) {
|
||||
uint16_t id = nameIter->nameID;
|
||||
if (id >= kStdNameCount || kStdNames[id] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
current_offset += len;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < kStringsLen; ++i) {
|
||||
if (!kStrings[i]) continue;
|
||||
|
||||
// string length in UTF-16.
|
||||
size_t len = std::strlen(kStrings[i]) * 2;
|
||||
|
||||
if (!out->WriteU16(3) || // Windows
|
||||
!out->WriteU16(1) || // Unicode BMP (UCS-2)
|
||||
!out->WriteU16(0x0409) || // US English
|
||||
!out->WriteU16(i) ||
|
||||
!out->WriteU16(len) ||
|
||||
!out->WriteU16(current_offset)) {
|
||||
return OTS_FAILURE();
|
||||
if (nameIter->platformID == 1) {
|
||||
macName[id] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
current_offset += len;
|
||||
}
|
||||
|
||||
// Write strings in Mac Roman compatible with ASCII.
|
||||
// Because all the entries are ASCII, we can just copy.
|
||||
for (unsigned i = 0; i < kStringsLen; ++i) {
|
||||
if (!kStrings[i]) continue;
|
||||
|
||||
const size_t len = std::strlen(kStrings[i]);
|
||||
if (!out->Write(kStrings[i], len)) {
|
||||
return OTS_FAILURE();
|
||||
if (nameIter->platformID == 3) {
|
||||
winName[id] = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Write strings in UCS-2. Because all the entries are ASCII,
|
||||
// we can just expand each byte to U16.
|
||||
for (unsigned i = 0; i < kStringsLen; ++i) {
|
||||
if (!kStrings[i]) continue;
|
||||
|
||||
const size_t len = std::strlen(kStrings[i]);
|
||||
for (size_t j = 0; j < len; ++j) {
|
||||
uint16_t v = kStrings[i][j];
|
||||
if (!out->WriteU16(v)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
for (unsigned int i = 0; i < kStdNameCount; ++i) {
|
||||
if (kStdNames[i] == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (!macName[i]) {
|
||||
NameRecord rec(1, 0, 0, i);
|
||||
rec.text.assign(kStdNames[i]);
|
||||
name->names.push_back(rec);
|
||||
sortRequired = true;
|
||||
}
|
||||
if (!winName[i]) {
|
||||
NameRecord rec(3, 1, 1033, i);
|
||||
assign_to_utf16_be_from_ascii(rec.text, std::string(kStdNames[i]));
|
||||
name->names.push_back(rec);
|
||||
sortRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (sortRequired) {
|
||||
std::sort(name->names.begin(), name->names.end());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ots_name_free(OpenTypeFile *) {
|
||||
bool ots_name_should_serialise(OpenTypeFile *file) {
|
||||
return file->name != NULL;
|
||||
}
|
||||
|
||||
bool ots_name_serialise(OTSStream *out, OpenTypeFile *file) {
|
||||
const OpenTypeNAME *name = file->name;
|
||||
|
||||
uint16_t nameCount = name->names.size();
|
||||
uint16_t langTagCount = name->langTags.size();
|
||||
uint16_t format = 0;
|
||||
size_t stringOffset = 6 + nameCount * 12;
|
||||
|
||||
if (name->langTags.size() > 0) {
|
||||
// lang tags require a format-1 name table
|
||||
format = 1;
|
||||
stringOffset = 8 + nameCount * 12 + langTagCount * 4;
|
||||
}
|
||||
if (stringOffset > 0xffff) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
if (!out->WriteU16(format) ||
|
||||
!out->WriteU16(nameCount) ||
|
||||
!out->WriteU16(stringOffset)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
std::string stringData;
|
||||
for (std::vector<NameRecord>::const_iterator nameIter = name->names.begin();
|
||||
nameIter != name->names.end(); nameIter++) {
|
||||
const NameRecord& rec = *nameIter;
|
||||
if (!out->WriteU16(rec.platformID) ||
|
||||
!out->WriteU16(rec.encodingID) ||
|
||||
!out->WriteU16(rec.languageID) ||
|
||||
!out->WriteU16(rec.nameID) ||
|
||||
!out->WriteU16(rec.text.size()) ||
|
||||
!out->WriteU16(stringData.size()) ) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
stringData.append(rec.text);
|
||||
}
|
||||
|
||||
if (format == 1) {
|
||||
if (!out->WriteU16(langTagCount)) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
for (std::vector<std::string>::const_iterator tagIter = name->langTags.begin();
|
||||
tagIter != name->langTags.end(); tagIter++) {
|
||||
if (!out->WriteU16(tagIter->size()) ||
|
||||
!out->WriteU16(stringData.size())) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
stringData.append(*tagIter);
|
||||
}
|
||||
}
|
||||
|
||||
if (!out->Write(stringData.data(), stringData.size())) {
|
||||
return OTS_FAILURE();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ots_name_free(OpenTypeFile *file) {
|
||||
delete file->name;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
50
gfx/ots/src/name.h
Normal file
50
gfx/ots/src/name.h
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2011 Mozilla Foundation. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef OTS_NAME_H_
|
||||
#define OTS_NAME_H_
|
||||
|
||||
#include <new>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "ots.h"
|
||||
|
||||
namespace ots {
|
||||
|
||||
struct NameRecord {
|
||||
NameRecord()
|
||||
{ }
|
||||
|
||||
NameRecord(uint16_t p, uint16_t e, uint16_t l, uint16_t n)
|
||||
: platformID(p), encodingID(e), languageID(l), nameID(n)
|
||||
{ }
|
||||
|
||||
uint16_t platformID;
|
||||
uint16_t encodingID;
|
||||
uint16_t languageID;
|
||||
uint16_t nameID;
|
||||
std::string text;
|
||||
|
||||
bool operator<(const NameRecord& rhs) const {
|
||||
if (platformID < rhs.platformID) return true;
|
||||
if (platformID > rhs.platformID) return false;
|
||||
if (encodingID < rhs.encodingID) return true;
|
||||
if (encodingID > rhs.encodingID) return false;
|
||||
if (languageID < rhs.languageID) return true;
|
||||
if (languageID > rhs.languageID) return false;
|
||||
if (nameID < rhs.nameID) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
struct OpenTypeNAME {
|
||||
std::vector<NameRecord> names;
|
||||
std::vector<std::string> langTags;
|
||||
};
|
||||
|
||||
} // namespace ots
|
||||
|
||||
#endif // OTS_NAME_H_
|
@ -112,15 +112,6 @@ nsresult nsSystemFontsWin::GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
|
||||
LOGFONTW logFont;
|
||||
LOGFONTW* ptrLogFont = NULL;
|
||||
|
||||
#ifdef WINCE
|
||||
hGDI = ::GetStockObject(SYSTEM_FONT);
|
||||
if (hGDI == NULL)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (::GetObjectW(hGDI, sizeof(logFont), &logFont) > 0)
|
||||
ptrLogFont = &logFont;
|
||||
#else
|
||||
|
||||
NONCLIENTMETRICSW ncm;
|
||||
|
||||
BOOL status;
|
||||
@ -197,8 +188,6 @@ nsresult nsSystemFontsWin::GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
|
||||
break;
|
||||
} // switch
|
||||
|
||||
#endif // WINCE
|
||||
|
||||
if (nsnull == ptrLogFont)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -403,6 +403,14 @@ TRY_AGAIN_NO_SHARING:
|
||||
{
|
||||
MarkDestroyed();
|
||||
|
||||
// see bug 659842 comment 76
|
||||
#ifdef DEBUG
|
||||
bool success =
|
||||
#endif
|
||||
sGLXLibrary.xMakeCurrent(mDisplay, None, nsnull);
|
||||
NS_ABORT_IF_FALSE(success,
|
||||
"glXMakeCurrent failed to release GL context before we call glXDestroyContext!");
|
||||
|
||||
sGLXLibrary.xDestroyContext(mDisplay, mContext);
|
||||
|
||||
if (mDeleteDrawable) {
|
||||
|
@ -135,20 +135,10 @@ EXPORTS += \
|
||||
gfxWindowsSurface.h \
|
||||
gfxWindowsNativeDrawing.h \
|
||||
WGLLibrary.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef WINCE
|
||||
EXPORTS += \
|
||||
gfxFT2Fonts.h \
|
||||
gfxFT2FontBase.h \
|
||||
$(NULL)
|
||||
else
|
||||
EXPORTS += \
|
||||
gfxDWriteFonts.h \
|
||||
gfxD2DSurface.h \
|
||||
$(NULL)
|
||||
endif
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
gfxASurface.cpp \
|
||||
@ -205,20 +195,13 @@ SHARED_LIBRARY_LIBS += \
|
||||
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
|
||||
CPPSRCS += gfxWindowsPlatform.cpp \
|
||||
gfxWindowsSurface.cpp \
|
||||
gfxWindowsNativeDrawing.cpp \
|
||||
nsUnicodeRange.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef WINCE
|
||||
CPPSRCS += gfxFT2Fonts.cpp \
|
||||
gfxFT2FontBase.cpp \
|
||||
gfxFT2Utils.cpp \
|
||||
gfxFT2FontList.cpp \
|
||||
$(NULL)
|
||||
|
||||
else
|
||||
ifdef MOZ_ENABLE_DWRITE_FONT
|
||||
CPPSRCS += gfxDWriteFonts.cpp \
|
||||
gfxDWriteShaper.cpp \
|
||||
@ -228,12 +211,12 @@ CPPSRCS += gfxDWriteFonts.cpp \
|
||||
gfxDWriteFontList.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CPPSRCS += gfxGDIFont.cpp \
|
||||
gfxGDIFontList.cpp \
|
||||
gfxGDIShaper.cpp \
|
||||
gfxUniscribeShaper.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CPPSRCS += gfxPDFSurface.cpp
|
||||
|
||||
@ -342,11 +325,8 @@ CSRCS += woff.c
|
||||
GL_PROVIDER = Null
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
ifndef WINCE
|
||||
GL_PROVIDER = WGL
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
GL_PROVIDER = CGL
|
||||
@ -394,12 +374,6 @@ DEFINES := $(filter-out -DUNICODE,$(DEFINES))
|
||||
CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
|
||||
CFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
ifdef WINCE
|
||||
CXXFLAGS += $(CAIRO_FT_CFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
|
||||
CXXFLAGS += $(CAIRO_FT_CFLAGS)
|
||||
endif
|
||||
|
@ -110,10 +110,9 @@ gfxDWriteShaper::InitTextRun(gfxContext *aContext,
|
||||
}
|
||||
}
|
||||
|
||||
gfxTextRange range(aRunStart + rangeOffset,
|
||||
aRunStart + rangeOffset + rangeLen);
|
||||
PRUint32 rangeStart = aRunStart + rangeOffset;
|
||||
rangeOffset += rangeLen;
|
||||
TextAnalysis analysis(aString + range.start, range.Length(),
|
||||
TextAnalysis analysis(aString + rangeStart, rangeLen,
|
||||
NULL,
|
||||
readingDirection);
|
||||
TextAnalysis::Run *runHead;
|
||||
@ -130,18 +129,18 @@ gfxDWriteShaper::InitTextRun(gfxContext *aContext,
|
||||
|
||||
UINT32 maxGlyphs = 0;
|
||||
trymoreglyphs:
|
||||
if ((PR_UINT32_MAX - 3 * range.Length() / 2 + 16) < maxGlyphs) {
|
||||
if ((PR_UINT32_MAX - 3 * rangeLen / 2 + 16) < maxGlyphs) {
|
||||
// This isn't going to work, we're going to cross the UINT32 upper
|
||||
// limit. Next range it is.
|
||||
continue;
|
||||
}
|
||||
maxGlyphs += 3 * range.Length() / 2 + 16;
|
||||
maxGlyphs += 3 * rangeLen / 2 + 16;
|
||||
|
||||
nsAutoTArray<UINT16, 400> clusters;
|
||||
nsAutoTArray<UINT16, 400> indices;
|
||||
nsAutoTArray<DWRITE_SHAPING_TEXT_PROPERTIES, 400> textProperties;
|
||||
nsAutoTArray<DWRITE_SHAPING_GLYPH_PROPERTIES, 400> glyphProperties;
|
||||
if (!clusters.SetLength(range.Length()) ||
|
||||
if (!clusters.SetLength(rangeLen) ||
|
||||
!indices.SetLength(maxGlyphs) ||
|
||||
!textProperties.SetLength(maxGlyphs) ||
|
||||
!glyphProperties.SetLength(maxGlyphs)) {
|
||||
@ -150,7 +149,7 @@ trymoreglyphs:
|
||||
|
||||
UINT32 actualGlyphs;
|
||||
|
||||
hr = analyzer->GetGlyphs(aString + range.start, range.Length(),
|
||||
hr = analyzer->GetGlyphs(aString + rangeStart, rangeLen,
|
||||
font->GetFontFace(), FALSE,
|
||||
readingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT,
|
||||
&runHead->mScript, NULL, NULL, NULL, NULL, 0,
|
||||
@ -177,10 +176,10 @@ trymoreglyphs:
|
||||
|
||||
if (!static_cast<gfxDWriteFont*>(mFont)->mUseSubpixelPositions) {
|
||||
hr = analyzer->GetGdiCompatibleGlyphPlacements(
|
||||
aString + range.start,
|
||||
aString + rangeStart,
|
||||
clusters.Elements(),
|
||||
textProperties.Elements(),
|
||||
range.Length(),
|
||||
rangeLen,
|
||||
indices.Elements(),
|
||||
glyphProperties.Elements(),
|
||||
actualGlyphs,
|
||||
@ -199,10 +198,10 @@ trymoreglyphs:
|
||||
advances.Elements(),
|
||||
glyphOffsets.Elements());
|
||||
} else {
|
||||
hr = analyzer->GetGlyphPlacements(aString + range.start,
|
||||
hr = analyzer->GetGlyphPlacements(aString + rangeStart,
|
||||
clusters.Elements(),
|
||||
textProperties.Elements(),
|
||||
range.Length(),
|
||||
rangeLen,
|
||||
indices.Elements(),
|
||||
glyphProperties.Elements(),
|
||||
actualGlyphs,
|
||||
@ -226,9 +225,9 @@ trymoreglyphs:
|
||||
|
||||
nsAutoTArray<gfxTextRun::DetailedGlyph,1> detailedGlyphs;
|
||||
|
||||
for (unsigned int c = 0; c < range.Length(); c++) {
|
||||
for (unsigned int c = 0; c < rangeLen; c++) {
|
||||
PRUint32 k = clusters[c];
|
||||
PRUint32 absC = range.start + c;
|
||||
PRUint32 absC = rangeStart + c;
|
||||
|
||||
if (c > 0 && k == clusters[c - 1]) {
|
||||
g.SetComplex(aTextRun->IsClusterStart(absC), PR_FALSE, 0);
|
||||
@ -241,7 +240,7 @@ trymoreglyphs:
|
||||
PRUint32 glyphCount = actualGlyphs - k;
|
||||
PRUint32 nextClusterOffset;
|
||||
for (nextClusterOffset = c + 1;
|
||||
nextClusterOffset < range.Length(); ++nextClusterOffset) {
|
||||
nextClusterOffset < rangeLen; ++nextClusterOffset) {
|
||||
if (clusters[nextClusterOffset] > k) {
|
||||
glyphCount = clusters[nextClusterOffset] - k;
|
||||
break;
|
||||
|
@ -42,9 +42,6 @@
|
||||
#include "gfxQtPlatform.h"
|
||||
#define gfxToolkitPlatform gfxQtPlatform
|
||||
#elif defined(XP_WIN)
|
||||
#ifdef WINCE
|
||||
#define SHGetSpecialFolderPathW SHGetSpecialFolderPath
|
||||
#endif
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#define gfxToolkitPlatform gfxWindowsPlatform
|
||||
#include "gfxFT2FontList.h"
|
||||
@ -260,31 +257,42 @@ FontEntry::ReadCMAP()
|
||||
// attempt this once, if errors occur leave a blank cmap
|
||||
mCmapInitialized = PR_TRUE;
|
||||
|
||||
AutoFallibleTArray<PRUint8,16384> buffer;
|
||||
nsresult rv = GetFontTable(TTAG_cmap, buffer);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRPackedBool unicodeFont;
|
||||
PRPackedBool symbolFont;
|
||||
rv = gfxFontUtils::ReadCMAP(buffer.Elements(), buffer.Length(),
|
||||
mCharacterMap, mUVSOffset,
|
||||
unicodeFont, symbolFont);
|
||||
}
|
||||
|
||||
mHasCmapTable = NS_SUCCEEDED(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FontEntry::GetFontTable(PRUint32 aTableTag, FallibleTArray<PRUint8>& aBuffer)
|
||||
{
|
||||
// Ensure existence of mFTFace
|
||||
CairoFontFace();
|
||||
NS_ENSURE_TRUE(mFTFace, NS_ERROR_FAILURE);
|
||||
|
||||
FT_Error status;
|
||||
FT_ULong len = 0;
|
||||
status = FT_Load_Sfnt_Table(mFTFace, TTAG_cmap, 0, nsnull, &len);
|
||||
status = FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, nsnull, &len);
|
||||
NS_ENSURE_TRUE(status == 0, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(len != 0, NS_ERROR_FAILURE);
|
||||
|
||||
AutoFallibleTArray<PRUint8,16384> buffer;
|
||||
if (!buffer.AppendElements(len)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!aBuffer.SetLength(len)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
PRUint8 *buf = buffer.Elements();
|
||||
|
||||
status = FT_Load_Sfnt_Table(mFTFace, TTAG_cmap, 0, buf, &len);
|
||||
PRUint8 *buf = aBuffer.Elements();
|
||||
status = FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, buf, &len);
|
||||
NS_ENSURE_TRUE(status == 0, NS_ERROR_FAILURE);
|
||||
|
||||
PRPackedBool unicodeFont;
|
||||
PRPackedBool symbolFont;
|
||||
nsresult rv = gfxFontUtils::ReadCMAP(buf, len, mCharacterMap, mUVSOffset,
|
||||
unicodeFont, symbolFont);
|
||||
mHasCmapTable = NS_SUCCEEDED(rv);
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
FontEntry *
|
||||
@ -707,7 +715,6 @@ gfxFT2Font::AddRange(gfxTextRun *aTextRun, const PRUnichar *str, PRUint32 offset
|
||||
|
||||
FT_UInt spaceGlyph = GetSpaceGlyph();
|
||||
|
||||
aTextRun->AddGlyphRun(this, offset);
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
PRUint32 ch = str[offset + i];
|
||||
|
||||
|
@ -112,6 +112,8 @@ public:
|
||||
cairo_font_face_t *CairoFontFace();
|
||||
nsresult ReadCMAP();
|
||||
|
||||
nsresult GetFontTable(PRUint32 aTableTag, FallibleTArray<PRUint8>& aBuffer);
|
||||
|
||||
FT_Face mFTFace;
|
||||
cairo_font_face_t *mFontFace;
|
||||
|
||||
|
@ -165,10 +165,29 @@ nsresult gfxFontEntry::ReadCMAP()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsString& gfxFontEntry::FamilyName() const
|
||||
nsString gfxFontEntry::FamilyName() const
|
||||
{
|
||||
NS_ASSERTION(mFamily, "gfxFontEntry is not a member of a family");
|
||||
return mFamily->Name();
|
||||
NS_ASSERTION(mFamily, "orphaned font entry");
|
||||
if (mFamily) {
|
||||
return mFamily->Name();
|
||||
} else {
|
||||
return nsString();
|
||||
}
|
||||
}
|
||||
|
||||
nsString
|
||||
gfxFontEntry::RealFaceName()
|
||||
{
|
||||
FallibleTArray<PRUint8> nameTable;
|
||||
nsresult rv = GetFontTable(TRUETYPE_TAG('n','a','m','e'), nameTable);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoString name;
|
||||
rv = gfxFontUtils::GetFullNameFromTable(nameTable, name);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return Name();
|
||||
}
|
||||
|
||||
already_AddRefed<gfxFont>
|
||||
@ -1974,7 +1993,7 @@ gfxFontGroup::BuildFontList()
|
||||
{
|
||||
// "#if" to be removed once all platforms are moved to gfxPlatformFontList interface
|
||||
// and subclasses of gfxFontGroup eliminated
|
||||
#if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(WINCE)) || defined(ANDROID)
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID)
|
||||
ForEachFont(FindPlatformFont, this);
|
||||
|
||||
if (mFonts.Length() == 0) {
|
||||
@ -2331,7 +2350,7 @@ gfxFontGroup::MakeSpaceTextRun(const Parameters *aParams, PRUint32 aFlags)
|
||||
// Short-circuit for size-0 fonts, as Windows and ATSUI can't handle
|
||||
// them, and always create at least size 1 fonts, i.e. they still
|
||||
// render something for size 0 fonts.
|
||||
textRun->AddGlyphRun(font, 0);
|
||||
textRun->AddGlyphRun(font, gfxTextRange::kFontGroup, 0, PR_FALSE);
|
||||
}
|
||||
else {
|
||||
textRun->SetSpaceGlyph(font, aParams->mContext, 0);
|
||||
@ -2480,8 +2499,13 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
|
||||
gfxFont *matchedFont = (range.font ? range.font.get() : nsnull);
|
||||
|
||||
// create the glyph run for this range
|
||||
aTextRun->AddGlyphRun(matchedFont ? matchedFont : mainFont,
|
||||
runStart, (matchedLength > 0));
|
||||
if (matchedFont) {
|
||||
aTextRun->AddGlyphRun(matchedFont, range.matchType,
|
||||
runStart, (matchedLength > 0));
|
||||
} else {
|
||||
aTextRun->AddGlyphRun(mainFont, gfxTextRange::kFontGroup,
|
||||
runStart, (matchedLength > 0));
|
||||
}
|
||||
if (matchedFont) {
|
||||
// do glyph layout and record the resulting positioned glyphs
|
||||
if (!matchedFont->SplitAndInitTextRun(aContext, aTextRun, aString,
|
||||
@ -2542,7 +2566,8 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
|
||||
|
||||
already_AddRefed<gfxFont>
|
||||
gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
PRInt32 aRunScript, gfxFont *aPrevMatchedFont)
|
||||
PRInt32 aRunScript, gfxFont *aPrevMatchedFont,
|
||||
PRUint8 *aMatchType)
|
||||
{
|
||||
nsRefPtr<gfxFont> selectedFont;
|
||||
|
||||
@ -2570,8 +2595,10 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
// 1. check fonts in the font group
|
||||
for (PRUint32 i = 0; i < FontListLength(); i++) {
|
||||
nsRefPtr<gfxFont> font = GetFontAt(i);
|
||||
if (font->HasCharacter(aCh))
|
||||
if (font->HasCharacter(aCh)) {
|
||||
*aMatchType = gfxTextRange::kFontGroup;
|
||||
return font.forget();
|
||||
}
|
||||
}
|
||||
|
||||
// if character is in Private Use Area, don't do matching against pref or system fonts
|
||||
@ -2580,12 +2607,14 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
|
||||
// 2. search pref fonts
|
||||
if ((selectedFont = WhichPrefFontSupportsChar(aCh))) {
|
||||
*aMatchType = gfxTextRange::kPrefsFallback;
|
||||
return selectedFont.forget();
|
||||
}
|
||||
|
||||
// 3. use fallback fonts
|
||||
// -- before searching for something else check the font used for the previous character
|
||||
if (!selectedFont && aPrevMatchedFont && aPrevMatchedFont->HasCharacter(aCh)) {
|
||||
*aMatchType = gfxTextRange::kSystemFallback;
|
||||
selectedFont = aPrevMatchedFont;
|
||||
return selectedFont.forget();
|
||||
}
|
||||
@ -2601,6 +2630,7 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
|
||||
// -- otherwise look for other stuff
|
||||
if (!selectedFont) {
|
||||
*aMatchType = gfxTextRange::kSystemFallback;
|
||||
selectedFont = WhichSystemFontSupportsChar(aCh);
|
||||
return selectedFont.forget();
|
||||
}
|
||||
@ -2625,6 +2655,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<gfxTextRange>& aRanges,
|
||||
|
||||
PRUint32 prevCh = 0;
|
||||
gfxFont *prevFont = nsnull;
|
||||
PRUint8 matchType = 0;
|
||||
|
||||
for (PRUint32 i = 0; i < len; i++) {
|
||||
|
||||
@ -2639,26 +2670,21 @@ void gfxFontGroup::ComputeRanges(nsTArray<gfxTextRange>& aRanges,
|
||||
|
||||
// find the font for this char
|
||||
nsRefPtr<gfxFont> font =
|
||||
FindFontForChar(ch, prevCh, aRunScript, prevFont);
|
||||
FindFontForChar(ch, prevCh, aRunScript, prevFont, &matchType);
|
||||
|
||||
prevCh = ch;
|
||||
|
||||
if (aRanges.Length() == 0) {
|
||||
// first char ==> make a new range
|
||||
gfxTextRange r(0,1);
|
||||
r.font = font;
|
||||
aRanges.AppendElement(r);
|
||||
aRanges.AppendElement(gfxTextRange(0, 1, font, matchType));
|
||||
prevFont = font;
|
||||
} else {
|
||||
// if font has changed, make a new range
|
||||
gfxTextRange& prevRange = aRanges[aRanges.Length() - 1];
|
||||
if (prevRange.font != font) {
|
||||
if (prevRange.font != font || prevRange.matchType != matchType) {
|
||||
// close out the previous range
|
||||
prevRange.end = origI;
|
||||
|
||||
gfxTextRange r(origI, i+1);
|
||||
r.font = font;
|
||||
aRanges.AppendElement(r);
|
||||
aRanges.AppendElement(gfxTextRange(origI, i+1, font, matchType));
|
||||
|
||||
// update prevFont for the next match, *unless* we switched
|
||||
// fonts on a ZWJ, in which case propagating the changed font
|
||||
@ -2705,7 +2731,7 @@ gfxFontGroup::UpdateFontList()
|
||||
mSkipDrawing = PR_FALSE;
|
||||
|
||||
// bug 548184 - need to clean up FT2, OS/2 platform code to use BuildFontList
|
||||
#if defined(XP_MACOSX) || (defined(XP_WIN) && !defined(WINCE)) || defined(ANDROID)
|
||||
#if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID)
|
||||
BuildFontList();
|
||||
#else
|
||||
ForEachFont(FindPlatformFont, this);
|
||||
@ -3930,20 +3956,22 @@ gfxTextRun::FindFirstGlyphRunContaining(PRUint32 aOffset)
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxTextRun::AddGlyphRun(gfxFont *aFont, PRUint32 aUTF16Offset, PRBool aForceNewRun)
|
||||
gfxTextRun::AddGlyphRun(gfxFont *aFont, PRUint8 aMatchType,
|
||||
PRUint32 aUTF16Offset, PRBool aForceNewRun)
|
||||
{
|
||||
PRUint32 numGlyphRuns = mGlyphRuns.Length();
|
||||
if (!aForceNewRun &&
|
||||
numGlyphRuns > 0)
|
||||
{
|
||||
if (!aForceNewRun && numGlyphRuns > 0) {
|
||||
GlyphRun *lastGlyphRun = &mGlyphRuns[numGlyphRuns - 1];
|
||||
|
||||
NS_ASSERTION(lastGlyphRun->mCharacterOffset <= aUTF16Offset,
|
||||
"Glyph runs out of order (and run not forced)");
|
||||
|
||||
// Don't append a run if the font is already the one we want
|
||||
if (lastGlyphRun->mFont == aFont)
|
||||
if (lastGlyphRun->mFont == aFont &&
|
||||
lastGlyphRun->mMatchType == aMatchType)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If the offset has not changed, avoid leaving a zero-length run
|
||||
// by overwriting the last entry instead of appending...
|
||||
@ -3953,13 +3981,15 @@ gfxTextRun::AddGlyphRun(gfxFont *aFont, PRUint32 aUTF16Offset, PRBool aForceNewR
|
||||
// font as the new one wants, merge with it instead of creating
|
||||
// adjacent runs with the same font
|
||||
if (numGlyphRuns > 1 &&
|
||||
mGlyphRuns[numGlyphRuns - 2].mFont == aFont)
|
||||
mGlyphRuns[numGlyphRuns - 2].mFont == aFont &&
|
||||
mGlyphRuns[numGlyphRuns - 2].mMatchType == aMatchType)
|
||||
{
|
||||
mGlyphRuns.TruncateLength(numGlyphRuns - 1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
lastGlyphRun->mFont = aFont;
|
||||
lastGlyphRun->mMatchType = aMatchType;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@ -3972,6 +4002,7 @@ gfxTextRun::AddGlyphRun(gfxFont *aFont, PRUint32 aUTF16Offset, PRBool aForceNewR
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
glyphRun->mFont = aFont;
|
||||
glyphRun->mCharacterOffset = aUTF16Offset;
|
||||
glyphRun->mMatchType = aMatchType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4197,7 +4228,8 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, PRUint32 aStart,
|
||||
NS_WARN_IF_FALSE(end == aSource->GetLength() || aSource->IsClusterStart(end),
|
||||
"Ended font run in the middle of a cluster");
|
||||
|
||||
nsresult rv = AddGlyphRun(font, start - aStart + aDest);
|
||||
nsresult rv = AddGlyphRun(font, iter.GetGlyphRun()->mMatchType,
|
||||
start - aStart + aDest, PR_FALSE);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
}
|
||||
@ -4225,8 +4257,7 @@ gfxTextRun::SetSpaceGlyph(gfxFont *aFont, gfxContext *aContext, PRUint32 aCharIn
|
||||
CopyGlyphDataFrom(textRun, 0, 1, aCharIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
AddGlyphRun(aFont, aCharIndex);
|
||||
AddGlyphRun(aFont, gfxTextRange::kFontGroup, aCharIndex, PR_FALSE);
|
||||
CompressedGlyph g;
|
||||
g.SetSimpleGlyph(spaceWidthAppUnits, spaceGlyph);
|
||||
SetSimpleGlyph(aCharIndex, g);
|
||||
|
@ -221,9 +221,14 @@ public:
|
||||
|
||||
virtual ~gfxFontEntry();
|
||||
|
||||
// unique name for the face, *not* the family
|
||||
// unique name for the face, *not* the family; not necessarily the
|
||||
// "real" or user-friendly name, may be an internal identifier
|
||||
const nsString& Name() const { return mName; }
|
||||
|
||||
// the "real" name of the face, if available from the font resource
|
||||
// (may be expensive); returns Name() if nothing better is available
|
||||
virtual nsString RealFaceName();
|
||||
|
||||
gfxFontFamily* Family() const { return mFamily; }
|
||||
|
||||
PRUint16 Weight() const { return mWeight; }
|
||||
@ -273,7 +278,7 @@ public:
|
||||
mFamily = aFamily;
|
||||
}
|
||||
|
||||
const nsString& FamilyName() const;
|
||||
virtual nsString FamilyName() const;
|
||||
|
||||
already_AddRefed<gfxFont> FindOrMakeFont(const gfxFontStyle *aStyle,
|
||||
PRBool aNeedsBold);
|
||||
@ -605,10 +610,23 @@ protected:
|
||||
};
|
||||
|
||||
struct gfxTextRange {
|
||||
gfxTextRange(PRUint32 aStart, PRUint32 aEnd) : start(aStart), end(aEnd) { }
|
||||
enum {
|
||||
// flags for recording the kind of font-matching that was used
|
||||
kFontGroup = 0x0001,
|
||||
kPrefsFallback = 0x0002,
|
||||
kSystemFallback = 0x0004
|
||||
};
|
||||
gfxTextRange(PRUint32 aStart, PRUint32 aEnd,
|
||||
gfxFont* aFont, PRUint8 aMatchType)
|
||||
: start(aStart),
|
||||
end(aEnd),
|
||||
font(aFont),
|
||||
matchType(aMatchType)
|
||||
{ }
|
||||
PRUint32 Length() const { return end - start; }
|
||||
nsRefPtr<gfxFont> font;
|
||||
PRUint32 start, end;
|
||||
nsRefPtr<gfxFont> font;
|
||||
PRUint8 matchType;
|
||||
};
|
||||
|
||||
|
||||
@ -1871,6 +1889,7 @@ public:
|
||||
struct GlyphRun {
|
||||
nsRefPtr<gfxFont> mFont; // never null
|
||||
PRUint32 mCharacterOffset; // into original UTF16 string
|
||||
PRUint8 mMatchType;
|
||||
};
|
||||
|
||||
class THEBES_API GlyphRunIterator {
|
||||
@ -1926,7 +1945,8 @@ public:
|
||||
* are added before any further operations are performed with this
|
||||
* TextRun.
|
||||
*/
|
||||
nsresult AddGlyphRun(gfxFont *aFont, PRUint32 aStartCharIndex, PRBool aForceNewRun = PR_FALSE);
|
||||
nsresult AddGlyphRun(gfxFont *aFont, PRUint8 aMatchType,
|
||||
PRUint32 aStartCharIndex, PRBool aForceNewRun);
|
||||
void ResetGlyphRuns() { mGlyphRuns.Clear(); }
|
||||
void SortGlyphRuns();
|
||||
void SanitizeGlyphRuns();
|
||||
@ -2225,7 +2245,7 @@ private:
|
||||
|
||||
// XXX this should be changed to a GlyphRun plus a maybe-null GlyphRun*,
|
||||
// for smaller size especially in the super-common one-glyphrun case
|
||||
nsAutoTArray<GlyphRun,1> mGlyphRuns;
|
||||
nsAutoTArray<GlyphRun,1> mGlyphRuns;
|
||||
// When TEXT_IS_8BIT is set, we use mSingle, otherwise we use mDouble.
|
||||
// When TEXT_IS_PERSISTENT is set, we don't own the text, otherwise we
|
||||
// own the text. When we own the text, it's allocated fused with the
|
||||
@ -2352,7 +2372,8 @@ public:
|
||||
|
||||
virtual already_AddRefed<gfxFont>
|
||||
FindFontForChar(PRUint32 ch, PRUint32 prevCh, PRInt32 aRunScript,
|
||||
gfxFont *aPrevMatchedFont);
|
||||
gfxFont *aPrevMatchedFont,
|
||||
PRUint8 *aMatchType);
|
||||
|
||||
// search through pref fonts for a character, return nsnull if no matching pref font
|
||||
virtual already_AddRefed<gfxFont> WhichPrefFontSupportsChar(PRUint32 aCh);
|
||||
|
@ -1434,6 +1434,80 @@ gfxFontUtils::RenameFont(const nsAString& aName, const PRUint8 *aFontData,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// This is only called after the basic validity of the downloaded sfnt
|
||||
// data has been checked, so it should never fail to find the name table
|
||||
// (though it might fail to read it, if memory isn't available);
|
||||
// other checks here are just for extra paranoia.
|
||||
nsresult
|
||||
gfxFontUtils::GetFullNameFromSFNT(const PRUint8* aFontData, PRUint32 aLength,
|
||||
nsAString& aFullName)
|
||||
{
|
||||
aFullName.AssignLiteral("(MISSING NAME)"); // should always get replaced
|
||||
|
||||
NS_ENSURE_TRUE(aLength >= sizeof(SFNTHeader), NS_ERROR_UNEXPECTED);
|
||||
const SFNTHeader *sfntHeader =
|
||||
reinterpret_cast<const SFNTHeader*>(aFontData);
|
||||
const TableDirEntry *dirEntry =
|
||||
reinterpret_cast<const TableDirEntry*>(aFontData + sizeof(SFNTHeader));
|
||||
PRUint32 numTables = sfntHeader->numTables;
|
||||
NS_ENSURE_TRUE(aLength >=
|
||||
sizeof(SFNTHeader) + numTables * sizeof(TableDirEntry),
|
||||
NS_ERROR_UNEXPECTED);
|
||||
PRBool foundName = PR_FALSE;
|
||||
for (PRUint32 i = 0; i < numTables; i++, dirEntry++) {
|
||||
if (dirEntry->tag == TRUETYPE_TAG('n','a','m','e')) {
|
||||
foundName = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// should never fail, as we're only called after font validation succeeded
|
||||
NS_ENSURE_TRUE(foundName, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
PRUint32 len = dirEntry->length;
|
||||
NS_ENSURE_TRUE(aLength > len && aLength - len >= dirEntry->offset,
|
||||
NS_ERROR_UNEXPECTED);
|
||||
FallibleTArray<PRUint8> nameTable;
|
||||
if (!nameTable.SetLength(len)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(nameTable.Elements(), aFontData + dirEntry->offset, len);
|
||||
|
||||
return GetFullNameFromTable(nameTable, aFullName);
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxFontUtils::GetFullNameFromTable(FallibleTArray<PRUint8>& aNameTable,
|
||||
nsAString& aFullName)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult rv =
|
||||
gfxFontUtils::ReadCanonicalName(aNameTable,
|
||||
gfxFontUtils::NAME_ID_FULL,
|
||||
name);
|
||||
if (NS_SUCCEEDED(rv) && !name.IsEmpty()) {
|
||||
aFullName = name;
|
||||
return NS_OK;
|
||||
}
|
||||
rv = gfxFontUtils::ReadCanonicalName(aNameTable,
|
||||
gfxFontUtils::NAME_ID_FAMILY,
|
||||
name);
|
||||
if (NS_SUCCEEDED(rv) && !name.IsEmpty()) {
|
||||
nsAutoString styleName;
|
||||
rv = gfxFontUtils::ReadCanonicalName(aNameTable,
|
||||
gfxFontUtils::NAME_ID_STYLE,
|
||||
styleName);
|
||||
if (NS_SUCCEEDED(rv) && !styleName.IsEmpty()) {
|
||||
name.AppendLiteral(" ");
|
||||
name.Append(styleName);
|
||||
aFullName = name;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
enum {
|
||||
#if defined(XP_MACOSX)
|
||||
CANONICAL_LANG_ID = gfxFontUtils::LANG_ID_MAC_ENGLISH,
|
||||
|
@ -706,10 +706,26 @@ public:
|
||||
DetermineFontDataType(const PRUint8 *aFontData, PRUint32 aFontDataLength);
|
||||
|
||||
// checks for valid SFNT table structure, returns true if valid
|
||||
// does *not* guarantee that all font data is valid
|
||||
// does *not* guarantee that all font data is valid, though it does
|
||||
// check that key tables such as 'name' are present and readable.
|
||||
// XXX to be removed if/when we eliminate the option to disable OTS,
|
||||
// which does more thorough validation.
|
||||
static PRBool
|
||||
ValidateSFNTHeaders(const PRUint8 *aFontData, PRUint32 aFontDataLength);
|
||||
|
||||
// Read the fullname from the sfnt data (used to save the original name
|
||||
// prior to renaming the font for installation).
|
||||
// This is called with sfnt data that has already been validated,
|
||||
// so it should always succeed in finding the name table.
|
||||
static nsresult
|
||||
GetFullNameFromSFNT(const PRUint8* aFontData, PRUint32 aLength,
|
||||
nsAString& aFullName);
|
||||
|
||||
// helper to get fullname from name table
|
||||
static nsresult
|
||||
GetFullNameFromTable(FallibleTArray<PRUint8>& aNameTable,
|
||||
nsAString& aFullName);
|
||||
|
||||
// create a new name table and build a new font with that name table
|
||||
// appended on the end, returns true on success
|
||||
static nsresult
|
||||
|
@ -866,6 +866,7 @@ gfxMacPlatformFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
||||
aProxyEntry->mItalic ?
|
||||
FONT_STYLE_ITALIC : FONT_STYLE_NORMAL,
|
||||
nsnull);
|
||||
newFontEntry->mIsUserFont = newFontEntry->mIsLocalUserFont = PR_TRUE;
|
||||
} else {
|
||||
newFontEntry =
|
||||
new MacOSFontEntry(aFontName, fontRef,
|
||||
|
@ -190,6 +190,15 @@ public:
|
||||
(cairo_font_face_get_user_data(aFace, &sFontEntryKey));
|
||||
}
|
||||
|
||||
// override the default impl in gfxFontEntry because we don't organize
|
||||
// gfxFcFontEntries in families; just read the name from fontconfig
|
||||
virtual nsString FamilyName() const;
|
||||
|
||||
// override the gfxFontEntry impl to read the name from fontconfig
|
||||
// instead of trying to get the 'name' table, as we don't implement
|
||||
// GetFontTable() here
|
||||
virtual nsString RealFaceName();
|
||||
|
||||
protected:
|
||||
gfxFcFontEntry(const nsAString& aName)
|
||||
: gfxFontEntry(aName),
|
||||
@ -208,6 +217,46 @@ protected:
|
||||
|
||||
cairo_user_data_key_t gfxFcFontEntry::sFontEntryKey;
|
||||
|
||||
nsString
|
||||
gfxFcFontEntry::FamilyName() const
|
||||
{
|
||||
if (mIsUserFont) {
|
||||
// for user fonts, we want the name of the family
|
||||
// as specified in the user font set
|
||||
return gfxFontEntry::FamilyName();
|
||||
}
|
||||
FcChar8 *familyname;
|
||||
if (!mPatterns.IsEmpty() &&
|
||||
FcPatternGetString(mPatterns[0],
|
||||
FC_FAMILY, 0, &familyname) == FcResultMatch) {
|
||||
return NS_ConvertUTF8toUTF16((const char*)familyname);
|
||||
}
|
||||
return gfxFontEntry::FamilyName();
|
||||
}
|
||||
|
||||
nsString
|
||||
gfxFcFontEntry::RealFaceName()
|
||||
{
|
||||
FcChar8 *name;
|
||||
if (!mPatterns.IsEmpty()) {
|
||||
if (FcPatternGetString(mPatterns[0],
|
||||
FC_FULLNAME, 0, &name) == FcResultMatch) {
|
||||
return NS_ConvertUTF8toUTF16((const char*)name);
|
||||
}
|
||||
if (FcPatternGetString(mPatterns[0],
|
||||
FC_FAMILY, 0, &name) == FcResultMatch) {
|
||||
NS_ConvertUTF8toUTF16 result((const char*)name);
|
||||
if (FcPatternGetString(mPatterns[0],
|
||||
FC_STYLE, 0, &name) == FcResultMatch) {
|
||||
result.AppendLiteral(" ");
|
||||
AppendUTF8toUTF16((const char*)name, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return gfxFontEntry::RealFaceName();
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxFcFontEntry::ShouldUseHarfBuzz(PRInt32 aRunScript) {
|
||||
if (mSkipHarfBuzz ||
|
||||
@ -1951,7 +2000,8 @@ gfxPangoFontGroup::GetFontSet(PangoLanguage *aLang)
|
||||
already_AddRefed<gfxFont>
|
||||
gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
PRInt32 aRunScript,
|
||||
gfxFont *aPrevMatchedFont)
|
||||
gfxFont *aPrevMatchedFont,
|
||||
PRUint8 *aMatchType)
|
||||
{
|
||||
if (aPrevMatchedFont) {
|
||||
PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh);
|
||||
@ -2015,6 +2065,7 @@ gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
if (!mStyle.systemFont && mPangoLanguage) {
|
||||
basePattern = fontSet->GetFontPatternAt(0);
|
||||
if (HasChar(basePattern, aCh)) {
|
||||
*aMatchType = gfxTextRange::kFontGroup;
|
||||
return nsRefPtr<gfxFont>(GetBaseFont()).forget();
|
||||
}
|
||||
|
||||
@ -2041,6 +2092,7 @@ gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
||||
}
|
||||
|
||||
if (HasChar(pattern, aCh)) {
|
||||
*aMatchType = gfxTextRange::kFontGroup;
|
||||
return nsRefPtr<gfxFont>(fontSet->GetFontAt(i)).forget();
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,8 @@ public:
|
||||
|
||||
virtual already_AddRefed<gfxFont>
|
||||
FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh, PRInt32 aRunScript,
|
||||
gfxFont *aPrevMatchedFont);
|
||||
gfxFont *aPrevMatchedFont,
|
||||
PRUint8 *aMatchType);
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
|
@ -569,7 +569,7 @@ MakeBlankTextRun(const void* aText, PRUint32 aLength,
|
||||
if (!textRun || !textRun->GetCharacterGlyphs())
|
||||
return nsnull;
|
||||
gfxFont *font = aFontGroup->GetFontAt(0);
|
||||
textRun->AddGlyphRun(font, 0);
|
||||
textRun->AddGlyphRun(font, gfxTextRange::kFontGroup, 0, PR_FALSE);
|
||||
#ifdef DEBUG
|
||||
textRun->mCachedWords = 0;
|
||||
textRun->mCacheGeneration = gTextRunWordCache ? gTextRunWordCache->mGeneration : 0;
|
||||
@ -603,7 +603,8 @@ TextRunWordCache::MakeTextRun(const PRUnichar *aText, PRUint32 aLength,
|
||||
#endif
|
||||
|
||||
gfxFont *font = aFontGroup->GetFontAt(0);
|
||||
nsresult rv = textRun->AddGlyphRun(font, 0);
|
||||
nsresult rv =
|
||||
textRun->AddGlyphRun(font, gfxTextRange::kFontGroup, 0, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsAutoTArray<PRUnichar,200> tempString;
|
||||
@ -746,7 +747,8 @@ TextRunWordCache::MakeTextRun(const PRUint8 *aText, PRUint32 aLength,
|
||||
#endif
|
||||
|
||||
gfxFont *font = aFontGroup->GetFontAt(0);
|
||||
nsresult rv = textRun->AddGlyphRun(font, 0);
|
||||
nsresult rv =
|
||||
textRun->AddGlyphRun(font, gfxTextRange::kFontGroup, 0, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsAutoTArray<PRUint8,200> tempString;
|
||||
|
@ -372,6 +372,74 @@ SanitizeOpenTypeData(const PRUint8* aData, PRUint32 aLength,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
StoreUserFontData(gfxFontEntry* aFontEntry, gfxProxyFontEntry* aProxy,
|
||||
const nsAString& aOriginalName,
|
||||
nsTArray<PRUint8>* aMetadata, PRUint32 aMetaOrigLen)
|
||||
{
|
||||
if (!aFontEntry->mUserFontData) {
|
||||
aFontEntry->mUserFontData = new gfxUserFontData;
|
||||
}
|
||||
gfxUserFontData* userFontData = aFontEntry->mUserFontData;
|
||||
userFontData->mSrcIndex = aProxy->mSrcIndex;
|
||||
const gfxFontFaceSrc& src = aProxy->mSrcList[aProxy->mSrcIndex];
|
||||
if (src.mIsLocal) {
|
||||
userFontData->mLocalName = src.mLocalName;
|
||||
} else {
|
||||
userFontData->mURI = src.mURI;
|
||||
}
|
||||
userFontData->mFormat = src.mFormatFlags;
|
||||
userFontData->mRealName = aOriginalName;
|
||||
if (aMetadata) {
|
||||
userFontData->mMetadata.SwapElements(*aMetadata);
|
||||
userFontData->mMetaOrigLen = aMetaOrigLen;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CopyWOFFMetadata(const PRUint8* aFontData, PRUint32 aLength,
|
||||
nsTArray<PRUint8>* aMetadata, PRUint32* aMetaOrigLen)
|
||||
{
|
||||
// This function may be called with arbitrary, unvalidated "font" data
|
||||
// from @font-face, so it needs to be careful to bounds-check, etc.,
|
||||
// before trying to read anything.
|
||||
// This just saves a copy of the compressed data block; it does NOT check
|
||||
// that the block can be successfully decompressed, or that it contains
|
||||
// well-formed/valid XML metadata.
|
||||
struct WOFFHeader {
|
||||
AutoSwap_PRUint32 signature;
|
||||
AutoSwap_PRUint32 flavor;
|
||||
AutoSwap_PRUint32 length;
|
||||
AutoSwap_PRUint16 numTables;
|
||||
AutoSwap_PRUint16 reserved;
|
||||
AutoSwap_PRUint32 totalSfntSize;
|
||||
AutoSwap_PRUint16 majorVersion;
|
||||
AutoSwap_PRUint16 minorVersion;
|
||||
AutoSwap_PRUint32 metaOffset;
|
||||
AutoSwap_PRUint32 metaCompLen;
|
||||
AutoSwap_PRUint32 metaOrigLen;
|
||||
AutoSwap_PRUint32 privOffset;
|
||||
AutoSwap_PRUint32 privLen;
|
||||
};
|
||||
if (aLength < sizeof(WOFFHeader)) {
|
||||
return;
|
||||
}
|
||||
const WOFFHeader* woff = reinterpret_cast<const WOFFHeader*>(aFontData);
|
||||
PRUint32 metaOffset = woff->metaOffset;
|
||||
PRUint32 metaCompLen = woff->metaCompLen;
|
||||
if (!metaOffset || !metaCompLen || !woff->metaOrigLen) {
|
||||
return;
|
||||
}
|
||||
if (metaOffset >= aLength || metaCompLen > aLength - metaOffset) {
|
||||
return;
|
||||
}
|
||||
if (!aMetadata->SetLength(woff->metaCompLen)) {
|
||||
return;
|
||||
}
|
||||
memcpy(aMetadata->Elements(), aFontData + metaOffset, metaCompLen);
|
||||
*aMetaOrigLen = woff->metaOrigLen;
|
||||
}
|
||||
|
||||
// This is called when a font download finishes.
|
||||
// Ownership of aFontData passes in here, and the font set must
|
||||
// ensure that it is eventually deleted via NS_Free().
|
||||
@ -384,14 +452,31 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
|
||||
if (NS_SUCCEEDED(aDownloadStatus)) {
|
||||
gfxFontEntry *fe = nsnull;
|
||||
|
||||
gfxUserFontType fontType =
|
||||
gfxFontUtils::DetermineFontDataType(aFontData, aLength);
|
||||
|
||||
// Save a copy of the metadata block (if present) for nsIDOMFontFace
|
||||
// to use if required. Ownership of the metadata block will be passed
|
||||
// to the gfxUserFontData record below.
|
||||
// NOTE: after the non-OTS codepath using PrepareOpenTypeData is
|
||||
// removed, we should defer this until after we've created the new
|
||||
// fontEntry.
|
||||
nsTArray<PRUint8> metadata;
|
||||
PRUint32 metaOrigLen = 0;
|
||||
if (fontType == GFX_USERFONT_WOFF) {
|
||||
CopyWOFFMetadata(aFontData, aLength, &metadata, &metaOrigLen);
|
||||
}
|
||||
|
||||
// Unwrap/decompress/sanitize or otherwise munge the downloaded data
|
||||
// to make a usable sfnt structure.
|
||||
|
||||
if (gfxPlatform::GetPlatform()->SanitizeDownloadedFonts()) {
|
||||
gfxUserFontType fontType =
|
||||
gfxFontUtils::DetermineFontDataType(aFontData, aLength);
|
||||
// Because platform font activation code may replace the name table
|
||||
// in the font with a synthetic one, we save the original name so that
|
||||
// it can be reported via the nsIDOMFontFace API.
|
||||
nsAutoString originalFullName;
|
||||
|
||||
// Call the OTS sanitizer; this will also decode WOFF to sfnt
|
||||
if (gfxPlatform::GetPlatform()->SanitizeDownloadedFonts()) {
|
||||
// Call the OTS sanitizer; this will also decode WOFF to sfnt
|
||||
// if necessary. The original data in aFontData is left unchanged.
|
||||
PRUint32 saneLen;
|
||||
const PRUint8* saneData =
|
||||
@ -406,6 +491,12 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
|
||||
}
|
||||
#endif
|
||||
if (saneData) {
|
||||
// The sanitizer ensures that we have a valid sfnt and a usable
|
||||
// name table, so this should never fail unless we're out of
|
||||
// memory, and GetFullNameFromSFNT is not directly exposed to
|
||||
// arbitrary/malicious data from the web.
|
||||
gfxFontUtils::GetFullNameFromSFNT(saneData, saneLen,
|
||||
originalFullName);
|
||||
// Here ownership of saneData is passed to the platform,
|
||||
// which will delete it when no longer required
|
||||
fe = gfxPlatform::GetPlatform()->MakePlatformFont(aProxy,
|
||||
@ -423,6 +514,10 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
|
||||
|
||||
if (aFontData) {
|
||||
if (gfxFontUtils::ValidateSFNTHeaders(aFontData, aLength)) {
|
||||
// ValidateSFNTHeaders has checked that we have a valid
|
||||
// sfnt structure and a usable 'name' table
|
||||
gfxFontUtils::GetFullNameFromSFNT(aFontData, aLength,
|
||||
originalFullName);
|
||||
// Here ownership of aFontData is passed to the platform,
|
||||
// which will delete it when no longer required
|
||||
fe = gfxPlatform::GetPlatform()->MakePlatformFont(aProxy,
|
||||
@ -447,7 +542,8 @@ gfxUserFontSet::OnLoadComplete(gfxProxyFontEntry *aProxy,
|
||||
// newly-created font entry
|
||||
fe->mFeatureSettings.AppendElements(aProxy->mFeatureSettings);
|
||||
fe->mLanguageOverride = aProxy->mLanguageOverride;
|
||||
|
||||
StoreUserFontData(fe, aProxy, originalFullName,
|
||||
&metadata, metaOrigLen);
|
||||
#ifdef PR_LOGGING
|
||||
// must do this before ReplaceFontEntry() because that will
|
||||
// clear the proxy's mFamily pointer!
|
||||
@ -539,6 +635,7 @@ gfxUserFontSet::LoadNext(gfxProxyFontEntry *aProxyEntry)
|
||||
PRUint32(mGeneration)));
|
||||
fe->mFeatureSettings.AppendElements(aProxyEntry->mFeatureSettings);
|
||||
fe->mLanguageOverride = aProxyEntry->mLanguageOverride;
|
||||
StoreUserFontData(fe, aProxyEntry, nsString(), nsnull, 0);
|
||||
ReplaceFontEntry(aProxyEntry, fe);
|
||||
return STATUS_LOADED;
|
||||
} else {
|
||||
|
@ -71,12 +71,26 @@ struct gfxFontFaceSrc {
|
||||
|
||||
};
|
||||
|
||||
// subclassed to store platform-specific code cleaned out when font entry is deleted
|
||||
// lifetime: from when platform font is created until it is deactivated
|
||||
// Subclassed to store platform-specific code cleaned out when font entry is
|
||||
// deleted.
|
||||
// Lifetime: from when platform font is created until it is deactivated.
|
||||
// If the platform does not need to add any platform-specific code/data here,
|
||||
// then the gfxUserFontSet will allocate a base gfxUserFontData and attach
|
||||
// to the entry to track the basic user font info fields here.
|
||||
class gfxUserFontData {
|
||||
public:
|
||||
gfxUserFontData() { }
|
||||
gfxUserFontData()
|
||||
: mSrcIndex(0), mFormat(0), mMetaOrigLen(0)
|
||||
{ }
|
||||
virtual ~gfxUserFontData() { }
|
||||
|
||||
nsTArray<PRUint8> mMetadata; // woff metadata block (compressed), if any
|
||||
nsCOMPtr<nsIURI> mURI; // URI of the source, if it was url()
|
||||
nsString mLocalName; // font name used for the source, if local()
|
||||
nsString mRealName; // original fullname from the font resource
|
||||
PRUint32 mSrcIndex; // index in the rule's source list
|
||||
PRUint32 mFormat; // format hint for the source used, if any
|
||||
PRUint32 mMetaOrigLen; // length needed to decompress metadata
|
||||
};
|
||||
|
||||
// initially contains a set of proxy font entry objects, replaced with
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "gfxDrawable.h"
|
||||
#include "nsRegion.h"
|
||||
|
||||
#if defined(XP_WIN) || defined(WINCE)
|
||||
#ifdef XP_WIN
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#endif
|
||||
|
||||
|
@ -168,12 +168,7 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
|
||||
GetWorldTransform(mDC, &mOldWorldTransform);
|
||||
SetWorldTransform(mDC, &mWorldTransform);
|
||||
}
|
||||
|
||||
#ifdef WINCE
|
||||
SetViewportOrgEx(mDC, 0, 0, &mOrigViewportOrigin);
|
||||
#else
|
||||
GetViewportOrgEx(mDC, &mOrigViewportOrigin);
|
||||
#endif
|
||||
SetViewportOrgEx(mDC,
|
||||
mOrigViewportOrigin.x + (int)mDeviceOffset.x,
|
||||
mOrigViewportOrigin.y + (int)mDeviceOffset.y,
|
||||
|
@ -59,23 +59,15 @@
|
||||
|
||||
#include "gfxCrashReporterUtils.h"
|
||||
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
#include "ft2build.h"
|
||||
#include FT_FREETYPE_H
|
||||
#include "gfxFT2Fonts.h"
|
||||
#include "gfxFT2FontList.h"
|
||||
#include "cairo-ft.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#else
|
||||
#include "gfxGDIFontList.h"
|
||||
#include "gfxGDIFont.h"
|
||||
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
#include "gfxDWriteFontList.h"
|
||||
#include "gfxDWriteFonts.h"
|
||||
#include "gfxDWriteCommon.h"
|
||||
#include <dwrite.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -168,10 +160,6 @@ public:
|
||||
NS_IMPL_ISUPPORTS1(D2DVRAMReporter, nsIMemoryReporter)
|
||||
#endif
|
||||
|
||||
#ifdef WINCE
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
#include "gfxUserFontSet.h"
|
||||
|
||||
#include <string>
|
||||
@ -186,10 +174,6 @@ NS_IMPL_ISUPPORTS1(D2DVRAMReporter, nsIMemoryReporter)
|
||||
#define GFX_CLEARTYPE_PARAMS_STRUCTURE "gfx.font_rendering.cleartype_params.pixel_structure"
|
||||
#define GFX_CLEARTYPE_PARAMS_MODE "gfx.font_rendering.cleartype_params.rendering_mode"
|
||||
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
static FT_Library gPlatformFTLibrary = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
// DirectWrite is not available on all platforms, we need to use the function
|
||||
// pointer.
|
||||
@ -236,10 +220,6 @@ gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
|
||||
mScreenDC = GetDC(NULL);
|
||||
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
FT_Init_FreeType(&gPlatformFTLibrary);
|
||||
#endif
|
||||
|
||||
#ifdef CAIRO_HAS_D2D_SURFACE
|
||||
NS_RegisterMemoryReporter(new D2DCacheReporter());
|
||||
NS_RegisterMemoryReporter(new D2DVRAMReporter());
|
||||
@ -453,9 +433,6 @@ gfxWindowsPlatform::CreatePlatformFontList()
|
||||
{
|
||||
mUsingGDIFonts = PR_FALSE;
|
||||
gfxPlatformFontList *pfl;
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
pfl = new gfxFT2FontList();
|
||||
#else
|
||||
#ifdef CAIRO_HAS_DWRITE_FONT
|
||||
if (AllowDirectWrite() && GetDWriteFactory()) {
|
||||
pfl = new gfxDWriteFontList();
|
||||
@ -471,7 +448,6 @@ gfxWindowsPlatform::CreatePlatformFontList()
|
||||
#endif
|
||||
pfl = new gfxGDIFontList();
|
||||
mUsingGDIFonts = PR_TRUE;
|
||||
#endif
|
||||
|
||||
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
||||
return pfl;
|
||||
@ -572,11 +548,7 @@ gfxWindowsPlatform::CreateFontGroup(const nsAString &aFamilies,
|
||||
const gfxFontStyle *aStyle,
|
||||
gfxUserFontSet *aUserFontSet)
|
||||
{
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
return new gfxFT2FontGroup(aFamilies, aStyle);
|
||||
#else
|
||||
return new gfxFontGroup(aFamilies, aStyle, aUserFontSet);
|
||||
#endif
|
||||
}
|
||||
|
||||
gfxFontEntry*
|
||||
@ -639,7 +611,6 @@ gfxWindowsPlatform::FindFontEntry(const nsAString& aName, const gfxFontStyle& aF
|
||||
qcms_profile*
|
||||
gfxWindowsPlatform::GetPlatformCMSOutputProfile()
|
||||
{
|
||||
#ifndef MOZ_FT2_FONTS
|
||||
WCHAR str[MAX_PATH];
|
||||
DWORD size = MAX_PATH;
|
||||
BOOL res;
|
||||
@ -670,9 +641,6 @@ gfxWindowsPlatform::GetPlatformCMSOutputProfile()
|
||||
NS_ConvertUTF16toUTF8(str).get());
|
||||
#endif
|
||||
return profile;
|
||||
#else
|
||||
return nsnull;
|
||||
#endif
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -687,14 +655,6 @@ gfxWindowsPlatform::SetPrefFontEntries(const nsCString& aKey, nsTArray<nsRefPtr<
|
||||
mPrefFonts.Put(aKey, array);
|
||||
}
|
||||
|
||||
#ifdef MOZ_FT2_FONTS
|
||||
FT_Library
|
||||
gfxWindowsPlatform::GetFTLibrary()
|
||||
{
|
||||
return gPlatformFTLibrary;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool
|
||||
gfxWindowsPlatform::UseClearTypeForDownloadableFonts()
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user