зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to fx-team.
This commit is contained in:
Коммит
b7e782a702
2
CLOBBER
2
CLOBBER
|
@ -18,4 +18,4 @@
|
|||
# Modifying this file will now automatically clobber the buildbot machines \o/
|
||||
#
|
||||
|
||||
Bug 904831 - MSVC_ENABLE_PGO in js/src/Makefile.in
|
||||
Bug 908208 - ipdl dependencies are busted, so we must clobber. See Bug 907394 for a solution.
|
||||
|
|
|
@ -60,6 +60,7 @@ ifndef MOZ_PROFILE_USE
|
|||
# We need to explicitly put backend.RecursiveMakeBackend.built here
|
||||
# otherwise the rule in rules.mk doesn't run early enough.
|
||||
default alldep all:: CLOBBER $(topsrcdir)/configure config.status backend.RecursiveMakeBackend.built
|
||||
$(call SUBMAKE,backend.RecursiveMakeBackend.built,js/src,1)
|
||||
$(call py_action,purge_manifests,-d _build_manifests/purge .)
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"revision": "bdac3547cbc0423bcdcf3b1650be326bfd1c601f",
|
||||
"revision": "a96d83d7e0bbd6b3fb8ecb78712c924ba8094659",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ pref("prompts.tab_modal.enabled", true);
|
|||
pref("layers.offmainthreadcomposition.enabled", true);
|
||||
pref("layers.async-pan-zoom.enabled", false);
|
||||
pref("layers.componentalpha.enabled", false);
|
||||
pref("gfx.azpc.touch_start_tolerance", "0.1"); // dpi * tolerance = pixel threshold
|
||||
pref("gfx.axis.fling_friction", "0.002");
|
||||
|
||||
// Enable Microsoft TSF support by default for imes.
|
||||
|
|
48
build/cl.py
48
build/cl.py
|
@ -2,12 +2,47 @@
|
|||
# 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/.
|
||||
|
||||
import ctypes
|
||||
import os, os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from mozbuild.makeutil import Makefile
|
||||
|
||||
CL_INCLUDES_PREFIX = os.environ.get("CL_INCLUDES_PREFIX", "Note: including file:")
|
||||
|
||||
GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW
|
||||
GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW
|
||||
|
||||
|
||||
# cl.exe likes to print inconsistent paths in the showIncludes output
|
||||
# (some lowercased, some not, with different directions of slashes),
|
||||
# and we need the original file case for make/pymake to be happy.
|
||||
# As this is slow and needs to be called a lot of times, use a cache
|
||||
# to speed things up.
|
||||
_normcase_cache = {}
|
||||
|
||||
def normcase(path):
|
||||
# Get*PathName want paths with backslashes
|
||||
path = path.replace('/', os.sep)
|
||||
dir = os.path.dirname(path)
|
||||
# name is fortunately always going to have the right case,
|
||||
# so we can use a cache for the directory part only.
|
||||
name = os.path.basename(path)
|
||||
if dir in _normcase_cache:
|
||||
result = _normcase_cache[dir]
|
||||
else:
|
||||
path = ctypes.create_unicode_buffer(dir)
|
||||
length = GetShortPathName(path, None, 0)
|
||||
shortpath = ctypes.create_unicode_buffer(length)
|
||||
GetShortPathName(path, shortpath, length)
|
||||
length = GetLongPathName(shortpath, None, 0)
|
||||
if length > len(path):
|
||||
path = ctypes.create_unicode_buffer(length)
|
||||
GetLongPathName(shortpath, path, length)
|
||||
result = _normcase_cache[dir] = path.value
|
||||
return os.path.join(result, name)
|
||||
|
||||
|
||||
def InvokeClWithDependencyGeneration(cmdline):
|
||||
target = ""
|
||||
# Figure out what the target is
|
||||
|
@ -29,7 +64,9 @@ def InvokeClWithDependencyGeneration(cmdline):
|
|||
cmdline += ['-showIncludes']
|
||||
cl = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
||||
|
||||
deps = set([os.path.normcase(source).replace(os.sep, '/')])
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule(target)
|
||||
rule.add_dependencies([normcase(source)])
|
||||
for line in cl.stdout:
|
||||
# cl -showIncludes prefixes every header with "Note: including file:"
|
||||
# and an indentation corresponding to the depth (which we don't need)
|
||||
|
@ -39,7 +76,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
|||
# we can assume that anything in a path with spaces is a system
|
||||
# header and throw it away.
|
||||
if ' ' not in dep:
|
||||
deps.add(os.path.normcase(dep).replace(os.sep, '/'))
|
||||
rule.add_dependencies([normcase(dep)])
|
||||
else:
|
||||
sys.stdout.write(line) # Make sure we preserve the relevant output
|
||||
# from cl
|
||||
|
@ -59,12 +96,7 @@ def InvokeClWithDependencyGeneration(cmdline):
|
|||
# die on the next line though, so it's not that much of a loss.
|
||||
|
||||
with open(depstarget, "w") as f:
|
||||
f.write("%s: %s" % (target, source))
|
||||
for dep in sorted(deps):
|
||||
f.write(" \\\n%s" % dep)
|
||||
f.write('\n')
|
||||
for dep in sorted(deps):
|
||||
f.write("%s:\n" % dep)
|
||||
mk.dump(f)
|
||||
|
||||
if __name__ == "__main__":
|
||||
InvokeClWithDependencyGeneration(sys.argv[1:])
|
||||
|
|
|
@ -172,11 +172,10 @@ class Rule(Statement):
|
|||
if not deps:
|
||||
return
|
||||
targets = self.targetexp.resolvesplit(makefile, makefile.variables)
|
||||
assert len(targets) == 1
|
||||
target = targets[0]
|
||||
rule = data.Rule(deps, self.doublecolon, loc=self.targetexp.loc, weakdeps=True)
|
||||
makefile.gettarget(target).addrule(rule)
|
||||
makefile.foundtarget(target)
|
||||
for target in targets:
|
||||
makefile.gettarget(target).addrule(rule)
|
||||
makefile.foundtarget(target)
|
||||
context.currule = rule
|
||||
|
||||
def _execute(self, makefile, context):
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# This file contains code for populating the virtualenv environment for
|
||||
# Mozilla's build system. It is typically called as part of configure.
|
||||
|
||||
from __future__ import print_function, unicode_literals, with_statement
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import distutils.sysconfig
|
||||
import os
|
||||
|
|
|
@ -302,6 +302,28 @@ def module_name(name):
|
|||
return name.replace('inlines.h', '').replace('-inl.h', '').replace('.h', '').replace('.cpp', '')
|
||||
|
||||
|
||||
def is_module_header(enclosing_inclname, header_inclname):
|
||||
'''Determine if an included name is the "module header", i.e. should be
|
||||
first in the file.'''
|
||||
|
||||
module = module_name(enclosing_inclname)
|
||||
|
||||
# Normal case, e.g. module == "foo/Bar", header_inclname == "foo/Bar.h".
|
||||
if module == module_name(header_inclname):
|
||||
return True
|
||||
|
||||
# A public header, e.g. module == "foo/Bar", header_inclname == "js/Bar.h".
|
||||
m = re.match(r'js\/(.*)\.h', header_inclname)
|
||||
if m is not None and module.endswith('/' + m.group(1)):
|
||||
return True
|
||||
|
||||
# A weird public header case.
|
||||
if module == 'jsmemorymetrics' and header_inclname == 'js/MemoryMetrics.h':
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class Include(object):
|
||||
'''Important information for a single #include statement.'''
|
||||
|
||||
|
@ -313,7 +335,7 @@ class Include(object):
|
|||
def isLeaf(self):
|
||||
return True
|
||||
|
||||
def section(self, module):
|
||||
def section(self, enclosing_inclname):
|
||||
'''Identify which section inclname belongs to.
|
||||
|
||||
The section numbers are as follows.
|
||||
|
@ -333,11 +355,9 @@ class Include(object):
|
|||
if not self.inclname.endswith('.h'):
|
||||
return 7
|
||||
|
||||
# A couple of modules have the .h file in js/ and the .cpp file elsewhere and so need special
|
||||
# handling.
|
||||
if module == module_name(self.inclname) or \
|
||||
module == 'jsmemorymetrics' and self.inclname == 'js/MemoryMetrics.h' or \
|
||||
module == 'vm/PropertyKey' and self.inclname == 'js/PropertyKey.h':
|
||||
# A couple of modules have the .h file in js/ and the .cpp file elsewhere and so need
|
||||
# special handling.
|
||||
if is_module_header(enclosing_inclname, self.inclname):
|
||||
return 0
|
||||
|
||||
if '/' in self.inclname:
|
||||
|
@ -451,8 +471,6 @@ def do_file(filename, inclname, file_kind, f, all_inclnames, included_h_inclname
|
|||
if inclname == include.inclname:
|
||||
error(filename, include.linenum, 'the file includes itself')
|
||||
|
||||
module = module_name(inclname)
|
||||
|
||||
def check_includes_order(include1, include2):
|
||||
'''Check the ordering of two #include statements.'''
|
||||
|
||||
|
@ -460,8 +478,8 @@ def do_file(filename, inclname, file_kind, f, all_inclnames, included_h_inclname
|
|||
include2.inclname in oddly_ordered_inclnames:
|
||||
return
|
||||
|
||||
section1 = include1.section(module)
|
||||
section2 = include2.section(module)
|
||||
section1 = include1.section(inclname)
|
||||
section2 = include2.section(inclname)
|
||||
if (section1 > section2) or \
|
||||
((section1 == section2) and (include1.inclname.lower() > include2.inclname.lower())):
|
||||
error(filename, str(include1.linenum) + ':' + str(include2.linenum),
|
||||
|
|
|
@ -99,9 +99,9 @@ class Element;
|
|||
struct ElementRegistrationOptions;
|
||||
class EventTarget;
|
||||
class FrameRequestCallback;
|
||||
class GlobalObject;
|
||||
class HTMLBodyElement;
|
||||
class Link;
|
||||
class GlobalObject;
|
||||
class NodeFilter;
|
||||
class NodeIterator;
|
||||
class ProcessingInstruction;
|
||||
|
@ -150,6 +150,7 @@ NS_GetContentList(nsINode* aRootNode,
|
|||
// Gecko.
|
||||
class nsIDocument : public nsINode
|
||||
{
|
||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||
public:
|
||||
typedef mozilla::dom::Element Element;
|
||||
|
||||
|
@ -1924,7 +1925,7 @@ public:
|
|||
return GetScopeObject();
|
||||
}
|
||||
static already_AddRefed<nsIDocument>
|
||||
Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
mozilla::ErrorResult& rv);
|
||||
virtual mozilla::dom::DOMImplementation*
|
||||
GetImplementation(mozilla::ErrorResult& rv) = 0;
|
||||
|
|
|
@ -60,10 +60,10 @@ Comment::List(FILE* out, int32_t aIndent) const
|
|||
#endif
|
||||
|
||||
/* static */ already_AddRefed<Comment>
|
||||
Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
|
||||
ErrorResult& aRv)
|
||||
Comment::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window || !window->GetDoc()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -122,9 +122,10 @@ DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
|
|||
#endif
|
||||
|
||||
/* static */ already_AddRefed<DocumentFragment>
|
||||
DocumentFragment::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
DocumentFragment::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window || !window->GetDoc()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -285,12 +285,13 @@ EventSource::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<EventSource>
|
||||
EventSource::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
|
||||
EventSource::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aURL,
|
||||
const EventSourceInit& aEventSourceInitDict,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<EventSource> eventSource = new EventSource();
|
||||
aRv = eventSource->Init(aGlobal.Get(), aURL,
|
||||
aRv = eventSource->Init(aGlobal.GetAsSupports(), aURL,
|
||||
aEventSourceInitDict.mWithCredentials);
|
||||
return eventSource.forget();
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ Text::SplitText(uint32_t aOffset, ErrorResult& rv)
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<Text>
|
||||
Text::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
|
||||
ErrorResult& aRv)
|
||||
Text::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aData, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window || !window->GetDoc()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -29,8 +29,8 @@ public:
|
|||
}
|
||||
|
||||
static already_AddRefed<Text>
|
||||
Constructor(const GlobalObject& aGlobal, const nsAString& aData,
|
||||
ErrorResult& aRv);
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aData, ErrorResult& aRv);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -521,7 +521,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> scriptPrincipal =
|
||||
do_QueryInterface(aGlobal.Get());
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!scriptPrincipal) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -533,13 +533,13 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!sgo) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!ownerWindow) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/dom/HTMLTemplateElement.h"
|
||||
#include "mozilla/dom/TextDecoderBase.h"
|
||||
#include "mozilla/dom/TextDecoder.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Selection.h"
|
||||
|
@ -3422,15 +3422,15 @@ nsContentUtils::ConvertStringFromCharset(const nsACString& aCharset,
|
|||
}
|
||||
|
||||
ErrorResult rv;
|
||||
TextDecoderBase decoder;
|
||||
decoder.Init(NS_ConvertUTF8toUTF16(aCharset), false, rv);
|
||||
nsAutoPtr<TextDecoder> decoder(new TextDecoder());
|
||||
decoder->Init(NS_ConvertUTF8toUTF16(aCharset), false, rv);
|
||||
if (rv.Failed()) {
|
||||
rv.ClearMessage();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
decoder.Decode(aInput.BeginReading(), aInput.Length(), false,
|
||||
aOutput, rv);
|
||||
decoder->Decode(aInput.BeginReading(), aInput.Length(), false,
|
||||
aOutput, rv);
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
|
|
|
@ -186,21 +186,12 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx,
|
|||
{
|
||||
bool nativeEOL = false;
|
||||
if (aArgc > 1) {
|
||||
if (NS_IsMainThread()) {
|
||||
BlobPropertyBag d;
|
||||
if (!d.Init(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1]))) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
mContentType = d.mType;
|
||||
nativeEOL = d.mEndings == EndingTypes::Native;
|
||||
} else {
|
||||
BlobPropertyBagWorkers d;
|
||||
if (!d.Init(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1]))) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
mContentType = d.mType;
|
||||
nativeEOL = d.mEndings == EndingTypes::Native;
|
||||
BlobPropertyBag d;
|
||||
if (!d.Init(aCx, JS::Handle<JS::Value>::fromMarkedLocation(&aArgv[1]))) {
|
||||
return NS_ERROR_TYPE_ERR;
|
||||
}
|
||||
mContentType = d.mType;
|
||||
nativeEOL = d.mEndings == EndingTypes::Native;
|
||||
}
|
||||
|
||||
if (aArgc > 0) {
|
||||
|
|
|
@ -147,7 +147,7 @@ nsDOMFileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
|||
{
|
||||
nsRefPtr<nsDOMFileReader> fileReader = new nsDOMFileReader();
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> owner = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> owner = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!owner) {
|
||||
NS_WARNING("Unexpected nsIJSNativeInitializer owner");
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -34,6 +34,7 @@ class nsDOMFileReader : public mozilla::dom::FileIOObject,
|
|||
public nsSupportsWeakReference
|
||||
{
|
||||
typedef mozilla::ErrorResult ErrorResult;
|
||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||
public:
|
||||
nsDOMFileReader();
|
||||
virtual ~nsDOMFileReader();
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
|
||||
// WebIDL
|
||||
static already_AddRefed<nsDOMFileReader>
|
||||
Constructor(const mozilla::dom::GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
void ReadAsArrayBuffer(JSContext* aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(aBlob);
|
||||
|
|
|
@ -531,7 +531,7 @@ nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
mozilla::dom::MutationCallback& aCb,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -361,16 +361,16 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI,
|
|||
}
|
||||
|
||||
/*static */already_AddRefed<nsDOMParser>
|
||||
nsDOMParser::Constructor(const GlobalObject& aOwner, nsIPrincipal* aPrincipal,
|
||||
nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
||||
ErrorResult& rv)
|
||||
nsDOMParser::Constructor(const GlobalObject& aOwner,
|
||||
nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
|
||||
nsIURI* aBaseURI, ErrorResult& rv)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.Get());
|
||||
rv = domParser->InitInternal(aOwner.Get(), aPrincipal, aDocumentURI,
|
||||
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.GetAsSupports());
|
||||
rv = domParser->InitInternal(aOwner.GetAsSupports(), aPrincipal, aDocumentURI,
|
||||
aBaseURI);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
|
@ -379,7 +379,8 @@ nsDOMParser::Constructor(const GlobalObject& aOwner, nsIPrincipal* aPrincipal,
|
|||
}
|
||||
|
||||
/*static */already_AddRefed<nsDOMParser>
|
||||
nsDOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv)
|
||||
nsDOMParser::Constructor(const GlobalObject& aOwner,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIPrincipal> prin;
|
||||
nsCOMPtr<nsIURI> documentURI;
|
||||
|
@ -402,8 +403,8 @@ nsDOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.Get());
|
||||
rv = domParser->InitInternal(aOwner.Get(), prin, documentURI, baseURI);
|
||||
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.GetAsSupports());
|
||||
rv = domParser->InitInternal(aOwner.GetAsSupports(), prin, documentURI, baseURI);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class nsDOMParser MOZ_FINAL : public nsIDOMParser,
|
|||
public nsSupportsWeakReference,
|
||||
public nsWrapperCache
|
||||
{
|
||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||
public:
|
||||
nsDOMParser();
|
||||
virtual ~nsDOMParser();
|
||||
|
@ -34,11 +35,11 @@ public:
|
|||
|
||||
// WebIDL API
|
||||
static already_AddRefed<nsDOMParser>
|
||||
Constructor(const mozilla::dom::GlobalObject& aOwner,
|
||||
Constructor(const GlobalObject& aOwner,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
||||
static already_AddRefed<nsDOMParser>
|
||||
Constructor(const mozilla::dom::GlobalObject& aOwner,
|
||||
Constructor(const GlobalObject& aOwner,
|
||||
nsIPrincipal* aPrincipal, nsIURI* aDocumentURI, nsIURI* aBaseURI,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
Constructor(const mozilla::dom::GlobalObject& aOwner,
|
||||
mozilla::ErrorResult& rv)
|
||||
{
|
||||
nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.Get());
|
||||
nsRefPtr<nsDOMSerializer> domSerializer = new nsDOMSerializer(aOwner.GetAsSupports());
|
||||
return domSerializer.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -11233,15 +11233,16 @@ nsDocument::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aRetur
|
|||
}
|
||||
|
||||
already_AddRefed<nsIDocument>
|
||||
nsIDocument::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
|
||||
nsIDocument::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!global) {
|
||||
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> prin = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!prin) {
|
||||
rv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
|
|
|
@ -111,7 +111,7 @@ nsFormData::Constructor(const GlobalObject& aGlobal,
|
|||
const Optional<NonNull<HTMLFormElement> >& aFormElement,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.Get());
|
||||
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.GetAsSupports());
|
||||
if (aFormElement.WasPassed()) {
|
||||
aRv = aFormElement.Value().WalkFormElements(formData);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
// nsWrapperCache
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
// WebIDL
|
||||
nsISupports*
|
||||
|
|
|
@ -3000,9 +3000,10 @@ nsRange::AutoInvalidateSelection::~AutoInvalidateSelection()
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<nsRange>
|
||||
nsRange::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
nsRange::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window || !window->GetDoc()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -142,9 +142,9 @@ public:
|
|||
const mozilla::dom::MozXMLHttpRequestParameters& aParams,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> principal =
|
||||
do_QueryInterface(aGlobal.Get());
|
||||
do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!global || ! principal) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -874,7 +874,7 @@ CanvasRenderingContext2D::EnsureTarget()
|
|||
#endif
|
||||
mTarget = layerManager->CreateDrawTarget(size, format);
|
||||
} else {
|
||||
mTarget = gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(size, format);
|
||||
mTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(size, format);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3566,7 +3566,7 @@ CanvasRenderingContext2D::EnsureErrorTarget()
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(IntSize(1, 1), FORMAT_B8G8R8A8);
|
||||
RefPtr<DrawTarget> errorTarget = gfxPlatform::GetPlatform()->CreateOffscreenCanvasDrawTarget(IntSize(1, 1), FORMAT_B8G8R8A8);
|
||||
NS_ABORT_IF_FALSE(errorTarget, "Failed to allocate the error target!");
|
||||
|
||||
sErrorTarget = errorTarget;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "CanvasUtils.h"
|
||||
#include "gfxFont.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
#include "mozilla/dom/CanvasGradient.h"
|
||||
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
|
||||
#include "mozilla/dom/CanvasPattern.h"
|
||||
|
@ -31,6 +30,7 @@ class SourceSurface;
|
|||
|
||||
namespace dom {
|
||||
class HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement;
|
||||
class ImageData;
|
||||
class StringOrCanvasGradientOrCanvasPattern;
|
||||
class StringOrCanvasGradientOrCanvasPatternReturnValue;
|
||||
class TextMetrics;
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
{
|
||||
return mHeight;
|
||||
}
|
||||
JSObject* Data(JSContext* cx) const
|
||||
JSObject* Data(JSContext* cx, JS::Handle<JSObject*> /* unused */) const
|
||||
{
|
||||
return GetDataObject();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
#include "mozilla/ProcessPriorityManager.h"
|
||||
|
||||
#include "Layers.h"
|
||||
|
@ -155,6 +156,7 @@ WebGLContext::WebGLContext()
|
|||
|
||||
mScissorTestEnabled = 0;
|
||||
mDitherEnabled = 1;
|
||||
mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244
|
||||
|
||||
// initialize some GL values: we're going to get them from the GL and use them as the sizes of arrays,
|
||||
// so in case glGetIntegerv leaves them uninitialized because of a GL bug, we would have very weird crashes.
|
||||
|
@ -1327,6 +1329,10 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask, const bool
|
|||
gl->fClearStencil(0);
|
||||
}
|
||||
|
||||
if (mRasterizerDiscardEnabled) {
|
||||
gl->fDisable(LOCAL_GL_RASTERIZER_DISCARD);
|
||||
}
|
||||
|
||||
// Do the clear!
|
||||
gl->fClear(mask);
|
||||
|
||||
|
@ -1334,6 +1340,10 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask, const bool
|
|||
if (mScissorTestEnabled)
|
||||
gl->fEnable(LOCAL_GL_SCISSOR_TEST);
|
||||
|
||||
if (mRasterizerDiscardEnabled) {
|
||||
gl->fEnable(LOCAL_GL_RASTERIZER_DISCARD);
|
||||
}
|
||||
|
||||
// Restore GL state after clearing.
|
||||
if (initializeColorBuffer) {
|
||||
if (drawBuffersIsEnabled) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
#include "ForceDiscreteGPUHelperCGL.h"
|
||||
|
@ -73,6 +72,8 @@ class WebGLTexture;
|
|||
class WebGLVertexArray;
|
||||
|
||||
namespace dom {
|
||||
class ImageData;
|
||||
|
||||
struct WebGLContextAttributes;
|
||||
struct WebGLContextAttributesInitializer;
|
||||
template<typename> class Nullable;
|
||||
|
@ -780,7 +781,13 @@ public:
|
|||
bool IsEnabled(WebGLenum cap);
|
||||
|
||||
private:
|
||||
// State tracking slots
|
||||
realGLboolean mDitherEnabled;
|
||||
realGLboolean mRasterizerDiscardEnabled;
|
||||
realGLboolean mScissorTestEnabled;
|
||||
|
||||
bool ValidateCapabilityEnum(WebGLenum cap, const char* info);
|
||||
realGLboolean* GetStateTrackingSlot(WebGLenum cap);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Vertices Feature (WebGLContextVertices.cpp)
|
||||
|
@ -1166,8 +1173,6 @@ protected:
|
|||
mStencilWriteMaskFront, mStencilWriteMaskBack;
|
||||
realGLboolean mColorWriteMask[4];
|
||||
realGLboolean mDepthWriteMask;
|
||||
realGLboolean mScissorTestEnabled;
|
||||
realGLboolean mDitherEnabled;
|
||||
WebGLfloat mColorClearValue[4];
|
||||
WebGLint mStencilClearValue;
|
||||
WebGLfloat mDepthClearValue;
|
||||
|
|
|
@ -24,6 +24,8 @@ WebGLContext::Clear(WebGLbitfield mask)
|
|||
|
||||
if (mask == 0) {
|
||||
GenerateWarning("Calling gl.clear(0) has no effect.");
|
||||
} else if (mRasterizerDiscardEnabled) {
|
||||
GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects.");
|
||||
}
|
||||
|
||||
if (mBoundFramebuffer) {
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#endif
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ImageData.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
|
|
@ -25,13 +25,11 @@ WebGLContext::Disable(WebGLenum cap)
|
|||
if (!ValidateCapabilityEnum(cap, "disable"))
|
||||
return;
|
||||
|
||||
switch(cap) {
|
||||
case LOCAL_GL_SCISSOR_TEST:
|
||||
mScissorTestEnabled = 0;
|
||||
break;
|
||||
case LOCAL_GL_DITHER:
|
||||
mDitherEnabled = 0;
|
||||
break;
|
||||
realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
|
||||
|
||||
if (trackingSlot)
|
||||
{
|
||||
*trackingSlot = 0;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
|
@ -47,13 +45,11 @@ WebGLContext::Enable(WebGLenum cap)
|
|||
if (!ValidateCapabilityEnum(cap, "enable"))
|
||||
return;
|
||||
|
||||
switch(cap) {
|
||||
case LOCAL_GL_SCISSOR_TEST:
|
||||
mScissorTestEnabled = 1;
|
||||
break;
|
||||
case LOCAL_GL_DITHER:
|
||||
mDitherEnabled = 1;
|
||||
break;
|
||||
realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
|
||||
|
||||
if (trackingSlot)
|
||||
{
|
||||
*trackingSlot = 1;
|
||||
}
|
||||
|
||||
MakeContextCurrent();
|
||||
|
@ -547,3 +543,18 @@ WebGLContext::ValidateCapabilityEnum(WebGLenum cap, const char* info)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
realGLboolean*
|
||||
WebGLContext::GetStateTrackingSlot(WebGLenum cap)
|
||||
{
|
||||
switch (cap) {
|
||||
case LOCAL_GL_SCISSOR_TEST:
|
||||
return &mScissorTestEnabled;
|
||||
case LOCAL_GL_DITHER:
|
||||
return &mDitherEnabled;
|
||||
case LOCAL_GL_RASTERIZER_DISCARD:
|
||||
return &mRasterizerDiscardEnabled;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ DOMWheelEvent::Constructor(const GlobalObject& aGlobal,
|
|||
const WheelEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<DOMWheelEvent> e = new DOMWheelEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
nsAutoString modifierList;
|
||||
|
|
|
@ -22,7 +22,7 @@ SpeechRecognitionError::Constructor(const GlobalObject& aGlobal,
|
|||
const SpeechRecognitionErrorInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv);
|
||||
|
|
|
@ -20,10 +20,11 @@ public:
|
|||
nsEvent* aEvent);
|
||||
virtual ~SpeechRecognitionError();
|
||||
|
||||
static already_AddRefed<SpeechRecognitionError> Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const SpeechRecognitionErrorInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
static already_AddRefed<SpeechRecognitionError>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const SpeechRecognitionErrorInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ nsDOMAnimationEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::AnimationEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMAnimationEvent> e = new nsDOMAnimationEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::ClipboardEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMClipboardEvent> e =
|
||||
new nsDOMClipboardEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
|
|
|
@ -356,7 +356,7 @@ nsDOMEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::EventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMEvent> e = new nsDOMEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
|
||||
|
|
|
@ -68,7 +68,7 @@ nsDOMFocusEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::FocusEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMFocusEvent> e = new nsDOMFocusEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
|
||||
|
|
|
@ -152,7 +152,7 @@ nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::MouseEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMMouseEvent> e = new nsDOMMouseEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
|
||||
|
|
|
@ -47,7 +47,7 @@ nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::TransitionEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ nsDOMUIEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
|||
const mozilla::dom::UIEventInit& aParam,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<nsDOMUIEvent> e = new nsDOMUIEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
aRv = e->InitUIEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
|
||||
|
|
|
@ -46,9 +46,9 @@ public:
|
|||
|
||||
// WebIDL
|
||||
|
||||
static already_AddRefed<HTMLAudioElement> Audio(const GlobalObject& global,
|
||||
const Optional<nsAString>& src,
|
||||
ErrorResult& aRv);
|
||||
static already_AddRefed<HTMLAudioElement>
|
||||
Audio(const GlobalObject& aGlobal,
|
||||
const Optional<nsAString>& aSrc, ErrorResult& aRv);
|
||||
|
||||
void MozSetup(uint32_t aChannels, uint32_t aRate, ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ HTMLAudioElement::Audio(const GlobalObject& aGlobal,
|
|||
const Optional<nsAString>& aSrc,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsIDocument* doc;
|
||||
if (!win || !(doc = win->GetExtantDoc())) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -529,9 +529,10 @@ HTMLImageElement::IntrinsicState() const
|
|||
already_AddRefed<HTMLImageElement>
|
||||
HTMLImageElement::Image(const GlobalObject& aGlobal,
|
||||
const Optional<uint32_t>& aWidth,
|
||||
const Optional<uint32_t>& aHeight, ErrorResult& aError)
|
||||
const Optional<uint32_t>& aHeight,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsIDocument* doc;
|
||||
if (!win || !(doc = win->GetExtantDoc())) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -25,8 +25,10 @@ public:
|
|||
virtual ~HTMLImageElement();
|
||||
|
||||
static already_AddRefed<HTMLImageElement>
|
||||
Image(const GlobalObject& aGlobal, const Optional<uint32_t>& aWidth,
|
||||
const Optional<uint32_t>& aHeight, ErrorResult& aError);
|
||||
Image(const GlobalObject& aGlobal,
|
||||
const Optional<uint32_t>& aWidth,
|
||||
const Optional<uint32_t>& aHeight,
|
||||
ErrorResult& aError);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
|
|
@ -335,7 +335,7 @@ HTMLOptionElement::Option(const GlobalObject& aGlobal,
|
|||
const Optional<bool>& aDefaultSelected,
|
||||
const Optional<bool>& aSelected, ErrorResult& aError)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsIDocument* doc;
|
||||
if (!win || !(doc = win->GetExtantDoc())) {
|
||||
aError.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -26,7 +26,8 @@ public:
|
|||
virtual ~HTMLOptionElement();
|
||||
|
||||
static already_AddRefed<HTMLOptionElement>
|
||||
Option(const GlobalObject& aGlobal, const Optional<nsAString>& aText,
|
||||
Option(const GlobalObject& aGlobal,
|
||||
const Optional<nsAString>& aText,
|
||||
const Optional<nsAString>& aValue,
|
||||
const Optional<bool>& aDefaultSelected,
|
||||
const Optional<bool>& aSelected, ErrorResult& aError);
|
||||
|
|
|
@ -124,7 +124,7 @@ MediaRecorder::~MediaRecorder()
|
|||
}
|
||||
|
||||
void
|
||||
MediaRecorder::Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow)
|
||||
MediaRecorder::Init(nsPIDOMWindow* aOwnerWindow)
|
||||
{
|
||||
MOZ_ASSERT(aOwnerWindow);
|
||||
MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
|
||||
|
@ -273,23 +273,23 @@ MediaRecorder::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<MediaRecorder>
|
||||
MediaRecorder::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
|
||||
MediaRecorder::Constructor(const GlobalObject& aGlobal,
|
||||
DOMMediaStream& aStream, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!sgo) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!ownerWindow) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<MediaRecorder> object = new MediaRecorder(aStream);
|
||||
object->Init(aCx, ownerWindow);
|
||||
object->Init(ownerWindow);
|
||||
return object.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ public:
|
|||
void GetMimeType(nsString &aMimeType) { aMimeType = mMimeType; }
|
||||
|
||||
static already_AddRefed<MediaRecorder>
|
||||
Constructor(const GlobalObject& aGlobal, JSContext* aCx, DOMMediaStream& aStream,
|
||||
ErrorResult& aRv);
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
DOMMediaStream& aStream, ErrorResult& aRv);
|
||||
|
||||
// EventHandler
|
||||
IMPL_EVENT_HANDLER(dataavailable)
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
friend class ExtractEncodedData;
|
||||
|
||||
protected:
|
||||
void Init(JSContext* aCx, nsPIDOMWindow* aOwnerWindow);
|
||||
void Init(nsPIDOMWindow* aOwnerWindow);
|
||||
// Copy encoded data from encoder to EncodedBufferCache. This function runs in the Media Encoder Thread.
|
||||
void ExtractEncodedData();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
const nsAString& aText,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<TextTrackCue> ttcue = new TextTrackCue(aGlobal.Get(), aStartTime,
|
||||
nsRefPtr<TextTrackCue> ttcue = new TextTrackCue(aGlobal.GetAsSupports(), aStartTime,
|
||||
aEndTime, aText, aRv);
|
||||
return ttcue.forget();
|
||||
}
|
||||
|
|
|
@ -31,9 +31,10 @@ MediaSource::CreateInternalStream()
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<MediaSource>
|
||||
MediaSource::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
MediaSource::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||
return nullptr;
|
||||
|
@ -151,7 +152,8 @@ MediaSource::EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, Er
|
|||
}
|
||||
|
||||
/* static */ bool
|
||||
MediaSource::IsTypeSupported(const GlobalObject& aGlobal, const nsAString& aType)
|
||||
MediaSource::IsTypeSupported(const GlobalObject& aGlobal,
|
||||
const nsAString& aType)
|
||||
{
|
||||
ErrorResult unused;
|
||||
return IsTypeSupportedInternal(aType, unused);
|
||||
|
|
|
@ -35,7 +35,9 @@ class MediaSource MOZ_FINAL : public nsDOMEventTargetHelper
|
|||
{
|
||||
public:
|
||||
/** WebIDL Methods. */
|
||||
static already_AddRefed<MediaSource> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
static already_AddRefed<MediaSource>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
SourceBufferList* SourceBuffers();
|
||||
SourceBufferList* ActiveSourceBuffers();
|
||||
|
@ -48,7 +50,8 @@ public:
|
|||
void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
|
||||
|
||||
void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
|
||||
static bool IsTypeSupported(const GlobalObject& aGlobal, const nsAString& aType);
|
||||
static bool IsTypeSupported(const GlobalObject& aGlobal,
|
||||
const nsAString& aType);
|
||||
/** End WebIDL Methods. */
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
|
|
@ -84,9 +84,10 @@ AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<AudioContext>
|
||||
AudioContext::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
AudioContext::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
@ -104,7 +105,7 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
|
|||
float aSampleRate,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -49,9 +49,9 @@ class ConvolverNode;
|
|||
class DelayNode;
|
||||
class DynamicsCompressorNode;
|
||||
class GainNode;
|
||||
class GlobalObject;
|
||||
class HTMLMediaElement;
|
||||
class MediaElementAudioSourceNode;
|
||||
class GlobalObject;
|
||||
class MediaStreamAudioDestinationNode;
|
||||
class MediaStreamAudioSourceNode;
|
||||
class OscillatorNode;
|
||||
|
|
|
@ -31,9 +31,10 @@ SpeechGrammar::~SpeechGrammar()
|
|||
}
|
||||
|
||||
SpeechGrammar*
|
||||
SpeechGrammar::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
SpeechGrammar::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return new SpeechGrammar(aGlobal.Get());
|
||||
return new SpeechGrammar(aGlobal.GetAsSupports());
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
|
|
|
@ -39,7 +39,8 @@ public:
|
|||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
static SpeechGrammar* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
static SpeechGrammar* Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void GetSrc(nsString& aRetVal, ErrorResult& aRv) const;
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ SpeechGrammarList::~SpeechGrammarList()
|
|||
}
|
||||
|
||||
SpeechGrammarList*
|
||||
SpeechGrammarList::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
SpeechGrammarList::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return new SpeechGrammarList(aGlobal.Get());
|
||||
return new SpeechGrammarList(aGlobal.GetAsSupports());
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -33,7 +33,8 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SpeechGrammarList)
|
||||
|
||||
SpeechGrammarList* Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
SpeechGrammarList* Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
nsISupports* GetParentObject() const;
|
||||
|
||||
|
|
|
@ -107,9 +107,10 @@ SpeechRecognition::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
already_AddRefed<SpeechRecognition>
|
||||
SpeechRecognition::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
SpeechRecognition::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!win) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ public:
|
|||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
static already_AddRefed<SpeechRecognition> Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
static already_AddRefed<SpeechRecognition>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<SpeechGrammarList> GetGrammars(ErrorResult& aRv) const;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ SpeechSynthesisUtterance::Constructor(GlobalObject& aGlobal,
|
|||
const nsAString& aText,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
if (!win) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -221,7 +221,8 @@ nsXPathEvaluator::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
|
||||
/* static */
|
||||
already_AddRefed<nsXPathEvaluator>
|
||||
nsXPathEvaluator::Constructor(const GlobalObject& aGlobal, ErrorResult& rv)
|
||||
nsXPathEvaluator::Constructor(const GlobalObject& aGlobal,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
nsRefPtr<nsXPathEvaluator> newObj = new nsXPathEvaluator(nullptr);
|
||||
newObj->Init();
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<Activity> activity = new Activity();
|
||||
aRv = activity->Initialize(aOwner.Get(), aOptions);
|
||||
aRv = activity->Initialize(aOwner.GetAsSupports(), aOptions);
|
||||
return activity.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ interface nsITimezoneChangedCb : nsISupports
|
|||
#define ALARMHALSERVICE_CONTRACTID "@mozilla.org/alarmHalService;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(057b1ee4-f696-486d-bd55-205e21e88fab)]
|
||||
[scriptable, uuid(057b1ee4-f696-486d-bd55-205e21e88fab)]
|
||||
interface nsIAlarmHalService : nsISupports
|
||||
{
|
||||
bool setAlarm(in int32_t aSeconds, in int32_t aNanoseconds);
|
||||
|
|
|
@ -65,10 +65,11 @@ DOMError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMError>
|
||||
DOMError::Constructor(const GlobalObject& aGlobal, const nsAString& aName,
|
||||
const nsAString& aMessage, ErrorResult& aRv)
|
||||
DOMError::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aName, const nsAString& aMessage,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
||||
// Window is null for chrome code.
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ IndexedDBHelper.prototype = {
|
|||
self.upgradeSchema(req.transaction, _db, aEvent.oldVersion, aEvent.newVersion);
|
||||
};
|
||||
req.onerror = function (aEvent) {
|
||||
if (DEBUG) debug("Failed to open database:" + self.dbName);
|
||||
if (DEBUG) debug("Failed to open database: " + self.dbName);
|
||||
aFailureCb(aEvent.target.error.name);
|
||||
};
|
||||
req.onblocked = function (aEvent) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef StructuredCloneTags_h__
|
||||
#define StructuredCloneTags_h__
|
||||
|
||||
#include "js/StructuredClone.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
void
|
||||
URL::CreateObjectURL(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
|
||||
URL::CreateObjectURL(const GlobalObject& aGlobal,
|
||||
nsIDOMBlob* aBlob,
|
||||
const objectURLOptions& aOptions,
|
||||
nsString& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
CreateObjectURLInternal(aGlobal.Get(), aBlob,
|
||||
CreateObjectURLInternal(aGlobal.GetAsSupports(), aBlob,
|
||||
NS_LITERAL_CSTRING(BLOBURI_SCHEME), aOptions, aResult,
|
||||
aError);
|
||||
}
|
||||
|
@ -33,7 +34,7 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, DOMMediaStream& aStream,
|
|||
nsString& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
CreateObjectURLInternal(aGlobal.Get(), &aStream,
|
||||
CreateObjectURLInternal(aGlobal.GetAsSupports(), &aStream,
|
||||
NS_LITERAL_CSTRING(MEDIASTREAMURI_SCHEME), aOptions,
|
||||
aResult, aError);
|
||||
}
|
||||
|
@ -44,7 +45,7 @@ URL::CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource,
|
|||
nsString& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
CreateObjectURLInternal(aGlobal.Get(), &aSource,
|
||||
CreateObjectURLInternal(aGlobal.GetAsSupports(), &aSource,
|
||||
NS_LITERAL_CSTRING(MEDIASOURCEURI_SCHEME), aOptions,
|
||||
aResult, aError);
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ URL::CreateObjectURLInternal(nsISupports* aGlobal, nsISupports* aObject,
|
|||
void
|
||||
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
|
||||
NS_PRECONDITION(!window || window->IsInnerWindow(),
|
||||
"Should be inner window");
|
||||
|
|
|
@ -26,7 +26,8 @@ class URL MOZ_FINAL
|
|||
{
|
||||
public:
|
||||
// WebIDL methods
|
||||
static void CreateObjectURL(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
|
||||
static void CreateObjectURL(const GlobalObject& aGlobal,
|
||||
nsIDOMBlob* aBlob,
|
||||
const objectURLOptions& aOptions,
|
||||
nsString& aResult,
|
||||
ErrorResult& aError);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/StructuredClone.h"
|
||||
|
||||
#include "mozilla/Base64.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef mozilla_dom_AtomList_h__
|
||||
#define mozilla_dom_AtomList_h__
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/dom/GeneratedAtomList.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
template<class T>
|
||||
T* GetAtomCache(JSContext* aCx)
|
||||
{
|
||||
JSRuntime* rt = JS_GetRuntime(aCx);
|
||||
|
||||
auto atomCache = static_cast<PerThreadAtomCache*>(JS_GetRuntimePrivate(rt));
|
||||
|
||||
return static_cast<T*>(atomCache);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AtomList_h__
|
|
@ -64,31 +64,13 @@ class MOZ_STACK_CLASS GlobalObject
|
|||
public:
|
||||
GlobalObject(JSContext* aCx, JSObject* aObject);
|
||||
|
||||
nsISupports* Get() const
|
||||
{
|
||||
return mGlobalObject;
|
||||
}
|
||||
|
||||
bool Failed() const
|
||||
{
|
||||
return !Get();
|
||||
}
|
||||
|
||||
private:
|
||||
JS::Rooted<JSObject*> mGlobalJSObject;
|
||||
nsISupports* mGlobalObject;
|
||||
nsCOMPtr<nsISupports> mGlobalObjectRef;
|
||||
};
|
||||
|
||||
class MOZ_STACK_CLASS WorkerGlobalObject
|
||||
{
|
||||
public:
|
||||
WorkerGlobalObject(JSContext* aCx, JSObject* aObject);
|
||||
|
||||
JSObject* Get() const
|
||||
{
|
||||
return mGlobalJSObject;
|
||||
}
|
||||
|
||||
nsISupports* GetAsSupports() const;
|
||||
|
||||
// The context that this returns is not guaranteed to be in the compartment of
|
||||
// the object returned from Get(), in fact it's generally in the caller's
|
||||
// compartment.
|
||||
|
@ -102,9 +84,11 @@ public:
|
|||
return !Get();
|
||||
}
|
||||
|
||||
private:
|
||||
protected:
|
||||
JS::RootedObject mGlobalJSObject;
|
||||
JSContext* mCx;
|
||||
mutable nsISupports* mGlobalObject;
|
||||
mutable nsCOMPtr<nsISupports> mGlobalObjectRef;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,10 @@ import os
|
|||
import cPickle
|
||||
from Configuration import Configuration
|
||||
from Codegen import CGBindingRoot, replaceFileIfChanged
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozbuild.pythonutil import iter_modules_in_path
|
||||
from buildconfig import topsrcdir
|
||||
|
||||
|
||||
def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
|
||||
"""
|
||||
|
@ -18,10 +22,12 @@ def generate_binding_files(config, outputprefix, srcprefix, webidlfile):
|
|||
replaceFileIfChanged(outputprefix + ".h", root.declare())
|
||||
replaceFileIfChanged(outputprefix + ".cpp", root.define())
|
||||
|
||||
with open(depsname, 'wb') as f:
|
||||
# Sort so that our output is stable
|
||||
f.write("\n".join(outputprefix + ": " + os.path.join(srcprefix, x) for
|
||||
x in sorted(root.deps())))
|
||||
mk = Makefile()
|
||||
rule = mk.create_rule([outputprefix + '.h', outputprefix + '.cpp'])
|
||||
rule.add_dependencies(os.path.join(srcprefix, x) for x in root.deps())
|
||||
rule.add_dependencies(iter_modules_in_path(topsrcdir))
|
||||
with open(depsname, 'w') as f:
|
||||
mk.dump(f)
|
||||
|
||||
def main():
|
||||
# Parse arguments.
|
||||
|
|
|
@ -1704,53 +1704,53 @@ ReparentWrapper(JSContext* aCx, JS::HandleObject aObjArg)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
template<bool mainThread>
|
||||
inline JSObject*
|
||||
GetGlobalObject(JSContext* aCx, JSObject* aObject,
|
||||
Maybe<JSAutoCompartment>& aAutoCompartment)
|
||||
GlobalObject::GlobalObject(JSContext* aCx, JSObject* aObject)
|
||||
: mGlobalJSObject(aCx),
|
||||
mCx(aCx),
|
||||
mGlobalObject(nullptr)
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
JS::Rooted<JSObject*> obj(aCx, aObject);
|
||||
if (js::IsWrapper(obj)) {
|
||||
obj = js::CheckedUnwrap(obj, /* stopAtOuter = */ false);
|
||||
if (!obj) {
|
||||
Throw<mainThread>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
|
||||
return nullptr;
|
||||
// We should never end up here on a worker thread, since there shouldn't
|
||||
// be any security wrappers to worry about.
|
||||
if (!MOZ_LIKELY(NS_IsMainThread())) {
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
Throw<true>(aCx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
|
||||
return;
|
||||
}
|
||||
aAutoCompartment.construct(aCx, obj);
|
||||
ac.construct(aCx, obj);
|
||||
}
|
||||
|
||||
return JS_GetGlobalForObject(aCx, obj);
|
||||
mGlobalJSObject = JS_GetGlobalForObject(aCx, obj);
|
||||
}
|
||||
|
||||
GlobalObject::GlobalObject(JSContext* aCx, JSObject* aObject)
|
||||
: mGlobalJSObject(aCx)
|
||||
nsISupports*
|
||||
GlobalObject::GetAsSupports() const
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
mGlobalJSObject = GetGlobalObject<true>(aCx, aObject, ac);
|
||||
if (!mGlobalJSObject) {
|
||||
mGlobalObject = nullptr;
|
||||
return;
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mGlobalObject) {
|
||||
return mGlobalObject;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> val(aCx, JS::ObjectValue(*mGlobalJSObject));
|
||||
JS::Rooted<JS::Value> val(mCx, JS::ObjectValue(*mGlobalJSObject));
|
||||
|
||||
// Switch this to UnwrapDOMObjectToISupports once our global objects are
|
||||
// using new bindings.
|
||||
nsresult rv = xpc_qsUnwrapArg<nsISupports>(aCx, val, &mGlobalObject,
|
||||
nsresult rv = xpc_qsUnwrapArg<nsISupports>(mCx, val, &mGlobalObject,
|
||||
static_cast<nsISupports**>(getter_AddRefs(mGlobalObjectRef)),
|
||||
val.address());
|
||||
if (NS_FAILED(rv)) {
|
||||
mGlobalObject = nullptr;
|
||||
Throw<true>(aCx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
Throw<true>(mCx, NS_ERROR_XPC_BAD_CONVERT_JS);
|
||||
}
|
||||
}
|
||||
|
||||
WorkerGlobalObject::WorkerGlobalObject(JSContext* aCx, JSObject* aObject)
|
||||
: mGlobalJSObject(aCx),
|
||||
mCx(aCx)
|
||||
{
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
mGlobalJSObject = GetGlobalObject<false>(aCx, aObject, ac);
|
||||
return mGlobalObject;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1847,7 +1847,7 @@ ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj)
|
|||
if (global.Failed()) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.GetAsSupports());
|
||||
if (window && window->GetDoc()) {
|
||||
window->GetDoc()->WarnOnceAbout(nsIDocument::eLenientThis);
|
||||
}
|
||||
|
@ -1884,7 +1884,7 @@ GetWindowForJSImplementedObject(JSContext* cx, JS::Handle<JSObject*> obj,
|
|||
|
||||
// It's OK if we have null here: that just means the content-side
|
||||
// object really wasn't associated with any window.
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global.Get()));
|
||||
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(global.GetAsSupports()));
|
||||
win.forget(window);
|
||||
return true;
|
||||
}
|
||||
|
@ -1896,7 +1896,7 @@ ConstructJSImplementation(JSContext* aCx, const char* aContractId,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
// Get the window to use as a parent and for initialization.
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
if (!window) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
|
|
|
@ -715,7 +715,6 @@ DOMInterfaces = {
|
|||
|
||||
'MediaRecorder': {
|
||||
'headerFile': 'MediaRecorder.h',
|
||||
'implicitJSContext': [ 'constructor' ],
|
||||
'resultNotAddRefed': [ 'stream' ]
|
||||
},
|
||||
|
||||
|
@ -875,10 +874,6 @@ DOMInterfaces = {
|
|||
'headerFile': 'nsGeolocation.h'
|
||||
},
|
||||
|
||||
'Promise': {
|
||||
'implicitJSContext': [ 'constructor' ]
|
||||
},
|
||||
|
||||
'PropertyNodeList': {
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
|
@ -1174,19 +1169,13 @@ DOMInterfaces = {
|
|||
'headerFile': 'nsTextNode.h',
|
||||
},
|
||||
|
||||
'TextDecoder': [
|
||||
{
|
||||
'workers': True,
|
||||
}],
|
||||
|
||||
'TextEncoder': [
|
||||
{
|
||||
'implicitJSContext': [ 'encode' ],
|
||||
'TextDecoder': {
|
||||
'nativeOwnership': 'owned',
|
||||
},
|
||||
|
||||
'TextEncoder': {
|
||||
'nativeOwnership': 'owned',
|
||||
},
|
||||
{
|
||||
'workers': True,
|
||||
'implicitJSContext': [ 'encode' ],
|
||||
}],
|
||||
|
||||
'TextMetrics': {
|
||||
'wrapperCache': False,
|
||||
|
|
|
@ -3481,8 +3481,7 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
# should be able to assume not isOptional here.
|
||||
assert not isOptional
|
||||
|
||||
typeName = CGDictionary.makeDictionaryName(type.inner,
|
||||
descriptorProvider.workers)
|
||||
typeName = CGDictionary.makeDictionaryName(type.inner)
|
||||
actualTypeName = typeName
|
||||
|
||||
declType = CGGeneric(actualTypeName)
|
||||
|
@ -3729,7 +3728,7 @@ def instantiateJSToNativeConversion(info, replacements, checkForValue=False):
|
|||
# Add an empty CGGeneric to get an extra newline after the argument
|
||||
# conversion.
|
||||
result.append(CGGeneric(""))
|
||||
return result;
|
||||
return result
|
||||
|
||||
def convertConstIDLValueToJSVal(value):
|
||||
if isinstance(value, IDLNullValue):
|
||||
|
@ -4262,6 +4261,9 @@ def leafTypeNeedsCx(type, descriptorProvider, retVal):
|
|||
(retVal and type.isSpiderMonkeyInterface()) or
|
||||
(descriptorProvider.workers and type.isCallback()))
|
||||
|
||||
def leafTypeNeedsScopeObject(type, descriptorProvider, retVal):
|
||||
return (retVal and type.isSpiderMonkeyInterface())
|
||||
|
||||
def leafTypeNeedsRooting(type, descriptorProvider):
|
||||
return (leafTypeNeedsCx(type, descriptorProvider, False) or
|
||||
type.isSpiderMonkeyInterface())
|
||||
|
@ -4274,6 +4276,10 @@ def typeNeedsCx(type, descriptorProvider, retVal=False):
|
|||
return typeMatchesLambda(type,
|
||||
lambda t: leafTypeNeedsCx(t, descriptorProvider, retVal))
|
||||
|
||||
def typeNeedsScopeObject(type, descriptorProvider, retVal=False):
|
||||
return typeMatchesLambda(type,
|
||||
lambda t: leafTypeNeedsScopeObject(t, descriptorProvider, retVal))
|
||||
|
||||
def typeMatchesLambda(type, func):
|
||||
if type is None:
|
||||
return False
|
||||
|
@ -4334,11 +4340,11 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
|
|||
if returnType.isGeckoInterface():
|
||||
result = CGGeneric(descriptorProvider.getDescriptor(
|
||||
returnType.unroll().inner.identifier.name).nativeType)
|
||||
if resultAlreadyAddRefed:
|
||||
result = CGTemplatedType("nsRefPtr", result)
|
||||
elif descriptorProvider.getDescriptor(
|
||||
if descriptorProvider.getDescriptor(
|
||||
returnType.unroll().inner.identifier.name).nativeOwnership == 'owned':
|
||||
result = CGTemplatedType("nsAutoPtr", result)
|
||||
elif resultAlreadyAddRefed:
|
||||
result = CGTemplatedType("nsRefPtr", result)
|
||||
else:
|
||||
result = CGWrapper(result, post="*")
|
||||
return result, False, None, None
|
||||
|
@ -4373,8 +4379,7 @@ def getRetvalDeclarationForType(returnType, descriptorProvider,
|
|||
return result, True, rooter, None
|
||||
if returnType.isDictionary():
|
||||
nullable = returnType.nullable()
|
||||
dictName = (CGDictionary.makeDictionaryName(returnType.unroll().inner,
|
||||
descriptorProvider.workers) +
|
||||
dictName = (CGDictionary.makeDictionaryName(returnType.unroll().inner) +
|
||||
"Initializer")
|
||||
result = CGGeneric(dictName)
|
||||
if not isMember and typeNeedsRooting(returnType, descriptorProvider):
|
||||
|
@ -4411,6 +4416,12 @@ def needCx(returnType, arguments, extendedAttributes, descriptorProvider,
|
|||
any(typeNeedsCx(a.type, descriptorProvider) for a in arguments)) or
|
||||
'implicitJSContext' in extendedAttributes)
|
||||
|
||||
def needScopeObject(returnType, arguments, extendedAttributes,
|
||||
descriptorProvider, isWrapperCached, considerTypes):
|
||||
return (considerTypes and not isWrapperCached and
|
||||
(typeNeedsScopeObject(returnType, descriptorProvider, True) or
|
||||
any(typeNeedsScopeObject(a.type, descriptorProvider) for a in arguments)))
|
||||
|
||||
class CGCallGenerator(CGThing):
|
||||
"""
|
||||
A class to generate an actual call to a C++ object. Assumes that the C++
|
||||
|
@ -4666,14 +4677,11 @@ class CGPerSignatureCall(CGThing):
|
|||
if static:
|
||||
nativeMethodName = "%s::%s" % (descriptor.nativeType,
|
||||
nativeMethodName)
|
||||
globalObjectType = "GlobalObject"
|
||||
if descriptor.workers:
|
||||
globalObjectType = "Worker" + globalObjectType
|
||||
cgThings.append(CGGeneric("""%s global(cx, obj);
|
||||
cgThings.append(CGGeneric("""GlobalObject global(cx, obj);
|
||||
if (global.Failed()) {
|
||||
return false;
|
||||
}
|
||||
""" % globalObjectType))
|
||||
"""))
|
||||
argsPre.append("global")
|
||||
|
||||
# For JS-implemented interfaces we do not want to base the
|
||||
|
@ -4684,6 +4692,16 @@ if (global.Failed()) {
|
|||
if needsCx and not (static and descriptor.workers):
|
||||
argsPre.append("cx")
|
||||
|
||||
needsUnwrap = isConstructor
|
||||
if needScopeObject(returnType, arguments, self.extendedAttributes,
|
||||
descriptor, descriptor.wrapperCache,
|
||||
not descriptor.interface.isJSImplemented()):
|
||||
# We cannot assign into obj because it's a Handle, not a
|
||||
# MutableHandle, so we need a separate Rooted.
|
||||
cgThings.append(CGGeneric("Maybe<JS::Rooted<JSObject*> > unwrappedObj;"))
|
||||
argsPre.append("unwrappedObj.empty() ? obj : unwrappedObj.ref()")
|
||||
needsUnwrap = True
|
||||
|
||||
if idlNode.isMethod() and idlNode.isLegacycaller():
|
||||
# If we can have legacycaller with identifier, we can't
|
||||
# just use the idlNode to determine whether we're
|
||||
|
@ -4708,26 +4726,36 @@ if (global.Failed()) {
|
|||
lenientFloatCode=lenientFloatCode) for
|
||||
i in range(argConversionStartsAt, self.argCount)])
|
||||
|
||||
if isConstructor:
|
||||
# If we're called via an xray, we need to enter the underlying
|
||||
# object's compartment and then wrap up all of our arguments into
|
||||
# that compartment as needed. This is all happening after we've
|
||||
# already done the conversions from JS values to WebIDL (C++)
|
||||
# values, so we only need to worry about cases where there are 'any'
|
||||
# or 'object' types, or other things that we represent as actual
|
||||
# JSAPI types, present. Effectively, we're emulating a
|
||||
# CrossCompartmentWrapper, but working with the C++ types, not the
|
||||
# original list of JS::Values.
|
||||
cgThings.append(CGGeneric("Maybe<JSAutoCompartment> ac;"))
|
||||
xraySteps = [
|
||||
CGGeneric("obj = js::CheckedUnwrap(obj);\n"
|
||||
"if (!obj) {\n"
|
||||
" return false;\n"
|
||||
"}\n"
|
||||
"ac.construct(cx, obj);") ]
|
||||
xraySteps.extend(
|
||||
wrapArgIntoCurrentCompartment(arg, argname, isMember=False)
|
||||
for (arg, argname) in self.getArguments())
|
||||
if needsUnwrap:
|
||||
# Something depends on having the unwrapped object, so unwrap it now.
|
||||
xraySteps = []
|
||||
if not isConstructor:
|
||||
xraySteps.append(
|
||||
CGGeneric("unwrappedObj.construct(cx, obj);"))
|
||||
|
||||
# XXXkhuey we should be able to MOZ_ASSERT that ${obj} is
|
||||
# not null.
|
||||
xraySteps.append(
|
||||
CGGeneric(string.Template("""${obj} = js::CheckedUnwrap(${obj});
|
||||
if (!${obj}) {
|
||||
return false;
|
||||
}""").substitute({ 'obj' : 'obj' if isConstructor else 'unwrappedObj.ref()' })))
|
||||
if isConstructor:
|
||||
# If we're called via an xray, we need to enter the underlying
|
||||
# object's compartment and then wrap up all of our arguments into
|
||||
# that compartment as needed. This is all happening after we've
|
||||
# already done the conversions from JS values to WebIDL (C++)
|
||||
# values, so we only need to worry about cases where there are 'any'
|
||||
# or 'object' types, or other things that we represent as actual
|
||||
# JSAPI types, present. Effectively, we're emulating a
|
||||
# CrossCompartmentWrapper, but working with the C++ types, not the
|
||||
# original list of JS::Values.
|
||||
cgThings.append(CGGeneric("Maybe<JSAutoCompartment> ac;"))
|
||||
xraySteps.append(CGGeneric("ac.construct(cx, obj);"))
|
||||
xraySteps.extend(
|
||||
wrapArgIntoCurrentCompartment(arg, argname, isMember=False)
|
||||
for (arg, argname) in self.getArguments())
|
||||
|
||||
cgThings.append(
|
||||
CGIfWrapper(CGList(xraySteps, "\n"),
|
||||
"xpc::WrapperFactory::IsXrayWrapper(obj)"))
|
||||
|
@ -7936,9 +7964,7 @@ class CGDictionary(CGThing):
|
|||
def __init__(self, dictionary, descriptorProvider):
|
||||
self.dictionary = dictionary
|
||||
self.descriptorProvider = descriptorProvider
|
||||
self.workers = descriptorProvider.workers
|
||||
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||
self.needToInitIds = not self.workers and len(dictionary.members) > 0
|
||||
self.needToInitIds = len(dictionary.members) > 0
|
||||
self.memberInfo = [
|
||||
(member,
|
||||
getJSToNativeConversionInfo(
|
||||
|
@ -7962,9 +7988,7 @@ class CGDictionary(CGThing):
|
|||
def base(self):
|
||||
if self.dictionary.parent:
|
||||
return self.makeClassName(self.dictionary.parent)
|
||||
if not self.workers:
|
||||
return "MainThreadDictionaryBase"
|
||||
return "DictionaryBase"
|
||||
return "MainThreadDictionaryBase"
|
||||
|
||||
def initMethod(self):
|
||||
body = (
|
||||
|
@ -7973,10 +7997,17 @@ class CGDictionary(CGThing):
|
|||
"MOZ_ASSERT_IF(!cx, val.isNull());\n")
|
||||
|
||||
if self.needToInitIds:
|
||||
body += (
|
||||
"if (cx && !initedIds && !InitIds(cx)) {\n"
|
||||
" return false;\n"
|
||||
"}\n")
|
||||
initIdText = """${dictName}Atoms* atomsCache = nullptr;
|
||||
if (cx) {
|
||||
atomsCache = GetAtomCache<${dictName}Atoms>(cx);
|
||||
if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
body += string.Template(initIdText).substitute(
|
||||
{ "dictName": self.makeClassName(self.dictionary)})
|
||||
|
||||
if self.dictionary.parent:
|
||||
body += (
|
||||
|
@ -8014,10 +8045,10 @@ class CGDictionary(CGThing):
|
|||
], body=body)
|
||||
|
||||
def initFromJSONMethod(self):
|
||||
assert not self.workers
|
||||
return ClassMethod("Init", "bool", [
|
||||
Argument('const nsAString&', 'aJSON'),
|
||||
], body=(
|
||||
"MOZ_ASSERT(NS_IsMainThread());\n"
|
||||
"AutoSafeJSContext cx;\n"
|
||||
"JS::Rooted<JS::Value> json(cx);\n"
|
||||
"bool ok = ParseJSON(cx, aJSON, &json);\n"
|
||||
|
@ -8028,10 +8059,14 @@ class CGDictionary(CGThing):
|
|||
def toObjectMethod(self):
|
||||
body = ""
|
||||
if self.needToInitIds:
|
||||
body += (
|
||||
"if (!initedIds && !InitIds(cx)) {\n"
|
||||
" return false;\n"
|
||||
"}\n")
|
||||
initIdText = """${dictName}Atoms* atomsCache = GetAtomCache<${dictName}Atoms>(cx);
|
||||
if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
"""
|
||||
body += string.Template(initIdText).substitute(
|
||||
{ "dictName": self.makeClassName(self.dictionary)})
|
||||
|
||||
if self.dictionary.parent:
|
||||
body += (
|
||||
|
@ -8062,23 +8097,28 @@ class CGDictionary(CGThing):
|
|||
|
||||
def initIdsMethod(self):
|
||||
assert self.needToInitIds
|
||||
idinit = [CGGeneric('!InternJSString(cx, %s, "%s")' %
|
||||
idinit = [CGGeneric('!InternJSString(cx, atomsCache->%s, "%s")' %
|
||||
(m.identifier.name + "_id", m.identifier.name))
|
||||
for m in self.dictionary.members]
|
||||
idinit.reverse();
|
||||
idinit = CGList(idinit, " ||\n")
|
||||
idinit = CGWrapper(idinit, pre="if (",
|
||||
idinit = CGWrapper(idinit, pre="""
|
||||
// Initialize these in reverse order so that any failure leaves the first one
|
||||
// uninitialized.
|
||||
if (""",
|
||||
post=(") {\n"
|
||||
" return false;\n"
|
||||
"}"),
|
||||
reindent=True)
|
||||
body = (
|
||||
"MOZ_ASSERT(!initedIds);\n"
|
||||
"MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));\n"
|
||||
"%s\n"
|
||||
"initedIds = true;\n"
|
||||
"return true;") % idinit.define()
|
||||
|
||||
return ClassMethod("InitIds", "bool", [
|
||||
Argument("JSContext*", "cx"),
|
||||
Argument("%sAtoms*" % self.makeClassName(self.dictionary),
|
||||
"atomsCache"),
|
||||
], static=True, body=body, visibility="private")
|
||||
|
||||
def traceDictionaryMethod(self):
|
||||
|
@ -8110,16 +8150,9 @@ class CGDictionary(CGThing):
|
|||
|
||||
if self.needToInitIds:
|
||||
methods.append(self.initIdsMethod())
|
||||
members.append(ClassMember("initedIds", "bool", static=True, body="false"))
|
||||
members.extend(
|
||||
ClassMember(self.makeIdName(m.identifier.name), "jsid", static=True, body="JSID_VOID")
|
||||
for m in d.members)
|
||||
|
||||
methods.append(self.initMethod())
|
||||
|
||||
if not self.workers:
|
||||
methods.append(self.initFromJSONMethod())
|
||||
|
||||
methods.append(self.initFromJSONMethod())
|
||||
methods.append(self.toObjectMethod())
|
||||
methods.append(self.traceDictionaryMethod())
|
||||
|
||||
|
@ -8149,12 +8182,11 @@ class CGDictionary(CGThing):
|
|||
return self.dictionary.getDeps()
|
||||
|
||||
@staticmethod
|
||||
def makeDictionaryName(dictionary, workers):
|
||||
suffix = "Workers" if workers else ""
|
||||
return dictionary.identifier.name + suffix
|
||||
def makeDictionaryName(dictionary):
|
||||
return dictionary.identifier.name
|
||||
|
||||
def makeClassName(self, dictionary):
|
||||
return self.makeDictionaryName(dictionary, self.workers)
|
||||
return self.makeDictionaryName(dictionary)
|
||||
|
||||
@staticmethod
|
||||
def makeMemberName(name):
|
||||
|
@ -8185,15 +8217,9 @@ class CGDictionary(CGThing):
|
|||
if member.defaultValue:
|
||||
replacements["haveValue"] = "!isNull && !temp.ref().isUndefined()"
|
||||
|
||||
# NOTE: jsids are per-runtime, so don't use them in workers
|
||||
if self.workers:
|
||||
propName = member.identifier.name
|
||||
propGet = ('JS_GetProperty(cx, &val.toObject(), "%s", &temp.ref())' %
|
||||
propName)
|
||||
else:
|
||||
propId = self.makeIdName(member.identifier.name);
|
||||
propGet = ("JS_GetPropertyById(cx, &val.toObject(), %s, &temp.ref())" %
|
||||
propId)
|
||||
propId = self.makeIdName(member.identifier.name);
|
||||
propGet = ("JS_GetPropertyById(cx, &val.toObject(), atomsCache->%s, &temp.ref())" %
|
||||
propId)
|
||||
|
||||
conversionReplacements = {
|
||||
"prop": self.makeMemberName(member.identifier.name),
|
||||
|
@ -8229,14 +8255,9 @@ class CGDictionary(CGThing):
|
|||
# The data is inside the Optional<>
|
||||
memberData = "%s.InternalValue()" % memberLoc
|
||||
|
||||
if self.workers:
|
||||
propDef = (
|
||||
'JS_DefineProperty(cx, obj, "%s", temp, nullptr, nullptr, JSPROP_ENUMERATE)' %
|
||||
member.identifier.name)
|
||||
else:
|
||||
propDef = (
|
||||
'JS_DefinePropertyById(cx, obj, %s, temp, nullptr, nullptr, JSPROP_ENUMERATE)' %
|
||||
self.makeIdName(member.identifier.name))
|
||||
propDef = (
|
||||
'JS_DefinePropertyById(cx, obj, atomsCache->%s, temp, nullptr, nullptr, JSPROP_ENUMERATE)' %
|
||||
self.makeIdName(member.identifier.name))
|
||||
|
||||
innerTemplate = wrapForType(
|
||||
member.type, self.descriptorProvider,
|
||||
|
@ -8499,7 +8520,7 @@ class CGForwardDeclarations(CGWrapper):
|
|||
Code generate the forward declarations for a header file.
|
||||
"""
|
||||
def __init__(self, config, descriptors, mainCallbacks, workerCallbacks,
|
||||
mainDictionaries, workerDictionaries, callbackInterfaces):
|
||||
dictionaries, callbackInterfaces):
|
||||
builder = ForwardDeclarationBuilder()
|
||||
|
||||
def forwardDeclareForType(t, workerness='both'):
|
||||
|
@ -8550,13 +8571,11 @@ class CGForwardDeclarations(CGWrapper):
|
|||
for t in getTypesFromDescriptor(d):
|
||||
forwardDeclareForType(t)
|
||||
|
||||
for d in mainDictionaries:
|
||||
for d in dictionaries:
|
||||
if len(d.members) > 0:
|
||||
builder.addInMozillaDom(d.identifier.name + "Atoms", isStruct=True)
|
||||
for t in getTypesFromDictionary(d):
|
||||
forwardDeclareForType(t, workerness='mainthreadonly')
|
||||
|
||||
for d in workerDictionaries:
|
||||
for t in getTypesFromDictionary(d):
|
||||
forwardDeclareForType(t, workerness='workeronly')
|
||||
forwardDeclareForType(t)
|
||||
|
||||
CGWrapper.__init__(self, builder.build())
|
||||
|
||||
|
@ -8588,10 +8607,8 @@ class CGBindingRoot(CGThing):
|
|||
isEventTarget = webIDLFile.endswith("EventTarget.webidl")
|
||||
hasWorkerStuff = len(config.getDescriptors(webIDLFile=webIDLFile,
|
||||
workers=True)) != 0
|
||||
mainDictionaries = config.getDictionaries(webIDLFile=webIDLFile,
|
||||
workers=False)
|
||||
workerDictionaries = config.getDictionaries(webIDLFile=webIDLFile,
|
||||
workers=True)
|
||||
dictionaries = config.getDictionaries(webIDLFile=webIDLFile)
|
||||
requiresAtoms = any([len(dict.members) > 0 for dict in dictionaries])
|
||||
mainCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
|
||||
workers=False)
|
||||
workerCallbacks = config.getCallbacks(webIDLFile=webIDLFile,
|
||||
|
@ -8627,14 +8644,9 @@ class CGBindingRoot(CGThing):
|
|||
# here, because we have to generate these in order from least derived
|
||||
# to most derived so that class inheritance works out. We also have to
|
||||
# generate members before the dictionary that contains them.
|
||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider(True))
|
||||
for d in
|
||||
dependencySortObjects(workerDictionaries,
|
||||
CGDictionary.getDictionaryDependencies,
|
||||
lambda d: d.identifier.name)])
|
||||
cgthings.extend([CGDictionary(d, config.getDescriptorProvider(False))
|
||||
for d in
|
||||
dependencySortObjects(mainDictionaries,
|
||||
dependencySortObjects(dictionaries,
|
||||
CGDictionary.getDictionaryDependencies,
|
||||
lambda d: d.identifier.name)])
|
||||
|
||||
|
@ -8671,7 +8683,7 @@ class CGBindingRoot(CGThing):
|
|||
|
||||
curr = CGList([CGForwardDeclarations(config, descriptors,
|
||||
mainCallbacks, workerCallbacks,
|
||||
mainDictionaries, workerDictionaries,
|
||||
dictionaries,
|
||||
callbackDescriptors + jsImplemented),
|
||||
CGWrapper(CGGeneric("using namespace mozilla::dom;"),
|
||||
defineOnly=True),
|
||||
|
@ -8680,7 +8692,7 @@ class CGBindingRoot(CGThing):
|
|||
|
||||
# Add header includes.
|
||||
curr = CGHeaders(descriptors,
|
||||
mainDictionaries + workerDictionaries,
|
||||
dictionaries,
|
||||
mainCallbacks + workerCallbacks,
|
||||
callbackDescriptors,
|
||||
['mozilla/dom/BindingDeclarations.h',
|
||||
|
@ -8699,9 +8711,10 @@ class CGBindingRoot(CGThing):
|
|||
+ (['mozilla/Preferences.h'] if requiresPreferences else [])
|
||||
+ (['mozilla/dom/NonRefcountedDOMObject.h'] if hasOwnedDescriptors else [])
|
||||
+ (['nsContentUtils.h'] if requiresContentUtils else [])
|
||||
+ (['nsCxPusher.h'] if mainDictionaries else [])
|
||||
+ (['nsCxPusher.h'] if dictionaries else [])
|
||||
+ (['AccessCheck.h'] if hasChromeOnly else [])
|
||||
+ (['xpcprivate.h'] if isEventTarget else []),
|
||||
+ (['xpcprivate.h'] if isEventTarget else [])
|
||||
+ (['AtomList.h'] if requiresAtoms else []),
|
||||
prefix,
|
||||
curr,
|
||||
config,
|
||||
|
@ -8726,22 +8739,22 @@ class CGBindingRoot(CGThing):
|
|||
|
||||
class CGNativeMember(ClassMethod):
|
||||
def __init__(self, descriptorProvider, member, name, signature, extendedAttrs,
|
||||
breakAfter=True, passCxAsNeeded=True, visibility="public",
|
||||
breakAfter=True, passJSBitsAsNeeded=True, visibility="public",
|
||||
jsObjectsArePtr=False, variadicIsSequence=False):
|
||||
"""
|
||||
If jsObjectsArePtr is true, typed arrays and "object" will be
|
||||
passed as JSObject*.
|
||||
|
||||
If passCxAsNeeded is false, we don't automatically pass in a
|
||||
JSContext* based on the return and argument types. We can
|
||||
still pass it based on 'implicitJSContext' annotations.
|
||||
If passJSBitsAsNeeded is false, we don't automatically pass in a
|
||||
JSContext* or a JSObject* based on the return and argument types. We
|
||||
can still pass it based on 'implicitJSContext' annotations.
|
||||
"""
|
||||
self.descriptorProvider = descriptorProvider
|
||||
self.member = member
|
||||
self.extendedAttrs = extendedAttrs
|
||||
self.resultAlreadyAddRefed = isResultAlreadyAddRefed(self.descriptorProvider,
|
||||
self.extendedAttrs)
|
||||
self.passCxAsNeeded = passCxAsNeeded
|
||||
self.passJSBitsAsNeeded = passJSBitsAsNeeded
|
||||
self.jsObjectsArePtr = jsObjectsArePtr
|
||||
self.variadicIsSequence = variadicIsSequence
|
||||
breakAfterSelf = "\n" if breakAfter else ""
|
||||
|
@ -8902,14 +8915,15 @@ class CGNativeMember(ClassMethod):
|
|||
args.insert(0, Argument("JS::Value", "aThisVal"))
|
||||
# And jscontext bits.
|
||||
if needCx(returnType, argList, self.extendedAttrs,
|
||||
self.descriptorProvider, self.passCxAsNeeded):
|
||||
self.descriptorProvider, self.passJSBitsAsNeeded):
|
||||
args.insert(0, Argument("JSContext*", "cx"))
|
||||
if needScopeObject(returnType, argList, self.extendedAttrs,
|
||||
self.descriptorProvider, self.descriptorProvider,
|
||||
self.passJSBitsAsNeeded):
|
||||
args.insert(1, Argument("JS::Handle<JSObject*>", "obj"))
|
||||
# And if we're static, a global
|
||||
if self.member.isStatic():
|
||||
globalObjectType = "GlobalObject"
|
||||
if self.descriptorProvider.workers:
|
||||
globalObjectType = "Worker" + globalObjectType
|
||||
args.insert(0, Argument("const %s&" % globalObjectType, "global"))
|
||||
args.insert(0, Argument("const GlobalObject&", "global"))
|
||||
return args
|
||||
|
||||
def doGetArgType(self, type, optional, isMember):
|
||||
|
@ -9014,8 +9028,7 @@ class CGNativeMember(ClassMethod):
|
|||
return declType, False, False
|
||||
|
||||
if type.isDictionary():
|
||||
typeName = CGDictionary.makeDictionaryName(
|
||||
type.inner, self.descriptorProvider.workers)
|
||||
typeName = CGDictionary.makeDictionaryName(type.inner)
|
||||
return typeName, True, True
|
||||
|
||||
if type.isDate():
|
||||
|
@ -9354,7 +9367,7 @@ class CGJSImplMethod(CGNativeMember):
|
|||
descriptor.getExtendedAttributes(method),
|
||||
breakAfter=breakAfter,
|
||||
variadicIsSequence=True,
|
||||
passCxAsNeeded=False)
|
||||
passJSBitsAsNeeded=False)
|
||||
self.signature = signature
|
||||
self.descriptor = descriptor
|
||||
if isConstructor:
|
||||
|
@ -9432,7 +9445,7 @@ class CGJSImplGetter(CGNativeMember):
|
|||
(attr.type, []),
|
||||
descriptor.getExtendedAttributes(attr,
|
||||
getter=True),
|
||||
passCxAsNeeded=False)
|
||||
passJSBitsAsNeeded=False)
|
||||
self.body = self.getImpl()
|
||||
|
||||
def getImpl(self):
|
||||
|
@ -9448,7 +9461,7 @@ class CGJSImplSetter(CGNativeMember):
|
|||
[FakeArgument(attr.type, attr)]),
|
||||
descriptor.getExtendedAttributes(attr,
|
||||
setter=True),
|
||||
passCxAsNeeded=False)
|
||||
passJSBitsAsNeeded=False)
|
||||
self.body = self.getImpl()
|
||||
|
||||
def getImpl(self):
|
||||
|
@ -9599,7 +9612,7 @@ class CGJSImplClass(CGBindingImplClass):
|
|||
"if (global.Failed()) {\n"
|
||||
" return false;\n"
|
||||
"}\n"
|
||||
"nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());\n"
|
||||
"nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.GetAsSupports());\n"
|
||||
"if (!window) {\n"
|
||||
' return ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ${ifaceName}._create", "Window");\n'
|
||||
"}\n"
|
||||
|
@ -9793,7 +9806,7 @@ class CallbackMember(CGNativeMember):
|
|||
CGNativeMember.__init__(self, descriptorProvider, FakeMember(),
|
||||
name, (self.retvalType, args),
|
||||
extendedAttrs={},
|
||||
passCxAsNeeded=False,
|
||||
passJSBitsAsNeeded=False,
|
||||
visibility=visibility,
|
||||
jsObjectsArePtr=True)
|
||||
# We have to do all the generation of our body now, because
|
||||
|
@ -10142,6 +10155,54 @@ class GlobalGenRoots():
|
|||
call the appropriate define/declare method.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def GeneratedAtomList(config):
|
||||
# Atom enum
|
||||
dictionaries = config.dictionaries
|
||||
|
||||
structs = []
|
||||
|
||||
for dict in dictionaries:
|
||||
dictMembers = dict.members
|
||||
if len(dictMembers) == 0:
|
||||
continue
|
||||
|
||||
classMembers = [ClassMember(m.identifier.name + "_id",
|
||||
"jsid",
|
||||
visibility="public",
|
||||
body="JSID_VOID") for m in dictMembers]
|
||||
|
||||
structName = dict.identifier.name + "Atoms"
|
||||
structs.append((structName,
|
||||
CGWrapper(CGClass(structName,
|
||||
bases=None,
|
||||
isStruct=True,
|
||||
members=classMembers), post='\n')))
|
||||
|
||||
structs.sort()
|
||||
generatedStructs = [struct for (structName, struct) in structs]
|
||||
structNames = [structName for (structName, struct) in structs]
|
||||
|
||||
mainStruct = CGWrapper(CGClass("PerThreadAtomCache",
|
||||
bases=[ClassBase(structName) for structName in structNames],
|
||||
isStruct=True), post='\n')
|
||||
|
||||
structs = CGList(generatedStructs + [mainStruct])
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
curr = CGNamespace.build(['mozilla', 'dom'],
|
||||
CGWrapper(structs, pre='\n'))
|
||||
curr = CGWrapper(curr, post='\n')
|
||||
|
||||
# Add include guards.
|
||||
curr = CGIncludeGuard('GeneratedAtomList', curr)
|
||||
|
||||
# Add the auto-generated comment.
|
||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||
|
||||
# Done.
|
||||
return curr
|
||||
|
||||
@staticmethod
|
||||
def PrototypeList(config):
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ class Configuration:
|
|||
item.setUserData("mainThread", True)
|
||||
if item in worker:
|
||||
item.setUserData("workers", True)
|
||||
flagWorkerOrMainThread(self.dictionaries, mainDictionaries,
|
||||
workerDictionaries);
|
||||
flagWorkerOrMainThread(self.callbacks, mainCallbacks, workerCallbacks)
|
||||
|
||||
def getInterface(self, ifname):
|
||||
|
|
|
@ -63,6 +63,9 @@ def main():
|
|||
cPickle.dump(config, resultsFile, -1)
|
||||
resultsFile.close()
|
||||
|
||||
# Generate the atom list.
|
||||
generate_file(config, 'GeneratedAtomList', 'declare')
|
||||
|
||||
# Generate the prototype list.
|
||||
generate_file(config, 'PrototypeList', 'declare')
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ binding_cpp_files := $(subst .webidl,Binding.cpp,$(all_webidl_files))
|
|||
binding_dependency_trackers := $(subst .webidl,Binding,$(all_webidl_files))
|
||||
|
||||
globalgen_targets := \
|
||||
GeneratedAtomList.h \
|
||||
PrototypeList.h \
|
||||
RegisterBindings.h \
|
||||
RegisterBindings.cpp \
|
||||
|
|
|
@ -98,15 +98,34 @@ struct TypedArray : public TypedArray_base<T,UnboxArray> {
|
|||
|
||||
static inline JSObject*
|
||||
Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
|
||||
const T* data = NULL) {
|
||||
const T* data = nullptr) {
|
||||
JS::Rooted<JSObject*> creatorWrapper(cx);
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
|
||||
ac.construct(cx, creatorWrapper);
|
||||
}
|
||||
|
||||
return CreateCommon(cx, creatorWrapper, length, data);
|
||||
}
|
||||
|
||||
static inline JSObject*
|
||||
Create(JSContext* cx, JS::Handle<JSObject*> creator, uint32_t length,
|
||||
const T* data = nullptr) {
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
if (creator) {
|
||||
ac.construct(cx, creator);
|
||||
}
|
||||
|
||||
return CreateCommon(cx, creator, length, data);
|
||||
}
|
||||
|
||||
private:
|
||||
static inline JSObject*
|
||||
CreateCommon(JSContext* cx, JS::Handle<JSObject*> creator, uint32_t length,
|
||||
const T* data) {
|
||||
JSObject* obj = CreateNew(cx, length);
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (data) {
|
||||
T* buf = static_cast<T*>(GetData(obj));
|
||||
|
|
|
@ -11,6 +11,7 @@ EXPORTS.mozilla += [
|
|||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AtomList.h',
|
||||
'BindingDeclarations.h',
|
||||
'BindingUtils.h',
|
||||
'CallbackFunction.h',
|
||||
|
@ -20,6 +21,7 @@ EXPORTS.mozilla.dom += [
|
|||
'DOMJSProxyHandler.h',
|
||||
'Date.h',
|
||||
'Errors.msg',
|
||||
'GeneratedAtomList.h',
|
||||
'NonRefcountedDOMObject.h',
|
||||
'Nullable.h',
|
||||
'PrimitiveConversions.h',
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "BluetoothCommon.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "js/Value.h"
|
||||
|
||||
class nsIDOMDOMRequest;
|
||||
|
||||
|
|
|
@ -812,34 +812,17 @@ GetPropertiesInternal(const nsAString& aPath,
|
|||
return true;
|
||||
}
|
||||
|
||||
class GetPropertiesReplyHandler : public DBusReplyHandler
|
||||
{
|
||||
public:
|
||||
GetPropertiesReplyHandler(const nsCString& aIface)
|
||||
: mIface(aIface)
|
||||
{
|
||||
MOZ_ASSERT(!mIface.IsEmpty());
|
||||
}
|
||||
|
||||
const nsCString& GetInterface() const
|
||||
{
|
||||
return mIface;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCString mIface;
|
||||
};
|
||||
|
||||
class AppendDeviceNameReplyHandler: public GetPropertiesReplyHandler
|
||||
class AppendDeviceNameReplyHandler: public DBusReplyHandler
|
||||
{
|
||||
public:
|
||||
AppendDeviceNameReplyHandler(const nsCString& aIface,
|
||||
const nsString& aDevicePath,
|
||||
const BluetoothSignal& aSignal)
|
||||
: GetPropertiesReplyHandler(aIface)
|
||||
: mIface(aIface)
|
||||
, mDevicePath(aDevicePath)
|
||||
, mSignal(aSignal)
|
||||
{
|
||||
MOZ_ASSERT(!mIface.IsEmpty());
|
||||
MOZ_ASSERT(!mDevicePath.IsEmpty());
|
||||
}
|
||||
|
||||
|
@ -859,7 +842,7 @@ public:
|
|||
BluetoothValue deviceProperties;
|
||||
|
||||
bool success = UnpackPropertiesMessage(aReply, &err, deviceProperties,
|
||||
GetInterface().get());
|
||||
mIface.get());
|
||||
if (!success) {
|
||||
BT_WARNING("Failed to get device properties");
|
||||
return;
|
||||
|
@ -894,6 +877,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
nsCString mIface;
|
||||
nsString mDevicePath;
|
||||
BluetoothSignal mSignal;
|
||||
};
|
||||
|
@ -1805,46 +1789,119 @@ BluetoothDBusService::IsEnabledInternal()
|
|||
return mEnabled;
|
||||
}
|
||||
|
||||
class DefaultAdapterPropertiesRunnable : public nsRunnable
|
||||
class DefaultAdapterPathReplyHandler : public DBusReplyHandler
|
||||
{
|
||||
public:
|
||||
DefaultAdapterPropertiesRunnable(BluetoothReplyRunnable* aRunnable)
|
||||
: mRunnable(dont_AddRef(aRunnable))
|
||||
DefaultAdapterPathReplyHandler(BluetoothReplyRunnable* aRunnable)
|
||||
: mRunnable(aRunnable)
|
||||
{
|
||||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
nsresult Run()
|
||||
void Handle(DBusMessage* aReply) MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread
|
||||
|
||||
BluetoothValue v;
|
||||
nsAutoString replyError;
|
||||
if (!GetDefaultAdapterPath(v, replyError)) {
|
||||
DispatchBluetoothReply(mRunnable, v, replyError);
|
||||
return NS_ERROR_FAILURE;
|
||||
if (!aReply || (dbus_message_get_type(aReply) == DBUS_MESSAGE_TYPE_ERROR)) {
|
||||
const char* errStr = "Timeout in DefaultAdapterPathReplyHandler";
|
||||
if (aReply) {
|
||||
errStr = dbus_message_get_error_name(aReply);
|
||||
if (!errStr) {
|
||||
errStr = "Bluetooth DBus Error";
|
||||
}
|
||||
}
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(),
|
||||
NS_ConvertUTF8toUTF16(errStr));
|
||||
return;
|
||||
}
|
||||
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
bool success;
|
||||
nsAutoString replyError;
|
||||
|
||||
nsString objectPath = v.get_nsString();
|
||||
v = InfallibleTArray<BluetoothNamedValue>();
|
||||
if (!GetPropertiesInternal(objectPath, DBUS_ADAPTER_IFACE, v)) {
|
||||
NS_WARNING("Getting properties failed!");
|
||||
return NS_ERROR_FAILURE;
|
||||
if (mAdapterPath.IsEmpty()) {
|
||||
success = HandleDefaultAdapterPathReply(aReply, replyError);
|
||||
} else {
|
||||
success = HandleGetPropertiesReply(aReply, replyError);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
DispatchBluetoothReply(mRunnable, BluetoothValue(), replyError);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool HandleDefaultAdapterPathReply(DBusMessage* aReply,
|
||||
nsAString& aReplyError)
|
||||
{
|
||||
BluetoothValue value;
|
||||
DBusError error;
|
||||
dbus_error_init(&error);
|
||||
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread
|
||||
|
||||
UnpackObjectPathMessage(aReply, &error, value, aReplyError);
|
||||
|
||||
if (!aReplyError.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mAdapterPath = value.get_nsString();
|
||||
|
||||
// Acquire another reference to this reply handler
|
||||
nsRefPtr<DefaultAdapterPathReplyHandler> handler = this;
|
||||
|
||||
nsRefPtr<RawDBusConnection> threadConnection = gThreadConnection;
|
||||
|
||||
if (!threadConnection.get()) {
|
||||
aReplyError = NS_LITERAL_STRING("DBus connection has been closed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool success = dbus_func_args_async(threadConnection->GetConnection(), 1000,
|
||||
DefaultAdapterPathReplyHandler::Callback,
|
||||
handler.get(),
|
||||
NS_ConvertUTF16toUTF8(mAdapterPath).get(),
|
||||
DBUS_ADAPTER_IFACE, "GetProperties",
|
||||
DBUS_TYPE_INVALID);
|
||||
if (!success) {
|
||||
aReplyError = NS_LITERAL_STRING("dbus_func_args_async failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
handler.forget();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HandleGetPropertiesReply(DBusMessage* aReply,
|
||||
nsAutoString& aReplyError)
|
||||
{
|
||||
BluetoothValue value;
|
||||
DBusError error;
|
||||
dbus_error_init(&error);
|
||||
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // DBus thread
|
||||
|
||||
bool success = UnpackPropertiesMessage(aReply, &error, value,
|
||||
DBUS_ADAPTER_IFACE);
|
||||
if (!success) {
|
||||
aReplyError = NS_ConvertUTF8toUTF16(error.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have to manually attach the path to the rest of the elements
|
||||
v.get_ArrayOfBluetoothNamedValue().AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Path"), objectPath));
|
||||
value.get_ArrayOfBluetoothNamedValue().AppendElement(
|
||||
BluetoothNamedValue(NS_LITERAL_STRING("Path"), mAdapterPath));
|
||||
|
||||
DispatchBluetoothReply(mRunnable, v, replyError);
|
||||
// Dispatch result
|
||||
DispatchBluetoothReply(mRunnable, value, aReplyError);
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<BluetoothReplyRunnable> mRunnable;
|
||||
nsString mAdapterPath;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -1859,14 +1916,18 @@ BluetoothDBusService::GetDefaultAdapterPathInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothReplyRunnable> runnable = aRunnable;
|
||||
nsRefPtr<nsRunnable> func(new DefaultAdapterPropertiesRunnable(runnable));
|
||||
if (NS_FAILED(mBluetoothCommandThread->Dispatch(func, NS_DISPATCH_NORMAL))) {
|
||||
NS_WARNING("Cannot dispatch firmware loading task!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsRefPtr<DefaultAdapterPathReplyHandler> handler =
|
||||
new DefaultAdapterPathReplyHandler(aRunnable);
|
||||
bool success = dbus_func_args_async(mConnection, 1000,
|
||||
DefaultAdapterPathReplyHandler::Callback,
|
||||
handler.get(),
|
||||
"/",
|
||||
DBUS_MANAGER_IFACE, "DefaultAdapter",
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE(success, NS_ERROR_FAILURE);
|
||||
|
||||
handler.forget();
|
||||
|
||||
runnable.forget();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -658,6 +658,12 @@ ContactManager.prototype = {
|
|||
Services.DOMRequest.fireError(req, msg.errorMsg);
|
||||
}
|
||||
break;
|
||||
case "Contacts:GetAll:Return:KO":
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
Services.DOMRequest.fireError(req.cursor, msg.errorMsg);
|
||||
}
|
||||
break;
|
||||
case "PermissionPromptHelper:AskPermission:OK":
|
||||
if (DEBUG) debug("id: " + msg.requestID);
|
||||
req = this.getRequest(msg.requestID);
|
||||
|
@ -686,14 +692,14 @@ ContactManager.prototype = {
|
|||
if (DEBUG) debug("new revision: " + msg.revision);
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
Services.DOMRequest.fireSuccess(req, msg.revision);
|
||||
Services.DOMRequest.fireSuccess(req.request, msg.revision);
|
||||
}
|
||||
break;
|
||||
case "Contacts:Count":
|
||||
if (DEBUG) debug("count: " + msg.count);
|
||||
req = this.getRequest(msg.requestID);
|
||||
if (req) {
|
||||
Services.DOMRequest.fireSuccess(req, msg.count);
|
||||
Services.DOMRequest.fireSuccess(req.request, msg.count);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -871,8 +877,12 @@ ContactManager.prototype = {
|
|||
},
|
||||
|
||||
remove: function removeContact(aRecord) {
|
||||
let request;
|
||||
request = this.createRequest();
|
||||
let request = this.createRequest();
|
||||
if (!aRecord || !aRecord.id) {
|
||||
Services.DOMRequest.fireErrorAsync(request, true);
|
||||
return request;
|
||||
}
|
||||
|
||||
let options = { id: aRecord.id };
|
||||
let allowCallback = function() {
|
||||
cpmm.sendAsyncMessage("Contact:Remove", {requestID: this.getRequestId({request: request, reason: "remove"}), options: options});
|
||||
|
@ -898,7 +908,7 @@ ContactManager.prototype = {
|
|||
|
||||
let allowCallback = function() {
|
||||
cpmm.sendAsyncMessage("Contacts:GetRevision", {
|
||||
requestID: this.getRequestId(request)
|
||||
requestID: this.getRequestId({ request: request })
|
||||
});
|
||||
}.bind(this);
|
||||
|
||||
|
@ -915,7 +925,7 @@ ContactManager.prototype = {
|
|||
|
||||
let allowCallback = function() {
|
||||
cpmm.sendAsyncMessage("Contacts:GetCount", {
|
||||
requestID: this.getRequestId(request)
|
||||
requestID: this.getRequestId({ request: request })
|
||||
});
|
||||
}.bind(this);
|
||||
|
||||
|
@ -934,7 +944,8 @@ ContactManager.prototype = {
|
|||
"Contact:Remove:Return:OK", "Contact:Remove:Return:KO",
|
||||
"Contact:Changed",
|
||||
"PermissionPromptHelper:AskPermission:OK",
|
||||
"Contacts:GetAll:Next", "Contacts:Count",
|
||||
"Contacts:GetAll:Next", "Contacts:GetAll:Return:KO",
|
||||
"Contacts:Count",
|
||||
"Contacts:Revision", "Contacts:GetRevision:Return:KO",]);
|
||||
},
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ let ContactService = {
|
|||
throw e;
|
||||
}
|
||||
}.bind(this),
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Find:Return:KO", { requestID: msg.cursorId, errorMsg: aErrorMsg }); },
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:GetAll:Return:KO", { requestID: msg.cursorId, errorMsg: aErrorMsg }); },
|
||||
msg.findOptions, msg.cursorId);
|
||||
break;
|
||||
case "Contacts:GetAll:SendNow":
|
||||
|
@ -192,7 +192,9 @@ let ContactService = {
|
|||
mm.sendAsyncMessage("Contacts:Clear:Return:OK", { requestID: msg.requestID });
|
||||
this.broadcastMessage("Contact:Changed", { reason: "remove" });
|
||||
}.bind(this),
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Clear:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
function(aErrorMsg) {
|
||||
mm.sendAsyncMessage("Contacts:Clear:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg });
|
||||
}.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:GetRevision":
|
||||
|
@ -206,7 +208,9 @@ let ContactService = {
|
|||
revision: revision
|
||||
});
|
||||
},
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:GetRevision:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
function(aErrorMsg) {
|
||||
mm.sendAsyncMessage("Contacts:GetRevision:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg });
|
||||
}.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:GetCount":
|
||||
|
@ -220,7 +224,9 @@ let ContactService = {
|
|||
count: count
|
||||
});
|
||||
},
|
||||
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Count:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg }); }.bind(this)
|
||||
function(aErrorMsg) {
|
||||
mm.sendAsyncMessage("Contacts:Count:Return:KO", { requestID: msg.requestID, errorMsg: aErrorMsg });
|
||||
}.bind(this)
|
||||
);
|
||||
break;
|
||||
case "Contacts:RegisterForMessages":
|
||||
|
|
|
@ -158,6 +158,7 @@ function onUnwantedSuccess() {
|
|||
|
||||
function onFailure() {
|
||||
ok(false, "in on Failure!");
|
||||
next();
|
||||
}
|
||||
|
||||
function checkStr(str1, str2, msg) {
|
||||
|
@ -801,21 +802,25 @@ var steps = [
|
|||
},
|
||||
function () {
|
||||
ok(true, "Modifying contact1");
|
||||
findResult1.impp = properties1.impp = [{value:"phil impp"}];
|
||||
req = navigator.mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
var req2 = mozContacts.find({});
|
||||
req2.onsuccess = function() {
|
||||
is(req2.result.length, 1, "Found exactly 1 contact.");
|
||||
findResult2 = req2.result[0];
|
||||
ok(findResult2.id == sample_id1, "Same ID");
|
||||
checkContacts(findResult2, properties1);
|
||||
is(findResult2.impp.length, 1, "Found exactly 1 IMS info.");
|
||||
next();
|
||||
if (!findResult1) {
|
||||
SpecialPowers.executeSoon(next);
|
||||
} else {
|
||||
findResult1.impp = properties1.impp = [{value:"phil impp"}];
|
||||
req = navigator.mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
var req2 = mozContacts.find({});
|
||||
req2.onsuccess = function() {
|
||||
is(req2.result.length, 1, "Found exactly 1 contact.");
|
||||
findResult2 = req2.result[0];
|
||||
ok(findResult2.id == sample_id1, "Same ID");
|
||||
checkContacts(findResult2, properties1);
|
||||
is(findResult2.impp.length, 1, "Found exactly 1 IMS info.");
|
||||
next();
|
||||
};
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
req.onerror = onFailure;
|
||||
}
|
||||
},
|
||||
function() {
|
||||
// Android does not support published/updated fields. Skip this.
|
||||
|
@ -861,21 +866,25 @@ var steps = [
|
|||
},
|
||||
function () {
|
||||
ok(true, "Modifying contact2");
|
||||
findResult1.impp = properties1.impp = [{value: "phil impp"}];
|
||||
req = mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
var req2 = mozContacts.find({});
|
||||
req2.onsuccess = function () {
|
||||
is(req2.result.length, 1, "Found exactly 1 contact.");
|
||||
findResult1 = req2.result[0];
|
||||
ok(findResult1.id == sample_id1, "Same ID");
|
||||
checkContacts(findResult1, properties1);
|
||||
is(findResult1.impp.length, 1, "Found exactly 1 IMS info.");
|
||||
next();
|
||||
}
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
if (!findResult1) {
|
||||
SpecialPowers.executeSoon(next);
|
||||
} else {
|
||||
findResult1.impp = properties1.impp = [{value: "phil impp"}];
|
||||
req = mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
var req2 = mozContacts.find({});
|
||||
req2.onsuccess = function () {
|
||||
is(req2.result.length, 1, "Found exactly 1 contact.");
|
||||
findResult1 = req2.result[0];
|
||||
ok(findResult1.id == sample_id1, "Same ID");
|
||||
checkContacts(findResult1, properties1);
|
||||
is(findResult1.impp.length, 1, "Found exactly 1 IMS info.");
|
||||
next();
|
||||
}
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
}
|
||||
},
|
||||
function () {
|
||||
ok(true, "Searching contacts by query");
|
||||
|
@ -924,28 +933,32 @@ var steps = [
|
|||
},
|
||||
function () {
|
||||
ok(true, "Modifying contact3");
|
||||
findResult1.email = [{value: properties1.nickname}];
|
||||
findResult1.nickname = "TEST";
|
||||
var newContact = new mozContact();
|
||||
newContact.init(findResult1);
|
||||
req = mozContacts.save(newContact);
|
||||
req.onsuccess = function () {
|
||||
var options = {filterBy: ["email", "givenName"],
|
||||
filterOp: "startsWith",
|
||||
filterValue: properties1.givenName[0]};
|
||||
// One contact has it in nickname and the other in email
|
||||
var req2 = mozContacts.find(options);
|
||||
req2.onsuccess = function () {
|
||||
is(req2.result.length, 2, "Found exactly 2 contacts.");
|
||||
ok(req2.result[0].id != req2.result[1].id, "Different ID");
|
||||
next();
|
||||
}
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
if (!findResult1) {
|
||||
SpecialPowers.executeSoon(next);
|
||||
} else {
|
||||
findResult1.email = [{value: properties1.nickname}];
|
||||
findResult1.nickname = "TEST";
|
||||
var newContact = new mozContact();
|
||||
newContact.init(findResult1);
|
||||
req = mozContacts.save(newContact);
|
||||
req.onsuccess = function () {
|
||||
var options = {filterBy: ["email", "givenName"],
|
||||
filterOp: "startsWith",
|
||||
filterValue: properties1.givenName[0]};
|
||||
// One contact has it in nickname and the other in email
|
||||
var req2 = mozContacts.find(options);
|
||||
req2.onsuccess = function () {
|
||||
is(req2.result.length, 2, "Found exactly 2 contacts.");
|
||||
ok(req2.result[0].id != req2.result[1].id, "Different ID");
|
||||
next();
|
||||
}
|
||||
req2.onerror = onFailure;
|
||||
};
|
||||
req.onerror = onFailure;
|
||||
}
|
||||
},
|
||||
function () {
|
||||
ok(true, "Deleting contact" + findResult1.id);
|
||||
ok(true, "Deleting contact" + findResult1);
|
||||
req = mozContacts.remove(findResult1);
|
||||
req.onsuccess = function () {
|
||||
var req2 = mozContacts.find({});
|
||||
|
|
|
@ -111,6 +111,7 @@ function onUnwantedSuccess() {
|
|||
|
||||
function onFailure() {
|
||||
ok(false, "in on Failure!");
|
||||
next();
|
||||
}
|
||||
|
||||
function verifyBlob(blob1, blob2, isLast)
|
||||
|
|
|
@ -56,6 +56,7 @@ let properties1 = {
|
|||
|
||||
function onFailure() {
|
||||
ok(false, "in on Failure!");
|
||||
next();
|
||||
}
|
||||
|
||||
function checkStr(str1, str2, msg) {
|
||||
|
|
|
@ -37,6 +37,7 @@ var androidVersion = SpecialPowers.Cc['@mozilla.org/system-info;1']
|
|||
|
||||
function onFailure() {
|
||||
ok(false, "in on Failure!");
|
||||
next();
|
||||
}
|
||||
|
||||
var number1 = {
|
||||
|
@ -167,11 +168,15 @@ var steps = [
|
|||
},
|
||||
function() {
|
||||
ok(true, "Modifying number");
|
||||
findResult1.tel[0].value = number2.local;
|
||||
req = mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
next();
|
||||
};
|
||||
if (!findResult1) {
|
||||
SpecialPowers.executeSoon(next);
|
||||
} else {
|
||||
findResult1.tel[0].value = number2.local;
|
||||
req = mozContacts.save(findResult1);
|
||||
req.onsuccess = function () {
|
||||
next();
|
||||
};
|
||||
}
|
||||
},
|
||||
function () {
|
||||
ok(true, "Searching for local number");
|
||||
|
@ -225,7 +230,7 @@ var steps = [
|
|||
},
|
||||
function () {
|
||||
ok(true, "Deleting database");
|
||||
req = mozContacts.clear()
|
||||
req = mozContacts.clear();
|
||||
req.onsuccess = function () {
|
||||
ok(true, "Deleted the database");
|
||||
next();
|
||||
|
|
|
@ -44,6 +44,7 @@ var findResult1;
|
|||
|
||||
function onFailure() {
|
||||
ok(false, "in on Failure!");
|
||||
next();
|
||||
}
|
||||
|
||||
var prop = {
|
||||
|
|
|
@ -300,6 +300,7 @@ private:
|
|||
static mozilla::StaticRefPtr<VolumeNameCache> sVolumeNameCache;
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsString mLastStatus;
|
||||
void DispatchMountChangeEvent(nsAString& aVolumeStatus);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1261,14 +1261,27 @@ DeviceStorageFile::GetStatus(nsAString& aStatus)
|
|||
nsCOMPtr<nsIVolume> vol;
|
||||
nsresult rv = vs->GetVolumeByName(mStorageName, getter_AddRefs(vol));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (!vol) {
|
||||
return;
|
||||
}
|
||||
bool isMediaPresent;
|
||||
rv = vol->GetIsMediaPresent(&isMediaPresent);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (!isMediaPresent) {
|
||||
return;
|
||||
}
|
||||
bool isSharing;
|
||||
rv = vol->GetIsSharing(&isSharing);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (isSharing) {
|
||||
aStatus.AssignLiteral("shared");
|
||||
return;
|
||||
}
|
||||
int32_t volState;
|
||||
rv = vol->GetState(&volState);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (volState == nsIVolume::STATE_MOUNTED) {
|
||||
aStatus.AssignLiteral("available");
|
||||
} else if (volState == nsIVolume::STATE_SHARED ||
|
||||
volState == nsIVolume::STATE_SHAREDMNT) {
|
||||
aStatus.AssignLiteral("shared");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -3159,6 +3172,12 @@ nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath,
|
|||
void
|
||||
nsDOMDeviceStorage::DispatchMountChangeEvent(nsAString& aVolumeStatus)
|
||||
{
|
||||
if (aVolumeStatus == mLastStatus) {
|
||||
// We've already sent this status, don't bother sending it again.
|
||||
return;
|
||||
}
|
||||
mLastStatus = aVolumeStatus;
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMDeviceStorageChangeEvent(getter_AddRefs(event), this,
|
||||
nullptr, nullptr);
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace dom {
|
|||
static const PRUnichar kReplacementChar = static_cast<PRUnichar>(0xFFFD);
|
||||
|
||||
void
|
||||
TextDecoderBase::Init(const nsAString& aEncoding, const bool aFatal,
|
||||
ErrorResult& aRv)
|
||||
TextDecoder::Init(const nsAString& aEncoding, const bool aFatal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsAutoString label(aEncoding);
|
||||
EncodingUtils::TrimSpaceCharacters(label);
|
||||
|
@ -52,9 +52,9 @@ TextDecoderBase::Init(const nsAString& aEncoding, const bool aFatal,
|
|||
}
|
||||
|
||||
void
|
||||
TextDecoderBase::Decode(const char* aInput, const int32_t aLength,
|
||||
const bool aStream, nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv)
|
||||
TextDecoder::Decode(const char* aInput, const int32_t aLength,
|
||||
const bool aStream, nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aOutDecodedString.Truncate();
|
||||
|
||||
|
@ -101,16 +101,11 @@ TextDecoderBase::Decode(const char* aInput, const int32_t aLength,
|
|||
}
|
||||
|
||||
void
|
||||
TextDecoderBase::GetEncoding(nsAString& aEncoding)
|
||||
TextDecoder::GetEncoding(nsAString& aEncoding)
|
||||
{
|
||||
CopyASCIItoUTF16(mEncoding, aEncoding);
|
||||
nsContentUtils::ASCIIToLower(aEncoding);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextDecoder, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextDecoder, Release)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextDecoder, mGlobal)
|
||||
|
||||
} // dom
|
||||
} // mozilla
|
||||
|
|
|
@ -5,27 +5,29 @@
|
|||
#ifndef mozilla_dom_textdecoder_h_
|
||||
#define mozilla_dom_textdecoder_h_
|
||||
|
||||
#include "mozilla/dom/TextDecoderBase.h"
|
||||
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
||||
#include "mozilla/dom/TextDecoderBinding.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class TextDecoder MOZ_FINAL
|
||||
: public nsWrapperCache, public TextDecoderBase
|
||||
: public NonRefcountedDOMObject
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TextDecoder)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(TextDecoder)
|
||||
|
||||
// The WebIDL constructor.
|
||||
static already_AddRefed<TextDecoder>
|
||||
static TextDecoder*
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aEncoding,
|
||||
const TextDecoderOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsRefPtr<TextDecoder> txtDecoder = new TextDecoder(aGlobal.Get());
|
||||
nsAutoPtr<TextDecoder> txtDecoder(new TextDecoder());
|
||||
txtDecoder->Init(aEncoding, aOptions.mFatal, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
|
@ -33,46 +35,85 @@ public:
|
|||
return txtDecoder.forget();
|
||||
}
|
||||
|
||||
TextDecoder(nsISupports* aGlobal)
|
||||
: mGlobal(aGlobal)
|
||||
TextDecoder()
|
||||
: mFatal(false)
|
||||
{
|
||||
MOZ_ASSERT(aGlobal);
|
||||
SetIsDOMBinding();
|
||||
MOZ_COUNT_CTOR(TextDecoder);
|
||||
}
|
||||
|
||||
virtual
|
||||
~TextDecoder()
|
||||
{}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
|
||||
{
|
||||
return TextDecoderBinding::Wrap(aCx, aScope, this);
|
||||
MOZ_COUNT_DTOR(TextDecoder);
|
||||
}
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope,
|
||||
bool* aTookOwnership)
|
||||
{
|
||||
return TextDecoderBinding::Wrap(aCx, aScope, this, aTookOwnership);
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
GetParentObject()
|
||||
{
|
||||
return mGlobal;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates provided encoding and throws an exception if invalid encoding.
|
||||
* If no encoding is provided then mEncoding is default initialised to "utf-8".
|
||||
*
|
||||
* @param aEncoding Optional encoding (case insensitive) provided.
|
||||
* Default value is "utf-8" if no encoding is provided.
|
||||
* @param aFatal aFatal, indicates whether to throw an 'EncodingError'
|
||||
* exception or not.
|
||||
* @return aRv EncodingError exception else null.
|
||||
*/
|
||||
void Init(const nsAString& aEncoding, const bool aFatal, ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
* Return the encoding name.
|
||||
*
|
||||
* @param aEncoding, current encoding.
|
||||
*/
|
||||
void GetEncoding(nsAString& aEncoding);
|
||||
|
||||
/**
|
||||
* Decodes incoming byte stream of characters in charset indicated by
|
||||
* encoding.
|
||||
*
|
||||
* The encoding algorithm state is reset if aOptions.mStream is not set.
|
||||
*
|
||||
* If the fatal flag is set then a decoding error will throw EncodingError.
|
||||
* Else the decoder will return a decoded string with replacement
|
||||
* character(s) for unidentified character(s).
|
||||
*
|
||||
* @param aView, incoming byte stream of characters to be decoded to
|
||||
* to UTF-16 code points.
|
||||
* @param aOptions, indicates if streaming or not.
|
||||
* @param aOutDecodedString, decoded string of UTF-16 code points.
|
||||
* @param aRv, error result.
|
||||
*/
|
||||
void Decode(const char* aInput, const int32_t aLength,
|
||||
const bool aStream, nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void Decode(nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv) {
|
||||
TextDecoderBase::Decode(nullptr, 0, false,
|
||||
aOutDecodedString, aRv);
|
||||
Decode(nullptr, 0, false, aOutDecodedString, aRv);
|
||||
}
|
||||
|
||||
void Decode(const ArrayBufferView& aView,
|
||||
const TextDecodeOptions& aOptions,
|
||||
nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv) {
|
||||
TextDecoderBase::Decode(reinterpret_cast<char*>(aView.Data()),
|
||||
aView.Length(), aOptions.mStream,
|
||||
aOutDecodedString, aRv);
|
||||
Decode(reinterpret_cast<char*>(aView.Data()), aView.Length(),
|
||||
aOptions.mStream, aOutDecodedString, aRv);
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mGlobal;
|
||||
nsCString mEncoding;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
bool mFatal;
|
||||
};
|
||||
|
||||
} // dom
|
||||
|
|
|
@ -1,76 +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/. */
|
||||
|
||||
#ifndef mozilla_dom_textdecoderbase_h_
|
||||
#define mozilla_dom_textdecoderbase_h_
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class TextDecoderBase
|
||||
{
|
||||
public:
|
||||
TextDecoderBase()
|
||||
: mFatal(false)
|
||||
{}
|
||||
|
||||
virtual
|
||||
~TextDecoderBase()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Validates provided encoding and throws an exception if invalid encoding.
|
||||
* If no encoding is provided then mEncoding is default initialised to "utf-8".
|
||||
*
|
||||
* @param aEncoding Optional encoding (case insensitive) provided.
|
||||
* Default value is "utf-8" if no encoding is provided.
|
||||
* @param aFatal aFatal, indicates whether to throw an 'EncodingError'
|
||||
* exception or not.
|
||||
* @return aRv EncodingError exception else null.
|
||||
*/
|
||||
void Init(const nsAString& aEncoding, const bool aFatal, ErrorResult& aRv);
|
||||
|
||||
/**
|
||||
* Return the encoding name.
|
||||
*
|
||||
* @param aEncoding, current encoding.
|
||||
*/
|
||||
void GetEncoding(nsAString& aEncoding);
|
||||
|
||||
/**
|
||||
* Decodes incoming byte stream of characters in charset indicated by
|
||||
* encoding.
|
||||
*
|
||||
* The encoding algorithm state is reset if aOptions.mStream is not set.
|
||||
*
|
||||
* If the fatal flag is set then a decoding error will throw EncodingError.
|
||||
* Else the decoder will return a decoded string with replacement
|
||||
* character(s) for unidentified character(s).
|
||||
*
|
||||
* @param aView, incoming byte stream of characters to be decoded to
|
||||
* to UTF-16 code points.
|
||||
* @param aOptions, indicates if streaming or not.
|
||||
* @param aOutDecodedString, decoded string of UTF-16 code points.
|
||||
* @param aRv, error result.
|
||||
*/
|
||||
void Decode(const char* aInput, const int32_t aLength,
|
||||
const bool aStream, nsAString& aOutDecodedString,
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
nsCString mEncoding;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
|
||||
bool mFatal;
|
||||
};
|
||||
|
||||
} // dom
|
||||
} // mozilla
|
||||
|
||||
#endif // mozilla_dom_textdecoderbase_h_
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче