This commit is contained in:
Wes Kocher 2013-07-31 17:39:43 -07:00
Родитель 3b588f7b19 df5101f5fc
Коммит 085f7b9a5a
315 изменённых файлов: 3220 добавлений и 3319 удалений

Просмотреть файл

@ -1830,10 +1830,16 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert,
{
uint32_t updateFlags = eAccessible;
// If a focused node has been shown then it could mean its frame was recreated
// while the node stays focused and we need to fire focus event on
// the accessible we just created. If the queue contains a focus event for
// this node already then it will be suppressed by this one.
Accessible* focusedAcc = nullptr;
nsINode* node = aChild->GetNode();
if (aIsInsert) {
// Create accessible tree for shown accessible.
CacheChildrenInSubtree(aChild);
CacheChildrenInSubtree(aChild, &focusedAcc);
} else {
// Fire menupopup end event before hide event if a menu goes away.
@ -1870,16 +1876,6 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert,
updateFlags = eAlertAccessible;
FireDelayedEvent(nsIAccessibleEvent::EVENT_ALERT, aChild);
}
// If focused node has been shown then it means its frame was recreated
// while it's focused. Fire focus event on new focused accessible. If
// the queue contains focus event for this node then it's suppressed by
// this one.
// XXX: do we really want to send focus to focused DOM node not taking into
// account active item?
if (FocusMgr()->IsFocused(aChild))
FocusMgr()->DispatchFocusEvent(this, aChild);
} else {
// Update the tree for content removal.
// The accessible parent may differ from container accessible if
@ -1893,12 +1889,24 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert,
UncacheChildrenInSubtree(aChild);
}
// XXX: do we really want to send focus to focused DOM node not taking into
// account active item?
if (focusedAcc)
FocusMgr()->DispatchFocusEvent(this, focusedAcc);
return updateFlags;
}
void
DocAccessible::CacheChildrenInSubtree(Accessible* aRoot)
DocAccessible::CacheChildrenInSubtree(Accessible* aRoot,
Accessible** aFocusedAcc)
{
// If the accessible is focused then report a focus event after all related
// mutation events.
if (aFocusedAcc && !*aFocusedAcc &&
FocusMgr()->HasDOMFocus(aRoot->GetContent()))
*aFocusedAcc = aRoot;
aRoot->EnsureChildren();
// Make sure we create accessible tree defined in DOM only, i.e. if accessible
@ -1910,7 +1918,7 @@ DocAccessible::CacheChildrenInSubtree(Accessible* aRoot)
NS_ASSERTION(child, "Illicit tree change while tree is created!");
// Don't cross document boundaries.
if (child && child->IsContent())
CacheChildrenInSubtree(child);
CacheChildrenInSubtree(child, aFocusedAcc);
}
// Fire document load complete on ARIA documents.

Просмотреть файл

@ -449,8 +449,13 @@ protected:
/**
* Create accessible tree.
*
* @param aRoot [in] a root of subtree to create
* @param aFocusedAcc [in, optional] a focused accessible under created
* subtree if any
*/
void CacheChildrenInSubtree(Accessible* aRoot);
void CacheChildrenInSubtree(Accessible* aRoot,
Accessible** aFocusedAcc = nullptr);
/**
* Remove accessibles in subtree from node to accessible map.

Просмотреть файл

@ -55,7 +55,4 @@ exports.IDBKeyRange = IDBKeyRange;
exports.DOMException = Ci.nsIDOMDOMException;
exports.IDBCursor = Ci.nsIIDBCursor;
exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
exports.IDBDatabase = Ci.nsIIDBDatabase;
exports.IDBIndex = Ci.nsIIDBIndex;
exports.IDBObjectStore = Ci.nsIIDBObjectStore;
exports.IDBRequest = Ci.nsIIDBRequest;

Просмотреть файл

@ -9,7 +9,7 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) {
new function tests() {
const { indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBObjectStore, IDBRequest
IDBOpenDBRequest, IDBRequest
} = require("sdk/indexed-db");
exports["test indexedDB is frozen"] = function(assert){
@ -23,8 +23,7 @@ exports["test indexedDB is frozen"] = function(assert){
exports["test db variables"] = function(assert) {
[ indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBIndex,
IDBObjectStore, IDBRequest
IDBOpenDBRequest, IDBOpenDBRequest, IDBRequest
].forEach(function(value) {
assert.notEqual(typeof(value), "undefined", "variable is defined");
});

Просмотреть файл

@ -6406,7 +6406,7 @@ var gIdentityHandler = {
this._encryptionLabel[this.IDENTITY_MODE_MIXED_DISPLAY_LOADED] =
gNavigatorBundle.getString("identity.mixed_display_loaded");
this._encryptionLabel[this.IDENTITY_MODE_MIXED_ACTIVE_LOADED] =
gNavigatorBundle.getString("identity.mixed_active_loaded");
gNavigatorBundle.getString("identity.mixed_active_loaded2");
this._encryptionLabel[this.IDENTITY_MODE_MIXED_DISPLAY_LOADED_ACTIVE_BLOCKED] =
gNavigatorBundle.getString("identity.mixed_display_loaded_active_blocked");
return this._encryptionLabel;

Просмотреть файл

@ -260,7 +260,7 @@ identity.identified.state_and_country=%S, %S
identity.encrypted2=The connection to this website is secure.
identity.mixed_display_loaded=The connection to this website is not fully secure because it contains unencrypted elements (such as images).
identity.mixed_display_loaded_active_blocked=Interactive content (such as script) that isn't encrypted has been blocked for your protection.
identity.mixed_active_loaded=This website contains interactive content that isn't encrypted (such as scripts). Other people can view or modify the website's behavior.
identity.mixed_active_loaded2=This website contains interactive content that isn't encrypted (such as scripts). Other people can view your information or modify the website's behavior.
identity.unencrypted=Your connection to this website is not encrypted.
identity.unknown.tooltip=This website does not supply identity information.

Просмотреть файл

@ -86,3 +86,7 @@
margin-top: .5em;
margin-bottom: .5em;
}
#identity-popup-content-box {
max-width: 50ch;
}

Просмотреть файл

@ -3,18 +3,23 @@
# 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/.
from __future__ import unicode_literals
import subprocess
import sys
from os import path
from buildconfig import substs
import logging
log = logging.getLogger(__name__)
def determine_platform():
platform_mapping = {'WINNT': {'x86_64': 'win64',
'i386': 'win32'},
'i686': 'win32'},
'Darwin': {'x86_64': 'macosx-universal',
'i386':'macosx-universal'},
'Linux': {'x86_64': 'linux64',
'i386': 'linux32'}}
'i686': 'linux32'}}
os_type = substs['OS_TARGET']
cpu_type = substs['TARGET_CPU']
@ -37,17 +42,22 @@ def main():
release_mozconfig_path = path.join(browser_dir, 'config/mozconfigs', platform, 'release')
nightly_mozconfig_path = path.join(browser_dir, 'config/mozconfigs', platform, 'nightly')
# compare beta vs nightly
log.info("Comparing beta against nightly mozconfigs")
ret_code = subprocess.call([python_exe, script_path, '--whitelist',
whitelist_path, '--no-download',
platform + ',' + beta_mozconfig_path +
',' + nightly_mozconfig_path])
if ret_code > 0:
sys.exit(ret_code)
return ret_code
# compare release vs nightly
log.info("Comparing release against nightly mozconfigs")
ret_code = subprocess.call([python_exe, script_path, '--whitelist',
whitelist_path, '--no-download',
platform + ',' + release_mozconfig_path +
',' + nightly_mozconfig_path])
return ret_code
if __name__ == '__main__':
sys.exit(main())

Просмотреть файл

@ -1,19 +1,116 @@
#!/usr/bin/python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# originally from http://hg.mozilla.org/build/tools/file/4ab9c1a4e05b/scripts/release/compare-mozconfigs.py
from __future__ import unicode_literals
import logging
import os
import site
import sys
import urllib2
site.addsitedir(os.path.join(os.path.dirname(__file__), "../../lib/python"))
from release.sanity import verify_mozconfigs
from release.info import readConfig
from util.hg import make_hg_url
import difflib
FAILURE_CODE = 1
SUCCESS_CODE = 0
log = logging.getLogger(__name__)
class ConfigError(Exception):
pass
def make_hg_url(hgHost, repoPath, protocol='https', revision=None,
filename=None):
"""construct a valid hg url from a base hg url (hg.mozilla.org),
repoPath, revision and possible filename"""
base = '%s://%s' % (protocol, hgHost)
repo = '/'.join(p.strip('/') for p in [base, repoPath])
if not filename:
if not revision:
return repo
else:
return '/'.join([p.strip('/') for p in [repo, 'rev', revision]])
else:
assert revision
return '/'.join([p.strip('/') for p in [repo, 'raw-file', revision,
filename]])
def readConfig(configfile, keys=[], required=[]):
c = {}
execfile(configfile, c)
for k in keys:
c = c[k]
items = c.keys()
err = False
for key in required:
if key not in items:
err = True
log.error("Required item `%s' missing from %s" % (key, c))
if err:
raise ConfigError("Missing at least one item in config, see above")
return c
def verify_mozconfigs(mozconfig_pair, nightly_mozconfig_pair, platform,
mozconfigWhitelist={}):
"""Compares mozconfig to nightly_mozconfig and compare to an optional
whitelist of known differences. mozconfig_pair and nightly_mozconfig_pair
are pairs containing the mozconfig's identifier and the list of lines in
the mozconfig."""
# unpack the pairs to get the names, the names are just for
# identifying the mozconfigs when logging the error messages
mozconfig_name, mozconfig_lines = mozconfig_pair
nightly_mozconfig_name, nightly_mozconfig_lines = nightly_mozconfig_pair
missing_args = mozconfig_lines == [] or nightly_mozconfig_lines == []
if missing_args:
log.info("Missing mozconfigs to compare for %s" % platform)
return False
success = True
diff_instance = difflib.Differ()
diff_result = diff_instance.compare(mozconfig_lines, nightly_mozconfig_lines)
diff_list = list(diff_result)
for line in diff_list:
clean_line = line[1:].strip()
if (line[0] == '-' or line[0] == '+') and len(clean_line) > 1:
# skip comment lines
if clean_line.startswith('#'):
continue
# compare to whitelist
message = ""
if line[0] == '-':
if platform in mozconfigWhitelist.get('release', {}):
if clean_line in \
mozconfigWhitelist['release'][platform]:
continue
elif line[0] == '+':
if platform in mozconfigWhitelist.get('nightly', {}):
if clean_line in \
mozconfigWhitelist['nightly'][platform]:
continue
else:
log.warning("%s not in %s %s!" % (
clean_line, platform,
mozconfigWhitelist['nightly'][platform]))
else:
log.error("Skipping line %s!" % line)
continue
message = "found in %s but not in %s: %s"
if line[0] == '-':
log.error(message % (mozconfig_name,
nightly_mozconfig_name, clean_line))
else:
log.error(message % (nightly_mozconfig_name,
mozconfig_name, clean_line))
success = False
return success
def get_mozconfig(path, options):
"""Consumes a path and returns a list of lines from
the mozconfig file. If download is required, the path

Просмотреть файл

@ -77,7 +77,7 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext)
JS::Rooted<JSObject*> obj(cx, global);
JS::Rooted<JSObject*> proto(cx);
for (;;) {
MOZ_ALWAYS_TRUE(JS_GetPrototype(cx, obj, proto.address()));
MOZ_ALWAYS_TRUE(JS_GetPrototype(cx, obj, &proto));
if (!proto)
break;
obj = proto;

Просмотреть файл

@ -5242,7 +5242,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
// Check the proto chain for HTMLElement prototype.
JS::Rooted<JSObject*> protoProto(aCx);
if (!JS_GetPrototype(aCx, protoObject, protoProto.address())) {
if (!JS_GetPrototype(aCx, protoObject, &protoProto)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
@ -5250,7 +5250,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName,
if (protoProto == htmlProto) {
break;
}
if (!JS_GetPrototype(aCx, protoProto, protoProto.address())) {
if (!JS_GetPrototype(aCx, protoProto, &protoProto)) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}

Просмотреть файл

@ -3157,7 +3157,7 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx,
JS::Rooted<JSObject*> pi_obj(aCx);
JS::Rooted<JSObject*> pi_proto(aCx);
rv = GetPluginJSObject(aCx, obj, pi, pi_obj.address(), pi_proto.address());
rv = GetPluginJSObject(aCx, obj, pi, &pi_obj, &pi_proto);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return JS::UndefinedValue();
@ -3223,7 +3223,7 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx,
JS::Rooted<JSObject*> pi_obj(aCx); // XPConnect-wrapped peer object, when we get it.
JS::Rooted<JSObject*> pi_proto(aCx); // 'pi.__proto__'
rv = GetPluginJSObject(aCx, aObject, pi, pi_obj.address(), pi_proto.address());
rv = GetPluginJSObject(aCx, aObject, pi, &pi_obj, &pi_proto);
if (NS_FAILED(rv)) {
return;
}
@ -3310,21 +3310,18 @@ nsresult
nsObjectLoadingContent::GetPluginJSObject(JSContext *cx,
JS::Handle<JSObject*> obj,
nsNPAPIPluginInstance *plugin_inst,
JSObject **plugin_obj,
JSObject **plugin_proto)
JS::MutableHandle<JSObject*> plugin_obj,
JS::MutableHandle<JSObject*> plugin_proto)
{
*plugin_obj = nullptr;
*plugin_proto = nullptr;
// NB: We need an AutoEnterCompartment because we can be called from
// nsObjectFrame when the plugin loads after the JS object for our content
// node has been created.
JSAutoCompartment ac(cx, obj);
if (plugin_inst) {
plugin_inst->GetJSObject(cx, plugin_obj);
if (*plugin_obj) {
if (!::JS_GetPrototype(cx, *plugin_obj, plugin_proto)) {
plugin_inst->GetJSObject(cx, plugin_obj.address());
if (plugin_obj) {
if (!::JS_GetPrototype(cx, plugin_obj, plugin_proto)) {
return NS_ERROR_UNEXPECTED;
}
}
@ -3352,7 +3349,7 @@ nsObjectLoadingContent::TeardownProtoChain()
// all JS objects of the class sNPObjectJSWrapperClass
bool removed = false;
while (obj) {
if (!::JS_GetPrototype(cx, obj, proto.address())) {
if (!::JS_GetPrototype(cx, obj, &proto)) {
return;
}
if (!proto) {
@ -3362,7 +3359,7 @@ nsObjectLoadingContent::TeardownProtoChain()
// an NP object, that counts too.
if (JS_GetClass(js::UncheckedUnwrap(proto)) == &sNPObjectJSWrapperClass) {
// We found an NPObject on the proto chain, get its prototype...
if (!::JS_GetPrototype(cx, proto, proto.address())) {
if (!::JS_GetPrototype(cx, proto, &proto)) {
return;
}

Просмотреть файл

@ -481,8 +481,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
static nsresult GetPluginJSObject(JSContext *cx,
JS::Handle<JSObject*> obj,
nsNPAPIPluginInstance *plugin_inst,
JSObject **plugin_obj,
JSObject **plugin_proto);
JS::MutableHandle<JSObject*> plugin_obj,
JS::MutableHandle<JSObject*> plugin_proto);
// The final listener for mChannel (uriloader, pluginstreamlistener, etc.)
nsCOMPtr<nsIStreamListener> mFinalListener;

Просмотреть файл

@ -45,14 +45,12 @@ function checkWidth(element, x, y, w, h)
function run()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
// Set accept_languages to something we know
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var branch = prefService.getBranch("intl.");
var oldAcceptLanguages = branch.getCharPref("accept_languages");
branch.setCharPref("accept_languages", "en-gb,en,it");
SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en-gb,en,it"]]}, run1);
}
function run1()
{
try {
var doc = $("svg").contentDocument;
var s = doc.getElementById("s");
@ -93,7 +91,6 @@ function run()
checkWidth(s, 75, 100, 50, 50);
} finally {
branch.setCharPref("accept_languages", oldAcceptLanguages);
SimpleTest.finish();
}
}

Просмотреть файл

@ -765,7 +765,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
JS::Rooted<JSObject*> base(cx, scriptObject);
JS::Rooted<JSObject*> proto(cx);
for ( ; true; base = proto) { // Will break out on null proto
if (!JS_GetPrototype(cx, base, proto.address())) {
if (!JS_GetPrototype(cx, base, &proto)) {
return;
}
if (!proto) {
@ -799,7 +799,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen
// Alright! This is the right prototype. Pull it out of the
// proto chain.
JS::Rooted<JSObject*> grandProto(cx);
if (!JS_GetPrototype(cx, proto, grandProto.address())) {
if (!JS_GetPrototype(cx, proto, &grandProto)) {
return;
}
::JS_SetPrototype(cx, base, grandProto);
@ -899,7 +899,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle<JSObject*> global,
nsXBLJSClass* c = nullptr;
if (obj) {
// Retrieve the current prototype of obj.
if (!JS_GetPrototype(cx, obj, parent_proto.address())) {
if (!JS_GetPrototype(cx, obj, &parent_proto)) {
return NS_ERROR_FAILURE;
}
if (parent_proto) {

Просмотреть файл

@ -104,7 +104,7 @@ nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JS::Handle<JSObject*> obj,
// down on the proto chain.
JS::Rooted<JSObject*> base(cx, obj);
while (JS_GetClass(base) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
if (!::JS_GetPrototype(cx, base, base.address())) {
if (!::JS_GetPrototype(cx, base, &base)) {
return JS_FALSE;
}
if (!base) {

Просмотреть файл

@ -203,11 +203,8 @@
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBCursor.h"
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
#include "mozilla/dom/indexedDB/IDBIndex.h"
using mozilla::dom::indexedDB::IDBWrapperCache;
using mozilla::dom::workers::ResolveWorkerClasses;
@ -256,7 +253,6 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#include "DOMCameraCapabilities.h"
#include "nsIOpenWindowEventDetail.h"
#include "nsIAsyncScrollEventDetail.h"
#include "nsIDOMGlobalObjectConstructor.h"
#include "nsIDOMCanvasRenderingContext2D.h"
#include "LockedFile.h"
#include "nsDebug.h"
@ -637,18 +633,12 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
@ -1542,15 +1532,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
DOM_CLASSINFO_MAP_END
@ -1564,10 +1545,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)
@ -2178,7 +2155,7 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * aProto)
#ifdef DEBUG
JS::Rooted<JSObject*> proto2(cx);
JS_GetPrototype(cx, proto, proto2.address());
JS_GetPrototype(cx, proto, &proto2);
NS_ASSERTION(proto2 && JS_GetClass(proto2) == sObjectClass,
"Hmm, somebody did something evil?");
#endif
@ -2511,7 +2488,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JS::Handle<JSObject*> o
}
JS::Rooted<JSObject*> proto(cx);
if (!::JS_GetPrototype(cx, obj, proto.address())) {
if (!::JS_GetPrototype(cx, obj, &proto)) {
return JS_FALSE;
}
JSBool hasProp;
@ -2573,7 +2550,7 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
JS::Rooted<JSObject*> obj(cx, aObj);
for (;;) {
if (!::JS_GetPrototype(cx, obj, proto.address())) {
if (!::JS_GetPrototype(cx, obj, &proto)) {
return JS_FALSE;
}
if (!proto) {
@ -2583,7 +2560,7 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx,
if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
JS::Rooted<JSObject*> proto_proto(cx);
if (!::JS_GetPrototype(cx, proto, proto_proto.address())) {
if (!::JS_GetPrototype(cx, proto, &proto_proto)) {
return JS_FALSE;
}
@ -2615,7 +2592,7 @@ nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JS::Handle<JSObject*> obj)
// scope polluter (right before Object.prototype).
for (;;) {
if (!::JS_GetPrototype(cx, o, proto.address())) {
if (!::JS_GetPrototype(cx, o, &proto)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (!proto) {
@ -2729,8 +2706,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
}
nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));
nsCOMPtr<nsIDOMGlobalObjectConstructor> constructor(do_QueryInterface(native));
if (initializer || constructor) {
if (initializer) {
// Initialize object using the current inner window, but only if
// the caller can access it.
nsCOMPtr<nsPIDOMWindow> owner = do_QueryReferent(aWeakOwner);
@ -2743,62 +2719,9 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
return NS_ERROR_DOM_SECURITY_ERR;
}
if (initializer) {
rv = initializer->Initialize(currentInner, cx, obj, args);
if (NS_FAILED(rv)) {
return rv;
}
} else {
nsCOMPtr<nsIXPConnectWrappedJS> wrappedJS = do_QueryInterface(native);
JS::Rooted<JSObject*> thisObject(cx, wrappedJS->GetJSObject());
if (!thisObject) {
return NS_ERROR_UNEXPECTED;
}
nsCxPusher pusher;
pusher.Push(cx);
JSAutoCompartment ac(cx, thisObject);
JS::Rooted<JS::Value> funval(cx);
if (!JS_GetProperty(cx, thisObject, "constructor", &funval) ||
!funval.isObject()) {
return NS_ERROR_UNEXPECTED;
}
// Check if the object is even callable.
NS_ENSURE_STATE(JS_ObjectIsCallable(cx, &funval.toObject()));
{
// wrap parameters in the target compartment
// we also pass in the calling window as the first argument
unsigned argc = args.length() + 1;
nsAutoArrayPtr<JS::Value> argv(new JS::Value[argc]);
JS::AutoArrayRooter rooter(cx, 0, argv);
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsCOMPtr<nsIDOMWindow> currentWin(do_GetInterface(currentInner));
rv = WrapNative(cx, obj, currentWin, &NS_GET_IID(nsIDOMWindow),
true, &argv[0], getter_AddRefs(holder));
if (!JS_WrapValue(cx, &argv[0]))
return NS_ERROR_FAILURE;
rooter.changeLength(1);
for (size_t i = 1; i < argc; ++i) {
argv[i] = args[i - 1];
if (!JS_WrapValue(cx, &argv[i]))
return NS_ERROR_FAILURE;
rooter.changeLength(i + 1);
}
JS::Rooted<JS::Value> frval(cx);
bool ret = JS_CallFunctionValue(cx, thisObject, funval, argc, argv,
frval.address());
if (!ret) {
return NS_ERROR_FAILURE;
}
}
rv = initializer->Initialize(currentInner, cx, obj, args);
if (NS_FAILED(rv)) {
return rv;
}
}
@ -3271,7 +3194,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
JS::Rooted<JSObject*> proto(cx, dom_obj);
for (;;) {
if (!JS_GetPrototype(cx, proto, proto.address())) {
if (!JS_GetPrototype(cx, proto, &proto)) {
return NS_ERROR_UNEXPECTED;
}
if (!proto) {
@ -3633,7 +3556,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
if (dot_prototype) {
JSAutoCompartment ac(cx, dot_prototype);
JS::Rooted<JSObject*> xpc_proto_proto(cx);
if (!::JS_GetPrototype(cx, dot_prototype, xpc_proto_proto.address())) {
if (!::JS_GetPrototype(cx, dot_prototype, &xpc_proto_proto)) {
return NS_ERROR_UNEXPECTED;
}
@ -5255,7 +5178,7 @@ nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
}
JS::Rooted<JSObject*> proto(cx);
if (!::JS_GetPrototype(cx, realObj, proto.address())) {
if (!::JS_GetPrototype(cx, realObj, &proto)) {
return NS_ERROR_FAILURE;
}
JSBool hasProp;

Просмотреть файл

@ -120,12 +120,9 @@ DOMCI_CLASS(ChromeMessageBroadcaster)
DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(IDBRequest)
DOMCI_CLASS(IDBDatabase)
DOMCI_CLASS(IDBObjectStore)
DOMCI_CLASS(IDBCursor)
DOMCI_CLASS(IDBCursorWithValue)
DOMCI_CLASS(IDBKeyRange)
DOMCI_CLASS(IDBIndex)
DOMCI_CLASS(IDBOpenDBRequest)

Просмотреть файл

@ -2073,9 +2073,9 @@ nsGlobalWindow::SetOuterObject(JSContext* aCx, JS::Handle<JSObject*> aOuterObjec
js::SetDefaultObjectForContext(aCx, aOuterObject);
// Set up the prototype for the outer object.
JSObject* inner = JS_GetParent(aOuterObject);
JS::Rooted<JSObject*> inner(aCx, JS_GetParent(aOuterObject));
JS::Rooted<JSObject*> proto(aCx);
if (!JS_GetPrototype(aCx, inner, proto.address())) {
if (!JS_GetPrototype(aCx, inner, &proto)) {
return NS_ERROR_FAILURE;
}
JS_SetPrototype(aCx, aOuterObject, proto);
@ -2467,7 +2467,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// Now that both the the inner and outer windows are initialized
// let the script context do its magic to hook them together.
#ifdef DEBUG
JSObject* newInnerJSObject = newInnerWindow->FastGetGlobalJSObject();
JS::Rooted<JSObject*> newInnerJSObject(cx,
newInnerWindow->FastGetGlobalJSObject());
#endif
// Now that we're connecting the outer global to the inner one,
@ -2476,8 +2477,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
// so update that now since it might have changed.
js::SetDefaultObjectForContext(cx, mJSObject);
#ifdef DEBUG
JSObject *proto1, *proto2;
JS_GetPrototype(cx, mJSObject, &proto1);
JS::Rooted<JSObject*> rootedJSObject(cx, mJSObject);
JS::Rooted<JSObject*> proto1(cx), proto2(cx);
JS_GetPrototype(cx, rootedJSObject, &proto1);
JS_GetPrototype(cx, newInnerJSObject, &proto2);
NS_ASSERTION(proto1 == proto2,
"outer and inner globals should have the same prototype");
@ -6592,7 +6594,7 @@ nsGlobalWindow::CallerInnerWindow()
{
JSAutoCompartment ac(cx, scope);
JS::Rooted<JSObject*> scopeProto(cx);
bool ok = JS_GetPrototype(cx, scope, scopeProto.address());
bool ok = JS_GetPrototype(cx, scope, &scopeProto);
NS_ENSURE_TRUE(ok, nullptr);
if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) &&
(scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false)))

Просмотреть файл

@ -1755,7 +1755,7 @@ InterfaceHasInstance(JSContext* cx, JS::Handle<JSObject*> obj,
"Someone messed with our prototype property?");
JS::Rooted<JSObject*> proto(cx);
if (!JS_GetPrototype(cx, instance, proto.address())) {
if (!JS_GetPrototype(cx, instance, &proto)) {
return false;
}
@ -1765,7 +1765,7 @@ InterfaceHasInstance(JSContext* cx, JS::Handle<JSObject*> obj,
return true;
}
if (!JS_GetPrototype(cx, proto, proto.address())) {
if (!JS_GetPrototype(cx, proto, &proto)) {
return false;
}
}

Просмотреть файл

@ -538,6 +538,10 @@ DOMInterfaces = {
'nativeType' : 'mozilla::dom::HTMLSharedListElement'
},
'IDBDatabase': {
'nativeType': 'mozilla::dom::indexedDB::IDBDatabase',
},
'IDBFactory': {
'nativeType': 'mozilla::dom::indexedDB::IDBFactory',
},
@ -546,6 +550,22 @@ DOMInterfaces = {
'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle',
},
'IDBIndex': {
'nativeType': 'mozilla::dom::indexedDB::IDBIndex',
'binaryNames': {
'mozGetAll': 'getAll',
'mozGetAllKeys': 'getAllKeys',
}
},
'IDBObjectStore': {
'nativeType': 'mozilla::dom::indexedDB::IDBObjectStore',
'implicitJSContext': [ 'createIndex' ],
'binaryNames': {
'mozGetAll': 'getAll'
}
},
'IDBTransaction': {
'nativeType': 'mozilla::dom::indexedDB::IDBTransaction',
},
@ -1659,9 +1679,8 @@ addExternalIface('File')
addExternalIface('FileCallback', nativeType='nsIFileCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase')
addExternalIface('IDBObjectStore', nativeType='nsIIDBObjectStore')
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
addExternalIface('IDBRequest', nativeType='nsIIDBRequest')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LockedFile')

Просмотреть файл

@ -230,7 +230,7 @@ bool
DOMProxyHandler::enumerate(JSContext* cx, JS::Handle<JSObject*> proxy, AutoIdVector& props)
{
JS::Rooted<JSObject*> proto(cx);
if (!JS_GetPrototype(cx, proxy, proto.address())) {
if (!JS_GetPrototype(cx, proxy, &proto)) {
return false;
}
return getOwnPropertyNames(cx, proxy, props) &&

Просмотреть файл

@ -645,9 +645,6 @@ const KineticPanning = {
let momentums = this.momentums;
let flick = momentums[momentums.length - 1].time - momentums[0].time < 300;
// Calculate the panning based on the last moves.
momentums = momentums.slice(-kSamples);
let distance = new Point(0, 0);
momentums.forEach(function(momentum) {
distance.add(momentum.dx, momentum.dy);
@ -707,6 +704,12 @@ const KineticPanning = {
record: function kp_record(delta, timestamp) {
this.momentums.push({ 'time': this._getTime(timestamp),
'dx' : delta.x, 'dy' : delta.y });
// We only need to keep kSamples in this.momentums.
if (this.momentums.length > kSamples) {
this.momentums.shift();
}
this.distance.add(delta.x, delta.y);
},

Просмотреть файл

@ -173,7 +173,7 @@ AsyncConnectionHelper::~AsyncConnectionHelper()
if (mainThread) {
if (database) {
NS_ProxyRelease(mainThread, static_cast<nsIIDBDatabase*>(database));
NS_ProxyRelease(mainThread, static_cast<IDBWrapperCache*>(database));
}
if (transaction) {
NS_ProxyRelease(mainThread, static_cast<IDBWrapperCache*>(transaction));

Просмотреть файл

@ -273,26 +273,25 @@ IDBCursor::Create(IDBRequest* aRequest,
}
// static
nsresult
IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult)
IDBCursor::Direction
IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection)
{
if (aDirection.EqualsLiteral("next")) {
*aResult = NEXT;
switch (aDirection) {
case mozilla::dom::IDBCursorDirection::Next:
return NEXT;
case mozilla::dom::IDBCursorDirection::Nextunique:
return NEXT_UNIQUE;
case mozilla::dom::IDBCursorDirection::Prev:
return PREV;
case mozilla::dom::IDBCursorDirection::Prevunique:
return PREV_UNIQUE;
default:
MOZ_CRASH("Unknown direction!");
}
else if (aDirection.EqualsLiteral("nextunique")) {
*aResult = NEXT_UNIQUE;
}
else if (aDirection.EqualsLiteral("prev")) {
*aResult = PREV;
}
else if (aDirection.EqualsLiteral("prevunique")) {
*aResult = PREV_UNIQUE;
}
else {
return NS_ERROR_TYPE_ERR;
}
return NS_OK;
}
// static
@ -732,9 +731,12 @@ IDBCursor::Update(const jsval& aValue,
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
rv = mObjectStore->Put(aValue, JSVAL_VOID, aCx, 0, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx);
request = mObjectStore->Put(aCx, value, keyValue, error);
if (error.Failed()) {
return error.ErrorCode();
}
}
else {
@ -742,9 +744,12 @@ IDBCursor::Update(const jsval& aValue,
rv = objectKey.ToJSVal(aCx, &keyVal);
NS_ENSURE_SUCCESS(rv, rv);
rv = mObjectStore->Put(aValue, keyVal, aCx, 1, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx, keyVal);
request = mObjectStore->Put(aCx, value, keyValue, error);
if (error.Failed()) {
return error.ErrorCode();
}
}
@ -813,10 +818,10 @@ IDBCursor::Delete(JSContext* aCx,
nsresult rv = objectKey.ToJSVal(aCx, &key);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIIDBRequest> request;
rv = mObjectStore->Delete(key, aCx, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
nsCOMPtr<nsIIDBRequest> request = mObjectStore->Delete(aCx, key, error);
if (error.Failed()) {
return error.ErrorCode();
}
#ifdef IDB_PROFILER_USE_MARKS

Просмотреть файл

@ -8,13 +8,16 @@
#define mozilla_dom_indexeddb_idbcursor_h__
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/Key.h"
#include "nsIIDBCursorWithValue.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/Key.h"
class nsIRunnable;
class nsIScriptContext;
class nsPIDOMWindow;
@ -113,8 +116,8 @@ public:
return mRequest;
}
static nsresult ParseDirection(const nsAString& aDirection,
Direction* aResult);
static Direction
ConvertDirection(IDBCursorDirection aDirection);
void
SetActor(IndexedDBCursorChild* aActorChild)

Просмотреть файл

@ -43,6 +43,7 @@ using mozilla::dom::ContentParent;
using mozilla::dom::quota::AssertIsOnIOThread;
using mozilla::dom::quota::Client;
using mozilla::dom::quota::QuotaManager;
using mozilla::ErrorResult;
using namespace mozilla::dom;
namespace {
@ -238,6 +239,8 @@ IDBDatabase::IDBDatabase()
mRunningVersionChange(false)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
SetIsDOMBinding();
}
IDBDatabase::~IDBDatabase()
@ -401,10 +404,10 @@ IDBDatabase::OnUnlink()
}
}
nsresult
already_AddRefed<IDBObjectStore>
IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
const ObjectStoreInfoGuts& aInfo,
IDBObjectStore** _retval)
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aTransaction, "Null transaction!");
@ -419,7 +422,8 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
if (!databaseInfo->PutObjectStore(newInfo)) {
NS_WARNING("Put failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
// Don't leave this in the hash if we fail below!
@ -427,14 +431,22 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
nsRefPtr<IDBObjectStore> objectStore =
aTransaction->GetOrCreateObjectStore(newInfo->name, newInfo, true);
NS_ENSURE_TRUE(objectStore, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!objectStore) {
NS_WARNING("Failed to get objectStore!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (IndexedDatabaseManager::IsMainProcess()) {
nsRefPtr<CreateObjectStoreHelper> helper =
new CreateObjectStoreHelper(aTransaction, objectStore);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
}
autoRemove.forget();
@ -446,9 +458,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
IDB_PROFILER_STRING(aTransaction),
IDB_PROFILER_STRING(objectStore));
objectStore.forget(_retval);
return NS_OK;
return objectStore.forget();
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
@ -463,42 +473,29 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBDatabase)
NS_INTERFACE_MAP_ENTRY(nsIIDBDatabase)
NS_INTERFACE_MAP_ENTRY(nsIFileStorage)
NS_INTERFACE_MAP_ENTRY(nsIOfflineStorage)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBDatabase)
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)
DOMCI_DATA(IDBDatabase, IDBDatabase)
NS_IMPL_EVENT_HANDLER(IDBDatabase, abort)
NS_IMPL_EVENT_HANDLER(IDBDatabase, error)
NS_IMPL_EVENT_HANDLER(IDBDatabase, versionchange)
NS_IMETHODIMP
IDBDatabase::GetName(nsAString& aName)
JSObject*
IDBDatabase::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
return NS_OK;
return IDBDatabaseBinding::Wrap(aCx, aScope, this);
}
NS_IMETHODIMP
IDBDatabase::GetVersion(uint64_t* aVersion)
uint64_t
IDBDatabase::Version() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
DatabaseInfo* info = Info();
*aVersion = info->version;
return NS_OK;
return info->version;
}
NS_IMETHODIMP
IDBDatabase::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores)
already_AddRefed<nsIDOMDOMStringList>
IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -507,25 +504,28 @@ IDBDatabase::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores)
nsAutoTArray<nsString, 10> objectStoreNames;
if (!info->GetObjectStoreNames(objectStoreNames)) {
NS_WARNING("Couldn't get names!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
uint32_t count = objectStoreNames.Length();
for (uint32_t index = 0; index < count; index++) {
NS_ENSURE_TRUE(list->Add(objectStoreNames[index]),
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!list->Add(objectStoreNames[index])) {
NS_WARNING("Failed to add element");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
}
list.forget(aObjectStores);
return NS_OK;
return list.forget();
}
NS_IMETHODIMP
IDBDatabase::CreateObjectStore(const nsAString& aName,
const jsval& aOptions,
JSContext* aCx,
nsIIDBObjectStore** _retval)
already_AddRefed<IDBObjectStore>
IDBDatabase::CreateObjectStore(
JSContext* aCx, const nsAString& aName,
const IDBObjectStoreParameters& aOptionalParameters,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -533,28 +533,26 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
if (!transaction ||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr;
}
DatabaseInfo* databaseInfo = transaction->DBInfo();
RootedDictionary<IDBObjectStoreParameters> params(aCx);
JS::Rooted<JS::Value> options(aCx, aOptions);
if (!params.Init(aCx, options)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
KeyPath keyPath(0);
if (NS_FAILED(KeyPath::Parse(aCx, params.mKeyPath, &keyPath))) {
return NS_ERROR_DOM_SYNTAX_ERR;
if (NS_FAILED(KeyPath::Parse(aCx, aOptionalParameters.mKeyPath, &keyPath))) {
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return nullptr;
}
if (databaseInfo->ContainsStoreName(aName)) {
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR);
return nullptr;
}
if (!keyPath.IsAllowedForObjectStore(params.mAutoIncrement)) {
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
if (!keyPath.IsAllowedForObjectStore(aOptionalParameters.mAutoIncrement)) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return nullptr;
}
ObjectStoreInfoGuts guts;
@ -562,19 +560,13 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
guts.name = aName;
guts.id = databaseInfo->nextObjectStoreId++;
guts.keyPath = keyPath;
guts.autoIncrement = params.mAutoIncrement;
guts.autoIncrement = aOptionalParameters.mAutoIncrement;
nsRefPtr<IDBObjectStore> objectStore;
nsresult rv = CreateObjectStoreInternal(transaction, guts,
getter_AddRefs(objectStore));
NS_ENSURE_SUCCESS(rv, rv);
objectStore.forget(_retval);
return NS_OK;
return CreateObjectStoreInternal(transaction, guts, aRv);
}
NS_IMETHODIMP
IDBDatabase::DeleteObjectStore(const nsAString& aName)
void
IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -582,23 +574,27 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName)
if (!transaction ||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return;
}
DatabaseInfo* info = transaction->DBInfo();
ObjectStoreInfo* objectStoreInfo = info->GetObjectStore(aName);
if (!objectStoreInfo) {
return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR);
return;
}
nsresult rv;
if (IndexedDatabaseManager::IsMainProcess()) {
nsRefPtr<DeleteObjectStoreHelper> helper =
new DeleteObjectStoreHelper(transaction, objectStoreInfo->id);
rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return;
}
}
else {
IndexedDBTransactionChild* actor = transaction->GetActorChild();
@ -615,188 +611,114 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName)
IDB_PROFILER_STRING(this),
IDB_PROFILER_STRING(transaction),
NS_ConvertUTF16toUTF8(aName).get());
return NS_OK;
}
NS_IMETHODIMP
IDBDatabase::Transaction(const jsval& aStoreNames,
const nsAString& aMode,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsISupports** _retval)
already_AddRefed<indexedDB::IDBTransaction>
IDBDatabase::Transaction(const Sequence<nsString>& aStoreNames,
IDBTransactionMode aMode, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (QuotaManager::IsShuttingDown()) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (mClosed) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr;
}
if (mRunningVersionChange) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr;
}
if (aStoreNames.IsEmpty()) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return nullptr;
}
IDBTransaction::Mode transactionMode = IDBTransaction::READ_ONLY;
if (aOptionalArgCount) {
if (aMode.EqualsLiteral("readwrite")) {
switch (aMode) {
case IDBTransactionMode::Readonly:
transactionMode = IDBTransaction::READ_ONLY;
break;
case IDBTransactionMode::Readwrite:
transactionMode = IDBTransaction::READ_WRITE;
}
else if (!aMode.EqualsLiteral("readonly")) {
return NS_ERROR_TYPE_ERR;
}
}
nsresult rv;
nsTArray<nsString> storesToOpen;
if (!JSVAL_IS_PRIMITIVE(aStoreNames)) {
JS::Rooted<JSObject*> obj(aCx, JSVAL_TO_OBJECT(aStoreNames));
// See if this is a JS array.
if (JS_IsArrayObject(aCx, obj)) {
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (!length) {
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
storesToOpen.SetCapacity(length);
for (uint32_t index = 0; index < length; index++) {
JS::Rooted<JS::Value> val(aCx);
JSString* jsstr;
nsDependentJSString str;
if (!JS_GetElement(aCx, obj, index, val.address()) ||
!(jsstr = JS_ValueToString(aCx, val)) ||
!str.init(aCx, jsstr)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
storesToOpen.AppendElement(str);
}
NS_ASSERTION(!storesToOpen.IsEmpty(),
"Must have something here or else code below will "
"misbehave!");
}
else {
// Perhaps some kind of wrapped object?
nsIXPConnect* xpc = nsContentUtils::XPConnect();
NS_ASSERTION(xpc, "This should never be null!");
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
rv = xpc->GetWrappedNativeOfJSObject(aCx, obj, getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (wrapper) {
nsISupports* wrappedObject = wrapper->Native();
NS_ENSURE_TRUE(wrappedObject, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// We only accept DOMStringList.
nsCOMPtr<nsIDOMDOMStringList> list = do_QueryInterface(wrappedObject);
if (list) {
uint32_t length;
rv = list->GetLength(&length);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!length) {
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
storesToOpen.SetCapacity(length);
for (uint32_t index = 0; index < length; index++) {
nsString* item = storesToOpen.AppendElement();
NS_ASSERTION(item, "This should never fail!");
rv = list->Item(index, *item);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
NS_ASSERTION(!storesToOpen.IsEmpty(),
"Must have something here or else code below will "
"misbehave!");
}
}
}
}
// If our list is empty here then the argument must have been an object that
// we don't support or a primitive. Either way we convert to a string.
if (storesToOpen.IsEmpty()) {
JSString* jsstr;
nsDependentJSString str;
if (!(jsstr = JS_ValueToString(aCx, aStoreNames)) ||
!str.init(aCx, jsstr)) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
storesToOpen.AppendElement(str);
break;
case IDBTransactionMode::Versionchange:
transactionMode = IDBTransaction::VERSION_CHANGE;
break;
default:
MOZ_CRASH("Unknown mode!");
}
// Now check to make sure the object store names we collected actually exist.
DatabaseInfo* info = Info();
for (uint32_t index = 0; index < storesToOpen.Length(); index++) {
if (!info->ContainsStoreName(storesToOpen[index])) {
return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR;
for (uint32_t index = 0; index < aStoreNames.Length(); index++) {
if (!info->ContainsStoreName(aStoreNames[index])) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR);
return nullptr;
}
}
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(this, storesToOpen, transactionMode, false);
NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDBTransaction::Create(this, aStoreNames, transactionMode, false);
if (!transaction) {
NS_WARNING("Failed to create the transaction!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Transaction %llu: database(%s).transaction(%s)",
"IDBTransaction[%llu] MT Started",
transaction->GetSerialNumber(), IDB_PROFILER_STRING(this),
IDB_PROFILER_STRING(transaction));
nsRefPtr<IDBWrapperCache> tmp = transaction.get();
tmp.forget(_retval);
return NS_OK;
return transaction.forget();
}
NS_IMETHODIMP
already_AddRefed<IDBRequest>
IDBDatabase::MozCreateFileHandle(const nsAString& aName,
const nsAString& aType,
JSContext* aCx,
nsIIDBRequest** _retval)
const Optional<nsAString>& aType,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!IndexedDatabaseManager::IsMainProcess()) {
NS_WARNING("Not supported yet!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (QuotaManager::IsShuttingDown()) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (mClosed) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = IDBRequest::Create(nullptr, this, nullptr);
nsRefPtr<CreateFileHelper> helper =
new CreateFileHelper(this, request, aName, aType);
new CreateFileHelper(this, request, aName,
aType.WasPassed() ? aType.Value() : EmptyString());
QuotaManager* quotaManager = QuotaManager::Get();
NS_ASSERTION(quotaManager, "We should definitely have a manager here");
nsresult rv = helper->Dispatch(quotaManager->IOThread());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
request.forget(_retval);
return NS_OK;
return request.forget();
}
NS_IMETHODIMP
@ -807,6 +729,7 @@ IDBDatabase::Close()
CloseInternal(false);
NS_ASSERTION(mClosed, "Should have set the closed flag!");
return NS_OK;
}

Просмотреть файл

@ -7,17 +7,19 @@
#ifndef mozilla_dom_indexeddb_idbdatabase_h__
#define mozilla_dom_indexeddb_idbdatabase_h__
#include "mozilla/Attributes.h"
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "nsIDocument.h"
#include "nsIFileStorage.h"
#include "nsIIDBDatabase.h"
#include "nsIOfflineStorage.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/IDBObjectStoreBinding.h"
#include "mozilla/dom/IDBTransactionBinding.h"
#include "nsDOMEventTargetHelper.h"
#include "mozilla/dom/indexedDB/FileManager.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
class nsIScriptContext;
@ -46,7 +48,6 @@ class IndexedDBDatabaseParent;
struct ObjectStoreInfoGuts;
class IDBDatabase : public IDBWrapperCache,
public nsIIDBDatabase,
public nsIOfflineStorage
{
friend class AsyncConnectionHelper;
@ -55,9 +56,8 @@ class IDBDatabase : public IDBWrapperCache,
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIIDBDATABASE
NS_DECL_NSIFILESTORAGE
NS_DECL_NSIOFFLINESTORAGE_NOCLOSE
NS_DECL_NSIOFFLINESTORAGE
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, IDBWrapperCache)
@ -156,10 +156,63 @@ public:
return mContentParent;
}
nsresult
already_AddRefed<IDBObjectStore>
CreateObjectStoreInternal(IDBTransaction* aTransaction,
const ObjectStoreInfoGuts& aInfo,
IDBObjectStore** _retval);
ErrorResult& aRv);
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
nsPIDOMWindow*
GetParentObject() const
{
return GetOwner();
}
void
GetName(nsString& aName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
}
uint64_t
Version() const;
already_AddRefed<nsIDOMDOMStringList>
GetObjectStoreNames(ErrorResult& aRv) const;
already_AddRefed<IDBObjectStore>
CreateObjectStore(JSContext* aCx, const nsAString& aName,
const IDBObjectStoreParameters& aOptionalParameters,
ErrorResult& aRv);
void
DeleteObjectStore(const nsAString& name, ErrorResult& aRv);
already_AddRefed<indexedDB::IDBTransaction>
Transaction(const nsAString& aStoreName, IDBTransactionMode aMode,
ErrorResult& aRv)
{
Sequence<nsString> list;
list.AppendElement(aStoreName);
return Transaction(list, aMode, aRv);
}
already_AddRefed<indexedDB::IDBTransaction>
Transaction(const Sequence<nsString>& aStoreNames, IDBTransactionMode aMode,
ErrorResult& aRv);
IMPL_EVENT_HANDLER(abort)
IMPL_EVENT_HANDLER(error)
IMPL_EVENT_HANDLER(versionchange)
already_AddRefed<IDBRequest>
MozCreateFileHandle(const nsAString& aName, const Optional<nsAString>& aType,
ErrorResult& aRv);
virtual void LastRelease() MOZ_OVERRIDE;
private:

Просмотреть файл

@ -106,7 +106,7 @@ IDBFileHandle::CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile,
return file.forget();
}
nsIIDBDatabase*
IDBDatabase*
IDBFileHandle::Database()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

Просмотреть файл

@ -12,10 +12,10 @@
#include "mozilla/dom/file/FileHandle.h"
#include "mozilla/dom/indexedDB/FileInfo.h"
class nsIIDBDatabase;
BEGIN_INDEXEDDB_NAMESPACE
class IDBDatabase;
class IDBFileHandle : public mozilla::dom::file::FileHandle
{
public:
@ -45,7 +45,8 @@ public:
CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile,
uint32_t aFileSize);
nsIIDBDatabase* Database();
IDBDatabase*
Database();
private:
IDBFileHandle()

Просмотреть файл

@ -15,7 +15,6 @@
#include "mozilla/dom/ipc/Blob.h"
#include "mozilla/storage.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfoID.h"
#include "nsEventDispatcher.h"
#include "nsThreadUtils.h"
#include "xpcpublic.h"
@ -37,6 +36,7 @@
USING_INDEXEDDB_NAMESPACE
using namespace mozilla::dom;
using namespace mozilla::dom::indexedDB::ipc;
using mozilla::ErrorResult;
namespace {
@ -406,6 +406,8 @@ IDBIndex::IDBIndex()
mRooted(false)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
SetIsDOMBinding();
}
IDBIndex::~IDBIndex()
@ -425,26 +427,33 @@ IDBIndex::~IDBIndex()
}
}
nsresult
IDBIndex::GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetHelper> helper =
new GetHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -457,30 +466,36 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetKeyHelper> helper =
new GetKeyHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -493,31 +508,37 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetAllHelper> helper =
new GetAllHelper(transaction, request, this, aKeyRange, aLimit);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -531,31 +552,36 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this),
IDB_PROFILER_STRING(aKeyRange), aLimit);
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetAllKeysHelper> helper =
new GetAllKeysHelper(transaction, request, this, aKeyRange, aLimit);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -569,30 +595,36 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
aLimit);
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<CountHelper> helper =
new CountHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -605,34 +637,40 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
IDBCursor::Direction direction =
static_cast<IDBCursor::Direction>(aDirection);
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<OpenKeyCursorHelper> helper =
new OpenKeyCursorHelper(transaction, request, this, aKeyRange, direction);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -646,8 +684,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
IDB_PROFILER_STRING(direction));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
@ -751,6 +788,7 @@ IDBIndex::OpenCursorFromChildProcess(
}
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mCachedKeyPath)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
@ -760,6 +798,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
// Don't unlink mObjectStore!
tmp->mCachedKeyPath = JSVAL_VOID;
@ -771,315 +811,222 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBIndex)
NS_INTERFACE_MAP_ENTRY(nsIIDBIndex)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBIndex)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBIndex)
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBIndex)
DOMCI_DATA(IDBIndex, IDBIndex)
NS_IMETHODIMP
IDBIndex::GetName(nsAString& aName)
JSObject*
IDBIndex::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
return NS_OK;
return IDBIndexBinding::Wrap(aCx, aScope, this);
}
NS_IMETHODIMP
IDBIndex::GetStoreName(nsAString& aStoreName)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mObjectStore->GetName(aStoreName);
}
NS_IMETHODIMP
IDBIndex::GetKeyPath(JSContext* aCx,
jsval* aVal)
JS::Value
IDBIndex::GetKeyPath(JSContext* aCx, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!JSVAL_IS_VOID(mCachedKeyPath)) {
*aVal = mCachedKeyPath;
return NS_OK;
return mCachedKeyPath;
}
nsresult rv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
NS_ENSURE_SUCCESS(rv, rv);
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID);
if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
NS_HOLD_JS_OBJECTS(this, IDBIndex);
mRooted = true;
}
*aVal = mCachedKeyPath;
return NS_OK;
return mCachedKeyPath;
}
NS_IMETHODIMP
IDBIndex::GetUnique(bool* aUnique)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
*aUnique = mUnique;
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::GetMultiEntry(bool* aMultiEntry)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
*aMultiEntry = mMultiEntry;
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::GetObjectStore(nsIIDBObjectStore** aObjectStore)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIIDBObjectStore> objectStore(mObjectStore);
objectStore.forget(aObjectStore);
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::Get(const jsval& aKey,
JSContext* aCx,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
if (!keyRange) {
// Must specify a key or keyRange for getKey().
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
return nullptr;
}
return GetInternal(keyRange, aRv);
}
already_AddRefed<IDBRequest>
IDBIndex::GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
if (!keyRange) {
// Must specify a key or keyRange for get().
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request;
rv = GetInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return GetKeyInternal(keyRange, aRv);
}
NS_IMETHODIMP
IDBIndex::GetKey(const jsval& aKey,
JSContext* aCx,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (!keyRange) {
// Must specify a key or keyRange for get().
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = GetKeyInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
limit = aLimit.Value();
}
request.forget(_retval);
return NS_OK;
return GetAllInternal(keyRange, limit, aRv);
}
NS_IMETHODIMP
IDBIndex::GetAll(const jsval& aKey,
uint32_t aLimit,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllKeys(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
if (aOptionalArgCount < 2 || aLimit == 0) {
aLimit = UINT32_MAX;
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
limit = aLimit.Value();
}
nsRefPtr<IDBRequest> request;
rv = GetAllInternal(keyRange, aLimit, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return GetAllKeysInternal(keyRange, limit, aRv);
}
NS_IMETHODIMP
IDBIndex::GetAllKeys(const jsval& aKey,
uint32_t aLimit,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
if (aOptionalArgCount < 2 || aLimit == 0) {
aLimit = UINT32_MAX;
}
nsRefPtr<IDBRequest> request;
rv = GetAllKeysInternal(keyRange, aLimit, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::OpenCursor(const jsval& aKey,
const nsAString& aDirection,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
IDBCursor::Direction direction = IDBCursor::NEXT;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aOptionalArgCount >= 2) {
rv = IDBCursor::ParseDirection(aDirection, &direction);
NS_ENSURE_SUCCESS(rv, rv);
}
}
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<OpenCursorHelper> helper =
new OpenCursorHelper(transaction, request, this, keyRange, direction);
rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
request.forget(_retval);
return NS_OK;
return request.forget();
}
NS_IMETHODIMP
IDBIndex::OpenKeyCursor(const jsval& aKey,
const nsAString& aDirection,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenKeyCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
IDBCursor::Direction direction = IDBCursor::NEXT;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aOptionalArgCount >= 2) {
rv = IDBCursor::ParseDirection(aDirection, &direction);
NS_ENSURE_SUCCESS(rv, rv);
}
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = OpenKeyCursorInternal(keyRange, direction, aCx,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
request.forget(_retval);
return NS_OK;
return OpenKeyCursorInternal(keyRange, direction, aRv);
}
NS_IMETHODIMP
IDBIndex::Count(const jsval& aKey,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv)
{
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = CountInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return CountInternal(keyRange, aRv);
}
void

Просмотреть файл

@ -8,11 +8,16 @@
#define mozilla_dom_indexeddb_idbindex_h__
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
#include "nsIIDBIndex.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
class nsIScriptContext;
class nsPIDOMWindow;
@ -30,12 +35,11 @@ class Key;
struct IndexInfo;
class IDBIndex MOZ_FINAL : public nsIIDBIndex
class IDBIndex MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIIDBINDEX
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)
static already_AddRefed<IDBIndex>
@ -100,27 +104,27 @@ public:
return mActorParent;
}
nsresult GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetKeyInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetKeyInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
ErrorResult& aRv);
nsresult GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
ErrorResult& aRv);
nsresult CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
CountInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult OpenCursorFromChildProcess(
IDBRequest* aRequest,
@ -129,10 +133,10 @@ public:
const Key& aObjectKey,
IDBCursor** _retval);
nsresult OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
ErrorResult& aRv);
nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
@ -147,6 +151,81 @@ public:
nsTArray<StructuredCloneFile>& aBlobs,
IDBCursor** _retval);
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
IDBObjectStore*
GetParentObject() const
{
return mObjectStore;
}
void
GetName(nsString& aName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
}
IDBObjectStore*
ObjectStore() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mObjectStore;
}
JS::Value
GetKeyPath(JSContext* aCx, ErrorResult& aRv);
bool
MultiEntry() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mMultiEntry;
}
bool
Unique() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mUnique;
}
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenKeyCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv);
void
GetStoreName(nsString& aStoreName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
mObjectStore->GetName(aStoreName);
}
already_AddRefed<IDBRequest>
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAllKeys(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
private:
IDBIndex();
~IDBIndex();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,10 +9,12 @@
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "nsIIDBObjectStore.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/dom/IDBIndexBinding.h"
#include "mozilla/dom/IDBObjectStoreBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBTransaction.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
@ -46,12 +48,11 @@ struct ObjectStoreInfo;
struct FileHandleData;
struct BlobOrFileData;
class IDBObjectStore MOZ_FINAL : public nsIIDBObjectStore
class IDBObjectStore MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIIDBOBJECTSTORE
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBObjectStore)
static already_AddRefed<IDBObjectStore>
@ -197,13 +198,9 @@ public:
return mActorParent;
}
nsresult
already_AddRefed<IDBIndex>
CreateIndexInternal(const IndexInfo& aInfo,
IDBIndex** _retval);
nsresult
IndexInternal(const nsAString& aName,
IDBIndex** _retval);
ErrorResult& aRv);
nsresult AddOrPutInternal(
const SerializedStructuredCloneWriteInfo& aCloneWriteInfo,
@ -213,30 +210,27 @@ public:
bool aOverwrite,
IDBRequest** _retval);
nsresult GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
ErrorResult& aRv);
nsresult DeleteInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
DeleteInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult ClearInternal(JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
CountInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
OpenCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
ErrorResult& aRv);
nsresult OpenCursorFromChildProcess(
IDBRequest* aRequest,
@ -251,6 +245,96 @@ public:
static JSClass sDummyPropJSClass;
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
IDBTransaction*
GetParentObject() const
{
return mTransaction;
}
void
GetName(nsString& aName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
}
JS::Value
GetKeyPath(JSContext* aCx, ErrorResult& aRv);
already_AddRefed<nsIDOMDOMStringList>
GetIndexNames(ErrorResult& aRv);
IDBTransaction*
Transaction() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mTransaction;
}
bool
AutoIncrement() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mAutoIncrement;
}
already_AddRefed<IDBRequest>
Put(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, true, aRv);
}
already_AddRefed<IDBRequest>
Add(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, false, aRv);
}
already_AddRefed<IDBRequest>
Delete(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Clear(ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName,
const Sequence<nsString >& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<IDBIndex>
Index(const nsAString& aName, ErrorResult &aRv);
void
DeleteIndex(const nsAString& aIndexName, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t >& aLimit, ErrorResult& aRv);
protected:
IDBObjectStore();
~IDBObjectStore();
@ -262,12 +346,14 @@ protected:
Key& aKey,
nsTArray<IndexUpdateInfo>& aUpdateInfoArray);
nsresult AddOrPut(const jsval& aValue,
const jsval& aKey,
JSContext* aCx,
uint8_t aOptionalArgCount,
bool aOverwrite,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, bool aOverwrite,
ErrorResult& aRv);
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
static void
ClearStructuredCloneBuffer(JSAutoStructuredCloneBuffer& aBuffer);

Просмотреть файл

@ -92,7 +92,7 @@ NS_IMPL_QUERY_INTERFACE1(StartTransactionRunnable, nsIRunnable)
// static
already_AddRefed<IDBTransaction>
IDBTransaction::CreateInternal(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
const Sequence<nsString>& aObjectStoreNames,
Mode aMode,
bool aDispatchDelayed,
bool aIsVersionChangeTransactionChild)
@ -699,7 +699,7 @@ IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
return list.forget();
}
already_AddRefed<nsIIDBObjectStore>
already_AddRefed<IDBObjectStore>
IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

Просмотреть файл

@ -89,7 +89,7 @@ public:
static already_AddRefed<IDBTransaction>
Create(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
const Sequence<nsString>& aObjectStoreNames,
Mode aMode,
bool aDispatchDelayed)
{
@ -230,7 +230,7 @@ public:
IDBTransactionMode
GetMode(ErrorResult& aRv) const;
nsIIDBDatabase*
IDBDatabase*
Db() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -240,7 +240,7 @@ public:
DOMError*
GetError(ErrorResult& aRv);
already_AddRefed<nsIIDBObjectStore>
already_AddRefed<IDBObjectStore>
ObjectStore(const nsAString& aName, ErrorResult& aRv);
void
@ -265,7 +265,7 @@ private:
// Should only be called directly through IndexedDBDatabaseChild.
static already_AddRefed<IDBTransaction>
CreateInternal(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
const Sequence<nsString>& aObjectStoreNames,
Mode aMode,
bool aDispatchDelayed,
bool aIsVersionChangeTransactionChild);

Просмотреть файл

@ -12,6 +12,8 @@
#include "nsJSUtils.h"
#include "xpcpublic.h"
#include "mozilla/dom/BindingDeclarations.h"
USING_INDEXEDDB_NAMESPACE
namespace {
@ -220,6 +222,39 @@ GetJSValFromKeyPathString(JSContext* aCx,
} // anonymous namespace
// static
nsresult
KeyPath::Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath)
{
KeyPath keyPath(0);
keyPath.SetType(STRING);
if (!keyPath.AppendStringWithValidation(aCx, aString)) {
return NS_ERROR_FAILURE;
}
*aKeyPath = keyPath;
return NS_OK;
}
//static
nsresult
KeyPath::Parse(JSContext* aCx, const mozilla::dom::Sequence<nsString>& aStrings,
KeyPath* aKeyPath)
{
KeyPath keyPath(0);
keyPath.SetType(ARRAY);
for (uint32_t i = 0; i < aStrings.Length(); ++i) {
if (!keyPath.AppendStringWithValidation(aCx, aStrings[i])) {
return NS_ERROR_FAILURE;
}
}
*aKeyPath = keyPath;
return NS_OK;
}
// static
nsresult
KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)

Просмотреть файл

@ -9,6 +9,8 @@
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/BindingDeclarations.h"
BEGIN_INDEXEDDB_NAMESPACE
class Key;
@ -45,6 +47,12 @@ public:
MOZ_COUNT_DTOR(KeyPath);
}
static nsresult
Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath);
static nsresult
Parse(JSContext* aCx, const Sequence<nsString>& aStrings, KeyPath* aKeyPath);
static nsresult
Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath);

Просмотреть файл

@ -2059,7 +2059,7 @@ OpenDatabaseHelper::StartSetVersion()
nsresult rv = EnsureSuccessResult();
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<nsString> storesToOpen;
Sequence<nsString> storesToOpen;
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(mDatabase, storesToOpen,
IDBTransaction::VERSION_CHANGE, true);

Просмотреть файл

@ -508,7 +508,7 @@ IndexedDBDatabaseChild::RecvPIndexedDBTransactionConstructor(
nsRefPtr<IPCOpenDatabaseHelper> helper =
new IPCOpenDatabaseHelper(mDatabase, mRequest);
nsTArray<nsString> storesToOpen;
Sequence<nsString> storesToOpen;
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::CreateInternal(mDatabase, storesToOpen,
IDBTransaction::VERSION_CHANGE, false, true);

Просмотреть файл

@ -2,30 +2,34 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "IndexedDBParent.h"
#include "AsyncConnectionHelper.h"
#include "nsIDOMEvent.h"
#include "nsIDOMFile.h"
#include "nsIXPConnect.h"
#include "mozilla/AppProcessChecker.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/indexedDB/DatabaseInfo.h"
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBEvents.h"
#include "mozilla/dom/indexedDB/IDBFactory.h"
#include "mozilla/dom/indexedDB/IDBIndex.h"
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBTransaction.h"
#include "mozilla/dom/IDBDatabaseBinding.h"
#include "mozilla/dom/ipc/Blob.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/unused.h"
#include "mozilla/Util.h"
#include "nsContentUtils.h"
#include "nsCxPusher.h"
#include "nsIDOMEvent.h"
#include "nsIDOMFile.h"
#include "nsIXPConnect.h"
#include "AsyncConnectionHelper.h"
#include "DatabaseInfo.h"
#include "IDBDatabase.h"
#include "IDBEvents.h"
#include "IDBFactory.h"
#include "IDBIndex.h"
#include "IDBKeyRange.h"
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#define CHROME_ORIGIN "chrome"
#define PERMISSION_PREFIX "indexedDB-chrome-"
@ -377,9 +381,6 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
return NS_OK;
}
nsIXPConnect* xpc = nsContentUtils::XPConnect();
MOZ_ASSERT(xpc);
AutoSafeJSContext cx;
JS::Rooted<JS::Value> result(cx);
@ -388,20 +389,14 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result));
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
rv = xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(result),
getter_AddRefs(wrapper));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIIDBDatabase> database;
if (!wrapper || !(database = do_QueryInterface(wrapper->Native()))) {
IDBDatabase *database;
rv = UnwrapObject<IDBDatabase>(cx, &result.toObject(), database);
if (NS_FAILED(rv)) {
NS_WARNING("Didn't get the object we expected!");
return NS_ERROR_FAILURE;
return rv;
}
IDBDatabase* databaseConcrete = static_cast<IDBDatabase*>(database.get());
DatabaseInfo* dbInfo = databaseConcrete->Info();
DatabaseInfo* dbInfo = database->Info();
MOZ_ASSERT(dbInfo);
nsAutoTArray<nsString, 20> objectStoreNames;
@ -427,8 +422,7 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
nsRefPtr<IDBOpenDBRequest> request;
mOpenRequest.swap(request);
EventTarget* target =
static_cast<EventTarget*>(databaseConcrete);
EventTarget* target = static_cast<EventTarget*>(database);
#ifdef DEBUG
{
@ -447,11 +441,11 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(!mDatabase || mDatabase == databaseConcrete);
MOZ_ASSERT(!mDatabase || mDatabase == database);
if (!mDatabase) {
databaseConcrete->SetActor(this);
mDatabase = databaseConcrete;
database->SetActor(this);
mDatabase = database;
}
return NS_OK;
@ -464,7 +458,7 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
AsyncConnectionHelper::GetCurrentTransaction();
MOZ_ASSERT(transaction);
if (!CheckWritePermission(databaseConcrete->Name())) {
if (!CheckWritePermission(database->Name())) {
// If we get here then the child process is either dead or in the process
// of being killed. Abort the transaction now to prevent any changes to
// the database.
@ -497,8 +491,8 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
return NS_ERROR_FAILURE;
}
databaseConcrete->SetActor(this);
mDatabase = databaseConcrete;
database->SetActor(this);
mDatabase = database;
return NS_OK;
}
@ -600,7 +594,7 @@ IndexedDBDatabaseParent::RecvPIndexedDBTransactionConstructor(
return true;
}
nsTArray<nsString> storesToOpen;
Sequence<nsString> storesToOpen;
storesToOpen.AppendElements(params.names());
nsRefPtr<IDBTransaction> transaction =
@ -796,13 +790,9 @@ IndexedDBTransactionParent::RecvPIndexedDBObjectStoreConstructor(
AutoSetCurrentTransaction asct(mTransaction);
ErrorResult rv;
nsCOMPtr<nsIIDBObjectStore> store = mTransaction->ObjectStore(name, rv);
if (rv.Failed()) {
NS_WARNING("Failed to get object store!");
return false;
}
objectStore = mTransaction->ObjectStore(name, rv);
ENSURE_SUCCESS(rv, false);
objectStore = static_cast<IDBObjectStore*>(store.get());
actor->SetObjectStore(objectStore);
}
@ -874,16 +864,14 @@ IndexedDBVersionChangeTransactionParent::RecvDeleteObjectStore(
IDBDatabase* db = mTransaction->Database();
MOZ_ASSERT(db);
nsresult rv;
ErrorResult rv;
{
AutoSetCurrentTransaction asct(mTransaction);
rv = db->DeleteObjectStore(aName);
db->DeleteObjectStore(aName, rv);
}
NS_ENSURE_SUCCESS(rv, false);
ENSURE_SUCCESS(rv, false);
return true;
}
@ -924,16 +912,15 @@ IndexedDBVersionChangeTransactionParent::RecvPIndexedDBObjectStoreConstructor(
nsRefPtr<IDBObjectStore> objectStore;
nsresult rv;
ErrorResult rv;
{
AutoSetCurrentTransaction asct(mTransaction);
rv = db->CreateObjectStoreInternal(mTransaction, info,
getter_AddRefs(objectStore));
objectStore = db->CreateObjectStoreInternal(mTransaction, info, rv);
}
NS_ENSURE_SUCCESS(rv, false);
ENSURE_SUCCESS(rv, false);
actor->SetObjectStore(objectStore);
objectStore->SetActor(actor);
@ -1153,8 +1140,9 @@ IndexedDBObjectStoreParent::RecvPIndexedDBIndexConstructor(
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->IndexInternal(name, getter_AddRefs(index));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
index = mObjectStore->Index(name, rv);
ENSURE_SUCCESS(rv, false);
actor->SetIndex(index);
}
@ -1253,16 +1241,15 @@ IndexedDBVersionChangeObjectStoreParent::RecvDeleteIndex(const nsString& aName)
return true;
}
nsresult rv;
ErrorResult rv;
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
rv = mObjectStore->DeleteIndex(aName);
mObjectStore->DeleteIndex(aName, rv);
}
NS_ENSURE_SUCCESS(rv, false);
ENSURE_SUCCESS(rv, false);
return true;
}
@ -1297,16 +1284,14 @@ IndexedDBVersionChangeObjectStoreParent::RecvPIndexedDBIndexConstructor(
nsRefPtr<IDBIndex> index;
nsresult rv;
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
rv = mObjectStore->CreateIndexInternal(info, getter_AddRefs(index));
ErrorResult rv;
index = mObjectStore->CreateIndexInternal(info, rv);
ENSURE_SUCCESS(rv, false);
}
NS_ENSURE_SUCCESS(rv, false);
actor->SetIndex(index);
index->SetActor(actor);
return true;
@ -1513,9 +1498,9 @@ IndexedDBObjectStoreRequestParent::Get(const GetParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->GetInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->GetInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1553,10 +1538,9 @@ IndexedDBObjectStoreRequestParent::GetAll(const GetAllParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->GetAllInternal(keyRange, aParams.limit(),
nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->GetAllInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1635,9 +1619,9 @@ IndexedDBObjectStoreRequestParent::Delete(const DeleteParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->DeleteInternal(keyRange, nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->DeleteInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1656,8 +1640,9 @@ IndexedDBObjectStoreRequestParent::Clear(const ClearParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->ClearInternal(nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->Clear(rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1694,9 +1679,9 @@ IndexedDBObjectStoreRequestParent::Count(const CountParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->CountInternal(keyRange, nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->CountInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1735,10 +1720,9 @@ IndexedDBObjectStoreRequestParent::OpenCursor(const OpenCursorParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->OpenCursorInternal(keyRange, direction, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->OpenCursorInternal(keyRange, direction, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1789,9 +1773,9 @@ IndexedDBIndexRequestParent::Get(const GetParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1814,9 +1798,9 @@ IndexedDBIndexRequestParent::GetKey(const GetKeyParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetKeyInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetKeyInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1853,9 +1837,9 @@ IndexedDBIndexRequestParent::GetAll(const GetAllParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetAllInternal(keyRange, aParams.limit(), nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetAllInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1892,9 +1876,9 @@ IndexedDBIndexRequestParent::GetAllKeys(const GetAllKeysParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1931,9 +1915,9 @@ IndexedDBIndexRequestParent::Count(const CountParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->CountInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->CountInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -2013,10 +1997,9 @@ IndexedDBIndexRequestParent::OpenKeyCursor(const OpenKeyCursorParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv =
mIndex->OpenKeyCursorInternal(keyRange, direction, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->OpenKeyCursorInternal(keyRange, direction, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);

Просмотреть файл

@ -10,10 +10,7 @@ TEST_DIRS += ['test']
XPIDL_SOURCES += [
'nsIIDBCursor.idl',
'nsIIDBCursorWithValue.idl',
'nsIIDBDatabase.idl',
'nsIIDBIndex.idl',
'nsIIDBKeyRange.idl',
'nsIIDBObjectStore.idl',
'nsIIDBOpenDBRequest.idl',
'nsIIDBRequest.idl',
'nsIIndexedDatabaseManager.idl',

Просмотреть файл

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIIDBObjectStore;
interface nsIIDBRequest;
interface nsIDOMDOMStringList;
interface nsIDOMEventListener;
/**
* IDBDatabase interface. See
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase
* for more information.
*/
[scriptable, builtinclass, uuid(89299bf8-e078-4ebc-abda-d97fe5618602)]
interface nsIIDBDatabase : nsISupports
{
readonly attribute DOMString name;
readonly attribute unsigned long long version;
readonly attribute nsIDOMDOMStringList objectStoreNames;
[implicit_jscontext]
nsIIDBObjectStore
createObjectStore([Null(Stringify)] in DOMString name,
/* IDBObjectStoreParameters */
[optional /* none */] in jsval options);
void
deleteObjectStore([Null(Stringify)] in DOMString name);
// mode can be either "readonly" or "readwrite"
[optional_argc, implicit_jscontext]
nsISupports
transaction(in jsval storeNames, // js array of strings
[optional /* "readonly" */] in DOMString mode);
[implicit_jscontext]
nsIIDBRequest
mozCreateFileHandle(in DOMString name,
[optional] in DOMString type);
void
close();
[implicit_jscontext] attribute jsval onabort;
[implicit_jscontext] attribute jsval onerror;
[implicit_jscontext] attribute jsval onversionchange;
};

Просмотреть файл

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIIDBObjectStore;
interface nsIIDBRequest;
/**
* IDBIndex interface. See
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBIndex for more
* information.
*/
[scriptable, builtinclass, uuid(a859747a-0f05-4dfb-8f42-05c61415d4e4)]
interface nsIIDBIndex : nsISupports
{
readonly attribute DOMString name;
readonly attribute DOMString storeName;
[implicit_jscontext]
readonly attribute jsval keyPath;
readonly attribute boolean unique;
readonly attribute boolean multiEntry;
readonly attribute nsIIDBObjectStore objectStore;
[implicit_jscontext]
nsIIDBRequest
get(in jsval key);
[implicit_jscontext]
nsIIDBRequest
getKey(in jsval key);
[implicit_jscontext, optional_argc, binaryname(GetAll)]
nsIIDBRequest
mozGetAll([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
[implicit_jscontext, optional_argc, binaryname(GetAllKeys)]
nsIIDBRequest
mozGetAllKeys([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openCursor([optional /* null */] in jsval key,
[optional /* "next" */] in DOMString direction);
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openKeyCursor([optional /* null */] in jsval key,
[optional /* "next" */] in DOMString direction);
// Accepts null, a key value, or a nsIIDBKeyRange object.
[implicit_jscontext, optional_argc]
nsIIDBRequest
count([optional] in jsval key);
};

Просмотреть файл

@ -1,99 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIIDBIndex;
interface nsIIDBKeyRange;
interface nsIIDBRequest;
interface nsIDOMDOMStringList;
dictionary IDBIndexParameters
{
boolean unique;
boolean multiEntry;
};
/**
* nsIIDBObjectStore interface. See
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore
* for more information.
*/
[scriptable, builtinclass, uuid(dd189afd-e1b7-4496-bf8d-629c58709595)]
interface nsIIDBObjectStore : nsISupports
{
readonly attribute DOMString name;
[implicit_jscontext]
readonly attribute jsval keyPath;
readonly attribute nsIDOMDOMStringList indexNames;
// IDBTransaction
readonly attribute nsISupports transaction;
readonly attribute boolean autoIncrement;
// Success fires IDBTransactionEvent, result == value for key
[implicit_jscontext]
nsIIDBRequest
get(in jsval key);
// Success fires IDBTransactionEvent, result == array of values for given keys
[implicit_jscontext, optional_argc, binaryname(GetAll)]
nsIIDBRequest
mozGetAll([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
// Success fires IDBTransactionEvent, result == key
[implicit_jscontext, optional_argc]
nsIIDBRequest
add(in jsval value,
[optional /* undefined */] in jsval key);
// Success fires IDBTransactionEvent, result == key
[implicit_jscontext, optional_argc]
nsIIDBRequest
put(in jsval value,
[optional /* undefined */] in jsval key);
// Success fires IDBTransactionEvent, result == null
[implicit_jscontext]
nsIIDBRequest
delete(in jsval key);
// Success fires IDBTransactionEvent, result == null
[implicit_jscontext]
nsIIDBRequest
clear();
// Success fires IDBTransactionEvent, result == IDBCursor or result == null if
// no match.
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openCursor([optional /* null */] in jsval range,
[optional /* "next" */] in DOMString direction);
[implicit_jscontext]
nsIIDBIndex
createIndex([Null(Stringify)] in DOMString name,
in jsval keyPath,
/* nsIIDBIndexParameters */
[optional /* none */] in jsval options);
// Returns object immediately
nsIIDBIndex
index([Null(Stringify)] in DOMString name);
void
deleteIndex([Null(Stringify)] in DOMString name);
// Accepts null, a key value, or a nsIIDBKeyRange object.
[implicit_jscontext, optional_argc]
nsIIDBRequest
count([optional] in jsval key);
};

Просмотреть файл

@ -24,7 +24,7 @@ function test1()
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) {
ok(result instanceof Components.interfaces.nsIIDBDatabase,
ok(result instanceof IDBDatabase,
"First database creation was successful");
ok(!exception, "No exception");
is(getPermission(testPageURL, "indexedDB"),
@ -60,7 +60,7 @@ function test2()
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) {
ok(result instanceof Components.interfaces.nsIIDBDatabase,
ok(result instanceof IDBDatabase,
"First database creation was successful");
ok(!exception, "No exception");
is(getPermission(testPageURL, "indexedDB"),

Просмотреть файл

@ -20,7 +20,7 @@ function test1()
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) {
ok(result instanceof Components.interfaces.nsIIDBDatabase,
ok(result instanceof IDBDatabase,
"First database creation was successful");
ok(!exception, "No exception");
gBrowser.removeCurrentTab();

Просмотреть файл

@ -8,9 +8,6 @@ const { 'classes': Cc, 'interfaces': Ci } = Components;
const DOMException = Ci.nsIDOMDOMException;
const IDBCursor = Ci.nsIIDBCursor;
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
const IDBDatabase = Ci.nsIIDBDatabase
const IDBIndex = Ci.nsIIDBIndex
const IDBObjectStore = Ci.nsIIDBObjectStore
const IDBRequest = Ci.nsIIDBRequest
function is(a, b, msg) {

Просмотреть файл

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
// Test object stores
const name = "test_complex_keyPaths";

Просмотреть файл

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const IDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
var request = indexedDB.open(name, 1);

Просмотреть файл

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const IDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
var data = [

Просмотреть файл

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const objectStoreName = "Objects";

Просмотреть файл

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const indexName = "My Test Index";

Просмотреть файл

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const objectStoreName = "Objects";

Просмотреть файл

@ -16,7 +16,6 @@ XPIDL_SOURCES += [
'nsIDOMClientRect.idl',
'nsIDOMClientRectList.idl',
'nsIDOMConstructor.idl',
'nsIDOMGlobalObjectConstructor.idl',
'nsIDOMGlobalPropertyInitializer.idl',
'nsIDOMHistory.idl',
'nsIDOMJSWindow.idl',

Просмотреть файл

@ -1,19 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
[scriptable, uuid(cb439c73-0129-4289-a349-c5216e6b912a)]
interface nsIDOMGlobalObjectConstructor : nsISupports
{
/*
* JS use only
*
* The constructor() method will be called with any parameters passed
* to the object constructor.
* If the JS implementation returns a value, it will be ignored.
*/
void constructor();
};

Просмотреть файл

@ -1085,7 +1085,7 @@ GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true)
}
return obj;
}
if (!::JS_GetPrototype(cx, obj, obj.address())) {
if (!::JS_GetPrototype(cx, obj, &obj)) {
return NULL;
}
}

Просмотреть файл

@ -73,20 +73,4 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIOfflineStorage, NS_OFFLINESTORAGE_IID)
NS_IMETHOD_(void) \
Invalidate() MOZ_OVERRIDE;
#define NS_DECL_NSIOFFLINESTORAGE_NOCLOSE \
NS_IMETHOD_(Client*) \
GetClient() MOZ_OVERRIDE; \
\
NS_IMETHOD_(bool) \
IsOwned(nsPIDOMWindow* aOwner) MOZ_OVERRIDE; \
\
NS_IMETHOD_(const nsACString&) \
Origin() MOZ_OVERRIDE; \
\
NS_IMETHOD_(bool) \
IsClosed() MOZ_OVERRIDE; \
\
NS_IMETHOD_(void) \
Invalidate() MOZ_OVERRIDE;
#endif // nsIOfflineStorage_h__

Просмотреть файл

@ -185,7 +185,7 @@ WifiGeoPositionProvider.prototype = {
return;
}
if (!xhr.response.location) {
if (!xhr.response || !xhr.response.location) {
return;
}

Просмотреть файл

@ -18,7 +18,6 @@ interface DummyInterface {
void funcDNSCacheDict(optional DNSCacheDict arg);
void funcConnStatusDict(optional ConnStatusDict arg);
void frameRequestCallback(FrameRequestCallback arg);
void idbObjectStoreParams(optional IDBObjectStoreParameters arg);
void CameraPictureOptions(optional CameraPictureOptions arg);
void MmsParameters(optional MmsParameters arg);
void MmsAttachment(optional MmsAttachment arg);

Просмотреть файл

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBCursorDirection
*/
enum IDBCursorDirection {
"next",
"nextunique",
"prev",
"prevunique"
};

Просмотреть файл

@ -10,11 +10,40 @@
* liability, trademark and document use rules apply.
*/
dictionary IDBObjectStoreParameters {
// XXXbz this should be "(DOMString or sequence<DOMString>)?", but
// we don't support unions in dictionaries yet. See bug 767926.
any keyPath = null;
boolean autoIncrement = false;
interface IDBDatabase : EventTarget {
readonly attribute DOMString name;
readonly attribute unsigned long long version;
[Throws]
readonly attribute DOMStringList objectStoreNames;
[Throws]
IDBObjectStore createObjectStore (DOMString name, optional IDBObjectStoreParameters optionalParameters);
[Throws]
void deleteObjectStore (DOMString name);
// This should be:
// IDBTransaction transaction ((DOMString or sequence<DOMString>) storeNames, optional IDBTransactionMode mode = "readonly");
// but unions are not currently supported.
[Throws]
IDBTransaction transaction (DOMString storeName, optional IDBTransactionMode mode = "readonly");
[Throws]
IDBTransaction transaction (sequence<DOMString> storeNames, optional IDBTransactionMode mode = "readonly");
void close ();
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler onerror;
[SetterThrows]
attribute EventHandler onversionchange;
};
// If we start using IDBObjectStoreParameters here, remove it from DummyBinding.
partial interface IDBDatabase {
[Throws]
IDBRequest mozCreateFileHandle (DOMString name, optional DOMString type);
};

Просмотреть файл

@ -3,8 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface IDBDatabase;
interface IDBFileHandle : FileHandle {
readonly attribute IDBDatabase database;
};

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBIndexParameters
*/
dictionary IDBIndexParameters {
boolean unique = false;
boolean multiEntry = false;
};
interface IDBIndex {
readonly attribute DOMString name;
readonly attribute IDBObjectStore objectStore;
[Throws]
readonly attribute any keyPath;
readonly attribute boolean multiEntry;
readonly attribute boolean unique;
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest get (any key);
[Throws]
IDBRequest getKey (any key);
[Throws]
IDBRequest count (optional any key);
};
partial interface IDBIndex {
readonly attribute DOMString storeName;
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
[Throws]
IDBRequest mozGetAllKeys (optional any key, optional unsigned long limit);
};

Просмотреть файл

@ -0,0 +1,70 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore
*/
interface IDBRequest;
dictionary IDBObjectStoreParameters {
// TODO (DOMString or sequence<DOMString>)? keyPath = null;
any keyPath = null;
boolean autoIncrement = false;
};
interface IDBObjectStore {
readonly attribute DOMString name;
[Throws]
readonly attribute any keyPath;
[Throws]
readonly attribute DOMStringList indexNames;
readonly attribute IDBTransaction transaction;
readonly attribute boolean autoIncrement;
[Throws]
IDBRequest put (any value, optional any key);
[Throws]
IDBRequest add (any value, optional any key);
[Throws]
IDBRequest delete (any key);
[Throws]
IDBRequest get (any key);
[Throws]
IDBRequest clear ();
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
// Bug 899972
// IDBIndex createIndex (DOMString name, (DOMString or sequence<DOMString>) keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex createIndex (DOMString name, DOMString keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex createIndex (DOMString name, sequence<DOMString> keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex index (DOMString name);
[Throws]
void deleteIndex (DOMString indexName);
[Throws]
IDBRequest count (optional any key);
};
partial interface IDBObjectStore {
// Success fires IDBTransactionEvent, result == array of values for given keys
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
};

Просмотреть файл

@ -8,8 +8,6 @@
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransactionMode
*/
interface IDBObjectStore;
enum IDBTransactionMode {
"readonly",
"readwrite",

Просмотреть файл

@ -164,9 +164,12 @@ webidl_files = \
HTMLTrackElement.webidl \
HTMLUListElement.webidl \
HTMLVideoElement.webidl \
IDBCursor.webidl \
IDBDatabase.webidl \
IDBFactory.webidl \
IDBFileHandle.webidl \
IDBIndex.webidl \
IDBObjectStore.webidl \
IDBTransaction.webidl \
IDBVersionChangeEvent.webidl \
ImageData.webidl \

Просмотреть файл

@ -979,14 +979,14 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx)
return NULL;
}
JSObject* scopeProto =
WorkerGlobalScope::InitClass(aCx, global, eventTargetProto);
JS::Rooted<JSObject*> scopeProto(aCx,
WorkerGlobalScope::InitClass(aCx, global, eventTargetProto));
if (!scopeProto) {
return NULL;
}
JSObject* dedicatedScopeProto =
DedicatedWorkerGlobalScope::InitClass(aCx, global, scopeProto);
JS::Rooted<JSObject*> dedicatedScopeProto(aCx,
DedicatedWorkerGlobalScope::InitClass(aCx, global, scopeProto));
if (!dedicatedScopeProto) {
return NULL;
}

Просмотреть файл

@ -111,16 +111,11 @@ public:
bool RemoveTile(int x, int y, Tile& aRemovedTile);
uint16_t GetTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE; }
uint32_t GetScaledTileLength() const {
// volatile variables to help investigate bug 881018
volatile float resolution = mResolution;
volatile float fScaledLength = TILEDLAYERBUFFER_TILE_SIZE / mResolution;
volatile uint32_t uiScaledLength = TILEDLAYERBUFFER_TILE_SIZE / mResolution;
if (!uiScaledLength) {
MOZ_CRASH();
}
return uiScaledLength;
}
#ifdef MOZ_WIDGET_ANDROID
MOZ_NEVER_INLINE // bug 881018 causes wrong results when GetScaledTileLength is inlined
#endif
uint32_t GetScaledTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE / mResolution; }
unsigned int GetTileCount() const { return mRetainedTiles.Length(); }

Просмотреть файл

@ -113,7 +113,7 @@ gfxASurface*
gfxASurface::GetSurfaceWrapper(cairo_surface_t *csurf)
{
if (!csurf)
return NULL;
return nullptr;
return (gfxASurface*) cairo_surface_get_user_data(csurf, &gfxasurface_pointer_key);
}
@ -281,7 +281,7 @@ void *
gfxASurface::GetData(const cairo_user_data_key_t *key)
{
if (!mSurfaceValid)
return NULL;
return nullptr;
return cairo_surface_get_user_data(mSurface, key);
}

Просмотреть файл

@ -27,7 +27,7 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
static FT_Library gPlatformFTLibrary = NULL;
static FT_Library gPlatformFTLibrary = nullptr;
static int64_t sFreetypeMemoryUsed;
static FT_MemoryRec_ sFreetypeMemoryRecord;
@ -114,7 +114,7 @@ gfxAndroidPlatform::~gfxAndroidPlatform()
cairo_debug_reset_static_data();
FT_Done_Library(gPlatformFTLibrary);
gPlatformFTLibrary = NULL;
gPlatformFTLibrary = nullptr;
}
already_AddRefed<gfxASurface>

Просмотреть файл

@ -52,12 +52,13 @@ public:
* this value. This parameter should nearly always be computed using
* CalculateBlurRadius, below.
*
* @param aDirtyRect A pointer to a dirty rect, measured in device units, if available.
* This will be used for optimizing the blur operation. It is safe to pass NULL here.
* @param aDirtyRect A pointer to a dirty rect, measured in device units,
* if available. This will be used for optimizing the blur operation. It
* is safe to pass nullptr here.
*
* @param aSkipRect A pointer to a rect, measured in device units, that represents an area
* where blurring is unnecessary and shouldn't be done for speed reasons. It is safe to
* pass NULL here.
* @param aSkipRect A pointer to a rect, measured in device units, that
* represents an area where blurring is unnecessary and shouldn't be done
* for speed reasons. It is safe to pass nullptr here.
*/
gfxContext* Init(const gfxRect& aRect,
const gfxIntSize& aSpreadRadius,

Просмотреть файл

@ -36,7 +36,7 @@ using namespace mozilla::gfx;
class GeneralPattern
{
public:
GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(NULL) {}
GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(nullptr) {}
~GeneralPattern() { if (mPattern) { mPattern->~Pattern(); } }
operator mozilla::gfx::Pattern&()
@ -76,7 +76,7 @@ private:
};
gfxContext::gfxContext(gfxASurface *surface)
: mRefCairo(NULL)
: mRefCairo(nullptr)
, mSurface(surface)
{
MOZ_COUNT_CTOR(gfxContext);
@ -97,9 +97,9 @@ gfxContext::gfxContext(gfxASurface *surface)
gfxContext::gfxContext(DrawTarget *aTarget)
: mPathIsRect(false)
, mTransformChanged(false)
, mCairo(NULL)
, mRefCairo(NULL)
, mSurface(NULL)
, mCairo(nullptr)
, mRefCairo(nullptr)
, mSurface(nullptr)
, mFlags(0)
, mDT(aTarget)
, mOriginalDT(aTarget)
@ -224,8 +224,8 @@ gfxContext::NewPath()
if (mCairo) {
cairo_new_path(mCairo);
} else {
mPath = NULL;
mPathBuilder = NULL;
mPath = nullptr;
mPathBuilder = nullptr;
mPathIsRect = false;
mTransformChanged = false;
}
@ -934,7 +934,8 @@ gfxContext::SetDash(gfxFloat *dashes, int ndash, gfxFloat offset)
}
state.strokeOptions.mDashLength = ndash;
state.strokeOptions.mDashOffset = Float(offset);
state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements() : NULL;
state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements()
: nullptr;
}
}
@ -974,7 +975,7 @@ gfxContext::CurrentDashOffset() const
return 0.0;
}
gfxFloat offset;
cairo_get_dash(mCairo, NULL, &offset);
cairo_get_dash(mCairo, nullptr, &offset);
return offset;
} else {
return CurrentState().strokeOptions.mDashOffset;
@ -1122,7 +1123,7 @@ gfxContext::Clip(const gfxRect& rect)
cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
cairo_clip(mCairo);
} else {
AzureState::PushedClip clip = { NULL, ToRect(rect), mTransform };
AzureState::PushedClip clip = { nullptr, ToRect(rect), mTransform };
CurrentState().pushedClips.AppendElement(clip);
mDT->PushClipRect(ToRect(rect));
NewPath();
@ -1138,7 +1139,7 @@ gfxContext::Clip()
if (mPathIsRect) {
MOZ_ASSERT(!mTransformChanged);
AzureState::PushedClip clip = { NULL, mRect, mTransform };
AzureState::PushedClip clip = { nullptr, mRect, mTransform };
CurrentState().pushedClips.AppendElement(clip);
mDT->PushClipRect(mRect);
} else {
@ -1279,9 +1280,9 @@ gfxContext::SetColor(const gfxRGBA& c)
else
cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
} else {
CurrentState().pattern = NULL;
CurrentState().sourceSurfCairo = NULL;
CurrentState().sourceSurface = NULL;
CurrentState().pattern = nullptr;
CurrentState().sourceSurfCairo = nullptr;
CurrentState().sourceSurface = nullptr;
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
@ -1305,9 +1306,9 @@ gfxContext::SetDeviceColor(const gfxRGBA& c)
if (mCairo) {
cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a);
} else {
CurrentState().pattern = NULL;
CurrentState().sourceSurfCairo = NULL;
CurrentState().sourceSurface = NULL;
CurrentState().pattern = nullptr;
CurrentState().sourceSurfCairo = nullptr;
CurrentState().sourceSurface = nullptr;
CurrentState().color = ToColor(c);
}
}
@ -1343,7 +1344,7 @@ gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset)
cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
} else {
CurrentState().surfTransform = Matrix(1.0f, 0, 0, 1.0f, Float(offset.x), Float(offset.y));
CurrentState().pattern = NULL;
CurrentState().pattern = nullptr;
CurrentState().patternTransformChanged = false;
// Keep the underlying cairo surface around while we keep the
// sourceSurface.
@ -1359,8 +1360,8 @@ gfxContext::SetPattern(gfxPattern *pattern)
if (mCairo) {
cairo_set_source(mCairo, pattern->CairoPattern());
} else {
CurrentState().sourceSurfCairo = NULL;
CurrentState().sourceSurface = NULL;
CurrentState().sourceSurfCairo = nullptr;
CurrentState().sourceSurface = nullptr;
CurrentState().patternTransformChanged = false;
CurrentState().pattern = pattern;
}
@ -1621,9 +1622,9 @@ gfxContext::PopGroupToSource()
RefPtr<SourceSurface> src = mDT->Snapshot();
Point deviceOffset = CurrentState().deviceOffset;
Restore();
CurrentState().sourceSurfCairo = NULL;
CurrentState().sourceSurfCairo = nullptr;
CurrentState().sourceSurface = src;
CurrentState().pattern = NULL;
CurrentState().pattern = nullptr;
CurrentState().patternTransformChanged = false;
Matrix mat = mTransform;
@ -1952,7 +1953,7 @@ gfxContext::EnsurePath()
{
if (mPathBuilder) {
mPath = mPathBuilder->Finish();
mPathBuilder = NULL;
mPathBuilder = nullptr;
}
if (mPath) {
@ -1962,7 +1963,7 @@ gfxContext::EnsurePath()
mat = mPathTransform * mat;
mPathBuilder = mPath->TransformedCopyToBuilder(mat, CurrentState().fillRule);
mPath = mPathBuilder->Finish();
mPathBuilder = NULL;
mPathBuilder = nullptr;
mTransformChanged = false;
}
@ -1974,13 +1975,13 @@ gfxContext::EnsurePath()
mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule);
mPath = mPathBuilder->Finish();
mPathBuilder = NULL;
mPathBuilder = nullptr;
return;
}
EnsurePathBuilder();
mPath = mPathBuilder->Finish();
mPathBuilder = NULL;
mPathBuilder = nullptr;
}
void
@ -1993,7 +1994,7 @@ gfxContext::EnsurePathBuilder()
if (mPath) {
if (!mTransformChanged) {
mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule);
mPath = NULL;
mPath = nullptr;
} else {
Matrix invTransform = mTransform;
invTransform.Invert();
@ -2019,8 +2020,8 @@ gfxContext::EnsurePathBuilder()
if (mTransformChanged) {
// This could be an else if since this should never happen when
// mPathBuilder is NULL and mPath is NULL. But this way we can assert
// if all the state is as expected.
// mPathBuilder is nullptr and mPath is nullptr. But this way we can
// assert if all the state is as expected.
MOZ_ASSERT(oldPath);
MOZ_ASSERT(!mPathIsRect);

Просмотреть файл

@ -67,7 +67,7 @@ public:
*/
already_AddRefed<gfxASurface> CurrentSurface(gfxFloat *dx, gfxFloat *dy);
already_AddRefed<gfxASurface> CurrentSurface() {
return CurrentSurface(NULL, NULL);
return CurrentSurface(nullptr, nullptr);
}
/**
@ -453,7 +453,7 @@ public:
void SetDash(gfxLineType ltype);
void SetDash(gfxFloat *dashes, int ndash, gfxFloat offset);
// Return true if dashing is set, false if it's not enabled or the
// context is in an error state. |offset| can be NULL to mean
// context is in an error state. |offset| can be nullptr to mean
// "don't care".
bool CurrentDash(FallibleTArray<gfxFloat>& dashes, gfxFloat* offset) const;
// Returns 0.0 if dashing isn't enabled.

Просмотреть файл

@ -32,8 +32,8 @@
using namespace mozilla;
// standard font descriptors that we construct the first time they're needed
CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = NULL;
CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = NULL;
CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = nullptr;
CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = nullptr;
gfxCoreTextShaper::gfxCoreTextShaper(gfxMacFont *aFont)
: gfxFontShaper(aFont)
@ -41,7 +41,7 @@ gfxCoreTextShaper::gfxCoreTextShaper(gfxMacFont *aFont)
// Create our CTFontRef
mCTFont = ::CTFontCreateWithGraphicsFont(aFont->GetCGFontRef(),
aFont->GetAdjustedSize(),
NULL,
nullptr,
GetDefaultFeaturesDescriptor());
// Set up the default attribute dictionary that we will need each time we create a CFAttributedString
@ -214,9 +214,9 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText,
nsAutoArrayPtr<CGGlyph> glyphsArray;
nsAutoArrayPtr<CGPoint> positionsArray;
nsAutoArrayPtr<CFIndex> glyphToCharArray;
const CGGlyph* glyphs = NULL;
const CGPoint* positions = NULL;
const CFIndex* glyphToChar = NULL;
const CGGlyph* glyphs = nullptr;
const CGPoint* positions = nullptr;
const CFIndex* glyphToChar = nullptr;
// Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds,
// and so allocating a new array and copying data with CTRunGetGlyphs
@ -260,7 +260,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText,
}
double runWidth = ::CTRunGetTypographicBounds(aCTRun, ::CFRangeMake(0, 0),
NULL, NULL, NULL);
nullptr, nullptr, nullptr);
nsAutoTArray<gfxShapedText::DetailedGlyph,1> detailedGlyphs;
gfxShapedText::CompressedGlyph g;
@ -513,7 +513,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText,
void
gfxCoreTextShaper::CreateDefaultFeaturesDescriptor()
{
if (sDefaultFeaturesDescriptor != NULL) {
if (sDefaultFeaturesDescriptor != nullptr) {
return;
}
@ -586,7 +586,7 @@ gfxCoreTextShaper::CreateDefaultFeaturesDescriptor()
CTFontRef
gfxCoreTextShaper::CreateCTFontWithDisabledLigatures(CGFloat aSize)
{
if (sDisableLigaturesDescriptor == NULL) {
if (sDisableLigaturesDescriptor == nullptr) {
// initialize cached descriptor to turn off the Common Ligatures feature
SInt16 val = kLigaturesType;
CFNumberRef ligaturesType =
@ -636,19 +636,19 @@ gfxCoreTextShaper::CreateCTFontWithDisabledLigatures(CGFloat aSize)
}
gfxMacFont *f = static_cast<gfxMacFont*>(mFont);
return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, NULL,
return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, nullptr,
sDisableLigaturesDescriptor);
}
void
gfxCoreTextShaper::Shutdown() // [static]
{
if (sDisableLigaturesDescriptor != NULL) {
if (sDisableLigaturesDescriptor != nullptr) {
::CFRelease(sDisableLigaturesDescriptor);
sDisableLigaturesDescriptor = NULL;
sDisableLigaturesDescriptor = nullptr;
}
if (sDefaultFeaturesDescriptor != NULL) {
if (sDefaultFeaturesDescriptor != nullptr) {
::CFRelease(sDefaultFeaturesDescriptor);
sDefaultFeaturesDescriptor = NULL;
sDefaultFeaturesDescriptor = nullptr;
}
}

Просмотреть файл

@ -47,7 +47,7 @@ protected:
static void CreateDefaultFeaturesDescriptor();
static CTFontDescriptorRef GetDefaultFeaturesDescriptor() {
if (sDefaultFeaturesDescriptor == NULL) {
if (sDefaultFeaturesDescriptor == nullptr) {
CreateDefaultFeaturesDescriptor();
}
return sDefaultFeaturesDescriptor;

Просмотреть файл

@ -83,7 +83,7 @@ void
gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect)
{
if (!aUpdatedRect) {
return cairo_d2d_release_dc(CairoSurface(), NULL);
return cairo_d2d_release_dc(CairoSurface(), nullptr);
}
cairo_rectangle_int_t rect;

Просмотреть файл

@ -5,7 +5,7 @@
#include "gfxDWriteCommon.h"
IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = NULL;
IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr;
HRESULT STDMETHODCALLTYPE
gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey,
@ -61,7 +61,7 @@ gfxDWriteFontFileStream::ReadFileFragment(const void **fragmentStart,
}
// We should be alive for the duration of this.
*fragmentStart = &mData[fileOffset];
*fragmentContext = NULL;
*fragmentContext = nullptr;
return S_OK;
}

Просмотреть файл

@ -290,7 +290,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
uint32_t tableSize =
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag), 0,
NULL, 0);
nullptr, 0);
if (tableSize != GDI_ERROR) {
if (aBuffer.SetLength(tableSize)) {
::GetFontData(dc.GetDC(),
@ -312,7 +312,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
uint8_t *tableData;
uint32_t len;
void *tableContext = NULL;
void *tableContext = nullptr;
BOOL exists;
HRESULT hr =
fontFace->TryGetFontTable(NativeEndian::swapToBigEndian(aTableTag),
@ -481,7 +481,7 @@ gfxDWriteFontEntry::CreateFontFace(IDWriteFontFace **aFontFace,
// has the Bold simulation - unfortunately, DWrite doesn't provide
// a simple API for this
UINT32 numberOfFiles = 0;
if (FAILED(mFontFace->GetFiles(&numberOfFiles, NULL))) {
if (FAILED(mFontFace->GetFiles(&numberOfFiles, nullptr))) {
return NS_ERROR_FAILURE;
}
nsAutoTArray<IDWriteFontFile*,1> files;
@ -753,8 +753,8 @@ gfxDWriteFontList::InitFontList()
if (LOG_FONTINIT_ENABLED()) {
GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT,
NULL, NULL, nowTime, 256);
GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256);
nullptr, nullptr, nowTime, 256);
GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
}
upTime = (double) GetTickCount();
QueryPerformanceFrequency(&frequency);
@ -821,8 +821,8 @@ gfxDWriteFontList::DelayedInitFontList()
if (LOG_FONTINIT_ENABLED()) {
GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT,
NULL, NULL, nowTime, 256);
GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256);
nullptr, nullptr, nowTime, 256);
GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256);
}
upTime = (double) GetTickCount();
@ -1094,7 +1094,7 @@ gfxDWriteFontList::GetFontSubstitutes()
lenAlias = ArrayLength(aliasName);
actualName[0] = 0;
lenActual = sizeof(actualName);
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType,
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType,
(LPBYTE)actualName, &lenActual);
if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {
@ -1371,7 +1371,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh,
// initialize text format
if (!mFallbackFormat) {
hr = dwFactory->CreateTextFormat(L"Arial", NULL,
hr = dwFactory->CreateTextFormat(L"Arial", nullptr,
DWRITE_FONT_WEIGHT_REGULAR,
DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL,
@ -1409,7 +1409,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh,
// call the draw method to invoke the DirectWrite layout functions
// which determine the fallback font
hr = fallbackLayout->Draw(NULL, mFallbackRenderer, 50.0f, 50.0f);
hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f);
if (FAILED(hr)) {
return nullptr;
}

Просмотреть файл

@ -313,7 +313,7 @@ public:
} else if (__uuidof(IUnknown) == riid) {
*ppvObject = this;
} else {
*ppvObject = NULL;
*ppvObject = nullptr;
return E_FAIL;
}

Просмотреть файл

@ -491,7 +491,7 @@ gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
bool
gfxDWriteFont::IsValid()
{
return mFontFace != NULL;
return mFontFace != nullptr;
}
IDWriteFontFace*

Просмотреть файл

@ -45,7 +45,7 @@ gfxDWriteShaper::ShapeText(gfxContext *aContext,
*/
UINT32 length = aLength;
TextAnalysis analysis(aText, length, NULL, readingDirection);
TextAnalysis analysis(aText, length, nullptr, readingDirection);
TextAnalysis::Run *runHead;
hr = analysis.GenerateResults(analyzer, &runHead);
@ -83,7 +83,7 @@ trymoreglyphs:
hr = analyzer->GetGlyphs(aText, length,
font->GetFontFace(), FALSE,
readingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT,
&runHead->mScript, NULL, NULL, NULL, NULL, 0,
&runHead->mScript, nullptr, nullptr, nullptr, nullptr, 0,
maxGlyphs, clusters.Elements(), textProperties.Elements(),
indices.Elements(), glyphProperties.Elements(), &actualGlyphs);
@ -122,9 +122,9 @@ trymoreglyphs:
FALSE,
FALSE,
&runHead->mScript,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
0,
advances.Elements(),
glyphOffsets.Elements());
@ -141,9 +141,9 @@ trymoreglyphs:
FALSE,
FALSE,
&runHead->mScript,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
0,
advances.Elements(),
glyphOffsets.Elements());

Просмотреть файл

@ -13,7 +13,7 @@ TextAnalysis::TextAnalysis(const wchar_t* text,
, mTextLength(textLength)
, mLocaleName(localeName)
, mReadingDirection(readingDirection)
, mCurrentRun(NULL)
, mCurrentRun(nullptr)
{
}
@ -42,7 +42,7 @@ TextAnalysis::GenerateResults(IDWriteTextAnalyzer* textAnalyzer,
mRunHead.mTextLength = mTextLength;
mRunHead.mBidiLevel =
(mReadingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT);
mRunHead.nextRun = NULL;
mRunHead.nextRun = nullptr;
mCurrentRun = &mRunHead;
// Call each of the analyzers in sequence, recording their results.
@ -67,7 +67,7 @@ TextAnalysis::GetTextAtPosition(UINT32 textPosition,
{
if (textPosition >= mTextLength) {
// No text at this position, valid query though.
*textString = NULL;
*textString = nullptr;
*textLength = 0;
} else {
*textString = mText + textPosition;
@ -85,7 +85,7 @@ TextAnalysis::GetTextBeforePosition(UINT32 textPosition,
if (textPosition == 0 || textPosition > mTextLength) {
// Either there is no text before here (== 0), or this
// is an invalid position. The query is considered valid thouh.
*textString = NULL;
*textString = nullptr;
*textLength = 0;
} else {
*textString = mText;
@ -122,7 +122,7 @@ TextAnalysis::GetNumberSubstitution(UINT32 textPosition,
OUT IDWriteNumberSubstitution** numberSubstitution)
{
// We do not support number substitution.
*numberSubstitution = NULL;
*numberSubstitution = nullptr;
*textLength = mTextLength - textPosition;
return S_OK;

Просмотреть файл

@ -91,7 +91,7 @@ gfxFT2FontBase::GetGlyph(uint32_t aCharCode)
void
gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents)
{
NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL");
NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL");
cairo_glyph_t glyphs[1];
glyphs[0].index = aGlyph;

Просмотреть файл

@ -600,7 +600,7 @@ public:
MoveEntry,
PL_DHashClearEntryStub,
PL_DHashFinalizeStub,
NULL
nullptr
};
if (!PL_DHashTableInit(&mMap, &mOps, nullptr,
@ -659,12 +659,12 @@ public:
if (!(end = strchr(beginning, ';'))) {
break;
}
uint32_t timestamp = strtoul(beginning, NULL, 10);
uint32_t timestamp = strtoul(beginning, nullptr, 10);
beginning = end + 1;
if (!(end = strchr(beginning, ';'))) {
break;
}
uint32_t filesize = strtoul(beginning, NULL, 10);
uint32_t filesize = strtoul(beginning, nullptr, 10);
FNCMapEntry* mapEntry =
static_cast<FNCMapEntry*>
@ -829,7 +829,7 @@ gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName,
if (!(end = strchr(beginning, ','))) {
break;
}
uint32_t index = strtoul(beginning, NULL, 10);
uint32_t index = strtoul(beginning, nullptr, 10);
beginning = end + 1;
if (!(end = strchr(beginning, ','))) {
break;
@ -839,12 +839,12 @@ gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName,
if (!(end = strchr(beginning, ','))) {
break;
}
uint32_t weight = strtoul(beginning, NULL, 10);
uint32_t weight = strtoul(beginning, nullptr, 10);
beginning = end + 1;
if (!(end = strchr(beginning, ','))) {
break;
}
int32_t stretch = strtol(beginning, NULL, 10);
int32_t stretch = strtol(beginning, nullptr, 10);
FontListEntry fle(familyName, faceName, aFileName,
weight, stretch, italic, index);
@ -1157,7 +1157,7 @@ gfxFT2FontList::FindFonts()
FindExInfoStandard,
&results,
FindExSearchNameMatch,
NULL,
nullptr,
0);
bool moreFiles = handle != INVALID_HANDLE_VALUE;
while (moreFiles) {
@ -1276,8 +1276,8 @@ gfxFT2FontList::FindFontsInDir(const nsCString& aDir, FontNameCache *aFNC)
return;
}
struct dirent *ent = NULL;
while ((ent = readdir(d)) != NULL) {
struct dirent *ent = nullptr;
while ((ent = readdir(d)) != nullptr) {
int namelen = strlen(ent->d_name);
if (namelen <= 4) {
// cannot be a usable font filename

Просмотреть файл

@ -55,7 +55,7 @@ public:
// Create a font entry for a given freetype face; if it is an installed font,
// also record the filename and index.
// aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on,
// aFontData (if non-nullptr) is NS_Malloc'ed data that aFace depends on,
// to be freed after the face is destroyed
static FT2FontEntry*
CreateFontEntry(FT_Face aFace,

Просмотреть файл

@ -286,7 +286,7 @@ void gfxFT2FontGroup::GetCJKPrefFonts(nsTArray<nsRefPtr<gfxFontEntry> >& aFontEn
case 950: GetPrefFonts(nsGkAtoms::zh_tw, aFontEntryList); break;
}
#else
const char *ctype = setlocale(LC_CTYPE, NULL);
const char *ctype = setlocale(LC_CTYPE, nullptr);
if (ctype) {
if (!PL_strncasecmp(ctype, "ja", 2)) {
GetPrefFonts(nsGkAtoms::Japanese, aFontEntryList);

Просмотреть файл

@ -47,8 +47,8 @@ void
gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics,
uint32_t* aSpaceGlyph)
{
NS_PRECONDITION(aMetrics != NULL, "aMetrics must not be NULL");
NS_PRECONDITION(aSpaceGlyph != NULL, "aSpaceGlyph must not be NULL");
NS_PRECONDITION(aMetrics != nullptr, "aMetrics must not be NULL");
NS_PRECONDITION(aSpaceGlyph != nullptr, "aSpaceGlyph must not be NULL");
if (MOZ_UNLIKELY(!mFace)) {
// No face. This unfortunate situation might happen if the font
@ -323,7 +323,7 @@ gfxFT2LockedFace::GetUVSGlyph(uint32_t aCharCode, uint32_t aVariantSelector)
uint32_t
gfxFT2LockedFace::GetCharExtents(char aChar, cairo_text_extents_t* aExtents)
{
NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL");
NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL");
if (!mFace)
return 0;

Просмотреть файл

@ -706,7 +706,7 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle,
// Most families are "simple", having just Regular/Bold/Italic/BoldItalic,
// or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts,
// stored in the above order; note that some of the entries may be NULL.
// stored in the above order; note that some of the entries may be nullptr.
// We can then pick the required entry based on whether the request is for
// bold or non-bold, italic or non-italic, without running the more complex
// matching algorithm used for larger families with many weights and/or widths.
@ -885,7 +885,7 @@ gfxFontFamily::FindWeightsForStyle(gfxFontEntry* aFontsForWeights[],
uint32_t count = mAvailableFonts.Length();
for (uint32_t i = 0; i < count; i++) {
// this is not called for "simple" families, and therefore it does not
// need to check the mAvailableFonts entries for NULL
// need to check the mAvailableFonts entries for nullptr.
gfxFontEntry *fe = mAvailableFonts[i];
uint32_t distance = StyleDistance(fe, anItalic, aStretch);
if (distance <= bestMatchDistance) {
@ -2526,8 +2526,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
Matrix mat, matInv;
Matrix oldMat = dt->GetTransform();
// This is NULL when we have inverse-transformed glyphs and we need to
// transform the Brush inside flush.
// This is nullptr when we have inverse-transformed glyphs and we need
// to transform the Brush inside flush.
Matrix *passedInvMatrix = nullptr;
RefPtr<GlyphRenderingOptions> renderingOptions =

Просмотреть файл

@ -350,12 +350,12 @@ public:
// Subclasses should override this if they can provide more efficient
// access than copying table data into our own buffers.
//
// Get blob that encapsulates a specific font table, or NULL if
// Get blob that encapsulates a specific font table, or nullptr if
// the table doesn't exist in the font.
//
// Caller is responsible to call hb_blob_destroy() on the returned blob
// (if non-NULL) when no longer required. For transient access to a table,
// use of AutoTable (below) is generally preferred.
// (if non-nullptr) when no longer required. For transient access to a
// table, use of AutoTable (below) is generally preferred.
virtual hb_blob_t *GetFontTable(uint32_t aTag);
// Stack-based utility to return a specified table, automatically releasing
@ -395,8 +395,8 @@ public:
// reference is owned by the caller. Removing the last reference
// unregisters the table from the font entry.
//
// Pass NULL for aBuffer to indicate that the table is not present and
// NULL will be returned. Also returns NULL on OOM.
// Pass nullptr for aBuffer to indicate that the table is not present and
// nullptr will be returned. Also returns nullptr on OOM.
hb_blob_t *ShareFontTableAndGetBlob(uint32_t aTag,
FallibleTArray<uint8_t>* aTable);
@ -1548,7 +1548,7 @@ public:
* @param aDrawMode specifies whether the fill or stroke of the glyph should be
* drawn, or if it should be drawn into the current path
* @param aObjectPaint information about how to construct the fill and
* stroke pattern. Can be NULL if we are not stroking the text, which
* stroke pattern. Can be nullptr if we are not stroking the text, which
* indicates that the current source from aContext should be used for filling
*
* Callers guarantee:

Просмотреть файл

@ -308,7 +308,7 @@ gfxFontconfigUtils::NewPattern(const nsTArray<nsString>& aFamilies,
}
gfxFontconfigUtils::gfxFontconfigUtils()
: mLastConfig(NULL)
: mLastConfig(nullptr)
{
mFontsByFamily.Init(50);
mFontsByFullname.Init(50);
@ -477,7 +477,7 @@ gfxFontconfigUtils::GetSampleLangForGroup(nsIAtom *aLangGroup,
}
}
}
const char *ctype = setlocale(LC_CTYPE, NULL);
const char *ctype = setlocale(LC_CTYPE, nullptr);
if (ctype &&
TryLangForGroup(nsDependentCString(ctype), aLangGroup, aFcLang))
return;
@ -494,9 +494,9 @@ nsresult
gfxFontconfigUtils::GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
nsIAtom *aLangGroup)
{
FcPattern *pat = NULL;
FcObjectSet *os = NULL;
FcFontSet *fs = NULL;
FcPattern *pat = nullptr;
FcObjectSet *os = nullptr;
FcFontSet *fs = nullptr;
nsresult rv = NS_ERROR_FAILURE;
aListOfFonts.Clear();
@ -505,7 +505,7 @@ gfxFontconfigUtils::GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
if (!pat)
goto end;
os = FcObjectSetBuild(FC_FAMILY, NULL);
os = FcObjectSetBuild(FC_FAMILY, nullptr);
if (!os)
goto end;
@ -514,7 +514,7 @@ gfxFontconfigUtils::GetFontListInternal(nsTArray<nsCString>& aListOfFonts,
AddLangGroup(pat, aLangGroup);
}
fs = FcFontList(NULL, pat, os);
fs = FcFontList(nullptr, pat, os);
if (!fs)
goto end;
@ -564,8 +564,8 @@ gfxFontconfigUtils::UpdateFontListInternal(bool aForce)
// This checks periodically according to fontconfig's configured
// <rescan> interval.
FcInitBringUptoDate();
} else if (!FcConfigUptoDate(NULL)) { // check now with aForce
mLastConfig = NULL;
} else if (!FcConfigUptoDate(nullptr)) { // check now with aForce
mLastConfig = nullptr;
FcInitReinitialize();
}
@ -669,11 +669,11 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
if (!IsExistingFamily(fontname))
return NS_OK;
FcPattern *pat = NULL;
FcObjectSet *os = NULL;
FcFontSet *givenFS = NULL;
FcPattern *pat = nullptr;
FcObjectSet *os = nullptr;
FcFontSet *givenFS = nullptr;
nsTArray<nsCString> candidates;
FcFontSet *candidateFS = NULL;
FcFontSet *candidateFS = nullptr;
rv = NS_ERROR_FAILURE;
pat = FcPatternCreate();
@ -682,11 +682,11 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)fontname.get());
os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, NULL);
os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, nullptr);
if (!os)
goto end;
givenFS = FcFontList(NULL, pat, os);
givenFS = FcFontList(nullptr, pat, os);
if (!givenFS)
goto end;
@ -718,7 +718,7 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString&
FcPatternDel(pat, FC_FAMILY);
FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j].get());
candidateFS = FcFontList(NULL, pat, os);
candidateFS = FcFontList(nullptr, pat, os);
if (!candidateFS)
goto end;
@ -834,7 +834,8 @@ bool
gfxFontconfigUtils::FontsByFullnameEntry::KeyEquals(KeyTypePointer aKey) const
{
const FcChar8 *key = mKey;
// If mKey is NULL, key comes from the style and family of the first font.
// If mKey is nullptr, key comes from the style and family of the first
// font.
nsAutoCString fullname;
if (!key) {
NS_ASSERTION(mFonts.Length(), "No font in FontsByFullnameEntry!");
@ -850,7 +851,7 @@ void
gfxFontconfigUtils::AddFullnameEntries()
{
// This FcFontSet is owned by fontconfig
FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem);
FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem);
// Record the existing font families
for (int f = 0; f < fontSet->nfont; ++f) {
@ -866,8 +867,8 @@ gfxFontconfigUtils::AddFullnameEntries()
// will always succeed, and so the entry will always have a
// font from which to obtain the key.
bool added = entry->AddFont(font);
// The key may be NULL either if this is the first font, or if
// the first font does not have a fullname property, and so
// The key may be nullptr either if this is the first font, or
// if the first font does not have a fullname property, and so
// the key is obtained from the font. Set the key in both
// cases. The check that AddFont succeeded is required for
// the second case.
@ -890,8 +891,8 @@ gfxFontconfigUtils::AddFullnameEntries()
if (entry) {
entry->AddFont(font);
// Either entry->mKey has been set for a previous font or it
// remains NULL to indicate that the key is obtained from the
// first font.
// remains nullptr to indicate that the key is obtained from
// the first font.
}
}
}
@ -1008,7 +1009,7 @@ gfxFontconfigUtils::GetLangSupportEntry(const FcChar8 *aLang, bool aWithFonts)
}
// This FcFontSet is owned by fontconfig
FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem);
FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem);
nsAutoTArray<FcPattern*,100> fonts;
@ -1046,7 +1047,7 @@ gfxFontconfigUtils::GetLangSupportEntry(const FcChar8 *aLang, bool aWithFonts)
// entry->mSupport needs to be recalculated, but this is an
// indication that the set of installed fonts has changed, so
// update all caches.
mLastConfig = NULL; // invalidates caches
mLastConfig = nullptr; // invalidates caches
UpdateFontListInternal(true);
return GetLangSupportEntry(aLang, aWithFonts);
}

Просмотреть файл

@ -181,11 +181,11 @@ public:
class DepFcStrEntry : public FcStrEntryBase {
public:
// When constructing a new entry in the hashtable, the key is left
// NULL. The caller of PutEntry() must fill in mKey when NULL. This
// provides a mechanism for the caller of PutEntry() to determine
// nullptr. The caller of PutEntry() must fill in mKey when nullptr.
// This provides a mechanism for the caller of PutEntry() to determine
// whether the entry has been initialized.
DepFcStrEntry(KeyTypePointer aName)
: mKey(NULL) { }
: mKey(nullptr) { }
DepFcStrEntry(const DepFcStrEntry& toCopy)
: mKey(toCopy.mKey) { }
@ -253,7 +253,7 @@ protected:
class FontsByFullnameEntry : public DepFcStrEntry {
public:
// When constructing a new entry in the hashtable, the key is left
// NULL. The caller of PutEntry() is must fill in mKey when adding
// nullptr. The caller of PutEntry() is must fill in mKey when adding
// the first font if the key is not derived from the family and style.
// If the key is derived from family and style, a font must be added.
FontsByFullnameEntry(KeyTypePointer aName)

Просмотреть файл

@ -40,7 +40,7 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry,
bool aNeedsBold,
AntialiasOption anAAOption)
: gfxFont(aFontEntry, aFontStyle, anAAOption),
mFont(NULL),
mFont(nullptr),
mFontFace(nullptr),
mMetrics(nullptr),
mSpaceGlyph(0),
@ -543,7 +543,7 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
AutoSelectFont fs(dc, GetHFONT());
int devWidth;
if (GetCharWidthI(dc, aGID, 1, NULL, &devWidth)) {
if (GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) {
// ensure width is positive, 16.16 fixed-point value
width = (devWidth & 0x7fff) << 16;
mGlyphWidths.Put(aGID, width);

Просмотреть файл

@ -243,7 +243,8 @@ GDIFontEntry::CopyFontTable(uint32_t aTableTag,
if (font.IsValid()) {
uint32_t tableSize =
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag), 0, NULL, 0);
NativeEndian::swapToBigEndian(aTableTag),
0, nullptr, 0);
if (tableSize != GDI_ERROR) {
if (aBuffer.SetLength(tableSize)) {
::GetFontData(dc.GetDC(),
@ -343,14 +344,14 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh)
} else {
// ScriptGetCMap works better than GetGlyphIndicesW
// for things like bitmap/vector fonts
SCRIPT_CACHE sc = NULL;
SCRIPT_CACHE sc = nullptr;
HRESULT rv = ScriptGetCMap(dc, &sc, str, 1, 0, glyph);
if (rv == S_OK)
hasGlyph = true;
}
SelectObject(dc, oldFont);
ReleaseDC(NULL, dc);
ReleaseDC(nullptr, dc);
if (hasGlyph) {
mCharacterMap->set(aCh);
@ -599,7 +600,7 @@ gfxGDIFontList::GetFontSubstitutes()
lenAlias = ArrayLength(aliasName);
actualName[0] = 0;
lenActual = sizeof(actualName);
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType,
rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType,
(LPBYTE)actualName, &lenActual);
if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {

Просмотреть файл

@ -17,11 +17,11 @@ class AutoDC // get the global device context, and auto-release it on destructio
{
public:
AutoDC() {
mDC = ::GetDC(NULL);
mDC = ::GetDC(nullptr);
}
~AutoDC() {
::ReleaseDC(NULL, mDC);
::ReleaseDC(nullptr, mDC);
}
HDC GetDC() {
@ -44,7 +44,7 @@ public:
mDC = aDC;
mOldFont = (HFONT)::SelectObject(aDC, mFont);
} else {
mOldFont = NULL;
mOldFont = nullptr;
}
}
@ -66,7 +66,7 @@ public:
}
bool IsValid() const {
return mFont != NULL;
return mFont != nullptr;
}
HFONT GetFont() const {

Просмотреть файл

@ -52,7 +52,7 @@ gfxGDIShaper::ShapeText(gfxContext *aContext,
glyphs,
length,
INT_MAX,
NULL,
nullptr,
partialWidthArray.Elements(),
&size);
if (!success) {

Просмотреть файл

@ -44,7 +44,7 @@ gfxGdkNativeRenderer::DrawWithXlib(gfxXlibSurface* surface,
}
return DrawWithGDK(drawable, offset.x, offset.y,
numClipRects ? &clipRect : NULL, numClipRects);
numClipRects ? &clipRect : nullptr, numClipRects);
}
void

Просмотреть файл

@ -46,7 +46,7 @@ void
gfxImageSurface::MakeInvalid()
{
mSize = gfxIntSize(-1, -1);
mData = NULL;
mData = nullptr;
mStride = 0;
}

Просмотреть файл

@ -60,7 +60,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl
// synthetic oblique by skewing via the font matrix
bool needsOblique =
(mFontEntry != NULL) &&
(mFontEntry != nullptr) &&
(!mFontEntry->IsItalic() &&
(mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)));
@ -369,7 +369,7 @@ gfxMacFont::InitMetricsFromPlatform()
{
CTFontRef ctFont = ::CTFontCreateWithGraphicsFont(mCGFont,
mAdjustedSize,
NULL, NULL);
nullptr, nullptr);
if (!ctFont) {
return;
}

Просмотреть файл

@ -356,7 +356,7 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace()
// finally find a matching font
FcResult fcRes;
FcPattern *fcMatch = FcFontMatch(NULL, fcPattern, &fcRes);
FcPattern *fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes);
// Most code that depends on FcFontMatch() assumes it won't fail,
// then crashes when it does. For now, at least, substitute the
@ -370,7 +370,7 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace()
//#endif
// FcPatternAddString() will free the existing FC_FAMILY string
FcPatternAddString(fcPattern, FC_FAMILY, (FcChar8*)"SERIF");
fcMatch = FcFontMatch(NULL, fcPattern, &fcRes);
fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes);
//#ifdef DEBUG
printf("Attempt to substitute default SERIF font %s\n",
fcMatch ? "succeeded" : "failed");
@ -449,7 +449,7 @@ bool gfxOS2Font::SetupCairoFont(gfxContext *aContext)
#endif
// gfxPangoFont checks the CTM but Windows doesn't so leave away here, too
// this implicitely ensures that mScaledFont is created if NULL
// this implicitely ensures that mScaledFont is created if nullptr
cairo_scaled_font_t *scaledFont = CairoScaledFont();
if (!scaledFont || cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) {
// Don't cairo_set_scaled_font as that would propagate the error to

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше