Merge last PGO-green changeset of mozilla-inbound to mozilla-central

This commit is contained in:
Ed Morley 2012-08-16 14:14:29 +01:00
commit 62f12670ea
189 changed files with 3864 additions and 2403 deletions

View File

@ -37,7 +37,6 @@ ifndef LIBXUL_SDK
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
tier_base_dirs += \
other-licenses/android \
other-licenses/skia-npapi \
$(NULL)
endif
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))

View File

@ -44,7 +44,7 @@ var AccessFu = {
this.prefsBranch.addObserver('activate', this, false);
this.prefsBranch.addObserver('explorebytouch', this, false);
if (Utils.OS == 'Android')
if (Utils.MozBuildApp == 'mobile/android')
Services.obs.addObserver(this, 'Accessibility:Settings', false);
this._processPreferences();
@ -116,7 +116,7 @@ var AccessFu = {
} catch (x) {
}
if (Utils.OS == 'Android') {
if (Utils.MozBuildApp == 'mobile/android') {
if (accessPref == ACCESSFU_AUTO) {
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(

View File

@ -152,7 +152,7 @@ var UtteranceGenerator = {
'outlineitem': INCLUDE_DESC,
'pagetab': INCLUDE_DESC,
'graphic': INCLUDE_DESC,
'pushbutton': INCLUDE_DESC,
'pushbutton': INCLUDE_DESC | INCLUDE_NAME,
'checkbutton': INCLUDE_DESC,
'radiobutton': INCLUDE_DESC,
'combobox': INCLUDE_DESC,

View File

@ -260,28 +260,6 @@ var VirtualCursorController = {
}
this[methodName](document, false, rule);
break;
case aEvent.DOM_VK_END:
if (this.editableState) {
if (target.selectionEnd != target.textLength)
// Don't move forward if caret is not at end of entry.
// XXX: Fix for rtl
return;
else
target.blur();
}
this.moveForward(document, true);
break;
case aEvent.DOM_VK_HOME:
if (this.editableState) {
if (target.selectionEnd != 0)
// Don't move backward if caret is not at start of entry.
// XXX: Fix for rtl
return;
else
target.blur();
}
this.moveBackward(document, true);
break;
case aEvent.DOM_VK_RIGHT:
if (this.editableState) {
if (target.selectionEnd != target.textLength)
@ -313,7 +291,7 @@ var VirtualCursorController = {
target.blur();
}
if (Utils.OS == 'Android')
if (Utils.MozBuildApp == 'mobile/android')
// Return focus to native Android browser chrome.
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(

View File

@ -502,3 +502,9 @@ pref("hal.processPriorityManager.gonk.backgroundOomAdjust", 2);
pref("hal.processPriorityManager.gonk.masterNice", -1);
pref("hal.processPriorityManager.gonk.foregroundNice", 0);
pref("hal.processPriorityManager.gonk.backgroundNice", 10);
// Enable pre-launching content processes for improved startup time
// (hiding latency).
pref("dom.ipc.processPrelauch.enabled", true);
// Wait this long before pre-launching a new subprocess.
pref("dom.ipc.processPrelauch.delayMs", 1000);

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="11px" style="position: absolute; top: -moz-calc(50% - 2px);">
<polyline points="1 1 5 6 9 1" stroke="#414141" stroke-width="2" stroke-linecap="round" fill="transparent" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 360 B

View File

@ -74,3 +74,216 @@ xul|thumb {
:-moz-any(video, audio) > xul|videocontrols {
-moz-binding: url("chrome://global/content/bindings/videocontrols.xml#touchControls");
}
select:not([size]):not([multiple]) > xul|scrollbar,
select[size="1"] > xul|scrollbar,
select:not([size]):not([multiple]) xul|scrollbarbutton,
select[size="1"] xul|scrollbarbutton {
display: block;
margin-left: 0;
min-width: 16px;
}
/* Override inverse OS themes */
select,
textarea,
button,
xul|button,
* > input:not([type="image"]) {
-moz-appearance: none !important; /* See bug 598421 for fixing the platform */
border-radius: 3px;
}
select[size],
select[multiple],
select[size][multiple],
textarea,
* > input:not([type="image"]) {
border-style: solid;
border-color: #7d7d7d;
color: #414141;
background: white -moz-linear-gradient(top, rgba(115,115,115,0.5) 0, rgba(215,215,215,0.5) 3px, rgba(255,255,255,0.2) 16px);
}
/* Selects are handled by the form helper, see bug 685197 */
select option, select optgroup {
pointer-events: none;
}
input:-moz-placeholder,
textarea:-moz-placeholder {
color: GrayText;
}
select:not([size]):not([multiple]),
select[size="0"],
select[size="1"],
* > input[type="button"],
* > input[type="submit"],
* > input[type="reset"],
button {
border-style: solid;
border-color: #7d7d7d;
color: #414141;
background: white -moz-linear-gradient(top, rgba(255,255,255,0.2) 0, rgba(215,215,215,0.5) 18px, rgba(115,115,115,0.5) 100%);
}
input[type="checkbox"] {
background: white -moz-linear-gradient(top, rgba(115,115,115,0.5) 0, rgba(215,215,215,0.5) 2px, rgba(255,255,255,0.2) 6px);
}
input[type="radio"] {
background: -moz-radial-gradient(6px 6px, cover, rgba(255,255,255,0.2) 3px, rgba(195,195,195,0.5) 5px, rgba(115,115,115,0.5) 100%);
}
select {
border-width: 1px;
padding: 1px;
}
select:not([size]):not([multiple]),
select[size="0"],
select[size="1"] {
padding: 0 1px 0 1px;
}
* > input:not([type="image"]) {
border-width: 1px;
padding: 1px;
}
textarea {
resize: none;
border-width: 1px;
padding: 2px 1px 2px 1px;
}
input[type="button"],
input[type="submit"],
input[type="reset"],
button {
border-width: 1px;
padding: 0 7px 0 7px;
}
input[type="radio"],
input[type="checkbox"] {
max-width: 14px;
max-height: 14px;
border: 1px solid #a7a7a7 !important;
padding: 2px 1px 2px 1px;
}
select > button {
border-width: 0px !important;
margin: 0px !important;
padding: 0px !important;
border-radius: 0;
color: #414141;
background-image: -moz-radial-gradient(bottom left, #bbbbbb 40%, #f5f5f5), url(arrow.svg) !important;
background-color: transparent;
background-position: -15px center, 4px center !important;
background-repeat: no-repeat, no-repeat !important;
background-size: 100% 90%, normal normal;
-moz-binding: none !important;
position: relative !important;
font-size: inherit;
}
select[size]:focus,
select[multiple]:focus,
select[size][multiple]:focus,
textarea:focus,
input[type="file"]:focus > input[type="text"],
* > input:not([type="image"]):focus {
outline: 0px !important;
border-style: solid;
border-color: rgb(94,128,153);
background: white -moz-linear-gradient(top, rgba(27,113,177,0.5) 0, rgba(198,225,246,0.2) 3px, rgba(255,255,255,0.2) 16px);
}
select:not([size]):not([multiple]):focus,
select[size="0"]:focus,
select[size="1"]:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
button:focus {
outline: 0px !important;
border-style: solid;
border-color: rgb(94,128,153);
background: white -moz-linear-gradient(top, rgba(255,255,255,0.2) 0, rgba(198,225,256,0.2) 18px, rgba(27,113,177,0.5) 100%);
}
input[type="checkbox"]:focus,
input[type="radio"]:focus {
border-color: #99c6e0 !important;
}
input[type="checkbox"]:focus {
background: white -moz-linear-gradient(top, rgba(27,113,177,0.5) 0, rgba(198,225,246,0.2) 2px, rgba(255,255,255,0.2) 6px);
}
input[type="radio"]:focus {
background: -moz-radial-gradient(6px 6px, cover, rgba(255,255,255,0.2) 3px, rgba(198,225,246,0.2) 5px, rgba(27,113,177,0.5) 100%);
}
/* we need to be specific for selects because the above rules are specific too */
textarea[disabled],
select[size][disabled],
select[multiple][disabled],
select[size][multiple][disabled],
select:not([size]):not([multiple])[disabled],
select[size="0"][disabled],
select[size="1"][disabled],
button[disabled],
* > input:not([type="image"])[disabled] {
color: rgba(0,0,0,0.3);
border-color: rgba(125,125,125,0.4);
border-style: solid;
border-width: 1px;
background: transparent -moz-linear-gradient(top, rgba(185,185,185,0.4) 0, rgba(235,235,235,0.4) 3px, rgba(255,255,255,0.4) 100%);
}
select:not([size]):not([multiple])[disabled],
select[size="0"][disabled],
select[size="1"][disabled] {
background: transparent -moz-linear-gradient(top, rgba(255,255,255,0.4) 0, rgba(235,235,235,0.4) 3px, rgba(185,185,185,0.4) 100%);
}
input[type="button"][disabled],
input[type="submit"][disabled],
input[type="reset"][disabled],
button[disabled="true"] {
padding: 0 7px 0 7px;
background: transparent -moz-linear-gradient(top, rgba(255,255,255,0.4) 0, rgba(235,235,235,0.4) 3px, rgba(185,185,185,0.4) 100%);
}
input[type="radio"][disabled],
input[type="radio"][disabled]:active,
input[type="radio"][disabled]:hover,
input[type="radio"][disabled]:hover:active,
input[type="checkbox"][disabled],
input[type="checkbox"][disabled]:active,
input[type="checkbox"][disabled]:hover,
input[type="checkbox"][disabled]:hover:active {
border:1px solid rgba(125,125,125,0.4) !important;
}
select[disabled] > button {
opacity: 0.6;
padding: 1px 7px 1px 7px;
}
*:-moz-any-link:active,
*[role=button]:active,
button:active,
input:active,
option:active,
select:active,
label:active,
textarea:active {
background-color: rgba(141, 184, 216, 0.5);
}

View File

@ -8,6 +8,7 @@ chrome.jar:
% content branding %content/branding/
% content browser %content/
content/arrow.svg (content/arrow.svg)
content/dbg-browser-actors.js (content/dbg-browser-actors.js)
content/forms.js (content/forms.js)
content/settings.js (content/settings.js)

View File

@ -116,16 +116,16 @@ let TestObserver = {
return;
}
is(aSubject.category, TESTS[pos].category,
"test #" + pos + ": error category '" + TESTS[pos].category + "'");
var expectedCategory = TESTS[pos].category;
if (aSubject.category == TESTS[pos].category) {
info("test #" + pos + " console observer got " + aSubject.category + ", is expecting " + expectedCategory);
if (aSubject.category == expectedCategory) {
foundCategory = true;
}
else {
ok(false, aSubject.sourceName + ':' + aSubject.lineNumber + '; ' +
info("unexpected message was: " + aSubject.sourceName + ':' + aSubject.lineNumber + '; ' +
aSubject.errorMessage);
testEnded = true;
}
}
};

View File

@ -43,6 +43,8 @@ class B2GRemoteAutomation(Automation):
self.marionette = marionette
self.context_chrome = context_chrome
self._is_emulator = False
self.test_script = None
self.test_script_args = None
# Default our product to b2g
self._product = "b2g"
@ -254,14 +256,14 @@ class B2GRemoteAutomation(Automation):
# provided by B2G's shell.js.
self.marionette.execute_script("document.getElementById('homescreen').src='%s';" % self.testURL)
# run the script that starts the tests
elif hasattr(self, 'testScript'):
if os.path.isfile(self.testScript):
script = open(self.testScript, 'r')
self.marionette.execute_script(script.read())
elif self.test_script:
if os.path.isfile(self.test_script):
script = open(self.test_script, 'r')
self.marionette.execute_script(script.read(), script_args=self.test_script_args)
script.close()
else:
# assume testScript is a string
self.marionette.execute_script(self.testScript)
# assume test_script is a string
self.marionette.execute_script(self.test_script, script_args=self.test_script_args)
else:
# assumes the tests are started on startup automatically
pass

View File

@ -86,6 +86,21 @@ def do_cvs_export(modules, tag, cvsroot, cvs):
cwd=os.path.join(topsrcdir, parent))
print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
def toggle_trailing_blank_line(depname):
"""If the trailing line is empty, then we'll delete it.
Otherwise we'll add a blank line."""
lines = open(depname, "r").readlines()
if not lines:
print >>sys.stderr, "unexpected short file"
return
if not lines[-1].strip():
# trailing line is blank, removing it
open(depname, "w").writelines(lines[:-1])
else:
# adding blank line
open(depname, "a").write("\n")
o = OptionParser(usage="client.py [options] update_nspr tagname | update_nss tagname | update_libffi tagname | update_webidlparser tagname")
o.add_option("--skip-mozilla", dest="skip_mozilla",
action="store_true", default=False,
@ -114,6 +129,7 @@ elif action in ('update_nspr'):
options.cvsroot = os.environ.get('CVSROOT', CVSROOT_MOZILLA)
do_cvs_export(NSPR_DIRS, tag, options.cvsroot, options.cvs)
print >>file("nsprpub/TAG-INFO", "w"), tag
toggle_trailing_blank_line("nsprpub/config/prdepend.h")
elif action in ('update_nss'):
tag, = args[1:]
if not options.cvsroot:
@ -121,6 +137,7 @@ elif action in ('update_nss'):
do_cvs_export(NSS_DIRS, tag, options.cvsroot, options.cvs)
print >>file("security/nss/TAG-INFO", "w"), tag
print >>file("security/nss/TAG-INFO-CKBI", "w"), tag
toggle_trailing_blank_line("security/coreconf/coreconf.dep")
elif action in ('update_nssckbi'):
tag, = args[1:]
if not options.cvsroot:

View File

@ -17,7 +17,8 @@
#include "nsIDocument.h"
#include "nsIFileStreams.h"
#include "nsIInputStream.h"
#include "nsIIPCSerializable.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsIIPCSerializableObsolete.h"
#include "nsIMIMEService.h"
#include "nsIPlatformCharset.h"
#include "nsISeekableStream.h"
@ -47,8 +48,9 @@ using namespace mozilla::dom;
// stream is. We do that by passing back this class instead.
class DataOwnerAdapter MOZ_FINAL : public nsIInputStream,
public nsISeekableStream,
public nsIIPCSerializable,
public nsIClassInfo
public nsIIPCSerializableObsolete,
public nsIClassInfo,
public nsIIPCSerializableInputStream
{
typedef nsDOMMemoryFile::DataOwner DataOwner;
public:
@ -65,16 +67,18 @@ public:
// These are optional. We use a conditional QI to keep them from being called
// if the underlying stream doesn't QI to either interface.
NS_FORWARD_NSIIPCSERIALIZABLE(mSerializable->)
NS_FORWARD_NSIIPCSERIALIZABLEOBSOLETE(mSerializableObsolete->)
NS_FORWARD_NSICLASSINFO(mClassInfo->)
NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(mSerializableInputStream->)
private:
DataOwnerAdapter(DataOwner* aDataOwner,
nsIInputStream* aStream)
: mDataOwner(aDataOwner), mStream(aStream),
mSeekableStream(do_QueryInterface(aStream)),
mSerializable(do_QueryInterface(aStream)),
mClassInfo(do_QueryInterface(aStream))
mSerializableObsolete(do_QueryInterface(aStream)),
mClassInfo(do_QueryInterface(aStream)),
mSerializableInputStream(do_QueryInterface(aStream))
{
NS_ASSERTION(mSeekableStream, "Somebody gave us the wrong stream!");
}
@ -82,8 +86,9 @@ private:
nsRefPtr<DataOwner> mDataOwner;
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsISeekableStream> mSeekableStream;
nsCOMPtr<nsIIPCSerializable> mSerializable;
nsCOMPtr<nsIIPCSerializableObsolete> mSerializableObsolete;
nsCOMPtr<nsIClassInfo> mClassInfo;
nsCOMPtr<nsIIPCSerializableInputStream> mSerializableInputStream;
};
NS_IMPL_THREADSAFE_ADDREF(DataOwnerAdapter)
@ -92,8 +97,11 @@ NS_IMPL_THREADSAFE_RELEASE(DataOwnerAdapter)
NS_INTERFACE_MAP_BEGIN(DataOwnerAdapter)
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
NS_INTERFACE_MAP_ENTRY(nsISeekableStream)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializable, mSerializable)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableObsolete,
mSerializableObsolete)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIClassInfo, mClassInfo)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIIPCSerializableInputStream,
mSerializableInputStream)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream)
NS_INTERFACE_MAP_END

View File

@ -317,6 +317,10 @@ EVENT(waiting,
NS_WAITING,
EventNameType_HTML,
NS_EVENT_NULL)
EVENT(wheel,
NS_WHEEL_WHEEL,
EventNameType_All,
NS_WHEEL_EVENT)
// Gecko-specific extensions that apply to elements
EVENT(copy,
NS_COPY,
@ -600,10 +604,6 @@ NON_IDL_EVENT(underflow,
NS_SCROLLPORT_UNDERFLOW,
EventNameType_XUL,
NS_EVENT_NULL)
NON_IDL_EVENT(wheel,
NS_WHEEL_WHEEL,
EventNameType_XUL,
NS_WHEEL_EVENT)
// Various SVG events
NON_IDL_EVENT(SVGLoad,

View File

@ -652,6 +652,42 @@ function testEventOrder()
SpecialPowers.removeSystemEventListener(window, "MozMousePixelScroll", systemHandler, true);
}
var gOnWheelAttrHandled = new Array;
function testOnWheelAttr()
{
document.documentElement.setAttribute("onwheel", "gOnWheelAttrHandled['html'] = true;");
document.body.setAttribute("onwheel", "gOnWheelAttrHandled['body'] = true;");
gScrollableElement.setAttribute("onwheel", "gOnWheelAttrHandled['div'] = true;");
var target = document.getElementById("onwheel");
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 1.0, deltaY: 2.0 });
ok(gOnWheelAttrHandled['html'], "html element's onwheel attribute isn't performed");
ok(gOnWheelAttrHandled['body'], "body element's onwheel attribute isn't performed");
ok(gOnWheelAttrHandled['div'], "div element's onwheel attribute isn't performed");
}
var gOnWheelPropHandled = new Array;
function testOnWheelProperty()
{
window.onwheel = function (e) { gOnWheelPropHandled["window"] = true; }
document.onwheel = function (e) { gOnWheelPropHandled["document"] = true; }
document.documentElement.onwheel = function (e) { gOnWheelPropHandled["html"] = true; };
document.body.onwheel = function (e) { gOnWheelPropHandled["body"] = true; };
gScrollableElement.onwheel = function (e) { gOnWheelPropHandled["div"] = true; };
var target = document.getElementById("onwheel");
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 1.0, deltaY: 2.0 });
ok(gOnWheelPropHandled['window'], "window's onwheel property isn't performed");
ok(gOnWheelPropHandled['document'], "document's onwheel property isn't performed");
ok(gOnWheelPropHandled['html'], "html element's onwheel property isn't performed");
ok(gOnWheelPropHandled['body'], "body element's onwheel property isn't performed");
ok(gOnWheelPropHandled['div'], "div element's onwheel property isn't performed");
}
function runTests()
{
SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
@ -678,6 +714,8 @@ function runTests()
testDeltaMultiplierPrefs();
testDispatchingUntrustEvent();
testEventOrder();
testOnWheelAttr();
testOnWheelProperty();
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");

View File

@ -9,7 +9,6 @@
#include "base/basictypes.h"
#include "IPC/IPCMessageUtils.h"
#include "nsIIPCSerializable.h"
#include "nsILoadContext.h"
/*

View File

@ -251,7 +251,11 @@ let Activities = {
let matchFunc = function matchFunc(aResult) {
// Bug 773383: arrays of strings / regexp.
for (let prop in aResult.description.filters) {
if (aMsg.options.data[prop] !== aResult.description.filters[prop]) {
if (Array.isArray(aResult.description.filters[prop])) {
if (aResult.description.filters[prop].indexOf(aMsg.options.data[prop]) == -1) {
return false;
}
} else if (aResult.description.filters[prop] !== aMsg.options.data[prop] ) {
return false;
}
}

View File

@ -39,6 +39,8 @@ XPCOMUtils.defineLazyGetter(this, "msgmgr", function() {
#ifdef MOZ_WIDGET_GONK
const DIRECTORY_NAME = "webappsDir";
#elifdef ANDROID
const DIRECTORY_NAME = "webappsDir";
#else
// If we're executing in the context of the webapp runtime, the data files
// are in a different directory (currently the Firefox profile that installed
@ -58,7 +60,7 @@ let DOMApplicationRegistry = {
"Webapps:Launch", "Webapps:GetAll",
"Webapps:InstallPackage", "Webapps:GetBasePath",
"WebApps:GetAppByManifestURL", "WebApps:GetAppLocalIdByManifestURL",
"WebApps:GetAppByLocalId", "Webapps:GetManifestURLByLocalId"];
"WebApps:GetAppByLocalId", "WebApps:GetManifestURLByLocalId"];
this.messages.forEach((function(msgName) {
ppmm.addMessageListener(msgName, this);

View File

@ -40,9 +40,11 @@ public:
MOZ_ASSERT(NS_IsMainThread());
if (!mEnabled || gInShutdown) {
nsCOMPtr<nsIThread> t;
gBluetoothService->mBluetoothCommandThread.swap(t);
t->Shutdown();
if (gBluetoothService->mBluetoothCommandThread) {
nsCOMPtr<nsIThread> t;
gBluetoothService->mBluetoothCommandThread.swap(t);
t->Shutdown();
}
}
if (gInShutdown) {

View File

@ -79,50 +79,51 @@ ContactAddress.prototype = {
QueryInterface : XPCOMUtils.generateQI([nsIDOMContactAddress])
}
//ContactEmail
//ContactField
const CONTACTEMAIL_CONTRACTID = "@mozilla.org/contactEmail;1";
const CONTACTEMAIL_CID = Components.ID("{94811520-c11f-11e1-afa7-0800200c9a66}");
const nsIDOMContactEmail = Components.interfaces.nsIDOMContactEmail;
const CONTACTFIELD_CONTRACTID = "@mozilla.org/contactField;1";
const CONTACTFIELD_CID = Components.ID("{e2cb19c0-e4aa-11e1-9b23-0800200c9a66}");
const nsIDOMContactField = Components.interfaces.nsIDOMContactField;
function ContactEmail(aType, aAddress) {
function ContactField(aType, aValue) {
this.type = aType || null;
this.address = aAddress || null;
this.value = aValue || null;
};
ContactEmail.prototype = {
ContactField.prototype = {
classID : CONTACTEMAIL_CID,
classInfo : XPCOMUtils.generateCI({classID: CONTACTEMAIL_CID,
contractID: CONTACTEMAIL_CONTRACTID,
classDescription: "ContactEmail",
interfaces: [nsIDOMContactEmail],
classID : CONTACTFIELD_CID,
classInfo : XPCOMUtils.generateCI({classID: CONTACTFIELD_CID,
contractID: CONTACTFIELD_CONTRACTID,
classDescription: "ContactField",
interfaces: [nsIDOMContactField],
flags: nsIClassInfo.DOM_OBJECT}),
QueryInterface : XPCOMUtils.generateQI([nsIDOMContactEmail])
QueryInterface : XPCOMUtils.generateQI([nsIDOMContactField])
}
//ContactTelephone
//ContactTelField
const CONTACTTELEPHONE_CONTRACTID = "@mozilla.org/contactTelephone;1";
const CONTACTTELEPHONE_CID = Components.ID("{82601b20-89e8-11e1-b0c4-0800200c9a66}");
const nsIDOMContactTelephone = Components.interfaces.nsIDOMContactTelephone;
const CONTACTTELFIELD_CONTRACTID = "@mozilla.org/contactTelField;1";
const CONTACTTELFIELD_CID = Components.ID("{ed0ab260-e4aa-11e1-9b23-0800200c9a66}");
const nsIDOMContactTelField = Components.interfaces.nsIDOMContactTelField;
function ContactTelephone(aType, aNumber) {
function ContactTelField(aType, aValue, aCarrier) {
this.type = aType || null;
this.number = aNumber || null;
this.value = aValue || null;
this.carrier = aCarrier || null;
};
ContactTelephone.prototype = {
ContactTelField.prototype = {
classID : CONTACTTELEPHONE_CID,
classInfo : XPCOMUtils.generateCI({classID: CONTACTTELEPHONE_CID,
contractID: CONTACTTELEPHONE_CONTRACTID,
classDescription: "ContactTelephone",
interfaces: [nsIDOMContactTelephone],
classID : CONTACTTELFIELD_CID,
classInfo : XPCOMUtils.generateCI({classID: CONTACTTELFIELD_CID,
contractID: CONTACTTELFIELD_CONTRACTID,
classDescription: "ContactTelField",
interfaces: [nsIDOMContactTelField],
flags: nsIClassInfo.DOM_OBJECT}),
QueryInterface : XPCOMUtils.generateQI([nsIDOMContactTelephone])
QueryInterface : XPCOMUtils.generateQI([nsIDOMContactTelField])
}
//ContactFindOptions
@ -196,13 +197,12 @@ Contact.prototype = {
aProp.email = Array.isArray(aProp.email) ? aProp.email : [aProp.email];
this.email = new Array();
for (let i = 0; i < aProp.email.length; i++)
this.email.push(new ContactEmail(aProp.email[i].type, aProp.email[i].address));
this.email.push(new ContactField(aProp.email[i].type, aProp.email[i].value));
} else {
this.email = null;
}
this.photo = _checkBlobArray(aProp.photo) || null;
this.url = _create(aProp.url) || null;
this.category = _create(aProp.category) || null;
if (aProp.adr) {
@ -221,7 +221,7 @@ Contact.prototype = {
aProp.tel = Array.isArray(aProp.tel) ? aProp.tel : [aProp.tel];
this.tel = new Array();
for (let i = 0; i < aProp.tel.length; i++)
this.tel.push(new ContactTelephone(aProp.tel[i].type, aProp.tel[i].number));
this.tel.push(new ContactTelField(aProp.tel[i].type, aProp.tel[i].value, aProp.tel[i].carrier));
} else {
this.tel = null;
}
@ -230,7 +230,25 @@ Contact.prototype = {
this.jobTitle = _create(aProp.jobTitle) || null;
this.bday = (aProp.bday == "undefined" || aProp.bday == null) ? null : new Date(aProp.bday);
this.note = _create(aProp.note) || null;
this.impp = _create(aProp.impp) || null;
if (aProp.impp) {
aProp.impp = Array.isArray(aProp.impp) ? aProp.impp : [aProp.impp];
this.impp = new Array();
for (let i = 0; i < aProp.impp.length; i++)
this.impp.push(new ContactField(aProp.impp[i].type, aProp.impp[i].value));
} else {
this.impp = null;
}
if (aProp.url) {
aProp.url = Array.isArray(aProp.url) ? aProp.url : [aProp.url];
this.url = new Array();
for (let i = 0; i < aProp.url.length; i++)
this.url.push(new ContactField(aProp.url[i].type, aProp.url[i].value));
} else {
this.url = null;
}
this.anniversary = (aProp.anniversary == "undefined" || aProp.anniversary == null) ? null : new Date(aProp.anniversary);
this.sex = (aProp.sex != "undefined") ? aProp.sex : null;
this.genderIdentity = (aProp.genderIdentity != "undefined") ? aProp.genderIdentity : null;
@ -539,4 +557,4 @@ ContactManager.prototype = {
}
const NSGetFactory = XPCOMUtils.generateNSGetFactory(
[Contact, ContactManager, ContactProperties, ContactAddress, ContactTelephone, ContactFindOptions, ContactEmail])
[Contact, ContactManager, ContactProperties, ContactAddress, ContactField, ContactTelField, ContactFindOptions])

View File

@ -4,11 +4,11 @@ contract @mozilla.org/contactProperties;1 {f5181640-89e8-11e1-b0c4-0800200c9a66}
component {eba48030-89e8-11e1-b0c4-0800200c9a66} ContactManager.js
contract @mozilla.org/contactAddress;1 {eba48030-89e8-11e1-b0c4-0800200c9a66}
component {82601b20-89e8-11e1-b0c4-0800200c9a66} ContactManager.js
contract @mozilla.org/contactTelephone;1 {82601b20-89e8-11e1-b0c4-0800200c9a66}
component {e2cb19c0-e4aa-11e1-9b23-0800200c9a66} ContactManager.js
contract @mozilla.org/contactField;1 {e2cb19c0-e4aa-11e1-9b23-0800200c9a66}
component {94811520-c11f-11e1-afa7-0800200c9a66} ContactManager.js
contract @mozilla.org/contactEmail;1 {94811520-c11f-11e1-afa7-0800200c9a66}
component {ed0ab260-e4aa-11e1-9b23-0800200c9a66} ContactManager.js
contract @mozilla.org/contactTelField;1 {ed0ab260-e4aa-11e1-9b23-0800200c9a66}
component {e31daea0-0cb6-11e1-be50-0800200c9a66} ContactManager.js
contract @mozilla.org/contactFindOptions;1 {e31daea0-0cb6-11e1-be50-0800200c9a66}

View File

@ -22,7 +22,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
const DB_NAME = "contacts";
const DB_VERSION = 3;
const DB_VERSION = 4;
const STORE_NAME = "contacts";
function ContactDB(aGlobal) {
@ -126,6 +126,37 @@ ContactDB.prototype = {
// Create new searchable indexes.
objectStore.createIndex("email", "search.email", { unique: false, multiEntry: true });
} else if (currVersion == 3) {
debug("upgrade 3");
if (!objectStore) {
objectStore = aTransaction.objectStore(STORE_NAME);
}
// Upgrade existing impp field in the DB.
objectStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (cursor) {
debug("upgrade impp1: " + JSON.stringify(cursor.value));
cursor.value.properties.impp =
cursor.value.properties.impp.map(function(value) { return { value: value }; });
cursor.update(cursor.value);
debug("upgrade impp2: " + JSON.stringify(cursor.value));
cursor.continue();
}
};
// Upgrade existing url field in the DB.
objectStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (cursor) {
debug("upgrade url1: " + JSON.stringify(cursor.value));
cursor.value.properties.url =
cursor.value.properties.url.map(function(value) { return { value: value }; });
cursor.update(cursor.value);
debug("upgrade impp2: " + JSON.stringify(cursor.value));
cursor.continue();
}
};
}
}
},
@ -184,24 +215,31 @@ ContactDB.prototype = {
// "+1-234-567" should also be found with 1234, 234-56, 23456
// Chop off the first characters
let number = aContact.properties[field][i].number;
for(let i = 0; i < number.length; i++) {
contact.search[field].push(number.substring(i, number.length));
}
// Store +1-234-567 as ["1234567", "234567"...]
let digits = number.match(/\d/g);
if (digits && number.length != digits.length) {
digits = digits.join('');
for(let i = 0; i < digits.length; i++) {
contact.search[field].push(digits.substring(i, digits.length));
let number = aContact.properties[field][i].value;
if (number) {
for (let i = 0; i < number.length; i++) {
contact.search[field].push(number.substring(i, number.length));
}
// Store +1-234-567 as ["1234567", "234567"...]
let digits = number.match(/\d/g);
if (digits && number.length != digits.length) {
digits = digits.join('');
for(let i = 0; i < digits.length; i++) {
contact.search[field].push(digits.substring(i, digits.length));
}
}
}
debug("lookup: " + JSON.stringify(contact.search[field]));
}
} else if (field == "email") {
let address = aContact.properties[field][i].address;
let address = aContact.properties[field][i].value;
if (address && typeof address == "string") {
contact.search[field].push(address.toLowerCase());
}
} else if (field == "impp") {
let value = aContact.properties[field][i].value;
if (value && typeof value == "string") {
contact.search[field].push(value.toLowerCase());
}
} else {
let val = aContact.properties[field][i];
if (typeof val == "string") {

View File

@ -78,9 +78,9 @@ var properties1 = {
familyName: ["TestFamilyName","Wagner"],
givenName: ["Test1","Test2"],
nickname: "nicktest",
tel: [{type: "work", number: "123456"} , {type: "home", number: "+9-876-5432"}],
tel: [{type: ["work"], value: "123456", carrier: "testCarrier"} , {type: ["home", "fax"], value: "+9-876-5432"}],
adr: adr1,
email: [{type: "work", address: "x@y.com"}]
email: [{type: ["work"], value: "x@y.com"}]
};
var properties2 = {
@ -91,16 +91,16 @@ var properties2 = {
honorificSuffix: "dummyHonorificSuffix",
additionalName: "dummyadditionalName",
nickname: "dummyNickname",
tel: [{type: "test", number: "123456789"},{type: "home", number: "234567890"}],
email: [{type: "test", address: "a@b.c"}, {address: "b@c.d"}],
tel: [{type: ["test"], value: "123456789"},{type: ["home", "custom"], value: "234567890"}],
email: [{type: ["test"], value: "a@b.c"}, {value: "b@c.d"}],
adr: [adr1, adr2],
impp: ["im1", "im2"],
impp: [{type: ["aim"], value:"im1"}, {value: "im2"}],
org: ["org1", "org2"],
jobTitle: ["boss", "superboss"],
bday: new Date("1980, 12, 01"),
note: "test note",
category: ["cat1", "cat2"],
url: ["www.1.com", "www.2.com"],
url: [{type: ["work", "work2"], value: "www.1.com"}, {value:"www2.com"}],
anniversary: new Date("2000, 12, 01"),
sex: "male",
genderIdentity: "test"
@ -148,12 +148,13 @@ function checkAddress(adr1, adr2) {
function checkTel(tel1, tel2) {
checkStr(tel1.type, tel2.type, "Same type");
checkStr(tel1.number, tel2.number, "Same number");
checkStr(tel1.value, tel2.value, "Same value");
checkStr(tel1.carrier, tel2.carrier, "Same carrier");
}
function checkEmail(email1, email2) {
checkStr(email1.type, email2.type, "Same type");
checkStr(email1.address, email2.address, "Same address");
function checkField(field1, field2) {
checkStr(field1.type, field1.type, "Same type");
checkStr(field1.value, field1.value, "Same value");
}
function checkContacts(contact1, contact2) {
@ -164,23 +165,60 @@ function checkContacts(contact1, contact2) {
checkStr(contact1.familyName, contact2.familyName, "Same familyName");
checkStr(contact1.honorificSuffix, contact2.honorificSuffix, "Same honorificSuffix");
checkStr(contact1.nickname, contact2.nickname, "Same nickname");
checkStr(contact1.url, contact2.url, "Same url");
checkStr(contact1.category, contact2.category, "Same category");
checkStr(contact1.org, contact2.org, "Same org");
checkStr(contact1.jobTitle, contact2.jobTitle, "Same jobTitle");
is(contact1.bday ? contact1.bday.valueOf() : null, contact2.bday ? contact2.bday.valueOf() : null, "Same birthday");
checkStr(contact1.note, contact2.note, "Same note");
checkStr(contact1.impp, contact2.impp, "Same impp");
is(contact1.anniversary ? contact1.anniversary.valueOf() : null , contact2.anniversary ? contact2.anniversary.valueOf() : null, "Same anniversary");
is(contact1.sex, contact2.sex, "Same sex");
is(contact1.genderIdentity, contact2.genderIdentity, "Same genderIdentity");
for (var i in contact1.email)
checkEmail(contact1.email[i], contact2.email[i]);
for (var i in contact1.adr)
for (var i in contact1.email) {
if (contact1.email) {
ok(contact2.email != null, "conatct2.email exists");
}
if (contact2.email) {
ok(contact1.email != null, "conatct1.email exists");
}
checkField(contact1.email[i], contact2.email[i]);
}
for (var i in contact1.adr) {
if (contact1.adr) {
ok(contact2.adr != null, "conatct2.adr exists");
}
if (contact2.adr) {
ok(contact1.adr != null, "conatct1.adr exists");
}
checkAddress(contact1.adr[i], contact2.adr[i]);
for (var i in contact1.tel)
}
for (var i in contact1.tel) {
if (contact1.tel) {
ok(contact2.tel != null, "conatct2.tel exists");
}
if (contact2.tel) {
ok(contact1.tel != null, "conatct1.tel exists");
}
checkTel(contact1.tel[i], contact2.tel[i]);
}
for (var i in contact1.url) {
if (contact1.url) {
ok(contact2.url != null, "conatct2.url exists");
}
if (contact2.url) {
ok(contact1.url != null, "conatct1.url exists");
}
checkField(contact1.url[i], contact2.url[i]);
}
for (var i in contact1.impp) {
if (contact1.impp) {
ok(contact2.impp != null, "conatct2.impp exists");
}
if (contact2.impp) {
ok(contact1.impp != null, "conatct1.impp exists");
}
checkField(contact1.impp[i], contact2.impp[i]);
}
}
var req;
@ -281,7 +319,7 @@ var steps = [
ok(true, "Searching for exact email");
var options = {filterBy: ["email"],
filterOp: "equals",
filterValue: properties1.email[0].address};
filterValue: properties1.email[0].value};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -420,7 +458,7 @@ var steps = [
ok(true, "Retrieving by substring tel1");
var options = {filterBy: ["tel"],
filterOp: "contains",
filterValue: properties1.tel[1].number.substring(1,5)};
filterValue: properties1.tel[1].value.substring(1,5)};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -522,7 +560,7 @@ var steps = [
},
function () {
ok(true, "Modifying contact1");
findResult1.impp = properties1.impp = (["phil impp"]);
findResult1.impp = properties1.impp = [{value:"phil impp"}];
req = navigator.mozContacts.save(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
@ -554,7 +592,7 @@ var steps = [
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(createResult1, properties1);
checkContacts(findResult1, properties1);
next();
};
req.onerror = onFailure;
@ -569,14 +607,14 @@ var steps = [
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(findResult1, createResult1);
checkContacts(findResult1, properties1);
next();
}
req.onerror = onFailure;
},
function () {
ok(true, "Modifying contact2");
findResult1.impp = properties1.impp = (["phil impp"]);
findResult1.impp = properties1.impp = [{value: "phil impp"}];
req = mozContacts.save(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
@ -584,7 +622,7 @@ var steps = [
ok(req2.result.length == 1, "Found exactly 1 contact.");
findResult1 = req2.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(findResult1, createResult1);
checkContacts(findResult1, properties1);
ok(findResult1.impp.length == 1, "Found exactly 1 IMS info.");
next();
}
@ -602,7 +640,7 @@ var steps = [
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(findResult1, createResult1);
checkContacts(findResult1, properties1);
next();
};
req.onerror = onFailure;
@ -617,7 +655,7 @@ var steps = [
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(findResult1, createResult1);
checkContacts(findResult1, properties1);
next();
};
req.onerror = onFailure;
@ -632,14 +670,14 @@ var steps = [
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(findResult1, createResult1);
checkContacts(findResult1, properties1);
next();
};
req.onerror = onFailure;
},
function () {
ok(true, "Modifying contact3");
findResult1.email = [{address: properties1.nickname}];
findResult1.email = [{value: properties1.nickname}];
findResult1.nickname = "TEST";
var newContact = new mozContact();
newContact.init(findResult1);
@ -749,7 +787,7 @@ var steps = [
ok(true, "Searching contacts by tel");
var options = {filterBy: ["tel"],
filterOp: "contains",
filterValue: properties2.tel[0].number.substring(0, 7)};
filterValue: properties2.tel[0].value.substring(0, 7)};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -764,7 +802,7 @@ var steps = [
ok(true, "Searching contacts by email");
var options = {filterBy: ["email"],
filterOp: "contains",
filterValue: properties2.email[0].address.substring(0, 4)};
filterValue: properties2.email[0].value.substring(0, 4)};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -888,12 +926,12 @@ var steps = [
ok(true, "Testing clone contact2");
var cloned = new mozContact(createResult1);
ok(cloned.id != createResult1.id, "Cloned contact has new ID");
cloned.email = {address: "new email!"};
cloned.email = {value: "new email!"};
cloned.givenName = "Tom";
req = mozContacts.save(cloned);
req.onsuccess = function () {
ok(cloned.id, "The contact now has an ID.");
ok(cloned.email.address == "new email!", "Same Email");
ok(cloned.email.value == "new email!", "Same Email");
ok(createResult1.email != cloned.email, "Clone has different email");
ok(cloned.givenName == "Tom", "New Name");
next();
@ -915,7 +953,7 @@ var steps = [
function () {
ok(true, "Search with redundant fields should only return 1 contact");
createResult1 = new mozContact();
createResult1.init({name: "XXX", nickname: "XXX", email: [{address: "XXX"}], tel: {number: "XXX"}});
createResult1.init({name: "XXX", nickname: "XXX", email: [{value: "XXX"}], tel: {value: "XXX"}});
req = mozContacts.save(createResult1);
req.onsuccess = function() {
var options = {filterBy: [],

View File

@ -18,18 +18,17 @@ interface nsIDOMContactAddress : nsISupports
attribute DOMString countryName;
};
[scriptable, uuid(82601b20-89e8-11e1-b0c4-0800200c9a66)]
interface nsIDOMContactTelephone : nsISupports
[scriptable, uuid(e2cb19c0-e4aa-11e1-9b23-0800200c9a66)]
interface nsIDOMContactField : nsISupports
{
attribute DOMString type;
attribute DOMString number;
attribute jsval type; // DOMString[] for primary/favorite (use:"PREF"), "home", "work", etc.
attribute DOMString value;
};
[scriptable, uuid(94811520-c11f-11e1-afa7-0800200c9a66)]
interface nsIDOMContactEmail : nsISupports
[scriptable, uuid(ed0ab260-e4aa-11e1-9b23-0800200c9a66)]
interface nsIDOMContactTelField : nsIDOMContactField
{
attribute DOMString type;
attribute DOMString address;
attribute DOMString carrier;
};
[scriptable, uuid(e31daea0-0cb6-11e1-be50-0800200c9a66)]
@ -43,7 +42,7 @@ interface nsIDOMContactFindOptions : nsISupports
attribute unsigned long filterLimit;
};
[scriptable, uuid(f5181640-89e8-11e1-b0c4-0800200c9a66)]
[scriptable, uuid(f0ddb360-e4aa-11e1-9b23-0800200c9a66)]
interface nsIDOMContactProperties : nsISupports
{
attribute jsval name; // DOMString[]
@ -53,17 +52,17 @@ interface nsIDOMContactProperties : nsISupports
attribute jsval familyName; // DOMString[]
attribute jsval honorificSuffix; // DOMString[]
attribute jsval nickname; // DOMString[]
attribute jsval email; // ContactEmail[]
attribute jsval email; // ContactField[]
attribute jsval photo; // nsIDOMBlob[]
attribute jsval url; // DOMString[]
attribute jsval url; // ContactField[]
attribute jsval category; // DOMString[]
attribute jsval adr; // ContactAddress[]
attribute jsval tel; // ContactTelephone[]
attribute jsval tel; // ContactTelField[]
attribute jsval org; // DOMString[]
attribute jsval jobTitle; // DOMString[]
attribute jsval bday; // Date
attribute jsval note; // DOMString[]
attribute jsval impp; // DOMString[]
attribute jsval impp; // ContactField[]
attribute jsval anniversary; // Date
attribute jsval sex; // DOMString
attribute jsval genderIdentity; // DOMString

View File

@ -7,7 +7,7 @@
#include "jspubtd.h"
%}
[scriptable, uuid(5b3f9656-9d81-40e4-85ba-01f302177815)]
[scriptable, uuid(22df6ed6-d094-4e45-97fc-a8eca11c390c)]
interface nsIInlineEventHandlers : nsISupports
{
[implicit_jscontext] attribute jsval onabort;
@ -69,6 +69,7 @@ interface nsIInlineEventHandlers : nsISupports
[implicit_jscontext] attribute jsval ontimeupdate;
[implicit_jscontext] attribute jsval onvolumechange;
[implicit_jscontext] attribute jsval onwaiting;
[implicit_jscontext] attribute jsval onwheel;
/**
* Non-HTML5 event attributes

View File

@ -10,13 +10,14 @@
#include "nsIDOMFile.h"
#include "nsIInputStream.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsIRemoteBlob.h"
#include "nsISeekableStream.h"
#include "mozilla/Assertions.h"
#include "mozilla/Monitor.h"
#include "mozilla/unused.h"
#include "mozilla/net/NeckoMessageUtils.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "nsDOMFile.h"
#include "nsThreadUtils.h"
@ -25,6 +26,7 @@
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
using namespace mozilla::ipc;
namespace {
@ -227,10 +229,18 @@ private:
}
};
NS_IMPL_THREADSAFE_ADDREF(RemoteInputStream)
NS_IMPL_THREADSAFE_RELEASE(RemoteInputStream)
NS_INTERFACE_MAP_BEGIN(RemoteInputStream)
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISeekableStream, IsSeekableStream())
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream)
NS_INTERFACE_MAP_END
template <ActorFlavorEnum ActorFlavor>
class InputStreamActor : public BlobTraits<ActorFlavor>::StreamType
{
typedef typename BlobTraits<ActorFlavor>::StreamType::InputStream InputStream;
nsRefPtr<RemoteInputStream> mRemoteStream;
public:
@ -249,12 +259,17 @@ public:
private:
// This method is only called by the IPDL message machinery.
virtual bool
Recv__delete__(const InputStream& aStream) MOZ_OVERRIDE
Recv__delete__(const InputStreamParams& aParams) MOZ_OVERRIDE
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mRemoteStream);
mRemoteStream->SetStream(aStream);
nsCOMPtr<nsIInputStream> stream = DeserializeInputStream(aParams);
if (!stream) {
return false;
}
mRemoteStream->SetStream(stream);
return true;
}
};
@ -605,14 +620,10 @@ public:
virtual void*
GetPBlob() MOZ_OVERRIDE
{
return static_cast<typename ActorType::BaseType*>(mActor);
return static_cast<typename ActorType::ProtocolType*>(mActor);
}
};
} // namespace ipc
} // namespace dom
} // namespace mozilla
template <ActorFlavorEnum ActorFlavor>
Blob<ActorFlavor>::Blob(nsIDOMBlob* aBlob)
: mBlob(aBlob), mRemoteBlob(nullptr), mOwnsBlob(true), mBlobIsFile(false)
@ -740,7 +751,7 @@ Blob<ActorFlavor>::SetMysteryBlobInfo(const nsString& aName,
ToConcreteBlob(mBlob)->SetLazyData(aName, aContentType, aLength);
FileBlobConstructorParams params(aName, aContentType, aLength);
return BaseType::SendResolveMystery(params);
return ProtocolType::SendResolveMystery(params);
}
template <ActorFlavorEnum ActorFlavor>
@ -759,7 +770,7 @@ Blob<ActorFlavor>::SetMysteryBlobInfo(const nsString& aContentType,
ToConcreteBlob(mBlob)->SetLazyData(voidString, aContentType, aLength);
NormalBlobConstructorParams params(aContentType, aLength);
return BaseType::SendResolveMystery(params);
return ProtocolType::SendResolveMystery(params);
}
template <ActorFlavorEnum ActorFlavor>
@ -809,7 +820,7 @@ Blob<ActorFlavor>::NoteDyingRemoteBlob()
// access a dangling pointer.
mRemoteBlob = nullptr;
mozilla::unused << BaseType::Send__delete__(this);
mozilla::unused << ProtocolType::Send__delete__(this);
}
template <ActorFlavorEnum ActorFlavor>
@ -868,9 +879,9 @@ Blob<ActorFlavor>::RecvResolveMystery(const ResolveMysteryParams& aParams)
return true;
}
template <ActorFlavorEnum ActorFlavor>
template <>
bool
Blob<ActorFlavor>::RecvPBlobStreamConstructor(StreamType* aActor)
Blob<Parent>::RecvPBlobStreamConstructor(StreamType* aActor)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mBlob);
@ -880,7 +891,55 @@ Blob<ActorFlavor>::RecvPBlobStreamConstructor(StreamType* aActor)
nsresult rv = mBlob->GetInternalStream(getter_AddRefs(stream));
NS_ENSURE_SUCCESS(rv, false);
return aActor->Send__delete__(aActor, stream.get());
nsCOMPtr<nsIIPCSerializableInputStream> serializable =
do_QueryInterface(stream);
if (!serializable) {
MOZ_ASSERT(false, "Must be serializable!");
return false;
}
nsCOMPtr<nsIEventTarget> target =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
NS_ENSURE_TRUE(target, false);
nsRefPtr<BaseType::OpenStreamRunnable> runnable =
new BaseType::OpenStreamRunnable(this, aActor, stream, serializable,
target);
rv = target->Dispatch(runnable, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, false);
nsRevocableEventPtr<BaseType::OpenStreamRunnable>* arrayMember =
mOpenStreamRunnables.AppendElement();
*arrayMember = runnable;
return true;
}
template <>
bool
Blob<Child>::RecvPBlobStreamConstructor(StreamType* aActor)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mBlob);
MOZ_ASSERT(!mRemoteBlob);
nsCOMPtr<nsIInputStream> stream;
nsresult rv = mBlob->GetInternalStream(getter_AddRefs(stream));
NS_ENSURE_SUCCESS(rv, false);
nsCOMPtr<nsIIPCSerializableInputStream> serializable =
do_QueryInterface(stream);
if (!serializable) {
MOZ_ASSERT(false, "Must be serializable!");
return false;
}
InputStreamParams params;
serializable->Serialize(params);
MOZ_ASSERT(params.type() != InputStreamParams::T__None);
return aActor->Send__delete__(aActor, params);
}
template <ActorFlavorEnum ActorFlavor>
@ -910,18 +969,127 @@ template <ActorFlavorEnum ActorFlavor>
NS_IMPL_QUERY_INTERFACE_INHERITED1(RemoteBlob<ActorFlavor>, nsDOMFile,
nsIRemoteBlob)
NS_IMPL_THREADSAFE_ADDREF(RemoteInputStream)
NS_IMPL_THREADSAFE_RELEASE(RemoteInputStream)
void
BlobTraits<Parent>::BaseType::NoteRunnableCompleted(
BlobTraits<Parent>::BaseType::OpenStreamRunnable* aRunnable)
{
MOZ_ASSERT(NS_IsMainThread());
NS_INTERFACE_MAP_BEGIN(RemoteInputStream)
NS_INTERFACE_MAP_ENTRY(nsIInputStream)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISeekableStream, IsSeekableStream())
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInputStream)
NS_INTERFACE_MAP_END
for (PRUint32 index = 0; index < mOpenStreamRunnables.Length(); index++) {
nsRevocableEventPtr<BaseType::OpenStreamRunnable>& runnable =
mOpenStreamRunnables[index];
namespace mozilla {
namespace dom {
namespace ipc {
if (runnable.get() == aRunnable) {
runnable.Forget();
mOpenStreamRunnables.RemoveElementAt(index);
return;
}
}
MOZ_NOT_REACHED("Runnable not in our array!");
}
BlobTraits<Parent>::BaseType::
OpenStreamRunnable::OpenStreamRunnable(
BlobTraits<Parent>::BaseType* aOwner,
BlobTraits<Parent>::StreamType* aActor,
nsIInputStream* aStream,
nsIIPCSerializableInputStream* aSerializable,
nsIEventTarget* aTarget)
: mOwner(aOwner), mActor(aActor), mStream(aStream),
mSerializable(aSerializable), mTarget(aTarget), mRevoked(false),
mClosing(false)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aOwner);
MOZ_ASSERT(aActor);
MOZ_ASSERT(aStream);
MOZ_ASSERT(aSerializable);
MOZ_ASSERT(aTarget);
}
NS_IMETHODIMP
BlobTraits<Parent>::BaseType::OpenStreamRunnable::Run()
{
MOZ_ASSERT(mStream);
nsresult rv;
if (NS_IsMainThread()) {
MOZ_ASSERT(mTarget);
MOZ_ASSERT(!mClosing);
if (mRevoked) {
MOZ_ASSERT(!mOwner);
MOZ_ASSERT(!mActor);
}
else {
MOZ_ASSERT(mOwner);
MOZ_ASSERT(mActor);
nsCOMPtr<nsIIPCSerializableInputStream> serializable;
mSerializable.swap(serializable);
InputStreamParams params;
serializable->Serialize(params);
MOZ_ASSERT(params.type() != InputStreamParams::T__None);
unused << mActor->Send__delete__(mActor, params);
mOwner->NoteRunnableCompleted(this);
#ifdef DEBUG
mOwner = nullptr;
mActor = nullptr;
#endif
}
mClosing = true;
nsCOMPtr<nsIEventTarget> target;
mTarget.swap(target);
rv = target->Dispatch(this, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
if (!mClosing) {
// To force the stream open we call Available(). We don't actually care how
// much data is available.
PRUint64 available;
if (NS_FAILED(mStream->Available(&available))) {
NS_WARNING("Available failed on this stream!");
}
rv = NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// Going to always release here.
nsCOMPtr<nsIInputStream> stream;
mStream.swap(stream);
rv = stream->Close();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
#ifdef DEBUG
void
BlobTraits<Parent>::BaseType::OpenStreamRunnable::Revoke()
{
MOZ_ASSERT(NS_IsMainThread());
mOwner = nullptr;
mActor = nullptr;
mRevoked = true;
}
#endif
// Explicit instantiation of both classes.
template class Blob<Parent>;

View File

@ -12,12 +12,16 @@
#include "mozilla/dom/PBlobParent.h"
#include "mozilla/dom/PBlobStreamChild.h"
#include "mozilla/dom/PBlobStreamParent.h"
#include "mozilla/dom/PContentChild.h"
#include "mozilla/dom/PContentParent.h"
#include "mozilla/dom/PContent.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"
class nsIDOMBlob;
class nsIIPCSerializableInputStream;
class nsIInputStream;
namespace mozilla {
namespace dom {
@ -36,17 +40,92 @@ struct BlobTraits
template <>
struct BlobTraits<Parent>
{
typedef mozilla::dom::PBlobParent BaseType;
typedef mozilla::dom::PBlobParent ProtocolType;
typedef mozilla::dom::PBlobStreamParent StreamType;
typedef mozilla::dom::PContentParent ManagerType;
// BaseType on the parent side is a bit more complicated than for the child
// side. In the case of nsIInputStreams backed by files we need to ensure that
// the files are actually opened and closed on a background thread before we
// can send their file handles across to the child. The child process could
// crash during this process so we need to make sure we cancel the intended
// response in such a case. We do that by holding an array of
// nsRevocableEventPtr. If the child crashes then this actor will be destroyed
// and the nsRevocableEventPtr destructor will cancel any stream events that
// are currently in flight.
class BaseType : public ProtocolType
{
protected:
BaseType()
{ }
virtual ~BaseType()
{ }
// Each instance of this class will be dispatched to the network stream
// thread pool to run the first time where it will open the file input
// stream. It will then dispatch itself back to the main thread to send the
// child process its response (assuming that the child has not crashed). The
// runnable will then dispatch itself to the thread pool again in order to
// close the file input stream.
class OpenStreamRunnable : public nsRunnable
{
friend class nsRevocableEventPtr<OpenStreamRunnable>;
public:
NS_DECL_NSIRUNNABLE
OpenStreamRunnable(BaseType* aOwner, StreamType* aActor,
nsIInputStream* aStream,
nsIIPCSerializableInputStream* aSerializable,
nsIEventTarget* aTarget);
private:
#ifdef DEBUG
void
Revoke();
#else
void
Revoke()
{
mRevoked = true;
}
#endif
// Only safe to access these two pointers if mRevoked is false!
BaseType* mOwner;
StreamType* mActor;
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsIIPCSerializableInputStream> mSerializable;
nsCOMPtr<nsIEventTarget> mTarget;
bool mRevoked;
bool mClosing;
};
friend class OpenStreamRunnable;
void
NoteRunnableCompleted(OpenStreamRunnable* aRunnable);
nsTArray<nsRevocableEventPtr<OpenStreamRunnable> > mOpenStreamRunnables;
};
};
template <>
struct BlobTraits<Child>
{
typedef mozilla::dom::PBlobChild BaseType;
typedef mozilla::dom::PBlobChild ProtocolType;
typedef mozilla::dom::PBlobStreamChild StreamType;
typedef mozilla::dom::PContentChild ManagerType;
class BaseType : public ProtocolType
{
protected:
BaseType()
{ }
virtual ~BaseType()
{ }
};
};
template <ActorFlavorEnum>
@ -58,9 +137,9 @@ class Blob : public BlobTraits<ActorFlavor>::BaseType
friend class RemoteBlob<ActorFlavor>;
public:
typedef typename BlobTraits<ActorFlavor>::BaseType BaseType;
typedef typename BlobTraits<ActorFlavor>::ProtocolType ProtocolType;
typedef typename BlobTraits<ActorFlavor>::StreamType StreamType;
typedef typename BlobTraits<ActorFlavor>::ManagerType ManagerType;
typedef typename BlobTraits<ActorFlavor>::BaseType BaseType;
typedef RemoteBlob<ActorFlavor> RemoteBlobType;
typedef mozilla::ipc::IProtocolManager<
mozilla::ipc::RPCChannel::RPCListener>::ActorDestroyReason

View File

@ -48,6 +48,7 @@
#include "nsJSEnvironment.h"
#include "SandboxHal.h"
#include "nsDebugImpl.h"
#include "nsLayoutStylesheetCache.h"
#include "History.h"
#include "nsDocShellCID.h"
@ -908,11 +909,20 @@ ContentChild::RecvCycleCollect()
return true;
}
static void
PreloadSlowThings()
{
// This fetches and creates all the built-in stylesheets.
nsLayoutStylesheetCache::UserContentSheet();
}
bool
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID)
{
mAppInfo.version.Assign(version);
mAppInfo.buildID.Assign(buildID);
PreloadSlowThings();
return true;
}

View File

@ -21,10 +21,7 @@
#include "IndexedDBParent.h"
#include "IndexedDatabaseManager.h"
#include "mozIApplication.h"
#include "mozilla/Preferences.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Util.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/dom/ExternalHelperAppParent.h"
#include "mozilla/dom/PMemoryReportRequestParent.h"
#include "mozilla/dom/StorageParent.h"
@ -34,6 +31,10 @@
#include "mozilla/ipc/TestShellParent.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/net/NeckoParent.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Util.h"
#include "mozilla/unused.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
@ -158,6 +159,93 @@ nsTArray<ContentParent*>* ContentParent::gPrivateContent;
// The first content child has ID 1, so the chrome process can have ID 0.
static PRUint64 gContentChildID = 1;
// Try to keep an app process always preallocated, to get
// initialization off the critical path of app startup.
static bool sKeepAppProcessPreallocated;
static StaticRefPtr<ContentParent> sPreallocatedAppProcess;
static CancelableTask* sPreallocateAppProcessTask;
// This number is fairly arbitrary ... the intention is to put off
// launching another app process until the last one has finished
// loading its content, to reduce CPU/memory/IO contention.
static int sPreallocateDelayMs;
// We want the prelaunched process to know that it's for apps, but not
// actually for any app in particular. Use a magic manifest URL.
// Can't be a static constant.
#define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
/*static*/ void
ContentParent::PreallocateAppProcess()
{
MOZ_ASSERT(!sPreallocatedAppProcess);
if (sPreallocateAppProcessTask) {
// We were called directly while a delayed task was scheduled.
sPreallocateAppProcessTask->Cancel();
sPreallocateAppProcessTask = nullptr;
}
sPreallocatedAppProcess =
new ContentParent(MAGIC_PREALLOCATED_APP_MANIFEST_URL);
sPreallocatedAppProcess->Init();
}
/*static*/ void
ContentParent::DelayedPreallocateAppProcess()
{
sPreallocateAppProcessTask = nullptr;
if (!sPreallocatedAppProcess) {
PreallocateAppProcess();
}
}
/*static*/ void
ContentParent::ScheduleDelayedPreallocateAppProcess()
{
if (!sKeepAppProcessPreallocated || sPreallocateAppProcessTask) {
return;
}
sPreallocateAppProcessTask =
NewRunnableFunction(DelayedPreallocateAppProcess);
MessageLoop::current()->PostDelayedTask(
FROM_HERE, sPreallocateAppProcessTask, sPreallocateDelayMs);
}
/*static*/ already_AddRefed<ContentParent>
ContentParent::MaybeTakePreallocatedAppProcess()
{
nsRefPtr<ContentParent> process = sPreallocatedAppProcess.get();
sPreallocatedAppProcess = nullptr;
ScheduleDelayedPreallocateAppProcess();
return process.forget();
}
/*static*/ void
ContentParent::StartUp()
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
return;
}
sKeepAppProcessPreallocated =
Preferences::GetBool("dom.ipc.processPrelauch.enabled", false);
if (sKeepAppProcessPreallocated) {
ClearOnShutdown(&sPreallocatedAppProcess);
sPreallocateDelayMs = Preferences::GetUint(
"dom.ipc.processPrelauch.delayMs", 1000);
MOZ_ASSERT(!sPreallocateAppProcessTask);
ScheduleDelayedPreallocateAppProcess();
}
}
/*static*/ void
ContentParent::ShutDown()
{
// No-op for now. We rely on normal process shutdown and
// ClearOnShutdown() to clean up our state.
}
/*static*/ ContentParent*
ContentParent::GetNewOrUsed()
{
@ -225,10 +313,16 @@ ContentParent::CreateBrowser(mozIApplication* aApp, bool aIsBrowserElement)
return nullptr;
}
ContentParent* p = gAppContentParents->Get(manifestURL);
nsRefPtr<ContentParent> p = gAppContentParents->Get(manifestURL);
if (!p) {
p = new ContentParent(manifestURL);
p->Init();
p = MaybeTakePreallocatedAppProcess();
if (p) {
p->SetManifestFromPreallocated(manifestURL);
} else {
NS_WARNING("Unable to use pre-allocated app process");
p = new ContentParent(manifestURL);
p->Init();
}
gAppContentParents->Put(manifestURL, p);
}
@ -302,7 +396,16 @@ ContentParent::Init()
}
void
ContentParent::ShutDown()
ContentParent::SetManifestFromPreallocated(const nsAString& aAppManifestURL)
{
MOZ_ASSERT(mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL);
// Clients should think of mAppManifestURL as const ... we're
// bending the rules here just for the preallocation hack.
const_cast<nsString&>(mAppManifestURL) = aAppManifestURL;
}
void
ContentParent::ShutDownProcess()
{
if (mIsAlive) {
// Close() can only be called once. It kicks off the
@ -447,6 +550,10 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
#endif
}
if (sPreallocatedAppProcess == this) {
sPreallocatedAppProcess = nullptr;
}
mMessageManager->Disconnect();
// clear the child memory reporters
@ -513,7 +620,7 @@ ContentParent::NotifyTabDestroyed(PBrowserParent* aTab)
if (IsForApp() && ManagedPBrowserParent().Length() == 1) {
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentParent::ShutDown));
NewRunnableMethod(this, &ContentParent::ShutDownProcess));
}
}

View File

@ -58,6 +58,14 @@ private:
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
public:
/**
* Start up the content-process machinery. This might include
* scheduling pre-launch tasks.
*/
static void StartUp();
/** Shut down the content-process machinery. */
static void ShutDown();
static ContentParent* GetNewOrUsed();
/**
@ -112,6 +120,11 @@ private:
static nsTArray<ContentParent*>* gNonAppContentParents;
static nsTArray<ContentParent*>* gPrivateContent;
static void PreallocateAppProcess();
static void DelayedPreallocateAppProcess();
static void ScheduleDelayedPreallocateAppProcess();
static already_AddRefed<ContentParent> MaybeTakePreallocatedAppProcess();
// Hide the raw constructor methods since we don't want client code
// using them.
using PContentParent::SendPBrowserConstructor;
@ -122,6 +135,10 @@ private:
void Init();
// Transform a pre-allocated app process into a "real" app
// process, for the specified manifest URL.
void SetManifestFromPreallocated(const nsAString& aAppManifestURL);
/**
* Mark this ContentParent as dead for the purposes of Get*().
* This method is idempotent.
@ -134,7 +151,7 @@ private:
* by the Get*() funtions. However, the shutdown sequence itself
* may be asynchronous.
*/
void ShutDown();
void ShutDownProcess();
PCompositorParent* AllocPCompositor(mozilla::ipc::Transport* aTransport,
base::ProcessId aOtherProcess) MOZ_OVERRIDE;

View File

@ -3,10 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBlob;
include "mozilla/net/NeckoMessageUtils.h";
using IPC::InputStream;
include IPCSerializableParams;
namespace mozilla {
namespace dom {
@ -16,7 +13,7 @@ protocol PBlobStream
manager PBlob;
both:
__delete__(InputStream stream);
__delete__(InputStreamParams params);
};
} // namespace dom

View File

@ -8,6 +8,7 @@ interface nsIDOMEventListener;
interface nsIDOMDOMRequest;
interface nsIDOMMozMobileConnectionInfo;
interface nsIDOMMozMobileNetworkInfo;
interface nsIDOMMozMobileCellInfo;
[scriptable, builtinclass, uuid(e7309c47-9a2e-4e12-84ab-f8f39214eaba)]
interface nsIDOMMozMobileConnection : nsIDOMEventTarget
@ -222,7 +223,7 @@ interface nsIDOMMozMobileConnection : nsIDOMEventTarget
attribute nsIDOMEventListener onussdreceived;
};
[scriptable, uuid(6601c20e-337f-4286-8d6e-0990fc1c2372)]
[scriptable, uuid(5ea0e4a9-4684-40da-9930-8ebb61d187f3)]
interface nsIDOMMozMobileConnectionInfo : nsISupports
{
/**
@ -276,6 +277,11 @@ interface nsIDOMMozMobileConnectionInfo : nsISupports
*/
readonly attribute jsval relSignalStrength;
/**
* Cell location.
*/
readonly attribute nsIDOMMozMobileCellInfo cell;
};
[scriptable, uuid(3bd866c7-98a5-4ef4-a464-c22d8cc6b992)]
@ -308,3 +314,17 @@ interface nsIDOMMozMobileNetworkInfo: nsISupports
*/
readonly attribute DOMString state;
};
[scriptable, uuid(aa546788-4f34-488b-8c3e-2786e02ab992)]
interface nsIDOMMozMobileCellInfo: nsISupports
{
/**
* Mobile Location Area Code (LAC) for GSM/WCDMA networks.
*/
readonly attribute unsigned short gsmLocationAreaCode;
/**
* Mobile Cell ID for GSM/WCDMA networks.
*/
readonly attribute unsigned long gsmCellId;
};

View File

@ -17,6 +17,12 @@ function setEmulatorVoiceState(state) {
});
}
function setEmulatorGsmLocation(lac, cid) {
runEmulatorCmd("gsm location " + lac + " " + cid, function (result) {
is(result[0], "OK");
});
}
function testConnectionInfo() {
let voice = connection.voice;
is(voice.connected, true);
@ -24,7 +30,31 @@ function testConnectionInfo() {
is(voice.emergencyCallsOnly, false);
is(voice.roaming, false);
testUnregistered();
testCellLocation();
}
function testCellLocation() {
let voice = connection.voice;
// Emulator always reports valid lac/cid value because its AT command parser
// insists valid value for every complete response. See source file
// hardare/ril/reference-ril/at_tok.c, function at_tok_nexthexint().
ok(voice.cell, "location available");
// Initial LAC/CID. Android emulator initializes both value to -1.
is(voice.cell.gsmLocationAreaCode, 65535);
is(voice.cell.gsmCellId, 268435455);
connection.addEventListener("voicechange", function onvoicechange() {
connection.removeEventListener("voicechange", onvoicechange);
is(voice.cell.gsmLocationAreaCode, 100);
is(voice.cell.gsmCellId, 100);
testUnregistered();
});
setEmulatorGsmLocation(100, 100);
}
function testUnregistered() {

View File

@ -14,7 +14,6 @@ include "mozilla/dom/TabMessageUtils.h";
using NPError;
using NPNVariable;
using base::FileDescriptor;
using mozilla::dom::NativeThreadId;
using mac_plugin_interposing::NSCursorInfo;
using nsID;

View File

@ -1850,10 +1850,10 @@ PluginModuleChild::AnswerNP_Initialize(const uint32_t& aFlags, NPError* _retval)
#endif
#ifdef MOZ_X11
// Send the parent a dup of our X socket, to act as a proxy
// reference for our X resources
// Send the parent our X socket to act as a proxy reference for our X
// resources.
int xSocketFd = ConnectionNumber(DefaultXDisplay());
SendBackUpXResources(FileDescriptor(xSocketFd, false/*don't close*/));
SendBackUpXResources(FileDescriptor(xSocketFd));
#endif
#if defined(OS_LINUX)

View File

@ -689,9 +689,8 @@ PluginModuleParent::RecvBackUpXResources(const FileDescriptor& aXSocketFd)
#else
NS_ABORT_IF_FALSE(0 > mPluginXSocketFdDup.get(),
"Already backed up X resources??");
int fd = aXSocketFd.fd; // Copy to discard |const| qualifier
mPluginXSocketFdDup.forget();
mPluginXSocketFdDup.reset(fd);
mPluginXSocketFdDup.reset(aXSocketFd.PlatformHandle());
#endif
return true;
}

View File

@ -196,18 +196,20 @@ AudioManager::GetForceForUse(PRInt32 aUsage, PRInt32* aForce) {
void
AudioManager::SetAudioRoute(int aRoutes) {
audio_io_handle_t handle = 0;
if (static_cast<
audio_io_handle_t (*)(AudioSystem::stream_type, uint32_t, uint32_t, uint32_t, AudioSystem::output_flags)
>(AudioSystem::getOutput)) {
audio_io_handle_t handle = 0;
handle = AudioSystem::getOutput((AudioSystem::stream_type)AudioSystem::SYSTEM);
String8 cmd;
cmd.appendFormat("routing=%d", GetRoutingMode(aRoutes));
AudioSystem::setParameters(handle, cmd);
} else if (static_cast<
audio_io_handle_t (*)(audio_stream_type_t, uint32_t, uint32_t, uint32_t, audio_policy_output_flags_t)
>(AudioSystem::getOutput)) {
handle = AudioSystem::getOutput((audio_stream_type_t)AudioSystem::SYSTEM);
status_t (*)(audio_devices_t, audio_policy_dev_state_t, const char*)
>(AudioSystem::setDeviceConnectionState)) {
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_WIRED_HEADSET,
GetRoutingMode(aRoutes) == AudioSystem::DEVICE_OUT_WIRED_HEADSET ?
AUDIO_POLICY_DEVICE_STATE_AVAILABLE : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
"");
}
String8 cmd;
cmd.appendFormat("routing=%d", GetRoutingMode(aRoutes));
AudioSystem::setParameters(handle, cmd);
}

View File

@ -24,6 +24,7 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsINetworkManager.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsIDOMMobileConnection.h"
#include "nsThreadUtils.h"
#ifdef AGPS_TYPE_INVALID
@ -371,11 +372,15 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
icc->GetMcc(&location.u.cellID.mcc);
icc->GetMnc(&location.u.cellID.mnc);
}
nsCOMPtr<nsICellLocation> cell;
rilCtx->GetCell(getter_AddRefs(cell));
if (cell) {
cell->GetLac(&location.u.cellID.lac);
cell->GetCid(&location.u.cellID.cid);
nsCOMPtr<nsIDOMMozMobileConnectionInfo> voice;
rilCtx->GetVoice(getter_AddRefs(voice));
if (voice) {
nsCOMPtr<nsIDOMMozMobileCellInfo> cell;
voice->GetCell(getter_AddRefs(cell));
if (cell) {
cell->GetGsmLocationAreaCode(&location.u.cellID.lac);
cell->GetGsmCellId(&location.u.cellID.cid);
}
}
if (mAGpsRilInterface) {
mAGpsRilInterface->set_ref_location(&location, sizeof(location));

View File

@ -33,6 +33,8 @@ const MOBILECONNECTIONINFO_CID =
Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
const MOBILENETWORKINFO_CID =
Components.ID("{a6c8416c-09b4-46d1-bf29-6520d677d085}");
const MOBILECELLINFO_CID =
Components.ID("{5e809018-68c0-4c54-af0b-2a9b8f748c45}");
const VOICEMAILSTATUS_CID=
Components.ID("{5467f2eb-e214-43ea-9b89-67711241ec8e}");
@ -84,6 +86,7 @@ MobileConnectionInfo.prototype = {
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null
@ -109,6 +112,23 @@ MobileNetworkInfo.prototype = {
state: null
};
function MobileCellInfo() {}
MobileCellInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileCellInfo]),
classID: MOBILECELLINFO_CID,
classInfo: XPCOMUtils.generateCI({
classID: MOBILECELLINFO_CID,
classDescription: "MobileCellInfo",
flags: Ci.nsIClassInfo.DOM_OBJECT,
interfaces: [Ci.nsIDOMMozMobileCellInfo]
}),
// nsIDOMMozMobileCellInfo
gsmLocationAreaCode: null,
gsmCellId: null
};
function VoicemailStatus() {}
VoicemailStatus.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozVoicemailStatus]),
@ -163,11 +183,24 @@ RILContentHelper.prototype = {
updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
for (let key in srcInfo) {
if (key != "network") {
if ((key != "network") && (key != "cell")) {
destInfo[key] = srcInfo[key];
}
}
let srcCell = srcInfo.cell;
if (!srcCell) {
destInfo.cell = null;
} else {
let cell = destInfo.cell;
if (!cell) {
cell = destInfo.cell = new MobileCellInfo();
}
cell.gsmLocationAreaCode = srcCell.gsmLocationAreaCode;
cell.gsmCellId = srcCell.gsmCellId;
}
let srcNetwork = srcInfo.network;
if (!srcNetwork) {
destInfo.network= null;

View File

@ -151,14 +151,16 @@ function RadioInterfaceLayer() {
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
icc: null,
cell: null,
// These objects implement the nsIDOMMozMobileConnectionInfo interface,
// although the actual implementation lives in the content process.
// although the actual implementation lives in the content process. So are
// the child attributes `network` and `cell`, which implement
// nsIDOMMozMobileNetworkInfo and nsIDOMMozMobileCellInfo respectively.
voice: {connected: false,
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null},
@ -166,6 +168,7 @@ function RadioInterfaceLayer() {
emergencyCallsOnly: false,
roaming: false,
network: null,
cell: null,
type: null,
signalStrength: null,
relSignalStrength: null},
@ -416,9 +419,6 @@ RadioInterfaceLayer.prototype = {
case "iccmbdn":
ppmm.sendAsyncMessage("RIL:VoicemailNumberChanged", message);
break;
case "celllocationchanged":
this.rilContext.cell = message;
break;
case "ussdreceived":
debug("ussdreceived " + JSON.stringify(message));
this.handleUSSDReceived(message);
@ -502,6 +502,13 @@ RadioInterfaceLayer.prototype = {
voiceInfo.relSignalStrength = null;
}
let newCell = newInfo.cell;
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
voiceInfo.cell = null;
} else {
voiceInfo.cell = newCell;
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
}
@ -525,6 +532,13 @@ RadioInterfaceLayer.prototype = {
dataInfo.relSignalStrength = null;
}
let newCell = newInfo.cell;
if ((newCell.gsmLocationAreaCode < 0) || (newCell.gsmCellId < 0)) {
dataInfo.cell = null;
} else {
dataInfo.cell = newCell;
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:DataInfoChanged", dataInfo);
}

View File

@ -217,21 +217,7 @@ interface nsIICCRecords : nsISupports
readonly attribute jsval fdn;
};
[scriptable, uuid(1b47459d-d0bc-4e91-8509-cc106054b9ee)]
interface nsICellLocation : nsISupports
{
/**
* Location Area Code
*/
readonly attribute unsigned short lac;
/**
* Cell Identity
*/
readonly attribute unsigned long cid;
};
[scriptable, uuid(a6f6977e-f4ee-42b4-ae79-798c8c47c360)]
[scriptable, uuid(e6dc89f2-0d4e-46fc-902c-cfeeaee15e40)]
interface nsIRilContext : nsISupports
{
readonly attribute DOMString radioState;
@ -240,8 +226,6 @@ interface nsIRilContext : nsISupports
readonly attribute nsIICCRecords icc;
readonly attribute nsICellLocation cell;
readonly attribute nsIDOMMozMobileConnectionInfo voice;
readonly attribute nsIDOMMozMobileConnectionInfo data;

View File

@ -623,11 +623,6 @@ let RIL = {
voiceRegistrationState: {},
dataRegistrationState: {},
/**
* The cell location on a phone, such as LAC, CID.
*/
cellLocation: {},
/**
* List of strings identifying the network operator.
*/
@ -698,11 +693,13 @@ let RIL = {
*
* @param string
* String to be parsed.
* @param defaultValue
* @param defaultValue [optional]
* Default value to be used.
* @param radix [optional]
* A number that represents the numeral system to be used. Default 10.
*/
parseInt: function RIL_parseInt(string, defaultValue) {
let number = parseInt(string, 10);
parseInt: function RIL_parseInt(string, defaultValue, radix) {
let number = parseInt(string, radix || 10);
if (!isNaN(number)) {
return number;
}
@ -1984,7 +1981,9 @@ let RIL = {
return;
}
let app = iccStatus.apps[iccStatus.gsmUmtsSubscriptionAppIndex];
// TODO: Bug 726098, change to use cdmaSubscriptionAppIndex when in CDMA.
let index = iccStatus.gsmUmtsSubscriptionAppIndex;
let app = iccStatus.apps[index];
if (!app) {
if (DEBUG) {
debug("Subscription application is not present in iccStatus.");
@ -1998,6 +1997,8 @@ let RIL = {
cardState: this.cardState});
return;
}
// fetchICCRecords will need to read aid, so read aid here.
this.aid = app.aid;
let newCardState;
switch (app.app_state) {
@ -2023,15 +2024,12 @@ let RIL = {
return;
}
// TODO: Bug 726098, change to use cdmaSubscriptionAppIndex when in CDMA.
// fetchICCRecords will need to read aid, so read aid here.
let index = iccStatus.gsmUmtsSubscriptionAppIndex;
this.aid = iccStatus.apps[index].aid;
// This was moved down from CARD_APPSTATE_READY
this.requestNetworkInfo();
this.getSignalStrength();
this.fetchICCRecords();
if (newCardState == GECKO_CARDSTATE_READY) {
this.fetchICCRecords();
}
this.cardState = newCardState;
this.sendDOMMessage({rilMessageType: "cardstatechange",
@ -2265,6 +2263,24 @@ let RIL = {
}
}
if (!curState.cell) {
curState.cell = {};
}
// From TS 23.003, 0000 and 0xfffe are indicated that no valid LAI exists
// in MS. So we still need to report the '0000' as well.
let lac = RIL.parseInt(newState[1], -1, 16);
if (curState.cell.gsmLocationAreaCode !== lac) {
curState.cell.gsmLocationAreaCode = lac;
changed = true;
}
let cid = RIL.parseInt(newState[2], -1, 16);
if (curState.cell.gsmCellId !== cid) {
curState.cell.gsmCellId = cid;
changed = true;
}
let radioTech = RIL.parseInt(newState[3], NETWORK_CREG_TECH_UNKNOWN);
if (curState.radioTech != radioTech) {
changed = true;
@ -2281,28 +2297,6 @@ let RIL = {
RIL.getSMSCAddress();
}
let cell = this.cellLocation;
let cellChanged = false;
// From TS 23.003, 0000 and 0xfffe are indicated that no valid LAI exists
// in MS. So we still need to report the '0000' as well.
let lac = parseInt(state[1], 16);
if (cell.lac !== lac) {
cell.lac = lac;
cellChanged = true;
}
let cid = parseInt(state[2], 16);
if (cell.cid !== cid) {
cell.cid = cid;
cellChanged = true;
}
if (cellChanged) {
cell.rilMessageType = "celllocationchanged";
this.sendDOMMessage(cell);
}
// TODO: This zombie code branch that will be raised from the dead once
// we add explicit CDMA support everywhere (bug 726098).
let cdma = false;

View File

@ -524,15 +524,16 @@ var interfaceNamesInGlobalScope =
"File",
"WebGLActiveInfo",
"SVGGradientElement",
"ContactTelephone",
"ContactEmail",
"ContactTelField",
"ContactField",
"SVGFitToViewBox",
"SVGAElement",
"NavigatorCamera",
"CameraControl",
"CameraCapabilities",
"CameraManager",
"CSSSupportsRule"
"CSSSupportsRule",
"MozMobileCellInfo"
]
for (var i in Components.interfaces) {

View File

@ -52,8 +52,6 @@
#include "nsIDOMHTMLTableRowElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMRange.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocument.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
@ -65,7 +63,6 @@
#include "nsINode.h"
#include "nsIParserUtils.h"
#include "nsIPlaintextEditor.h"
#include "nsIPrincipal.h"
#include "nsISelection.h"
#include "nsISupportsImpl.h"
#include "nsISupportsPrimitives.h"
@ -1171,35 +1168,6 @@ nsHTMLEditor::ParseCFHTML(nsCString & aCfhtml, PRUnichar **aStuffToPaste, PRUnic
return NS_OK;
}
bool nsHTMLEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
{
// Try to determine whether we should use a sanitizing fragment sink
bool isSafe = false;
nsCOMPtr<nsIDocument> destdoc = GetDocument();
NS_ASSERTION(destdoc, "Where is our destination doc?");
nsCOMPtr<nsISupports> container = destdoc->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(container);
nsCOMPtr<nsIDocShellTreeItem> root;
if (dsti)
dsti->GetRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(root);
PRUint32 appType;
if (docShell && NS_SUCCEEDED(docShell->GetAppType(&appType)))
isSafe = appType == nsIDocShell::APP_TYPE_EDITOR;
if (!isSafe && aSourceDoc) {
nsCOMPtr<nsIDocument> srcdoc = do_QueryInterface(aSourceDoc);
NS_ASSERTION(srcdoc, "Where is our source doc?");
nsIPrincipal* srcPrincipal = srcdoc->NodePrincipal();
nsIPrincipal* destPrincipal = destdoc->NodePrincipal();
NS_ASSERTION(srcPrincipal && destPrincipal, "How come we don't have a principal?");
srcPrincipal->Subsumes(destPrincipal, &isSafe);
}
return isSafe;
}
nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
nsIDOMDocument *aSourceDoc,
nsIDOMNode *aDestinationNode,

View File

@ -534,10 +534,6 @@ protected:
NS_IMETHOD InsertAsPlaintextQuotation(const nsAString & aQuotedText,
bool aAddCites,
nsIDOMNode **aNodeInserted);
// Return true if the data is safe to insert as the source and destination
// principals match, or we are in a editor context where this doesn't matter.
// Otherwise, the data must be sanitized first.
bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
nsresult InsertObject(const char* aType, nsISupports* aObject, bool aIsSafe,
nsIDOMDocument *aSourceDoc,

View File

@ -28,6 +28,9 @@
#include "nsIDragSession.h"
#include "nsIEditor.h"
#include "nsIEditorIMESupport.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIPrincipal.h"
#include "nsIFormControl.h"
#include "nsIPlaintextEditor.h"
#include "nsISelection.h"
@ -173,9 +176,21 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
NS_ASSERTION(dragSession, "No drag session");
nsCOMPtr<nsIDOMNode> sourceNode;
dataTransfer->GetMozSourceNode(getter_AddRefs(sourceNode));
nsCOMPtr<nsIDOMDocument> srcdomdoc;
if (sourceNode) {
sourceNode->GetOwnerDocument(getter_AddRefs(srcdomdoc));
NS_ENSURE_TRUE(sourceNode, NS_ERROR_FAILURE);
}
nsDragEvent* dragEventInternal = static_cast<nsDragEvent *>(aDropEvent->GetInternalNSEvent());
if (nsContentUtils::CheckForSubFrameDrop(dragSession, dragEventInternal)) {
return NS_OK;
// Don't allow drags from subframe documents with different origins than
// the drop destination.
if (srcdomdoc && !IsSafeToInsertData(srcdomdoc))
return NS_OK;
}
// Current doc is destination
@ -213,15 +228,6 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
bool isCollapsed = selection->Collapsed();
nsCOMPtr<nsIDOMNode> sourceNode;
dataTransfer->GetMozSourceNode(getter_AddRefs(sourceNode));
nsCOMPtr<nsIDOMDocument> srcdomdoc;
if (sourceNode) {
sourceNode->GetOwnerDocument(getter_AddRefs(srcdomdoc));
NS_ENSURE_TRUE(sourceNode, NS_ERROR_FAILURE);
}
// Only the nsHTMLEditor::FindUserSelectAllNode returns a node.
nsCOMPtr<nsIDOMNode> userSelectNode = FindUserSelectAllNode(newSelectionParent);
if (userSelectNode)
@ -419,3 +425,33 @@ NS_IMETHODIMP nsPlaintextEditor::CanPasteTransferable(nsITransferable *aTransfer
return NS_OK;
}
bool nsPlaintextEditor::IsSafeToInsertData(nsIDOMDocument* aSourceDoc)
{
// Try to determine whether we should use a sanitizing fragment sink
bool isSafe = false;
nsCOMPtr<nsIDocument> destdoc = GetDocument();
NS_ASSERTION(destdoc, "Where is our destination doc?");
nsCOMPtr<nsISupports> container = destdoc->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(container);
nsCOMPtr<nsIDocShellTreeItem> root;
if (dsti)
dsti->GetRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(root);
PRUint32 appType;
if (docShell && NS_SUCCEEDED(docShell->GetAppType(&appType)))
isSafe = appType == nsIDocShell::APP_TYPE_EDITOR;
if (!isSafe && aSourceDoc) {
nsCOMPtr<nsIDocument> srcdoc = do_QueryInterface(aSourceDoc);
NS_ASSERTION(srcdoc, "Where is our source doc?");
nsIPrincipal* srcPrincipal = srcdoc->NodePrincipal();
nsIPrincipal* destPrincipal = destdoc->NodePrincipal();
NS_ASSERTION(srcPrincipal && destPrincipal, "How come we don't have a principal?");
srcPrincipal->Subsumes(destPrincipal, &isSafe);
}
return isSafe;
}

View File

@ -154,6 +154,11 @@ public:
nsresult ExtendSelectionForDelete(nsISelection* aSelection,
nsIEditor::EDirection *aAction);
// Return true if the data is safe to insert as the source and destination
// principals match, or we are in a editor context where this doesn't matter.
// Otherwise, the data must be sanitized first.
bool IsSafeToInsertData(nsIDOMDocument* aSourceDoc);
static void GetDefaultEditorPrefs(PRInt32 &aNewLineHandling,
PRInt32 &aCaretStyle);

View File

@ -6,6 +6,7 @@
#ifndef _MOZILLA_GFX_2D_H
#define _MOZILLA_GFX_2D_H
#include "Types.h"
#include "Point.h"
#include "Rect.h"
#include "Matrix.h"
@ -19,23 +20,6 @@
#include <string>
#endif
/**
* Use C++11 nullptr if available; otherwise use a C++ typesafe template; and
* for C, fall back to longs. See bugs 547964 and 626472.
* Copy and paste job from nscore.h, see bug 781943
*/
#if defined(MOZ_GFX) && !defined(HAVE_NULLPTR)
#ifndef __cplusplus
# define nullptr ((void*)0)
#elif defined(__GNUC__)
# define nullptr __null
#elif defined(_WIN64)
# define nullptr 0LL
#else
# define nullptr 0L
#endif
#endif /* defined(MOZ_GFX) && !defined(HAVE_NULLPTR) */
struct _cairo_surface;
typedef _cairo_surface cairo_surface_t;

View File

@ -330,7 +330,7 @@ AlphaBoxBlur::AlphaBoxBlur(const Rect& aRect,
const Rect* aSkipRect)
: mSpreadRadius(aSpreadRadius),
mBlurRadius(aBlurRadius),
mData(NULL)
mData(nullptr)
{
Rect rect(aRect);
rect.Inflate(Size(aBlurRadius + aSpreadRadius));
@ -424,7 +424,7 @@ AlphaBoxBlur::GetDirtyRect()
return &mDirtyRect;
}
return NULL;
return nullptr;
}
void

View File

@ -45,11 +45,11 @@ public:
*
* @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.
* 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.
* speed reasons. It is safe to pass nullptr here.
*/
AlphaBoxBlur(const Rect& aRect,
const IntSize& aSpreadRadius,
@ -84,7 +84,7 @@ public:
IntRect GetRect();
/**
* Return a pointer to a dirty rect, as passed in to the constructor, or NULL
* Return a pointer to a dirty rect, as passed in to the constructor, or nullptr
* if none was passed in.
*/
Rect* GetDirtyRect();

View File

@ -77,7 +77,7 @@ CGBlendMode ToBlendMode(CompositionOp op)
DrawTargetCG::DrawTargetCG() : mSnapshot(NULL)
DrawTargetCG::DrawTargetCG() : mSnapshot(nullptr)
{
}
@ -128,7 +128,7 @@ DrawTargetCG::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aForma
if (newTarget->Init(GetType(), aSize, aFormat)) {
return newTarget;
} else {
return NULL;
return nullptr;
}
}
@ -141,7 +141,7 @@ DrawTargetCG::CreateSourceSurfaceFromData(unsigned char *aData,
RefPtr<SourceSurfaceCG> newSurf = new SourceSurfaceCG();
if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
return NULL;
return nullptr;
}
return newSurf;
@ -162,7 +162,7 @@ GetImageFromSourceSurface(SourceSurface *aSurface)
TemporaryRef<SourceSurface>
DrawTargetCG::OptimizeSourceSurface(SourceSurface *aSurface) const
{
return NULL;
return nullptr;
}
class UnboundnessFixer
@ -171,7 +171,7 @@ class UnboundnessFixer
CGLayerRef mLayer;
CGContextRef mCg;
public:
UnboundnessFixer() : mCg(NULL) {}
UnboundnessFixer() : mCg(nullptr) {}
CGContextRef Check(CGContextRef baseCg, CompositionOp blend)
{
@ -182,8 +182,8 @@ class UnboundnessFixer
//XXX: The size here is in default user space units, of the layer relative to the graphics context.
// is the clip bounds still correct if, for example, we have a scale applied to the context?
mLayer = CGLayerCreateWithContext(baseCg, mClipBounds.size, NULL);
//XXX: if the size is 0x0 we get a NULL CGContext back from GetContext
mLayer = CGLayerCreateWithContext(baseCg, mClipBounds.size, nullptr);
//XXX: if the size is 0x0 we get a nullptr CGContext back from GetContext
mCg = CGLayerGetContext(mLayer);
// CGContext's default to have the origin at the bottom left
// so flip it to the top left and adjust for the origin
@ -219,7 +219,7 @@ DrawTargetCG::DrawSurface(SourceSurface *aSurface,
MarkChanged();
CGImageRef image;
CGImageRef subimage = NULL;
CGImageRef subimage = nullptr;
CGContextSaveGState(mCg);
CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
@ -429,7 +429,7 @@ SetFillFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &
} else if (aPattern.GetType() == PATTERN_SURFACE) {
CGColorSpaceRef patternSpace;
patternSpace = CGColorSpaceCreatePattern (NULL);
patternSpace = CGColorSpaceCreatePattern (nullptr);
CGContextSetFillColorSpace(cg, patternSpace);
CGColorSpaceRelease(patternSpace);
@ -452,7 +452,7 @@ SetStrokeFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern
CGColorRelease(cgcolor);
} else if (aPattern.GetType() == PATTERN_SURFACE) {
CGColorSpaceRef patternSpace;
patternSpace = CGColorSpaceCreatePattern (NULL);
patternSpace = CGColorSpaceCreatePattern (nullptr);
CGContextSetStrokeColorSpace(cg, patternSpace);
CGColorSpaceRelease(patternSpace);
@ -756,7 +756,7 @@ DrawTargetCG::CopySurface(SourceSurface *aSurface,
MarkChanged();
CGImageRef image;
CGImageRef subimage = NULL;
CGImageRef subimage = nullptr;
if (aSurface->GetType() == SURFACE_COREGRAPHICS_IMAGE) {
image = GetImageFromSourceSurface(aSurface);
/* we have two options here:
@ -830,9 +830,9 @@ DrawTargetCG::Init(BackendType aType,
// 32767 is the maximum size supported by cairo
// we clamp to that to make it easier to interoperate
aSize.width > 32767 || aSize.height > 32767) {
mColorSpace = NULL;
mCg = NULL;
mData = NULL;
mColorSpace = nullptr;
mCg = nullptr;
mData = nullptr;
return false;
}
@ -841,14 +841,14 @@ DrawTargetCG::Init(BackendType aType,
//XXX: we'd be better off reusing the Colorspace across draw targets
mColorSpace = CGColorSpaceCreateDeviceRGB();
if (aData == NULL && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
if (aData == nullptr && aType != BACKEND_COREGRAPHICS_ACCELERATED) {
// XXX: Currently, Init implicitly clears, that can often be a waste of time
mData = calloc(aSize.height * aStride, 1);
aData = static_cast<unsigned char*>(mData);
} else {
// mData == NULL means DrawTargetCG doesn't own the image data and will not
// mData == nullptr means DrawTargetCG doesn't own the image data and will not
// delete it in the destructor
mData = NULL;
mData = nullptr;
}
mSize = aSize;
@ -858,7 +858,7 @@ DrawTargetCG::Init(BackendType aType,
mCg = ioSurface->CreateIOSurfaceContext();
// If we don't have the symbol for 'CreateIOSurfaceContext' mCg will be null
// and we will fallback to software below
mData = NULL;
mData = nullptr;
}
if (!mCg || aType == BACKEND_COREGRAPHICS) {
@ -916,9 +916,9 @@ DrawTargetCG::Init(CGContextRef cgContext, const IntSize &aSize)
// XXX: we should come up with some consistent semantics for dealing
// with zero area drawtargets
if (aSize.width == 0 || aSize.height == 0) {
mColorSpace = NULL;
mCg = NULL;
mData = NULL;
mColorSpace = nullptr;
mCg = nullptr;
mData = nullptr;
return false;
}
@ -931,7 +931,7 @@ DrawTargetCG::Init(CGContextRef cgContext, const IntSize &aSize)
mCg = cgContext;
mData = NULL;
mData = nullptr;
assert(mCg);
// CGContext's default to have the origin at the bottom left
@ -950,8 +950,8 @@ DrawTargetCG::Init(BackendType aType, const IntSize &aSize, SurfaceFormat &aForm
{
int stride = aSize.width*4;
// Calling Init with aData == NULL will allocate.
return Init(aType, NULL, aSize, stride, aFormat);
// Calling Init with aData == nullptr will allocate.
return Init(aType, nullptr, aSize, stride, aFormat);
}
TemporaryRef<PathBuilder>
@ -968,7 +968,7 @@ DrawTargetCG::GetNativeSurface(NativeSurfaceType aType)
aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE) {
return mCg;
} else {
return NULL;
return nullptr;
}
}
@ -1066,7 +1066,7 @@ DrawTargetCG::MarkChanged()
// We only need to worry about snapshots that someone else knows about
mSnapshot->DrawTargetWillChange();
}
mSnapshot = NULL;
mSnapshot = nullptr;
}
}

View File

@ -124,7 +124,7 @@ public:
virtual void PushClip(const Path *);
virtual void PushClipRect(const Rect &aRect);
virtual void PopClip();
virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return NULL;}
virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return nullptr;}
virtual TemporaryRef<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const;
virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule) const;
virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *, uint32_t,
@ -155,7 +155,7 @@ private:
/**
* A pointer to the image buffer if the buffer is owned by this class (set to
* NULL otherwise).
* nullptr otherwise).
* The data is not considered owned by DrawTargetCG if the DrawTarget was
* created for a pre-existing buffer or if the buffer's lifetime is managed
* by CoreGraphics.

View File

@ -164,7 +164,7 @@ GetCairoSurfaceForSourceSurface(SourceSurface *aSurface)
return surf;
}
// Never returns NULL. As such, you must always pass in Cairo-compatible
// Never returns nullptr. As such, you must always pass in Cairo-compatible
// patterns, most notably gradients with a GradientStopCairo.
// The pattern returned must have cairo_pattern_destroy() called on it by the
// caller.
@ -275,7 +275,7 @@ NeedIntermediateSurface(const Pattern& aPattern, const DrawOptions& aOptions)
}
DrawTargetCairo::DrawTargetCairo()
: mContext(NULL)
: mContext(nullptr)
{
}
@ -318,7 +318,7 @@ DrawTargetCairo::Flush()
}
void
DrawTargetCairo::PrepareForDrawing(cairo_t* aContext, const Path* aPath /* = NULL */)
DrawTargetCairo::PrepareForDrawing(cairo_t* aContext, const Path* aPath /* = nullptr */)
{
WillChange(aPath);
}
@ -391,7 +391,7 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface,
AlphaBoxBlur blur(extents, IntSize(0, 0),
AlphaBoxBlur::CalculateBlurRadius(Point(aSigma, aSigma)),
NULL, NULL);
nullptr, nullptr);
if (!blur.GetData()) {
return;
}
@ -786,7 +786,7 @@ DrawTargetCairo::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurf
}
}
return NULL;
return nullptr;
}
TemporaryRef<DrawTarget>
@ -802,7 +802,7 @@ DrawTargetCairo::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFo
return target;
}
return NULL;
return nullptr;
}
bool
@ -824,7 +824,7 @@ DrawTargetCairo::GetNativeSurface(NativeSurfaceType aType)
return cairo_get_target(mContext);
}
return NULL;
return nullptr;
}
void
@ -857,7 +857,7 @@ DrawTargetCairo::RemoveSnapshot(SourceSurfaceCairo* aSnapshot)
}
void
DrawTargetCairo::WillChange(const Path* aPath /* = NULL */)
DrawTargetCairo::WillChange(const Path* aPath /* = nullptr */)
{
if (!mSnapshots.empty()) {
for (std::vector<SourceSurfaceCairo*>::iterator iter = mSnapshots.begin();
@ -871,7 +871,7 @@ DrawTargetCairo::WillChange(const Path* aPath /* = NULL */)
if (mPathObserver &&
(!aPath || !mPathObserver->ContainsPath(aPath))) {
mPathObserver->PathWillChange();
mPathObserver = NULL;
mPathObserver = nullptr;
}
}

View File

@ -95,7 +95,7 @@ public:
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions,
const GlyphRenderingOptions *aRenderingOptions = NULL);
const GlyphRenderingOptions *aRenderingOptions = nullptr);
virtual void Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions = DrawOptions());
@ -132,7 +132,7 @@ public:
// Call to set up aContext for drawing (with the current transform, etc).
// Pass the path you're going to be using if you have one.
// Implicitly calls WillChange(aPath).
void PrepareForDrawing(cairo_t* aContext, const Path* aPath = NULL);
void PrepareForDrawing(cairo_t* aContext, const Path* aPath = nullptr);
private: // methods
enum DrawPatternType { DRAW_FILL, DRAW_STROKE };
@ -149,7 +149,7 @@ private: // methods
// Call before you make any changes to the backing surface with which this
// context is associated. Pass the path you're going to be using if you have
// one.
void WillChange(const Path* aPath = NULL);
void WillChange(const Path* aPath = nullptr);
// Call if there is any reason to disassociate all snapshots from this draw
// target; for example, because we're going to be destroyed.

View File

@ -79,7 +79,7 @@ public:
1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, NULL, byRef(tmpTexture));
HRESULT hr = mDT->mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
if (FAILED(hr)) {
gfxWarning() << "Failed to create temporary texture to hold surface data.";
}
@ -128,7 +128,7 @@ public:
RefPtr<ID2D1GeometrySink> sink;
invClippedArea->Open(byRef(sink));
rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, NULL, sink);
rectGeom->CombineWithGeometry(mClippedArea, D2D1_COMBINE_MODE_EXCLUDE, nullptr, sink);
sink->Close();
RefPtr<ID2D1BitmapBrush> brush;
@ -151,7 +151,7 @@ private:
DrawTargetD2D::DrawTargetD2D()
: mCurrentCachedLayer(0)
, mClipsArePushed(false)
, mPrivateData(NULL)
, mPrivateData(nullptr)
{
}
@ -183,7 +183,7 @@ DrawTargetD2D::~DrawTargetD2D()
for (int i = 0; i < kLayerCacheSize; i++) {
if (mCachedLayers[i]) {
mCachedLayers[i] = NULL;
mCachedLayers[i] = nullptr;
mVRAMUsageDT -= GetByteSize();
}
}
@ -320,7 +320,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
Float aSigma,
CompositionOp aOperator)
{
RefPtr<ID3D10ShaderResourceView> srView = NULL;
RefPtr<ID3D10ShaderResourceView> srView = nullptr;
if (aSurface->GetType() != SURFACE_D2D1_DRAWTARGET) {
return;
}
@ -342,7 +342,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
if (!mTempRTView) {
// This view is only needed in this path.
HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, NULL, byRef(mTempRTView));
HRESULT hr = mDevice->CreateRenderTargetView(mTempTexture, nullptr, byRef(mTempRTView));
if (FAILED(hr)) {
gfxWarning() << "Failure to create RenderTargetView. Code: " << hr;
@ -360,7 +360,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
if (mPushedClips.size()) {
EnsureClipMaskTexture();
mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, NULL, byRef(maskSRView));
mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(maskSRView));
}
IntSize srcSurfSize;
@ -402,7 +402,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
desc.MiscFlags = D3D10_RESOURCE_MISC_GENERATE_MIPS;
RefPtr<ID3D10Texture2D> mipTexture;
hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mipTexture));
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mipTexture));
if (FAILED(hr)) {
gfxWarning() << "Failure to create temporary texture. Size: " <<
@ -430,7 +430,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
dsSize.height, 1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
RefPtr<ID3D10Texture2D> tmpDSTexture;
hr = mDevice->CreateTexture2D(&desc, NULL, byRef(tmpDSTexture));
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpDSTexture));
if (FAILED(hr)) {
gfxWarning() << "Failure to create temporary texture. Size: " << dsSize << " Code: " << hr;
@ -444,13 +444,13 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
box.bottom = aSurface->GetSize().height;
mDevice->CopySubresourceRegion(mipTexture, 0, 0, 0, 0, static_cast<SourceSurfaceD2DTarget*>(aSurface)->mTexture, 0, &box);
mDevice->CreateShaderResourceView(mipTexture, NULL, byRef(srView));
mDevice->CreateShaderResourceView(mipTexture, nullptr, byRef(srView));
mDevice->GenerateMips(srView);
RefPtr<ID3D10RenderTargetView> dsRTView;
RefPtr<ID3D10ShaderResourceView> dsSRView;
mDevice->CreateRenderTargetView(tmpDSTexture, NULL, byRef(dsRTView));
mDevice->CreateShaderResourceView(tmpDSTexture, NULL, byRef(dsSRView));
mDevice->CreateRenderTargetView(tmpDSTexture, nullptr, byRef(dsRTView));
mDevice->CreateShaderResourceView(tmpDSTexture, nullptr, byRef(dsSRView));
// We're not guaranteed the texture we created will be empty, we've
// seen old content at least on NVidia drivers.
@ -458,7 +458,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
mDevice->ClearRenderTargetView(dsRTView, color);
rtViews = dsRTView;
mDevice->OMSetRenderTargets(1, &rtViews, NULL);
mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
viewport.MaxDepth = 1;
viewport.MinDepth = 0;
@ -472,7 +472,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->
GetPassByIndex(0)->Apply(0);
mDevice->OMSetBlendState(GetBlendStateForOperator(OP_OVER), NULL, 0xffffffff);
mDevice->OMSetBlendState(GetBlendStateForOperator(OP_OVER), nullptr, 0xffffffff);
mDevice->Draw(4, 0);
@ -541,15 +541,15 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
mDevice->CreateTexture2D(&desc, NULL, byRef(tmpTexture));
mDevice->CreateRenderTargetView(tmpTexture, NULL, byRef(tmpRTView));
mDevice->CreateShaderResourceView(tmpTexture, NULL, byRef(tmpSRView));
mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
mDevice->CreateRenderTargetView(tmpTexture, nullptr, byRef(tmpRTView));
mDevice->CreateShaderResourceView(tmpTexture, nullptr, byRef(tmpSRView));
tmpSurfSize = srcSurfSize;
}
rtViews = tmpRTView;
mDevice->OMSetRenderTargets(1, &rtViews, NULL);
mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
@ -593,7 +593,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(tmpSRView);
rtViews = destRTView;
mDevice->OMSetRenderTargets(1, &rtViews, NULL);
mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
Point shadowDest = aDest + aOffset;
@ -619,7 +619,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
GetPassByIndex(1)->Apply(0);
}
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
mDevice->Draw(4, 0);
@ -644,7 +644,7 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
GetPassByIndex(0)->Apply(0);
}
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
mDevice->Draw(4, 0);
}
@ -868,7 +868,7 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
IDWriteRenderingParams *params = NULL;
IDWriteRenderingParams *params = nullptr;
if (aRenderOptions) {
if (aRenderOptions->GetType() != FONT_DWRITE) {
gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
@ -927,7 +927,7 @@ DrawTargetD2D::Mask(const Pattern &aSource,
layer = GetCachedLayer();
rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), NULL,
rt->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), nullptr,
D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
D2D1::IdentityMatrix(),
1.0f, maskBrush),
@ -951,8 +951,8 @@ DrawTargetD2D::PushClip(const Path *aPath)
return;
}
mCurrentClipMaskTexture = NULL;
mCurrentClippedGeometry = NULL;
mCurrentClipMaskTexture = nullptr;
mCurrentClippedGeometry = nullptr;
RefPtr<PathD2D> pathD2D = static_cast<PathD2D*>(const_cast<Path*>(aPath));
@ -980,7 +980,7 @@ DrawTargetD2D::PushClip(const Path *aPath)
mRT->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), pathD2D->mGeometry,
D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
clip.mTransform, 1.0f, NULL,
clip.mTransform, 1.0f, nullptr,
options), clip.mLayer);
}
}
@ -988,8 +988,8 @@ DrawTargetD2D::PushClip(const Path *aPath)
void
DrawTargetD2D::PushClipRect(const Rect &aRect)
{
mCurrentClipMaskTexture = NULL;
mCurrentClippedGeometry = NULL;
mCurrentClipMaskTexture = nullptr;
mCurrentClippedGeometry = nullptr;
if (!mTransform.IsRectilinear()) {
// Whoops, this isn't a rectangle in device space, Direct2D will not deal
// with this transform the way we want it to.
@ -1021,8 +1021,8 @@ DrawTargetD2D::PushClipRect(const Rect &aRect)
void
DrawTargetD2D::PopClip()
{
mCurrentClipMaskTexture = NULL;
mCurrentClippedGeometry = NULL;
mCurrentClipMaskTexture = nullptr;
mCurrentClippedGeometry = nullptr;
if (mClipsArePushed) {
if (mPushedClips.back().mLayer) {
PopCachedLayer(mRT);
@ -1042,7 +1042,7 @@ DrawTargetD2D::CreateSourceSurfaceFromData(unsigned char *aData,
RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
if (!newSurf->InitFromData(aData, aSize, aStride, aFormat, mRT)) {
return NULL;
return nullptr;
}
return newSurf;
@ -1052,7 +1052,7 @@ TemporaryRef<SourceSurface>
DrawTargetD2D::OptimizeSourceSurface(SourceSurface *aSurface) const
{
// Unsupported!
return NULL;
return nullptr;
}
TemporaryRef<SourceSurface>
@ -1060,7 +1060,7 @@ DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurfac
{
if (aSurface.mType != NATIVE_SURFACE_D3D10_TEXTURE) {
gfxDebug() << *this << ": Failure to create source surface from non-D3D10 texture native surface.";
return NULL;
return nullptr;
}
RefPtr<SourceSurfaceD2D> newSurf = new SourceSurfaceD2D();
@ -1069,7 +1069,7 @@ DrawTargetD2D::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurfac
mRT))
{
gfxWarning() << *this << ": Failed to create SourceSurface from texture.";
return NULL;
return nullptr;
}
return newSurf;
@ -1083,7 +1083,7 @@ DrawTargetD2D::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aForm
if (!newTarget->Init(aSize, aFormat)) {
gfxDebug() << *this << ": Failed to create optimal draw target. Size: " << aSize;
return NULL;
return nullptr;
}
return newTarget;
@ -1097,14 +1097,14 @@ DrawTargetD2D::CreatePathBuilder(FillRule aFillRule) const
if (FAILED(hr)) {
gfxWarning() << "Failed to create Direct2D Path Geometry. Code: " << hr;
return NULL;
return nullptr;
}
RefPtr<ID2D1GeometrySink> sink;
hr = path->Open(byRef(sink));
if (FAILED(hr)) {
gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hr;
return NULL;
return nullptr;
}
if (aFillRule == FILL_WINDING) {
@ -1134,7 +1134,7 @@ DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, E
if (FAILED(hr)) {
gfxWarning() << "Failed to create GradientStopCollection. Code: " << hr;
return NULL;
return nullptr;
}
return new GradientStopsD2D(stopCollection);
@ -1144,7 +1144,7 @@ void*
DrawTargetD2D::GetNativeSurface(NativeSurfaceType aType)
{
if (aType != NATIVE_SURFACE_D3D10_TEXTURE) {
return NULL;
return nullptr;
}
return mTexture;
@ -1173,7 +1173,7 @@ DrawTargetD2D::Init(const IntSize &aSize, SurfaceFormat aFormat)
1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mTexture));
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTexture));
if (FAILED(hr)) {
gfxDebug() << "Failed to init Direct2D DrawTarget. Size: " << mSize << " Code: " << hr;
@ -1243,7 +1243,7 @@ DrawTargetD2D::InitD3D10Data()
createD3DEffect = (D3D10CreateEffectFromMemoryFunc)
GetProcAddress(d3dModule, "D3D10CreateEffectFromMemory");
hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, NULL, byRef(mPrivateData->mEffect));
hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, byRef(mPrivateData->mEffect));
if (FAILED(hr)) {
gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hr;
@ -1375,7 +1375,7 @@ DrawTargetD2D::MarkChanged()
if (mSnapshot) {
if (mSnapshot->hasOneRef()) {
// Just destroy it, since no-one else knows about it.
mSnapshot = NULL;
mSnapshot = nullptr;
} else {
mSnapshot->DrawTargetWillChange();
// The snapshot will no longer depend on this target.
@ -1533,7 +1533,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP
}
ID3D10RenderTargetView *rtViews = mRTView;
mDevice->OMSetRenderTargets(1, &rtViews, NULL);
mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
UINT stride = sizeof(Vertex);
UINT offset = 0;
@ -1573,7 +1573,7 @@ DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aP
SetupEffectForRadialGradient(pat);
}
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), NULL, 0xffffffff);
mDevice->OMSetBlendState(GetBlendStateForOperator(aOperator), nullptr, 0xffffffff);
mDevice->Draw(4, 0);
}
@ -1671,7 +1671,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm
if (FAILED(hr)) {
gfxWarning() << "Failed to QI texture to surface.";
return NULL;
return nullptr;
}
D3D10_TEXTURE2D_DESC desc;
@ -1689,7 +1689,7 @@ DrawTargetD2D::CreateRTForTexture(ID3D10Texture2D *aTexture, SurfaceFormat aForm
if (FAILED(hr)) {
gfxWarning() << "Failed to create D2D render target for texture.";
return NULL;
return nullptr;
}
return rt;
@ -1710,7 +1710,7 @@ DrawTargetD2D::EnsureViews()
1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mTempTexture));
hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mTempTexture));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create temporary texture for rendertarget. Size: "
@ -1718,14 +1718,14 @@ DrawTargetD2D::EnsureViews()
return;
}
hr = mDevice->CreateShaderResourceView(mTempTexture, NULL, byRef(mSRView));
hr = mDevice->CreateShaderResourceView(mTempTexture, nullptr, byRef(mSRView));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
return;
}
hr = mDevice->CreateRenderTargetView(mTexture, NULL, byRef(mRTView));
hr = mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(mRTView));
if (FAILED(hr)) {
gfxWarning() << *this << "Failed to create rendertarget view for temp texture. Code: " << hr;
@ -1756,7 +1756,7 @@ DrawTargetD2D::PushClipsToRT(ID2D1RenderTarget *aRT)
aRT->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), iter->mPath->mGeometry,
D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
iter->mTransform, 1.0f, NULL,
iter->mTransform, 1.0f, nullptr,
options), iter->mLayer);
} else {
aRT->PushAxisAlignedClip(iter->mBounds, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
@ -1789,7 +1789,7 @@ DrawTargetD2D::EnsureClipMaskTexture()
1, 1);
desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
HRESULT hr = mDevice->CreateTexture2D(&desc, NULL, byRef(mCurrentClipMaskTexture));
HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(mCurrentClipMaskTexture));
if (FAILED(hr)) {
gfxWarning() << "Failed to create texture for ClipMask!";
@ -1909,7 +1909,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
}
RefPtr<ID3D10ShaderResourceView> srView;
hr = mDevice->CreateShaderResourceView(tex, NULL, byRef(srView));
hr = mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView));
if (FAILED(hr)) {
return false;
@ -1960,7 +1960,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
EnsureClipMaskTexture();
RefPtr<ID3D10ShaderResourceView> srViewMask;
hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, NULL, byRef(srViewMask));
hr = mDevice->CreateShaderResourceView(mCurrentClipMaskTexture, nullptr, byRef(srViewMask));
if (FAILED(hr)) {
return false;
@ -1979,10 +1979,10 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
RefPtr<ID3D10RenderTargetView> rtView;
ID3D10RenderTargetView *rtViews;
mDevice->CreateRenderTargetView(mTexture, NULL, byRef(rtView));
mDevice->CreateRenderTargetView(mTexture, nullptr, byRef(rtView));
rtViews = rtView;
mDevice->OMSetRenderTargets(1, &rtViews, NULL);
mDevice->OMSetRenderTargets(1, &rtViews, nullptr);
mDevice->Draw(4, 0);
return true;
@ -2014,7 +2014,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
if (!stops) {
gfxDebug() << "No stops specified for gradient pattern.";
return NULL;
return nullptr;
}
if (pat->mBegin == pat->mEnd) {
@ -2043,7 +2043,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
if (!stops) {
gfxDebug() << "No stops specified for gradient pattern.";
return NULL;
return nullptr;
}
// This will not be a complex radial gradient brush.
@ -2063,7 +2063,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
if (!pat->mSurface) {
gfxDebug() << "No source surface specified for surface pattern";
return NULL;
return nullptr;
}
RefPtr<ID2D1Bitmap> bitmap;
@ -2078,7 +2078,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
bitmap = surf->mBitmap;
if (!bitmap) {
return NULL;
return nullptr;
}
}
break;
@ -2097,7 +2097,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
bitmap = CreatePartialBitmapForSurface(dataSurf, mat, pat->mExtendMode);
if (!bitmap) {
return NULL;
return nullptr;
}
}
break;
@ -2116,7 +2116,7 @@ DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
}
gfxWarning() << "Invalid pattern type detected.";
return NULL;
return nullptr;
}
TemporaryRef<ID2D1StrokeStyle>
@ -2183,7 +2183,7 @@ DrawTargetD2D::CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
D2D1::StrokeStyleProperties(capStyle, capStyle,
capStyle, joinStyle,
aStrokeOptions.mMiterLimit),
NULL, 0, byRef(style));
nullptr, 0, byRef(style));
}
if (FAILED(hr)) {
@ -2285,7 +2285,7 @@ DrawTargetD2D::CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, cons
if (FAILED(hr)) {
delete [] texture;
return NULL;
return nullptr;
}
int alignedBufferSize = aBounds.width * aBounds.height * 4;
@ -2324,7 +2324,7 @@ DrawTargetD2D::CreateTextureForAnalysis(IDWriteGlyphRunAnalysis *aAnalysis, cons
delete [] texture;
if (FAILED(hr)) {
return NULL;
return nullptr;
}
return tex;
@ -2344,7 +2344,7 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
Matrix invTransform = transform = aMatrix * transform;
if (!invTransform.Invert()) {
// Singular transform, nothing to be drawn.
return NULL;
return nullptr;
}
Rect rect(0, 0, mSize.width, mSize.height);
@ -2412,7 +2412,7 @@ DrawTargetD2D::CreatePartialBitmapForSurface(DataSourceSurface *aSurface, Matrix
if (Bpp != 4) {
// This shouldn't actually happen in practice!
MOZ_ASSERT(false);
return NULL;
return nullptr;
}
ImageHalfScaler scaler(aSurface->GetData(), stride, size);
@ -2469,7 +2469,7 @@ DrawTargetD2D::SetupEffectForRadialGradient(const RadialGradientPattern *aPatter
RefPtr<ID3D10Texture2D> tex = CreateGradientTexture(stops);
RefPtr<ID3D10ShaderResourceView> srView;
mDevice->CreateShaderResourceView(tex, NULL, byRef(srView));
mDevice->CreateShaderResourceView(tex, nullptr, byRef(srView));
mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
@ -2563,7 +2563,7 @@ DrawTargetD2D::factory()
if (!createD2DFactory) {
gfxWarning() << "Failed to locate D2D1CreateFactory function.";
return NULL;
return nullptr;
}
D2D1_FACTORY_OPTIONS options;
@ -2599,7 +2599,7 @@ DrawTargetD2D::GetDWriteFactory()
if (!createDWriteFactory) {
gfxWarning() << "Failed to locate DWriteCreateFactory function.";
return NULL;
return nullptr;
}
HRESULT hr = createDWriteFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),

View File

@ -91,7 +91,7 @@ public:
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions(),
const GlyphRenderingOptions *aRenderingOptions = NULL);
const GlyphRenderingOptions *aRenderingOptions = nullptr);
virtual void Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions = DrawOptions());

View File

@ -124,7 +124,7 @@ public:
virtual void *GetNativeSurface(NativeSurfaceType aType)
{
return NULL;
return nullptr;
}
private:
@ -135,4 +135,4 @@ private:
}
}
#endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */
#endif /* MOZILLA_GFX_DRAWTARGETDUAL_H_ */

View File

@ -162,7 +162,7 @@ DrawTargetSkia::Snapshot()
{
RefPtr<SourceSurfaceSkia> source = new SourceSurfaceSkia();
if (!source->InitWithBitmap(mBitmap, mFormat, this)) {
return NULL;
return nullptr;
}
AppendSnapshot(source);
return source;
@ -311,7 +311,7 @@ struct AutoPaintSetup {
temp.setXfermodeMode(GfxOpToSkiaOp(aOptions.mCompositionOp));
temp.setAlpha(aOptions.mAlpha*255);
//TODO: Get a rect here
mCanvas->saveLayer(NULL, &temp);
mCanvas->saveLayer(nullptr, &temp);
mNeedsRestore = true;
} else {
mPaint.setAlpha(aOptions.mAlpha*255.0);
@ -591,7 +591,7 @@ DrawTargetSkia::CreateSourceSurfaceFromData(unsigned char *aData,
if (!newSurf->InitFromData(aData, aSize, aStride, aFormat)) {
gfxDebug() << *this << ": Failure to create source surface from data. Size: " << aSize;
return NULL;
return nullptr;
}
return newSurf;
@ -602,7 +602,7 @@ DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
{
RefPtr<DrawTargetSkia> target = new DrawTargetSkia();
if (!target->Init(aSize, aFormat)) {
return NULL;
return nullptr;
}
return target;
}
@ -610,13 +610,13 @@ DrawTargetSkia::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFor
TemporaryRef<SourceSurface>
DrawTargetSkia::OptimizeSourceSurface(SourceSurface *aSurface) const
{
return NULL;
return nullptr;
}
TemporaryRef<SourceSurface>
DrawTargetSkia::CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
{
return NULL;
return nullptr;
}
void

View File

@ -66,7 +66,7 @@ public:
const GlyphBuffer &aBuffer,
const Pattern &aPattern,
const DrawOptions &aOptions = DrawOptions(),
const GlyphRenderingOptions *aRenderingOptions = NULL);
const GlyphRenderingOptions *aRenderingOptions = nullptr);
virtual void Mask(const Pattern &aSource,
const Pattern &aMask,
const DrawOptions &aOptions = DrawOptions());

View File

@ -196,12 +196,12 @@ Factory::CreateDrawTarget(BackendType aBackend, const IntSize &aSize, SurfaceFor
#endif
default:
gfxDebug() << "Invalid draw target type specified.";
return NULL;
return nullptr;
}
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
// Failed
return NULL;
return nullptr;
}
TemporaryRef<DrawTarget>
@ -232,12 +232,12 @@ Factory::CreateDrawTargetForData(BackendType aBackend,
#endif
default:
gfxDebug() << "Invalid draw target type specified.";
return NULL;
return nullptr;
}
gfxDebug() << "Failed to create DrawTarget, Type: " << aBackend << " Size: " << aSize;
// Failed
return NULL;
return nullptr;
}
TemporaryRef<ScaledFont>
@ -278,7 +278,7 @@ Factory::CreateScaledFontForNativeFont(const NativeFont &aNativeFont, Float aSiz
#endif
default:
gfxWarning() << "Invalid native font type specified.";
return NULL;
return nullptr;
}
}
@ -294,7 +294,7 @@ Factory::CreateScaledFontWithCairo(const NativeFont& aNativeFont, Float aSize, c
static_cast<ScaledFontBase*>(font.get())->SetCairoScaledFont(aScaledFont);
return font;
#else
return NULL;
return nullptr;
#endif
}
@ -312,7 +312,7 @@ Factory::CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceForma
gfxWarning() << "Failed to create draw target for D3D10 texture.";
// Failed
return NULL;
return nullptr;
}
TemporaryRef<DrawTarget>
@ -326,13 +326,13 @@ Factory::CreateDualDrawTargetForD3D10Textures(ID3D10Texture2D *aTextureA,
newTargetA = new DrawTargetD2D();
if (!newTargetA->Init(aTextureA, aFormat)) {
gfxWarning() << "Failed to create draw target for D3D10 texture.";
return NULL;
return nullptr;
}
newTargetB = new DrawTargetD2D();
if (!newTargetB->Init(aTextureB, aFormat)) {
gfxWarning() << "Failed to create draw target for D3D10 texture.";
return NULL;
return nullptr;
}
RefPtr<DrawTarget> newTarget =
@ -386,7 +386,7 @@ Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface, const IntSiz
}
#endif
return NULL;
return nullptr;
}
TemporaryRef<DataSourceSurface>
@ -400,7 +400,7 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
return newSurf;
}
return NULL;
return nullptr;
}
}

View File

@ -19,7 +19,7 @@ class ImageHalfScaler
public:
ImageHalfScaler(uint8_t *aData, int32_t aStride, const IntSize &aSize)
: mOrigData(aData), mOrigStride(aStride), mOrigSize(aSize)
, mDataStorage(NULL)
, mDataStorage(nullptr)
{
}

View File

@ -19,7 +19,7 @@ PathBuilderCG::~PathBuilderCG()
void
PathBuilderCG::MoveTo(const Point &aPoint)
{
CGPathMoveToPoint(mCGPath, NULL, aPoint.x, aPoint.y);
CGPathMoveToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
}
void
@ -28,7 +28,7 @@ PathBuilderCG::LineTo(const Point &aPoint)
if (CGPathIsEmpty(mCGPath))
MoveTo(aPoint);
else
CGPathAddLineToPoint(mCGPath, NULL, aPoint.x, aPoint.y);
CGPathAddLineToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
}
void
@ -39,7 +39,7 @@ PathBuilderCG::BezierTo(const Point &aCP1,
if (CGPathIsEmpty(mCGPath))
MoveTo(aCP1);
CGPathAddCurveToPoint(mCGPath, NULL,
CGPathAddCurveToPoint(mCGPath, nullptr,
aCP1.x, aCP1.y,
aCP2.x, aCP2.y,
aCP3.x, aCP3.y);
@ -52,7 +52,7 @@ PathBuilderCG::QuadraticBezierTo(const Point &aCP1,
{
if (CGPathIsEmpty(mCGPath))
MoveTo(aCP1);
CGPathAddQuadCurveToPoint(mCGPath, NULL,
CGPathAddQuadCurveToPoint(mCGPath, nullptr,
aCP1.x, aCP1.y,
aCP2.x, aCP2.y);
}
@ -171,7 +171,7 @@ PathCG::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
// The transform parameter of CGPathContainsPoint doesn't seem to work properly on OS X 10.5
// so we transform aPoint ourselves.
return CGPathContainsPoint(mPath, NULL, point, mFillRule == FILL_EVEN_ODD);
return CGPathContainsPoint(mPath, nullptr, point, mFillRule == FILL_EVEN_ODD);
}
static size_t
@ -184,9 +184,9 @@ PutBytesNull(void *info, const void *buffer, size_t count)
static CGContextRef
CreateScratchContext()
{
CGDataConsumerCallbacks callbacks = {PutBytesNull, NULL};
CGDataConsumerRef consumer = CGDataConsumerCreate(NULL, &callbacks);
CGContextRef cg = CGPDFContextCreate(consumer, NULL, NULL);
CGDataConsumerCallbacks callbacks = {PutBytesNull, nullptr};
CGDataConsumerRef consumer = CGDataConsumerCreate(nullptr, &callbacks);
CGContextRef cg = CGPDFContextCreate(consumer, nullptr, nullptr);
CGDataConsumerRelease(consumer);
return cg;
}

View File

@ -39,7 +39,7 @@ CairoPathContext::CairoPathContext(cairo_t* aCtx, DrawTargetCairo* aDrawTarget,
CairoPathContext::~CairoPathContext()
{
if (mDrawTarget) {
mDrawTarget->SetPathObserver(NULL);
mDrawTarget->SetPathObserver(nullptr);
}
cairo_destroy(mContext);
}
@ -52,7 +52,7 @@ CairoPathContext::ObserveTarget(DrawTargetCairo* aDrawTarget)
}
if (mDrawTarget) {
mDrawTarget->SetPathObserver(NULL);
mDrawTarget->SetPathObserver(nullptr);
}
mDrawTarget = aDrawTarget;
@ -159,7 +159,7 @@ CairoPathContext::CopyPathTo(cairo_t* aToContext)
void
CairoPathContext::ForgetDrawTarget()
{
mDrawTarget = NULL;
mDrawTarget = nullptr;
}
bool

View File

@ -236,7 +236,7 @@ PathBuilderD2D::Finish()
HRESULT hr = mSink->Close();
if (FAILED(hr)) {
gfxDebug() << "Failed to close PathSink. Code: " << hr;
return NULL;
return nullptr;
}
return new PathD2D(mGeometry, mFigureActive, mCurrentPoint, mFillRule);
@ -256,14 +256,14 @@ PathD2D::TransformedCopyToBuilder(const Matrix &aTransform, FillRule aFillRule)
if (FAILED(hr)) {
gfxWarning() << "Failed to create PathGeometry. Code: " << hr;
return NULL;
return nullptr;
}
RefPtr<ID2D1GeometrySink> sink;
hr = path->Open(byRef(sink));
if (FAILED(hr)) {
gfxWarning() << "Failed to open Geometry for writing. Code: " << hr;
return NULL;
return nullptr;
}
if (aFillRule == FILL_WINDING) {

View File

@ -137,7 +137,7 @@ CGLTexImageIOSurface2DFunc MacIOSurfaceLib::sTexImage;
IOSurfaceContextCreateFunc MacIOSurfaceLib::sIOSurfaceContextCreate;
IOSurfaceContextCreateImageFunc MacIOSurfaceLib::sIOSurfaceContextCreateImage;
IOSurfaceContextGetSurfaceFunc MacIOSurfaceLib::sIOSurfaceContextGetSurface;
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = NULL;
unsigned int (*MacIOSurfaceLib::sCGContextGetTypePtr) (CGContextRef) = nullptr;
CFStringRef MacIOSurfaceLib::kPropWidth;
CFStringRef MacIOSurfaceLib::kPropHeight;
@ -208,19 +208,19 @@ CGContextRef MacIOSurfaceLib::IOSurfaceContextCreate(IOSurfacePtr aIOSurfacePtr,
unsigned aBitsPerComponent, unsigned aBytes,
CGColorSpaceRef aColorSpace, CGBitmapInfo bitmapInfo) {
if (!sIOSurfaceContextCreate)
return NULL;
return nullptr;
return sIOSurfaceContextCreate(aIOSurfacePtr, aWidth, aHeight, aBitsPerComponent, aBytes, aColorSpace, bitmapInfo);
}
CGImageRef MacIOSurfaceLib::IOSurfaceContextCreateImage(CGContextRef aContext) {
if (!sIOSurfaceContextCreateImage)
return NULL;
return nullptr;
return sIOSurfaceContextCreateImage(aContext);
}
IOSurfacePtr MacIOSurfaceLib::IOSurfaceContextGetSurface(CGContextRef aContext) {
if (!sIOSurfaceContextGetSurface)
return NULL;
return nullptr;
return sIOSurfaceContextGetSurface(aContext);
}
@ -314,9 +314,9 @@ TemporaryRef<MacIOSurface> MacIOSurface::CreateIOSurface(int aWidth, int aHeight
return nullptr;
int32_t bytesPerElem = 4;
CFNumberRef cfWidth = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &aWidth);
CFNumberRef cfHeight = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &aHeight);
CFNumberRef cfBytesPerElem = ::CFNumberCreate(NULL, kCFNumberSInt32Type, &bytesPerElem);
CFNumberRef cfWidth = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aWidth);
CFNumberRef cfHeight = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &aHeight);
CFNumberRef cfBytesPerElem = ::CFNumberCreate(nullptr, kCFNumberSInt32Type, &bytesPerElem);
::CFDictionaryAddValue(props, MacIOSurfaceLib::kPropWidth,
cfWidth);
::CFRelease(cfWidth);
@ -382,11 +382,11 @@ size_t MacIOSurface::GetBytesPerRow() {
#define READ_ONLY 0x1
void MacIOSurface::Lock() {
MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, NULL);
MacIOSurfaceLib::IOSurfaceLock(mIOSurfacePtr, READ_ONLY, nullptr);
}
void MacIOSurface::Unlock() {
MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, NULL);
MacIOSurfaceLib::IOSurfaceUnlock(mIOSurfacePtr, READ_ONLY, nullptr);
}
#include "SourceSurfaceRawData.h"
@ -590,7 +590,7 @@ nsresult nsCARenderer::SetupRenderer(void *aCALayer, int aWidth, int aHeight,
mCGImage = ::CGImageCreate(aWidth, aHeight, 8, 32, aWidth * 4, colorSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, NULL, true, kCGRenderingIntentDefault);
dataProvider, nullptr, true, kCGRenderingIntentDefault);
::CGDataProviderRelease(dataProvider);
if (colorSpace) {
@ -763,8 +763,8 @@ nsresult nsCARenderer::Render(int aWidth, int aHeight,
NS_ERROR("No target destination for rendering");
} else if (aOutCGImage) {
// We are expected to return a CGImageRef, we will set
// it to NULL in case we fail before the image is ready.
*aOutCGImage = NULL;
// it to nullptr in case we fail before the image is ready.
*aOutCGImage = nullptr;
}
if (aWidth == 0 || aHeight == 0)
@ -813,7 +813,7 @@ nsresult nsCARenderer::Render(int aWidth, int aHeight,
[CATransaction commit];
double caTime = ::CACurrentMediaTime();
[caRenderer beginFrameAtTime:caTime timeStamp:NULL];
[caRenderer beginFrameAtTime:caTime timeStamp:nullptr];
[caRenderer addUpdateRect:CGRectMake(0,0, aWidth, aHeight)];
[caRenderer render];
[caRenderer endFrame];
@ -867,7 +867,7 @@ nsresult nsCARenderer::DrawSurfaceToCGContext(CGContextRef aContext,
void* ioData = surf->GetBaseAddress();
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
ioData, ioHeight*(bytesPerRow)*4,
NULL); //No release callback
nullptr); //No release callback
if (!dataProvider) {
surf->Unlock();
return NS_ERROR_FAILURE;
@ -875,7 +875,7 @@ nsresult nsCARenderer::DrawSurfaceToCGContext(CGContextRef aContext,
CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
aColorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, NULL, true, kCGRenderingIntentDefault);
dataProvider, nullptr, true, kCGRenderingIntentDefault);
::CGDataProviderRelease(dataProvider);
if (!cgImage) {
surf->Unlock();
@ -925,7 +925,7 @@ void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
void* ioData = surf->GetBaseAddress();
CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
ioData, ioHeight*(bytesPerRow)*4,
NULL); //No release callback
nullptr); //No release callback
if (!dataProvider) {
surf->Unlock();
return;
@ -934,7 +934,7 @@ void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
CGColorSpaceRef colorSpace = CreateSystemColorSpace();
CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
dataProvider, NULL, true, kCGRenderingIntentDefault);
dataProvider, nullptr, true, kCGRenderingIntentDefault);
::CGDataProviderRelease(dataProvider);
::CGColorSpaceRelease(colorSpace);
if (!cgImage) {
@ -949,16 +949,16 @@ void nsCARenderer::SaveToDisk(MacIOSurface *surf) {
CFStringRef cfStr = ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingMacRoman);
printf("Exporting: %s\n", cstr);
CFURLRef url = ::CFURLCreateWithString( NULL, cfStr, NULL);
CFURLRef url = ::CFURLCreateWithString( nullptr, cfStr, nullptr);
::CFRelease(cfStr);
CFStringRef type = kUTTypePNG;
size_t count = 1;
CFDictionaryRef options = NULL;
CFDictionaryRef options = nullptr;
CGImageDestinationRef dest = ::CGImageDestinationCreateWithURL(url, type, count, options);
::CFRelease(url);
::CGImageDestinationAddImage(dest, cgImage, NULL);
::CGImageDestinationAddImage(dest, cgImage, nullptr);
::CGImageDestinationFinalize(dest);
::CFRelease(dest);

View File

@ -37,10 +37,10 @@ ScaledFontBase::ScaledFontBase(Float aSize)
: mSize(aSize)
{
#ifdef USE_SKIA
mTypeface = NULL;
mTypeface = nullptr;
#endif
#ifdef USE_CAIRO
mScaledFont = NULL;
mScaledFont = nullptr;
#endif
}
@ -95,7 +95,7 @@ ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *a
return builder->Finish();
}
#endif
return NULL;
return nullptr;
}
void

View File

@ -18,7 +18,7 @@ ScaledFontDWrite::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget
if (aTarget->GetType() != BACKEND_DIRECT2D) {
// For now we only support Direct2D.
gfxWarning() << "Attempt to use Direct Write font with non-Direct2D backend";
return NULL;
return nullptr;
}
RefPtr<PathBuilder> pathBuilder = aTarget->CreatePathBuilder();

View File

@ -38,7 +38,7 @@ ScaledFontMac::~ScaledFontMac()
SkTypeface* ScaledFontMac::GetSkTypeface()
{
if (!mTypeface) {
CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, NULL, NULL);
CTFontRef fontFace = CTFontCreateWithGraphicsFont(mFont, mSize, nullptr, nullptr);
mTypeface = SkCreateTypefaceFromCTFont(fontFace);
CFRelease(fontFace);
}

View File

@ -53,9 +53,9 @@ SourceSurfaceCG::InitFromData(unsigned char *aData,
SurfaceFormat aFormat)
{
//XXX: we should avoid creating this colorspace everytime
CGColorSpaceRef colorSpace = NULL;
CGColorSpaceRef colorSpace = nullptr;
CGBitmapInfo bitinfo = 0;
CGDataProviderRef dataProvider = NULL;
CGDataProviderRef dataProvider = nullptr;
int bitsPerComponent = 0;
int bitsPerPixel = 0;
@ -110,7 +110,7 @@ SourceSurfaceCG::InitFromData(unsigned char *aData,
colorSpace,
bitinfo,
dataProvider,
NULL,
nullptr,
true,
kCGRenderingIntentDefault);
}
@ -118,7 +118,7 @@ SourceSurfaceCG::InitFromData(unsigned char *aData,
CGDataProviderRelease(dataProvider);
CGColorSpaceRelease (colorSpace);
return mImage != NULL;
return mImage != nullptr;
}
DataSourceSurfaceCG::~DataSourceSurfaceCG()
@ -144,9 +144,9 @@ DataSourceSurfaceCG::InitFromData(unsigned char *aData,
SurfaceFormat aFormat)
{
//XXX: we should avoid creating this colorspace everytime
CGColorSpaceRef colorSpace = NULL;
CGColorSpaceRef colorSpace = nullptr;
CGBitmapInfo bitinfo = 0;
CGDataProviderRef dataProvider = NULL;
CGDataProviderRef dataProvider = nullptr;
int bitsPerComponent = 0;
int bitsPerPixel = 0;
@ -199,7 +199,7 @@ DataSourceSurfaceCG::InitFromData(unsigned char *aData,
colorSpace,
bitinfo,
dataProvider,
NULL,
nullptr,
true,
kCGRenderingIntentDefault);
}
@ -225,10 +225,10 @@ CGContextRef CreateBitmapContextForImage(CGImageRef image)
colorSpace = CGColorSpaceCreateDeviceRGB();
assert(colorSpace);
// we'd like to pass NULL as the first parameter
// we'd like to pass nullptr as the first parameter
// to let Quartz manage this memory for us. However,
// on 10.5 and older CGBitmapContextGetData will return
// NULL instead of the associated buffer so we need
// nullptr instead of the associated buffer so we need
// to manage it ourselves.
CGContextRef cg = CGBitmapContextCreate(data,
width,
@ -248,7 +248,7 @@ DataSourceSurfaceCG::DataSourceSurfaceCG(CGImageRef aImage)
{
mImage = aImage;
mCg = CreateBitmapContextForImage(aImage);
if (mCg == NULL) {
if (mCg == nullptr) {
// error creating context
return;
}
@ -295,7 +295,7 @@ SourceSurfaceCGBitmapContext::SourceSurfaceCGBitmapContext(DrawTargetCG *aDrawTa
mStride = CGBitmapContextGetBytesPerRow(mCg);
mData = CGBitmapContextGetData(mCg);
mImage = NULL;
mImage = nullptr;
}
void SourceSurfaceCGBitmapContext::EnsureImage() const
@ -309,9 +309,9 @@ void SourceSurfaceCGBitmapContext::EnsureImage() const
// performance characteristics.
if (!mImage) {
//XXX: we should avoid creating this colorspace everytime
CGColorSpaceRef colorSpace = NULL;
CGColorSpaceRef colorSpace = nullptr;
CGBitmapInfo bitinfo = 0;
CGDataProviderRef dataProvider = NULL;
CGDataProviderRef dataProvider = nullptr;
int bitsPerComponent = 8;
int bitsPerPixel = 32;
@ -323,7 +323,7 @@ void SourceSurfaceCGBitmapContext::EnsureImage() const
// if we have an mCg than it owns the data
// and we don't want to tranfer ownership
// to the CGDataProviderCreateWithData
info = NULL;
info = nullptr;
} else {
// otherwise we transfer ownership to
// the dataProvider
@ -344,7 +344,7 @@ void SourceSurfaceCGBitmapContext::EnsureImage() const
colorSpace,
bitinfo,
dataProvider,
NULL,
nullptr,
true,
kCGRenderingIntentDefault);
@ -378,10 +378,10 @@ SourceSurfaceCGBitmapContext::DrawTargetWillChange()
// drop the current image for the data associated with the CGBitmapContext
if (mImage)
CGImageRelease(mImage);
mImage = NULL;
mImage = nullptr;
mCg = NULL;
mDrawTarget = NULL;
mCg = nullptr;
mDrawTarget = nullptr;
}
}
@ -406,7 +406,7 @@ SourceSurfaceCGIOSurfaceContext::SourceSurfaceCGIOSurfaceContext(DrawTargetCG *a
// TODO use CreateImageFromIOSurfaceContext instead of reading back the surface
//mImage = MacIOSurface::CreateImageFromIOSurfaceContext(cg);
mImage = NULL;
mImage = nullptr;
aDrawTarget->Flush();
surf->Lock();
@ -434,9 +434,9 @@ void SourceSurfaceCGIOSurfaceContext::EnsureImage() const
// performance characteristics.
if (!mImage) {
//XXX: we should avoid creating this colorspace everytime
CGColorSpaceRef colorSpace = NULL;
CGColorSpaceRef colorSpace = nullptr;
CGBitmapInfo bitinfo = 0;
CGDataProviderRef dataProvider = NULL;
CGDataProviderRef dataProvider = nullptr;
int bitsPerComponent = 8;
int bitsPerPixel = 32;
@ -457,7 +457,7 @@ void SourceSurfaceCGIOSurfaceContext::EnsureImage() const
colorSpace,
bitinfo,
dataProvider,
NULL,
nullptr,
true,
kCGRenderingIntentDefault);

View File

@ -31,7 +31,7 @@ CairoFormatToSurfaceFormat(cairo_format_t format)
SourceSurfaceCairo::SourceSurfaceCairo(cairo_surface_t* aSurface,
const IntSize& aSize,
const SurfaceFormat& aFormat,
DrawTargetCairo* aDrawTarget /* = NULL */)
DrawTargetCairo* aDrawTarget /* = nullptr */)
: mSize(aSize)
, mFormat(aFormat)
, mSurface(aSurface)
@ -92,7 +92,7 @@ void
SourceSurfaceCairo::DrawTargetWillChange()
{
if (mDrawTarget) {
mDrawTarget = NULL;
mDrawTarget = nullptr;
// We're about to lose our version of the surface, so make a copy of it.
cairo_surface_t* surface = cairo_surface_create_similar(mSurface,
@ -116,7 +116,7 @@ SourceSurfaceCairo::MarkIndependent()
{
if (mDrawTarget) {
mDrawTarget->RemoveSnapshot(this);
mDrawTarget = NULL;
mDrawTarget = nullptr;
}
}

View File

@ -18,12 +18,12 @@ class SourceSurfaceCairo : public SourceSurface
public:
// Create a SourceSurfaceCairo. The surface will not be copied, but simply
// referenced.
// If aDrawTarget is non-NULL, it is assumed that this is a snapshot source
// If aDrawTarget is non-nullptr, it is assumed that this is a snapshot source
// surface, and we'll call DrawTargetCairo::RemoveSnapshot(this) on it when
// we're destroyed.
SourceSurfaceCairo(cairo_surface_t* aSurface, const IntSize& aSize,
const SurfaceFormat& aFormat,
DrawTargetCairo* aDrawTarget = NULL);
DrawTargetCairo* aDrawTarget = nullptr);
virtual ~SourceSurfaceCairo();
virtual SurfaceType GetType() const { return SURFACE_CAIRO; }

View File

@ -43,7 +43,7 @@ SourceSurfaceD2D::IsValid() const
TemporaryRef<DataSourceSurface>
SourceSurfaceD2D::GetDataSurface()
{
return NULL;
return nullptr;
}
bool

View File

@ -64,11 +64,11 @@ SourceSurfaceD2DTarget::GetDataSurface()
desc.BindFlags = 0;
desc.MiscFlags = 0;
HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, NULL, byRef(dataSurf->mTexture));
HRESULT hr = Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(dataSurf->mTexture));
if (FAILED(hr)) {
gfxDebug() << "Failed to create staging texture for SourceSurface. Code: " << hr;
return NULL;
return nullptr;
}
Factory::GetDirect3D10Device()->CopyResource(dataSurf->mTexture, mTexture);
@ -82,7 +82,7 @@ SourceSurfaceD2DTarget::GetSRView()
return mSRView;
}
HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, NULL, byRef(mSRView));
HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, byRef(mSRView));
if (FAILED(hr)) {
gfxWarning() << "Failed to create ShaderResourceView. Code: " << hr;
@ -100,10 +100,10 @@ SourceSurfaceD2DTarget::DrawTargetWillChange()
mTexture->GetDesc(&desc);
// Get a copy of the surface data so the content at snapshot time was saved.
Factory::GetDirect3D10Device()->CreateTexture2D(&desc, NULL, byRef(mTexture));
Factory::GetDirect3D10Device()->CreateTexture2D(&desc, nullptr, byRef(mTexture));
Factory::GetDirect3D10Device()->CopyResource(mTexture, oldTexture);
mBitmap = NULL;
mBitmap = nullptr;
DrawTargetD2D::mVRAMUsageSS += desc.Width * desc.Height * BytesPerPixel(mFormat);
mOwnsCopy = true;
@ -130,7 +130,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT)
if (FAILED(hr)) {
gfxWarning() << "Failed to query interface texture to DXGISurface. Code: " << hr;
return NULL;
return nullptr;
}
D2D1_BITMAP_PROPERTIES props =
@ -160,7 +160,7 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT)
if (FAILED(hr)) {
gfxWarning() << "Failed to QI texture to surface.";
return NULL;
return nullptr;
}
D2D1_RENDER_TARGET_PROPERTIES props =
@ -169,11 +169,11 @@ SourceSurfaceD2DTarget::GetBitmap(ID2D1RenderTarget *aRT)
if (FAILED(hr)) {
gfxWarning() << "Failed to create D2D render target for texture.";
return NULL;
return nullptr;
}
}
mBitmap->CopyFromRenderTarget(NULL, rt, NULL);
mBitmap->CopyFromRenderTarget(nullptr, rt, nullptr);
return mBitmap;
}
@ -185,8 +185,8 @@ SourceSurfaceD2DTarget::MarkIndependent()
{
if (mDrawTarget) {
MOZ_ASSERT(mDrawTarget->mSnapshot == this);
mDrawTarget->mSnapshot = NULL;
mDrawTarget = NULL;
mDrawTarget->mSnapshot = nullptr;
mDrawTarget = nullptr;
}
}

View File

@ -27,7 +27,7 @@ public:
virtual SurfaceFormat GetFormat() const { return mA->GetFormat(); }
/* Readback from this surface type is not supported! */
virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return NULL; }
virtual TemporaryRef<DataSourceSurface> GetDataSurface() { return nullptr; }
private:
friend class DualSurface;
friend class DualPattern;

View File

@ -15,7 +15,7 @@ namespace mozilla {
namespace gfx {
SourceSurfaceSkia::SourceSurfaceSkia()
: mDrawTarget(NULL)
: mDrawTarget(nullptr)
{
}
@ -90,7 +90,7 @@ void
SourceSurfaceSkia::DrawTargetWillChange()
{
if (mDrawTarget) {
mDrawTarget = NULL;
mDrawTarget = nullptr;
SkBitmap temp = mBitmap;
mBitmap.reset();
temp.copyTo(&mBitmap, temp.getConfig());
@ -100,7 +100,7 @@ SourceSurfaceSkia::DrawTargetWillChange()
void
SourceSurfaceSkia::DrawTargetDestroyed()
{
mDrawTarget = NULL;
mDrawTarget = nullptr;
}
void
@ -108,7 +108,7 @@ SourceSurfaceSkia::MarkIndependent()
{
if (mDrawTarget) {
mDrawTarget->RemoveSnapshot(this);
mDrawTarget = NULL;
mDrawTarget = nullptr;
}
}

View File

@ -34,7 +34,7 @@ public:
SurfaceFormat aFormat);
/**
* If aOwner is NULL, we make a copy of the pixel data in the bitmap,
* If aOwner is nullptr, we make a copy of the pixel data in the bitmap,
* otherwise we just reference this data until DrawTargetWillChange is called.
*/
bool InitWithBitmap(const SkBitmap& aBitmap,

View File

@ -6,6 +6,23 @@
#ifndef MOZILLA_GFX_TYPES_H_
#define MOZILLA_GFX_TYPES_H_
/**
* Use C++11 nullptr if available; otherwise use a C++ typesafe template; and
* for C, fall back to longs. See bugs 547964 and 626472.
* Copy and paste job from nscore.h, see bug 781943
*/
#if defined(MOZ_GFX) && !defined(HAVE_NULLPTR)
#ifndef __cplusplus
# define nullptr ((void*)0)
#elif defined(__GNUC__)
# define nullptr __null
#elif defined(_WIN64)
# define nullptr 0LL
#else
# define nullptr 0L
#endif
#endif /* defined(MOZ_GFX) && !defined(HAVE_NULLPTR) */
#include "mozilla/StandardInteger.h"
#include <stddef.h>

View File

@ -7,6 +7,7 @@
#define MOZILLA_GFX_USERDATA_H_
#include <stdlib.h>
#include "Types.h"
#include "mozilla/Assertions.h"
namespace mozilla {
@ -21,7 +22,7 @@ class UserData
{
typedef void (*destroyFunc)(void *data);
public:
UserData() : count(0), entries(NULL) {}
UserData() : count(0), entries(nullptr) {}
/* Attaches untyped userData associated with key. destroy is called on destruction */
void Add(UserDataKey *key, void *userData, destroyFunc destroy)
@ -68,7 +69,7 @@ public:
return userData;
}
}
return NULL;
return nullptr;
}
/* Retrives the userData for the associated key */
@ -79,7 +80,7 @@ public:
return entries[i].userData;
}
}
return NULL;
return nullptr;
}
bool Has(UserDataKey *key)
@ -100,7 +101,7 @@ public:
}
}
free(entries);
entries = NULL;
entries = nullptr;
count = 0;
}

View File

@ -8,9 +8,9 @@
using namespace mozilla::gfx;
TestDrawTargetD2D::TestDrawTargetD2D()
{
::D3D10CreateDevice1(NULL,
::D3D10CreateDevice1(nullptr,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
nullptr,
D3D10_CREATE_DEVICE_BGRA_SUPPORT |
D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
D3D10_FEATURE_LEVEL_10_0,

View File

@ -16,4 +16,4 @@ public:
private:
mozilla::RefPtr<ID3D10Device1> mDevice;
};
};

View File

@ -139,7 +139,11 @@ class THEBES_API LayerManager {
NS_INLINE_DECL_REFCOUNTING(LayerManager)
public:
LayerManager() : mDestroyed(false), mSnapEffectiveTransforms(true), mId(0)
LayerManager()
: mDestroyed(false)
, mSnapEffectiveTransforms(true)
, mId(0)
, mInTransaction(false)
{
InitLog();
}
@ -455,6 +459,8 @@ public:
virtual bool IsCompositingCheap() { return true; }
bool IsInTransaction() const { return mInTransaction; }
protected:
nsRefPtr<Layer> mRoot;
gfx::UserData mUserData;
@ -468,6 +474,7 @@ protected:
static void InitLog();
static PRLogModuleInfo* sLog;
uint64_t mId;
bool mInTransaction;
private:
TimeStamp mLastFrameTime;
nsTArray<float> mFrameTimes;

View File

@ -152,6 +152,7 @@ BasicLayerManager::SetDefaultTargetConfiguration(BufferMode aDoubleBuffering, Sc
void
BasicLayerManager::BeginTransaction()
{
mInTransaction = true;
mUsingDefaultTarget = true;
BeginTransactionWithTarget(mDefaultTarget);
}
@ -204,6 +205,8 @@ BasicLayerManager::PopGroupToSourceWithCachedSurface(gfxContext *aTarget, gfxCon
void
BasicLayerManager::BeginTransactionWithTarget(gfxContext* aTarget)
{
mInTransaction = true;
#ifdef MOZ_LAYERS_HAVE_LOG
MOZ_LAYERS_LOG(("[----- BeginTransaction"));
Log();
@ -390,6 +393,8 @@ BasicLayerManager::EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags)
{
mInTransaction = false;
EndTransactionInternal(aCallback, aCallbackData, aFlags);
}
@ -401,6 +406,7 @@ BasicLayerManager::AbortTransaction()
mPhase = PHASE_NONE;
#endif
mUsingDefaultTarget = false;
mInTransaction = false;
}
bool
@ -529,6 +535,8 @@ BasicLayerManager::FlashWidgetUpdateArea(gfxContext *aContext)
bool
BasicLayerManager::EndEmptyTransaction(EndTransactionFlags aFlags)
{
mInTransaction = false;
if (!mRoot) {
return false;
}

View File

@ -322,6 +322,8 @@ LayerManagerD3D10::SetRoot(Layer *aRoot)
void
LayerManagerD3D10::BeginTransaction()
{
mInTransaction = true;
#ifdef MOZ_LAYERS_HAVE_LOG
MOZ_LAYERS_LOG(("[----- BeginTransaction"));
Log();
@ -331,12 +333,15 @@ LayerManagerD3D10::BeginTransaction()
void
LayerManagerD3D10::BeginTransactionWithTarget(gfxContext* aTarget)
{
mInTransaction = true;
mTarget = aTarget;
}
bool
LayerManagerD3D10::EndEmptyTransaction(EndTransactionFlags aFlags)
{
mInTransaction = false;
if (!mRoot)
return false;
@ -349,6 +354,8 @@ LayerManagerD3D10::EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags)
{
mInTransaction = false;
if (mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
mCurrentCallbackInfo.Callback = aCallback;
mCurrentCallbackInfo.CallbackData = aCallbackData;

View File

@ -107,11 +107,13 @@ LayerManagerD3D9::Destroy()
void
LayerManagerD3D9::BeginTransaction()
{
mInTransaction = true;
}
void
LayerManagerD3D9::BeginTransactionWithTarget(gfxContext *aTarget)
{
mInTransaction = true;
mTarget = aTarget;
}
@ -123,6 +125,8 @@ LayerManagerD3D9::EndConstruction()
bool
LayerManagerD3D9::EndEmptyTransaction(EndTransactionFlags aFlags)
{
mInTransaction = false;
// If the device reset count from our last EndTransaction doesn't match
// the current device reset count, the device must have been reset one or
// more times since our last transaction. In that case, an empty transaction
@ -139,6 +143,8 @@ LayerManagerD3D9::EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags)
{
mInTransaction = false;
mDeviceResetCount = mDeviceManager->GetDeviceResetCount();
if (mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {

View File

@ -361,11 +361,14 @@ LayerManagerOGL::SetClippingRegion(const nsIntRegion& aClippingRegion)
void
LayerManagerOGL::BeginTransaction()
{
mInTransaction = true;
}
void
LayerManagerOGL::BeginTransactionWithTarget(gfxContext *aTarget)
{
mInTransaction = true;
#ifdef MOZ_LAYERS_HAVE_LOG
MOZ_LAYERS_LOG(("[----- BeginTransaction"));
Log();
@ -382,6 +385,8 @@ LayerManagerOGL::BeginTransactionWithTarget(gfxContext *aTarget)
bool
LayerManagerOGL::EndEmptyTransaction(EndTransactionFlags aFlags)
{
mInTransaction = false;
if (!mRoot)
return false;
@ -394,6 +399,8 @@ LayerManagerOGL::EndTransaction(DrawThebesLayerCallback aCallback,
void* aCallbackData,
EndTransactionFlags aFlags)
{
mInTransaction = false;
#ifdef MOZ_LAYERS_HAVE_LOG
MOZ_LAYERS_LOG((" ----- (beginning paint)"));
Log();

View File

@ -231,7 +231,7 @@ CPPSRCS = \
SkMaskFilter.cpp \
SkMath.cpp \
SkMatrix.cpp \
SkMemory_malloc.cpp \
SkMemory_mozalloc.cpp \
SkMetaData.cpp \
SkMorphologyImageFilter.cpp \
SkOrderedReadBuffer.cpp \

View File

@ -35,6 +35,16 @@
commented out, so including it will have no effect.
*/
/*
Override new/delete with Mozilla's allocator, mozalloc
Ideally we shouldn't need to do this here, but until
http://code.google.com/p/skia/issues/detail?id=598 is fixed
we need to include this here to override operator new and delete
*/
#include "mozilla/mozalloc.h"
///////////////////////////////////////////////////////////////////////////////
/* Scalars (the fractional value type in skia) can be implemented either as

View File

@ -0,0 +1,40 @@
/*
* Copyright 2011 Google Inc.
* Copyright 2012 Mozilla Foundation
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkTypes.h"
#include "mozilla/mozalloc.h"
#include "mozilla/mozalloc_abort.h"
#include "mozilla/mozalloc_oom.h"
void sk_throw() {
SkDEBUGFAIL("sk_throw");
mozalloc_abort("Abort from sk_throw");
}
void sk_out_of_memory(void) {
SkDEBUGFAIL("sk_out_of_memory");
mozalloc_handle_oom(0);
}
void* sk_malloc_throw(size_t size) {
return sk_malloc_flags(size, SK_MALLOC_THROW);
}
void* sk_realloc_throw(void* addr, size_t size) {
return moz_xrealloc(addr, size);
}
void sk_free(void* p) {
moz_free(p);
}
void* sk_malloc_flags(size_t size, unsigned flags) {
return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : moz_malloc(size);
}

View File

@ -86,7 +86,7 @@ void PlatformThread::SetName(const char* name) {
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
pthread_set_name_np(pthread_self(), name);
#elif defined(__NetBSD__)
pthread_setname_np(pthread_self(), "%s", name);
pthread_setname_np(pthread_self(), "%s", (void *)name);
#else
prctl(PR_SET_NAME, reinterpret_cast<uintptr_t>(name), 0, 0, 0);
#endif

View File

@ -0,0 +1,65 @@
/* 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 "FileDescriptor.h"
#include "mozilla/Assertions.h"
#include "nsDebug.h"
#ifdef XP_WIN
#include <windows.h>
#define INVALID_HANDLE INVALID_HANDLE_VALUE
#else
#include <unistd.h>
#define INVALID_HANDLE -1
#endif
using mozilla::ipc::FileDescriptor;
FileDescriptor::FileDescriptor()
: mHandle(INVALID_HANDLE)
{ }
FileDescriptor::PickleType
FileDescriptor::ShareTo(const FileDescriptor::IPDLPrivate&,
FileDescriptor::ProcessHandle aOtherProcess) const
{
#ifdef XP_WIN
if (mHandle == INVALID_HANDLE) {
return INVALID_HANDLE;
}
PlatformHandleType newHandle;
if (!DuplicateHandle(GetCurrentProcess(), mHandle, aOtherProcess, &newHandle,
0, FALSE, DUPLICATE_SAME_ACCESS)) {
NS_WARNING("Failed to duplicate file handle!");
return INVALID_HANDLE;
}
return newHandle;
#else // XP_WIN
if (mHandle == INVALID_HANDLE) {
return base::FileDescriptor();
}
PlatformHandleType newHandle = dup(mHandle);
if (newHandle < 0) {
NS_WARNING("Failed to duplicate file descriptor!");
return base::FileDescriptor();
}
// This file descriptor must be closed once the caller is done using it, so
// pass true here for the 'auto_close' argument.
return base::FileDescriptor(newHandle, true);
#endif
MOZ_NOT_REACHED("Must not get here!");
return PickleType();
}
bool
FileDescriptor::IsValid() const
{
return mHandle != INVALID_HANDLE;
}

95
ipc/glue/FileDescriptor.h Normal file
View File

@ -0,0 +1,95 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ipc_FileDescriptor_h
#define mozilla_ipc_FileDescriptor_h
#include "base/basictypes.h"
#include "base/process.h"
#include "nscore.h"
#ifdef XP_WIN
// Need the HANDLE typedef.
#include <winnt.h>
#else
#include "base/file_descriptor_posix.h"
#endif
namespace mozilla {
namespace ipc {
// This class is used by IPDL to share file descriptors across processes. When
// sending a FileDescriptor IPDL will first duplicate a platform-specific file
// handle type ('PlatformHandleType') into a handle that is valid in the other
// process. Then IPDL will convert the duplicated handle into a type suitable
// for pickling ('PickleType') and then send that through the IPC pipe. In the
// receiving process the pickled data is converted into a platform-specific file
// handle and then returned to the receiver.
//
// To use this class add 'FileDescriptor' as an argument in the IPDL protocol
// and then pass a file descriptor from C++ to the Call/Send method. The
// Answer/Recv method will receive a FileDescriptor& on which PlatformHandle()
// can be called to return the platform file handle.
class FileDescriptor
{
public:
typedef base::ProcessHandle ProcessHandle;
#ifdef XP_WIN
typedef HANDLE PlatformHandleType;
typedef HANDLE PickleType;
#else
typedef int PlatformHandleType;
typedef base::FileDescriptor PickleType;
#endif
// This should only ever be created by IPDL.
struct IPDLPrivate
{};
FileDescriptor();
FileDescriptor(PlatformHandleType aHandle)
: mHandle(aHandle)
{ }
FileDescriptor(const IPDLPrivate&, const PickleType& aPickle)
#ifdef XP_WIN
: mHandle(aPickle)
#else
: mHandle(aPickle.fd)
#endif
{ }
// Performs platform-specific actions to duplicate mHandle in the other
// process (e.g. dup() on POSIX, DuplicateHandle() on Windows). Returns a
// pickled value that can be passed to the other process via IPC.
PickleType
ShareTo(const IPDLPrivate&, ProcessHandle aOtherProcess) const;
// Tests mHandle against a well-known invalid platform-specific file handle
// (e.g. -1 on POSIX, INVALID_HANDLE_VALUE on Windows).
bool
IsValid() const;
PlatformHandleType
PlatformHandle() const
{
return mHandle;
}
bool
operator==(const FileDescriptor& aOther) const
{
return mHandle == aOther.mHandle;
}
private:
PlatformHandleType mHandle;
};
} // namespace ipc
} // namespace mozilla
#endif // mozilla_ipc_FileDescriptor_h

View File

@ -0,0 +1,44 @@
/* 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/. */
namespace mozilla {
namespace ipc {
struct StringInputStreamParams
{
nsCString data;
};
struct FileInputStreamParams
{
FileDescriptor file;
int32_t behaviorFlags;
int32_t ioFlags;
};
struct PartialFileInputStreamParams
{
FileInputStreamParams fileStreamParams;
uint64_t begin;
uint64_t length;
};
struct MultiplexInputStreamParams
{
InputStreamParams[] streams;
uint32_t currentStream;
nsresult status;
bool startedReadingCurrent;
};
union InputStreamParams
{
StringInputStreamParams;
FileInputStreamParams;
PartialFileInputStreamParams;
MultiplexInputStreamParams;
};
} // namespace ipc
} // namespace mozilla

View File

@ -0,0 +1,79 @@
/* 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 "InputStreamUtils.h"
#include "nsIIPCSerializableInputStream.h"
#include "mozilla/Assertions.h"
#include "nsComponentManagerUtils.h"
#include "nsDebug.h"
#include "nsID.h"
#include "nsMultiplexInputStream.h"
#include "nsNetCID.h"
#include "nsStringStream.h"
#include "nsThreadUtils.h"
using namespace mozilla::ipc;
namespace {
NS_DEFINE_CID(kStringInputStreamCID, NS_STRINGINPUTSTREAM_CID);
NS_DEFINE_CID(kFileInputStreamCID, NS_LOCALFILEINPUTSTREAM_CID);
NS_DEFINE_CID(kPartialFileInputStreamCID, NS_PARTIALLOCALFILEINPUTSTREAM_CID);
NS_DEFINE_CID(kMultiplexInputStreamCID, NS_MULTIPLEXINPUTSTREAM_CID);
} // anonymous namespace
namespace mozilla {
namespace ipc {
already_AddRefed<nsIInputStream>
DeserializeInputStream(const InputStreamParams& aParams)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIIPCSerializableInputStream> serializable;
switch (aParams.type()) {
case InputStreamParams::T__None:
NS_WARNING("This union has no type!");
return nullptr;
case InputStreamParams::TStringInputStreamParams:
serializable = do_CreateInstance(kStringInputStreamCID);
break;
case InputStreamParams::TFileInputStreamParams:
serializable = do_CreateInstance(kFileInputStreamCID);
break;
case InputStreamParams::TPartialFileInputStreamParams:
serializable = do_CreateInstance(kPartialFileInputStreamCID);
break;
case InputStreamParams::TMultiplexInputStreamParams:
serializable = do_CreateInstance(kMultiplexInputStreamCID);
break;
default:
NS_WARNING("Unknown params!");
return nullptr;
}
MOZ_ASSERT(serializable);
if (!serializable->Deserialize(aParams)) {
NS_WARNING("Deserialize failed!");
return nullptr;
}
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(serializable);
MOZ_ASSERT(stream);
return stream.forget();
}
} // namespace ipc
} // namespace mozilla

View File

@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ipc_InputStreamUtils_h
#define mozilla_ipc_InputStreamUtils_h
#include "mozilla/ipc/IPCSerializableParams.h"
#include "nsCOMPtr.h"
#include "nsIInputStream.h"
namespace mozilla {
namespace ipc {
already_AddRefed<nsIInputStream>
DeserializeInputStream(const InputStreamParams& aParams);
} // namespace ipc
} // namespace mozilla
#endif // mozilla_ipc_InputStreamUtils_h

View File

@ -25,7 +25,9 @@ EXPORTS_mozilla/ipc = \
AsyncChannel.h \
BrowserProcessSubThread.h \
CrossProcessMutex.h \
FileDescriptor.h \
GeckoChildProcessHost.h \
InputStreamUtils.h \
IOThreadChild.h \
ProcessChild.h \
ProtocolUtils.h \
@ -40,6 +42,8 @@ EXPORTS_mozilla/ipc = \
Transport.h \
$(NULL)
EXPORTS = nsIIPCSerializableInputStream.h
ifeq ($(OS_ARCH),WINNT) #{
EXPORTS_mozilla/ipc += \
Transport_win.h \
@ -63,7 +67,9 @@ endif #}
CPPSRCS += \
AsyncChannel.cpp \
BrowserProcessSubThread.cpp \
FileDescriptor.cpp \
GeckoChildProcessHost.cpp \
InputStreamUtils.cpp \
MessagePump.cpp \
ProcessChild.cpp \
ProtocolUtils.cpp \

View File

@ -15,6 +15,7 @@
#include "prenv.h"
#include "IPCMessageStart.h"
#include "mozilla/ipc/FileDescriptor.h"
#include "mozilla/ipc/Shmem.h"
#include "mozilla/ipc/Transport.h"

5
ipc/glue/ipdl.mk Normal file
View File

@ -0,0 +1,5 @@
# 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/.
IPDLSRCS = IPCSerializableParams.ipdlh

View File

@ -0,0 +1,57 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ipc_nsIIPCSerializableInputStream_h
#define mozilla_ipc_nsIIPCSerializableInputStream_h
#include "nsISupports.h"
#include "mozilla/Attributes.h"
namespace mozilla {
namespace ipc {
class InputStreamParams;
}
}
#define NS_IIPCSERIALIZABLEINPUTSTREAM_IID \
{0x1f56a3f8, 0xc413, 0x4274, {0x88, 0xe6, 0x68, 0x50, 0x9d, 0xf8, 0x85, 0x2d}}
class NS_NO_VTABLE nsIIPCSerializableInputStream : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
virtual void
Serialize(mozilla::ipc::InputStreamParams& aParams) = 0;
virtual bool
Deserialize(const mozilla::ipc::InputStreamParams& aParams) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIIPCSerializableInputStream,
NS_IIPCSERIALIZABLEINPUTSTREAM_IID)
#define NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM \
virtual void \
Serialize(mozilla::ipc::InputStreamParams&) MOZ_OVERRIDE; \
virtual bool \
Deserialize(const mozilla::ipc::InputStreamParams&) MOZ_OVERRIDE;
#define NS_FORWARD_NSIIPCSERIALIZABLEINPUTSTREAM(_to) \
virtual void \
Serialize(mozilla::ipc::InputStreamParams& aParams) MOZ_OVERRIDE \
{ _to Serialize(aParams); } \
virtual bool \
Deserialize(const mozilla::ipc::InputStreamParams& aParams) MOZ_OVERRIDE \
{ return _to Deserialize(aParams); }
#define NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(_to) \
virtual void \
Serialize(mozilla::ipc::InputStreamParams& aParams) MOZ_OVERRIDE \
{ if (_to) { _to->Serialize(aParams); } } \
virtual bool \
Deserialize(const mozilla::ipc::InputStreamParams& aParams) MOZ_OVERRIDE \
{ if (_to) { return _to->Deserialize(aParams); } return false; }
#endif // mozilla_ipc_nsIIPCSerializableInputStream_h

View File

@ -32,6 +32,7 @@ IPDLDIRS = \
dom/src/storage \
gfx/layers/ipc \
hal/sandbox \
ipc/glue \
ipc/testshell \
js/ipc \
layout/ipc \

View File

@ -48,6 +48,7 @@ Types = (
'nsString',
'nsCString',
'mozilla::ipc::Shmem',
'mozilla::ipc::FileDescriptor',
# quasi-stdint types used by "public" Gecko headers
'int8',

View File

@ -233,7 +233,6 @@ def _shmemRevokeRights(shmemexpr):
def _lookupShmem(idexpr):
return ExprCall(ExprVar('LookupSharedMemory'), args=[ idexpr ])
def _makeForwardDeclForQClass(clsname, quals):
fd = ForwardDecl(clsname, cls=1)
if 0 == len(quals):
@ -492,6 +491,9 @@ class _ConvertToCxxType(TypeVisitor):
def visitShmemType(self, s):
return Type(self.typename(s))
def visitFDType(self, s):
return Type(self.typename(s))
def visitProtocolType(self, p): assert 0
def visitMessageType(self, m): assert 0
def visitVoidType(self, v): assert 0
@ -668,6 +670,8 @@ class _StructField(_CompoundTypeComponent):
refexpr = self.refExpr(thisexpr)
if 'Shmem' == self.ipdltype.name():
refexpr = ExprCast(refexpr, Type('Shmem', ref=1), const=1)
if 'FileDescriptor' == self.ipdltype.name():
refexpr = ExprCast(refexpr, Type('FileDescriptor', ref=1), const=1)
return refexpr
def argVar(self):
@ -826,6 +830,8 @@ IPDL union type."""
# sigh
if 'Shmem' == self.ipdltype.name():
v = ExprCast(v, Type('Shmem', ref=1), const=1)
if 'FileDescriptor' == self.ipdltype.name():
v = ExprCast(v, Type('FileDescriptor', ref=1), const=1)
return v
##--------------------------------------------------
@ -990,7 +996,6 @@ def _subtreeUsesShmem(p):
return True
return False
class Protocol(ipdl.ast.Protocol):
def cxxTypedefs(self):
return self.decl.cxxtypedefs
@ -1867,6 +1872,11 @@ stmt. Some types generate both kinds.'''
self.visited.add(s)
self.maybeTypedef('mozilla::ipc::Shmem', 'Shmem')
def visitFDType(self, s):
if s in self.visited: return
self.visited.add(s)
self.maybeTypedef('mozilla::ipc::FileDescriptor', 'FileDescriptor')
def visitVoidType(self, v): assert 0
def visitMessageType(self, v): assert 0
def visitProtocolType(self, v): assert 0
@ -3379,11 +3389,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
p = self.protocol
routedvar = ExprVar('aRouted')
idvar = ExprVar('aId')
shmemvar = ExprVar('aShmem')
shmemvar = ExprVar('shmem')
rawvar = ExprVar('segment')
sizevar = ExprVar('aSize')
typevar = ExprVar('type')
unsafevar = ExprVar('unsafe')
typevar = ExprVar('aType')
unsafevar = ExprVar('aUnsafe')
listenertype = Type('ChannelListener', ptr=1)
register = MethodDefn(MethodDecl(
@ -3978,8 +3988,9 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
# pickling for IPDL types
specialtypes = set()
class findSpecialTypes(TypeVisitor):
def visitActorType(self, a): specialtypes.add(a)
def visitShmemType(self, s): specialtypes.add(s)
def visitActorType(self, a): specialtypes.add(a)
def visitShmemType(self, s): specialtypes.add(s)
def visitFDType(self, s): specialtypes.add(s)
def visitStructType(self, s):
specialtypes.add(s)
return TypeVisitor.visitStructType(self, s)
@ -4006,6 +4017,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
if t.isActor(): self.implementActorPickling(t)
elif t.isArray(): self.implementSpecialArrayPickling(t)
elif t.isShmem(): self.implementShmemPickling(t)
elif t.isFD(): self.implementFDPickling(t)
elif t.isStruct(): self.implementStructPickling(t)
elif t.isUnion(): self.implementUnionPickling(t)
else:
@ -4225,6 +4237,57 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
self.cls.addstmts([ write, Whitespace.NL, read, Whitespace.NL ])
def implementFDPickling(self, fdtype):
msgvar = self.msgvar
itervar = self.itervar
var = self.var
tmpvar = ExprVar('fd')
picklevar = ExprVar('pfd')
intype = _cxxConstRefType(fdtype, self.side)
outtype = _cxxPtrToType(fdtype, self.side)
def _fdType():
return Type('FileDescriptor')
def _fdPickleType():
return Type('FileDescriptor::PickleType')
def _fdBackstagePass():
return ExprCall(ExprVar('FileDescriptor::IPDLPrivate'))
write = MethodDefn(self.writeMethodDecl(intype, var))
write.addstmts([
StmtDecl(Decl(_fdPickleType(), picklevar.name),
init=ExprCall(ExprSelect(var, '.', 'ShareTo'),
args=[ _fdBackstagePass(),
self.protocol.callOtherProcess() ])),
StmtExpr(ExprCall(ExprVar('IPC::WriteParam'),
args=[ msgvar, picklevar ])),
])
read = MethodDefn(self.readMethodDecl(outtype, var))
ifread = StmtIf(ExprNot(ExprCall(ExprVar('IPC::ReadParam'),
args=[ msgvar, itervar,
ExprAddrOf(picklevar) ])))
ifread.addifstmt(StmtReturn.FALSE)
ifnvalid = StmtIf(ExprNot(ExprCall(ExprSelect(tmpvar, '.', 'IsValid'))))
ifnvalid.addifstmt(StmtReturn.FALSE)
read.addstmts([
StmtDecl(Decl(_fdPickleType(), picklevar.name)),
ifread,
Whitespace.NL,
StmtDecl(Decl(_fdType(), tmpvar.name),
init=ExprCall(ExprVar('FileDescriptor'),
args=[ _fdBackstagePass(), picklevar ])),
ifnvalid,
Whitespace.NL,
StmtExpr(ExprAssn(ExprDeref(var), tmpvar)),
StmtReturn.TRUE
])
self.cls.addstmts([ write, Whitespace.NL, read, Whitespace.NL ])
def implementStructPickling(self, structtype):
msgvar = self.msgvar

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