merge mozilla-central to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2013-12-12 16:09:30 +01:00
commit f924e8d961
591 changed files with 15584 additions and 7696 deletions

View File

@ -19,3 +19,8 @@
#
Bug 942231 needs a clobber -- JNI wrappers need to be re-generated.
and
Bug 934646 needs a clobber -- the icon resources previously copied
into $OBJDIR/mobile/android/base/res will conflict with those in
$BRANDING_DIRECTORY/res.

View File

@ -14,7 +14,6 @@
#include "States.h"
#include "nsContentList.h"
#include "nsCxPusher.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "nsIAccessibleRelation.h"
#include "nsIDOMNSEditableElement.h"
@ -26,6 +25,7 @@
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsITextControlFrame.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Preferences.h"
@ -468,8 +468,7 @@ HTMLTextFieldAccessible::GetEditor() const
// nsGenericHTMLElement::GetEditor has a security check.
// Make sure we're not restricted by the permissions of
// whatever script is currently running.
nsCxPusher pusher;
pusher.PushNull();
mozilla::dom::AutoSystemCaller asc;
nsCOMPtr<nsIEditor> editor;
editableElt->GetEditor(getter_AddRefs(editor));

View File

@ -1,4 +1,4 @@
{
"revision": "8a192fcf2927a866574996b4895426213e01a325",
"revision": "5bfef5faac50d14e055f642a44ed2df8483fb2fe",
"repo_path": "/integration/gaia-central"
}

View File

@ -57,7 +57,7 @@ MOZ_PLACES=
MOZ_B2G=1
if test "$OS_TARGET" = "Android"; then
MOZ_NUWA_PROCESS=0
MOZ_NUWA_PROCESS=
fi
MOZ_FOLD_LIBS=1

View File

@ -170,9 +170,7 @@ function addWindow(windowOptions, callback) {
let win = OpenBrowserWindow(windowOptions);
let onLoad = function() {
win.removeEventListener("load", onLoad, false);
whenDelayedStartupFinished(win, function() {
// Would like to get rid of this executeSoon, but without it the url
// (TEST_URI) provided in addTabWithToolbarRunTests hasn't loaded
executeSoon(function() {
@ -187,9 +185,7 @@ function addWindow(windowOptions, callback) {
deferred.reject(ex);
}
});
};
win.addEventListener("load", onLoad, false);
});
return deferred.promise;
}

View File

@ -10,6 +10,15 @@ let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
Services.scriptloader.loadSubScript(testDir + "/helpers.js", this);
Services.scriptloader.loadSubScript(testDir + "/mockCommands.js", this);
function whenDelayedStartupFinished(aWindow, aCallback) {
Services.obs.addObserver(function observer(aSubject, aTopic) {
if (aWindow == aSubject) {
Services.obs.removeObserver(observer, aTopic);
executeSoon(aCallback);
}
}, "browser-delayed-startup-finished", false);
}
/**
* Force GC on shutdown, because it seems that GCLI can outrun the garbage
* collector in some situations, which causes test failures in later tests

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
NO_PROFILE_GUIDED_OPTIMIZE = 1
include $(topsrcdir)/config/config.mk
DIST_PROGRAM = CommandExecuteHandler$(BIN_SUFFIX)

View File

@ -16,3 +16,5 @@ DIST_SUBDIR = ''
for var in ('UNICODE', '_UNICODE', 'NS_NO_XPCOM'):
DEFINES[var] = True
NO_PGO = True

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
NO_PROFILE_GUIDED_OPTIMIZE = 1
include $(topsrcdir)/config/config.mk
OS_LIBS = \

View File

@ -14,3 +14,5 @@ DIST_SUBDIR = 'metro/install'
for var in ('UNICODE', '_UNICODE'):
DEFINES[var] = True
NO_PGO = True

View File

@ -9,8 +9,6 @@ USE_STATIC_LIBS = 1
MOZ_GLUE_LDFLAGS =
MOZ_GLUE_PROGRAM_LDFLAGS =
NO_PROFILE_GUIDED_OPTIMIZE = 1
include $(topsrcdir)/config/config.mk
OS_LIBS = \

View File

@ -15,3 +15,5 @@ DIST_SUBDIR = ''
for var in ('UNICODE', '_UNICODE'):
DEFINES[var] = True
NO_PGO = True

View File

@ -64,7 +64,9 @@ def config_status(topobjdir='.', topsrcdir='.',
help='display verbose output')
parser.add_option('-n', dest='not_topobjdir', action='store_true',
help='do not consider current directory as top object directory')
(options, args) = parser.parse_args()
parser.add_option('-d', '--diff', action='store_true',
help='print diffs of changed files.')
options, args = parser.parse_args()
# Without -n, the current directory is meant to be the top object directory
if not options.not_topobjdir:
@ -98,3 +100,7 @@ def config_status(topobjdir='.', topsrcdir='.',
for line in summary.summaries():
print(line, file=sys.stderr)
if options.diff:
for path, diff in sorted(summary.file_diffs.items()):
print(diff)

View File

@ -1,20 +1,13 @@
==================================
Mozilla Build System Documentation
==================================
Overview
========
.. toctree::
:maxdepth: 1
glossary
============
Build System
============
Important Concepts
==================
.. toctree::
:maxdepth: 1
glossary
build-overview
supported-configurations
Mozconfig Files <mozconfigs>
@ -41,24 +34,3 @@ Mozilla build system.
mozbuild/index
mozbuild/dumbmake
Python Packages
===============
.. toctree::
:maxdepth: 2
python/codegen
python/makeutils
python/mozbuild
python/mozpack
python/mozversioncontrol
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -1,7 +0,0 @@
makeutils Module
================
.. automodule:: makeutils
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,35 +0,0 @@
action Package
==============
:mod:`link_deps` Module
-----------------------
.. automodule:: mozbuild.action.link_deps
:members:
:undoc-members:
:show-inheritance:
:mod:`process_install_manifest` Module
--------------------------------------
.. automodule:: mozbuild.action.process_install_manifest
:members:
:undoc-members:
:show-inheritance:
:mod:`xpccheck` Module
----------------------
.. automodule:: mozbuild.action.xpccheck
:members:
:undoc-members:
:show-inheritance:
:mod:`xpidl-process` Module
---------------------------
.. automodule:: mozbuild.action.xpidl-process
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,35 +0,0 @@
backend Package
===============
:mod:`base` Module
------------------
.. automodule:: mozbuild.backend.base
:members:
:undoc-members:
:show-inheritance:
:mod:`common` Module
--------------------
.. automodule:: mozbuild.backend.common
:members:
:undoc-members:
:show-inheritance:
:mod:`configenvironment` Module
-------------------------------
.. automodule:: mozbuild.backend.configenvironment
:members:
:undoc-members:
:show-inheritance:
:mod:`recursivemake` Module
---------------------------
.. automodule:: mozbuild.backend.recursivemake
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,11 +0,0 @@
compilation Package
===================
:mod:`warnings` Module
----------------------
.. automodule:: mozbuild.compilation.warnings
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,19 +0,0 @@
controller Package
==================
:mod:`building` Module
----------------------
.. automodule:: mozbuild.controller.building
:members:
:undoc-members:
:show-inheritance:
:mod:`clobber` Module
---------------------
.. automodule:: mozbuild.controller.clobber
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,51 +0,0 @@
frontend Package
================
:mod:`data` Module
------------------
.. automodule:: mozbuild.frontend.data
:members:
:undoc-members:
:show-inheritance:
:mod:`emitter` Module
---------------------
.. automodule:: mozbuild.frontend.emitter
:members:
:undoc-members:
:show-inheritance:
:mod:`mach_commands` Module
---------------------------
.. automodule:: mozbuild.frontend.mach_commands
:members:
:undoc-members:
:show-inheritance:
:mod:`reader` Module
--------------------
.. automodule:: mozbuild.frontend.reader
:members:
:undoc-members:
:show-inheritance:
:mod:`sandbox` Module
---------------------
.. automodule:: mozbuild.frontend.sandbox
:members:
:undoc-members:
:show-inheritance:
:mod:`sandbox_symbols` Module
-----------------------------
.. automodule:: mozbuild.frontend.sandbox_symbols
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,103 +0,0 @@
mozbuild Package
================
:mod:`base` Module
------------------
.. automodule:: mozbuild.base
:members:
:undoc-members:
:show-inheritance:
:mod:`config` Module
--------------------
.. automodule:: mozbuild.config
:members:
:undoc-members:
:show-inheritance:
:mod:`html_build_viewer` Module
-------------------------------
.. automodule:: mozbuild.html_build_viewer
:members:
:undoc-members:
:show-inheritance:
:mod:`mach_commands` Module
---------------------------
.. automodule:: mozbuild.mach_commands
:members:
:undoc-members:
:show-inheritance:
:mod:`makeutil` Module
----------------------
.. automodule:: mozbuild.makeutil
:members:
:undoc-members:
:show-inheritance:
:mod:`mozconfig` Module
-----------------------
.. automodule:: mozbuild.mozconfig
:members:
:undoc-members:
:show-inheritance:
:mod:`mozinfo` Module
---------------------
.. automodule:: mozbuild.mozinfo
:members:
:undoc-members:
:show-inheritance:
:mod:`pythonutil` Module
------------------------
.. automodule:: mozbuild.pythonutil
:members:
:undoc-members:
:show-inheritance:
:mod:`sphinx` Module
--------------------
.. automodule:: mozbuild.sphinx
:members:
:undoc-members:
:show-inheritance:
:mod:`util` Module
------------------
.. automodule:: mozbuild.util
:members:
:undoc-members:
:show-inheritance:
:mod:`virtualenv` Module
------------------------
.. automodule:: mozbuild.virtualenv
:members:
:undoc-members:
:show-inheritance:
Subpackages
-----------
.. toctree::
mozbuild.action
mozbuild.backend
mozbuild.compilation
mozbuild.controller
mozbuild.frontend
mozbuild.test

View File

@ -1,19 +0,0 @@
chrome Package
==============
:mod:`flags` Module
-------------------
.. automodule:: mozpack.chrome.flags
:members:
:undoc-members:
:show-inheritance:
:mod:`manifest` Module
----------------------
.. automodule:: mozpack.chrome.manifest
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,35 +0,0 @@
packager Package
================
:mod:`packager` Package
-----------------------
.. automodule:: mozpack.packager
:members:
:undoc-members:
:show-inheritance:
:mod:`formats` Module
---------------------
.. automodule:: mozpack.packager.formats
:members:
:undoc-members:
:show-inheritance:
:mod:`l10n` Module
------------------
.. automodule:: mozpack.packager.l10n
:members:
:undoc-members:
:show-inheritance:
:mod:`unpack` Module
--------------------
.. automodule:: mozpack.packager.unpack
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,76 +0,0 @@
mozpack Package
===============
:mod:`copier` Module
--------------------
.. automodule:: mozpack.copier
:members:
:undoc-members:
:show-inheritance:
:mod:`errors` Module
--------------------
.. automodule:: mozpack.errors
:members:
:undoc-members:
:show-inheritance:
:mod:`executables` Module
-------------------------
.. automodule:: mozpack.executables
:members:
:undoc-members:
:show-inheritance:
:mod:`files` Module
-------------------
.. automodule:: mozpack.files
:members:
:undoc-members:
:show-inheritance:
:mod:`manifests` Module
-----------------------
.. automodule:: mozpack.manifests
:members:
:undoc-members:
:show-inheritance:
:mod:`mozjar` Module
--------------------
.. automodule:: mozpack.mozjar
:members:
:undoc-members:
:show-inheritance:
:mod:`path` Module
------------------
.. automodule:: mozpack.path
:members:
:undoc-members:
:show-inheritance:
:mod:`unify` Module
-------------------
.. automodule:: mozpack.unify
:members:
:undoc-members:
:show-inheritance:
Subpackages
-----------
.. toctree::
mozpack.chrome
mozpack.packager
mozpack.test

View File

@ -1,11 +0,0 @@
mozversioncontrol Package
=========================
:mod:`repoupdate` Module
------------------------
.. automodule:: mozversioncontrol.repoupdate
:members:
:undoc-members:
:show-inheritance:

View File

@ -75,6 +75,7 @@ MACH_MODULES = [
'testing/xpcshell/mach_commands.py',
'testing/talos/mach_commands.py',
'testing/xpcshell/mach_commands.py',
'tools/docs/mach_commands.py',
'tools/mercurial/mach_commands.py',
'tools/mach_commands.py',
]

View File

@ -4,8 +4,4 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_RESFILES = [
'res/values/strings.xml',
]
DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']

View File

@ -3,11 +3,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_RESFILES = [
'res/drawable-hdpi/icon.png',
'res/drawable-ldpi/icon.png',
'res/drawable-mdpi/icon.png',
'res/layout/main.xml',
'res/values/strings.xml',
]

View File

@ -3,11 +3,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_RESFILES = [
'res/drawable-hdpi/icon.png',
'res/drawable-ldpi/icon.png',
'res/drawable-mdpi/icon.png',
'res/layout/main.xml',
'res/values/strings.xml',
]

View File

@ -3,13 +3,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_RESFILES = [
'res/drawable/ateamlogo.png',
'res/drawable/ic_stat_first.png',
'res/drawable/ic_stat_neterror.png',
'res/drawable/ic_stat_warning.png',
'res/drawable/icon.png',
'res/layout/main.xml',
'res/values/strings.xml',
]

View File

@ -3,14 +3,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
ANDROID_RESFILES = [
'res/drawable-hdpi/ateamlogo.png',
'res/drawable-hdpi/icon.png',
'res/drawable-ldpi/ateamlogo.png',
'res/drawable-ldpi/icon.png',
'res/drawable-mdpi/ateamlogo.png',
'res/drawable-mdpi/icon.png',
'res/layout/main.xml',
'res/values/strings.xml',
]

View File

@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SPHINX_TREES['build'] = 'docs'
if CONFIG['OS_ARCH'] not in ('WINNT', 'OS2'):
DIRS += ['unix']
elif CONFIG['OS_ARCH'] == 'WINNT':

View File

@ -5,8 +5,6 @@
INTERNAL_TOOLS = 1
NO_PROFILE_GUIDED_OPTIMIZE = 1
VPATH += $(topsrcdir)/build
OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions

View File

@ -4,7 +4,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
INTERNAL_TOOLS = 1
NO_PROFILE_GUIDED_OPTIMIZE = 1
include $(topsrcdir)/config/rules.mk

View File

@ -18,3 +18,5 @@ GENERATED_SOURCES += [
]
DEFINES['ELFHACK_BUILD'] = True
NO_PGO = True

View File

@ -25,3 +25,5 @@ HOST_SOURCES += [
HOST_PROGRAM = 'elfhack'
DEFINES['ELFHACK_BUILD'] = True
NO_PGO = True

View File

@ -4,7 +4,6 @@
STL_FLAGS =
NO_EXPAND_LIBS = 1
NO_PROFILE_GUIDED_OPTIMIZE = 1
include $(topsrcdir)/config/rules.mk

View File

@ -15,3 +15,5 @@ if CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']:
]
FORCE_STATIC_LIB = True
NO_PGO = True

View File

@ -13,6 +13,7 @@ mock.pth:python/mock-1.0.0
mozilla.pth:build
mozilla.pth:config
mozilla.pth:xpcom/typelib/xpt/tools
moztreedocs.pth:tools/docs
copy:build/buildconfig.py
packages.txt:testing/mozbase/packages.txt
objdir:build

View File

@ -2,8 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
NO_PROFILE_GUIDED_OPTIMIZE = 1
ifdef ENABLE_TESTS
USE_STATIC_LIBS = 1

View File

@ -14,3 +14,5 @@ if CONFIG['ENABLE_TESTS']:
SOURCES += [
'crashinject.cpp',
]
NO_PGO = True

View File

@ -35,7 +35,7 @@ endif
# responsibility between Makefile.in and mozbuild files.
_MOZBUILD_EXTERNAL_VARIABLES := \
ANDROID_GENERATED_RESFILES \
ANDROID_RESFILES \
ANDROID_RES_DIRS \
CMSRCS \
CMMSRCS \
CPP_UNIT_TESTS \
@ -70,6 +70,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \
$(NULL)
_DEPRECATED_VARIABLES := \
ANDROID_RESFILES \
MOCHITEST_FILES_PARTS \
MOCHITEST_BROWSER_FILES_PARTS \
SHORT_LIBNAME \

View File

@ -7,29 +7,6 @@
ifndef INCLUDED_JAVA_BUILD_MK #{
ifdef ANDROID_RESFILES #{
ifndef IGNORE_ANDROID_RESFILES #{
res-dep := .deps-copy-java-res
GENERATED_DIRS += res
GARBAGE += $(res-dep)
export:: $(res-dep)
res-dep-preqs := \
$(addprefix $(srcdir)/,$(ANDROID_RESFILES)) \
$(call mkdir_deps,res) \
$(if $(IS_LANGUAGE_REPACK),FORCE) \
$(NULL)
# nop-build: only copy res/ files when needed
$(res-dep): $(res-dep-preqs)
$(call copy_dir,$(srcdir)/res,$(CURDIR)/res)
@$(TOUCH) $@
endif #} IGNORE_ANDROID_RESFILES
endif #} ANDROID_RESFILES
ifdef JAVAFILES #{
GENERATED_DIRS += classes
@ -39,7 +16,8 @@ endif #} JAVAFILES
ifdef ANDROID_APK_NAME #{
_ANDROID_RES_FLAG := -S $(or $(ANDROID_RES_DIR),res)
android_res_dirs := $(addprefix $(srcdir)/,$(or $(ANDROID_RES_DIRS),res))
_ANDROID_RES_FLAG := $(addprefix -S ,$(android_res_dirs))
_ANDROID_ASSETS_FLAG := $(addprefix -A ,$(ANDROID_ASSETS_DIR))
GENERATED_DIRS += classes
@ -57,7 +35,11 @@ classes.dex: $(JAVAFILES)
R.java: .aapt.deps
$(ANDROID_APK_NAME).ap_: .aapt.deps
.aapt.deps: AndroidManifest.xml $(wildcard $(ANDROID_RES_DIR)) $(wildcard $(ANDROID_ASSETS_DIR))
# This uses the fact that Android resource directories list all
# resource files one subdirectory below the parent resource directory.
android_res_files := $(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(android_res_dirs)))))
.aapt.deps: AndroidManifest.xml $(android_res_files) $(wildcard $(ANDROID_ASSETS_DIR))
$(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \
-J ${@D} \
-F $(ANDROID_APK_NAME).ap_

View File

@ -642,7 +642,7 @@ tools::
endif
##############################################
ifndef NO_PROFILE_GUIDED_OPTIMIZE
ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE))
ifdef MOZ_PROFILE_USE
ifeq ($(OS_ARCH)_$(GNU_CC), WINNT_)
# When building with PGO, we have to make sure to re-link

View File

@ -1545,6 +1545,7 @@ public:
static JSContext *GetCurrentJSContext();
static JSContext *GetSafeJSContext();
static JSContext *GetCurrentJSContextForThread();
static JSContext *GetDefaultJSContextForThread();
/**

View File

@ -5262,6 +5262,17 @@ nsContentUtils::GetDefaultJSContextForThread()
}
}
/* static */
JSContext *
nsContentUtils::GetCurrentJSContextForThread()
{
if (MOZ_LIKELY(NS_IsMainThread())) {
return GetCurrentJSContext();
} else {
return workers::GetCurrentThreadJSContext();
}
}
/* static */
nsresult
nsContentUtils::ASCIIToLower(nsAString& aStr)

View File

@ -39,7 +39,6 @@
#include "nsIDOMNode.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsLayoutUtils.h"
#include "nsIContentPolicy.h"
#include "nsEventDispatcher.h"
@ -47,6 +46,7 @@
#include "mozAutoDocUpdate.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ScriptSettings.h"
#if defined(XP_WIN)
// Undefine LoadImage to prevent naming conflict with Windows.
@ -1194,12 +1194,6 @@ nsImageLoadingContent::ClearPendingRequest(nsresult aReason,
if (!mPendingRequest)
return;
// Push a null JSContext on the stack so that code that runs within
// the below code doesn't think it's being called by JS. See bug
// 604262.
nsCxPusher pusher;
pusher.PushNull();
// Deregister this image from the refresh driver so it no longer receives
// notifications.
nsLayoutUtils::DeregisterImageRequest(GetFramePresContext(), mPendingRequest,
@ -1259,11 +1253,6 @@ nsImageLoadingContent::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (!aDocument)
return;
// Push a null JSContext on the stack so that callbacks triggered by the
// below code won't think they're being called from JS.
nsCxPusher pusher;
pusher.PushNull();
TrackImage(mCurrentRequest);
TrackImage(mPendingRequest);
@ -1279,11 +1268,6 @@ nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
if (!doc)
return;
// Push a null JSContext on the stack so that callbacks triggered by the
// below code won't think they're being called from JS.
nsCxPusher pusher;
pusher.PushNull();
UntrackImage(mCurrentRequest);
UntrackImage(mPendingRequest);

View File

@ -14,10 +14,12 @@
#include "mozilla/dom/HTMLCanvasElement.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
using namespace dom;
using namespace gfx;
struct ImageCacheKey {
ImageCacheKey(Element* aImage, HTMLCanvasElement* aCanvas)
@ -32,7 +34,7 @@ struct ImageCacheEntryData {
, mILC(aOther.mILC)
, mCanvas(aOther.mCanvas)
, mRequest(aOther.mRequest)
, mSurface(aOther.mSurface)
, mSourceSurface(aOther.mSourceSurface)
, mSize(aOther.mSize)
{}
ImageCacheEntryData(const ImageCacheKey& aKey)
@ -51,7 +53,7 @@ struct ImageCacheEntryData {
nsRefPtr<HTMLCanvasElement> mCanvas;
// Value
nsCOMPtr<imgIRequest> mRequest;
nsRefPtr<gfxASurface> mSurface;
RefPtr<SourceSurface> mSourceSurface;
gfxIntSize mSize;
nsExpirationState mState;
};
@ -127,7 +129,7 @@ void
CanvasImageCache::NotifyDrawImage(Element* aImage,
HTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
SourceSurface* aSource,
const gfxIntSize& aSize)
{
if (!gImageCache) {
@ -137,7 +139,7 @@ CanvasImageCache::NotifyDrawImage(Element* aImage,
ImageCacheEntry* entry = gImageCache->mCache.PutEntry(ImageCacheKey(aImage, aCanvas));
if (entry) {
if (entry->mData->mSurface) {
if (entry->mData->mSourceSurface) {
// We are overwriting an existing entry.
gImageCache->mTotal -= entry->mData->SizeInBytes();
gImageCache->RemoveObject(entry->mData);
@ -150,7 +152,7 @@ CanvasImageCache::NotifyDrawImage(Element* aImage,
getter_AddRefs(entry->mData->mRequest));
}
entry->mData->mILC = ilc;
entry->mData->mSurface = aSurface;
entry->mData->mSourceSurface = aSource;
entry->mData->mSize = aSize;
gImageCache->mTotal += entry->mData->SizeInBytes();
@ -164,7 +166,7 @@ CanvasImageCache::NotifyDrawImage(Element* aImage,
gImageCache->AgeOneGeneration();
}
gfxASurface*
SourceSurface*
CanvasImageCache::Lookup(Element* aImage,
HTMLCanvasElement* aCanvas,
gfxIntSize* aSize)
@ -184,7 +186,7 @@ CanvasImageCache::Lookup(Element* aImage,
gImageCache->MarkUsed(entry->mData);
*aSize = entry->mData->mSize;
return entry->mData->mSurface;
return entry->mData->mSourceSurface;
}
NS_IMPL_ISUPPORTS1(CanvasImageCacheShutdownObserver, nsIObserver)

View File

@ -11,6 +11,9 @@ namespace dom {
class Element;
class HTMLCanvasElement;
} // namespace dom
namespace gfx {
class SourceSurface;
} // namespace gfx
} // namespace mozilla
class imgIRequest;
class gfxASurface;
@ -20,6 +23,7 @@ class gfxASurface;
namespace mozilla {
class CanvasImageCache {
typedef mozilla::gfx::SourceSurface SourceSurface;
public:
/**
* Notify that image element aImage was (or is about to be) drawn to aCanvas
@ -29,7 +33,7 @@ public:
static void NotifyDrawImage(dom::Element* aImage,
dom::HTMLCanvasElement* aCanvas,
imgIRequest* aRequest,
gfxASurface* aSurface,
SourceSurface* aSource,
const gfxIntSize& aSize);
/**
@ -38,9 +42,9 @@ public:
* (with the same image request) and the returned surface contains the image
* data, and the image size will be returned in aSize.
*/
static gfxASurface* Lookup(dom::Element* aImage,
dom::HTMLCanvasElement* aCanvas,
gfxIntSize* aSize);
static SourceSurface* Lookup(dom::Element* aImage,
dom::HTMLCanvasElement* aCanvas,
gfxIntSize* aSize);
};
}

View File

@ -1450,29 +1450,21 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e
htmlElement = &element.GetAsHTMLVideoElement();
}
EnsureTarget();
// The canvas spec says that createPattern should use the first frame
// of animated images
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(htmlElement,
nsLayoutUtils::SFE_WANT_FIRST_FRAME | nsLayoutUtils::SFE_WANT_NEW_SURFACE);
nsLayoutUtils::SFE_WANT_FIRST_FRAME, mTarget);
if (!res.mSurface) {
if (!res.mSourceSurface) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
// Ignore nullptr cairo surfaces! See bug 666312.
if (!res.mSurface->CairoSurface() || res.mSurface->CairoStatus()) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
EnsureTarget();
RefPtr<SourceSurface> srcSurf =
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, res.mSurface);
nsRefPtr<CanvasPattern> pat =
new CanvasPattern(this, srcSurf, repeatMode, res.mPrincipal,
new CanvasPattern(this, res.mSourceSurface, repeatMode, res.mPrincipal,
res.mIsWriteOnly, res.mCORSUsed);
return pat.forget();
@ -3084,11 +3076,8 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
element = video;
}
gfxASurface* imgsurf =
srcSurf =
CanvasImageCache::Lookup(element, mCanvasElement, &imgSize);
if (imgsurf) {
srcSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, imgsurf);
}
}
if (!srcSurf) {
@ -3096,9 +3085,9 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
// of animated images
uint32_t sfeFlags = nsLayoutUtils::SFE_WANT_FIRST_FRAME;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(element, sfeFlags);
nsLayoutUtils::SurfaceFromElement(element, sfeFlags, mTarget);
if (!res.mSurface) {
if (!res.mSourceSurface) {
// Spec says to silently do nothing if the element is still loading.
if (!res.mIsStillLoading) {
error.Throw(NS_ERROR_NOT_AVAILABLE);
@ -3106,11 +3095,6 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
return;
}
// Ignore cairo surfaces that are bad! See bug 666312.
if (res.mSurface->CairoStatus()) {
return;
}
imgSize = res.mSize;
// Scale sw/sh based on aspect ratio
@ -3129,11 +3113,11 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
}
if (res.mImageRequest) {
CanvasImageCache::NotifyDrawImage(element, mCanvasElement,
res.mImageRequest, res.mSurface, imgSize);
CanvasImageCache::NotifyDrawImage(element, mCanvasElement, res.mImageRequest,
res.mSourceSurface, imgSize);
}
srcSurf = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(mTarget, res.mSurface);
srcSurf = res.mSourceSurface;
}
if (optional_argc == 0) {

View File

@ -28,6 +28,7 @@
#include "mozilla/LinkedList.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Scoped.h"
#include "mozilla/gfx/2D.h"
#ifdef XP_MACOSX
#include "ForceDiscreteGPUHelperCGL.h"
@ -420,18 +421,19 @@ public:
{
if (IsContextLost())
return;
nsRefPtr<gfxImageSurface> isurf;
RefPtr<gfx::DataSourceSurface> data;
WebGLTexelFormat srcFormat;
nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(elt);
rv = SurfaceFromElementResultToImageSurface(res, getter_AddRefs(isurf),
rv = SurfaceFromElementResultToImageSurface(res, data,
&srcFormat);
if (rv.Failed() || !isurf)
if (rv.Failed() || !data)
return;
uint32_t byteLength = isurf->Stride() * isurf->Height();
gfx::IntSize size = data->GetSize();
uint32_t byteLength = data->Stride() * size.height;
return TexImage2D_base(target, level, internalformat,
isurf->Width(), isurf->Height(), isurf->Stride(),
0, format, type, isurf->Data(), byteLength,
size.width, size.height, data->Stride(),
0, format, type, data->GetData(), byteLength,
-1, srcFormat, mPixelStorePremultiplyAlpha);
}
void TexParameterf(GLenum target, GLenum pname, GLfloat param) {
@ -459,19 +461,20 @@ public:
{
if (IsContextLost())
return;
nsRefPtr<gfxImageSurface> isurf;
RefPtr<gfx::DataSourceSurface> data;
WebGLTexelFormat srcFormat;
nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(elt);
rv = SurfaceFromElementResultToImageSurface(res, getter_AddRefs(isurf),
rv = SurfaceFromElementResultToImageSurface(res, data,
&srcFormat);
if (rv.Failed() || !isurf)
if (rv.Failed() || !data)
return;
uint32_t byteLength = isurf->Stride() * isurf->Height();
gfx::IntSize size = data->GetSize();
uint32_t byteLength = data->Stride() * size.height;
return TexSubImage2D_base(target, level, xoffset, yoffset,
isurf->Width(), isurf->Height(),
isurf->Stride(), format, type,
isurf->Data(), byteLength,
size.width, size.height,
data->Stride(), format, type,
data->GetData(), byteLength,
-1, srcFormat, mPixelStorePremultiplyAlpha);
}
@ -992,7 +995,7 @@ protected:
nsLayoutUtils::SurfaceFromElementResult SurfaceFromElement(ElementType* aElement) {
MOZ_ASSERT(aElement);
uint32_t flags =
nsLayoutUtils::SFE_WANT_IMAGE_SURFACE;
nsLayoutUtils::SFE_WANT_IMAGE_SURFACE;
if (mPixelStoreColorspaceConversion == LOCAL_GL_NONE)
flags |= nsLayoutUtils::SFE_NO_COLORSPACE_CONVERSION;
@ -1007,7 +1010,7 @@ protected:
}
nsresult SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
gfxImageSurface **imageOut,
RefPtr<gfx::DataSourceSurface>& imageOut,
WebGLTexelFormat *format);
void CopyTexSubImage2D_base(GLenum target,

View File

@ -48,6 +48,7 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gl;
using namespace mozilla::gfx;
static bool BaseTypeAndSizeFromUniformType(GLenum uType, GLenum *baseType, GLint *unitSize);
static GLenum InternalFormatForFormatAndType(GLenum format, GLenum type, bool isGLES2);
@ -2640,14 +2641,14 @@ WebGLContext::StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum
nsresult
WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromElementResult& res,
gfxImageSurface **imageOut, WebGLTexelFormat *format)
RefPtr<DataSourceSurface>& imageOut, WebGLTexelFormat *format)
{
*imageOut = nullptr;
*format = WebGLTexelFormat::None;
if (!res.mSurface)
if (!res.mSourceSurface)
return NS_OK;
if (res.mSurface->GetType() != gfxSurfaceTypeImage) {
RefPtr<DataSourceSurface> data = res.mSourceSurface->GetDataSurface();
if (!data) {
// SurfaceFromElement lied!
return NS_OK;
}
@ -2687,22 +2688,17 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
// Notice that there is never a need to mark the WebGL canvas as write-only, since we reject write-only/cross-domain
// texture sources in the first place.
gfxImageSurface* surf = static_cast<gfxImageSurface*>(res.mSurface.get());
res.mSurface.forget();
*imageOut = surf;
switch (surf->Format()) {
case gfxImageFormatARGB32:
switch (data->GetFormat()) {
case FORMAT_B8G8R8A8:
*format = WebGLTexelFormat::BGRA8; // careful, our ARGB means BGRA
break;
case gfxImageFormatRGB24:
case FORMAT_B8G8R8X8:
*format = WebGLTexelFormat::BGRX8; // careful, our RGB24 is not tightly packed. Whence BGRX8.
break;
case gfxImageFormatA8:
case FORMAT_A8:
*format = WebGLTexelFormat::A8;
break;
case gfxImageFormatRGB16_565:
case FORMAT_R5G6B5:
*format = WebGLTexelFormat::RGB565;
break;
default:
@ -2710,6 +2706,8 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
return NS_ERROR_NOT_IMPLEMENTED;
}
imageOut = data;
return NS_OK;
}

View File

@ -9,6 +9,7 @@
#include "nsIDocument.h"
#include "prprf.h"
#include "nsGlobalWindow.h"
#include "ScriptSettings.h"
#include "mozilla/Likely.h"
using namespace mozilla;
@ -271,10 +272,10 @@ nsDOMEventTargetHelper::SetEventHandler(nsIAtom* aType,
const JS::Value& aValue)
{
nsRefPtr<EventHandlerNonNull> handler;
JSObject* callable;
JS::Rooted<JSObject*> callable(aCx);
if (aValue.isObject() &&
JS_ObjectIsCallable(aCx, callable = &aValue.toObject())) {
handler = new EventHandlerNonNull(callable);
handler = new EventHandlerNonNull(callable, mozilla::dom::GetIncumbentGlobal());
}
SetEventHandler(aType, EmptyString(), handler);
return NS_OK;

View File

@ -883,19 +883,23 @@ nsEventListenerManager::CompileEventHandlerInternal(nsListenerStruct *aListenerS
JS::Rooted<JSObject*> scope(cx, listener->GetEventScope());
context->BindCompiledEventHandler(mTarget, scope, handler, &boundHandler);
aListenerStruct = nullptr;
// Note - We pass null for aIncumbentGlobal below. We could also pass the
// compilation global, but since the handler is guaranteed to be scripted,
// there's no need to use an override, since the JS engine will always give
// us the right answer.
if (!boundHandler) {
listener->ForgetHandler();
} else if (listener->EventName() == nsGkAtoms::onerror && win) {
nsRefPtr<OnErrorEventHandlerNonNull> handlerCallback =
new OnErrorEventHandlerNonNull(boundHandler);
new OnErrorEventHandlerNonNull(boundHandler, /* aIncumbentGlobal = */ nullptr);
listener->SetHandler(handlerCallback);
} else if (listener->EventName() == nsGkAtoms::onbeforeunload && win) {
nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handlerCallback =
new OnBeforeUnloadEventHandlerNonNull(boundHandler);
new OnBeforeUnloadEventHandlerNonNull(boundHandler, /* aIncumbentGlobal = */ nullptr);
listener->SetHandler(handlerCallback);
} else {
nsRefPtr<EventHandlerNonNull> handlerCallback =
new EventHandlerNonNull(boundHandler);
new EventHandlerNonNull(boundHandler, /* aIncumbentGlobal = */ nullptr);
listener->SetHandler(handlerCallback);
}
}

View File

@ -2504,11 +2504,11 @@ void
nsEventStateManager::DoScrollZoom(nsIFrame *aTargetFrame,
int32_t adjustment)
{
// Exclude form controls and XUL content.
// Exclude form controls and content in chrome docshells.
nsIContent *content = aTargetFrame->GetContent();
if (content &&
!content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL) &&
!content->OwnerDoc()->IsXUL())
!nsContentUtils::IsInChromeDocshell(content->OwnerDoc()))
{
// positive adjustment to decrease zoom, negative to increase
int32_t change = (adjustment > 0) ? -1 : 1;

View File

@ -207,10 +207,6 @@ public:
virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
layers::ImageContainer* GetImageContainer();
// Called by the video frame to get the print surface, if this is
// a static document and we're not actually playing video
gfxASurface* GetPrintSurface() { return mPrintSurface; }
// Dispatch events
using nsGenericHTMLElement::DispatchEvent;
virtual nsresult DispatchEvent(const nsAString& aName) MOZ_FINAL MOZ_OVERRIDE;
@ -1013,8 +1009,6 @@ protected:
// non-intrinsic value.
bool mPreservesPitch;
nsRefPtr<gfxASurface> mPrintSurface;
// Reference to the source element last returned by GetNextSource().
// This is the child source element which we're trying to load from.
nsCOMPtr<nsIContent> mSourceLoadCandidate;

View File

@ -3223,11 +3223,6 @@ VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer()
if (mVideoFrameContainer)
return mVideoFrameContainer;
// If we have a print surface, this is just a static image so
// no image container is required
if (mPrintSurface)
return nullptr;
// Only video frames need an image container.
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
if (!video)
@ -3604,26 +3599,7 @@ HTMLMediaElement::CopyInnerTo(Element* aDest)
NS_ENSURE_SUCCESS(rv, rv);
if (aDest->OwnerDoc()->IsStaticDocument()) {
HTMLMediaElement* dest = static_cast<HTMLMediaElement*>(aDest);
if (mPrintSurface) {
dest->mPrintSurface = mPrintSurface;
dest->mMediaSize = mMediaSize;
} else {
nsIFrame* frame = GetPrimaryFrame();
Element* element;
if (frame && frame->GetType() == nsGkAtoms::HTMLVideoFrame &&
static_cast<nsVideoFrame*>(frame)->ShouldDisplayPoster()) {
nsIContent* content = static_cast<nsVideoFrame*>(frame)->GetPosterImage();
element = content ? content->AsElement() : nullptr;
} else {
element = const_cast<HTMLMediaElement*>(this);
}
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(element,
nsLayoutUtils::SFE_WANT_NEW_SURFACE);
dest->mPrintSurface = res.mSurface;
dest->mMediaSize = nsIntSize(res.mSize.width, res.mSize.height);
}
dest->mMediaSize = mMediaSize;
}
return rv;
}

View File

@ -38,11 +38,11 @@
#include "mozilla/Selection.h"
#include "nsEventListenerManager.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "mozilla/Preferences.h"
#include "nsTextNode.h"
#include "nsIController.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/ScriptSettings.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1283,13 +1283,12 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
// What follows is a bit of a hack. The editor uses the public DOM APIs
// for its content manipulations, and it causes it to fail some security
// checks deep inside when initializing. So we push a null JSContext
// on the JS stack here to make it clear that we're native code.
// checks deep inside when initializing. So we explictly make it clear that
// we're native code.
// Note that any script that's directly trying to access our value
// has to be going through some scriptable object to do that and that
// already does the relevant security checks.
nsCxPusher pusher;
pusher.PushNull();
AutoSystemCaller asc;
rv = newEditor->Init(domdoc, GetRootNode(), mSelCon, editorFlags);
NS_ENSURE_SUCCESS(rv, rv);
@ -1777,9 +1776,8 @@ nsTextEditorState::GetValue(nsAString& aValue, bool aIgnoreWrap) const
// XXXbz if we could just get the textContent of our anonymous content (eg
// if plaintext editor didn't create <br> nodes all over), we wouldn't need
// this.
{ /* Scope for context pusher */
nsCxPusher pusher;
pusher.PushNull();
{ /* Scope for AutoSystemCaller. */
AutoSystemCaller asc;
mEditor->OutputToString(NS_LITERAL_STRING("text/plain"), flags,
aValue);
@ -1857,9 +1855,8 @@ nsTextEditorState::SetValue(const nsAString& aValue, bool aUserInput,
// Time to mess with our security context... See comments in GetValue()
// for why this is needed. Note that we have to do this up here, because
// otherwise SelectAll() will fail.
{ /* Scope for context pusher */
nsCxPusher pusher;
pusher.PushNull();
{
AutoSystemCaller asc;
nsCOMPtr<nsISelection> domSel;
nsCOMPtr<nsISelectionPrivate> selPriv;

View File

@ -322,7 +322,7 @@ nsXBLPrototypeHandler::ExecuteHandler(EventTarget* aTarget,
}
nsRefPtr<EventHandlerNonNull> handlerCallback =
new EventHandlerNonNull(bound);
new EventHandlerNonNull(bound, /* aIncumbentGlobal = */ nullptr);
nsEventHandler eventHandler(handlerCallback);

View File

@ -46,11 +46,6 @@ ifeq ($(OS_ARCH),WINNT)
MODULE_OPTIMIZE_FLAGS = -O2
endif
# disable PGO for Sun Studio
ifdef SOLARIS_SUNPRO_CC
NO_PROFILE_GUIDED_OPTIMIZE = 1
endif
include $(topsrcdir)/config/rules.mk
# next line allows use of MOZ_OBJDIR in .mozconfig with older gcc on BeOS, maybe others

View File

@ -62,3 +62,7 @@ if CONFIG['OS_TARGET'] == 'Android':
if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['MOZ_MEMORY']:
DEFINES['HAVE_MALLOC_USABLE_SIZE'] = True
DEFINES['SQLITE_WITHOUT_MSIZE'] = True
# disable PGO for Sun Studio
if CONFIG['SOLARIS_SUNPRO_CC']:
NO_PGO = True

191
dom/base/ScriptSettings.cpp Normal file
View File

@ -0,0 +1,191 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim: ft=cpp tw=78 sw=2 et ts=2
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ThreadLocal.h"
#include "mozilla/Assertions.h"
#include "jsapi.h"
#include "xpcpublic.h"
#include "nsIGlobalObject.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsContentUtils.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
class ScriptSettingsStack;
static mozilla::ThreadLocal<ScriptSettingsStack*> sScriptSettingsTLS;
ScriptSettingsStackEntry ScriptSettingsStackEntry::SystemSingleton;
class ScriptSettingsStack {
public:
static ScriptSettingsStack& Ref() {
return *sScriptSettingsTLS.get();
}
ScriptSettingsStack() {};
void Push(ScriptSettingsStackEntry* aSettings) {
// The bottom-most entry must always be a candidate entry point.
MOZ_ASSERT_IF(mStack.Length() == 0 || mStack.LastElement()->IsSystemSingleton(),
aSettings->mIsCandidateEntryPoint);
mStack.AppendElement(aSettings);
}
void PushSystem() {
mStack.AppendElement(&ScriptSettingsStackEntry::SystemSingleton);
}
void Pop() {
MOZ_ASSERT(mStack.Length() > 0);
mStack.RemoveElementAt(mStack.Length() - 1);
}
nsIGlobalObject* Incumbent() {
if (!mStack.Length()) {
return nullptr;
}
return mStack.LastElement()->mGlobalObject;
}
nsIGlobalObject* EntryPoint() {
if (!mStack.Length())
return nullptr;
for (int i = mStack.Length() - 1; i >= 0; --i) {
if (mStack[i]->mIsCandidateEntryPoint) {
return mStack[i]->mGlobalObject;
}
}
MOZ_ASSUME_UNREACHABLE("Non-empty stack should always have an entry point");
}
private:
// These pointers are caller-owned.
nsTArray<ScriptSettingsStackEntry*> mStack;
};
void
InitScriptSettings()
{
if (!sScriptSettingsTLS.initialized()) {
bool success = sScriptSettingsTLS.init();
if (!success) {
MOZ_CRASH();
}
}
ScriptSettingsStack* ptr = new ScriptSettingsStack();
sScriptSettingsTLS.set(ptr);
}
void DestroyScriptSettings()
{
ScriptSettingsStack* ptr = sScriptSettingsTLS.get();
MOZ_ASSERT(ptr);
sScriptSettingsTLS.set(nullptr);
delete ptr;
}
// Note: When we're ready to expose it, GetEntryGlobal will look similar to
// GetIncumbentGlobal below.
nsIGlobalObject*
GetIncumbentGlobal()
{
// We need the current JSContext in order to check the JS for
// scripted frames that may have appeared since anyone last
// manipulated the stack. If it's null, that means that there
// must be no entry point on the stack, and therefore no incumbent
// global either.
JSContext *cx = nsContentUtils::GetCurrentJSContextForThread();
if (!cx) {
MOZ_ASSERT(ScriptSettingsStack::Ref().EntryPoint() == nullptr);
return nullptr;
}
// See what the JS engine has to say. If we've got a scripted caller
// override in place, the JS engine will lie to us and pretend that
// there's nothing on the JS stack, which will cause us to check the
// incumbent script stack below.
JS::RootedScript script(cx);
if (JS_DescribeScriptedCaller(cx, &script, nullptr)) {
JS::RootedObject global(cx, JS_GetGlobalFromScript(script));
MOZ_ASSERT(global);
return xpc::GetNativeForGlobal(global);
}
// Ok, nothing from the JS engine. Let's use whatever's on the
// explicit stack.
return ScriptSettingsStack::Ref().Incumbent();
}
AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
bool aIsMainThread,
JSContext* aCx)
: mStack(ScriptSettingsStack::Ref())
, mEntry(aGlobalObject, /* aCandidate = */ true)
{
MOZ_ASSERT(aGlobalObject);
if (!aCx) {
// If the caller didn't provide a cx, hunt one down. This isn't exactly
// fast, but the callers that care about performance can pass an explicit
// cx for now. Eventually, the whole cx pushing thing will go away
// entirely.
MOZ_ASSERT(aIsMainThread, "cx is mandatory off-main-thread");
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobalObject);
if (sgo && sgo->GetScriptContext()) {
aCx = sgo->GetScriptContext()->GetNativeContext();
}
if (!aCx) {
aCx = nsContentUtils::GetSafeJSContext();
}
}
if (aIsMainThread) {
mCxPusher.Push(aCx);
}
mAc.construct(aCx, aGlobalObject->GetGlobalJSObject());
mStack.Push(&mEntry);
}
AutoEntryScript::~AutoEntryScript()
{
MOZ_ASSERT(mStack.Incumbent() == mEntry.mGlobalObject);
mStack.Pop();
}
AutoIncumbentScript::AutoIncumbentScript(nsIGlobalObject* aGlobalObject)
: mStack(ScriptSettingsStack::Ref())
, mEntry(aGlobalObject, /* aCandidate = */ false)
, mCallerOverride(nsContentUtils::GetCurrentJSContextForThread())
{
mStack.Push(&mEntry);
}
AutoIncumbentScript::~AutoIncumbentScript()
{
MOZ_ASSERT(mStack.Incumbent() == mEntry.mGlobalObject);
mStack.Pop();
}
AutoSystemCaller::AutoSystemCaller(bool aIsMainThread)
: mStack(ScriptSettingsStack::Ref())
{
if (aIsMainThread) {
mCxPusher.PushNull();
}
mStack.PushSystem();
}
AutoSystemCaller::~AutoSystemCaller()
{
mStack.Pop();
}
} // namespace dom
} // namespace mozilla

115
dom/base/ScriptSettings.h Normal file
View File

@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim: ft=cpp tw=78 sw=2 et ts=2
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Utilities for managing the script settings object stack defined in webapps */
#ifndef mozilla_dom_ScriptSettings_h
#define mozilla_dom_ScriptSettings_h
#include "nsCxPusher.h"
#include "MainThreadUtils.h"
#include "nsIGlobalObject.h"
#include "mozilla/Maybe.h"
class nsIGlobalObject;
namespace mozilla {
namespace dom {
/*
* System-wide setup/teardown routines. Init and Destroy should be invoked
* once each, at startup and shutdown (respectively).
*/
void InitScriptSettings();
void DestroyScriptSettings();
// Note: We don't yet expose GetEntryGlobal, because in order for it to be
// correct, we first need to replace a bunch of explicit cx pushing in the
// browser with AutoEntryScript. But GetIncumbentGlobal is simpler, because it
// can mostly be inferred from the JS stack.
nsIGlobalObject* GetIncumbentGlobal();
class ScriptSettingsStack;
struct ScriptSettingsStackEntry {
nsCOMPtr<nsIGlobalObject> mGlobalObject;
bool mIsCandidateEntryPoint;
ScriptSettingsStackEntry(nsIGlobalObject *aGlobal, bool aCandidate)
: mGlobalObject(aGlobal)
, mIsCandidateEntryPoint(aCandidate)
{
MOZ_ASSERT(mGlobalObject);
MOZ_ASSERT(mGlobalObject->GetGlobalJSObject(),
"Must have an actual JS global for the duration on the stack");
MOZ_ASSERT(JS_IsGlobalObject(mGlobalObject->GetGlobalJSObject()),
"No outer windows allowed");
}
~ScriptSettingsStackEntry() {
// We must have an actual JS global for the entire time this is on the stack.
MOZ_ASSERT_IF(mGlobalObject, mGlobalObject->GetGlobalJSObject());
}
bool IsSystemSingleton() { return this == &SystemSingleton; }
static ScriptSettingsStackEntry SystemSingleton;
private:
ScriptSettingsStackEntry() : mGlobalObject(nullptr)
, mIsCandidateEntryPoint(true)
{}
};
/*
* A class that represents a new script entry point.
*/
class AutoEntryScript {
public:
AutoEntryScript(nsIGlobalObject* aGlobalObject,
bool aIsMainThread = NS_IsMainThread(),
// Note: aCx is mandatory off-main-thread.
JSContext* aCx = nullptr);
~AutoEntryScript();
private:
dom::ScriptSettingsStack& mStack;
dom::ScriptSettingsStackEntry mEntry;
nsCxPusher mCxPusher;
mozilla::Maybe<JSAutoCompartment> mAc; // This can de-Maybe-fy when mCxPusher
// goes away.
};
/*
* A class that can be used to force a particular incumbent script on the stack.
*/
class AutoIncumbentScript {
public:
AutoIncumbentScript(nsIGlobalObject* aGlobalObject);
~AutoIncumbentScript();
private:
dom::ScriptSettingsStack& mStack;
dom::ScriptSettingsStackEntry mEntry;
JS::AutoHideScriptedCaller mCallerOverride;
};
/*
* A class used for C++ to indicate that existing entry and incumbent scripts
* should not apply to anything in scope, and that callees should act as if
* they were invoked "from C++".
*/
class AutoSystemCaller {
public:
AutoSystemCaller(bool aIsMainThread = NS_IsMainThread());
~AutoSystemCaller();
private:
dom::ScriptSettingsStack& mStack;
nsCxPusher mCxPusher;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_ScriptSettings_h

View File

@ -59,6 +59,7 @@ EXPORTS.mozilla.dom += [
'MessagePortList.h',
'Navigator.h',
'ScreenOrientation.h',
'ScriptSettings.h',
'StructuredCloneTags.h',
'URL.h',
]
@ -94,6 +95,7 @@ UNIFIED_SOURCES += [
'nsWindowMemoryReporter.cpp',
'nsWindowRoot.cpp',
'nsWrapperCache.cpp',
'ScriptSettings.cpp',
'URL.cpp',
'WindowNamedPropertiesHandler.cpp',
]

View File

@ -93,6 +93,7 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::layers;
using namespace mozilla::widget;
using namespace mozilla::gfx;
class gfxContext;
@ -1385,8 +1386,8 @@ nsDOMWindowUtils::NodesFromRect(float aX, float aY,
aIgnoreRootScrollFrame, aFlushLayout, aReturn);
}
static already_AddRefed<gfxImageSurface>
CanvasToImageSurface(nsIDOMHTMLCanvasElement* aCanvas)
static TemporaryRef<DataSourceSurface>
CanvasToDataSourceSurface(nsIDOMHTMLCanvasElement* aCanvas)
{
nsCOMPtr<nsINode> node = do_QueryInterface(aCanvas);
if (!node) {
@ -1397,9 +1398,8 @@ CanvasToImageSurface(nsIDOMHTMLCanvasElement* aCanvas)
"An nsINode that implements nsIDOMHTMLCanvasElement should "
"be an element.");
nsLayoutUtils::SurfaceFromElementResult result =
nsLayoutUtils::SurfaceFromElement(node->AsElement(),
nsLayoutUtils::SFE_WANT_IMAGE_SURFACE);
return result.mSurface.forget().downcast<gfxImageSurface>();
nsLayoutUtils::SurfaceFromElement(node->AsElement());
return result.mSourceSurface->GetDataSurface();
}
NS_IMETHODIMP
@ -1417,8 +1417,8 @@ nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
retVal == nullptr)
return NS_ERROR_FAILURE;
nsRefPtr<gfxImageSurface> img1 = CanvasToImageSurface(aCanvas1);
nsRefPtr<gfxImageSurface> img2 = CanvasToImageSurface(aCanvas2);
RefPtr<DataSourceSurface> img1 = CanvasToDataSourceSurface(aCanvas1);
RefPtr<DataSourceSurface> img2 = CanvasToDataSourceSurface(aCanvas2);
if (img1 == nullptr || img2 == nullptr ||
img1->GetSize() != img2->GetSize() ||
@ -1426,12 +1426,12 @@ nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
return NS_ERROR_FAILURE;
int v;
gfxIntSize size = img1->GetSize();
IntSize size = img1->GetSize();
uint32_t stride = img1->Stride();
// we can optimize for the common all-pass case
if (stride == (uint32_t) size.width * 4) {
v = memcmp(img1->Data(), img2->Data(), size.width * size.height * 4);
v = memcmp(img1->GetData(), img2->GetData(), size.width * size.height * 4);
if (v == 0) {
if (aMaxDifference)
*aMaxDifference = 0;
@ -1444,8 +1444,8 @@ nsDOMWindowUtils::CompareCanvases(nsIDOMHTMLCanvasElement *aCanvas1,
uint32_t different = 0;
for (int j = 0; j < size.height; j++) {
unsigned char *p1 = img1->Data() + j*stride;
unsigned char *p2 = img2->Data() + j*stride;
unsigned char *p1 = img1->GetData() + j*stride;
unsigned char *p2 = img2->GetData() + j*stride;
v = memcmp(p1, p2, stride);
if (v) {

View File

@ -43,6 +43,7 @@
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsJSEnvironment.h"
#include "ScriptSettings.h"
#include "mozilla/Preferences.h"
#include "mozilla/Likely.h"
@ -209,6 +210,7 @@
#include "mozilla/dom/WindowBinding.h"
#include "nsITabChild.h"
#include "nsIDOMMediaQueryList.h"
#include "mozilla/dom/ScriptSettings.h"
#ifdef MOZ_WEBSPEECH
#include "mozilla/dom/SpeechSynthesis.h"
@ -4944,8 +4946,9 @@ nsGlobalWindow::RequestAnimationFrame(const JS::Value& aCallback,
return NS_ERROR_INVALID_ARG;
}
JS::Rooted<JSObject*> callbackObj(cx, &aCallback.toObject());
nsRefPtr<FrameRequestCallback> callback =
new FrameRequestCallback(&aCallback.toObject());
new FrameRequestCallback(callbackObj, GetIncumbentGlobal());
ErrorResult rv;
*aHandle = RequestAnimationFrame(*callback, rv);
@ -11211,18 +11214,18 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
aDialog, aNavigate, argv,
getter_AddRefs(domReturn));
} else {
// Push a null JSContext here so that the window watcher won't screw us
// Force a system caller here so that the window watcher won't screw us
// up. We do NOT want this case looking at the JS context on the stack
// when searching. Compare comments on
// nsIDOMWindow::OpenWindow and nsIWindowWatcher::OpenWindow.
// Note: Because nsWindowWatcher is so broken, it's actually important
// that we don't push a null cx here, because that screws it up when it
// tries to compute the caller principal to associate with dialog
// that we don't force a system caller here, because that screws it up
// when it tries to compute the caller principal to associate with dialog
// arguments. That whole setup just really needs to be rewritten. :-(
nsCxPusher pusher;
Maybe<AutoSystemCaller> asc;
if (!aContentModal) {
pusher.PushNull();
asc.construct();
}
@ -13229,10 +13232,10 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx, \
const JS::Value &v) { \
nsRefPtr<EventHandlerNonNull> handler; \
JSObject *callable; \
JS::Rooted<JSObject*> callable(cx); \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new EventHandlerNonNull(callable); \
handler = new EventHandlerNonNull(callable, GetIncumbentGlobal()); \
} \
SetOn##name_(handler); \
return NS_OK; \
@ -13259,10 +13262,10 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
} \
\
nsRefPtr<OnErrorEventHandlerNonNull> handler; \
JSObject *callable; \
JS::Rooted<JSObject*> callable(cx); \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new OnErrorEventHandlerNonNull(callable); \
handler = new OnErrorEventHandlerNonNull(callable, GetIncumbentGlobal()); \
} \
elm->SetEventHandler(handler); \
return NS_OK; \
@ -13290,10 +13293,10 @@ nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
} \
\
nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handler; \
JSObject *callable; \
JS::Rooted<JSObject*> callable(cx); \
if (v.isObject() && \
JS_ObjectIsCallable(cx, callable = &v.toObject())) { \
handler = new OnBeforeUnloadEventHandlerNonNull(callable); \
handler = new OnBeforeUnloadEventHandlerNonNull(callable, GetIncumbentGlobal()); \
} \
elm->SetEventHandler(handler); \
return NS_OK; \

View File

@ -360,7 +360,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
mozilla::HoldJSObjects(this);
mFunction = new Function(funobj);
mFunction = new Function(funobj, GetIncumbentGlobal());
// Create our arg array. argc is the number of arguments passed
// to setTimeout or setInterval; the first two are our callback

View File

@ -27,6 +27,7 @@
#include "nsPrintfCString.h"
#include "prprf.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/DOMError.h"
#include "mozilla/dom/DOMErrorBinding.h"
#include "mozilla/dom/HTMLObjectElement.h"
@ -2015,12 +2016,12 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
return nullptr;
}
// Make sure to have nothing on the JS context stack while creating and
// Make sure to divorce ourselves from the calling JS while creating and
// initializing the object, so exceptions from that will get reported
// properly, since those are never exceptions that a spec wants to be thrown.
{ // Scope for the nsCxPusher
nsCxPusher pusher;
pusher.PushNull();
{
AutoSystemCaller asc;
// Get the XPCOM component containing the JS implementation.
nsCOMPtr<nsISupports> implISupports = do_CreateInstance(aContractId);
if (!implISupports) {

View File

@ -25,8 +25,9 @@ namespace dom {
class CallbackFunction : public CallbackObject
{
public:
explicit CallbackFunction(JSObject* aCallable)
: CallbackObject(aCallable)
explicit CallbackFunction(JS::Handle<JSObject*> aCallable,
nsIGlobalObject* aIncumbentGlobal)
: CallbackObject(aCallable, aIncumbentGlobal)
{
MOZ_ASSERT(JS_ObjectIsCallable(nullptr, mCallback));
}

View File

@ -24,8 +24,9 @@ namespace dom {
class CallbackInterface : public CallbackObject
{
public:
explicit CallbackInterface(JSObject* aCallback)
: CallbackObject(aCallback)
explicit CallbackInterface(JS::Handle<JSObject*> aCallback,
nsIGlobalObject *aIncumbentGlobal)
: CallbackObject(aCallback, aIncumbentGlobal)
{
}

View File

@ -19,6 +19,7 @@
#include "xpcprivate.h"
#include "WorkerPrivate.h"
#include "nsGlobalWindow.h"
#include "WorkerScope.h"
namespace mozilla {
namespace dom {
@ -35,15 +36,17 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(CallbackObject)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CallbackObject)
tmp->DropCallback();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIncumbentGlobal)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CallbackObject)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIncumbentGlobal)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CallbackObject)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
ErrorResult& aRv,
ExceptionHandling aExceptionHandling,
JSCompartment* aCompartment)
@ -63,8 +66,9 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
// callable.
// First, find the real underlying callback.
JSObject* realCallback = js::UncheckedUnwrap(aCallback);
JSObject* realCallback = js::UncheckedUnwrap(aCallback->CallbackPreserveColor());
JSContext* cx = nullptr;
nsIGlobalObject* globalObject = nullptr;
if (mIsMainThread) {
// Now get the global and JSContext for this callback.
@ -85,18 +89,33 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
// This happens - Removing it causes
// test_bug293235.xul to go orange.
: nsContentUtils::GetSafeJSContext();
globalObject = win;
} else {
// No DOM Window. Use the SafeJSContext.
// No DOM Window. Store the global and use the SafeJSContext.
JSObject* glob = js::GetGlobalForObjectCrossCompartment(realCallback);
globalObject = xpc::GetNativeForGlobal(glob);
MOZ_ASSERT(globalObject);
cx = nsContentUtils::GetSafeJSContext();
}
// Make sure our JSContext is pushed on the stack.
mCxPusher.Push(cx);
} else {
cx = workers::GetCurrentThreadJSContext();
globalObject = workers::GetCurrentThreadWorkerPrivate()->GlobalScope();
}
// Unmark the callable, and stick it in a Rooted before it can go gray again.
// Bail out if there's no useful global. This seems to happen intermittently
// on gaia-ui tests, probably because nsInProcessTabChildGlobal is returning
// null in some kind of teardown state.
if (!globalObject->GetGlobalJSObject()) {
return;
}
mAutoEntryScript.construct(globalObject, mIsMainThread, cx);
if (aCallback->IncumbentGlobalOrNull()) {
mAutoIncumbentScript.construct(aCallback->IncumbentGlobalOrNull());
}
// Unmark the callable (by invoking Callback() and not the CallbackPreserveColor()
// variant), and stick it in a Rooted before it can go gray again.
// Nothing before us in this function can trigger a CC, so it's safe to wait
// until here it do the unmark. This allows us to order the following two
// operations _after_ the Push() above, which lets us take advantage of the
@ -104,15 +123,14 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
//
// We can do this even though we're not in the right compartment yet, because
// Rooted<> does not care about compartments.
JS::ExposeObjectToActiveJS(aCallback);
mRootedCallable.construct(cx, aCallback);
mRootedCallable.construct(cx, aCallback->Callback());
if (mIsMainThread) {
// Check that it's ok to run this callback at all.
// Make sure to unwrap aCallback before passing it in to get the global of
// the callback object, not the wrapper.
// Make sure to use realCallback to get the global of the callback object,
// not the wrapper.
bool allowed = nsContentUtils::GetSecurityManager()->
ScriptAllowed(js::GetGlobalForObjectCrossCompartment(js::UncheckedUnwrap(aCallback)));
ScriptAllowed(js::GetGlobalForObjectCrossCompartment(realCallback));
if (!allowed) {
return;
@ -120,7 +138,11 @@ CallbackObject::CallSetup::CallSetup(JS::Handle<JSObject*> aCallback,
}
// Enter the compartment of our callback, so we can actually work with it.
mAc.construct(cx, aCallback);
//
// Note that if the callback is a wrapper, this will not be the same
// compartment that we ended up in with mAutoEntryScript above, because the
// entry point is based off of the unwrapped callback (realCallback).
mAc.construct(cx, mRootedCallable.ref());
// And now we're ready to go.
mCx = cx;
@ -194,17 +216,11 @@ CallbackObject::CallSetup::~CallSetup()
// But be careful: it might not have been constructed at all!
mAc.destroyIfConstructed();
// XXXbz For that matter why do we need to manually call ScriptEvaluated at
// all? nsCxPusher::Pop will do that nowadays if !mScriptIsRunning, so the
// concerns from bug 295983 don't seem relevant anymore. Do we want to make
// sure it's still called when !mScriptIsRunning? I guess play it safe for
// now and do what CallEventHandler did, which is call always.
// Popping an nsCxPusher is safe even if it never got pushed.
mCxPusher.Pop();
mAutoIncumbentScript.destroyIfConstructed();
mAutoEntryScript.destroyIfConstructed();
// It is important that this is the last thing we do, after leaving the
// compartment and popping the context.
// compartment and undoing all our entry/incumbent script changes
if (mIsMainThread) {
nsContentUtils::LeaveMicroTask();
}

View File

@ -24,8 +24,8 @@
#include "mozilla/Assertions.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/HoldDropJSObjects.h"
#include "mozilla/dom/ScriptSettings.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsWrapperCache.h"
#include "nsJSEnvironment.h"
#include "xpcpublic.h"
@ -45,9 +45,13 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CallbackObject)
explicit CallbackObject(JSObject* aCallback)
// The caller may pass a global object which will act as an override for the
// incumbent script settings object when the callback is invoked (overriding
// the entry point computed from aCallback). If no override is required, the
// caller should pass null.
explicit CallbackObject(JS::Handle<JSObject*> aCallback, nsIGlobalObject *aIncumbentGlobal)
{
Init(aCallback);
Init(aCallback, aIncumbentGlobal);
}
virtual ~CallbackObject()
@ -76,6 +80,11 @@ public:
return JS::Handle<JSObject*>::fromMarkedLocation(mCallback.address());
}
nsIGlobalObject* IncumbentGlobalOrNull() const
{
return mIncumbentGlobal;
}
enum ExceptionHandling {
// Report any exception and don't throw it to the caller code.
eReportExceptions,
@ -90,17 +99,19 @@ public:
protected:
explicit CallbackObject(CallbackObject* aCallbackObject)
{
Init(aCallbackObject->mCallback);
Init(aCallbackObject->mCallback, aCallbackObject->mIncumbentGlobal);
}
private:
inline void Init(JSObject* aCallback)
inline void Init(JSObject* aCallback, nsIGlobalObject* aIncumbentGlobal)
{
MOZ_ASSERT(aCallback && !mCallback);
// Set mCallback before we hold, on the off chance that a GC could somehow
// happen in there... (which would be pretty odd, granted).
mCallback = aCallback;
mozilla::HoldJSObjects(this);
mIncumbentGlobal = aIncumbentGlobal;
}
CallbackObject(const CallbackObject&) MOZ_DELETE;
@ -116,6 +127,7 @@ protected:
}
JS::Heap<JSObject*> mCallback;
nsCOMPtr<nsIGlobalObject> mIncumbentGlobal;
class MOZ_STACK_CLASS CallSetup
{
@ -128,7 +140,7 @@ protected:
public:
// If aExceptionHandling == eRethrowContentExceptions then aCompartment
// needs to be set to the caller's compartment.
CallSetup(JS::Handle<JSObject*> aCallable, ErrorResult& aRv,
CallSetup(CallbackObject* aCallback, ErrorResult& aRv,
ExceptionHandling aExceptionHandling,
JSCompartment* aCompartment = nullptr);
~CallSetup();
@ -152,17 +164,17 @@ protected:
JSCompartment* mCompartment;
// And now members whose construction/destruction order we need to control.
nsCxPusher mCxPusher;
Maybe<AutoEntryScript> mAutoEntryScript;
Maybe<AutoIncumbentScript> mAutoIncumbentScript;
// Constructed the rooter within the scope of mCxPusher above, so that it's
// always within a request during its lifetime.
Maybe<JS::Rooted<JSObject*> > mRootedCallable;
// Can't construct a JSAutoCompartment without a JSContext either. Also,
// Put mAc after mCxPusher so that we exit the compartment before we pop the
// JSContext. Though in practice we'll often manually order those two
// things.
// Put mAc after mAutoEntryScript so that we exit the compartment before
// we pop the JSContext. Though in practice we'll often manually order
// those two things.
Maybe<JSAutoCompartment> mAc;
// An ErrorResult to possibly re-throw exceptions on and whether
@ -336,28 +348,7 @@ public:
nsRefPtr<WebIDLCallbackT> callback = GetWebIDLCallback();
return callback.forget();
}
XPCOMCallbackT* callback = GetXPCOMCallback();
if (!callback) {
return nullptr;
}
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(callback);
if (!wrappedJS) {
return nullptr;
}
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, wrappedJS->GetJSObject());
if (!obj) {
return nullptr;
}
JSAutoCompartment ac(cx, obj);
nsRefPtr<WebIDLCallbackT> newCallback = new WebIDLCallbackT(obj);
return newCallback.forget();
return nullptr;
}
private:

View File

@ -3396,7 +3396,10 @@ for (uint32_t i = 0; i < length; ++i) {
else:
declType = CGGeneric("OwningNonNull<%s>" % name)
conversion = (
"${declName} = new %s(&${val}.toObject());\n" % name)
"{ // Scope for tempRoot\n"
" JS::Rooted<JSObject*> tempRoot(cx, &${val}.toObject());\n"
" ${declName} = new %s(tempRoot, mozilla::dom::GetIncumbentGlobal());\n"
"}" % name)
template = wrapObjectTemplate(conversion, type,
"${declName} = nullptr",
@ -3729,7 +3732,10 @@ for (uint32_t i = 0; i < length; ++i) {
else:
declType = CGGeneric("OwningNonNull<%s>" % name)
conversion = (
" ${declName} = new %s(&${val}.toObject());\n" % name)
"{ // Scope for tempRoot\n"
" JS::Rooted<JSObject*> tempRoot(cx, &${val}.toObject());\n"
" ${declName} = new %s(tempRoot, mozilla::dom::GetIncumbentGlobal());\n"
"}\n" % name)
if allowTreatNonCallableAsNull and type.treatNonCallableAsNull():
haveCallable = "JS_ObjectIsCallable(cx, &${val}.toObject())"
@ -10549,7 +10555,7 @@ class CGJSImplClass(CGBindingImplClass):
decorators = "MOZ_FINAL"
destructor = None
baseConstructors=["mImpl(new %s(aJSImplObject))" % jsImplName(descriptor.name),
baseConstructors=["mImpl(new %s(aJSImplObject, /* aIncumbentGlobal = */ nullptr))" % jsImplName(descriptor.name),
"mParent(aParent)"]
parentInterface = descriptor.interface.parent
while parentInterface:
@ -10676,12 +10682,12 @@ class CGCallback(CGClass):
def getConstructors(self):
return [ClassConstructor(
[Argument("JSObject*", "aCallback")],
[Argument("JS::Handle<JSObject*>", "aCallback"), Argument("nsIGlobalObject*", "aIncumbentGlobal")],
bodyInHeader=True,
visibility="public",
explicit=True,
baseConstructors=[
"%s(aCallback)" % self.baseName
"%s(aCallback, aIncumbentGlobal)" % self.baseName,
])]
def getMethodImpls(self, method):
@ -10706,7 +10712,7 @@ class CGCallback(CGClass):
argsWithoutThis = list(args)
args.insert(0, Argument("const T&", "thisObj"))
setupCall = ("CallSetup s(CallbackPreserveColor(), aRv, aExceptionHandling);\n"
setupCall = ("CallSetup s(this, aRv, aExceptionHandling);\n"
"if (!s.GetContext()) {\n"
" aRv.Throw(NS_ERROR_UNEXPECTED);\n"
" return${errorReturn};\n"
@ -10996,7 +11002,7 @@ class CallbackMember(CGNativeMember):
if self.needThisHandling:
# It's been done for us already
return ""
callSetup = "CallSetup s(CallbackPreserveColor(), aRv"
callSetup = "CallSetup s(this, aRv"
if self.rethrowContentException:
# getArgs doesn't add the aExceptionHandling argument but does add
# aCompartment for us.

View File

@ -2531,6 +2531,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
@ -2595,10 +2596,20 @@ TabChildGlobal::GetJSContextForEventHandlers()
return nsContentUtils::GetSafeJSContext();
}
nsIPrincipal*
nsIPrincipal*
TabChildGlobal::GetPrincipal()
{
if (!mTabChild)
return nullptr;
return mTabChild->GetPrincipal();
}
JSObject*
TabChildGlobal::GetGlobalJSObject()
{
NS_ENSURE_TRUE(mTabChild, nullptr);
nsCOMPtr<nsIXPConnectJSObjectHolder> ref = mTabChild->GetGlobal();
NS_ENSURE_TRUE(ref, nullptr);
return ref->GetJSObject();
}

View File

@ -51,7 +51,8 @@ class ClonedMessageData;
class TabChildGlobal : public nsDOMEventTargetHelper,
public nsIContentFrameMessageManager,
public nsIScriptObjectPrincipal
public nsIScriptObjectPrincipal,
public nsIGlobalObject
{
public:
TabChildGlobal(TabChild* aTabChild);
@ -127,6 +128,7 @@ public:
virtual JSContext* GetJSContextForEventHandlers() MOZ_OVERRIDE;
virtual nsIPrincipal* GetPrincipal() MOZ_OVERRIDE;
virtual JSObject* GetGlobalJSObject() MOZ_OVERRIDE;
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
TabChild* mTabChild;

View File

@ -144,3 +144,14 @@ PEExpectedNoneOrURL=Expected 'none' or URL but found '%1$S'.
PEExpectedNoneOrURLOrFilterFunction=Expected 'none', URL, or filter function but found '%1$S'.
PEExpectedNonnegativeNP=Expected non-negative number or percentage.
PEFilterFunctionArgumentsParsingError=Error in parsing arguments for filter function.
PEVariableEOF=variable
PEVariableEmpty=Expected variable value but found '%1$S'.
PEValueWithVariablesParsingError=Error in parsing value for '%1$S' after substituting variables.
PEValueWithVariablesFallbackInherit=Falling back to 'inherit'.
PEValueWithVariablesFallbackInitial=Falling back to 'initial'.
PEInvalidVariableReference=Property contained reference to invalid variable.
PEInvalidVariableTokenFallback=Found invalid token '%1$S' at top level of variable reference fallback.
PEExpectedVariableNameEOF=identifier for variable name
PEExpectedVariableName=Expected identifier for variable name but found '%1$S'.
PEExpectedVariableFallback=Expected variable reference fallback after ','.
PEExpectedVariableCommaOrCloseParen=Expected ',' or ')' after variable name in variable reference but found '%1$S'.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']:
EXTRA_JS_MODULES = [
'gonk/mms_consts.js',
'gonk/MmsPduHelper.jsm',
'gonk/MobileMessageDB.jsm',
'gonk/wap_consts.js',
'gonk/WspPduHelper.jsm',
]

View File

@ -8,7 +8,7 @@ let Promise = Cu.import("resource://gre/modules/Promise.jsm").Promise;
/* Push required permissions and test if |navigator.mozMobileMessage| exists.
* Resolve if it does, reject otherwise.
*
* Forfill params:
* Fulfill params:
* manager -- an reference to navigator.mozMobileMessage.
*
* Reject params: (none)
@ -47,7 +47,7 @@ function ensureMobileMessage() {
/* Send a SMS message to a single receiver. Resolve if it succeeds, reject
* otherwise.
*
* Forfill params:
* Fulfill params:
* message -- the sent SmsMessage.
*
* Reject params:
@ -75,7 +75,7 @@ function sendSmsWithSuccess(aReceiver, aText) {
/* Send a MMS message with specified parameters. Resolve if it fails, reject
* otherwise.
*
* Forfill params:
* Fulfill params:
* message -- the failed MmsMessage
*
* Reject params: (none)
@ -102,7 +102,7 @@ function sendMmsWithFailure(aMmsParameters) {
/* Retrieve messages from database.
*
* Forfill params:
* Fulfill params:
* messages -- an array of {Sms,Mms}Message instances.
*
* Reject params:
@ -138,7 +138,7 @@ function getMessages(aFilter, aReverse) {
/* Retrieve all messages from database.
*
* Forfill params:
* Fulfill params:
* messages -- an array of {Sms,Mms}Message instances.
*
* Reject params:
@ -152,7 +152,7 @@ function getAllMessages() {
/* Retrieve all threads from database.
*
* Forfill params:
* Fulfill params:
* threads -- an array of MozMobileMessageThread instances.
*
* Reject params:
@ -181,7 +181,7 @@ function getAllThreads() {
/* Retrieve a single specified thread from database.
*
* Forfill params:
* Fulfill params:
* thread -- a MozMobileMessageThread instance.
*
* Reject params:
@ -206,7 +206,7 @@ function getThreadById(aThreadId) {
/* Delete messages specified from database.
*
* Forfill params:
* Fulfill params:
* result -- an array of boolean values indicating whether delesion was
* actually performed on the message record with corresponding id.
*
@ -236,7 +236,7 @@ function deleteMessagesById(aMessageIds) {
/* Delete messages specified from database.
*
* Forfill params:
* Fulfill params:
* result -- an array of boolean values indicating whether delesion was
* actually performed on the message record with corresponding id.
*
@ -254,7 +254,7 @@ function deleteMessages(aMessages) {
/* Delete all messages from database.
*
* Forfill params:
* Fulfill params:
* ids -- an array of numeric values identifying those deleted
* {Sms,Mms}Messages.
*
@ -275,7 +275,7 @@ let pendingEmulatorCmdCount = 0;
* end, so here comes with the pending counter. Resolve when the emulator
* gives positive response, and reject otherwise.
*
* Forfill params:
* Fulfill params:
* result -- an array of emulator response lines.
*
* Reject params:
@ -303,7 +303,7 @@ function runEmulatorCmdSafe(aCommand) {
/* Send simple text SMS to emulator.
*
* Forfill params:
* Fulfill params:
* result -- an array of emulator response lines.
*
* Reject params:
@ -318,7 +318,7 @@ function sendTextSmsToEmulator(aFrom, aText) {
/* Send raw SMS TPDU to emulator.
*
* Forfill params:
* Fulfill params:
* result -- an array of emulator response lines.
*
* Reject params:
@ -331,6 +331,62 @@ function sendRawSmsToEmulator(aPdu) {
return runEmulatorCmdSafe(command);
}
/* Name space for MobileMessageDB.jsm. Only initialized after first call to
* newMobileMessageDB.
*/
let MMDB;
// Create a new MobileMessageDB instance.
function newMobileMessageDB() {
if (!MMDB) {
MMDB = Cu.import("resource://gre/modules/MobileMessageDB.jsm", {});
is(typeof MMDB.MobileMessageDB, "function", "MMDB.MobileMessageDB");
}
let mmdb = new MMDB.MobileMessageDB();
ok(mmdb, "MobileMessageDB instance");
return mmdb;
}
/* Initialize a MobileMessageDB. Resolve if initialized with success, reject
* otherwise.
*
* Fulfill params: a MobileMessageDB instance.
* Reject params: a MobileMessageDB instance.
*
* @param aMmdb
* A MobileMessageDB instance.
* @param aDbName
* A string name for that database.
* @param aDbVersion
* The version that MobileMessageDB should upgrade to. 0 for the lastest
* version.
*
* @return A deferred promise.
*/
function initMobileMessageDB(aMmdb, aDbName, aDbVersion) {
let deferred = Promise.defer();
aMmdb.init(aDbName, aDbVersion, function(aError) {
if (aError) {
deferred.reject(aMmdb);
} else {
deferred.resolve(aMmdb);
}
});
return deferred.promise;
}
/* Close a MobileMessageDB.
*
* @return The passed MobileMessageDB instance.
*/
function closeMobileMessageDB(aMmdb) {
aMmdb.close();
return aMmdb;
}
/* Create a new array of id attribute of input messages.
*
* @param aMessages an array of {Sms,Mms}Message instances.
@ -345,6 +401,23 @@ function messagesToIds(aMessages) {
return ids;
}
// A reference to a nsIUUIDGenerator service.
let uuidGenerator;
/* Generate a new UUID.
*
* @return A UUID string.
*/
function newUUID() {
if (!uuidGenerator) {
uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
.getService(Ci.nsIUUIDGenerator);
ok(uuidGenerator, "uuidGenerator");
}
return uuidGenerator.generateUUID().toString();
}
/* Flush permission settings and call |finish()|.
*/
function cleanUp() {
@ -360,13 +433,20 @@ function cleanUp() {
});
}
function startTestCommon(aTestCaseMain) {
ensureMobileMessage()
.then(deleteAllMessages)
.then(aTestCaseMain)
.then(deleteAllMessages)
.then(cleanUp, function() {
ok(false, 'promise rejects during test.');
cleanUp();
});
function startTestBase(aTestCaseMain) {
Promise.resolve()
.then(aTestCaseMain)
.then(cleanUp, function() {
ok(false, 'promise rejects during test.');
cleanUp();
});
}
function startTestCommon(aTestCaseMain) {
startTestBase(function() {
return ensureMobileMessage()
.then(deleteAllMessages)
.then(aTestCaseMain)
.then(deleteAllMessages);
});
}

View File

@ -39,5 +39,6 @@ qemu = true
[test_smsc_address.js]
[test_dsds_default_service_id.js]
[test_thread_subject.js]
[test_mmdb_new.js]
[test_mmdb_setmessagedeliverybyid_sms.js]
[test_replace_short_message_type.js]

View File

@ -0,0 +1,34 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
startTestBase(function testCaseMain() {
log("Test init MobileMessageDB");
let mmdb = newMobileMessageDB();
let dbName = "test_mmdb_new";
let dbVersion = 0;
let check = function() {
is(mmdb.dbName, dbName, "dbName");
if (!dbVersion) {
ok(mmdb.dbVersion, "dbVersion");
dbVersion = mmdb.dbVersion;
} else {
is(mmdb.dbVersion, dbVersion, "dbVersion");
}
};
return initMobileMessageDB(mmdb, dbName, dbVersion)
.then(check)
.then(closeMobileMessageDB.bind(null, mmdb))
.then(check)
.then(function() {
log("Test re-init and close.");
return initMobileMessageDB(mmdb, dbName, dbVersion);
})
.then(check)
.then(closeMobileMessageDB.bind(null, mmdb))
.then(check);
});

View File

@ -50,33 +50,20 @@ anp_system_getApplicationDataDirectory()
return anp_system_getApplicationDataDirectory(nullptr);
}
jclass anp_system_loadJavaClass(NPP instance, const char* className)
jclass anp_system_loadJavaClass(NPP instance, const char* classNameStr)
{
LOG("%s", __PRETTY_FUNCTION__);
JNIEnv* env = GetJNIForThread();
if (!env)
return nullptr;
jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell");
jmethodID method = env->GetStaticMethodID(cls,
"loadPluginClass",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Class;");
// pass libname and classname, gotta create java strings
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
mozilla::PluginPRLibrary* lib = static_cast<mozilla::PluginPRLibrary*>(pinst->GetPlugin()->GetLibrary());
nsCString libName;
lib->GetLibraryPath(libName);
NS_ConvertUTF8toUTF16 className(classNameStr);
jstring jclassName = env->NewStringUTF(className);
jstring jlibName = env->NewStringUTF(libName.get());
jobject obj = env->CallStaticObjectMethod(cls, method, jclassName, jlibName);
env->DeleteLocalRef(jlibName);
env->DeleteLocalRef(jclassName);
env->DeleteLocalRef(cls);
return reinterpret_cast<jclass>(obj);
nsCString libNameUtf8;
lib->GetLibraryPath(libNameUtf8);
NS_ConvertUTF8toUTF16 libName(libNameUtf8);
return GeckoAppShell::LoadPluginClass(className, libName);
}
void anp_system_setPowerState(NPP instance, ANPPowerState powerState)

View File

@ -15,7 +15,6 @@
#include "nsServiceManagerUtils.h"
#include "nsContentUtils.h"
#include "nsContentPermissionHelper.h"
#include "nsCxPusher.h"
#include "nsIDocument.h"
#include "nsIObserverService.h"
#include "nsPIDOMWindow.h"
@ -295,10 +294,6 @@ PositionError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
void
PositionError::NotifyCallback(const GeoPositionErrorCallback& aCallback)
{
// Ensure that the proper context is on the stack (bug 452762)
nsCxPusher pusher;
pusher.PushNull();
nsAutoMicroTask mt;
if (aCallback.HasWebIDLCallback()) {
PositionErrorCallback* callback = aCallback.GetWebIDLCallback();
@ -530,9 +525,6 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
Shutdown();
}
// Ensure that the proper context is on the stack (bug 452762)
nsCxPusher pusher;
pusher.PushNull();
nsAutoMicroTask mt;
if (mCallback.HasWebIDLCallback()) {
ErrorResult err;

View File

@ -1,18 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
INSTALL_EXTENSION_ID = widgetutils@extensions.mozilla.org
DIST_FILES = install.rdf
USE_EXTENSION_MANIFEST = 1
XPI_PKGNAME = widgetutils-$(MOZ_APP_VERSION)
XULAPP_DEFINES = \
-DTHUNDERBIRD_VERSION=$(THUNDERBIRD_VERSION) \
-DEXTENSION_VERSION=$(MOZILLA_VERSION) \
$(NULL)
ifdef TARGET_XPCOM_ABI
XULAPP_DEFINES += -DEM_ABI=$(OS_TARGET)_$(TARGET_XPCOM_ABI)
endif

View File

@ -1,44 +0,0 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
#filter substitution
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>widgetutils@extensions.mozilla.org</em:id>
<em:version>@EXTENSION_VERSION@</em:version>
#ifdef EM_ABI
<em:targetPlatform>@EM_ABI@</em:targetPlatform>
#endif
<em:targetApplication>
<!-- Firefox -->
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>@FIREFOX_VERSION@</em:minVersion>
<em:maxVersion>@FIREFOX_VERSION@</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<!-- Thunderbird -->
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>@THUNDERBIRD_VERSION@</em:minVersion>
<em:maxVersion>@THUNDERBIRD_VERSION@</em:maxVersion>
</Description>
</em:targetApplication>
<!-- front-end metadata -->
<em:name>WidgetUtils service</em:name>
<em:description>Provide scrolling by mouse feature.</em:description>
<em:creator>mozilla.org</em:creator>
<em:contributor>Oleg Romashin &lt;romaxa@gmail.com&gt;</em:contributor>
<em:homepageURL>http://hg.mozilla.org</em:homepageURL>
</Description>
</RDF>

View File

@ -1,9 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['src']
XPI_NAME = 'widgetutils'

View File

@ -1,10 +0,0 @@
# vim:set ts=8 sw=8 sts=8 noet:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_DSO_LDOPTS = \
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)

View File

@ -1,20 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SOURCES += [
'nsWidgetUtils.cpp',
]
LIBRARY_NAME = 'widgetutils'
IS_COMPONENT = True
XPI_NAME = 'widgetutils'
if CONFIG['TARGET_XPCOM_ABI']:
FINAL_TARGET += '/platform/%(OS_TARGET)s_%(TARGET_XPCOM_ABI)s' % CONFIG
FORCE_SHARED_LIB = True

View File

@ -1,537 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsCURILoader.h"
#include "nsICategoryManager.h"
#include "nsIDOMDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindowCollection.h"
#include "nsIDocument.h"
#include "nsIGenericFactory.h"
#include "nsIObserver.h"
#include "nsIPresShell.h"
#include "nsIStyleSheetService.h"
#include "nsIWebProgress.h"
#include "nsIWebProgressListener.h"
#include "nsIWindowWatcher.h"
#include "nsNetUtil.h"
#include "nsRect.h"
#include "nsString.h"
#include "nsWeakReference.h"
#include "nsIWebBrowser.h"
#include "nsIObserverService.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMWindow.h"
#include "nsIDOMCompositionListener.h"
#include "nsIDOMTextListener.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMWheelEvent.h"
#include "nsView.h"
#include "nsViewManager.h"
#include "nsIContentPolicy.h"
#include "nsIDocShellTreeItem.h"
#include "nsIContent.h"
#include "nsITimer.h"
#include "mozilla/MouseEvents.h"
using namespace mozilla;
const int MIN_INT =((int) (1 << (sizeof(int) * 8 - 1)));
static int g_lastX=MIN_INT;
static int g_lastY=MIN_INT;
static int32_t g_panning = 0;
static bool g_is_scrollable = false;
#define EM_MULT 16.
#define NS_FRAME_HAS_RELATIVE_SIZE 0x01000000
#define NS_FRAME_HAS_OPTIMIZEDVIEW 0x02000000
#define BEHAVIOR_ACCEPT nsIPermissionManager::ALLOW_ACTION
#define BEHAVIOR_REJECT nsIPermissionManager::DENY_ACTION
#define BEHAVIOR_NOFOREIGN 3
#define NUMBER_OF_TYPES 13
// TODO auto reload nsWidgetUtils in C.
class nsWidgetUtils : public nsIObserver,
public nsIDOMEventListener,
public nsIContentPolicy,
public nsSupportsWeakReference
{
public:
nsWidgetUtils();
virtual ~nsWidgetUtils();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIOBSERVER
NS_DECL_NSICONTENTPOLICY
private:
nsresult Init(void);
void RemoveWindowListeners(nsIDOMWindow *aDOMWin);
EventTarget* GetChromeEventHandler(nsIDOMWindow *aDOMWin);
void AttachWindowListeners(nsIDOMWindow *aDOMWin);
bool IsXULNode(nsIDOMNode *aNode, uint32_t *aType = 0);
nsresult GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow * *aDOMWindow);
nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
nsresult MouseDown(nsIDOMEvent* aDOMEvent);
nsresult MouseUp(nsIDOMEvent* aDOMEvent);
nsresult MouseMove(nsIDOMEvent* aDOMEvent);
static void StopPanningCallback(nsITimer *timer, void *closure);
nsCOMPtr<nsIWidget> mWidget;
nsRefPtr<nsViewManager> mViewManager;
nsCOMPtr<nsITimer> mTimer;
};
nsWidgetUtils::nsWidgetUtils()
{
Init();
}
NS_IMETHODIMP
nsWidgetUtils::Init()
{
nsresult rv;
nsCOMPtr<nsIObserverService> obsSvc =
do_GetService("@mozilla.org/observer-service;1");
NS_ENSURE_STATE(obsSvc);
rv = obsSvc->AddObserver(this, "domwindowopened", false);
NS_ENSURE_SUCCESS(rv, rv);
rv = obsSvc->AddObserver(this, "domwindowclosed", false);
NS_ENSURE_SUCCESS(rv, rv);
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
}
nsresult
nsWidgetUtils::UpdateFromEvent(nsIDOMEvent *aDOMEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
if (!mouseEvent)
return NS_OK;
mouseEvent->GetScreenX(&g_lastX);
mouseEvent->GetScreenY(&g_lastY);
nsCOMPtr<nsIDOMWindow> mWindow;
nsCOMPtr<nsIDOMNode> mNode;
nsCOMPtr<nsIDOMNode> mOrigNode;
uint32_t type = 0;
nsDOMEvent* event = aDOMEvent->InternalDOMEvent();
bool isXul = false;
{
nsCOMPtr<EventTarget> eventOrigTarget = event->GetOriginalTarget();
if (eventOrigTarget)
mOrigNode = do_QueryInterface(eventOrigTarget);
isXul = IsXULNode(mOrigNode, &type);
}
if (isXul)
return NS_ERROR_FAILURE;
nsCOMPtr<EventTarget> eventTarget = event->GetTarget();
if (eventTarget)
mNode = do_QueryInterface(eventTarget);
if (!mNode)
return NS_OK;
GetDOMWindowByNode(mNode, getter_AddRefs(mWindow));
if (!mWindow)
return NS_OK;
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIDOMDocument> domDoc;
mWindow->GetDocument(getter_AddRefs(domDoc));
doc = do_QueryInterface(domDoc);
if (!doc) return NS_OK;
// the only case where there could be more shells in printpreview
nsIPresShell *shell = doc->GetShell();
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
mViewManager = shell->GetViewManager();
NS_ENSURE_TRUE(mViewManager, NS_ERROR_FAILURE);
mViewManager->GetRootWidget(getter_AddRefs(mWidget));
NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE);
return NS_OK;
}
nsresult
nsWidgetUtils::MouseDown(nsIDOMEvent* aDOMEvent)
{
g_is_scrollable = false;
// Return TRUE from your signal handler to mark the event as consumed.
if (NS_FAILED(UpdateFromEvent(aDOMEvent)))
return NS_OK;
g_is_scrollable = true;
if (g_is_scrollable) {
aDOMEvent->StopPropagation();
aDOMEvent->PreventDefault();
}
return NS_OK;
}
/* static */ void
nsWidgetUtils::StopPanningCallback(nsITimer *timer, void *closure)
{
g_panning = false;
}
nsresult
nsWidgetUtils::MouseUp(nsIDOMEvent* aDOMEvent)
{
nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
mouseEvent = do_QueryInterface(aDOMEvent);
if (!mouseEvent)
return NS_OK;
// Return TRUE from your signal handler to mark the event as consumed.
g_lastX = MIN_INT;
g_lastY = MIN_INT;
g_is_scrollable = false;
if (g_panning) {
aDOMEvent->StopPropagation();
aDOMEvent->PreventDefault();
nsresult rv;
if (mTimer) {
rv = mTimer->InitWithFuncCallback(nsWidgetUtils::StopPanningCallback,
nullptr, 500, nsITimer::TYPE_ONE_SHOT);
if (NS_SUCCEEDED(rv))
return NS_OK;
}
g_panning = false;
}
return NS_OK;
}
nsresult
nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
{
if (!g_is_scrollable) return NS_OK;
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
if (!mouseEvent)
return NS_OK;
int x, y;
((nsIDOMMouseEvent*)mouseEvent)->GetScreenX(&x);
((nsIDOMMouseEvent*)mouseEvent)->GetScreenY(&y);
int dx = g_lastX - x;
int dy = g_lastY - y;
if(g_lastX == MIN_INT || g_lastY == MIN_INT)
return NS_OK;
nsView* aView = mViewManager->GetRootView();
if (!aView)
if (NS_FAILED(UpdateFromEvent(aDOMEvent)))
return NS_OK;
nsEventStatus status;
WidgetWheelEvent wheelEvent(true, NS_WHEEL_WHEEL, mWidget);
wheelEvent.deltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE;
wheelEvent.deltaX = wheelEvent.lineOrPageDeltaX = dx;
wheelEvent.deltaY = wheelEvent.lineOrPageDeltaY = dy;
mViewManager->DispatchEvent(&wheelEvent, aView, &status);
if (status != nsEventStatus_eIgnore) {
if (dx > 5 || dy > 5) {
g_panning = true;
}
g_lastX = x;
g_lastY = y;
}
if (g_panning) {
aDOMEvent->StopPropagation();
aDOMEvent->PreventDefault();
}
return NS_OK;
}
// nsIContentPolicy Implementation
NS_IMETHODIMP
nsWidgetUtils::ShouldLoad(uint32_t aContentType,
nsIURI *aContentLocation,
nsIURI *aRequestingLocation,
nsISupports *aRequestingContext,
const nsACString &aMimeGuess,
nsISupports *aExtra,
int16_t *aDecision)
{
*aDecision = nsIContentPolicy::ACCEPT;
nsresult rv;
if (aContentType != nsIContentPolicy::TYPE_DOCUMENT)
return NS_OK;
// we can't do anything without this
if (!aContentLocation)
return NS_OK;
nsAutoCString scheme;
rv = aContentLocation->GetScheme(scheme);
nsAutoCString lscheme;
ToLowerCase(scheme, lscheme);
if (!lscheme.EqualsLiteral("ftp") &&
!lscheme.EqualsLiteral("http") &&
!lscheme.EqualsLiteral("https"))
return NS_OK;
if (g_panning > 0)
*aDecision = nsIContentPolicy::REJECT_REQUEST;
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::HandleEvent(nsIDOMEvent* aDOMEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
if (eventType.EqualsLiteral("mousedown")) {
return MouseDown(aEvent);
}
if (eventType.EqualsLiteral("mouseup")) {
return MouseUp(aEvent);
}
if (eventType.EqualsLiteral("mousemove")) {
return MouseMove(aEvent);
}
return NS_OK;
}
NS_IMETHODIMP
nsWidgetUtils::ShouldProcess(uint32_t aContentType,
nsIURI *aContentLocation,
nsIURI *aRequestingLocation,
nsISupports *aRequestingContext,
const nsACString &aMimeGuess,
nsISupports *aExtra,
int16_t *aDecision)
{
*aDecision = nsIContentPolicy::ACCEPT;
return NS_OK;
}
bool
nsWidgetUtils::IsXULNode(nsIDOMNode *aNode, uint32_t *aType)
{
bool retval = false;
if (!aNode) return retval;
nsString sorigNode;
aNode->GetNodeName(sorigNode);
if (sorigNode.EqualsLiteral("#document"))
return retval;
retval = StringBeginsWith(sorigNode, NS_LITERAL_STRING("xul:"));
if (!aType) return retval;
if (sorigNode.EqualsLiteral("xul:thumb")
|| sorigNode.EqualsLiteral("xul:vbox")
|| sorigNode.EqualsLiteral("xul:spacer"))
*aType = false; // Magic
else if (sorigNode.EqualsLiteral("xul:slider"))
*aType = 2; // Magic
else if (sorigNode.EqualsLiteral("xul:scrollbarbutton"))
*aType = 3; // Magic
return retval;
}
nsresult
nsWidgetUtils::GetDOMWindowByNode(nsIDOMNode* aNode, nsIDOMWindow** aDOMWindow)
{
nsCOMPtr<nsIDOMDocument> nodeDoc;
nsresult rv = aNode->GetOwnerDocument(getter_AddRefs(nodeDoc));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(nodeDoc, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMWindow> window;
rv = nodeDoc->GetDefaultView(getter_AddRefs(window));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
window.forget(aDOMWindow);
return rv;
}
EventTarget*
nsWidgetUtils::GetChromeEventHandler(nsIDOMWindow* aDOMWin)
{
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(aDOMWin);
return privateDOMWindow ? privateDOMWindow->GetChromeEventHandler() : nullptr;
}
void
nsWidgetUtils::RemoveWindowListeners(nsIDOMWindow *aDOMWin)
{
nsresult rv;
EventTarget* chromeEventHandler = GetChromeEventHandler(aDOMWin);
if (!chromeEventHandler) {
return;
}
// Use capturing, otherwise the normal find next will get activated when ours should
// Remove DOM Text listener for IME text events
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousedown"),
this, false);
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mouseup"),
this, false);
chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
this, false);
}
void
nsWidgetUtils::AttachWindowListeners(nsIDOMWindow *aDOMWin)
{
nsresult rv;
EventHandler* chromeEventHandler = GetChromeEventHandler(aDOMWin);
if (!chromeEventHandler) {
return;
}
// Use capturing, otherwise the normal find next will get activated when ours should
// Attach menu listeners, this will help us ignore keystrokes meant for menus
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousedown"), this,
false, false);
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mouseup"), this,
false, false);
chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousemove"), this,
false, false);
}
nsWidgetUtils::~nsWidgetUtils()
{
}
NS_IMPL_ISUPPORTS4(nsWidgetUtils,
nsIObserver,
nsIDOMEventListener,
nsIContentPolicy,
nsISupportsWeakReference)
NS_IMETHODIMP
nsWidgetUtils::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
nsresult rv;
if (!strcmp(aTopic,"domwindowopened"))
{
nsCOMPtr<nsIDOMWindow> chromeWindow = do_QueryInterface(aSubject);
if (chromeWindow)
AttachWindowListeners(chromeWindow);
return NS_OK;
}
if (!strcmp(aTopic,"domwindowclosed"))
{
nsCOMPtr<nsIDOMWindow> chromeWindow = do_QueryInterface(aSubject);
RemoveWindowListeners(chromeWindow);
return NS_OK;
}
return NS_OK;
}
//------------------------------------------------------------------------------
// XPCOM REGISTRATION BELOW
//------------------------------------------------------------------------------
#define WidgetUtils_CID \
{ 0x0ced17b6, 0x96ed, 0x4030, \
{0xa1, 0x34, 0x77, 0xcb, 0x66, 0x10, 0xa8, 0xf6} }
#define WidgetUtils_ContractID "@mozilla.org/extensions/widgetutils;1"
static NS_METHOD WidgetUtilsRegistration(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsICategoryManager> catman;
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
NS_GET_IID(nsICategoryManager),
getter_AddRefs(catman));
if (NS_FAILED(rv))
return rv;
char* previous = nullptr;
rv = catman->AddCategoryEntry("app-startup",
"WidgetUtils",
WidgetUtils_ContractID,
true,
true,
&previous);
if (previous)
nsMemory::Free(previous);
rv = catman->AddCategoryEntry("content-policy",
"WidgetUtils",
WidgetUtils_ContractID,
true,
true,
&previous);
if (previous)
nsMemory::Free(previous);
return rv;
}
static NS_METHOD WidgetUtilsUnregistration(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const nsModuleComponentInfo *info)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsICategoryManager> catman;
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
NS_GET_IID(nsICategoryManager),
getter_AddRefs(catman));
if (NS_FAILED(rv))
return rv;
rv = catman->DeleteCategoryEntry("app-startup",
"WidgetUtils",
true);
rv = catman->DeleteCategoryEntry("content-policy",
"WidgetUtils",
true);
return rv;
}
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWidgetUtils)
static const nsModuleComponentInfo components[] =
{
{ "nsWidgetUtilsService",
WidgetUtils_CID,
WidgetUtils_ContractID,
nsWidgetUtilsConstructor,
WidgetUtilsRegistration,
WidgetUtilsUnregistration
}
};
NS_IMPL_NSGETMODULE(nsWidgetUtilsModule, components)

View File

@ -764,27 +764,37 @@ void
DrawTargetD2D::ClearRect(const Rect &aRect)
{
MarkChanged();
PushClipRect(aRect);
FlushTransformToRT();
PopAllClips();
AutoSaveRestoreClippedOut restoreClippedOut(this);
restoreClippedOut.Save();
D2D1_RECT_F clipRect;
bool isPixelAligned;
bool pushedClip = false;
if (mTransform.IsRectilinear() &&
GetDeviceSpaceClipRect(clipRect, isPixelAligned)) {
if (mTransformDirty ||
!mTransform.IsIdentity()) {
mRT->SetTransform(D2D1::IdentityMatrix());
mTransformDirty = true;
}
bool needsClip = false;
needsClip = aRect.x > 0 || aRect.y > 0 ||
aRect.XMost() < mSize.width ||
aRect.YMost() < mSize.height;
if (needsClip) {
mRT->PushAxisAlignedClip(D2DRect(aRect), D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
mRT->PushAxisAlignedClip(clipRect, isPixelAligned ? D2D1_ANTIALIAS_MODE_ALIASED : D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
pushedClip = true;
} else {
FlushTransformToRT();
restoreClippedOut.Save();
}
mRT->Clear(D2D1::ColorF(0, 0.0f));
if (needsClip) {
if (pushedClip) {
mRT->PopAxisAlignedClip();
}
PopClip();
return;
}
@ -1773,9 +1783,40 @@ IntersectRect(const D2D1_RECT_F& aRect1, const D2D1_RECT_F& aRect2)
result.top = max(aRect1.top, aRect2.top);
result.right = min(aRect1.right, aRect2.right);
result.bottom = min(aRect1.bottom, aRect2.bottom);
result.right = max(result.right, result.left);
result.bottom = max(result.bottom, result.top);
return result;
}
bool
DrawTargetD2D::GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect, bool& aIsPixelAligned)
{
if (!mPushedClips.size()) {
return false;
}
std::vector<DrawTargetD2D::PushedClip>::iterator iter = mPushedClips.begin();
if (iter->mPath) {
return false;
}
aClipRect = iter->mBounds;
aIsPixelAligned = iter->mIsPixelAligned;
iter++;
for (;iter != mPushedClips.end(); iter++) {
if (iter->mPath) {
return false;
}
aClipRect = IntersectRect(aClipRect, iter->mBounds);
if (!iter->mIsPixelAligned) {
aIsPixelAligned = false;
}
}
return true;
}
TemporaryRef<ID2D1Geometry>
DrawTargetD2D::GetClippedGeometry(IntRect *aClipBounds)
{

View File

@ -205,6 +205,8 @@ private:
// bounds to correctly reflect the total clip. This is in device space.
TemporaryRef<ID2D1Geometry> GetClippedGeometry(IntRect *aClipBounds);
bool GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect, bool& aIsPixelAligned);
TemporaryRef<ID2D1Brush> CreateBrushForPattern(const Pattern &aPattern, Float aAlpha = 1.0f);
TemporaryRef<ID3D10Texture2D> CreateGradientTexture(const GradientStopsD2D *aStops);

View File

@ -8,6 +8,7 @@
#include "GLUploadHelpers.h"
#include "DecomposeIntoNoRepeatTriangles.h"
#include "GLContext.h"
#include "ScopedGLHelpers.h"
#include "nsRect.h"
#include "gfx2DGlue.h"
#include "gfxUtils.h"
@ -143,7 +144,8 @@ GLBlitTextureImageHelper::BlitTextureImage(TextureImage *aSrc, const nsIntRect&
}
}
TextureImage::ScopedBindTexture texBind(aSrc, LOCAL_GL_TEXTURE0);
ScopedBindTextureUnit autoTexUnit(mGL, LOCAL_GL_TEXTURE0);
ScopedBindTexture autoTex(mGL, aSrc->GetTextureID());
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);

View File

@ -1189,24 +1189,6 @@ GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
return false;
}
void GLContext::ApplyFilterToBoundTexture(GraphicsFilter aFilter)
{
ApplyFilterToBoundTexture(LOCAL_GL_TEXTURE_2D, aFilter);
}
void GLContext::ApplyFilterToBoundTexture(GLuint aTarget,
GraphicsFilter aFilter)
{
if (aFilter == GraphicsFilter::FILTER_NEAREST) {
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST);
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST);
} else {
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
fTexParameteri(aTarget, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
}
}
void
GLContext::DetermineCaps()
{

View File

@ -2482,25 +2482,6 @@ public:
*/
virtual bool ReleaseTexImage() { return false; }
/**
* Applies aFilter to the texture currently bound to GL_TEXTURE_2D.
*/
void ApplyFilterToBoundTexture(GraphicsFilter aFilter);
/**
* Applies aFilter to the texture currently bound to aTarget.
*/
void ApplyFilterToBoundTexture(GLuint aTarget,
GraphicsFilter aFilter);
virtual bool BindExternalBuffer(GLuint texture, void* buffer) { return false; }
virtual bool UnbindExternalBuffer(GLuint texture) { return false; }
#ifdef MOZ_WIDGET_GONK
virtual EGLImage CreateEGLImageForNativeBuffer(void* buffer) = 0;
virtual void DestroyEGLImage(EGLImage image) = 0;
#endif
// Before reads from offscreen texture
void GuaranteeResolve();

View File

@ -408,25 +408,6 @@ public:
return true;
}
#ifdef MOZ_WIDGET_GONK
EGLImage CreateEGLImageForNativeBuffer(void* buffer) MOZ_OVERRIDE
{
EGLint attrs[] = {
LOCAL_EGL_IMAGE_PRESERVED, LOCAL_EGL_TRUE,
LOCAL_EGL_NONE, LOCAL_EGL_NONE
};
return sEGLLibrary.fCreateImage(EGL_DISPLAY(),
EGL_NO_CONTEXT,
LOCAL_EGL_NATIVE_BUFFER_ANDROID,
buffer, attrs);
}
void DestroyEGLImage(EGLImage image) MOZ_OVERRIDE
{
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), image);
}
#endif
virtual void SetEGLSurfaceOverride(EGLSurface surf) MOZ_OVERRIDE {
if (Screen()) {
/* Blit `draw` to `read` if we need to, before we potentially juggle

View File

@ -58,7 +58,7 @@ GLXLibrary::SelectLibrary(const ContextFlags& aFlags)
}
// Check that we have at least version aMajor.aMinor .
bool
bool
GLXLibrary::GLXVersionCheck(int aMajor, int aMinor)
{
return aMajor < mGLXMajorVersion ||
@ -244,7 +244,7 @@ GLXLibrary::EnsureInitialized(LibType libType)
}
if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") &&
GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap,
GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap,
(GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
{
#ifdef MOZ_WIDGET_GTK
@ -278,7 +278,7 @@ GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
if (!EnsureInitialized(mLibType)) {
return false;
}
if (aSurface->GetType() != gfxSurfaceTypeXlib || !mUseTextureFromPixmap) {
return false;
}
@ -286,7 +286,7 @@ GLXLibrary::SupportsTextureFromPixmap(gfxASurface* aSurface)
return true;
}
GLXPixmap
GLXPixmap
GLXLibrary::CreatePixmap(gfxASurface* aSurface)
{
if (!SupportsTextureFromPixmap(aSurface)) {
@ -320,7 +320,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
attribs,
&numConfigs));
// Find an fbconfig that matches the pixel format used on the Pixmap.
// Find an fbconfig that matches the pixel format used on the Pixmap.
int matchIndex = -1;
unsigned long redMask =
static_cast<unsigned long>(direct.redMask) << direct.red;
@ -436,7 +436,7 @@ GLXLibrary::DestroyPixmap(GLXPixmap aPixmap)
void
GLXLibrary::BindTexImage(GLXPixmap aPixmap)
{
{
if (!mUseTextureFromPixmap) {
return;
}
@ -508,7 +508,7 @@ GLXLibrary::AfterGLXCall()
#define BEFORE_GLX_CALL do { \
sGLXLibrary[gCurrLib].BeforeGLXCall(); \
} while (0)
#define AFTER_GLX_CALL do { \
sGLXLibrary[gCurrLib].AfterGLXCall(); \
} while (0)
@ -519,8 +519,8 @@ GLXLibrary::AfterGLXCall()
#define AFTER_GLX_CALL do { } while(0)
#endif
void
void
GLXLibrary::xDestroyContext(Display* display, GLXContext context)
{
BEFORE_GLX_CALL;
@ -528,9 +528,9 @@ GLXLibrary::xDestroyContext(Display* display, GLXContext context)
AFTER_GLX_CALL;
}
Bool
GLXLibrary::xMakeCurrent(Display* display,
GLXDrawable drawable,
Bool
GLXLibrary::xMakeCurrent(Display* display,
GLXDrawable drawable,
GLXContext context)
{
BEFORE_GLX_CALL;
@ -539,7 +539,7 @@ GLXLibrary::xMakeCurrent(Display* display,
return result;
}
GLXContext
GLXContext
GLXLibrary::xGetCurrentContext()
{
BEFORE_GLX_CALL;
@ -548,7 +548,7 @@ GLXLibrary::xGetCurrentContext()
return result;
}
/* static */ void*
/* static */ void*
GLXLibrary::xGetProcAddress(const char *procName)
{
BEFORE_GLX_CALL;
@ -558,9 +558,9 @@ GLXLibrary::xGetProcAddress(const char *procName)
}
GLXFBConfig*
GLXLibrary::xChooseFBConfig(Display* display,
int screen,
const int *attrib_list,
GLXLibrary::xChooseFBConfig(Display* display,
int screen,
const int *attrib_list,
int *nelements)
{
BEFORE_GLX_CALL;
@ -569,9 +569,9 @@ GLXLibrary::xChooseFBConfig(Display* display,
return result;
}
GLXFBConfig*
GLXLibrary::xGetFBConfigs(Display* display,
int screen,
GLXFBConfig*
GLXLibrary::xGetFBConfigs(Display* display,
int screen,
int *nelements)
{
BEFORE_GLX_CALL;
@ -579,16 +579,16 @@ GLXLibrary::xGetFBConfigs(Display* display,
AFTER_GLX_CALL;
return result;
}
GLXContext
GLXLibrary::xCreateNewContext(Display* display,
GLXFBConfig config,
int render_type,
GLXContext share_list,
GLXLibrary::xCreateNewContext(Display* display,
GLXFBConfig config,
int render_type,
GLXContext share_list,
Bool direct)
{
BEFORE_GLX_CALL;
GLXContext result = xCreateNewContextInternal(display, config,
GLXContext result = xCreateNewContextInternal(display, config,
render_type,
share_list, direct);
AFTER_GLX_CALL;
@ -647,7 +647,7 @@ GLXLibrary::xQueryServerString(Display *display,
}
GLXPixmap
GLXLibrary::xCreatePixmap(Display *display,
GLXLibrary::xCreatePixmap(Display *display,
GLXFBConfig config,
Pixmap pixmap,
const int *attrib_list)
@ -710,7 +710,7 @@ GLXLibrary::xReleaseTexImage(Display *display,
AFTER_GLX_CALL;
}
void
void
GLXLibrary::xWaitGL()
{
BEFORE_GLX_CALL;
@ -727,16 +727,16 @@ GLXLibrary::xWaitX()
}
GLXContext
GLXLibrary::xCreateContextAttribs(Display* display,
GLXFBConfig config,
GLXContext share_list,
GLXLibrary::xCreateContextAttribs(Display* display,
GLXFBConfig config,
GLXContext share_list,
Bool direct,
const int* attrib_list)
{
BEFORE_GLX_CALL;
GLXContext result = xCreateContextAttribsInternal(display,
config,
share_list,
GLXContext result = xCreateContextAttribsInternal(display,
config,
share_list,
direct,
attrib_list);
AFTER_GLX_CALL;
@ -905,7 +905,7 @@ TRY_AGAIN_NO_SHARING:
switch(aType) {
case NativeGLContext:
return mContext;
case NativeThebesSurface:
return mPixmap;
@ -1012,13 +1012,13 @@ GLContextProviderGLX::CreateForWindow(nsIWidget *aWidget)
// performance might be suboptimal. But using the existing visual
// is a relatively safe intermediate step.
Display *display = (Display*)aWidget->GetNativeData(NS_NATIVE_DISPLAY);
Display *display = (Display*)aWidget->GetNativeData(NS_NATIVE_DISPLAY);
int xscreen = DefaultScreen(display);
Window window = GET_NATIVE_WINDOW(aWidget);
int numConfigs;
ScopedXFree<GLXFBConfig> cfgs;
if (sDefGLXLib.IsATI() ||
if (sDefGLXLib.IsATI() ||
!sDefGLXLib.GLXVersionCheck(1, 3)) {
const int attribs[] = {
LOCAL_GLX_DOUBLEBUFFER, False,

View File

@ -205,13 +205,6 @@ BasicTextureImage::BindTexture(GLenum aTextureUnit)
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE0);
}
void
BasicTextureImage::ApplyFilter()
{
mGLContext->ApplyFilterToBoundTexture(mFilter);
}
already_AddRefed<gfxASurface>
BasicTextureImage::GetSurfaceForUpdate(const gfxIntSize& aSize, ImageFormat aFmt)
{
@ -637,12 +630,6 @@ TiledTextureImage::BindTexture(GLenum aTextureUnit)
mImages[mCurrentImage]->BindTexture(aTextureUnit);
}
void
TiledTextureImage::ApplyFilter()
{
mGL->ApplyFilterToBoundTexture(mFilter);
}
/*
* Resize, trying to reuse tiles. The reuse strategy is to decide on reuse per
* column. A tile on a column is reused if it hasn't changed size, otherwise it
@ -745,16 +732,6 @@ uint32_t TiledTextureImage::GetTileCount()
return mImages.Length();
}
TextureImage::ScopedBindTexture::ScopedBindTexture(TextureImage* aTexture,
GLenum aTextureUnit)
: mTexture(aTexture)
{
if (mTexture) {
MOZ_ASSERT(aTextureUnit >= LOCAL_GL_TEXTURE0);
mTexture->BindTexture(aTextureUnit);
}
}
already_AddRefed<TextureImage>
CreateBasicTextureImage(GLContext* aGL,
const nsIntSize& aSize,

View File

@ -185,41 +185,6 @@ public:
const gfx::IntPoint* aSrcOffset = nullptr);
virtual void BindTexture(GLenum aTextureUnit) = 0;
virtual void ReleaseTexture() {}
void BindTextureAndApplyFilter(GLenum aTextureUnit) {
BindTexture(aTextureUnit);
ApplyFilter();
}
class ScopedBindTexture
{
public:
ScopedBindTexture(TextureImage *aTexture, GLenum aTextureUnit);
~ScopedBindTexture()
{
if (mTexture) {
mTexture->ReleaseTexture();
}
}
protected:
TextureImage *mTexture;
};
class ScopedBindTextureAndApplyFilter
: public ScopedBindTexture
{
public:
ScopedBindTextureAndApplyFilter(TextureImage *aTexture, GLenum aTextureUnit) :
ScopedBindTexture(aTexture, aTextureUnit)
{
if (mTexture) {
mTexture->ApplyFilter();
}
}
};
/**
* Returns the image format of the texture. Only valid after a matching
@ -247,12 +212,6 @@ public:
void SetFilter(GraphicsFilter aFilter) { mFilter = aFilter; }
/**
* Applies this TextureImage's filter, assuming that its texture is
* the currently bound texture.
*/
virtual void ApplyFilter() = 0;
protected:
friend class GLContext;
@ -345,9 +304,7 @@ public:
virtual void Resize(const nsIntSize& aSize);
virtual void ApplyFilter();
protected:
GLuint mTexture;
TextureState mTextureState;
nsRefPtr<GLContext> mGLContext;
@ -390,7 +347,6 @@ public:
virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom = nsIntPoint(0,0));
virtual bool InUpdate() const { return mInUpdate; }
virtual void BindTexture(GLenum);
virtual void ApplyFilter();
protected:
virtual gfx::IntRect GetSrcTileRect();

View File

@ -311,12 +311,6 @@ TextureImageEGL::DestroyEGLSurface(void)
mSurface = nullptr;
}
void
TextureImageEGL::ApplyFilter()
{
mGLContext->ApplyFilterToBoundTexture(mFilter);
}
already_AddRefed<TextureImage>
CreateTextureImageEGL(GLContext *gl,
const nsIntSize& aSize,
@ -357,4 +351,4 @@ TileGenFuncEGL(GLContext *gl,
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More