diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 74907e884b..ded46a5023 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -394,28 +394,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, info->mFixupCreatedAlternateURI = MakeAlternateURI(info->mFixedURI); } - // If there is no relevent dot in the host, do we require the domain to - // be whitelisted? if (info->mFixedURI) { - if (aFixupFlags & FIXUP_FLAG_REQUIRE_WHITELISTED_HOST) { - nsAutoCString asciiHost; - if (NS_SUCCEEDED(info->mFixedURI->GetAsciiHost(asciiHost)) && - !asciiHost.IsEmpty()) { - uint32_t dotLoc = uint32_t(asciiHost.FindChar('.')); - - if ((dotLoc == uint32_t(kNotFound) || - dotLoc == asciiHost.Length() - 1)) { - if (IsDomainWhitelisted(asciiHost, dotLoc)) { - info->mPreferredURI = info->mFixedURI; - } - } else { - info->mPreferredURI = info->mFixedURI; - } - } - } else { - info->mPreferredURI = info->mFixedURI; - } - + info->mPreferredURI = info->mFixedURI; return NS_OK; } @@ -1123,6 +1103,15 @@ nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost, return Preferences::GetBool(pref.get(), false); } +NS_IMETHODIMP +nsDefaultURIFixup::IsDomainWhitelisted(const nsACString& aDomain, + const uint32_t aDotLoc, + bool* aResult) +{ + *aResult = IsDomainWhitelisted(nsAutoCString(aDomain), aDotLoc); + return NS_OK; +} + /* Implementation of nsIURIFixupInfo */ NS_IMPL_ISUPPORTS(nsDefaultURIFixupInfo, nsIURIFixupInfo) diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index a9a73a1478..0fc5be6ddf 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -62,8 +62,8 @@ namespace mozilla { namespace dom { class EventTarget; -} -} +} // namespace dom +} // namespace mozilla class nsDocShell; class nsDOMNavigationTiming; diff --git a/docshell/base/nsIURIFixup.idl b/docshell/base/nsIURIFixup.idl index 53ec55106a..0145aca00f 100644 --- a/docshell/base/nsIURIFixup.idl +++ b/docshell/base/nsIURIFixup.idl @@ -70,7 +70,7 @@ interface nsIURIFixupInfo : nsISupports /** * Interface implemented by objects capable of fixing up strings into URIs */ -[scriptable, uuid(d2a78abe-e678-4103-9bcc-dd1377460c44)] +[scriptable, uuid(1da7e9d4-620b-4949-849a-1cd6077b1b2d)] interface nsIURIFixup : nsISupports { /** No fixup flags. */ @@ -89,19 +89,13 @@ interface nsIURIFixup : nsISupports */ const unsigned long FIXUP_FLAGS_MAKE_ALTERNATE_URI = 2; - /** - * For an input that may be just a domain with only 1 level (eg, "mozilla"), - * require that the host be whitelisted. - * - * Overridden by FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP. - */ - const unsigned long FIXUP_FLAG_REQUIRE_WHITELISTED_HOST = 4; - /* * Fix common scheme typos. */ const unsigned long FIXUP_FLAG_FIX_SCHEME_TYPOS = 8; + /* NB: If adding an extra flag, 4 is free (again) */ + /** * Converts an internal URI (e.g. a wyciwyg URI) into one which we can * expose to the user, for example on the URL bar. @@ -155,5 +149,18 @@ interface nsIURIFixup : nsISupports */ nsIURIFixupInfo keywordToURI(in AUTF8String aKeyword, [optional] out nsIInputStream aPostData); + + /** + * Returns true if the specified domain is whitelisted and false otherwise. + * A whitelisted domain is relevant when we have a single word and can't be + * sure whether to treat the word as a host name or should instead be + * treated as a search term. + * + * @param aDomain A domain name to query. + * @param aDotPos The position of the first '.' character in aDomain, or + * -1 if no '.' character exists. + */ + bool isDomainWhitelisted(in AUTF8String aDomain, + in uint32_t aDotPos); }; diff --git a/docshell/build/nsDocShellCID.h b/docshell/build/nsDocShellCID.h index 35432ee1b5..85080c3cbc 100644 --- a/docshell/build/nsDocShellCID.h +++ b/docshell/build/nsDocShellCID.h @@ -1,6 +1,6 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 sts=4 - * This Source Code Form is subject to the terms of the Mozilla Public +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/docshell/build/nsDocShellModule.cpp b/docshell/build/nsDocShellModule.cpp index ec39cea2f6..716a256240 100644 --- a/docshell/build/nsDocShellModule.cpp +++ b/docshell/build/nsDocShellModule.cpp @@ -1,6 +1,6 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -155,6 +155,9 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = { { NS_ABOUT_MODULE_CONTRACTID_PREFIX "", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "about", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, +#ifdef MOZ_CRASHREPORTER + { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, +#endif { NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, { NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", &kNS_ABOUT_REDIRECTOR_MODULE_CID }, diff --git a/docshell/test/unit/test_nsDefaultURIFixup_info.js b/docshell/test/unit/test_nsDefaultURIFixup_info.js index e30ac1de29..64123fa8d3 100644 --- a/docshell/test/unit/test_nsDefaultURIFixup_info.js +++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js @@ -38,7 +38,6 @@ let flagInputs = [ urifixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP, urifixup.FIXUP_FLAGS_MAKE_ALTERNATE_URI, urifixup.FIXUP_FLAG_FIX_SCHEME_TYPOS, - urifixup.FIXUP_FLAG_REQUIRE_WHITELISTED_HOST, ]; flagInputs.concat([ @@ -56,7 +55,6 @@ flagInputs.concat([ alternateURI: "", // Expected alternateURI keywordLookup: false, // Whether a keyword lookup is expected protocolChange: false, // Whether a protocol change is expected - affectedByWhitelist: false, // Whether the input host is affected by the whitelist inWhitelist: false, // Whether the input host is in the whitelist affectedByDNSForSingleHosts: false, // Whether the input host could be a host, but is normally assumed to be a keyword query } @@ -176,25 +174,21 @@ let testcases = [ { fixedURI: "http://[::1]/", alternateURI: "http://[::1]/", protocolChange: true, - affectedByWhitelist: true }, { input: "[::1]/", fixedURI: "http://[::1]/", alternateURI: "http://[::1]/", protocolChange: true, - affectedByWhitelist: true, }, { input: "[::1]:8000", fixedURI: "http://[::1]:8000/", alternateURI: "http://[::1]:8000/", protocolChange: true, - affectedByWhitelist: true, }, { input: "[::1]:8000/", fixedURI: "http://[::1]:8000/", alternateURI: "http://[::1]:8000/", protocolChange: true, - affectedByWhitelist: true, }, { input: "[[::1]]/", keywordLookup: true, @@ -204,7 +198,6 @@ let testcases = [ { fixedURI: "http://[fe80:cd00:0:cde:1257:0:211e:729c]/", alternateURI: "http://[fe80:cd00:0:cde:1257:0:211e:729c]/", protocolChange: true, - affectedByWhitelist: true }, { input: "[64:ff9b::8.8.8.8]", fixedURI: "http://[64:ff9b::8.8.8.8]/", @@ -219,10 +212,11 @@ let testcases = [ { protocolChange: true }, { input: "[::1][100", - fixedURI: null, - alternateURI: null, + fixedURI: "http://[::1][100/", + alternateURI: "http://[::1][100/", keywordLookup: true, - protocolChange: true + protocolChange: true, + affectedByDNSForSingleHosts: true, }, { input: "[::1]]", keywordLookup: true, @@ -233,21 +227,18 @@ let testcases = [ { alternateURI: "http://www.1234.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "host/foo.txt", fixedURI: "http://host/foo.txt", alternateURI: "http://www.host.com/foo.txt", protocolChange: true, - affectedByWhitelist: true, }, { input: "mozilla", fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "test.", @@ -255,7 +246,6 @@ let testcases = [ { alternateURI: "http://www.test./", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: ".test", @@ -290,7 +280,6 @@ let testcases = [ { alternateURI: "http://www.mozilla.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: " mozilla ", @@ -298,13 +287,11 @@ let testcases = [ { alternateURI: "http://www.mozilla.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "mozilla \\", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, }, { input: "mozilla \\ foo.txt", keywordLookup: true, @@ -319,7 +306,6 @@ let testcases = [ { alternateURI: "http://www.mozilla.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "mozilla \r\n", @@ -327,7 +313,6 @@ let testcases = [ { alternateURI: "http://www.mozilla.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "moz\r\nfirefox\nos\r", @@ -335,7 +320,6 @@ let testcases = [ { alternateURI: "http://www.mozfirefoxos.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "moz\r\n firefox\n", @@ -353,7 +337,6 @@ let testcases = [ { input: "http://whitelisted/", fixedURI: "http://whitelisted/", alternateURI: "http://www.whitelisted.com/", - affectedByWhitelist: true, inWhitelist: true, }, { input: "café.local", @@ -391,7 +374,6 @@ let testcases = [ { alternateURI: "http://www.5+2.com/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "5/2", @@ -399,7 +381,6 @@ let testcases = [ { alternateURI: "http://www.5.com/2", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "moz ?.::%27", @@ -442,20 +423,17 @@ let testcases = [ { alternateURI: "http://www.'.com/?", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true }, { input: "a?.com", fixedURI: "http://a/?.com", alternateURI: "http://www.a.com/?.com", protocolChange: true, - affectedByWhitelist: true }, { input: "?'.com", fixedURI: "http:///?%27.com", alternateURI: "http://www..com/?%27.com", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true }, { input: "' ?.com", keywordLookup: true, @@ -466,40 +444,34 @@ let testcases = [ { alternateURI: "http://www..com/?mozilla", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true }, { input: "??mozilla", fixedURI: "http:///??mozilla", alternateURI: "http://www..com/??mozilla", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true }, { input: "mozilla/", fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", protocolChange: true, - affectedByWhitelist: true, }, { input: "mozilla", fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", protocolChange: true, keywordLookup: true, - affectedByWhitelist: true, affectedByDNSForSingleHosts: true, }, { input: "mozilla5/2", fixedURI: "http://mozilla5/2", alternateURI: "http://www.mozilla5.com/2", protocolChange: true, - affectedByWhitelist: true, }, { input: "mozilla/foo", fixedURI: "http://mozilla/foo", alternateURI: "http://www.mozilla.com/foo", protocolChange: true, - affectedByWhitelist: true, }]; if (Services.appinfo.OS.toLowerCase().startsWith("win")) { @@ -513,14 +485,12 @@ if (Services.appinfo.OS.toLowerCase().startsWith("win")) { fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", protocolChange: true, - affectedByWhitelist: true, }); testcases.push({ input: "mozilla\\", fixedURI: "http://mozilla/", alternateURI: "http://www.mozilla.com/", protocolChange: true, - affectedByWhitelist: true, }); } else { testcases.push({ @@ -535,12 +505,11 @@ if (Services.appinfo.OS.toLowerCase().startsWith("win")) { }); // \ is an invalid character in the hostname until bug 652186 is implemented testcases.push({ input: "mozilla\\", - // fixedURI: "http://mozilla\\/", - // alternateURI: "http://www.mozilla/", + fixedURI: "http://mozilla\\/", + alternateURI: "http://www.mozilla/", keywordLookup: true, protocolChange: true, - affectedByWhitelist: true, - // affectedByDNSForSingleHosts: true, + affectedByDNSForSingleHosts: true, }); } @@ -576,7 +545,6 @@ function do_single_test_run() { alternateURI: alternativeURI, keywordLookup: expectKeywordLookup, protocolChange: expectProtocolChange, - affectedByWhitelist: affectedByWhitelist, inWhitelist: inWhitelist, affectedByDNSForSingleHosts: affectedByDNSForSingleHosts, } of relevantTests) { @@ -584,7 +552,6 @@ function do_single_test_run() { // Explicitly force these into a boolean expectKeywordLookup = !!expectKeywordLookup; expectProtocolChange = !!expectProtocolChange; - affectedByWhitelist = !!affectedByWhitelist; inWhitelist = !!inWhitelist; affectedByDNSForSingleHosts = !!affectedByDNSForSingleHosts; @@ -635,10 +602,9 @@ function do_single_test_run() { do_check_eq(info.fixupCreatedAlternateURI, makeAlternativeURI && alternativeURI != null); // Check the preferred URI - let requiresWhitelistedDomain = flags & urifixup.FIXUP_FLAG_REQUIRE_WHITELISTED_HOST; if (couldDoKeywordLookup) { if (expectKeywordLookup) { - if (!affectedByWhitelist || (affectedByWhitelist && !inWhitelist)) { + if (!inWhitelist) { let urlparamInput = encodeURIComponent(sanitize(testInput)).replace(/%20/g, "+"); // If the input starts with `?`, then info.preferredURI.spec will omit it // In order to test this behaviour, remove `?` only if it is the first character @@ -654,14 +620,6 @@ function do_single_test_run() { } else { do_check_eq(info.preferredURI.spec, info.fixedURI.spec); } - } else if (requiresWhitelistedDomain) { - // Not a keyword search, but we want to enforce the host whitelist. - // If we always do DNS lookups, we should always havea preferred URI here - unless the - // input starts with '?' in which case preferredURI will just be null... - if (!affectedByWhitelist || (affectedByWhitelist && inWhitelist) || (gSingleWordHostLookup && !testInput.startsWith("?"))) - do_check_eq(info.preferredURI.spec, info.fixedURI.spec); - else - do_check_eq(info.preferredURI, null); } else { // In these cases, we should never be doing a keyword lookup and // the fixed URI should be preferred: diff --git a/dom/base/MultipartBlobImpl.h b/dom/base/MultipartBlobImpl.h index a74bf12272..0b43efbe49 100644 --- a/dom/base/MultipartBlobImpl.h +++ b/dom/base/MultipartBlobImpl.h @@ -98,7 +98,7 @@ public: virtual const nsTArray>* GetSubBlobImpls() const override { - return &mBlobImpls; + return mBlobImpls.Length() ? &mBlobImpls : nullptr; } virtual void GetMozFullPathInternal(nsAString& aFullPath, diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index fcfb0535b0..a63400293b 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6197,7 +6197,7 @@ nsGlobalWindow::GetMainWidget() } nsIWidget* -nsGlobalWindow::GetNearestWidget() +nsGlobalWindow::GetNearestWidget() const { nsIDocShell* docShell = GetDocShell(); NS_ENSURE_TRUE(docShell, nullptr); @@ -6357,8 +6357,16 @@ nsGlobalWindow::FullScreen() const nsCOMPtr rootItem; mDocShell->GetRootTreeItem(getter_AddRefs(rootItem)); if (rootItem == mDocShell) { - // We are the root window. Return our internal value. - return mFullScreen; + if (!XRE_IsContentProcess()) { + // We are the root window. Return our internal value. + return mFullScreen; + } + if (nsCOMPtr widget = GetNearestWidget()) { + // We are in content process, figure out the value from + // the sizemode of the puppet widget. + return widget->SizeMode() == nsSizeMode_Fullscreen; + } + return false; } nsCOMPtr window = rootItem->GetWindow(); diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 3d59b7ae44..8b407a390d 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1504,7 +1504,7 @@ public: bool WindowExists(const nsAString& aName, bool aLookForCallerOnJSStack); already_AddRefed GetMainWidget(); - nsIWidget* GetNearestWidget(); + nsIWidget* GetNearestWidget() const; void Freeze() { diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 1a3d4f71e9..8653076941 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -112,9 +112,9 @@ const size_t gStackSize = 8192; #define NS_FULL_GC_DELAY 60000 // ms -// The amount of time to wait from the user being idle to starting a shrinking -// GC. -#define NS_SHRINKING_GC_DELAY 15000 // ms +// The default amount of time to wait from the user being idle to starting a +// shrinking GC. +#define NS_DEAULT_INACTIVE_GC_DELAY 300000 // ms // Maximum amount of time that should elapse between incremental GC slices #define NS_INTERSLICE_GC_DELAY 100 // ms @@ -221,6 +221,7 @@ static bool sGCOnMemoryPressure; // after NS_SHRINKING_GC_DELAY ms later, if the appropriate pref is set. static bool sCompactOnUserInactive; +static uint32_t sCompactOnUserInactiveDelay = NS_DEAULT_INACTIVE_GC_DELAY; static bool sIsCompactingOnUserInactive = false; // In testing, we call RunNextCollectorTimer() to ensure that the collectors are run more @@ -2097,7 +2098,7 @@ nsJSContext::PokeShrinkingGC() } sShrinkingGCTimer->InitWithFuncCallback(ShrinkingGCTimerFired, nullptr, - NS_SHRINKING_GC_DELAY, + sCompactOnUserInactiveDelay, nsITimer::TYPE_ONE_SHOT); } @@ -2860,6 +2861,10 @@ nsJSContext::EnsureStatics() "javascript.options.compact_on_user_inactive", true); + Preferences::AddUintVarCache(&sCompactOnUserInactiveDelay, + "javascript.options.compact_on_user_inactive_delay", + NS_DEAULT_INACTIVE_GC_DELAY); + nsIObserver* observer = new nsJSEnvironmentObserver(); obs->AddObserver(observer, "memory-pressure", false); obs->AddObserver(observer, "user-interaction-inactive", false); diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 97ab3f6e78..d18b28cc29 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -383,7 +383,7 @@ public: /** * Get the docshell in this window. */ - nsIDocShell *GetDocShell() + nsIDocShell *GetDocShell() const { if (mOuterWindow) { return mOuterWindow->mDocShell; diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index f34521706f..186a777e10 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -2984,14 +2984,6 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable& aBody) if (scheme.LowerCaseEqualsLiteral("app") || scheme.LowerCaseEqualsLiteral("jar")) { mIsMappedArrayBuffer = true; - if (!XRE_IsParentProcess()) { - nsCOMPtr jarChannel = do_QueryInterface(mChannel); - // For memory mapping from child process, we need to get file - // descriptor of the JAR file opened remotely on the parent proess. - // Set this to make sure that file descriptor can be obtained by - // child process. - jarChannel->EnsureChildFd(); - } } } } diff --git a/dom/base/test/file_websocket_permessage_deflate_params_wsh.py b/dom/base/test/file_websocket_permessage_deflate_params_wsh.py new file mode 100644 index 0000000000..36169f4c28 --- /dev/null +++ b/dom/base/test/file_websocket_permessage_deflate_params_wsh.py @@ -0,0 +1,23 @@ +from mod_pywebsocket import msgutil +from mod_pywebsocket import common + +def web_socket_do_extra_handshake(request): + deflate_found = False + + if request.ws_extension_processors is not None: + for extension_processor in request.ws_extension_processors: + if extension_processor.name() == "deflate": + extension_processor.set_client_no_context_takeover(True) + deflate_found = True + + if deflate_found is False: + raise ValueError('deflate extension processor not found') + +def web_socket_transfer_data(request): + while True: + rcvd = msgutil.receive_message(request) + opcode = request.ws_stream.get_last_received_opcode() + if (opcode == common.OPCODE_BINARY): + msgutil.send_message(request, rcvd, binary=True) + elif (opcode == common.OPCODE_TEXT): + msgutil.send_message(request, rcvd) diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index 92ddcbc867..1ad4e0921a 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -192,6 +192,7 @@ support-files = file_websocket_permessage_deflate_wsh.py file_websocket_permessage_deflate_disabled_wsh.py file_websocket_permessage_deflate_rejected_wsh.py + file_websocket_permessage_deflate_params_wsh.py file_websocket_wsh.py file_x-frame-options_main.html file_x-frame-options_page.sjs diff --git a/dom/base/test/test_websocket_permessage_deflate.html b/dom/base/test/test_websocket_permessage_deflate.html index 83504b6c52..5c40600c48 100644 --- a/dom/base/test/test_websocket_permessage_deflate.html +++ b/dom/base/test/test_websocket_permessage_deflate.html @@ -25,7 +25,10 @@ tests = [ // disable PMCE [ false, false, "ws://mochi.test:8888/tests/dom/base/test/file_websocket_permessage_deflate_disabled" ], // server rejects offered PMCE - [ true, false, "ws://mochi.test:8888/tests/dom/base/test/file_websocket_permessage_deflate_rejected" ] ] + [ true, false, "ws://mochi.test:8888/tests/dom/base/test/file_websocket_permessage_deflate_rejected" ], + // server returns parameters in the handshake + [ true, true, "ws://mochi.test:8888/tests/dom/base/test/file_websocket_permessage_deflate_params" ] +] function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); diff --git a/dom/broadcastchannel/BroadcastChannel.h b/dom/broadcastchannel/BroadcastChannel.h index 9af19fa4da..7da0f4af81 100644 --- a/dom/broadcastchannel/BroadcastChannel.h +++ b/dom/broadcastchannel/BroadcastChannel.h @@ -105,6 +105,11 @@ private: void UpdateMustKeepAlive(); + bool IsCertainlyAliveForCC() const override + { + return mIsKeptAlive; + } + nsRefPtr mActor; nsTArray> mPendingMessages; diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp index bb053118d3..60a2fd20e1 100644 --- a/dom/events/DOMEventTargetHelper.cpp +++ b/dom/events/DOMEventTargetHelper.cpp @@ -48,10 +48,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(DOMEventTargetHelper) - if (tmp->IsBlack()) { + if (tmp->IsBlack() || tmp->IsCertainlyAliveForCC()) { if (tmp->mListenerManager) { tmp->mListenerManager->MarkForCC(); } + if (!tmp->IsBlack() && tmp->PreservingWrapper()) { + // This marks the wrapper black. + tmp->GetWrapper(); + } return true; } NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END diff --git a/dom/events/DOMEventTargetHelper.h b/dom/events/DOMEventTargetHelper.h index 60e1f7d405..126dfe89de 100644 --- a/dom/events/DOMEventTargetHelper.h +++ b/dom/events/DOMEventTargetHelper.h @@ -167,6 +167,14 @@ protected: nsresult WantsUntrusted(bool* aRetVal); + // If this method returns true your object is kept alive until it returns + // false. You can use this method instead using + // NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN macro. + virtual bool IsCertainlyAliveForCC() const + { + return false; + } + nsRefPtr mListenerManager; // Make |event| trusted and dispatch |aEvent| to |this|. nsresult DispatchTrustedEvent(nsIDOMEvent* aEvent); diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 038d97b8de..d2c32d65aa 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -510,6 +510,11 @@ FetchDriver::HttpFetch(bool aCORSFlag, bool aCORSPreflightFlag, bool aAuthentica if (httpChan) { nsCOMPtr internalChan = do_QueryInterface(httpChan); internalChan->ForceNoIntercept(); + } else { + nsCOMPtr jarChannel = do_QueryInterface(chan); + // If it is not an http channel, it has to be a jar one. + MOZ_ASSERT(jarChannel); + jarChannel->ForceNoIntercept(); } } diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 94d8e01e03..aa5e69481d 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -1075,6 +1075,8 @@ BlobDataFromBlobImpl(BlobImpl* aBlobImpl, BlobData& aBlobData) const nsTArray>* subBlobs = aBlobImpl->GetSubBlobImpls(); if (subBlobs) { + MOZ_ASSERT(subBlobs->Length()); + aBlobData = nsTArray(); nsTArray& subBlobDatas = aBlobData.get_ArrayOfBlobData(); @@ -1098,8 +1100,6 @@ BlobDataFromBlobImpl(BlobImpl* aBlobImpl, BlobData& aBlobData) return; } - MOZ_ASSERT(aBlobImpl->IsMemoryFile()); - ErrorResult rv; nsCOMPtr inputStream; aBlobImpl->GetInternalStream(getter_AddRefs(inputStream), rv); diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index e6e99169a0..9173b585c4 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -66,6 +66,7 @@ using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h"; using struct mozilla::OwningSerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h"; using mozilla::EventMessage from "mozilla/EventForwards.h"; using nsEventStatus from "mozilla/EventForwards.h"; +using nsSizeMode from "nsIWidgetListener.h"; namespace mozilla { namespace dom { @@ -566,7 +567,7 @@ child: CacheFileDescriptor(nsString path, FileDescriptor fd); - UpdateDimensions(CSSRect rect, CSSSize size, + UpdateDimensions(CSSRect rect, CSSSize size, nsSizeMode sizeMode, ScreenOrientationInternal orientation, LayoutDeviceIntPoint chromeDisp) compressall; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7024c69103..95874e1461 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -543,22 +543,6 @@ TabChild::Create(nsIContentChild* aManager, return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr; } -class TabChildSetAllowedTouchBehaviorCallback : public SetAllowedTouchBehaviorCallback { -public: - explicit TabChildSetAllowedTouchBehaviorCallback(TabChild* aTabChild) - : mTabChild(do_GetWeakReference(static_cast(aTabChild))) - {} - - void Run(uint64_t aInputBlockId, const nsTArray& aFlags) const override { - if (nsCOMPtr tabChild = do_QueryReferent(mTabChild)) { - static_cast(tabChild.get())->SendSetAllowedTouchBehavior(aInputBlockId, aFlags); - } - } - -private: - nsWeakPtr mTabChild; -}; - class TabChildContentReceivedInputBlockCallback : public ContentReceivedInputBlockCallback { public: explicit TabChildContentReceivedInputBlockCallback(TabChild* aTabChild) @@ -592,7 +576,6 @@ TabChild::TabChild(nsIContentChild* aManager, , mOrientation(eScreenOrientation_PortraitPrimary) , mUpdateHitRegion(false) , mIgnoreKeyPressEvent(false) - , mSetAllowedTouchBehaviorCallback(new TabChildSetAllowedTouchBehaviorCallback(this)) , mHasValidInnerSize(false) , mDestroyed(false) , mUniqueId(aTabId) @@ -608,6 +591,15 @@ TabChild::TabChild(nsIContentChild* aManager, // check the other conditions necessary for enabling APZ. mAsyncPanZoomEnabled = gfxPlatform::AsyncPanZoomEnabled(); + nsWeakPtr weakPtrThis(do_GetWeakReference(static_cast(this))); // for capture by the lambda + mSetAllowedTouchBehaviorCallback = [weakPtrThis](uint64_t aInputBlockId, + const nsTArray& aFlags) + { + if (nsCOMPtr tabChild = do_QueryReferent(weakPtrThis)) { + static_cast(tabChild.get())->SendSetAllowedTouchBehavior(aInputBlockId, aFlags); + } + }; + // preloaded TabChild should not be added to child map if (mUniqueId) { MOZ_ASSERT(NestedTabChildMap().find(mUniqueId) == NestedTabChildMap().end()); @@ -1694,6 +1686,7 @@ TabChild::RecvShow(const ScreenIntSize& aSize, bool TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, + const nsSizeMode& sizeMode, const ScreenOrientationInternal& orientation, const LayoutDeviceIntPoint& chromeDisp) { @@ -1720,6 +1713,7 @@ TabChild::RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, baseWin->SetPositionAndSize(0, 0, screenSize.width, screenSize.height, true); + mPuppetWidget->SetSizeMode(sizeMode); mPuppetWidget->Resize(screenRect.x + chromeDisp.x, screenRect.y + chromeDisp.y, screenSize.width, screenSize.height, true); diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index eeeb33f59c..38ff2d39de 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -32,6 +32,7 @@ #include "mozilla/EventDispatcher.h" #include "mozilla/EventForwards.h" #include "mozilla/layers/CompositorTypes.h" +#include "mozilla/layers/APZCCallbackHelper.h" #include "nsIWebBrowserChrome3.h" #include "mozilla/dom/ipc/IdType.h" #include "AudioChannelService.h" @@ -49,7 +50,6 @@ namespace layers { class APZEventState; class ImageCompositeNotification; struct SetTargetAPZCCallback; -struct SetAllowedTouchBehaviorCallback; } // namespace layers namespace widget { @@ -303,6 +303,7 @@ public: const bool& aParentIsActive) override; virtual bool RecvUpdateDimensions(const CSSRect& rect, const CSSSize& size, + const nsSizeMode& sizeMode, const ScreenOrientationInternal& orientation, const LayoutDeviceIntPoint& chromeDisp) override; virtual bool RecvUpdateFrame(const layers::FrameMetrics& aFrameMetrics) override; @@ -629,7 +630,7 @@ private: bool mIgnoreKeyPressEvent; nsRefPtr mAPZEventState; - nsRefPtr mSetAllowedTouchBehaviorCallback; + SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback; bool mHasValidInnerSize; bool mDestroyed; // Position of tab, relative to parent widget (typically the window) diff --git a/dom/ipc/TabMessageUtils.h b/dom/ipc/TabMessageUtils.h index 2138b20ae6..ba390c24e1 100644 --- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -84,6 +84,13 @@ struct ParamTraits nsEventStatus_eSentinel> { }; +template<> +struct ParamTraits + : public ContiguousEnumSerializer +{ }; + } // namespace IPC #endif diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 0ef3bbe47b..d1d3325287 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1072,7 +1072,9 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const ScreenIntSize& size) CSSRect unscaledRect = devicePixelRect / widgetScale; CSSSize unscaledSize = devicePixelSize / widgetScale; - unused << SendUpdateDimensions(unscaledRect, unscaledSize, orientation, chromeOffset); + unused << SendUpdateDimensions(unscaledRect, unscaledSize, + widget->SizeMode(), + orientation, chromeOffset); } } diff --git a/dom/messagechannel/MessagePort.h b/dom/messagechannel/MessagePort.h index ede640ba6a..28b2920c20 100644 --- a/dom/messagechannel/MessagePort.h +++ b/dom/messagechannel/MessagePort.h @@ -76,7 +76,7 @@ public: NS_DECL_NSIOBSERVER NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MessagePort, - DOMEventTargetHelper) + MessagePortBase) static already_AddRefed Create(nsPIDOMWindow* aWindow, const nsID& aUUID, @@ -177,6 +177,11 @@ private: // We release the object when the port is closed or disentangled. void UpdateMustKeepAlive(); + bool IsCertainlyAliveForCC() const override + { + return mIsKeptAlive; + } + nsAutoPtr mWorkerFeature; nsRefPtr mDispatchRunnable; diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index 498bb6b525..31657ae90c 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -1603,7 +1603,7 @@ PromiseWorkerProxy::GetWorkerPromise() const { #ifdef DEBUG - WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); + workers::WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); worker->AssertIsOnWorkerThread(); #endif diff --git a/dom/promise/PromiseCallback.h b/dom/promise/PromiseCallback.h index 175ed05553..06970bfcfb 100644 --- a/dom/promise/PromiseCallback.h +++ b/dom/promise/PromiseCallback.h @@ -125,7 +125,7 @@ private: JS::Heap mGlobal; }; -// NativePromiseCallback wraps a NativePromiseHandler. +// NativePromiseCallback wraps a PromiseNativeHandler. class NativePromiseCallback final : public PromiseCallback { public: diff --git a/dom/workers/test/1158031.html b/dom/workers/test/1158031.html new file mode 100644 index 0000000000..6d896bc466 --- /dev/null +++ b/dom/workers/test/1158031.html @@ -0,0 +1,11 @@ + + + diff --git a/dom/workers/test/crashtests.list b/dom/workers/test/crashtests.list index 02d2e6251c..fb643291a0 100644 --- a/dom/workers/test/crashtests.list +++ b/dom/workers/test/crashtests.list @@ -1 +1,2 @@ load 943516.html +load 1158031.html diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 1cce2be322..274942cc23 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -773,13 +773,13 @@ APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification( nsIWidget* aWidget, const WidgetTouchEvent& aEvent, uint64_t aInputBlockId, - const nsRefPtr& aCallback) + const SetAllowedTouchBehaviorCallback& aCallback) { nsTArray flags; for (uint32_t i = 0; i < aEvent.touches.Length(); i++) { flags.AppendElement(widget::ContentHelper::GetAllowedTouchBehavior(aWidget, aEvent.touches[i]->mRefPoint)); } - aCallback->Run(aInputBlockId, flags); + aCallback(aInputBlockId, flags); } void diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index 6e476530b1..a6a145ed01 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -8,6 +8,7 @@ #include "FrameMetrics.h" #include "mozilla/EventForwards.h" +#include "mozilla/Function.h" #include "mozilla/layers/APZUtils.h" #include "nsIDOMWindowUtils.h" @@ -22,15 +23,8 @@ template class nsRefPtr; namespace mozilla { namespace layers { -/* A base class for callbacks to be passed to - * APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification. */ -struct SetAllowedTouchBehaviorCallback { -public: - NS_INLINE_DECL_REFCOUNTING(SetAllowedTouchBehaviorCallback) - virtual void Run(uint64_t aInputBlockId, const nsTArray& aFlags) const = 0; -protected: - virtual ~SetAllowedTouchBehaviorCallback() {} -}; +typedef Function&)> + SetAllowedTouchBehaviorCallback; /* This class contains some helper methods that facilitate implementing the GeckoContentController callback interface required by the AsyncPanZoomController. @@ -159,7 +153,7 @@ public: static void SendSetAllowedTouchBehaviorNotification(nsIWidget* aWidget, const WidgetTouchEvent& aEvent, uint64_t aInputBlockId, - const nsRefPtr& aCallback); + const SetAllowedTouchBehaviorCallback& aCallback); /* Notify content of a mouse scroll testing event. */ static void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent); diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 91a2026112..fbff0ebb33 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -131,7 +131,10 @@ TextureHost::SendDeleteIPDLActor(PTextureParent* actor) TextureHost* TextureHost::AsTextureHost(PTextureParent* actor) { - return actor? static_cast(actor)->mTextureHost : nullptr; + if (!actor) { + return nullptr; + } + return static_cast(actor)->mTextureHost; } PTextureParent* diff --git a/layout/base/AccessibleCaret.cpp b/layout/base/AccessibleCaret.cpp index e2704416c1..ae363b435d 100644 --- a/layout/base/AccessibleCaret.cpp +++ b/layout/base/AccessibleCaret.cpp @@ -8,6 +8,7 @@ #include "AccessibleCaretLogger.h" #include "mozilla/Preferences.h" +#include "mozilla/ToString.h" #include "nsCanvasFrame.h" #include "nsCaret.h" #include "nsDOMTokenList.h" @@ -26,6 +27,29 @@ using namespace dom; NS_IMPL_ISUPPORTS(AccessibleCaret::DummyTouchListener, nsIDOMEventListener) +float AccessibleCaret::sWidth = 0.0f; +float AccessibleCaret::sHeight = 0.0f; +float AccessibleCaret::sMarginLeft = 0.0f; +float AccessibleCaret::sBarWidth = 0.0f; + +std::ostream& +operator<<(std::ostream& aStream, const AccessibleCaret::Appearance& aAppearance) +{ + using Appearance = AccessibleCaret::Appearance; + +#define AC_PROCESS_APPEARANCE_TO_STREAM(e) case(e): aStream << #e; break; + switch (aAppearance) { + AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::None); + AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Normal); + AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::NormalNotShown); + AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Left); + AC_PROCESS_APPEARANCE_TO_STREAM(Appearance::Right); + } +#undef AC_PROCESS_APPEARANCE_TO_STREAM + + return aStream; +} + // ----------------------------------------------------------------------------- // Implementation of AccessibleCaret methods @@ -40,6 +64,15 @@ AccessibleCaret::AccessibleCaret(nsIPresShell* aPresShell) MOZ_ASSERT(mPresShell->GetCanvasFrame()->GetCustomContentContainer()); InjectCaretElement(mPresShell->GetDocument()); + + static bool prefsAdded = false; + if (!prefsAdded) { + Preferences::AddFloatVarCache(&sWidth, "layout.accessiblecaret.width"); + Preferences::AddFloatVarCache(&sHeight, "layout.accessiblecaret.height"); + Preferences::AddFloatVarCache(&sMarginLeft, "layout.accessiblecaret.margin-left"); + Preferences::AddFloatVarCache(&sBarWidth, "layout.accessiblecaret.bar.width"); + prefsAdded = true; + } } AccessibleCaret::~AccessibleCaret() @@ -61,6 +94,9 @@ AccessibleCaret::SetAppearance(Appearance aAppearance) CaretElement()->ClassList()->Add(AppearanceString(aAppearance), rv); MOZ_ASSERT(!rv.Failed(), "Add new appearance failed!"); + AC_LOG("%s: %s -> %s", __FUNCTION__, ToString(mAppearance).c_str(), + ToString(aAppearance).c_str()); + mAppearance = aAppearance; // Need to reset rect since the cached rect will be compared in SetPosition. @@ -215,13 +251,13 @@ AccessibleCaret::SetPosition(nsIFrame* aFrame, int32_t aOffset) mImaginaryCaretRect = imaginaryCaretRect; - // SetCaretElementPosition() and SetSelectionBarElementPosition() require the + // SetCaretElementStyle() and SetSelectionBarElementStyle() require the // input rect relative to container frame. nsRect imaginaryCaretRectInContainerFrame = imaginaryCaretRectInFrame; nsLayoutUtils::TransformRect(aFrame, CustomContentContainerFrame(), imaginaryCaretRectInContainerFrame); - SetCaretElementPosition(imaginaryCaretRectInContainerFrame); - SetSelectionBarElementPosition(imaginaryCaretRectInContainerFrame); + SetCaretElementStyle(imaginaryCaretRectInContainerFrame); + SetSelectionBarElementStyle(imaginaryCaretRectInContainerFrame); return PositionChangedResult::Changed; } @@ -236,7 +272,7 @@ AccessibleCaret::CustomContentContainerFrame() const } void -AccessibleCaret::SetCaretElementPosition(const nsRect& aRect) +AccessibleCaret::SetCaretElementStyle(const nsRect& aRect) { nsPoint position = CaretElementPosition(aRect); nsAutoString styleStr; @@ -244,6 +280,12 @@ AccessibleCaret::SetCaretElementPosition(const nsRect& aRect) nsPresContext::AppUnitsToIntCSSPixels(position.x), nsPresContext::AppUnitsToIntCSSPixels(position.y)); + float zoomLevel = GetZoomLevel(); + styleStr.AppendPrintf(" width: %.2fpx; height: %.2fpx; margin-left: %.2fpx", + sWidth / zoomLevel, + sHeight / zoomLevel, + sMarginLeft / zoomLevel); + ErrorResult rv; CaretElement()->SetAttribute(NS_LITERAL_STRING("style"), styleStr, rv); MOZ_ASSERT(!rv.Failed()); @@ -252,13 +294,16 @@ AccessibleCaret::SetCaretElementPosition(const nsRect& aRect) } void -AccessibleCaret::SetSelectionBarElementPosition(const nsRect& aRect) +AccessibleCaret::SetSelectionBarElementStyle(const nsRect& aRect) { int32_t height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height); nsAutoString barStyleStr; barStyleStr.AppendPrintf("margin-top: -%dpx; height: %dpx;", height, height); + float zoomLevel = GetZoomLevel(); + barStyleStr.AppendPrintf(" width: %.2fpx;", sBarWidth / zoomLevel); + ErrorResult rv; SelectionBarElement()->SetAttribute(NS_LITERAL_STRING("style"), barStyleStr, rv); MOZ_ASSERT(!rv.Failed()); @@ -266,4 +311,16 @@ AccessibleCaret::SetSelectionBarElementPosition(const nsRect& aRect) AC_LOG("Set bar style: %s", NS_ConvertUTF16toUTF8(barStyleStr).get()); } +float +AccessibleCaret::GetZoomLevel() +{ + // Full zoom on desktop. + float fullZoom = mPresShell->GetPresContext()->GetFullZoom(); + + // Pinch-zoom on B2G. + float resolution = mPresShell->GetCumulativeResolution(); + + return fullZoom * resolution; +} + } // namespace mozilla diff --git a/layout/base/AccessibleCaret.h b/layout/base/AccessibleCaret.h index 5d6f95bebb..3a451a35df 100644 --- a/layout/base/AccessibleCaret.h +++ b/layout/base/AccessibleCaret.h @@ -129,8 +129,11 @@ public: private: // Argument aRect should be relative to CustomContentContainerFrame(). - void SetCaretElementPosition(const nsRect& aRect); - void SetSelectionBarElementPosition(const nsRect& aRect); + void SetCaretElementStyle(const nsRect& aRect); + void SetSelectionBarElementStyle(const nsRect& aRect); + + // Get current zoom level. + float GetZoomLevel(); // Element which contains the caret image for 'Contains' test. dom::Element* CaretImageElement() const @@ -202,6 +205,12 @@ private: // the caret. nsRefPtr mDummyTouchListener{new DummyTouchListener()}; + // Static class variables + static float sWidth; + static float sHeight; + static float sMarginLeft; + static float sBarWidth; + }; // class AccessibleCaret } // namespace mozilla diff --git a/layout/style/ua.css b/layout/style/ua.css index 630c41443a..748777a7cd 100644 --- a/layout/style/ua.css +++ b/layout/style/ua.css @@ -326,12 +326,6 @@ div:-moz-native-anonymous.moz-accessiblecaret > div.bar { z-index: 2147483647; } -div:-moz-native-anonymous.moz-accessiblecaret { - width: 44px; - height: 47px; - margin-left: -23px; -} - div:-moz-native-anonymous.moz-accessiblecaret > div.image { background-position: center center; background-size: 100% 100%; @@ -345,7 +339,6 @@ div:-moz-native-anonymous.moz-accessiblecaret > div.image { div:-moz-native-anonymous.moz-accessiblecaret > div.bar { margin-left: 49%; - width: 2px; background-color: #008aa0; } diff --git a/mfbt/RefPtr.h b/mfbt/RefPtr.h index f7f54c8b88..24a6e61248 100644 --- a/mfbt/RefPtr.h +++ b/mfbt/RefPtr.h @@ -16,6 +16,7 @@ #include "mozilla/Move.h" #include "mozilla/RefCounted.h" #include "mozilla/RefCountType.h" +#include "mozilla/nsRefPtr.h" #include "mozilla/TypeTraits.h" #if defined(MOZILLA_INTERNAL_API) #include "nsXPCOM.h" @@ -100,10 +101,23 @@ public: } T* get() const { return mPtr; } - operator T*() const { return mPtr; } + operator T*() const +#ifdef MOZ_HAVE_REF_QUALIFIERS + & +#endif + { return mPtr; } T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mPtr; } T& operator*() const { return *mPtr; } +#ifdef MOZ_HAVE_REF_QUALIFIERS + // Don't allow implicit conversion of temporary RefPtr to raw pointer, because + // the refcount might be one and the pointer will immediately become invalid. + operator T*() const && = delete; + + // Needed to avoid the deleted operator above + explicit operator bool() const { return !!mPtr; } +#endif + private: void assign(T* aVal) { @@ -178,23 +192,21 @@ byRef(RefPtr& aPtr) return OutParamRef(aPtr); } -/** - * Helper function to be able to conveniently write things like: - * - * already_AddRefed - * f(...) - * { - * return MakeAndAddRef(...); - * } - */ -template -already_AddRefed -MakeAndAddRef(Args&&... aArgs) -{ - RefPtr p(new T(Forward(aArgs)...)); - return p.forget(); -} - } // namespace mozilla +// Declared in nsRefPtr.h +template template +nsRefPtr::nsRefPtr(mozilla::RefPtr&& aOther) + : nsRefPtr(aOther.forget()) +{ +} + +template template +nsRefPtr& +nsRefPtr::operator=(mozilla::RefPtr&& aOther) +{ + assign_assuming_AddRef(aOther.forget().take()); + return *this; +} + #endif /* mozilla_RefPtr_h */ diff --git a/mfbt/nsRefPtr.h b/mfbt/nsRefPtr.h index a7ace2d9e5..deb8777751 100644 --- a/mfbt/nsRefPtr.h +++ b/mfbt/nsRefPtr.h @@ -7,18 +7,6 @@ #ifndef mozilla_nsRefPtr_h #define mozilla_nsRefPtr_h -#if defined(_MSC_VER) && _MSC_VER >= 1900 -# define MOZ_HAVE_REF_QUALIFIERS -#elif defined(__clang__) -// All supported Clang versions -# define MOZ_HAVE_REF_QUALIFIERS -#elif defined(__GNUC__) -# include "mozilla/Compiler.h" -# if MOZ_GCC_VERSION_AT_LEAST(4, 8, 1) -# define MOZ_HAVE_REF_QUALIFIERS -# endif -#endif - #include "mozilla/AlreadyAddRefed.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" @@ -31,6 +19,7 @@ class nsCOMPtr_helper; namespace mozilla { template class OwningNonNull; +template class RefPtr; } // namespace mozilla template @@ -46,13 +35,6 @@ private: assign_assuming_AddRef(aRawPtr); } - void** - begin_assignment() - { - assign_assuming_AddRef(0); - return reinterpret_cast(&mRawPtr); - } - void assign_assuming_AddRef(T* aNewPtr) { @@ -146,6 +128,10 @@ public: template MOZ_IMPLICIT nsRefPtr(const mozilla::OwningNonNull& aOther); + // Defined in RefPtr.h + template + MOZ_IMPLICIT nsRefPtr(mozilla::RefPtr&& aOther); + // Assignment operators nsRefPtr& @@ -206,6 +192,11 @@ public: nsRefPtr& operator=(const mozilla::OwningNonNull& aOther); + // Defined in RefPtr.h + template + nsRefPtr& + operator=(mozilla::RefPtr&& aOther); + // Other pointer operators void @@ -308,9 +299,10 @@ public: mFunction(aFunction) { } - R operator()(Args... aArgs) + template + R operator()(ActualArgs&&... aArgs) { - return ((*mRawPtr).*mFunction)(mozilla::Forward(aArgs)...); + return ((*mRawPtr).*mFunction)(mozilla::Forward(aArgs)...); } }; @@ -557,42 +549,34 @@ operator!=(U* aLhs, const nsRefPtr& aRhs) return const_cast(aLhs) != static_cast(aRhs.get()); } -namespace detail { -class nsRefPtrZero; -} - -// Comparing an |nsRefPtr| to |0| +// Comparing an |nsRefPtr| to |nullptr| template inline bool -operator==(const nsRefPtr& aLhs, ::detail::nsRefPtrZero* aRhs) -// specifically to allow |smartPtr == 0| +operator==(const nsRefPtr& aLhs, decltype(nullptr)) { - return static_cast(aLhs.get()) == reinterpret_cast(aRhs); + return aLhs.get() == nullptr; } template inline bool -operator==(::detail::nsRefPtrZero* aLhs, const nsRefPtr& aRhs) -// specifically to allow |0 == smartPtr| +operator==(decltype(nullptr), const nsRefPtr& aRhs) { - return reinterpret_cast(aLhs) == static_cast(aRhs.get()); + return nullptr == aRhs.get(); } template inline bool -operator!=(const nsRefPtr& aLhs, ::detail::nsRefPtrZero* aRhs) -// specifically to allow |smartPtr != 0| +operator!=(const nsRefPtr& aLhs, decltype(nullptr)) { - return static_cast(aLhs.get()) != reinterpret_cast(aRhs); + return aLhs.get() != nullptr; } template inline bool -operator!=(::detail::nsRefPtrZero* aLhs, const nsRefPtr& aRhs) -// specifically to allow |0 != smartPtr| +operator!=(decltype(nullptr), const nsRefPtr& aRhs) { - return reinterpret_cast(aLhs) != static_cast(aRhs.get()); + return nullptr != aRhs.get(); } /*****************************************************************************/ @@ -605,8 +589,25 @@ do_AddRef(T*&& aObj) return ref.forget(); } -#ifdef MOZ_HAVE_REF_QUALIFIERS -#undef MOZ_HAVE_REF_QUALIFIERS -#endif +namespace mozilla { + +/** + * Helper function to be able to conveniently write things like: + * + * already_AddRefed + * f(...) + * { + * return MakeAndAddRef(...); + * } + */ +template +already_AddRefed +MakeAndAddRef(Args&&... aArgs) +{ + nsRefPtr p(new T(Forward(aArgs)...)); + return p.forget(); +} + +} // namespace mozilla #endif /* mozilla_nsRefPtr_h */ diff --git a/modules/libjar/nsIJARChannel.idl b/modules/libjar/nsIJARChannel.idl index bd1977b32c..7fb6484ab4 100644 --- a/modules/libjar/nsIJARChannel.idl +++ b/modules/libjar/nsIJARChannel.idl @@ -8,7 +8,7 @@ interface nsIFile; interface nsIZipEntry; -[scriptable, builtinclass, uuid(6b438dc3-9ba0-4f5f-b83f-82e1d7b98604)] +[scriptable, builtinclass, uuid(1adea16e-aa6c-4201-8f71-e9ff0acfb52e)] interface nsIJARChannel : nsIChannel { /** @@ -36,16 +36,8 @@ interface nsIJARChannel : nsIChannel readonly attribute nsIZipEntry zipEntry; /** - * For child process, set this to make sure that a valid file descriptor of - * JAR file is always provided when calling NSPRFileDesc(). - * Must be set before Open() or AsyncOpen() to be effective. - * - * Note that the file descriptor returned by NSPRFileDesc() is duplicated - * from the original, which shares its file offset with the original. If - * the file offset is modified (ex: by lseek/read/write) on one of the - * shared descriptors, the offset is also changed for the other. - * It can be safely used only with operations that take absolute offsets, - * such as mmap/pread/pwrite. + * Force the channel to skip any chack for possible interception and + * proceed immediately to the network. */ - void ensureChildFd(); + void forceNoIntercept(); }; diff --git a/modules/libjar/nsIZipReader.idl b/modules/libjar/nsIZipReader.idl index e1c20e5788..9ca111a3a2 100644 --- a/modules/libjar/nsIZipReader.idl +++ b/modules/libjar/nsIZipReader.idl @@ -208,7 +208,7 @@ interface nsIZipReader : nsISupports //////////////////////////////////////////////////////////////////////////////// // nsIZipReaderCache -[scriptable, uuid(94ecd586-d405-4801-93d3-8ac7bef81bde)] +[scriptable, uuid(31179807-9fcd-46c4-befa-2ade209a394b)] interface nsIZipReaderCache : nsISupports { /** @@ -245,14 +245,6 @@ interface nsIZipReaderCache : nsISupports */ nsIZipReader getInnerZip(in nsIFile zipFile, in AUTF8String zipEntry); - /** - * Whether to keep NSPR file descriptor for newly opened files in the cache. - * When aMustCacheFd is enabled and a file is given, the file will be flushed - * from the cache if its file descriptor was not cached. - * Note: currently not supported on Windows platform. - */ - void setMustCacheFd(in nsIFile zipFile, in bool aMustCacheFd); - /** * Returns the cached NSPR file descriptor of the file. * Note: currently not supported on Windows platform. diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index c3c66d353a..6f2dc4071c 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -151,7 +151,7 @@ nsJAR::Open(nsIFile* zipFile) mZip = zip; return NS_OK; } - return mZip->OpenArchive(zipFile, mCache ? mCache->IsMustCacheFdEnabled() : false); + return mZip->OpenArchive(zipFile); } NS_IMETHODIMP @@ -1057,7 +1057,6 @@ NS_IMPL_ISUPPORTS(nsZipReaderCache, nsIZipReaderCache, nsIObserver, nsISupportsW nsZipReaderCache::nsZipReaderCache() : mLock("nsZipReaderCache.mLock") , mZips() - , mMustCacheFd(false) #ifdef ZIP_CACHE_HIT_RATE , mZipCacheLookups(0), @@ -1212,54 +1211,6 @@ nsZipReaderCache::GetInnerZip(nsIFile* zipFile, const nsACString &entry, return rv; } -NS_IMETHODIMP -nsZipReaderCache::SetMustCacheFd(nsIFile* zipFile, bool aMustCacheFd) -{ -#if defined(XP_WIN) - MOZ_CRASH("Not implemented"); - return NS_ERROR_NOT_IMPLEMENTED; -#else - - if (!aMustCacheFd) { - return NS_OK; - } - - if (!zipFile) { - return NS_ERROR_FAILURE; - } - - nsresult rv; - nsAutoCString uri; - rv = zipFile->GetNativePath(uri); - if (NS_FAILED(rv)) { - return rv; - } - uri.Insert(NS_LITERAL_CSTRING("file:"), 0); - - MutexAutoLock lock(mLock); - - mMustCacheFd = aMustCacheFd; - - nsRefPtr zip; - mZips.Get(uri, getter_AddRefs(zip)); - if (!zip) { - return NS_ERROR_FAILURE; - } - - // Flush the file from the cache if its file descriptor was not cached. - PRFileDesc* fd = nullptr; - zip->GetNSPRFileDesc(&fd); - if (!fd) { -#ifdef ZIP_CACHE_HIT_RATE - mZipCacheFlushes++; -#endif - zip->SetZipReaderCache(nullptr); - mZips.Remove(uri); - } - return NS_OK; -#endif /* XP_WIN */ -} - NS_IMETHODIMP nsZipReaderCache::GetFd(nsIFile* zipFile, PRFileDesc** aRetVal) { diff --git a/modules/libjar/nsJAR.h b/modules/libjar/nsJAR.h index 9420752725..f472bd94a0 100644 --- a/modules/libjar/nsJAR.h +++ b/modules/libjar/nsJAR.h @@ -198,10 +198,6 @@ public: nsresult ReleaseZip(nsJAR* reader); - bool IsMustCacheFdEnabled() { - return mMustCacheFd; - } - typedef nsRefPtrHashtable ZipsHashtable; protected: @@ -211,7 +207,6 @@ protected: mozilla::Mutex mLock; uint32_t mCacheSize; ZipsHashtable mZips; - bool mMustCacheFd; #ifdef ZIP_CACHE_HIT_RATE uint32_t mZipCacheLookups; diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index c10f88521f..f6d8a7c9f0 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -202,8 +202,8 @@ nsJARChannel::nsJARChannel() , mIsPending(false) , mIsUnsafe(true) , mOpeningRemote(false) - , mEnsureChildFd(false) , mSynthesizedStreamLength(0) + , mForceNoIntercept(false) { if (!gJarProtocolLog) gJarProtocolLog = PR_NewLogModule("nsJarProtocol"); @@ -385,9 +385,6 @@ nsJARChannel::LookupFile(bool aAllowAsync) // file descriptor here. return NS_OK; #else - if (!mEnsureChildFd) { - return NS_OK; - } PRFileDesc *fd = nullptr; jarCache->GetFd(mJarFile, &fd); if (fd) { @@ -404,13 +401,6 @@ nsJARChannel::LookupFile(bool aAllowAsync) mOpeningRemote = true; - #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) - #else - if (mEnsureChildFd && jarCache) { - jarCache->SetMustCacheFd(remoteFile, true); - } - #endif - if (gJarHandler->RemoteOpenFileInProgress(remoteFile, this)) { // JarHandler will trigger OnRemoteFileOpen() after the first // request for this file completes and we'll get a JAR cache @@ -888,7 +878,7 @@ nsJARChannel::ShouldIntercept() NS_GET_IID(nsINetworkInterceptController), getter_AddRefs(controller)); bool shouldIntercept = false; - if (controller) { + if (controller && !mForceNoIntercept) { bool isNavigation = mLoadFlags & LOAD_DOCUMENT_URI; nsresult rv = controller->ShouldPrepareForIntercept(mAppURI, isNavigation, @@ -1114,9 +1104,9 @@ nsJARChannel::GetZipEntry(nsIZipEntry **aZipEntry) } NS_IMETHODIMP -nsJARChannel::EnsureChildFd() +nsJARChannel::ForceNoIntercept() { - mEnsureChildFd = true; + mForceNoIntercept = true; return NS_OK; } @@ -1240,23 +1230,21 @@ nsJARChannel::OnRemoteFileOpenComplete(nsresult aOpenStatus) // Windows/OSX desktop builds skip remoting, we don't need file // descriptor here. #else - if (mEnsureChildFd) { - // Set file descriptor from Jar cache into remote Jar file, if it - // has not been set previously. - mozilla::AutoFDClose fd; - mJarFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd.rwget()); - if (!fd) { - nsIZipReaderCache *jarCache = gJarHandler->JarCache(); - if (!jarCache) { - rv = NS_ERROR_FAILURE; - } - PRFileDesc *jar_fd = nullptr; - jarCache->GetFd(mJarFile, &jar_fd); - // If we failed to get fd here, an error rv would be returned - // by SetRemoteNSPRFileDesc(), which would then stop the - // channel by NotifyError(). - rv = SetRemoteNSPRFileDesc(jar_fd); + // Set file descriptor from Jar cache into remote Jar file, if it + // has not been set previously. + mozilla::AutoFDClose fd; + mJarFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd.rwget()); + if (!fd) { + nsIZipReaderCache *jarCache = gJarHandler->JarCache(); + if (!jarCache) { + rv = NS_ERROR_FAILURE; } + PRFileDesc *jar_fd = nullptr; + jarCache->GetFd(mJarFile, &jar_fd); + // If we failed to get fd here, an error rv would be returned + // by SetRemoteNSPRFileDesc(), which would then stop the + // channel by NotifyError(). + rv = SetRemoteNSPRFileDesc(jar_fd); } #endif if (NS_SUCCEEDED(rv) || rv == NS_ERROR_ALREADY_OPENED) { @@ -1314,14 +1302,8 @@ nsJARChannel::OnStopRequest(nsIRequest *req, nsISupports *ctx, nsresult status) #if defined(XP_WIN) || defined(MOZ_WIDGET_COCOA) #else - if (mEnsureChildFd) { - nsIZipReaderCache *jarCache = gJarHandler->JarCache(); - if (jarCache) { - jarCache->SetMustCacheFd(mJarFile, false); - } - // To deallocate file descriptor by RemoteOpenFileChild destructor. - mJarFile = nullptr; - } + // To deallocate file descriptor by RemoteOpenFileChild destructor. + mJarFile = nullptr; #endif return NS_OK; diff --git a/modules/libjar/nsJARChannel.h b/modules/libjar/nsJARChannel.h index 5e92adeb06..59caad55f9 100644 --- a/modules/libjar/nsJARChannel.h +++ b/modules/libjar/nsJARChannel.h @@ -121,7 +121,6 @@ private: bool mIsPending; bool mIsUnsafe; bool mOpeningRemote; - bool mEnsureChildFd; mozilla::net::MemoryDownloader::Data mTempMem; nsCOMPtr mPump; @@ -133,8 +132,11 @@ private: nsCString mJarEntry; nsCString mInnerJarEntry; - nsRefPtr mSynthesizedResponsePump; - int64_t mSynthesizedStreamLength; + nsRefPtr mSynthesizedResponsePump; + int64_t mSynthesizedStreamLength; + + // True if this channel should skip any interception checks. + bool mForceNoIntercept; friend class mozilla::net::InterceptedJARChannel; }; diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index 4d734ce835..a97e1c7d38 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -171,7 +171,7 @@ nsZipHandle::nsZipHandle() NS_IMPL_ADDREF(nsZipHandle) NS_IMPL_RELEASE(nsZipHandle) -nsresult nsZipHandle::Init(nsIFile *file, bool aMustCacheFd, nsZipHandle **ret, +nsresult nsZipHandle::Init(nsIFile *file, nsZipHandle **ret, PRFileDesc **aFd) { mozilla::AutoFDClose fd; @@ -210,9 +210,7 @@ nsresult nsZipHandle::Init(nsIFile *file, bool aMustCacheFd, nsZipHandle **ret, *aFd = fd.forget(); } #else - if (aMustCacheFd) { - handle->mNSPRFileDesc = fd.forget(); - } + handle->mNSPRFileDesc = fd.forget(); #endif handle->mMap = map; handle->mFile.Init(file); @@ -267,6 +265,10 @@ nsresult nsZipHandle::GetNSPRFileDesc(PRFileDesc** aNSPRFileDesc) } *aNSPRFileDesc = mNSPRFileDesc; + if (!mNSPRFileDesc) { + return NS_ERROR_NOT_AVAILABLE; + } + return NS_OK; } @@ -305,15 +307,15 @@ nsresult nsZipArchive::OpenArchive(nsZipHandle *aZipHandle, PRFileDesc *aFd) return rv; } -nsresult nsZipArchive::OpenArchive(nsIFile *aFile, bool aMustCacheFd) +nsresult nsZipArchive::OpenArchive(nsIFile *aFile) { nsRefPtr handle; #if defined(XP_WIN) mozilla::AutoFDClose fd; - nsresult rv = nsZipHandle::Init(aFile, aMustCacheFd, getter_AddRefs(handle), + nsresult rv = nsZipHandle::Init(aFile, getter_AddRefs(handle), &fd.rwget()); #else - nsresult rv = nsZipHandle::Init(aFile, aMustCacheFd, getter_AddRefs(handle)); + nsresult rv = nsZipHandle::Init(aFile, getter_AddRefs(handle)); #endif if (NS_FAILED(rv)) return rv; diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index aafde980a9..bf6f915b2c 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -121,10 +121,9 @@ public: * Convenience function that generates nsZipHandle * * @param aFile The file used to access the zip - * @param aMustCacheFd Optional flag to keep the PRFileDesc in nsZipHandle * @return status code */ - nsresult OpenArchive(nsIFile *aFile, bool aMustCacheFd = false); + nsresult OpenArchive(nsIFile *aFile); /** * Test the integrity of items in this archive by running @@ -381,7 +380,7 @@ class nsZipHandle { friend class nsZipArchive; friend class mozilla::FileLocation; public: - static nsresult Init(nsIFile *file, bool aMustCacheFd, nsZipHandle **ret, + static nsresult Init(nsIFile *file, nsZipHandle **ret, PRFileDesc **aFd = nullptr); static nsresult Init(nsZipArchive *zip, const char *entry, nsZipHandle **ret); diff --git a/modules/libjar/test/unit/test_jarchannel.js b/modules/libjar/test/unit/test_jarchannel.js index 24458ed9d0..530ac65f45 100644 --- a/modules/libjar/test/unit/test_jarchannel.js +++ b/modules/libjar/test/unit/test_jarchannel.js @@ -277,20 +277,7 @@ if (inChild) { // Drop any JAR caches obs.notifyObservers(null, "chrome-flush-caches", null); - // Open the first channel without ensureChildFd() - var chan_first = ios.newChannel2(uri, - null, - null, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_NORMAL, - Ci.nsIContentPolicy.TYPE_OTHER) - .QueryInterface(Ci.nsIJARChannel); - chan_first.asyncOpen(new Listener(function(l) { - }), null); - - // Open multiple channels with ensureChildFd() + // Open multiple channels var num = 10; var chan = []; for (var i = 0; i < num; i++) { @@ -303,12 +290,11 @@ if (inChild) { Ci.nsILoadInfo.SEC_NORMAL, Ci.nsIContentPolicy.TYPE_OTHER) .QueryInterface(Ci.nsIJARChannel); - chan[i].ensureChildFd(); chan[i].asyncOpen(new Listener(function(l) { }), null); } - // Open the last channel with ensureChildFd() + // Open the last channel var chan_last = ios.newChannel2(uri, null, null, @@ -318,7 +304,6 @@ if (inChild) { Ci.nsILoadInfo.SEC_NORMAL, Ci.nsIContentPolicy.TYPE_OTHER) .QueryInterface(Ci.nsIJARChannel); - chan_last.ensureChildFd(); chan_last.asyncOpen(new Listener(function(l) { run_next_test(); }), null); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 3a992ce3d6..b85b676e0f 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1414,6 +1414,11 @@ pref("javascript.options.mem.log", false); pref("javascript.options.mem.notify", false); pref("javascript.options.gc_on_memory_pressure", true); pref("javascript.options.compact_on_user_inactive", true); +#ifdef NIGHTLY_BUILD +pref("javascript.options.compact_on_user_inactive_delay", 15000); // ms +#else +pref("javascript.options.compact_on_user_inactive_delay", 300000); // ms +#endif pref("javascript.options.mem.gc_high_frequency_time_limit_ms", 1000); pref("javascript.options.mem.gc_high_frequency_low_limit_mb", 100); @@ -4988,6 +4993,12 @@ pref("caret.manages-android-actionbar", false); // New implementation to unify touch-caret and selection-carets. pref("layout.accessiblecaret.enabled", false); +// CSS attributes of the AccessibleCaret in CSS pixels. +pref("layout.accessiblecaret.width", "44.0"); +pref("layout.accessiblecaret.height", "47.0"); +pref("layout.accessiblecaret.margin-left", "-23.5"); +pref("layout.accessiblecaret.bar.width", "2.0"); + // Timeout in milliseconds to hide the accessiblecaret under cursor mode while // no one touches it. Set the value to 0 to disable this feature. pref("layout.accessiblecaret.timeout_ms", 3000); diff --git a/netwerk/protocol/app/AppProtocolHandler.cpp b/netwerk/protocol/app/AppProtocolHandler.cpp index 21dd692fe6..48f892b1a0 100644 --- a/netwerk/protocol/app/AppProtocolHandler.cpp +++ b/netwerk/protocol/app/AppProtocolHandler.cpp @@ -162,11 +162,6 @@ NS_IMETHODIMP DummyChannel::GetZipEntry(nsIZipEntry* *aEntry) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP DummyChannel::EnsureChildFd() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - NS_IMETHODIMP DummyChannel::Run() { nsresult rv = mListener->OnStartRequest(this, mListenerContext); @@ -321,6 +316,11 @@ NS_IMETHODIMP DummyChannel::GetContentDispositionHeader(nsACString&) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP DummyChannel::ForceNoIntercept() +{ + return NS_OK; +} + /** * app:// protocol implementation. */ diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index 8e99bb5939..9527579fe0 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -742,7 +742,8 @@ nsCertTree::DeleteEntryObject(uint32_t index) if (certdi->mAddonInfo) { cert = certdi->mAddonInfo->mCert; } - nsCertAddonInfo *addonInfo = certdi->mAddonInfo ? certdi->mAddonInfo : nullptr; + nsCertAddonInfo* addonInfo = + certdi->mAddonInfo ? certdi->mAddonInfo.get() : nullptr; if (certdi->mTypeOfEntry == nsCertTreeDispInfo::host_port_override) { mOverrideService->ClearValidityOverride(certdi->mAsciiHost, certdi->mPort); if (addonInfo) { diff --git a/toolkit/components/places/UnifiedComplete.js b/toolkit/components/places/UnifiedComplete.js index e0129b39f7..fc0af22ad4 100644 --- a/toolkit/components/places/UnifiedComplete.js +++ b/toolkit/components/places/UnifiedComplete.js @@ -66,6 +66,11 @@ const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_TIME_MS"; // The default frecency value used when inserting matches with unknown frecency. const FRECENCY_SEARCHENGINES_DEFAULT = 1000; +// A regex that matches "single word" hostnames for whitelisting purposes. +// The hostname will already have been checked for general validity, so we +// don't need to be exhaustive here, so allow dashes anywhere. +const REGEXP_SINGLEWORD_HOST = new RegExp("^[a-z0-9-]+$", "i"); + // Sqlite result row index constants. const QUERYINDEX_QUERYTYPE = 0; const QUERYINDEX_URL = 1; @@ -998,7 +1003,7 @@ Search.prototype = { // scheme isn't specificed. _matchUnknownUrl: function* () { let flags = Ci.nsIURIFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS | - Ci.nsIURIFixup.FIXUP_FLAG_REQUIRE_WHITELISTED_HOST; + Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP; let fixupInfo = null; try { fixupInfo = Services.uriFixup.getFixupURIInfo(this._originalSearchString, @@ -1007,15 +1012,31 @@ Search.prototype = { return false; } - let uri = fixupInfo.preferredURI; + // If the URI cannot be fixed or the preferred URI would do a keyword search, + // that basically means this isn't useful to us. Note that + // fixupInfo.keywordAsSent will never be true if the keyword.enabled pref + // is false or there are no engines, so in that case we will always return + // a "visit". + if (!fixupInfo.fixedURI || fixupInfo.keywordAsSent) + return false; + + let uri = fixupInfo.fixedURI; // Check the host, as "http:///" is a valid nsIURI, but not useful to us. // But, some schemes are expected to have no host. So we check just against // schemes we know should have a host. This allows new schemes to be // implemented without us accidentally blocking access to them. let hostExpected = new Set(["http", "https", "ftp", "chrome", "resource"]); - if (!uri || (hostExpected.has(uri.scheme) && !uri.host)) + if (hostExpected.has(uri.scheme) && !uri.host) return false; + // If the result is something that looks like a single-worded hostname + // we need to check the domain whitelist to treat it as such. + if (uri.asciiHost && + REGEXP_SINGLEWORD_HOST.test(uri.asciiHost) && + !Services.uriFixup.isDomainWhitelisted(uri.asciiHost, -1)) { + return false; + } + let value = makeActionURL("visiturl", { url: uri.spec, input: this._originalSearchString, diff --git a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js index 9573b1d89e..562c254211 100644 --- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js +++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js @@ -298,11 +298,18 @@ function makeActionURI(action, params) { return NetUtil.newURI(url); } -// Hide all the search engines so they don't influence tests results. -add_task(function ensure_no_search_engines() { - let count = {}; - let engines = Services.search.getEngines(count); - for (let i = 0; i < count.value; i++) { - engines[i].hidden = true; +// Ensure we have a default search engine and the keyword.enabled preference +// set. +add_task(function ensure_search_engine() { + // keyword.enabled is necessary for the tests to see keyword searches. + Services.prefs.setBoolPref("keyword.enabled", true); + + // Remove any existing engines before adding ours. + for (let engine of Services.search.getEngines()) { + Services.search.removeEngine(engine); } + Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", + "http://s.example.com/search"); + let engine = Services.search.getEngineByName("MozSearch"); + Services.search.currentEngine = engine; }); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js b/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js index a579bbce9c..a8c1b36ea7 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_empty_search.js @@ -49,9 +49,13 @@ add_task(function* test_javascript_match() { { uri: uri4, title: "title", style: ["bookmark"] }, { uri: uri5, title: "title", style: ["bookmark"] }, { uri: uri6, title: "title", style: ["bookmark"] }, - { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, ] + { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, + { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "foo", searchQuery: "foo"}), title: "MozSearch", style: [ "action", "searchengine" ] }, + ] }); + // Note the next few tests do *not* get a search result as enable-actions + // isn't specified. do_print("Match only typed history"); yield check_autocomplete({ search: "foo ^ ~", @@ -82,7 +86,10 @@ add_task(function* test_javascript_match() { yield check_autocomplete({ search: "", searchParam: "enable-actions", - matches: [ { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, ] + matches: [ + { uri: makeActionURI("switchtab", {url: "http://t.foo/6"}), title: "title", style: [ "action,switchtab" ] }, + { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "", searchQuery: ""}), title: "MozSearch", style: [ "action", "searchengine" ] }, + ] }); Services.prefs.clearUserPref("browser.urlbar.suggest.history"); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js index 7ddf3f1b19..1167da67b0 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_alias.js @@ -3,10 +3,8 @@ add_task(function*() { - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://s.example.com/search"); - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.currentEngine = engine; + // Note that head_autocomplete.js has already added a MozSearch engine. + // Here we add another engine with a search alias. Services.search.addEngineWithDetails("AliasedMozSearch", "", "doit", "", "GET", "http://s.example.com/search"); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js index 0977fe8ebf..d0bf2ae726 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_searchEngine_current.js @@ -3,10 +3,8 @@ add_task(function*() { - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://s.example.com/search"); - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.currentEngine = engine; + // Note that head_autocomplete.js has already added a MozSearch engine. + // Here we add another engine with a search alias. Services.search.addEngineWithDetails("AliasedMozSearch", "", "doit", "", "GET", "http://s.example.com/search"); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js b/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js index 0cf47d33d9..7476a930a4 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_tabmatches.js @@ -7,11 +7,6 @@ let gTabRestrictChar = "%"; add_task(function* test_tab_matches() { - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://s.example.com/search"); - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.currentEngine = engine; - let uri1 = NetUtil.newURI("http://abc.com/"); let uri2 = NetUtil.newURI("http://xyz.net/"); let uri3 = NetUtil.newURI("about:mozilla"); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js b/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js index 0086d44ea2..50eb171510 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_visiturl.js @@ -38,10 +38,6 @@ add_task(function*() { // And hosts with no dot in them are special, due to requiring whitelisting. do_print("visit url, host matching visited host but not visited url, non-whitelisted host"); - Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET", - "http://s.example.com/search"); - let engine = Services.search.getEngineByName("MozSearch"); - Services.search.currentEngine = engine; yield PlacesTestUtils.addVisits([ { uri: NetUtil.newURI("http://mozilla/bourbon/"), title: "Mozilla Bourbon", transition: TRANSITION_TYPED }, ]); @@ -50,4 +46,19 @@ add_task(function*() { searchParam: "enable-actions", matches: [ { uri: makeActionURI("searchengine", {engineName: "MozSearch", input: "mozilla/rum", searchQuery: "mozilla/rum"}), title: "MozSearch", style: [ "action", "searchengine" ] } ] }); + + // ipv4 and ipv6 literal addresses should offer to visit. + do_print("visit url, ipv4 literal"); + yield check_autocomplete({ + search: "127.0.0.1", + searchParam: "enable-actions", + matches: [ { uri: makeActionURI("visiturl", {url: "http://127.0.0.1/", input: "127.0.0.1"}), title: "http://127.0.0.1/", style: ["action", "visiturl"] } ] + }); + + do_print("visit url, ipv6 literal"); + yield check_autocomplete({ + search: "[2001:db8::1]", + searchParam: "enable-actions", + matches: [ { uri: makeActionURI("visiturl", {url: "http://[2001:db8::1]/", input: "[2001:db8::1]"}), title: "http://[2001:db8::1]/", style: ["action", "visiturl"] } ] + }); }); diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index 182d2c6dc6..1b084ea546 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -283,7 +283,7 @@ public: NS_IMETHOD Move(double aX, double aY) override; NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate) override; - NS_IMETHOD SetSizeMode(int32_t aMode) override; + NS_IMETHOD SetSizeMode(nsSizeMode aMode) override; NS_IMETHOD HideWindowChrome(bool aShouldHide) override; virtual void PrepareForDOMFullscreenTransition() override; void EnteredFullScreen(bool aFullScreen, bool aNativeMode = true); diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 4adbbf886b..4b00c96bf3 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -1173,7 +1173,7 @@ NS_METHOD nsCocoaWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, return NS_OK; } -NS_METHOD nsCocoaWindow::SetSizeMode(int32_t aMode) +NS_METHOD nsCocoaWindow::SetSizeMode(nsSizeMode aMode) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; diff --git a/widget/gonk/HwcComposer2D.h b/widget/gonk/HwcComposer2D.h index a9d667b2db..4da7cf85cf 100644 --- a/widget/gonk/HwcComposer2D.h +++ b/widget/gonk/HwcComposer2D.h @@ -111,7 +111,7 @@ private: nsTArray mHwcLayerMap; bool mPrepared; bool mHasHWVsync; - nsRefPtr mCompositorParent; + layers::CompositorParent* mCompositorParent; Mutex mLock; }; diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 508459b17f..cf56530ffa 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -761,6 +761,16 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, return mLayerManager; } +void +nsWindow::DestroyCompositor() +{ + if (mCompositorParent && mScreen->IsPrimaryScreen()) { + // Unset CompositorParent + mComposer2D->SetCompositorParent(nullptr); + } + nsBaseWidget::DestroyCompositor(); +} + void nsWindow::BringToTop() { diff --git a/widget/gonk/nsWindow.h b/widget/gonk/nsWindow.h index 93987b186f..fda7c3e548 100644 --- a/widget/gonk/nsWindow.h +++ b/widget/gonk/nsWindow.h @@ -110,6 +110,7 @@ public: LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT, bool* aAllowRetaining = nullptr); + virtual void DestroyCompositor(); NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, const InputContextAction& aAction); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index b01159f04d..572e345df0 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -1167,7 +1167,7 @@ nsWindow::SetZIndex(int32_t aZIndex) } NS_IMETHODIMP -nsWindow::SetSizeMode(int32_t aMode) +nsWindow::SetSizeMode(nsSizeMode aMode) { nsresult rv; diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index f97a73cc78..feb3a81159 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -121,7 +121,7 @@ public: nsIWidget *aWidget, bool aActivate) override; void SetZIndex(int32_t aZIndex) override; - NS_IMETHOD SetSizeMode(int32_t aMode) override; + NS_IMETHOD SetSizeMode(nsSizeMode aMode) override; NS_IMETHOD Enable(bool aState) override; NS_IMETHOD SetFocus(bool aRaise = false) override; NS_IMETHOD GetScreenBounds(nsIntRect &aRect) override; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 888718002a..1baba3c824 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -639,17 +639,15 @@ NS_IMETHODIMP nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, // merely stores the state. // //------------------------------------------------------------------------- -NS_IMETHODIMP nsBaseWidget::SetSizeMode(int32_t aMode) +NS_IMETHODIMP +nsBaseWidget::SetSizeMode(nsSizeMode aMode) { - if (aMode == nsSizeMode_Normal || - aMode == nsSizeMode_Minimized || - aMode == nsSizeMode_Maximized || - aMode == nsSizeMode_Fullscreen) { - - mSizeMode = (nsSizeMode) aMode; - return NS_OK; - } - return NS_ERROR_ILLEGAL_VALUE; + MOZ_ASSERT(aMode == nsSizeMode_Normal || + aMode == nsSizeMode_Minimized || + aMode == nsSizeMode_Maximized || + aMode == nsSizeMode_Fullscreen); + mSizeMode = aMode; + return NS_OK; } //------------------------------------------------------------------------- @@ -882,23 +880,6 @@ nsBaseWidget::CreateRootContentController() return controller.forget(); } -class ChromeProcessSetAllowedTouchBehaviorCallback : public SetAllowedTouchBehaviorCallback { -public: - explicit ChromeProcessSetAllowedTouchBehaviorCallback(APZCTreeManager* aTreeManager) - : mTreeManager(aTreeManager) - {} - - void Run(uint64_t aInputBlockId, const nsTArray& aFlags) const override { - MOZ_ASSERT(NS_IsMainThread()); - APZThreadUtils::RunOnControllerThread(NewRunnableMethod( - mTreeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, aFlags)); - } - -private: - nsRefPtr mTreeManager; -}; - class ChromeProcessContentReceivedInputBlockCallback : public ContentReceivedInputBlockCallback { public: explicit ChromeProcessContentReceivedInputBlockCallback(APZCTreeManager* aTreeManager) @@ -925,7 +906,16 @@ void nsBaseWidget::ConfigureAPZCTreeManager() mAPZC->SetDPI(GetDPI()); mAPZEventState = new APZEventState(this, new ChromeProcessContentReceivedInputBlockCallback(mAPZC)); - mSetAllowedTouchBehaviorCallback = new ChromeProcessSetAllowedTouchBehaviorCallback(mAPZC); + + nsRefPtr treeManager = mAPZC; // for capture by the lambda + mSetAllowedTouchBehaviorCallback = [treeManager](uint64_t aInputBlockId, + const nsTArray& aFlags) + { + MOZ_ASSERT(NS_IsMainThread()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + treeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, aFlags)); + }; nsRefPtr controller = CreateRootContentController(); if (controller) { diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 7062eb8761..095347eb65 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -7,6 +7,7 @@ #include "mozilla/EventForwards.h" #include "mozilla/WidgetUtils.h" +#include "mozilla/layers/APZCCallbackHelper.h" #include "nsRect.h" #include "nsIWidget.h" #include "nsWidgetsCID.h" @@ -39,15 +40,14 @@ class APZCTreeManager; class GeckoContentController; class APZEventState; struct ScrollableLayerGuid; -struct SetAllowedTouchBehaviorCallback; -} +} // namespace layers class CompositorVsyncDispatcher; -} +} // namespace mozilla namespace base { class Thread; -} +} // namespace base // Windows specific constant indicating the maximum number of touch points the // inject api will allow. This also sets the maximum numerical value for touch @@ -124,8 +124,8 @@ public: NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate) override; - NS_IMETHOD SetSizeMode(int32_t aMode) override; - virtual int32_t SizeMode() override + NS_IMETHOD SetSizeMode(nsSizeMode aMode) override; + virtual nsSizeMode SizeMode() override { return mSizeMode; } @@ -472,7 +472,7 @@ protected: * require the compositor to be destroyed before ~nsBaseWidget is * reached (This is the case with gtk2 for instance). */ - void DestroyCompositor(); + virtual void DestroyCompositor(); void DestroyLayerManager(); void FreeShutdownObserver(); @@ -486,7 +486,7 @@ protected: nsRefPtr mCompositorVsyncDispatcher; nsRefPtr mAPZC; nsRefPtr mAPZEventState; - nsRefPtr mSetAllowedTouchBehaviorCallback; + SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback; nsRefPtr mShutdownObserver; nsRefPtr mTextEventDispatcher; nsCursor mCursor; diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 8fbfb83691..aa8c72c6ff 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -27,6 +27,7 @@ #include "mozilla/widget/IMEData.h" #include "nsDataHashtable.h" #include "nsIObserver.h" +#include "nsIWidgetListener.h" #include "FrameMetrics.h" #include "Units.h" @@ -35,7 +36,6 @@ class nsIRollupListener; class imgIContainer; class nsIContent; class ViewWrapper; -class nsIWidgetListener; class nsIntRegion; class nsIScreen; @@ -762,13 +762,13 @@ class nsIWidget : public nsISupports { * Minimize, maximize or normalize the window size. * Takes a value from nsSizeMode (see nsIWidgetListener.h) */ - NS_IMETHOD SetSizeMode(int32_t aMode) = 0; + NS_IMETHOD SetSizeMode(nsSizeMode aMode) = 0; /** * Return size mode (minimized, maximized, normalized). * Returns a value from nsSizeMode (see nsIWidgetListener.h) */ - virtual int32_t SizeMode() = 0; + virtual nsSizeMode SizeMode() = 0; /** * Enable or disable this Widget diff --git a/widget/nsIWidgetListener.h b/widget/nsIWidgetListener.h index 11ef193fe2..29b97efc40 100644 --- a/widget/nsIWidgetListener.h +++ b/widget/nsIWidgetListener.h @@ -23,7 +23,8 @@ enum nsSizeMode nsSizeMode_Normal = 0, nsSizeMode_Minimized, nsSizeMode_Maximized, - nsSizeMode_Fullscreen + nsSizeMode_Fullscreen, + nsSizeMode_Invalid }; /** diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index 7d7528327e..d62025f62d 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -1429,7 +1429,7 @@ nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, } NS_IMETHODIMP -nsWindow::SetSizeMode(int32_t aMode) +nsWindow::SetSizeMode(nsSizeMode aMode) { nsresult rv; diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h index 92320278bb..f580a2962a 100644 --- a/widget/qt/nsWindow.h +++ b/widget/qt/nsWindow.h @@ -201,7 +201,7 @@ public: NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate); - NS_IMETHOD SetSizeMode(int32_t aMode); + NS_IMETHOD SetSizeMode(nsSizeMode aMode); NS_IMETHOD GetScreenBounds(nsIntRect &aRect); NS_IMETHOD SetHasTransparentBackground(bool aTransparent); NS_IMETHOD GetHasTransparentBackground(bool& aTransparent); diff --git a/widget/uikit/nsWindow.h b/widget/uikit/nsWindow.h index cf9db39ab4..00e1c7a537 100644 --- a/widget/uikit/nsWindow.h +++ b/widget/uikit/nsWindow.h @@ -57,14 +57,14 @@ public: NS_IMETHOD Move(double aX, double aY) override; NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate) override; - NS_IMETHOD SetSizeMode(int32_t aMode) override; + NS_IMETHOD SetSizeMode(nsSizeMode aMode) override; void EnteredFullScreen(bool aFullScreen); NS_IMETHOD Resize(double aWidth, double aHeight, bool aRepaint) override; NS_IMETHOD Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override; NS_IMETHOD GetScreenBounds(nsIntRect &aRect) override; void ReportMoveEvent(); void ReportSizeEvent(); - void ReportSizeModeEvent(int32_t aMode); + void ReportSizeModeEvent(nsSizeMode aMode); CGFloat BackingScaleFactor(); void BackingScaleFactorChanged(); diff --git a/widget/uikit/nsWindow.mm b/widget/uikit/nsWindow.mm index 8417a7d77a..29e8fc9d0d 100644 --- a/widget/uikit/nsWindow.mm +++ b/widget/uikit/nsWindow.mm @@ -682,7 +682,7 @@ nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, } NS_IMETHODIMP -nsWindow::SetSizeMode(int32_t aMode) +nsWindow::SetSizeMode(nsSizeMode aMode) { if (aMode == static_cast(mSizeMode)) { return NS_OK; @@ -749,7 +749,7 @@ void nsWindow::ReportMoveEvent() NotifyWindowMoved(mBounds.x, mBounds.y); } -void nsWindow::ReportSizeModeEvent(int32_t aMode) +void nsWindow::ReportSizeModeEvent(nsSizeMode aMode) { if (mWidgetListener) { // This is terrible. diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 2bb63a79e4..a6dbfc368b 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -1621,7 +1621,8 @@ NS_METHOD nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, } // Maximize, minimize or restore the window. -NS_IMETHODIMP nsWindow::SetSizeMode(int32_t aMode) { +NS_IMETHODIMP +nsWindow::SetSizeMode(nsSizeMode aMode) { nsresult rv; diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 31874e6c85..4c8e857bc6 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -112,7 +112,7 @@ public: int32_t aHorizontal, int32_t aVertical); NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget *aWidget, bool aActivate); - NS_IMETHOD SetSizeMode(int32_t aMode); + NS_IMETHOD SetSizeMode(nsSizeMode aMode); NS_IMETHOD Enable(bool aState); virtual bool IsEnabled() const; NS_IMETHOD SetFocus(bool aRaise); diff --git a/xpcom/tests/TestNsRefPtr.cpp b/xpcom/tests/TestNsRefPtr.cpp index dfc8922f05..062e68714c 100644 --- a/xpcom/tests/TestNsRefPtr.cpp +++ b/xpcom/tests/TestNsRefPtr.cpp @@ -451,15 +451,15 @@ main() else printf("foo1p == foo2p\n"); - printf("\n### Test 7.5: can you compare a |nsCOMPtr| with NULL, 0, nullptr [!=]?\n"); - if ( foo1p != 0 ) - printf("foo1p != 0\n"); - if ( 0 != foo1p ) - printf("0 != foo1p\n"); - if ( foo1p == 0 ) - printf("foo1p == 0\n"); - if ( 0 == foo1p ) - printf("0 == foo1p\n"); + printf("\n### Test 7.5: can you compare a |nsCOMPtr| with nullptr [!=]?\n"); + if ( foo1p != nullptr ) + printf("foo1p != nullptr\n"); + if ( nullptr != foo1p ) + printf("nullptr != foo1p\n"); + if ( foo1p == nullptr ) + printf("foo1p == nullptr\n"); + if ( nullptr == foo1p ) + printf("nullptr == foo1p\n"); Foo* raw_foo2p = foo2p.get(); @@ -500,8 +500,8 @@ main() else printf("foo1p is NULL\n"); - printf("\n### Test 13: numeric pointer test?\n"); - if ( foo1p == 0 ) + printf("\n### Test 13: null pointer test?\n"); + if ( foo1p == nullptr ) printf("foo1p is NULL\n"); else printf("foo1p is not NULL\n"); diff --git a/xpfe/appshell/nsXULWindow.cpp b/xpfe/appshell/nsXULWindow.cpp index 730c58b0a0..72af755d4b 100644 --- a/xpfe/appshell/nsXULWindow.cpp +++ b/xpfe/appshell/nsXULWindow.cpp @@ -214,7 +214,7 @@ NS_IMETHODIMP nsXULWindow::SetZLevel(uint32_t aLevel) /* refuse to raise a maximized window above the normal browser level, for fear it could hide newly opened browser windows */ if (aLevel > nsIXULWindow::normalZ && mWindow) { - int32_t sizeMode = mWindow->SizeMode(); + nsSizeMode sizeMode = mWindow->SizeMode(); if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) { return NS_ERROR_FAILURE; } @@ -1190,7 +1190,7 @@ bool nsXULWindow::LoadMiscPersistentAttributesFromXUL() // sizemode windowElement->GetAttribute(MODE_ATTRIBUTE, stateString); - int32_t sizeMode = nsSizeMode_Normal; + nsSizeMode sizeMode = nsSizeMode_Normal; /* ignore request to minimize, to not confuse novices if (stateString.Equals(SIZEMODE_MINIMIZED)) sizeMode = nsSizeMode_Minimized; @@ -1506,7 +1506,7 @@ NS_IMETHODIMP nsXULWindow::SavePersistentAttributes() } if (mPersistentAttributesDirty & PAD_MISC) { - int32_t sizeMode = mWindow->SizeMode(); + nsSizeMode sizeMode = mWindow->SizeMode(); if (sizeMode != nsSizeMode_Minimized) { if (sizeMode == nsSizeMode_Maximized)