From df2987f6597bb162508086c90a43106d5c7b3163 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Thu, 23 May 2024 23:25:42 +0800 Subject: [PATCH] import changes from `dev' branch of rmottola/Arctic-Fox: - bit of Bug 1219134: P2. Use LibAV/FFmpeg logic to detect invalid pts. r=edwin (34d2a7d442) - Bug 1195018 - Support 'background_color' member in the manifest processor. r=marcosc (1451b14321) - Bug 1240490 - Fix console prefix used by the App Manifest processor. r=marcosc (e3196b53c8) - Bug 1086997 - Localize developer warnings issued by the manifest processor. r=baku (7659fc5dd6) - Bug 1258899 - teach manifest processor about dir member. r=baku (00b40c51c2) - Bug 1262739 - Remove support for splash_screens member in Manifest Processor r=mconley (bceb0d2517) - Bug 1264813 - Remove image object's density member from Web Manifest processor. r=mconley (f34da7259e) - Bug 1264816 - Drop background_color from Web manifest image object. r=mconley (40c55f7bf9) - Bug 1186908 - Return manifest members to canonical form after processing. r=mconley. (59d9a12a17) - Bug 293394 - javascript: should never execute with chrome privs. r=bz (0dcc8f146b) - bit of Bug 1153267 - part 2 (a0c5f7fda8) - Bug 1254320 - Remove SEC_NORMAL from dom/json/ . r=bz (cd068db51c) - Bug 1262590 - [e10s] AppProcessChecker.cpp has DEUBG typo preventing DEBUG messages. r=mconley (f9ffab4e57) - Bug 1263556 - Remove EmptyBlobImpl in dom/ipc/Blob.cpp, r=smaug (3f4fe63e05) - Bug 1261072 - File::GetName() should be const, r=smaug (bccd7475f1) - Bug 1257759 part.1 Use switch-case at the first message handling in PluginInstanceChild::PluginWindowProcInternal() r=m_kato (bc0d4c457e) - Bug 1257759 part.2 Separate Windows' message and related definitions from nsWindowDefs.h to mozilla/widget/WinMessages.h r=jimm (f8b5cb62f8) - Bug 1153829 - Don't use MOZ_ALWAYS_INLINE for non-inline functions. r=jimm (c0e5b26c35) - Bug 1257759 part.3 ModifierKeyState should be available in plugin module r=jimm (aa3fc81f63) - Bug 1257759 part.4 Rename WidgetGUIEvent::PluginEvent to NativeEventData for using this class to send native event from plugin process to content and/or chrome process r=smaug (49392203ad) - Bug 1255968 - Part 1: Let the callback of PeekMessages() to return a boolean to be able to break out the loop. r=dvander (d7f926ee7e) - Bug 1255968 - Part 2: Implement puppet widget's HasPendingInputEvent() for interruptible reflow to work in content process. r=bz (5a0915e650) - Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm (ad1e3ad1c0) - Bug 1252152 - Make plugin instances destroyed while that instance is on the stack crash earlier and more usefully, r=jimm (2238cc2a79) - Bug 1257759 part.6 Keep event order between keyboard events and IME events in a plugin process r=jimm (32cbe1b13e) - Bug 1257759 part.7 Add new internal events which represent key events on plugin r=smaug (161725755a) - Bug 1257759 part.8 nsXBLWindowKeyHandler should handle eKeyDownOnPlugin and eKeyUpOnPlugin events only with reserved shortcut key handlers r=smaug (aa7cd1d786) - Bug 1257759 part.9 Implement nsWindow::OnKeyEventInPluginProcess() on Windows r=jimm (245b2709e4) - Bug 1257759 part.10 PluginInstanceChild should consume WM_*CHAR messages which follow consumed WM_*KEYDOWN or WM_*KEYUP message r=jimm (db355e6a77) - Bug 1261735 (part 1) - Overhaul the atom implementation. r=froydnj,erahm. (abbed483f7) - Bug 1261735 (part 2) - Inline some {Dynamic,Static}Atom methods. r=erahm. (97b11fa656) - Bug 1261735 (part 3) - De-virtualize nsIAtom::IsStaticAtom(). r=froydnj,erahm. (4e0465a84a) - Bug 1257207 - Increase ATOM_HASHTABLE_INITIAL_LENGTH. r=froydnj. (fe663e9c77) - Bug 1261735 (part 4) - Change StaticAtomEntry::mAtom to |StaticAtom*|. r=erahm. (999fff7b8c) - Bug 1261744 - Add two missing null checks for nsStringBuffer::Alloc(). r=erahm. (dd9ef00b6a) - Bug 1266295 - Remove unnecessary compiler version checks for gcc <= 4.8.0 in xpcom. r=froydnj (b2f17f8d1a) - Bug 1259706: Add NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING macro. r=froydnj (d56a5fd48b) - just a space (1508ec768f) - Bug 1236991 - part 1: allow forwarding label direction through nsITooltipTextProvider, r=enndeakin (8d49127ffa) - Bug 1245649: Enable no-nested-ternary. r=mconley (43c7b99372) - Bug 1236991 - part 2: implement a default tooltiptextprovider in toolkit, r=enndeakin (a0a378979f) - Bug 1251032 - Send RenderFrame info down to child in BrowserFrameOpenWindow. r=kanru (aec01fcec9) - Bug 1246327 - Remove dom.always_allow_move_resize_window preference. r=jst (d06d83d596) - Bug 1158228 - merge github's readability code into m-c, rs=me (38da823ce7) - Bug 1158184 - merge recent github readability changes into m-c, rs=me (3b634d63c8) - Bug 1162917 - update readability from github repo, rs=me (29dd18a9f0) - No bug - update readability from github repo, includes fix for bug 1230050, rs=uplift-with-r+-patches-from-github (fa04927c71) - Bug 1265866 - update Readability to the latest version from github, rs=me (c89e4dbeac) - bits of Bug 1158228 (950dd3d561) - Bug 1249579 - part2 : audio competing suspend/resume methods. r=snorp, baku. (3b6ddc018d) - Bug 1266221 P1 Get devtools http service worker testing option from top window. r=bz (e8492118f0) - Bug 225910 - Use nsIURI's GetRef and GetHasRef in nsDocShell. r=bz (76da6473d4) - Bug 1261471: Remove support for getting mozIDOMWindowProxy via GetInterface. r=mrbkap (04904ed142) - Bug 1264725 - Isolate Troubleshoot.jsm (about:support) from addons with null names. r=felipe (4ebb240827) - Bug 1227730 - Support closing libnotify alerts. r=karlt,MattN (73d8b583dc) --- b2g/installer/package-manifest.in | 2 + browser/installer/package-manifest.in | 2 + docshell/base/nsDocShell.cpp | 73 +- docshell/base/nsDocShell.h | 4 +- dom/audiochannel/AudioChannelService.cpp | 3 +- dom/base/File.cpp | 14 +- dom/base/File.h | 18 +- dom/base/nsContentUtils.cpp | 26 - dom/base/nsContentUtils.h | 8 - dom/base/nsDOMWindowUtils.cpp | 20 + dom/base/nsGkAtomList.h | 2 + dom/base/nsGlobalWindow.cpp | 70 +- dom/base/nsPIDOMWindow.h | 17 +- dom/browser-element/BrowserElementParent.cpp | 15 +- dom/browser-element/BrowserElementParent.h | 13 +- dom/events/EventNameList.h | 8 + dom/events/KeyboardEvent.cpp | 4 + dom/indexedDB/FileSnapshot.h | 2 +- dom/interfaces/base/nsIDOMWindowUtils.idl | 6 + dom/interfaces/base/nsITabChild.idl | 2 + dom/ipc/AppProcessChecker.cpp | 4 +- dom/ipc/Blob.cpp | 56 +- dom/ipc/ContentChild.cpp | 5 +- dom/ipc/PBrowser.ipdl | 35 +- dom/ipc/TabChild.cpp | 24 +- dom/ipc/TabChild.h | 4 + dom/ipc/TabParent.cpp | 65 +- dom/ipc/TabParent.h | 20 +- dom/json/nsJSON.cpp | 5 +- dom/jsurl/nsJSProtocolHandler.cpp | 7 +- dom/locales/en-US/chrome/dom/dom.properties | 11 + dom/manifest/ImageObjectProcessor.jsm | 26 +- dom/manifest/ManifestProcessor.jsm | 61 +- dom/manifest/ValueExtractor.jsm | 14 +- dom/manifest/test/mochitest.ini | 4 +- ...ImageObjectProcessor_background_color.html | 84 -- .../test_ImageObjectProcessor_density.html | 57 -- .../test/test_ImageObjectProcessor_sizes.html | 20 +- .../test/test_ImageObjectProcessor_src.html | 4 - .../test/test_ManifestProcessor_dir.html | 57 ++ ...test_ManifestProcessor_splash_screens.html | 29 - .../platforms/ffmpeg/FFmpegH264Decoder.cpp | 8 + .../platforms/ffmpeg/FFmpegH264Decoder.h | 1 + dom/plugins/base/PluginPRLibrary.cpp | 13 + dom/plugins/base/PluginPRLibrary.h | 4 + dom/plugins/base/nsNPAPIPluginInstance.cpp | 17 + dom/plugins/base/nsNPAPIPluginInstance.h | 4 + dom/plugins/base/nsPluginInstanceOwner.cpp | 60 +- dom/plugins/base/nsPluginInstanceOwner.h | 25 +- dom/plugins/ipc/PPluginInstance.ipdl | 18 + dom/plugins/ipc/PluginInstanceChild.cpp | 339 +++++++- dom/plugins/ipc/PluginInstanceChild.h | 43 +- dom/plugins/ipc/PluginInstanceParent.cpp | 28 + dom/plugins/ipc/PluginInstanceParent.h | 9 + dom/plugins/ipc/PluginLibrary.h | 4 + dom/plugins/ipc/PluginModuleParent.cpp | 13 + dom/plugins/ipc/PluginModuleParent.h | 5 + .../ipc/PluginScriptableObjectChild.cpp | 14 + dom/xbl/nsXBLWindowKeyHandler.cpp | 144 +++- dom/xbl/nsXBLWindowKeyHandler.h | 7 + embedding/browser/nsCTooltipTextProvider.h | 2 + embedding/browser/nsDocShellTreeOwner.cpp | 207 +---- embedding/browser/nsDocShellTreeOwner.h | 3 +- embedding/browser/nsITooltipListener.idl | 4 +- embedding/browser/nsITooltipTextProvider.idl | 7 +- ipc/glue/MessageChannel.cpp | 6 +- ipc/glue/MessageChannel.h | 4 +- layout/base/nsLayoutUtils.cpp | 5 +- layout/base/nsPresShell.cpp | 9 +- parser/html/nsHtml5Atom.cpp | 23 +- toolkit/.eslintrc | 2 +- .../aboutmemory/content/aboutMemory.js | 4 +- .../components/alerts/nsIAlertsService.idl | 31 +- .../test/static/javascript/chai.js | 13 +- .../test/static/javascript/mocha.js | 31 +- .../test/static/javascript/prettify.js | 18 +- toolkit/components/moz.build | 1 + .../components/places/BookmarkJSONUtils.jsm | 7 +- toolkit/components/places/Bookmarks.jsm | 5 +- toolkit/components/places/PlacesBackups.jsm | 4 +- toolkit/components/places/UnifiedComplete.js | 25 +- .../components/places/tests/head_common.js | 9 +- toolkit/components/reader/JSDOMParser.js | 38 +- toolkit/components/reader/Readability.js | 224 ++++-- .../tests/unit/consumerNotifications.js | 92 ++- .../tooltiptext/TooltipTextProvider.js | 148 ++++ .../tooltiptext/TooltipTextProvider.manifest | 2 + toolkit/components/tooltiptext/moz.build | 15 + toolkit/content/tests/widgets/tree_shared.js | 24 +- toolkit/content/widgets/button.xml | 7 +- toolkit/content/widgets/datetimepicker.xml | 17 +- toolkit/content/widgets/popup.xml | 166 +--- toolkit/content/widgets/preferences.xml | 4 +- toolkit/content/widgets/tree.xml | 5 +- toolkit/modules/Geometry.jsm | 16 +- toolkit/modules/Troubleshoot.jsm | 6 +- .../modules/sessionstore/XPathGenerator.jsm | 8 +- .../internal/AddonUpdateChecker.jsm | 10 +- toolkit/mozapps/update/tests/data/shared.js | 9 +- toolkit/system/gnome/nsAlertsIconListener.cpp | 59 +- toolkit/system/gnome/nsAlertsIconListener.h | 14 +- .../system/gnome/nsSystemAlertsService.cpp | 42 +- toolkit/system/gnome/nsSystemAlertsService.h | 12 + widget/BasicEvents.h | 108 +-- widget/EventForwards.h | 2 + widget/EventMessageList.h | 7 + widget/PuppetWidget.cpp | 67 ++ widget/PuppetWidget.h | 13 + widget/TextEventDispatcher.cpp | 21 +- widget/TextEvents.h | 34 + widget/WidgetEventImpl.cpp | 2 + widget/moz.build | 1 + widget/nsBaseWidget.cpp | 8 + widget/nsGUIEventIPC.h | 22 +- widget/nsIKeyEventInPluginCallback.h | 42 + widget/nsIWidget.h | 24 + widget/windows/KeyboardLayout.cpp | 90 ++- widget/windows/KeyboardLayout.h | 58 +- widget/windows/WinMessages.h | 187 +++++ widget/windows/WinModifierKeyState.h | 58 ++ widget/windows/WinNativeEventData.h | 56 ++ widget/windows/moz.build | 3 + widget/windows/nsWindow.cpp | 41 + widget/windows/nsWindow.h | 3 + widget/windows/nsWindowDefs.h | 154 +--- xpcom/base/ErrorList.h | 12 +- xpcom/ds/nsAtomTable.cpp | 722 +++++++++--------- xpcom/ds/nsIAtom.idl | 15 +- xpcom/glue/nsISupportsImpl.h | 49 +- xpcom/glue/nsThreadUtils.h | 1 + xpcom/tests/gtest/TestAtoms.cpp | 10 +- xpfe/appshell/nsIXULBrowserWindow.idl | 7 +- 132 files changed, 3093 insertions(+), 1719 deletions(-) delete mode 100644 dom/manifest/test/test_ImageObjectProcessor_background_color.html delete mode 100644 dom/manifest/test/test_ImageObjectProcessor_density.html create mode 100644 dom/manifest/test/test_ManifestProcessor_dir.html delete mode 100644 dom/manifest/test/test_ManifestProcessor_splash_screens.html create mode 100644 toolkit/components/tooltiptext/TooltipTextProvider.js create mode 100644 toolkit/components/tooltiptext/TooltipTextProvider.manifest create mode 100644 toolkit/components/tooltiptext/moz.build create mode 100644 widget/nsIKeyEventInPluginCallback.h create mode 100644 widget/windows/WinMessages.h create mode 100644 widget/windows/WinModifierKeyState.h create mode 100644 widget/windows/WinNativeEventData.h diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 9bac8ee273..49bf298b66 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -428,6 +428,8 @@ @RESPATH@/components/nsLoginInfo.js @RESPATH@/components/nsLoginManager.js @RESPATH@/components/nsLoginManagerPrompter.js +@RESPATH@/components/TooltipTextProvider.js +@RESPATH@/components/TooltipTextProvider.manifest @RESPATH@/components/NetworkGeolocationProvider.manifest @RESPATH@/components/NetworkGeolocationProvider.js @RESPATH@/components/TVSimulatorService.js diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 47950714ac..16dd167e85 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -413,6 +413,8 @@ @RESPATH@/components/nsLoginManagerPrompter.js @RESPATH@/components/storage-json.js @RESPATH@/components/crypto-SDR.js +@RESPATH@/components/TooltipTextProvider.js +@RESPATH@/components/TooltipTextProvider.manifest @RESPATH@/components/jsconsole-clhandler.manifest @RESPATH@/components/jsconsole-clhandler.js #ifdef MOZ_DEVTOOLS diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 728e272766..d3b5e28481 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -10028,31 +10028,44 @@ nsDocShell::InternalLoad2(nsIURI* aURI, aLoadType == LOAD_HISTORY || aLoadType == LOAD_LINK) { nsCOMPtr currentURI = mCurrentURI; - // Split currentURI and aURI on the '#' character. Make sure we read - // the return values of SplitURIAtHash; if it fails, we don't want to - // allow a short-circuited navigation. - nsAutoCString curBeforeHash, curHash, newBeforeHash, newHash; - nsresult splitRv1, splitRv2; - splitRv1 = currentURI ? - nsContentUtils::SplitURIAtHash(currentURI, curBeforeHash, curHash) : - NS_ERROR_FAILURE; - splitRv2 = nsContentUtils::SplitURIAtHash(aURI, newBeforeHash, newHash); - bool sameExceptHashes = NS_SUCCEEDED(splitRv1) && - NS_SUCCEEDED(splitRv2) && - curBeforeHash.Equals(newBeforeHash); + nsAutoCString curHash, newHash; + bool curURIHasRef = false, newURIHasRef = false; + + nsresult rvURINew = aURI->GetRef(newHash); + if (NS_SUCCEEDED(rvURINew)) { + rvURINew = aURI->GetHasRef(&newURIHasRef); + } + + bool sameExceptHashes = false; + if (currentURI && NS_SUCCEEDED(rvURINew)) { + nsresult rvURIOld = currentURI->GetRef(curHash); + if (NS_SUCCEEDED(rvURIOld)) { + rvURIOld = currentURI->GetHasRef(&curURIHasRef); + } + if (NS_SUCCEEDED(rvURIOld)) { + if (NS_FAILED(currentURI->EqualsExceptRef(aURI, &sameExceptHashes))) { + sameExceptHashes = false; + } + } + } if (!sameExceptHashes && sURIFixup && currentURI && - NS_SUCCEEDED(splitRv2)) { + NS_SUCCEEDED(rvURINew)) { // Maybe aURI came from the exposable form of currentURI? nsCOMPtr currentExposableURI; rv = sURIFixup->CreateExposableURI(currentURI, getter_AddRefs(currentExposableURI)); NS_ENSURE_SUCCESS(rv, rv); - splitRv1 = nsContentUtils::SplitURIAtHash(currentExposableURI, - curBeforeHash, curHash); - sameExceptHashes = - NS_SUCCEEDED(splitRv1) && curBeforeHash.Equals(newBeforeHash); + nsresult rvURIOld = currentExposableURI->GetRef(curHash); + if (NS_SUCCEEDED(rvURIOld)) { + rvURIOld = currentExposableURI->GetHasRef(&curURIHasRef); + } + if (NS_SUCCEEDED(rvURIOld)) { + if (NS_FAILED(currentExposableURI->EqualsExceptRef(aURI, &sameExceptHashes))) { + sameExceptHashes = false; + } + } } bool historyNavBetweenSameDoc = false; @@ -10088,7 +10101,7 @@ nsDocShell::InternalLoad2(nsIURI* aURI, bool doShortCircuitedLoad = (historyNavBetweenSameDoc && mOSHE != aSHEntry) || (!aSHEntry && !aPostData && - sameExceptHashes && !newHash.IsEmpty()); + sameExceptHashes && newURIHasRef); if (doShortCircuitedLoad) { // Save the position of the scrollers. @@ -10243,7 +10256,7 @@ nsDocShell::InternalLoad2(nsIURI* aURI, // arguments it receives. But even if we don't end up scrolling, // ScrollToAnchor performs other important tasks, such as informing // the presShell that we have a new hash. See bug 680257. - rv = ScrollToAnchor(curHash, newHash, aLoadType); + rv = ScrollToAnchor(curURIHasRef, newURIHasRef, newHash, aLoadType); NS_ENSURE_SUCCESS(rv, rv); /* restore previous position of scroller(s), if we're moving @@ -10266,7 +10279,8 @@ nsDocShell::InternalLoad2(nsIURI* aURI, // reference to avoid null derefs. See bug 914521. if (win) { // Fire a hashchange event URIs differ, and only in their hashes. - bool doHashchange = sameExceptHashes && !curHash.Equals(newHash); + bool doHashchange = sameExceptHashes && + (curURIHasRef != newURIHasRef || !curHash.Equals(newHash)); if (historyNavBetweenSameDoc || doHashchange) { win->DispatchSyncPopState(); @@ -11151,8 +11165,8 @@ nsDocShell::DoChannelLoad(nsIChannel* aChannel, } nsresult -nsDocShell::ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, - uint32_t aLoadType) +nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef, + nsACString& aNewHash, uint32_t aLoadType) { if (!mCurrentURI) { return NS_OK; @@ -11174,25 +11188,20 @@ nsDocShell::ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, // current anchor and we are doing a history load. So return if we have no // new anchor, and there is no current anchor or the load is not a history // load. - if ((aCurHash.IsEmpty() || aLoadType != LOAD_HISTORY) && - aNewHash.IsEmpty()) { + if ((!aCurHasRef || aLoadType != LOAD_HISTORY) && !aNewHasRef) { return NS_OK; } - // Take the '#' off aNewHash to get the ref name. (aNewHash might be empty, - // but that's fine.) - nsDependentCSubstring newHashName(aNewHash, 1); - // Both the new and current URIs refer to the same page. We can now // browse to the hash stored in the new URI. - if (!newHashName.IsEmpty()) { + if (!aNewHash.IsEmpty()) { // anchor is there, but if it's a load from history, // we don't have any anchor jumping to do bool scroll = aLoadType != LOAD_HISTORY && aLoadType != LOAD_RELOAD_NORMAL; - char* str = ToNewCString(newHashName); + char* str = ToNewCString(aNewHash); if (!str) { return NS_ERROR_OUT_OF_MEMORY; } @@ -11234,7 +11243,7 @@ nsDocShell::ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, nsXPIDLString uStr; rv = textToSubURI->UnEscapeAndConvert(PromiseFlatCString(aCharset).get(), - PromiseFlatCString(newHashName).get(), + PromiseFlatCString(aNewHash).get(), getter_Copies(uStr)); NS_ENSURE_SUCCESS(rv, rv); @@ -11244,7 +11253,7 @@ nsDocShell::ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, // with the new URI no matter whether we actually scrolled // somewhere). // - // When newHashName contains "%00", unescaped string may be empty. + // When aNewHash contains "%00", unescaped string may be empty. // And GoToAnchor asserts if we ask it to scroll to an empty ref. shell->GoToAnchor(uStr, scroll && !uStr.IsEmpty(), nsIPresShell::SCROLL_SMOOTH_AUTO); diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index eaeb4cb903..d0027d75c9 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -377,7 +377,9 @@ protected: nsIURILoader* aURILoader, bool aBypassClassifier); - nsresult ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash, + nsresult ScrollToAnchor(bool aCurHasRef, + bool aNewHasRef, + nsACString& aNewHash, uint32_t aLoadType); // Returns true if would have called FireOnLocationChange, diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 87399953c4..a4d10167e5 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -397,7 +397,8 @@ AudioChannelService::GetState(nsPIDOMWindow* aWindow, uint32_t aAudioChannel, } *aVolume *= window->GetAudioVolume(); - *aMuted = *aMuted || window->GetAudioMuted(); + // TODO : distiguish between suspend and mute, it would be done in bug1242874. + *aMuted = *aMuted || window->GetMediaSuspended() || window->GetAudioMuted(); nsCOMPtr win = window->GetScriptableParent(); if (window == win) { diff --git a/dom/base/File.cpp b/dom/base/File.cpp index 724c281d2e..36d2abc988 100644 --- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -456,7 +456,7 @@ File::WrapObject(JSContext* aCx, JS::Handle aGivenProto) } void -File::GetName(nsAString& aFileName) +File::GetName(nsAString& aFileName) const { mImpl->GetName(aFileName); } @@ -675,7 +675,7 @@ NS_IMPL_ISUPPORTS(BlobImpl, BlobImpl) NS_IMPL_ISUPPORTS_INHERITED0(BlobImplFile, BlobImpl) void -BlobImplBase::GetName(nsAString& aName) +BlobImplBase::GetName(nsAString& aName) const { NS_ASSERTION(mIsFile, "Should only be called on files"); aName = mName; @@ -951,6 +951,11 @@ EmptyBlobImpl::CreateSlice(uint64_t aStart, uint64_t aLength, { MOZ_ASSERT(!aStart && !aLength); RefPtr impl = new EmptyBlobImpl(aContentType); + + DebugOnly isMutable; + MOZ_ASSERT(NS_SUCCEEDED(impl->GetMutable(&isMutable))); + MOZ_ASSERT(!isMutable); + return impl.forget(); } @@ -958,6 +963,11 @@ void EmptyBlobImpl::GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv) { + if (NS_WARN_IF(!aStream)) { + aRv.Throw(NS_ERROR_FAILURE); + return; + } + nsresult rv = NS_NewCStringInputStream(aStream, EmptyCString()); if (NS_WARN_IF(NS_FAILED(rv))) { aRv.Throw(rv); diff --git a/dom/base/File.h b/dom/base/File.h index a052eb8b7b..0c1825ab63 100644 --- a/dom/base/File.h +++ b/dom/base/File.h @@ -224,7 +224,7 @@ public: const ChromeFilePropertyBag& aBag, ErrorResult& aRv); - void GetName(nsAString& aName); + void GetName(nsAString& aName) const; int64_t GetLastModified(ErrorResult& aRv); @@ -256,7 +256,7 @@ public: BlobImpl() {} - virtual void GetName(nsAString& aName) = 0; + virtual void GetName(nsAString& aName) const = 0; virtual void GetPath(nsAString& aName, ErrorResult& aRv) = 0; @@ -392,7 +392,7 @@ public: mContentType.SetIsVoid(false); } - virtual void GetName(nsAString& aName) override; + virtual void GetName(nsAString& aName) const override; virtual void GetPath(nsAString& aName, ErrorResult& aRv) override; @@ -759,7 +759,17 @@ public: explicit EmptyBlobImpl(const nsAString& aContentType) : BlobImplBase(aContentType, 0 /* aLength */) - {} + { + mImmutable = true; + } + + EmptyBlobImpl(const nsAString& aName, + const nsAString& aContentType, + int64_t aLastModifiedDate) + : BlobImplBase(aName, aContentType, 0, aLastModifiedDate) + { + mImmutable = true; + } virtual void GetInternalStream(nsIInputStream** aStream, ErrorResult& aRv) override; diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 1d5cc868ed..e905cec394 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5416,32 +5416,6 @@ nsContentUtils::URIIsLocalFile(nsIURI *aURI) isFile; } -nsresult -nsContentUtils::SplitURIAtHash(nsIURI *aURI, - nsACString &aBeforeHash, - nsACString &aAfterHash) -{ - // See bug 225910 for why we can't do this using nsIURL. - - aBeforeHash.Truncate(); - aAfterHash.Truncate(); - - NS_ENSURE_ARG_POINTER(aURI); - - nsAutoCString spec; - nsresult rv = aURI->GetSpec(spec); - NS_ENSURE_SUCCESS(rv, rv); - - int32_t index = spec.FindChar('#'); - if (index == -1) { - index = spec.Length(); - } - - aBeforeHash.Assign(Substring(spec, 0, index)); - aAfterHash.Assign(Substring(spec, index)); - return NS_OK; -} - /* static */ nsIScriptContext* nsContentUtils::GetContextForEventHandlers(nsINode* aNode, diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 9163947eee..f5203376c0 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1537,14 +1537,6 @@ public: */ static bool URIIsLocalFile(nsIURI *aURI); - /** - * Given a URI, return set beforeHash to the part before the '#', and - * afterHash to the remainder of the URI, including the '#'. - */ - static nsresult SplitURIAtHash(nsIURI *aURI, - nsACString &aBeforeHash, - nsACString &aAfterHash); - /** * Get the application manifest URI for this document. The manifest URI * is specified in the manifest= attribute of the root element of the diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index e6ed9b6ef0..a19caa5e74 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3759,6 +3759,26 @@ nsDOMWindowUtils::PostRestyleSelfEvent(nsIDOMElement* aElement) return NS_OK; } +NS_IMETHODIMP +nsDOMWindowUtils::GetMediaSuspended(bool* aSuspended) +{ + nsCOMPtr window = do_QueryReferent(mWindow); + NS_ENSURE_STATE(window); + + *aSuspended = window->GetMediaSuspended(); + return NS_OK; +} + +NS_IMETHODIMP +nsDOMWindowUtils::SetMediaSuspended(bool aSuspended) +{ + nsCOMPtr window = do_QueryReferent(mWindow); + NS_ENSURE_STATE(window); + + window->SetMediaSuspended(aSuspended); + return NS_OK; +} + NS_IMETHODIMP nsDOMWindowUtils::GetAudioMuted(bool* aMuted) { diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 64ef0c8fad..f591b74014 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -831,6 +831,8 @@ GK_ATOM(onmozbrowserbeforekeydown, "onmozbrowserbeforekeydown") GK_ATOM(onmozbrowserbeforekeyup, "onmozbrowserbeforekeyup") GK_ATOM(onmozfullscreenchange, "onmozfullscreenchange") GK_ATOM(onmozfullscreenerror, "onmozfullscreenerror") +GK_ATOM(onmozkeydownonplugin, "onmozkeydownonplugin") +GK_ATOM(onmozkeyuponplugin, "onmozkeyuponplugin") GK_ATOM(onmozpointerlockchange, "onmozpointerlockchange") GK_ATOM(onmozpointerlockerror, "onmozpointerlockerror") GK_ATOM(onmoztimechange, "onmoztimechange") diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 42060c2de4..caeed4e12c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -618,7 +618,7 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindow *aOuterWindow) mMayHavePointerEnterLeaveEventListener(false), mInnerObjectsFreed(false), mIsModalContentWindow(false), - mIsActive(false), mIsBackground(false), + mIsActive(false), mIsBackground(false), mMediaSuspended(false), mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false), mDesktopModeViewport(false), mInnerWindow(nullptr), mOuterWindow(aOuterWindow), @@ -3717,6 +3717,32 @@ nsPIDOMWindow::CreatePerformanceObjectIfNeeded() } } +bool +nsPIDOMWindow::GetMediaSuspended() const +{ + if (IsInnerWindow()) { + return mOuterWindow->GetMediaSuspended(); + } + + return mMediaSuspended; +} + +void +nsPIDOMWindow::SetMediaSuspended(bool aSuspended) +{ + if (IsInnerWindow()) { + mOuterWindow->SetMediaSuspended(aSuspended); + return; + } + + if (mMediaSuspended == aSuspended) { + return; + } + + mMediaSuspended = aSuspended; + RefreshMediaElements(); +} + bool nsPIDOMWindow::GetAudioMuted() const { @@ -3782,6 +3808,28 @@ nsPIDOMWindow::RefreshMediaElements() } } +void +nsPIDOMWindow::SetServiceWorkersTestingEnabled(bool aEnabled) +{ + // Devtools should only be setting this on the top level window. Its + // ok if devtools clears the flag on clean up of nested windows, though. + // It will have no affect. +#ifdef DEBUG + nsCOMPtr topWindow = GetScriptableTop(); + MOZ_ASSERT_IF(aEnabled, this == topWindow); +#endif + mServiceWorkersTestingEnabled = aEnabled; +} + +bool +nsPIDOMWindow::GetServiceWorkersTestingEnabled() +{ + // Automatically get this setting from the top level window so that nested + // iframes get the correct devtools setting. + nsCOMPtr topWindow = GetScriptableTop(); + return topWindow->mServiceWorkersTestingEnabled; +} + bool nsPIDOMWindow::GetAudioCaptured() const { @@ -6674,10 +6722,7 @@ nsGlobalWindow::CanMoveResizeWindows(bool aCallerIsChrome) } } - // The preference is useful for the webapp runtime. Webapps should be able - // to resize or move their window. - if (mDocShell && !Preferences::GetBool("dom.always_allow_move_resize_window", - false)) { + if (mDocShell) { bool allow; nsresult rv = mDocShell->GetAllowWindowControl(&allow); if (NS_SUCCEEDED(rv) && !allow) @@ -10404,12 +10449,15 @@ nsGlobalWindow::DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI) // Make sure that aOldURI and aNewURI are identical up to the '#', and that // their hashes are different. - nsAutoCString oldBeforeHash, oldHash, newBeforeHash, newHash; - nsContentUtils::SplitURIAtHash(aOldURI, oldBeforeHash, oldHash); - nsContentUtils::SplitURIAtHash(aNewURI, newBeforeHash, newHash); - - NS_ENSURE_STATE(oldBeforeHash.Equals(newBeforeHash)); - NS_ENSURE_STATE(!oldHash.Equals(newHash)); + bool equal = false; + NS_ENSURE_STATE(NS_SUCCEEDED(aOldURI->EqualsExceptRef(aNewURI, &equal)) && equal); + nsAutoCString oldHash, newHash; + bool oldHasHash, newHasHash; + NS_ENSURE_STATE(NS_SUCCEEDED(aOldURI->GetRef(oldHash)) && + NS_SUCCEEDED(aNewURI->GetRef(newHash)) && + NS_SUCCEEDED(aOldURI->GetHasRef(&oldHasHash)) && + NS_SUCCEEDED(aNewURI->GetHasRef(&newHasHash)) && + (oldHasHash != newHasHash || !oldHash.Equals(newHash))); nsAutoCString oldSpec, newSpec; aOldURI->GetSpec(oldSpec); diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index ef310e1917..daddce96bd 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -202,6 +202,9 @@ public: virtual bool IsRunningTimeout() = 0; // Audio API + bool GetMediaSuspended() const; + void SetMediaSuspended(bool aSuspended); + bool GetAudioMuted() const; void SetAudioMuted(bool aMuted); @@ -211,17 +214,8 @@ public: bool GetAudioCaptured() const; nsresult SetAudioCapture(bool aCapture); - virtual void SetServiceWorkersTestingEnabled(bool aEnabled) - { - MOZ_ASSERT(IsOuterWindow()); - mServiceWorkersTestingEnabled = aEnabled; - } - - bool GetServiceWorkersTestingEnabled() - { - MOZ_ASSERT(IsOuterWindow()); - return mServiceWorkersTestingEnabled; - } + void SetServiceWorkersTestingEnabled(bool aEnabled); + bool GetServiceWorkersTestingEnabled(); already_AddRefed GetServiceWorkerRegistration(const nsAString& aScope); @@ -850,6 +844,7 @@ protected: // "active". Only used on outer windows. bool mIsBackground; + bool mMediaSuspended; bool mAudioMuted; float mAudioVolume; diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp index 3b48ef0ba4..ec4d46de06 100644 --- a/dom/browser-element/BrowserElementParent.cpp +++ b/dom/browser-element/BrowserElementParent.cpp @@ -23,9 +23,12 @@ #include "nsVariant.h" #include "mozilla/dom/BrowserElementDictionariesBinding.h" #include "mozilla/dom/CustomEvent.h" +#include "mozilla/layout/RenderFrameParent.h" using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::layers; +using namespace mozilla::layout; namespace { @@ -205,9 +208,12 @@ BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement, BrowserElementParent::OpenWindowResult BrowserElementParent::OpenWindowOOP(TabParent* aOpenerTabParent, TabParent* aPopupTabParent, + PRenderFrameParent* aRenderFrame, const nsAString& aURL, const nsAString& aName, - const nsAString& aFeatures) + const nsAString& aFeatures, + TextureFactoryIdentifier* aTextureFactoryIdentifier, + uint64_t* aLayersId) { // Create an iframe owned by the same document which owns openerFrameElement. nsCOMPtr openerFrameElement = aOpenerTabParent->GetOwnerElement(); @@ -241,6 +247,13 @@ BrowserElementParent::OpenWindowOOP(TabParent* aOpenerTabParent, aPopupTabParent->SetOwnerElement(popupFrameElement); popupFrameElement->AllowCreateFrameLoader(); popupFrameElement->CreateRemoteFrameLoader(aPopupTabParent); + + RenderFrameParent* rfp = static_cast(aRenderFrame); + if (!aPopupTabParent->SetRenderFrame(rfp) || + !aPopupTabParent->GetRenderFrameInfo(aTextureFactoryIdentifier, aLayersId)) { + return BrowserElementParent::OPEN_WINDOW_IGNORED; + } + return opened; } diff --git a/dom/browser-element/BrowserElementParent.h b/dom/browser-element/BrowserElementParent.h index d67481cff9..219092b250 100644 --- a/dom/browser-element/BrowserElementParent.h +++ b/dom/browser-element/BrowserElementParent.h @@ -22,6 +22,14 @@ namespace dom { class TabParent; } // namespace dom +namespace layers { +struct TextureFactoryIdentifier; +} // namespace layers + +namespace layout { +class PRenderFrameParent; +} // namespace layout + /** * BrowserElementParent implements a portion of the parent-process side of *