mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge mozilla-central to services-central.
This commit is contained in:
commit
de3a7ca3c3
@ -1334,9 +1334,9 @@
|
||||
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
|
||||
try {
|
||||
b.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset, aPostData);
|
||||
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
catch (ex) { }
|
||||
}
|
||||
|
||||
// We start our browsers out as inactive, and then maintain
|
||||
|
@ -18,12 +18,27 @@ function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
|
||||
run_test_1();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function run_test_1() {
|
||||
load("about:config", function() {
|
||||
let urls = [
|
||||
"about:config",
|
||||
"about:addons",
|
||||
"about:permissions"
|
||||
];
|
||||
|
||||
function nextTest() {
|
||||
let url = urls.shift();
|
||||
if (url) {
|
||||
testFindDisabled(url, nextTest);
|
||||
} else {
|
||||
// Make sure the find bar is re-enabled after disabled page is closed.
|
||||
testFindEnabled("about:blank", finish);
|
||||
}
|
||||
}
|
||||
|
||||
function testFindDisabled(url, cb) {
|
||||
load(url, function() {
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
@ -33,31 +48,16 @@ function run_test_1() {
|
||||
"Find command should be disabled");
|
||||
|
||||
gBrowser.removeTab(gTab);
|
||||
run_test_2();
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_2() {
|
||||
load("about:addons", function() {
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow);
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
EventUtils.synthesizeKey("f", { accelKey: true });
|
||||
ok(gFindBar.hidden, "Find bar should not be visible");
|
||||
ok(document.getElementById("cmd_find").getAttribute("disabled"),
|
||||
"Find command should be disabled");
|
||||
|
||||
gBrowser.removeTab(gTab);
|
||||
run_test_3();
|
||||
});
|
||||
}
|
||||
|
||||
function run_test_3() {
|
||||
load("about:blank", function() {
|
||||
function testFindEnabled(url, cb) {
|
||||
load(url, function() {
|
||||
ok(!document.getElementById("cmd_find").getAttribute("disabled"),
|
||||
"Find command should not be disabled");
|
||||
|
||||
gBrowser.removeTab(gTab);
|
||||
finish();
|
||||
cb();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -690,13 +690,8 @@ let AboutPermissions = {
|
||||
*/
|
||||
updatePermission: function(aType) {
|
||||
let allowItem = document.getElementById(aType + "-" + PermissionDefaults.ALLOW);
|
||||
if (!this._selectedSite &&
|
||||
this._noGlobalAllow.indexOf(aType) != -1) {
|
||||
allowItem.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
allowItem.hidden = false;
|
||||
allowItem.hidden = !this._selectedSite &&
|
||||
this._noGlobalAllow.indexOf(aType) != -1;
|
||||
|
||||
let permissionMenulist = document.getElementById(aType + "-menulist");
|
||||
let permissionValue;
|
||||
|
@ -52,6 +52,7 @@
|
||||
id="permissions-page" title="&permissionsManager.title;"
|
||||
onload="AboutPermissions.init();"
|
||||
onunload="AboutPermissions.cleanUp();"
|
||||
disablefastfind="true"
|
||||
role="application">
|
||||
|
||||
<script type="application/javascript"
|
||||
@ -163,7 +164,7 @@
|
||||
</menupopup>
|
||||
</menulist>
|
||||
<button id="cookies-clear-all-button"
|
||||
label="&cookie.clearAll;"
|
||||
label="&cookie.removeAll;"
|
||||
oncommand="Services.cookies.removeAll();"/>
|
||||
<button id="cookies-manage-all-button"
|
||||
label="&cookie.manage;"
|
||||
@ -172,7 +173,7 @@
|
||||
<hbox id="cookies-count" align="center">
|
||||
<label id="cookies-label"/>
|
||||
<button id="cookies-clear-button"
|
||||
label="&cookie.clear;"
|
||||
label="&cookie.remove;"
|
||||
oncommand="AboutPermissions.clearCookies();"/>
|
||||
<button id="cookies-manage-button"
|
||||
label="&cookie.manage;"
|
||||
|
@ -187,8 +187,8 @@
|
||||
<vbox id="historyCustomPane">
|
||||
<separator class="thin"/>
|
||||
<checkbox id="privateBrowsingAutoStart" class="indent"
|
||||
label="&privateBrowsingPermanent.label;"
|
||||
accesskey="&privateBrowsingPermanent.accesskey;"
|
||||
label="&privateBrowsingPermanent2.label;"
|
||||
accesskey="&privateBrowsingPermanent2.accesskey;"
|
||||
preference="browser.privatebrowsing.autostart"/>
|
||||
|
||||
<vbox class="indent">
|
||||
|
@ -25,6 +25,11 @@ const TEST_PERMS = {
|
||||
"popup": PERM_DENY
|
||||
};
|
||||
|
||||
const NO_GLOBAL_ALLOW = [
|
||||
"geo",
|
||||
"indexedDB"
|
||||
];
|
||||
|
||||
// number of managed permissions in the interface
|
||||
const TEST_PERMS_COUNT = 5;
|
||||
|
||||
@ -143,6 +148,12 @@ var tests = [
|
||||
ok(gBrowser.contentDocument.getElementById("cookies-count").hidden,
|
||||
"cookies count is hidden");
|
||||
|
||||
// Test to make sure "Allow" items hidden for certain permission types
|
||||
NO_GLOBAL_ALLOW.forEach(function(aType) {
|
||||
let menuitem = gBrowser.contentDocument.getElementById(aType + "-" + PERM_ALLOW);
|
||||
ok(menuitem.hidden, aType + " allow menuitem hidden for all sites");
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
},
|
||||
|
||||
@ -195,6 +206,12 @@ var tests = [
|
||||
ok(!gBrowser.contentDocument.getElementById("cookies-count").hidden,
|
||||
"cookies count is not hidden");
|
||||
|
||||
// Test to make sure "Allow" items are *not* hidden for certain permission types
|
||||
NO_GLOBAL_ALLOW.forEach(function(aType) {
|
||||
let menuitem = gBrowser.contentDocument.getElementById(aType + "-" + PERM_ALLOW);
|
||||
ok(!menuitem.hidden, aType + " allow menuitem not hidden for single site");
|
||||
});
|
||||
|
||||
runNextTest();
|
||||
},
|
||||
|
||||
|
@ -22,9 +22,9 @@
|
||||
<!ENTITY password.manage "Manage Passwords…">
|
||||
|
||||
<!ENTITY cookie.label "Set Cookies">
|
||||
<!ENTITY cookie.clear "Clear Cookies">
|
||||
<!ENTITY cookie.remove "Remove Cookies">
|
||||
<!ENTITY cookie.manage "Manage Cookies…">
|
||||
<!ENTITY cookie.clearAll "Clear All Cookies">
|
||||
<!ENTITY cookie.removeAll "Remove All Cookies">
|
||||
|
||||
<!ENTITY geo.label "Share Location">
|
||||
|
||||
|
@ -61,8 +61,8 @@
|
||||
<!ENTITY dontrememberActions.clearHistory.label "clear all current history">
|
||||
<!ENTITY dontrememberActions.post.label ".">
|
||||
|
||||
<!ENTITY privateBrowsingPermanent.label "Permanent Private Browsing mode">
|
||||
<!ENTITY privateBrowsingPermanent.accesskey "P">
|
||||
<!ENTITY privateBrowsingPermanent2.label "Always use private browsing mode">
|
||||
<!ENTITY privateBrowsingPermanent2.accesskey "p">
|
||||
|
||||
<!ENTITY rememberHistory.label "Remember my browsing history">
|
||||
<!ENTITY rememberHistory.accesskey "b">
|
||||
|
16
configure.in
16
configure.in
@ -4298,29 +4298,29 @@ dnl See if compiler supports some gcc-style attributes
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((always_inline)),
|
||||
ac_cv_attribute_always_inline,
|
||||
[AC_TRY_COMPILE([],
|
||||
[inline void f(void) __attribute__((always_inline));],
|
||||
[AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
|
||||
[],
|
||||
ac_cv_attribute_always_inline=yes,
|
||||
ac_cv_attribute_always_inline=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((malloc)),
|
||||
ac_cv_attribute_malloc,
|
||||
[AC_TRY_COMPILE([],
|
||||
[void* f(int) __attribute__((malloc));],
|
||||
[AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
|
||||
[],
|
||||
ac_cv_attribute_malloc=yes,
|
||||
ac_cv_attribute_malloc=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
|
||||
ac_cv_attribute_warn_unused,
|
||||
[AC_TRY_COMPILE([],
|
||||
[int f(void) __attribute__((warn_unused_result));],
|
||||
[AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
|
||||
[],
|
||||
ac_cv_attribute_warn_unused=yes,
|
||||
ac_cv_attribute_warn_unused=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((noreturn)),
|
||||
ac_cv_attribute_noreturn,
|
||||
[AC_TRY_COMPILE([],
|
||||
[void f(void) __attribute__((noreturn));],
|
||||
[AC_TRY_COMPILE([void f(void) __attribute__((noreturn));],
|
||||
[],
|
||||
ac_cv_attribute_noreturn=yes,
|
||||
ac_cv_attribute_noreturn=no)])
|
||||
|
||||
|
@ -64,7 +64,6 @@ void ParseSize(PRInt64 aSize, PRInt64& aStart, PRInt64& aEnd);
|
||||
|
||||
class nsDOMFile : public nsIDOMFile,
|
||||
public nsIXHRSendable,
|
||||
public nsICharsetDetectionObserver,
|
||||
public nsIJSNativeInitializer
|
||||
{
|
||||
public:
|
||||
@ -100,9 +99,6 @@ public:
|
||||
|
||||
virtual ~nsDOMFile() {}
|
||||
|
||||
// from nsICharsetDetectionObserver
|
||||
NS_IMETHOD Notify(const char *aCharset, nsDetectionConfident aConf);
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
@ -124,13 +120,6 @@ protected:
|
||||
nsString mContentType;
|
||||
|
||||
bool mIsFullFile;
|
||||
|
||||
// Used during charset detection
|
||||
nsCString mCharset;
|
||||
nsresult GuessCharset(nsIInputStream *aStream,
|
||||
nsACString &aCharset);
|
||||
nsresult ConvertStream(nsIInputStream *aStream, const char *aCharset,
|
||||
nsAString &aResult);
|
||||
};
|
||||
|
||||
class nsDOMMemoryFile : public nsDOMFile
|
||||
|
@ -63,7 +63,7 @@ interface nsIDOMBlob : nsISupports
|
||||
[optional] in DOMString contentType);
|
||||
};
|
||||
|
||||
[scriptable, uuid(91c9ebd9-2a4a-4a38-9412-ef492a2799be)]
|
||||
[scriptable, uuid(b096ef67-7b77-47f8-8e70-5d8ee36416bf)]
|
||||
interface nsIDOMFile : nsIDOMBlob
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
@ -71,14 +71,6 @@ interface nsIDOMFile : nsIDOMBlob
|
||||
|
||||
// This performs no security checks!
|
||||
[noscript] readonly attribute DOMString mozFullPathInternal;
|
||||
|
||||
// These are all deprecated and not in spec. Will be removed in a future
|
||||
// release
|
||||
readonly attribute DOMString fileName;
|
||||
readonly attribute unsigned long long fileSize;
|
||||
DOMString getAsText(in DOMString encoding); // raises(FileException) on retrieval
|
||||
DOMString getAsDataURL(); // raises(FileException) on retrieval
|
||||
DOMString getAsBinary(); // raises(FileException) on retrieval
|
||||
};
|
||||
|
||||
[scriptable, uuid(c4a77171-039b-4f84-97f9-820fb51626af)]
|
||||
|
@ -142,7 +142,6 @@ NS_INTERFACE_MAP_BEGIN(nsDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, mIsFullFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICharsetDetectionObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, mIsFullFile)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !mIsFullFile)
|
||||
@ -173,18 +172,6 @@ nsDOMFile::NewFile(nsISupports* *aNewObject)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetFileName(nsAString &aFileName)
|
||||
{
|
||||
return GetName(aFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetFileSize(PRUint64 *aFileSize)
|
||||
{
|
||||
return GetSize(aFileSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetName(nsAString &aFileName)
|
||||
{
|
||||
@ -358,231 +345,6 @@ nsDOMFile::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetAsText(const nsAString &aCharset, nsAString &aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = GetInternalStream(getter_AddRefs(stream));
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
|
||||
nsCAutoString charsetGuess;
|
||||
if (!aCharset.IsEmpty()) {
|
||||
CopyUTF16toUTF8(aCharset, charsetGuess);
|
||||
} else {
|
||||
rv = GuessCharset(stream, charsetGuess);
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(stream);
|
||||
if (!seekable) return NS_ERROR_FAILURE;
|
||||
rv = seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
}
|
||||
|
||||
nsCAutoString charset;
|
||||
nsCOMPtr<nsICharsetAlias> alias =
|
||||
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = alias->GetPreferred(charsetGuess, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return DOMFileResult(ConvertStream(stream, charset.get(), aResult));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetAsDataURL(nsAString &aResult)
|
||||
{
|
||||
aResult.AssignLiteral("data:");
|
||||
|
||||
nsresult rv;
|
||||
if (!mContentType.Length()) {
|
||||
nsCOMPtr<nsIMIMEService> mimeService =
|
||||
do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString contentType;
|
||||
rv = mimeService->GetTypeFromFile(mFile, contentType);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
CopyUTF8toUTF16(contentType, mContentType);
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentType.Length()) {
|
||||
aResult.Append(mContentType);
|
||||
} else {
|
||||
aResult.AppendLiteral("application/octet-stream");
|
||||
}
|
||||
aResult.AppendLiteral(";base64,");
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
rv = GetInternalStream(getter_AddRefs(stream));
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
|
||||
char readBuf[4096];
|
||||
PRUint32 leftOver = 0;
|
||||
PRUint32 numRead;
|
||||
do {
|
||||
rv = stream->Read(readBuf + leftOver, sizeof(readBuf) - leftOver, &numRead);
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
|
||||
PRUint32 numEncode = numRead + leftOver;
|
||||
leftOver = 0;
|
||||
|
||||
if (numEncode == 0) break;
|
||||
|
||||
// unless this is the end of the file, encode in multiples of 3
|
||||
if (numRead > 0) {
|
||||
leftOver = numEncode % 3;
|
||||
numEncode -= leftOver;
|
||||
}
|
||||
|
||||
// out buffer should be at least 4/3rds the read buf, plus a terminator
|
||||
char *base64 = PL_Base64Encode(readBuf, numEncode, nsnull);
|
||||
if (!base64) {
|
||||
return DOMFileResult(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
nsDependentCString str(base64);
|
||||
PRUint32 strLen = str.Length();
|
||||
PRUint32 oldLength = aResult.Length();
|
||||
AppendASCIItoUTF16(str, aResult);
|
||||
PR_Free(base64);
|
||||
if (aResult.Length() - oldLength != strLen) {
|
||||
return DOMFileResult(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
if (leftOver) {
|
||||
memmove(readBuf, readBuf + numEncode, leftOver);
|
||||
}
|
||||
} while (numRead > 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetAsBinary(nsAString &aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream;
|
||||
nsresult rv = GetInternalStream(getter_AddRefs(stream));
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
|
||||
PRUint32 numRead;
|
||||
do {
|
||||
char readBuf[4096];
|
||||
rv = stream->Read(readBuf, sizeof(readBuf), &numRead);
|
||||
NS_ENSURE_SUCCESS(rv, DOMFileResult(rv));
|
||||
PRUint32 oldLength = aResult.Length();
|
||||
AppendASCIItoUTF16(Substring(readBuf, readBuf + numRead), aResult);
|
||||
if (aResult.Length() - oldLength != numRead) {
|
||||
return DOMFileResult(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
} while (numRead > 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMFile::GuessCharset(nsIInputStream *aStream,
|
||||
nsACString &aCharset)
|
||||
{
|
||||
|
||||
if (!mCharset.IsEmpty()) {
|
||||
aCharset = mCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// First try the universal charset detector
|
||||
nsCOMPtr<nsICharsetDetector> detector
|
||||
= do_CreateInstance(NS_CHARSET_DETECTOR_CONTRACTID_BASE
|
||||
"universal_charset_detector");
|
||||
if (!detector) {
|
||||
// No universal charset detector, try the default charset detector
|
||||
const nsAdoptingCString& detectorName =
|
||||
Preferences::GetLocalizedCString("intl.charset.detector");
|
||||
if (!detectorName.IsEmpty()) {
|
||||
nsCAutoString detectorContractID;
|
||||
detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE);
|
||||
detectorContractID += detectorName;
|
||||
detector = do_CreateInstance(detectorContractID.get());
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
if (detector) {
|
||||
detector->Init(this);
|
||||
|
||||
PRBool done;
|
||||
PRUint32 numRead;
|
||||
do {
|
||||
char readBuf[4096];
|
||||
rv = aStream->Read(readBuf, sizeof(readBuf), &numRead);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = detector->DoIt(readBuf, numRead, &done);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} while (!done && numRead > 0);
|
||||
|
||||
rv = detector->Done();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
// no charset detector available, check the BOM
|
||||
unsigned char sniffBuf[4];
|
||||
PRUint32 numRead;
|
||||
rv = aStream->Read(reinterpret_cast<char*>(sniffBuf),
|
||||
sizeof(sniffBuf), &numRead);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (numRead >= 4 &&
|
||||
sniffBuf[0] == 0x00 &&
|
||||
sniffBuf[1] == 0x00 &&
|
||||
sniffBuf[2] == 0xfe &&
|
||||
sniffBuf[3] == 0xff) {
|
||||
mCharset = "UTF-32BE";
|
||||
} else if (numRead >= 4 &&
|
||||
sniffBuf[0] == 0xff &&
|
||||
sniffBuf[1] == 0xfe &&
|
||||
sniffBuf[2] == 0x00 &&
|
||||
sniffBuf[3] == 0x00) {
|
||||
mCharset = "UTF-32LE";
|
||||
} else if (numRead >= 2 &&
|
||||
sniffBuf[0] == 0xfe &&
|
||||
sniffBuf[1] == 0xff) {
|
||||
mCharset = "UTF-16BE";
|
||||
} else if (numRead >= 2 &&
|
||||
sniffBuf[0] == 0xff &&
|
||||
sniffBuf[1] == 0xfe) {
|
||||
mCharset = "UTF-16LE";
|
||||
} else if (numRead >= 3 &&
|
||||
sniffBuf[0] == 0xef &&
|
||||
sniffBuf[1] == 0xbb &&
|
||||
sniffBuf[2] == 0xbf) {
|
||||
mCharset = "UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
if (mCharset.IsEmpty()) {
|
||||
// no charset detected, default to the system charset
|
||||
nsCOMPtr<nsIPlatformCharset> platformCharset =
|
||||
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = platformCharset->GetCharset(kPlatformCharsetSel_PlainTextInFile,
|
||||
mCharset);
|
||||
}
|
||||
}
|
||||
|
||||
if (mCharset.IsEmpty()) {
|
||||
// no sniffed or default charset, try UTF-8
|
||||
mCharset.AssignLiteral("UTF-8");
|
||||
}
|
||||
|
||||
aCharset = mCharset;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::GetSendInfo(nsIInputStream** aBody,
|
||||
nsACString& aContentType,
|
||||
@ -606,14 +368,6 @@ nsDOMFile::GetSendInfo(nsIInputStream** aBody,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::Notify(const char* aCharset, nsDetectionConfident aConf)
|
||||
{
|
||||
mCharset.Assign(aCharset);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFile::Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
@ -674,42 +428,6 @@ nsDOMFile::Initialize(nsISupports* aOwner,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMFile::ConvertStream(nsIInputStream *aStream,
|
||||
const char *aCharset,
|
||||
nsAString &aResult)
|
||||
{
|
||||
aResult.Truncate();
|
||||
|
||||
nsCOMPtr<nsIConverterInputStream> converterStream =
|
||||
do_CreateInstance("@mozilla.org/intl/converter-input-stream;1");
|
||||
if (!converterStream) return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv = converterStream->Init
|
||||
(aStream, aCharset,
|
||||
8192,
|
||||
nsIConverterInputStream::DEFAULT_REPLACEMENT_CHARACTER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicharInputStream> unicharStream =
|
||||
do_QueryInterface(converterStream);
|
||||
if (!unicharStream) return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 numChars;
|
||||
nsString result;
|
||||
rv = unicharStream->ReadString(8192, result, &numChars);
|
||||
while (NS_SUCCEEDED(rv) && numChars > 0) {
|
||||
PRUint32 oldLength = aResult.Length();
|
||||
aResult.Append(result);
|
||||
if (aResult.Length() - oldLength != result.Length()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = unicharStream->ReadString(8192, result, &numChars);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// nsDOMMemoryFile Implementation
|
||||
NS_IMETHODIMP
|
||||
nsDOMMemoryFile::GetName(nsAString &aFileName)
|
||||
|
@ -158,7 +158,6 @@ _TEST_FILES1 = test_bug5141.html \
|
||||
test_bug413974.html \
|
||||
test_bug415860.html \
|
||||
test_bug414190.html \
|
||||
test_bug414796.html \
|
||||
test_bug527896.html \
|
||||
test_bug416317-1.html \
|
||||
test_bug416317-2.html \
|
||||
|
@ -1,55 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=414796
|
||||
-->
|
||||
<title>Test for Bug 414796</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=414796">Mozilla Bug 414796</a>
|
||||
<p id="display">
|
||||
<input id="fileList" type="file"></input>
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
||||
|
||||
// Write a test file > 8192 characters
|
||||
|
||||
var testData = "asdfblahqwer";
|
||||
for (var i = 0; i < 10; i++) {
|
||||
testData = testData + testData;
|
||||
}
|
||||
|
||||
var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties);
|
||||
var testFile = dirSvc.get("ProfD", Components.interfaces.nsIFile);
|
||||
testFile.append("testfile");
|
||||
|
||||
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
||||
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
|
||||
0666, 0);
|
||||
outStream.write(testData, testData.length);
|
||||
outStream.close();
|
||||
|
||||
var fileList = document.getElementById('fileList');
|
||||
fileList.value = testFile.path;
|
||||
|
||||
var domFileData = fileList.files[0].getAsText("iso-8859-1");
|
||||
ok(domFileData.length == testData.length);
|
||||
ok(domFileData == testData);
|
||||
|
||||
testFile.remove(false);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body> </html>
|
@ -6,6 +6,21 @@
|
||||
<body>
|
||||
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
|
||||
function compareAsync(file, canvas, type)
|
||||
{
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload =
|
||||
function(e) {
|
||||
is(e.target.result, canvas.toDataURL(type),
|
||||
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
MochiKit.DOM.addLoadEvent(function () {
|
||||
|
||||
@ -16,15 +31,13 @@ ctx.drawImage(document.getElementById('yellow75.png'), 0, 0);
|
||||
|
||||
var pngfile = canvas.mozGetAsFile("foo.png");
|
||||
is(pngfile.type, "image/png", "Default type for mozGetAsFile should be PNG");
|
||||
is(pngfile.getAsDataURL(), canvas.toDataURL(),
|
||||
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
|
||||
compareAsync(pngfile, canvas, "image/png");
|
||||
is(pngfile.name, "foo.png", "File name should be what we passed in");
|
||||
|
||||
var jpegfile = canvas.mozGetAsFile("bar.jpg", "image/jpeg");
|
||||
is(jpegfile.type, "image/jpeg",
|
||||
"When a valid type is specified that should be returned");
|
||||
is(jpegfile.getAsDataURL(), canvas.toDataURL("image/jpeg"),
|
||||
"<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
|
||||
compareAsync(jpegfile, canvas, "image/jpeg");
|
||||
is(jpegfile.name, "bar.jpg", "File name should be what we passed in");
|
||||
|
||||
SimpleTest.finish();
|
||||
|
@ -10676,7 +10676,9 @@ nsDocShell::ConfirmRepost(PRBool * aRepost)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 buttonPressed;
|
||||
PRBool checkState;
|
||||
// The actual value here is irrelevant, but we can't pass an invalid
|
||||
// PRBool through XPConnect.
|
||||
PRBool checkState = PR_FALSE;
|
||||
rv = prompter->
|
||||
ConfirmEx(nsnull, msgString.get(),
|
||||
(nsIPrompt::BUTTON_POS_0 * nsIPrompt::BUTTON_TITLE_IS_STRING) +
|
||||
|
@ -690,13 +690,13 @@ ContentParent::SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& rep
|
||||
|
||||
for (PRUint32 i = 0; i < report.Length(); i++) {
|
||||
|
||||
nsCString prefix = report[i].prefix();
|
||||
nsCString path = report[i].path();
|
||||
PRInt32 kind = report[i].kind();
|
||||
nsCString desc = report[i].desc();
|
||||
nsCString process = report[i].process();
|
||||
nsCString path = report[i].path();
|
||||
PRInt32 kind = report[i].kind();
|
||||
nsCString desc = report[i].desc();
|
||||
PRInt64 memoryUsed = report[i].memoryUsed();
|
||||
|
||||
nsRefPtr<nsMemoryReporter> r = new nsMemoryReporter(prefix,
|
||||
nsRefPtr<nsMemoryReporter> r = new nsMemoryReporter(process,
|
||||
path,
|
||||
kind,
|
||||
desc,
|
||||
|
@ -42,7 +42,7 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct MemoryReport {
|
||||
nsCString prefix;
|
||||
nsCString process;
|
||||
nsCString path;
|
||||
PRInt32 kind;
|
||||
nsCString desc;
|
||||
|
@ -258,17 +258,6 @@ PluginPRLibrary::GetImageSize(NPP instance, nsIntSize* aSize)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginPRLibrary::IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing)
|
||||
{
|
||||
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
|
||||
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
|
||||
*aDrawing = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
PluginPRLibrary::SetBackgroundUnknown(NPP instance)
|
||||
{
|
||||
|
@ -143,9 +143,6 @@ public:
|
||||
virtual nsresult GetImage(NPP instance, ImageContainer* aContainer, Image** aImage);
|
||||
virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize);
|
||||
NS_OVERRIDE virtual bool UseAsyncPainting() { return false; }
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing);
|
||||
#endif
|
||||
NS_OVERRIDE
|
||||
virtual nsresult SetBackgroundUnknown(NPP instance);
|
||||
NS_OVERRIDE
|
||||
|
@ -729,22 +729,6 @@ nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult nsNPAPIPluginInstance::IsRemoteDrawingCoreAnimation(PRBool* aDrawing)
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
if (!mPlugin)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PluginLibrary* library = mPlugin->GetLibrary();
|
||||
if (!library)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return library->IsRemoteDrawingCoreAnimation(&mNPP, aDrawing);
|
||||
#else
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNPAPIPluginInstance::GetJSObject(JSContext *cx, JSObject** outObject)
|
||||
{
|
||||
|
@ -251,6 +251,28 @@ nsPluginInstanceOwner::EndUpdateBackground(gfxContext* aContext,
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsPluginInstanceOwner::UseAsyncRendering()
|
||||
{
|
||||
#ifdef XP_MACOSX
|
||||
nsRefPtr<ImageContainer> container = mObjectFrame->GetImageContainer();
|
||||
#endif
|
||||
|
||||
PRBool useAsyncRendering;
|
||||
return (mInstance &&
|
||||
NS_SUCCEEDED(mInstance->UseAsyncPainting(&useAsyncRendering)) &&
|
||||
useAsyncRendering &&
|
||||
#ifdef XP_MACOSX
|
||||
mObjectFrame && mObjectFrame->GetImageContainer().get() &&
|
||||
mObjectFrame->GetImageContainer().get()->GetBackendType() ==
|
||||
LayerManager::LAYERS_OPENGL
|
||||
#else
|
||||
(!mPluginWindow ||
|
||||
mPluginWindow->type == NPWindowTypeDrawable)
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
nsIntSize
|
||||
nsPluginInstanceOwner::GetCurrentImageSize()
|
||||
{
|
||||
@ -1338,18 +1360,6 @@ NPDrawingModel nsPluginInstanceOwner::GetDrawingModel()
|
||||
return drawingModel;
|
||||
}
|
||||
|
||||
PRBool nsPluginInstanceOwner::IsRemoteDrawingCoreAnimation()
|
||||
{
|
||||
if (!mInstance)
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool coreAnimation;
|
||||
if (!NS_SUCCEEDED(mInstance->IsRemoteDrawingCoreAnimation(&coreAnimation)))
|
||||
return PR_FALSE;
|
||||
|
||||
return coreAnimation;
|
||||
}
|
||||
|
||||
NPEventModel nsPluginInstanceOwner::GetEventModel()
|
||||
{
|
||||
return mEventModel;
|
||||
@ -3217,7 +3227,7 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
|
||||
mPluginWindow->clipRect.right != oldClipRect.right ||
|
||||
mPluginWindow->clipRect.bottom != oldClipRect.bottom)
|
||||
{
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
CallSetWindow();
|
||||
mPluginPortChanged = PR_FALSE;
|
||||
#ifdef MAC_CARBON_PLUGINS
|
||||
// if the clipRect is of size 0, make the null timer fire less often
|
||||
@ -3231,7 +3241,7 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
|
||||
}
|
||||
#endif
|
||||
} else if (mPluginPortChanged) {
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
CallSetWindow();
|
||||
mPluginPortChanged = PR_FALSE;
|
||||
}
|
||||
|
||||
@ -3273,7 +3283,11 @@ nsPluginInstanceOwner::HidePluginWindow()
|
||||
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top;
|
||||
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left;
|
||||
mWidgetVisible = PR_FALSE;
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
if (mAsyncHidePluginWindow) {
|
||||
mInstance->AsyncSetWindow(mPluginWindow);
|
||||
} else {
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
}
|
||||
}
|
||||
|
||||
#else // XP_MACOSX
|
||||
@ -3321,19 +3335,6 @@ void nsPluginInstanceOwner::UpdateWindowPositionAndClipRect(PRBool aSetWindow)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::CallSetWindow()
|
||||
{
|
||||
if (!mInstance)
|
||||
return;
|
||||
|
||||
if (UseAsyncRendering()) {
|
||||
mInstance->AsyncSetWindow(mPluginWindow);
|
||||
} else {
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::UpdateWindowVisibility(PRBool aVisible)
|
||||
{
|
||||
@ -3343,6 +3344,21 @@ nsPluginInstanceOwner::UpdateWindowVisibility(PRBool aVisible)
|
||||
|
||||
#endif // XP_MACOSX
|
||||
|
||||
void
|
||||
nsPluginInstanceOwner::CallSetWindow()
|
||||
{
|
||||
if (!mInstance)
|
||||
return;
|
||||
|
||||
if (UseAsyncRendering()) {
|
||||
mAsyncHidePluginWindow = true;
|
||||
mInstance->AsyncSetWindow(mPluginWindow);
|
||||
} else {
|
||||
mAsyncHidePluginWindow = false;
|
||||
mInstance->SetWindow(mPluginWindow);
|
||||
}
|
||||
}
|
||||
|
||||
// Little helper function to resolve relative URL in
|
||||
// |value| for certain inputs of |name|
|
||||
void nsPluginInstanceOwner::FixUpURLS(const nsString &name, nsAString &value)
|
||||
|
@ -179,7 +179,6 @@ public:
|
||||
enum { ePluginPaintEnable, ePluginPaintDisable };
|
||||
|
||||
NPDrawingModel GetDrawingModel();
|
||||
PRBool IsRemoteDrawingCoreAnimation();
|
||||
NPEventModel GetEventModel();
|
||||
static void CARefresh(nsITimer *aTimer, void *aClosure);
|
||||
static void AddToCARefreshTimer(nsPluginInstanceOwner *aPluginInstance);
|
||||
@ -207,9 +206,9 @@ public:
|
||||
void EndCGPaint();
|
||||
#else // XP_MACOSX
|
||||
void UpdateWindowPositionAndClipRect(PRBool aSetWindow);
|
||||
void CallSetWindow();
|
||||
void UpdateWindowVisibility(PRBool aVisible);
|
||||
#endif // XP_MACOSX
|
||||
void CallSetWindow();
|
||||
|
||||
void SetOwner(nsObjectFrame *aOwner)
|
||||
{
|
||||
@ -295,15 +294,7 @@ public:
|
||||
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect);
|
||||
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect);
|
||||
|
||||
PRBool UseAsyncRendering()
|
||||
{
|
||||
PRBool useAsyncRendering;
|
||||
return (mInstance &&
|
||||
NS_SUCCEEDED(mInstance->UseAsyncPainting(&useAsyncRendering)) &&
|
||||
useAsyncRendering &&
|
||||
(!mPluginWindow ||
|
||||
mPluginWindow->type == NPWindowTypeDrawable));
|
||||
}
|
||||
PRBool UseAsyncRendering();
|
||||
|
||||
private:
|
||||
|
||||
@ -339,6 +330,9 @@ private:
|
||||
static nsTArray<nsPluginInstanceOwner*> *sCARefreshListeners;
|
||||
PRBool mSentInitialTopLevelWindowEvent;
|
||||
#endif
|
||||
// We need to know if async hide window is required since we
|
||||
// can not check UseAsyncRendering when executing StopPlugin
|
||||
PRBool mAsyncHidePluginWindow;
|
||||
|
||||
// Initially, the event loop nesting level we were created on, it's updated
|
||||
// if we detect the appshell is on a lower level as long as we're not stopped.
|
||||
|
@ -69,10 +69,15 @@ struct SurfaceDescriptorX11 {
|
||||
gfxIntSize size;
|
||||
};
|
||||
|
||||
struct IOSurfaceDescriptor {
|
||||
uint32_t surfaceId;
|
||||
};
|
||||
|
||||
union SurfaceDescriptor {
|
||||
Shmem;
|
||||
SurfaceDescriptorX11;
|
||||
PPluginSurface; // used on Windows
|
||||
IOSurfaceDescriptor; // used on OSX 10.5+
|
||||
// Descriptor can be null here in case
|
||||
// 1) of first Show call (prevSurface is null)
|
||||
// 2) when child is going to destroy
|
||||
|
@ -105,6 +105,7 @@ static const TCHAR kPluginIgnoreSubclassProperty[] = TEXT("PluginIgnoreSubclassP
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include "PluginUtilsOSX.h"
|
||||
#endif // defined(XP_MACOSX)
|
||||
|
||||
template<>
|
||||
@ -135,6 +136,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
|
||||
, mShColorSpace(nsnull)
|
||||
, mShContext(nsnull)
|
||||
, mDrawingModel(NPDrawingModelCoreGraphics)
|
||||
, mCGLayer(nsnull)
|
||||
, mCurrentEvent(nsnull)
|
||||
#endif
|
||||
, mLayersRendering(false)
|
||||
@ -183,6 +185,9 @@ PluginInstanceChild::~PluginInstanceChild()
|
||||
if (mShContext) {
|
||||
::CGContextRelease(mShContext);
|
||||
}
|
||||
if (mCGLayer) {
|
||||
mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -477,6 +482,9 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
mDrawingModel = drawingModel;
|
||||
|
||||
PLUGIN_LOG_DEBUG((" Plugin requested drawing model id #%i\n",
|
||||
mDrawingModel));
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -490,6 +498,9 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
|
||||
mEventModel = static_cast<NPEventModel>(eventModel);
|
||||
#endif
|
||||
|
||||
PLUGIN_LOG_DEBUG((" Plugin requested event model id # %i\n",
|
||||
eventModel));
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
@ -778,6 +789,32 @@ PluginInstanceChild::AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
||||
void CallCGDraw(CGContextRef ref, void* aPluginInstance, nsIntRect aUpdateRect) {
|
||||
PluginInstanceChild* pluginInstance = (PluginInstanceChild*)aPluginInstance;
|
||||
|
||||
pluginInstance->CGDraw(ref, aUpdateRect);
|
||||
}
|
||||
|
||||
bool
|
||||
PluginInstanceChild::CGDraw(CGContextRef ref, nsIntRect aUpdateRect) {
|
||||
|
||||
NPCocoaEvent drawEvent;
|
||||
drawEvent.type = NPCocoaEventDrawRect;
|
||||
drawEvent.version = 0;
|
||||
drawEvent.data.draw.x = aUpdateRect.x;
|
||||
drawEvent.data.draw.y = aUpdateRect.y;
|
||||
drawEvent.data.draw.width = aUpdateRect.width;
|
||||
drawEvent.data.draw.height = aUpdateRect.height;
|
||||
drawEvent.data.draw.context = ref;
|
||||
|
||||
NPRemoteEvent remoteDrawEvent = {drawEvent};
|
||||
|
||||
int16_t handled;
|
||||
AnswerNPP_HandleEvent(remoteDrawEvent, &handled);
|
||||
return handled == true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
||||
const uint32_t &surfaceid,
|
||||
@ -803,13 +840,16 @@ PluginInstanceChild::AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
||||
NPError result = mPluginIface->getvalue(GetNPP(),
|
||||
NPPVpluginCoreAnimationLayer,
|
||||
&caLayer);
|
||||
|
||||
if (result != NPERR_NO_ERROR || !caLayer) {
|
||||
PLUGIN_LOG_DEBUG(("Plugin requested CoreAnimation but did not "
|
||||
"provide CALayer."));
|
||||
*handled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
mCARenderer.SetupRenderer(caLayer, mWindow.width, mWindow.height);
|
||||
|
||||
// Flash needs to have the window set again after this step
|
||||
if (mPluginIface->setwindow)
|
||||
(void) mPluginIface->setwindow(&mData, &mWindow);
|
||||
@ -2278,12 +2318,17 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
|
||||
}
|
||||
|
||||
mWindow.window = NULL;
|
||||
#ifdef XP_MACOSX
|
||||
if (mWindow.width != aWindow.width || mWindow.height != aWindow.height)
|
||||
mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
|
||||
#else
|
||||
if (mWindow.width != aWindow.width || mWindow.height != aWindow.height ||
|
||||
mWindow.clipRect.top != aWindow.clipRect.top ||
|
||||
mWindow.clipRect.left != aWindow.clipRect.left ||
|
||||
mWindow.clipRect.bottom != aWindow.clipRect.bottom ||
|
||||
mWindow.clipRect.right != aWindow.clipRect.right)
|
||||
mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
|
||||
#endif
|
||||
|
||||
mWindow.x = aWindow.x;
|
||||
mWindow.y = aWindow.y;
|
||||
@ -2472,6 +2517,7 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
|
||||
bool
|
||||
PluginInstanceChild::EnsureCurrentBuffer(void)
|
||||
{
|
||||
#ifndef XP_MACOSX
|
||||
nsIntRect toInvalidate(0, 0, 0, 0);
|
||||
gfxIntSize winSize = gfxIntSize(mWindow.width, mWindow.height);
|
||||
|
||||
@ -2503,7 +2549,7 @@ PluginInstanceChild::EnsureCurrentBuffer(void)
|
||||
mAccumulatedInvalidRect.UnionRect(mAccumulatedInvalidRect, toInvalidate);
|
||||
|
||||
if (mCurrentSurface) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CreateOptSurface()) {
|
||||
@ -2517,6 +2563,65 @@ PluginInstanceChild::EnsureCurrentBuffer(void)
|
||||
}
|
||||
|
||||
return true;
|
||||
#else // XP_MACOSX
|
||||
if (mCurrentIOSurface &&
|
||||
(mCurrentIOSurface->GetWidth() != mWindow.width ||
|
||||
mCurrentIOSurface->GetHeight() != mWindow.height) ) {
|
||||
mCurrentIOSurface = nsnull;
|
||||
}
|
||||
|
||||
if (!mCARenderer.isInit() || !mCurrentIOSurface) {
|
||||
if (!mCurrentIOSurface) {
|
||||
mCurrentIOSurface = nsIOSurface::CreateIOSurface(mWindow.width, mWindow.height);
|
||||
|
||||
nsIntRect toInvalidate(0, 0, mWindow.width, mWindow.height);
|
||||
mAccumulatedInvalidRect.UnionRect(mAccumulatedInvalidRect, toInvalidate);
|
||||
}
|
||||
|
||||
if (!mCurrentIOSurface) {
|
||||
NS_WARNING("Failed to allocate IOSurface");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIOSurface *rendererSurface = nsIOSurface::LookupSurface(mCurrentIOSurface->GetIOSurfaceID());
|
||||
if (!rendererSurface) {
|
||||
NS_WARNING("Failed to lookup IOSurface");
|
||||
return false;
|
||||
}
|
||||
mCARenderer.AttachIOSurface(rendererSurface);
|
||||
|
||||
void *caLayer = nsnull;
|
||||
if (mDrawingModel == NPDrawingModelCoreGraphics) {
|
||||
if (mCGLayer) {
|
||||
mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
|
||||
mCGLayer = nsnull;
|
||||
}
|
||||
|
||||
caLayer = mozilla::plugins::PluginUtilsOSX::GetCGLayer(CallCGDraw, this);
|
||||
if (!caLayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mCGLayer = caLayer;
|
||||
} else {
|
||||
NPError result = mPluginIface->getvalue(GetNPP(),
|
||||
NPPVpluginCoreAnimationLayer,
|
||||
&caLayer);
|
||||
if (result != NPERR_NO_ERROR || !caLayer) {
|
||||
PLUGIN_LOG_DEBUG(("Plugin requested CoreAnimation but did not "
|
||||
"provide CALayer."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mCARenderer.SetupRenderer(caLayer, mWindow.width, mWindow.height);
|
||||
// Flash needs to have the window set again after this step
|
||||
if (mPluginIface->setwindow)
|
||||
(void) mPluginIface->setwindow(&mData, &mWindow);
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2893,6 +2998,57 @@ PluginInstanceChild::ShowPluginFrame()
|
||||
AutoRestore<bool> pending(mPendingPluginCall);
|
||||
mPendingPluginCall = true;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// We can't use the thebes code with CoreAnimation so we will
|
||||
// take a different code path.
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation ||
|
||||
mDrawingModel == NPDrawingModelInvalidatingCoreAnimation ||
|
||||
mDrawingModel == NPDrawingModelCoreGraphics) {
|
||||
|
||||
if (!EnsureCurrentBuffer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear accRect here to be able to pass
|
||||
// test_invalidate_during_plugin_paint test
|
||||
nsIntRect rect = mAccumulatedInvalidRect;
|
||||
mAccumulatedInvalidRect.SetEmpty();
|
||||
|
||||
// Fix up old invalidations that might have been made when our
|
||||
// surface was a different size
|
||||
rect.IntersectRect(rect,
|
||||
nsIntRect(0, 0, mCurrentIOSurface->GetWidth(), mCurrentIOSurface->GetHeight()));
|
||||
|
||||
if (!mCARenderer.isInit()) {
|
||||
NS_ERROR("CARenderer not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mDrawingModel == NPDrawingModelCoreGraphics) {
|
||||
mozilla::plugins::PluginUtilsOSX::Repaint(mCGLayer, rect);
|
||||
}
|
||||
|
||||
mCARenderer.Render(mWindow.width, mWindow.height, nsnull);
|
||||
|
||||
NPRect r = { (uint16_t)rect.y, (uint16_t)rect.x,
|
||||
(uint16_t)rect.YMost(), (uint16_t)rect.XMost() };
|
||||
SurfaceDescriptor currSurf;
|
||||
currSurf = IOSurfaceDescriptor(mCurrentIOSurface->GetIOSurfaceID());
|
||||
|
||||
// Unused
|
||||
SurfaceDescriptor returnSurf;
|
||||
|
||||
if (!SendShow(r, currSurf, &returnSurf)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
NS_ERROR("Unsupported drawing model for async layer rendering");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool temporarilyMakeVisible = !IsVisible() && !mHasPainted;
|
||||
if (temporarilyMakeVisible && mWindow.width && mWindow.height) {
|
||||
mWindow.clipRect.right = mWindow.width;
|
||||
@ -3145,6 +3301,7 @@ PluginInstanceChild::InvalidateRect(NPRect* aInvalidRect)
|
||||
AsyncShowPluginFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we were going to use layers rendering but it's not set up
|
||||
// yet, and the plugin happens to call this first, we'll forward
|
||||
// the invalidation to the browser. It's unclear whether
|
||||
@ -3384,6 +3541,18 @@ PluginInstanceChild::ClearAllSurfaces()
|
||||
mBackSurfaceActor = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (mCurrentIOSurface) {
|
||||
// Get last surface back, and drop it
|
||||
SurfaceDescriptor temp = null_t();
|
||||
NPRect r = { 0, 0, 1, 1 };
|
||||
SendShow(r, temp, &temp);
|
||||
|
||||
}
|
||||
|
||||
mCurrentIOSurface = nsnull;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -414,11 +414,14 @@ private:
|
||||
CGContextRef mShContext;
|
||||
int16_t mDrawingModel;
|
||||
nsCARenderer mCARenderer;
|
||||
void *mCGLayer;
|
||||
|
||||
public:
|
||||
const NPCocoaEvent* getCurrentEvent() {
|
||||
return mCurrentEvent;
|
||||
}
|
||||
|
||||
bool CGDraw(CGContextRef ref, nsIntRect aUpdateRect);
|
||||
|
||||
#if defined(__i386__)
|
||||
NPEventModel EventModel() { return mEventModel; }
|
||||
@ -511,6 +514,12 @@ private:
|
||||
// surface which is on ParentProcess side
|
||||
nsRefPtr<gfxASurface> mBackSurface;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Current IOSurface available for rendering
|
||||
// We can't use thebes gfxASurface like other platforms.
|
||||
nsAutoPtr<nsIOSurface> mCurrentIOSurface;
|
||||
#endif
|
||||
|
||||
// (Not to be confused with mBackSurface). This is a recent copy
|
||||
// of the opaque pixels under our object frame, if
|
||||
// |mIsTransparent|. We ask the plugin render directly onto a
|
||||
|
@ -103,7 +103,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
||||
, mShHeight(0)
|
||||
, mShColorSpace(nsnull)
|
||||
, mDrawingModel(NPDrawingModelCoreGraphics)
|
||||
, mIOSurface(nsnull)
|
||||
#endif
|
||||
{
|
||||
InitQuirksModes(aMimeType);
|
||||
@ -137,7 +136,6 @@ PluginInstanceParent::~PluginInstanceParent()
|
||||
}
|
||||
if (mShColorSpace)
|
||||
::CGColorSpaceRelease(mShColorSpace);
|
||||
delete mIOSurface;
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation) {
|
||||
mParent->RemoveFromRefreshTimer(this);
|
||||
}
|
||||
@ -517,6 +515,29 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
|
||||
}
|
||||
surface = gfxSharedImageSurface::Open(newSurface.get_Shmem());
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
else if (newSurface.type() == SurfaceDescriptor::TIOSurfaceDescriptor) {
|
||||
IOSurfaceDescriptor iodesc = newSurface.get_IOSurfaceDescriptor();
|
||||
|
||||
nsIOSurface *newIOSurface = nsIOSurface::LookupSurface(iodesc.surfaceId());
|
||||
|
||||
if (!newIOSurface) {
|
||||
NS_WARNING("Got bad IOSurfaceDescriptor in RecvShow");
|
||||
return false;
|
||||
}
|
||||
|
||||
mIOSurface = newIOSurface;
|
||||
|
||||
RecvNPN_InvalidateRect(updatedRect);
|
||||
|
||||
*prevSurface = null_t();
|
||||
|
||||
PLUGIN_LOG_DEBUG((" (RecvShow invalidated for surface %p)",
|
||||
mFrontSurface.get()));
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_X11
|
||||
else if (newSurface.type() == SurfaceDescriptor::TSurfaceDescriptorX11) {
|
||||
SurfaceDescriptorX11 xdesc = newSurface.get_SurfaceDescriptorX11();
|
||||
@ -659,16 +680,6 @@ PluginInstanceParent::GetImageSize(nsIntSize* aSize)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
nsresult
|
||||
PluginInstanceParent::IsRemoteDrawingCoreAnimation(PRBool *aDrawing)
|
||||
{
|
||||
*aDrawing = (NPDrawingModelCoreAnimation == (NPDrawingModel)mDrawingModel ||
|
||||
NPDrawingModelInvalidatingCoreAnimation == (NPDrawingModel)mDrawingModel);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
PluginInstanceParent::SetBackgroundUnknown()
|
||||
{
|
||||
@ -869,7 +880,6 @@ PluginInstanceParent::NPP_SetWindow(const NPWindow* aWindow)
|
||||
if (mShWidth != window.width || mShHeight != window.height) {
|
||||
if (mDrawingModel == NPDrawingModelCoreAnimation ||
|
||||
mDrawingModel == NPDrawingModelInvalidatingCoreAnimation) {
|
||||
delete mIOSurface;
|
||||
mIOSurface = nsIOSurface::CreateIOSurface(window.width, window.height);
|
||||
} else if (mShWidth * mShHeight != window.width * window.height) {
|
||||
if (mShWidth != 0 && mShHeight != 0) {
|
||||
|
@ -282,9 +282,6 @@ public:
|
||||
nsresult AsyncSetWindow(NPWindow* window);
|
||||
nsresult GetImage(mozilla::layers::ImageContainer* aContainer, mozilla::layers::Image** aImage);
|
||||
nsresult GetImageSize(nsIntSize* aSize);
|
||||
#ifdef XP_MACOSX
|
||||
nsresult IsRemoteDrawingCoreAnimation(PRBool *aDrawing);
|
||||
#endif
|
||||
nsresult SetBackgroundUnknown();
|
||||
nsresult BeginUpdateBackground(const nsIntRect& aRect,
|
||||
gfxContext** aCtx);
|
||||
@ -352,12 +349,12 @@ private:
|
||||
#endif // defined(XP_WIN)
|
||||
#if defined(OS_MACOSX)
|
||||
private:
|
||||
Shmem mShSurface;
|
||||
size_t mShWidth;
|
||||
size_t mShHeight;
|
||||
CGColorSpaceRef mShColorSpace;
|
||||
int16_t mDrawingModel;
|
||||
nsIOSurface *mIOSurface;
|
||||
Shmem mShSurface;
|
||||
size_t mShWidth;
|
||||
size_t mShHeight;
|
||||
CGColorSpaceRef mShColorSpace;
|
||||
int16_t mDrawingModel;
|
||||
nsAutoPtr<nsIOSurface> mIOSurface;
|
||||
#endif // definied(OS_MACOSX)
|
||||
|
||||
// ObjectFrame layer wrapper
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "nsPoint.h"
|
||||
#include "npapi.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
// Make this includable from non-Objective-C code.
|
||||
#ifndef __OBJC__
|
||||
|
@ -102,9 +102,6 @@ public:
|
||||
virtual nsresult GetImage(NPP instance, ImageContainer* aContainer, Image** aImage) = 0;
|
||||
virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize) = 0;
|
||||
virtual bool UseAsyncPainting() = 0;
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing) = 0;
|
||||
#endif
|
||||
/**
|
||||
* The next three methods are the third leg in the trip to
|
||||
* PluginInstanceParent. They approximately follow the ReadbackSink
|
||||
|
@ -39,8 +39,8 @@
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include <glib.h>
|
||||
#elif XP_MACOSX
|
||||
#include "PluginUtilsOSX.h"
|
||||
#include "PluginInterposeOSX.h"
|
||||
#include "PluginUtilsOSX.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#endif
|
||||
@ -924,18 +924,6 @@ PluginModuleParent::NPP_GetSitesWithData(InfallibleTArray<nsCString>& result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
nsresult
|
||||
PluginModuleParent::IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing)
|
||||
{
|
||||
PluginInstanceParent* i = InstCast(instance);
|
||||
if (!i)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return i->IsRemoteDrawingCoreAnimation(aDrawing);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
PluginModuleParent::AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
|
||||
NPError* aError,
|
||||
|
@ -282,10 +282,6 @@ private:
|
||||
uint64_t maxAge);
|
||||
virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result);
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, PRBool *aDrawing);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void WritePluginExtraDataForMinidump(const nsAString& id);
|
||||
void WriteExtraDataForHang();
|
||||
|
@ -38,18 +38,27 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "npapi.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
namespace PluginUtilsOSX {
|
||||
|
||||
// Need to call back into the browser's to process event.
|
||||
// Need to call back into the browser's message loop to process event.
|
||||
typedef void (*RemoteProcessEvents) (void*);
|
||||
|
||||
NPError ShowCocoaContextMenu(void* aMenu, int aX, int aY, void* pluginModule, RemoteProcessEvents remoteEvent);
|
||||
|
||||
void InvokeNativeEventLoop();
|
||||
|
||||
// Need to call back and send a cocoa draw event to the plugin.
|
||||
typedef void (*DrawPluginFunc) (CGContextRef, void*, nsIntRect aUpdateRect);
|
||||
|
||||
void* GetCGLayer(DrawPluginFunc aFunc, void* aPluginInstance);
|
||||
void ReleaseCGLayer(void* cgLayer);
|
||||
void Repaint(void* cgLayer, nsIntRect aRect);
|
||||
|
||||
|
||||
} // namespace PluginUtilsOSX
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
@ -38,6 +38,7 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#include "PluginUtilsOSX.h"
|
||||
|
||||
// Remove definitions for try/catch interfering with ObjCException macros.
|
||||
@ -45,6 +46,61 @@
|
||||
|
||||
using namespace mozilla::plugins::PluginUtilsOSX;
|
||||
|
||||
@interface CGBridgeLayer : CALayer {
|
||||
DrawPluginFunc mDrawFunc;
|
||||
void* mPluginInstance;
|
||||
nsIntRect mUpdateRect;
|
||||
}
|
||||
- (void) setDrawFunc: (DrawPluginFunc)aFunc pluginInstance:(void*) aPluginInstance;
|
||||
- (void) updateRect: (nsIntRect)aRect;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CGBridgeLayer
|
||||
- (void) updateRect: (nsIntRect)aRect
|
||||
{
|
||||
mUpdateRect.UnionRect(mUpdateRect, aRect);
|
||||
}
|
||||
|
||||
- (void) setDrawFunc: (DrawPluginFunc)aFunc pluginInstance:(void*) aPluginInstance
|
||||
{
|
||||
mDrawFunc = aFunc;
|
||||
mPluginInstance = aPluginInstance;
|
||||
}
|
||||
|
||||
- (void)drawInContext:(CGContextRef)aCGContext
|
||||
|
||||
{
|
||||
::CGContextSaveGState(aCGContext);
|
||||
::CGContextTranslateCTM(aCGContext, 0, self.bounds.size.height);
|
||||
::CGContextScaleCTM(aCGContext, (CGFloat) 1, (CGFloat) -1);
|
||||
|
||||
mDrawFunc(aCGContext, mPluginInstance, mUpdateRect);
|
||||
|
||||
::CGContextRestoreGState(aCGContext);
|
||||
|
||||
mUpdateRect.SetEmpty();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void* mozilla::plugins::PluginUtilsOSX::GetCGLayer(DrawPluginFunc aFunc, void* aPluginInstance) {
|
||||
CGBridgeLayer *bridgeLayer = [[CGBridgeLayer alloc] init ];
|
||||
[bridgeLayer setDrawFunc:aFunc pluginInstance:aPluginInstance];
|
||||
return bridgeLayer;
|
||||
}
|
||||
|
||||
void mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(void *cgLayer) {
|
||||
CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)cgLayer;
|
||||
[bridgeLayer release];
|
||||
}
|
||||
|
||||
void mozilla::plugins::PluginUtilsOSX::Repaint(void *caLayer, nsIntRect aRect) {
|
||||
CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)caLayer;
|
||||
[bridgeLayer updateRect:aRect];
|
||||
[bridgeLayer setNeedsDisplay];
|
||||
}
|
||||
|
||||
@interface EventProcessor : NSObject {
|
||||
RemoteProcessEvents aRemoteEvents;
|
||||
void *aPluginModule;
|
||||
|
@ -52,10 +52,14 @@
|
||||
var browser1 = document.getElementById('browser1');
|
||||
var browser2 = document.getElementById('browser2');
|
||||
|
||||
var progressListener1, progressListener2;
|
||||
|
||||
function setup() {
|
||||
browser1.addProgressListener(new ProgressListener(), nsIWebProgress.NOTIFY_STATE_WINDOW);
|
||||
progressListener1 = new ProgressListener();
|
||||
browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW);
|
||||
browser1.loadURI(kURI, null, null);
|
||||
browser2.addProgressListener(new ProgressListener(), nsIWebProgress.NOTIFY_STATE_WINDOW);
|
||||
progressListener2 = new ProgressListener();
|
||||
browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW);
|
||||
browser2.loadURI(kURI, null, null);
|
||||
}
|
||||
|
||||
|
@ -600,6 +600,11 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetProcess(char **process) {
|
||||
*process = strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPath(char **memoryPath) {
|
||||
*memoryPath = strdup(SurfaceMemoryReporterPathForType(mType));
|
||||
return NS_OK;
|
||||
|
@ -95,6 +95,11 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetProcess(char **process) {
|
||||
*process = strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPath(char **memoryPath) {
|
||||
*memoryPath = strdup("gfx-d2d-surfacecache");
|
||||
return NS_OK;
|
||||
@ -127,6 +132,11 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetProcess(char **process) {
|
||||
*process = strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPath(char **memoryPath) {
|
||||
*memoryPath = strdup("gfx-d2d-surfacevram");
|
||||
return NS_OK;
|
||||
|
@ -4221,29 +4221,29 @@ dnl See if compiler supports some gcc-style attributes
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((always_inline)),
|
||||
ac_cv_attribute_always_inline,
|
||||
[AC_TRY_COMPILE([],
|
||||
[inline void f(void) __attribute__((always_inline));],
|
||||
[AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
|
||||
[],
|
||||
ac_cv_attribute_always_inline=yes,
|
||||
ac_cv_attribute_always_inline=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((malloc)),
|
||||
ac_cv_attribute_malloc,
|
||||
[AC_TRY_COMPILE([],
|
||||
[void* f(int) __attribute__((malloc));],
|
||||
[AC_TRY_COMPILE([void* f(int) __attribute__((malloc));],
|
||||
[],
|
||||
ac_cv_attribute_malloc=yes,
|
||||
ac_cv_attribute_malloc=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
|
||||
ac_cv_attribute_warn_unused,
|
||||
[AC_TRY_COMPILE([],
|
||||
[int f(void) __attribute__((warn_unused_result));],
|
||||
[AC_TRY_COMPILE([int f(void) __attribute__((warn_unused_result));],
|
||||
[],
|
||||
ac_cv_attribute_warn_unused=yes,
|
||||
ac_cv_attribute_warn_unused=no)])
|
||||
|
||||
AC_CACHE_CHECK(for __attribute__((noreturn)),
|
||||
ac_cv_attribute_noreturn,
|
||||
[AC_TRY_COMPILE([],
|
||||
[void f(void) __attribute__((noreturn));],
|
||||
[AC_TRY_COMPILE([void f(void) __attribute__((noreturn));],
|
||||
[],
|
||||
ac_cv_attribute_noreturn=yes,
|
||||
ac_cv_attribute_noreturn=no)])
|
||||
|
||||
|
@ -1500,7 +1500,9 @@ nsObjectFrame::UpdateImageLayer(ImageContainer* aContainer, const gfxRect& aRect
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
mInstanceOwner->DoCocoaEventDrawRect(aRect, nsnull);
|
||||
if (!mInstanceOwner->UseAsyncRendering()) {
|
||||
mInstanceOwner->DoCocoaEventDrawRect(aRect, nsnull);
|
||||
}
|
||||
#endif
|
||||
|
||||
mInstanceOwner->SetCurrentImage(aContainer);
|
||||
@ -1516,9 +1518,9 @@ nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
#ifdef XP_MACOSX
|
||||
if (aManager &&
|
||||
aManager->GetBackendType() == LayerManager::LAYERS_OPENGL &&
|
||||
mInstanceOwner->UseAsyncRendering() &&
|
||||
mInstanceOwner->GetEventModel() == NPEventModelCocoa &&
|
||||
mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreGraphics &&
|
||||
mInstanceOwner->IsRemoteDrawingCoreAnimation())
|
||||
mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreGraphics)
|
||||
{
|
||||
return LAYER_ACTIVE;
|
||||
}
|
||||
|
@ -157,6 +157,12 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetProcess(char **process)
|
||||
{
|
||||
*process = strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPath(char **memoryPath)
|
||||
{
|
||||
if (mType == ChromeUsedRaw) {
|
||||
|
@ -951,7 +951,7 @@ nsWebSocketHandler::ApplyMask(PRUint32 mask, PRUint8 *data, PRUint64 len)
|
||||
// but the buffer might not be alligned. So we first deal with
|
||||
// 0 to 3 bytes of preamble individually
|
||||
|
||||
while (len && ((unsigned long) data & 3)) {
|
||||
while (len && (reinterpret_cast<PRUptrdiff>(data) & 3)) {
|
||||
*data ^= mask >> 24;
|
||||
mask = PR_ROTATE_LEFT32(mask, 8);
|
||||
data++;
|
||||
|
@ -348,6 +348,12 @@ public:
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHOD GetProcess(char **process)
|
||||
{
|
||||
*process = strdup("");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPath(char **memoryPath)
|
||||
{
|
||||
nsCString path;
|
||||
|
@ -149,57 +149,50 @@ function update()
|
||||
// - Make a copy of it into a sub-table indexed by its process. Each copy
|
||||
// looks like this:
|
||||
//
|
||||
// interface Tmr {
|
||||
// _tpath: string;
|
||||
// interface Reporter {
|
||||
// _path: string;
|
||||
// _kind: number;
|
||||
// _description: string;
|
||||
// _memoryUsed: number;
|
||||
// }
|
||||
//
|
||||
// - The .path property is renamed ._tpath ("truncated path") in the copy
|
||||
// because the process name and ':' (if present) are removed.
|
||||
// - Note that copying mr.memoryUsed (which calls a C++ function under the
|
||||
// IDL covers) to tmr._memoryUsed for every reporter now means that the
|
||||
// After this point we never use the original memory reporter again.
|
||||
//
|
||||
// - Note that copying rOrig.memoryUsed (which calls a C++ function under the
|
||||
// IDL covers) to r._memoryUsed for every reporter now means that the
|
||||
// results as consistent as possible -- measurements are made all at
|
||||
// once before most of the memory required to generate this page is
|
||||
// allocated.
|
||||
var tmrTable = {};
|
||||
var reportersByProcess = {};
|
||||
var e = mgr.enumerateReporters();
|
||||
while (e.hasMoreElements()) {
|
||||
var mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
|
||||
var process;
|
||||
var tmr = {};
|
||||
var i = mr.path.indexOf(':');
|
||||
if (i === -1) {
|
||||
process = "Main";
|
||||
tmr._tpath = mr.path;
|
||||
} else {
|
||||
process = mr.path.slice(0, i);
|
||||
tmr._tpath = mr.path.slice(i + 1);
|
||||
var rOrig = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
|
||||
var process = rOrig.process === "" ? "Main" : rOrig.process;
|
||||
var r = {
|
||||
_path: rOrig.path,
|
||||
_kind: rOrig.kind,
|
||||
_description: rOrig.description,
|
||||
_memoryUsed: rOrig.memoryUsed
|
||||
};
|
||||
if (!reportersByProcess[process]) {
|
||||
reportersByProcess[process] = {};
|
||||
}
|
||||
tmr._kind = mr.kind;
|
||||
tmr._description = mr.description;
|
||||
tmr._memoryUsed = mr.memoryUsed;
|
||||
|
||||
if (!tmrTable[process]) {
|
||||
tmrTable[process] = {};
|
||||
}
|
||||
var tmrs = tmrTable[process];
|
||||
if (tmrs[tmr._tpath]) {
|
||||
var reporters = reportersByProcess[process];
|
||||
if (reporters[r._path]) {
|
||||
// Already an entry; must be a duplicated reporter. This can
|
||||
// happen legitimately. Sum the sizes.
|
||||
tmrs[tmr._tpath]._memoryUsed += tmr._memoryUsed;
|
||||
reporters[r._path]._memoryUsed += r._memoryUsed;
|
||||
} else {
|
||||
tmrs[tmr._tpath] = tmr;
|
||||
reporters[r._path] = r;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate output for one process at a time. Always start with the
|
||||
// Main process.
|
||||
var text = genProcessText("Main", tmrTable["Main"]);
|
||||
for (var process in tmrTable) {
|
||||
var text = genProcessText("Main", reportersByProcess["Main"]);
|
||||
for (var process in reportersByProcess) {
|
||||
if (process !== "Main") {
|
||||
text += genProcessText(process, tmrTable[process]);
|
||||
text += genProcessText(process, reportersByProcess[process]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +232,7 @@ function update()
|
||||
content.appendChild(div);
|
||||
}
|
||||
|
||||
function cmpTmrs(a, b)
|
||||
function cmp_memoryUsed(a, b)
|
||||
{
|
||||
return b._memoryUsed - a._memoryUsed
|
||||
};
|
||||
@ -249,11 +242,11 @@ function cmpTmrs(a, b)
|
||||
*
|
||||
* @param aProcess
|
||||
* The name of the process
|
||||
* @param aTmrs
|
||||
* Table of Tmrs for this process
|
||||
* @param aReporters
|
||||
* Table of reporters for this process, indexed by _path
|
||||
* @return The generated text
|
||||
*/
|
||||
function genProcessText(aProcess, aTmrs)
|
||||
function genProcessText(aProcess, aReporters)
|
||||
{
|
||||
/**
|
||||
* From a list of memory reporters, builds a tree that mirrors the tree
|
||||
@ -293,10 +286,10 @@ function genProcessText(aProcess, aTmrs)
|
||||
_kind: MR_OTHER,
|
||||
_kids: []
|
||||
};
|
||||
for (var tpath in aTmrs) {
|
||||
var tmr = aTmrs[tpath];
|
||||
if (tmr._tpath.slice(0, treeName.length) === treeName) {
|
||||
var names = tmr._tpath.split('/');
|
||||
for (var path in aReporters) {
|
||||
var r = aReporters[path];
|
||||
if (r._path.slice(0, treeName.length) === treeName) {
|
||||
var names = r._path.split('/');
|
||||
var u = t;
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
var name = names[i];
|
||||
@ -313,7 +306,7 @@ function genProcessText(aProcess, aTmrs)
|
||||
u = v;
|
||||
}
|
||||
}
|
||||
u._kind = tmr._kind;
|
||||
u._kind = r._kind;
|
||||
u._hasReporter = true;
|
||||
}
|
||||
}
|
||||
@ -324,13 +317,13 @@ function genProcessText(aProcess, aTmrs)
|
||||
// Next, fill in '_description' and '_memoryUsed', and maybe '_hasProblem'
|
||||
// for each node. This is done bottom-up because for most non-leaf nodes
|
||||
// '_memoryUsed' and '_description' are determined from the child nodes.
|
||||
function fillInTree(aT, aPretpath)
|
||||
function fillInTree(aT, aPrepath)
|
||||
{
|
||||
var tpath = aPretpath ? aPretpath + '/' + aT._name : aT._name;
|
||||
var path = aPrepath ? aPrepath + '/' + aT._name : aT._name;
|
||||
if (aT._kids.length === 0) {
|
||||
// Leaf node. Must have a reporter.
|
||||
aT._description = getDescription(aTmrs, tpath);
|
||||
var memoryUsed = getBytes(aTmrs, tpath);
|
||||
aT._description = getDescription(aReporters, path);
|
||||
var memoryUsed = getBytes(aReporters, path);
|
||||
if (memoryUsed !== kUnknown) {
|
||||
aT._memoryUsed = memoryUsed;
|
||||
} else {
|
||||
@ -342,12 +335,12 @@ function genProcessText(aProcess, aTmrs)
|
||||
var childrenBytes = 0;
|
||||
for (var i = 0; i < aT._kids.length; i++) {
|
||||
// Allow for kUnknown, treat it like 0.
|
||||
var b = fillInTree(aT._kids[i], tpath);
|
||||
var b = fillInTree(aT._kids[i], path);
|
||||
childrenBytes += (b === kUnknown ? 0 : b);
|
||||
}
|
||||
if (aT._hasReporter === true) {
|
||||
aT._description = getDescription(aTmrs, tpath);
|
||||
var memoryUsed = getBytes(aTmrs, tpath);
|
||||
aT._description = getDescription(aReporters, path);
|
||||
var memoryUsed = getBytes(aReporters, path);
|
||||
if (memoryUsed !== kUnknown) {
|
||||
// Non-leaf node with its own reporter. Use the reporter and add
|
||||
// an "other" child node.
|
||||
@ -397,7 +390,7 @@ function genProcessText(aProcess, aTmrs)
|
||||
// A special case: compute the derived "heap-unclassified" value. Don't
|
||||
// mark "heap-used" when we get its size because we want it to appear in
|
||||
// the "Other Measurements" list.
|
||||
var heapUsedBytes = getBytes(aTmrs, "heap-used", true);
|
||||
var heapUsedBytes = getBytes(aReporters, "heap-used", true);
|
||||
var unknownHeapUsedBytes = 0;
|
||||
var hasProblem = true;
|
||||
if (heapUsedBytes !== kUnknown) {
|
||||
@ -435,7 +428,7 @@ function genProcessText(aProcess, aTmrs)
|
||||
*/
|
||||
function filterTree(aT)
|
||||
{
|
||||
aT._kids.sort(cmpTmrs);
|
||||
aT._kids.sort(cmp_memoryUsed);
|
||||
|
||||
for (var i = 0; i < aT._kids.length; i++) {
|
||||
if (shouldOmit(aT._kids[i]._memoryUsed)) {
|
||||
@ -451,14 +444,14 @@ function genProcessText(aProcess, aTmrs)
|
||||
}
|
||||
aT._kids.splice(i0);
|
||||
var n = i - i0;
|
||||
var tmrSub = {
|
||||
var rSub = {
|
||||
_name: "(" + n + " omitted)",
|
||||
_kind: MR_OTHER,
|
||||
_description: "Omitted sub-trees: " + aggNames.join(", ") + ".",
|
||||
_memoryUsed: aggBytes,
|
||||
_kids: []
|
||||
};
|
||||
aT._kids[i0] = tmrSub;
|
||||
aT._kids[i0] = rSub;
|
||||
break;
|
||||
}
|
||||
filterTree(aT._kids[i]);
|
||||
@ -473,7 +466,7 @@ function genProcessText(aProcess, aTmrs)
|
||||
var text = "";
|
||||
text += "<h1>" + aProcess + " Process</h1>\n\n";
|
||||
text += genTreeText(buildTree());
|
||||
text += genOtherText(aTmrs);
|
||||
text += genOtherText(aReporters);
|
||||
text += "<hr></hr>";
|
||||
return text;
|
||||
}
|
||||
@ -552,42 +545,42 @@ function pad(aS, aN, aC)
|
||||
* Gets the byte count for a particular memory reporter and sets its _done
|
||||
* property.
|
||||
*
|
||||
* @param aTmrs
|
||||
* Table of Tmrs for this process
|
||||
* @param aTpath
|
||||
* The tpath of the memory reporter
|
||||
* @param aReporters
|
||||
* Table of reporters for this process, indexed by _path
|
||||
* @param aPath
|
||||
* The path of the memory reporter
|
||||
* @param aDoNotMark
|
||||
* If set, the _done property is not set.
|
||||
* @return The byte count
|
||||
*/
|
||||
function getBytes(aTmrs, aTpath, aDoNotMark)
|
||||
function getBytes(aReporters, aPath, aDoNotMark)
|
||||
{
|
||||
var tmr = aTmrs[aTpath];
|
||||
if (tmr) {
|
||||
var bytes = tmr._memoryUsed;
|
||||
var r = aReporters[aPath];
|
||||
if (r) {
|
||||
var bytes = r._memoryUsed;
|
||||
if (!aDoNotMark) {
|
||||
tmr._done = true;
|
||||
r._done = true;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
// Nb: this should never occur; all tpaths have been extracted from aTmrs and
|
||||
// so the lookup will succeed. Return an obviously wrong number that will
|
||||
// likely be noticed.
|
||||
// Nb: this should never occur; all paths have been extracted from
|
||||
// the original list of reporters and so the lookup should succeed. Return
|
||||
// an obviously wrong number that will likely be noticed.
|
||||
return -2 * 1024 * 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description for a particular memory reporter.
|
||||
*
|
||||
* @param aTmrs
|
||||
* Table of Tmrs for this process
|
||||
* @param aTpath
|
||||
* The tpath of the memory reporter
|
||||
* @param aReporters
|
||||
* Table of reporters for this process, indexed by _path
|
||||
* @param aPath
|
||||
* The path of the memory reporter
|
||||
* @return The description
|
||||
*/
|
||||
function getDescription(aTmrs, aTpath)
|
||||
function getDescription(aReporters, aPath)
|
||||
{
|
||||
var r = aTmrs[aTpath];
|
||||
var r = aReporters[aPath];
|
||||
return r ? r._description : "???";
|
||||
}
|
||||
|
||||
@ -740,47 +733,47 @@ function genTreeText(aT)
|
||||
/**
|
||||
* Generates the text for the "Other Measurements" section.
|
||||
*
|
||||
* @param aTmrs
|
||||
* Table of Tmrs for this process
|
||||
* @param aReporters
|
||||
* Table of reporters for this process, indexed by _path
|
||||
* @return The generated text
|
||||
*/
|
||||
function genOtherText(aTmrs)
|
||||
function genOtherText(aReporters)
|
||||
{
|
||||
// Generate an array of tmr-like elements, stripping out all the tmrs that
|
||||
// have already been handled. Also find the width of the widest element, so
|
||||
// we can format things nicely.
|
||||
// Generate an array of Reporter-like elements, stripping out all the
|
||||
// reporters that have already been handled. Also find the width of the
|
||||
// widest element, so we can format things nicely.
|
||||
var maxBytesLength = 0;
|
||||
var tmrArray = [];
|
||||
for (var tpath in aTmrs) {
|
||||
var tmr = aTmrs[tpath];
|
||||
if (!tmr._done) {
|
||||
var rArray = [];
|
||||
for (var path in aReporters) {
|
||||
var r = aReporters[path];
|
||||
if (!r._done) {
|
||||
var hasProblem = false;
|
||||
if (tmr._memoryUsed === kUnknown) {
|
||||
if (r._memoryUsed === kUnknown) {
|
||||
hasProblem = true;
|
||||
}
|
||||
var elem = {
|
||||
_tpath: tmr._tpath,
|
||||
_kind: tmr._kind,
|
||||
_description: tmr._description,
|
||||
_memoryUsed: hasProblem ? 0 : tmr._memoryUsed,
|
||||
_path: r._path,
|
||||
_kind: r._kind,
|
||||
_description: r._description,
|
||||
_memoryUsed: hasProblem ? 0 : r._memoryUsed,
|
||||
_hasProblem: hasProblem
|
||||
};
|
||||
tmrArray.push(elem);
|
||||
rArray.push(elem);
|
||||
var thisBytesLength = formatBytes(elem._memoryUsed).length;
|
||||
if (thisBytesLength > maxBytesLength) {
|
||||
maxBytesLength = thisBytesLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmrArray.sort(cmpTmrs);
|
||||
rArray.sort(cmp_memoryUsed);
|
||||
|
||||
// Generate text for the not-yet-printed values.
|
||||
var text = "";
|
||||
for (var i = 0; i < tmrArray.length; i++) {
|
||||
var elem = tmrArray[i];
|
||||
for (var i = 0; i < rArray.length; i++) {
|
||||
var elem = rArray[i];
|
||||
text += genMrValueText(
|
||||
pad(formatBytes(elem._memoryUsed), maxBytesLength, ' ')) + " ";
|
||||
text += genMrNameText(elem._kind, elem._description, elem._tpath,
|
||||
text += genMrNameText(elem._kind, elem._description, elem._path,
|
||||
elem._hasProblem);
|
||||
}
|
||||
|
||||
@ -791,3 +784,11 @@ function genOtherText(aTmrs)
|
||||
"<pre>" + text + "</pre>\n";
|
||||
}
|
||||
|
||||
function debug(x)
|
||||
{
|
||||
var content = $("content");
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = JSON.stringify(x);
|
||||
content.appendChild(div);
|
||||
}
|
||||
|
||||
|
@ -35,44 +35,53 @@
|
||||
const HEAP = Ci.nsIMemoryReporter.MR_HEAP;
|
||||
const OTHER = Ci.nsIMemoryReporter.MR_OTHER;
|
||||
|
||||
fakeReporters = [
|
||||
{ path: "heap-used", kind: OTHER, memoryUsed: 500 * MB },
|
||||
{ path: "heap-unused", kind: OTHER, memoryUsed: 100 * MB },
|
||||
{ path: "explicit/a", kind: HEAP, memoryUsed: 222 * MB },
|
||||
{ path: "explicit/b/a", kind: HEAP, memoryUsed: 85 * MB },
|
||||
{ path: "explicit/b/b", kind: HEAP, memoryUsed: 75 * MB },
|
||||
{ path: "explicit/b/c/a", kind: HEAP, memoryUsed: 70 * MB },
|
||||
{ path: "explicit/b/c/b", kind: HEAP, memoryUsed: 2 * MB }, // omitted
|
||||
{ path: "explicit/c", kind: MAPPED,memoryUsed: 123 * MB },
|
||||
{ path: "explicit/d", kind: MAPPED,memoryUsed: 499 * KB }, // omitted
|
||||
{ path: "explicit/e", kind: MAPPED,memoryUsed: 100 * KB }, // omitted
|
||||
{ path: "explicit/f/g/h/i", kind: HEAP, memoryUsed: 20 * MB },
|
||||
{ path: "explicit/g", kind: HEAP, memoryUsed: 14 * MB }, // internal
|
||||
{ path: "explicit/g", kind: HEAP, memoryUsed: 1 * MB }, // internal, dup: merge
|
||||
{ path: "explicit/g/a", kind: HEAP, memoryUsed: 6 * MB },
|
||||
{ path: "explicit/g/b", kind: HEAP, memoryUsed: 5 * MB },
|
||||
{ path: "other1", kind: OTHER, memoryUsed: 111 * MB },
|
||||
{ path: "other2", kind: OTHER, memoryUsed: 222 * MB },
|
||||
function f(aProcess, aPath, aKind, aMemoryUsed) {
|
||||
return {
|
||||
process: aProcess,
|
||||
path: aPath,
|
||||
kind: aKind,
|
||||
description: "(description)",
|
||||
memoryUsed: aMemoryUsed
|
||||
};
|
||||
}
|
||||
|
||||
{ path: "2nd:heap-used", kind: OTHER, memoryUsed: 1000 * MB },
|
||||
{ path: "2nd:heap-unused", kind: OTHER, memoryUsed: 100 * MB },
|
||||
{ path: "2nd:explicit/a/b/c",kind: HEAP, memoryUsed: 498 * MB },
|
||||
{ path: "2nd:explicit/a/b/c",kind: HEAP, memoryUsed: 1 * MB }, // dup: merge
|
||||
{ path: "2nd:explicit/b", kind: HEAP, memoryUsed: 400 * MB },
|
||||
{ path: "2nd:other1", kind: OTHER, memoryUsed: 777 * MB },
|
||||
fakeReporters = [
|
||||
f("", "heap-used", OTHER, 500 * MB),
|
||||
f("", "heap-unused", OTHER, 100 * MB),
|
||||
f("", "explicit/a", HEAP, 222 * MB),
|
||||
f("", "explicit/b/a", HEAP, 85 * MB),
|
||||
f("", "explicit/b/b", HEAP, 75 * MB),
|
||||
f("", "explicit/b/c/a", HEAP, 70 * MB),
|
||||
f("", "explicit/b/c/b", HEAP, 2 * MB), // omitted
|
||||
f("", "explicit/c", MAPPED, 123 * MB),
|
||||
f("", "explicit/d", MAPPED, 499 * KB), // omitted
|
||||
f("", "explicit/e", MAPPED, 100 * KB), // omitted
|
||||
f("", "explicit/f/g/h/i", HEAP, 20 * MB),
|
||||
f("", "explicit/g", HEAP, 14 * MB), // internal
|
||||
f("", "explicit/g", HEAP, 1 * MB), // internal, dup: merge
|
||||
f("", "explicit/g/a", HEAP, 6 * MB),
|
||||
f("", "explicit/g/b", HEAP, 5 * MB),
|
||||
f("", "other1", OTHER, 111 * MB),
|
||||
f("", "other2", OTHER, 222 * MB),
|
||||
|
||||
f("2nd", "heap-used", OTHER, 1000 * MB),
|
||||
f("2nd", "heap-unused", OTHER, 100 * MB),
|
||||
f("2nd", "explicit/a/b/c", HEAP, 498 * MB),
|
||||
f("2nd", "explicit/a/b/c", HEAP, 1 * MB), // dup: merge
|
||||
f("2nd", "explicit/b", HEAP, 400 * MB),
|
||||
f("2nd", "other1", OTHER, 777 * MB),
|
||||
|
||||
// kUnknown should be handled gracefully for "heap-used", non-leaf
|
||||
// reporters, leaf-reporters, and "other" reporters.
|
||||
{ path: "3rd:heap-used", kind: OTHER, memoryUsed: kUnknown },
|
||||
{ path: "3rd:explicit/a", kind: HEAP, memoryUsed: kUnknown },
|
||||
{ path: "3rd:explicit/a/b", kind: HEAP, memoryUsed: 333 * MB },
|
||||
{ path: "3rd:explicit/a/c", kind: HEAP, memoryUsed: 444 * MB },
|
||||
{ path: "3rd:explicit/a/d", kind: HEAP, memoryUsed: kUnknown },
|
||||
{ path: "3rd:explicit/b", kind: MAPPED,memoryUsed: kUnknown },
|
||||
{ path: "3rd:other1", kind: OTHER, memoryUsed: kUnknown }
|
||||
f("3rd", "heap-used", OTHER, kUnknown),
|
||||
f("3rd", "explicit/a", HEAP, kUnknown),
|
||||
f("3rd", "explicit/a/b", HEAP, 333 * MB),
|
||||
f("3rd", "explicit/a/c", HEAP, 444 * MB),
|
||||
f("3rd", "explicit/a/d", HEAP, kUnknown),
|
||||
f("3rd", "explicit/b", MAPPED,kUnknown),
|
||||
f("3rd", "other1", OTHER, kUnknown)
|
||||
];
|
||||
for (var i = 0; i < fakeReporters.length; i++) {
|
||||
fakeReporters[i].description = "(description)";
|
||||
mgr.registerReporter(fakeReporters[i]);
|
||||
}
|
||||
]]>
|
||||
|
@ -135,11 +135,8 @@ using namespace mozilla::places;
|
||||
// Out of this cache, SQLite will use at most the size of the database file.
|
||||
#define DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE 6
|
||||
|
||||
// PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036). If the
|
||||
// return value is greater than MEMSIZE_MAX_BYTES, assume it is garbage and
|
||||
// use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync with the code in
|
||||
// nsPlacesExpiration.js.
|
||||
#define MEMSIZE_MAX_BYTES 137438953472LL // 128 G
|
||||
// If the physical memory size is not available, use MEMSIZE_FALLBACK_BYTES
|
||||
// instead. Must stay in sync with the code in nsPlacesExpiration.js.
|
||||
#define MEMSIZE_FALLBACK_BYTES 268435456 // 256 M
|
||||
|
||||
// Maximum size for the WAL file. It should be small enough since in case of
|
||||
@ -733,14 +730,14 @@ nsNavHistory::InitDB()
|
||||
if (cachePercentage < 0)
|
||||
cachePercentage = 0;
|
||||
|
||||
static PRInt64 physMem = PR_GetPhysicalMemorySize();
|
||||
if (physMem <= 0 || physMem > MEMSIZE_MAX_BYTES)
|
||||
static PRUint64 physMem = PR_GetPhysicalMemorySize();
|
||||
if (physMem == 0)
|
||||
physMem = MEMSIZE_FALLBACK_BYTES;
|
||||
|
||||
PRInt64 cacheSize = physMem * cachePercentage / 100;
|
||||
PRUint64 cacheSize = physMem * cachePercentage / 100;
|
||||
|
||||
// Compute number of cached pages, this will be our cache size.
|
||||
PRInt64 cachePages = cacheSize / mDBPageSize;
|
||||
PRUint64 cachePages = cacheSize / mDBPageSize;
|
||||
nsCAutoString cacheSizePragma("PRAGMA cache_size = ");
|
||||
cacheSizePragma.AppendInt(cachePages);
|
||||
rv = mDBConn->ExecuteSimpleSQL(cacheSizePragma);
|
||||
|
@ -717,17 +717,14 @@ nsPlacesExpiration.prototype = {
|
||||
catch(e) {}
|
||||
|
||||
if (this._urisLimit < 0) {
|
||||
// PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036).
|
||||
// If the return value is greater than MEMSIZE_MAX_BYTES, assume it is
|
||||
// garbage and use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync
|
||||
// with the code in nsNavHistory.cpp.
|
||||
const MEMSIZE_MAX_BYTES = 137438953472; // 128 G
|
||||
// If physical memory size is not available, use MEMSIZE_FALLBACK_BYTES
|
||||
// instead. Must stay in sync with the code in nsNavHistory.cpp.
|
||||
const MEMSIZE_FALLBACK_BYTES = 268435456; // 256 M
|
||||
|
||||
// The preference did not exist or has a negative value, so we calculate a
|
||||
// limit based on hardware.
|
||||
let memsize = this._sys.getProperty("memsize"); // Memory size in bytes.
|
||||
if (memsize <= 0 || memsize > MEMSIZE_MAX_BYTES)
|
||||
if (memsize <= 0)
|
||||
memsize = MEMSIZE_FALLBACK_BYTES;
|
||||
|
||||
let cpucount = this._sys.getProperty("cpucount"); // CPU count.
|
||||
|
@ -44,9 +44,16 @@ interface nsISimpleEnumerator;
|
||||
interface nsIMemoryReporter : nsISupports
|
||||
{
|
||||
/*
|
||||
* The path that this memory usage should be reported under. Paths can
|
||||
* begin with a process name plus a colon, eg "Content:", but this is not
|
||||
* necessary for the main process. After the process name, paths are
|
||||
* The name of the process containing this reporter. All reporters start
|
||||
* with "", which is short-hand for the "main" process; this is true even
|
||||
* for reporters in child processes. When reporters from child reporters
|
||||
* are copied into the main process, the copies have their 'process' field
|
||||
* set appropriately.
|
||||
*/
|
||||
readonly attribute string process;
|
||||
|
||||
/*
|
||||
* The path that this memory usage should be reported under. Paths are
|
||||
* '/'-delimited, eg. "a/b/c". There are two categories of paths.
|
||||
*
|
||||
* - Paths starting with "explicit" represent non-overlapping regions of
|
||||
@ -132,10 +139,14 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
|
||||
%{C++
|
||||
|
||||
/*
|
||||
* Note that this defaults 'process' to "", which is usually what's desired.
|
||||
*/
|
||||
#define NS_MEMORY_REPORTER_IMPLEMENT(_classname,_path,_kind,_desc,_usageFunction,_dataptr) \
|
||||
class MemoryReporter_##_classname : public nsIMemoryReporter { \
|
||||
public: \
|
||||
NS_DECL_ISUPPORTS \
|
||||
NS_IMETHOD GetProcess(char **process) { *process = strdup(""); return NS_OK; } \
|
||||
NS_IMETHOD GetPath(char **memoryPath) { *memoryPath = strdup(_path); return NS_OK; } \
|
||||
NS_IMETHOD GetKind(int *kind) { *kind = _kind; return NS_OK; } \
|
||||
NS_IMETHOD GetDescription(char **desc) { *desc = strdup(_desc); return NS_OK; } \
|
||||
|
@ -398,26 +398,29 @@ nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter)
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMemoryReporter, nsIMemoryReporter)
|
||||
|
||||
nsMemoryReporter::nsMemoryReporter(nsCString& prefix,
|
||||
nsMemoryReporter::nsMemoryReporter(nsCString& process,
|
||||
nsCString& path,
|
||||
PRInt32 kind,
|
||||
nsCString& desc,
|
||||
PRInt64 memoryUsed)
|
||||
: mKind(kind)
|
||||
: mProcess(process)
|
||||
, mPath(path)
|
||||
, mKind(kind)
|
||||
, mDesc(desc)
|
||||
, mMemoryUsed(memoryUsed)
|
||||
{
|
||||
if (!prefix.IsEmpty()) {
|
||||
mPath.Append(prefix);
|
||||
mPath.Append(NS_LITERAL_CSTRING(":"));
|
||||
}
|
||||
mPath.Append(path);
|
||||
}
|
||||
|
||||
nsMemoryReporter::~nsMemoryReporter()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMemoryReporter::GetProcess(char **aProcess)
|
||||
{
|
||||
*aProcess = strdup(mProcess.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMemoryReporter::GetPath(char **aPath)
|
||||
{
|
||||
*aPath = strdup(mPath.get());
|
||||
|
@ -11,7 +11,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
nsMemoryReporter(nsCString& prefix,
|
||||
nsMemoryReporter(nsCString& process,
|
||||
nsCString& path,
|
||||
PRInt32 kind,
|
||||
nsCString& desc,
|
||||
@ -20,6 +20,7 @@ public:
|
||||
~nsMemoryReporter();
|
||||
|
||||
protected:
|
||||
nsCString mProcess;
|
||||
nsCString mPath;
|
||||
PRInt32 mKind;
|
||||
nsCString mDesc;
|
||||
|
Loading…
Reference in New Issue
Block a user