diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp
index 768ed5c2d70..227aff7402b 100644
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1257,7 +1257,11 @@ nsAccessibilityService::Init()
logging::CheckEnv();
#endif
- gApplicationAccessible = new ApplicationAccessibleWrap();
+ if (XRE_GetProcessType() == GeckoProcessType_Default)
+ gApplicationAccessible = new ApplicationAccessibleWrap();
+ else
+ gApplicationAccessible = new ApplicationAccessible();
+
NS_ADDREF(gApplicationAccessible); // will release in Shutdown()
#ifdef MOZ_CRASHREPORTER
@@ -1274,7 +1278,8 @@ nsAccessibilityService::Init()
gIsShutdown = false;
// Now its safe to start platform accessibility.
- PlatformInit();
+ if (XRE_GetProcessType() == GeckoProcessType_Default)
+ PlatformInit();
return true;
}
@@ -1316,7 +1321,9 @@ nsAccessibilityService::Shutdown()
gIsShutdown = true;
- PlatformShutdown();
+ if (XRE_GetProcessType() == GeckoProcessType_Default)
+ PlatformShutdown();
+
gApplicationAccessible->Shutdown();
NS_RELEASE(gApplicationAccessible);
gApplicationAccessible = nullptr;
diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js
index e7039fb9221..970fd35632a 100644
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -328,6 +328,7 @@ pref("media.eme.apiVisible", true);
pref("media.video-queue.default-size", 3);
// optimize images' memory usage
+pref("image.downscale-during-decode.enabled", true);
pref("image.decode-only-on-draw.enabled", false);
pref("image.mem.allow_locking_in_content_processes", true);
// Limit the surface cache to 1/8 of main memory or 128MB, whichever is smaller.
diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml
index 9ceb0bc6869..6ae5451e5b7 100644
--- a/b2g/config/dolphin/sources.xml
+++ b/b2g/config/dolphin/sources.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml
index 6648ddf948b..8c7320f7f80 100644
--- a/b2g/config/emulator-ics/sources.xml
+++ b/b2g/config/emulator-ics/sources.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml
index 38e7453a7d6..fdd6af7eb02 100644
--- a/b2g/config/emulator-jb/sources.xml
+++ b/b2g/config/emulator-jb/sources.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml
index d4454f31eb8..66d9616f951 100644
--- a/b2g/config/emulator-kk/sources.xml
+++ b/b2g/config/emulator-kk/sources.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/b2g/config/emulator-l/sources.xml b/b2g/config/emulator-l/sources.xml
index 617176637ad..5a78c07c293 100644
--- a/b2g/config/emulator-l/sources.xml
+++ b/b2g/config/emulator-l/sources.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml
index 6648ddf948b..8c7320f7f80 100644
--- a/b2g/config/emulator/sources.xml
+++ b/b2g/config/emulator/sources.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml
index 067e12babc8..871188c4591 100644
--- a/b2g/config/flame-kk/sources.xml
+++ b/b2g/config/flame-kk/sources.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml
index 722afd65db7..5b4036dbc61 100644
--- a/b2g/config/flame/sources.xml
+++ b/b2g/config/flame/sources.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json
index ef3cd6eb188..72750f58cbc 100644
--- a/b2g/config/gaia.json
+++ b/b2g/config/gaia.json
@@ -1,9 +1,9 @@
{
"git": {
- "git_revision": "426fe6450ab8da92bb473fef12ccb39c6c920dd0",
+ "git_revision": "83b27f522642ea573c57e882657ab5c73d4b07f4",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
- "revision": "b48088c5abd6ad5a64b9b870e52d6de14b3f2bc3",
+ "revision": "6f889f462ec6387626570bab40a0f032a205edf6",
"repo_path": "integration/gaia-central"
}
diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml
index 41cc82dedbf..bf5ca7c07fe 100644
--- a/b2g/config/nexus-4/sources.xml
+++ b/b2g/config/nexus-4/sources.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/b2g/config/nexus-5-l/sources.xml b/b2g/config/nexus-5-l/sources.xml
index f4b27484498..929cd609aaa 100644
--- a/b2g/config/nexus-5-l/sources.xml
+++ b/b2g/config/nexus-5-l/sources.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/browser/base/content/browser-eme.js b/browser/base/content/browser-eme.js
index 08e8a9c15f8..a9065a89b97 100644
--- a/browser/base/content/browser-eme.js
+++ b/browser/base/content/browser-eme.js
@@ -206,6 +206,7 @@ let gEMEHandler = {
let options = {
dismissed: true,
eventCallback: aTopic => aTopic == "swapping",
+ learnMoreURL: Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content",
};
PopupNotifications.show(browser, "drmContentPlaying", message, anchorId, mainAction, null, options);
},
diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini
index 062fcf2502c..e4e0d5b2846 100644
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -238,7 +238,7 @@ skip-if = e10s && debug
[browser_bug624734.js]
[browser_bug633691.js]
[browser_bug647886.js]
-skip-if = buildapp == 'mulet' || e10s # Bug 1093373 - Relies on browser.sessionHistory
+skip-if = buildapp == 'mulet'
[browser_bug655584.js]
[browser_bug664672.js]
[browser_bug676619.js]
diff --git a/browser/base/content/test/general/browser_bug647886.js b/browser/base/content/test/general/browser_bug647886.js
index 4a41fc6ada1..6b5bbef4944 100644
--- a/browser/base/content/test/general/browser_bug647886.js
+++ b/browser/base/content/test/general/browser_bug647886.js
@@ -1,36 +1,25 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-function test() {
- waitForExplicitFinish();
-
- gBrowser.selectedTab = gBrowser.addTab();
- gBrowser.selectedBrowser.addEventListener("load", function () {
- gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
+add_task(function* () {
+ yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
+ yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
content.history.pushState({}, "2", "2.html");
+ });
- testBackButton();
- }, true);
-
- loadURI("http://example.com");
-}
-
-function testBackButton() {
var backButton = document.getElementById("back-button");
var rect = backButton.getBoundingClientRect();
info("waiting for the history menu to open");
- backButton.addEventListener("popupshown", function (event) {
- backButton.removeEventListener("popupshown", arguments.callee, false);
-
- ok(true, "history menu opened");
- event.target.hidePopup();
- gBrowser.removeTab(gBrowser.selectedTab);
- finish();
- }, false);
-
+ let popupShownPromise = BrowserTestUtils.waitForEvent(backButton, "popupshown");
EventUtils.synthesizeMouseAtCenter(backButton, {type: "mousedown"});
EventUtils.synthesizeMouse(backButton, rect.width / 2, rect.height, {type: "mouseup"});
-}
+ let event = yield popupShownPromise;
+
+ ok(true, "history menu opened");
+
+ event.target.hidePopup();
+ gBrowser.removeTab(gBrowser.selectedTab);
+});
diff --git a/docshell/base/LoadContext.cpp b/docshell/base/LoadContext.cpp
index 1d2df187423..5631b79896f 100644
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -11,7 +11,8 @@ namespace mozilla {
NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
-LoadContext::LoadContext(nsIPrincipal* aPrincipal, nsILoadContext* aOptionalBase)
+LoadContext::LoadContext(nsIPrincipal* aPrincipal,
+ nsILoadContext* aOptionalBase)
: mTopFrameElement(nullptr)
, mNestedFrameId(0)
, mIsContent(true)
@@ -22,17 +23,18 @@ LoadContext::LoadContext(nsIPrincipal* aPrincipal, nsILoadContext* aOptionalBase
#endif
{
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aPrincipal->GetAppId(&mAppId)));
- MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
- aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement)));
+ MOZ_ALWAYS_TRUE(
+ NS_SUCCEEDED(aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement)));
if (!aOptionalBase) {
return;
}
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aOptionalBase->GetIsContent(&mIsContent)));
- MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
- aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing)));
- MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs)));
+ MOZ_ALWAYS_TRUE(
+ NS_SUCCEEDED(aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing)));
+ MOZ_ALWAYS_TRUE(
+ NS_SUCCEEDED(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs)));
}
//-----------------------------------------------------------------------------
diff --git a/docshell/base/LoadContext.h b/docshell/base/LoadContext.h
index 22fd28583da..ff0c9adfd03 100644
--- a/docshell/base/LoadContext.h
+++ b/docshell/base/LoadContext.h
@@ -53,7 +53,8 @@ public:
#ifdef DEBUG
, mIsNotNull(aToCopy.mIsNotNull)
#endif
- {}
+ {
+ }
// AppId/inBrowser arguments override those in SerializedLoadContext provided
// by child process.
@@ -70,7 +71,8 @@ public:
#ifdef DEBUG
, mIsNotNull(aToCopy.mIsNotNull)
#endif
- {}
+ {
+ }
LoadContext(dom::Element* aTopFrameElement,
uint32_t aAppId,
@@ -88,7 +90,8 @@ public:
#ifdef DEBUG
, mIsNotNull(true)
#endif
- {}
+ {
+ }
// Constructor taking reserved appId for the safebrowsing cookie.
explicit LoadContext(uint32_t aAppId)
@@ -102,7 +105,8 @@ public:
#ifdef DEBUG
, mIsNotNull(true)
#endif
- {}
+ {
+ }
// Constructor for creating a LoadContext with a given principal's appId and
// browser flag.
@@ -127,4 +131,3 @@ private:
} // namespace mozilla
#endif // LoadContext_h
-
diff --git a/docshell/base/SerializedLoadContext.cpp b/docshell/base/SerializedLoadContext.cpp
index 0c746bd2b90..f328845b64f 100644
--- a/docshell/base/SerializedLoadContext.cpp
+++ b/docshell/base/SerializedLoadContext.cpp
@@ -77,4 +77,3 @@ SerializedLoadContext::Init(nsILoadContext* aLoadContext)
}
} // namespace IPC
-
diff --git a/docshell/base/SerializedLoadContext.h b/docshell/base/SerializedLoadContext.h
index fe2fb2e4dbd..4655dca68af 100644
--- a/docshell/base/SerializedLoadContext.h
+++ b/docshell/base/SerializedLoadContext.h
@@ -72,11 +72,11 @@ struct ParamTraits
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) ||
- !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
- !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
- !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
- !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
- !ReadParam(aMsg, aIter, &aResult->mAppId) ||
+ !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
+ !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
+ !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
+ !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
+ !ReadParam(aMsg, aIter, &aResult->mAppId) ||
!ReadParam(aMsg, aIter, &aResult->mIsInBrowserElement)) {
return false;
}
@@ -88,4 +88,3 @@ struct ParamTraits
} // namespace IPC
#endif // SerializedLoadContext_h
-
diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp
index b8434f40155..5a94654535b 100644
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -26,10 +26,6 @@
using namespace mozilla;
-//*****************************************************************************
-//*** nsDSURIContentListener: Object Management
-//*****************************************************************************
-
nsDSURIContentListener::nsDSURIContentListener(nsDocShell* aDocShell)
: mDocShell(aDocShell)
, mExistingJPEGRequest(nullptr)
@@ -50,10 +46,6 @@ nsDSURIContentListener::Init()
return rv;
}
-//*****************************************************************************
-// nsDSURIContentListener::nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF(nsDSURIContentListener)
NS_IMPL_RELEASE(nsDSURIContentListener)
@@ -63,16 +55,11 @@ NS_INTERFACE_MAP_BEGIN(nsDSURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
-//*****************************************************************************
-// nsDSURIContentListener::nsIURIContentListener
-//*****************************************************************************
-
NS_IMETHODIMP
nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
{
- // If mDocShell is null here, that means someone's starting a load
- // in our docshell after it's already been destroyed. Don't let
- // that happen.
+ // If mDocShell is null here, that means someone's starting a load in our
+ // docshell after it's already been destroyed. Don't let that happen.
if (!mDocShell) {
*aAbortOpen = true;
return NS_OK;
@@ -188,17 +175,16 @@ nsDSURIContentListener::IsPreferred(const char* aContentType,
aDesiredContentType,
aCanHandle);
}
- // we used to return false here if we didn't have a parent properly
- // registered at the top of the docshell hierarchy to dictate what
- // content types this docshell should be a preferred handler for. But
- // this really makes it hard for developers using iframe or browser tags
- // because then they need to make sure they implement
- // nsIURIContentListener otherwise all link clicks would get sent to
- // another window because we said we weren't the preferred handler type.
- // I'm going to change the default now...if we can handle the content,
- // and someone didn't EXPLICITLY set a nsIURIContentListener at the top
- // of our docshell chain, then we'll now always attempt to process the
- // content ourselves...
+ // we used to return false here if we didn't have a parent properly registered
+ // at the top of the docshell hierarchy to dictate what content types this
+ // docshell should be a preferred handler for. But this really makes it hard
+ // for developers using iframe or browser tags because then they need to make
+ // sure they implement nsIURIContentListener otherwise all link clicks would
+ // get sent to another window because we said we weren't the preferred handler
+ // type. I'm going to change the default now... if we can handle the content,
+ // and someone didn't EXPLICITLY set a nsIURIContentListener at the top of our
+ // docshell chain, then we'll now always attempt to process the content
+ // ourselves...
return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
}
diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp
index 97b5745dc94..aa10be1acd3 100644
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -970,7 +970,8 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString& aURIString,
// If we're at the end of the string or this is the first slash,
// check if the thing before the slash looks like ipv4:
- if ((iter.size_forward() == 1 || (lastSlashLoc == uint32_t(kNotFound) && *iter == '/')) &&
+ if ((iter.size_forward() == 1 ||
+ (lastSlashLoc == uint32_t(kNotFound) && *iter == '/')) &&
// Need 2 or 3 dots + only digits
(foundDots == 2 || foundDots == 3) &&
// and they should be all that came before now:
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index 23de8182170..fe34b94d523 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -712,7 +712,8 @@ SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
nsPingListener* pingListener =
new nsPingListener(info->requireSameHost, aContent, loadGroup);
- nsCOMPtr interceptController = do_QueryInterface(info->docShell);
+ nsCOMPtr interceptController =
+ do_QueryInterface(info->docShell);
pingListener->SetInterceptController(interceptController);
nsCOMPtr listener(pingListener);
@@ -845,10 +846,6 @@ DecreasePrivateDocShellCount()
}
}
-//*****************************************************************************
-//*** nsDocShell: Object Management
-//*****************************************************************************
-
static uint64_t gDocshellIDCounter = 0;
nsDocShell::nsDocShell()
@@ -1032,10 +1029,6 @@ nsDocShell::DestroyChildren()
nsDocLoader::DestroyChildren();
}
-//*****************************************************************************
-// nsDocShell::nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
@@ -1061,9 +1054,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsINetworkInterceptController)
NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
-///*****************************************************************************
-// nsDocShell::nsIInterfaceRequestor
-//*****************************************************************************
NS_IMETHODIMP
nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
{
@@ -1361,9 +1351,6 @@ nsDocShell::ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType)
return docShellLoadType;
}
-//*****************************************************************************
-// nsDocShell::nsIDocShell
-//*****************************************************************************
NS_IMETHODIMP
nsDocShell::LoadURI(nsIURI* aURI,
nsIDocShellLoadInfo* aLoadInfo,
@@ -2610,14 +2597,16 @@ nsDocShell::SetAllowContentRetargeting(bool aAllowContentRetargeting)
}
NS_IMETHODIMP
-nsDocShell::GetAllowContentRetargetingOnChildren(bool* aAllowContentRetargetingOnChildren)
+nsDocShell::GetAllowContentRetargetingOnChildren(
+ bool* aAllowContentRetargetingOnChildren)
{
*aAllowContentRetargetingOnChildren = mAllowContentRetargetingOnChildren;
return NS_OK;
}
NS_IMETHODIMP
-nsDocShell::SetAllowContentRetargetingOnChildren(bool aAllowContentRetargetingOnChildren)
+nsDocShell::SetAllowContentRetargetingOnChildren(
+ bool aAllowContentRetargetingOnChildren)
{
mAllowContentRetargetingOnChildren = aAllowContentRetargetingOnChildren;
return NS_OK;
@@ -3489,7 +3478,8 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent)
if (NS_SUCCEEDED(parentAsDocShell->GetAllowWindowControl(&value))) {
SetAllowWindowControl(value);
}
- SetAllowContentRetargeting(parentAsDocShell->GetAllowContentRetargetingOnChildren());
+ SetAllowContentRetargeting(
+ parentAsDocShell->GetAllowContentRetargetingOnChildren());
if (NS_SUCCEEDED(parentAsDocShell->GetIsActive(&value))) {
SetIsActive(value);
}
@@ -5611,6 +5601,7 @@ nsDocShell::GetSessionHistory(nsISHistory** aSessionHistory)
//*****************************************************************************
// nsDocShell::nsIWebPageDescriptor
//*****************************************************************************
+
NS_IMETHODIMP
nsDocShell::LoadPage(nsISupports* aPageDescriptor, uint32_t aDisplayType)
{
@@ -7174,7 +7165,7 @@ nsDocShell::RefreshURIFromQueue()
timer->InitWithCallback(refreshInfo, delay, nsITimer::TYPE_ONE_SHOT);
}
}
- } // while
+ }
return NS_OK;
}
@@ -7821,20 +7812,19 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
aStatus == NS_ERROR_PROXY_CONNECTION_REFUSED) &&
(isTopFrame || UseErrorPages())) {
DisplayLoadError(aStatus, url, nullptr, aChannel);
- }
- else if (aStatus == NS_ERROR_NET_TIMEOUT ||
- aStatus == NS_ERROR_REDIRECT_LOOP ||
- aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE ||
- aStatus == NS_ERROR_NET_INTERRUPT ||
- aStatus == NS_ERROR_NET_RESET ||
- aStatus == NS_ERROR_OFFLINE ||
- aStatus == NS_ERROR_MALWARE_URI ||
- aStatus == NS_ERROR_PHISHING_URI ||
- aStatus == NS_ERROR_UNWANTED_URI ||
- aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
- aStatus == NS_ERROR_REMOTE_XUL ||
- aStatus == NS_ERROR_OFFLINE ||
- NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
+ } else if (aStatus == NS_ERROR_NET_TIMEOUT ||
+ aStatus == NS_ERROR_REDIRECT_LOOP ||
+ aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE ||
+ aStatus == NS_ERROR_NET_INTERRUPT ||
+ aStatus == NS_ERROR_NET_RESET ||
+ aStatus == NS_ERROR_OFFLINE ||
+ aStatus == NS_ERROR_MALWARE_URI ||
+ aStatus == NS_ERROR_PHISHING_URI ||
+ aStatus == NS_ERROR_UNWANTED_URI ||
+ aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
+ aStatus == NS_ERROR_REMOTE_XUL ||
+ aStatus == NS_ERROR_OFFLINE ||
+ NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
// Errors to be shown for any frame
DisplayLoadError(aStatus, url, nullptr, aChannel);
} else if (aStatus == NS_ERROR_DOCUMENT_NOT_CACHED) {
@@ -7846,8 +7836,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
}
DisplayLoadError(aStatus, url, nullptr, aChannel);
}
- }
- else if (url && NS_SUCCEEDED(aStatus)) {
+ } else if (url && NS_SUCCEEDED(aStatus)) {
// If we have a host
mozilla::net::PredictorLearnRedirect(url, aChannel, this);
}
@@ -8001,9 +7990,9 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
blankDoc->SetSandboxFlags(mSandboxFlags);
// create a content viewer for us and the new document
- docFactory->CreateInstanceForDocument(NS_ISUPPORTS_CAST(nsIDocShell*, this),
- blankDoc, "view",
- getter_AddRefs(viewer));
+ docFactory->CreateInstanceForDocument(
+ NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view",
+ getter_AddRefs(viewer));
// hook 'em up
if (viewer) {
@@ -8405,8 +8394,8 @@ class MOZ_STACK_CLASS PresentationEventForgetter
{
public:
explicit PresentationEventForgetter(
- nsRevocableEventPtr&
- aRestorePresentationEvent)
+ nsRevocableEventPtr&
+ aRestorePresentationEvent)
: mRestorePresentationEvent(aRestorePresentationEvent)
, mEvent(aRestorePresentationEvent.get())
{
@@ -8785,7 +8774,8 @@ nsDocShell::RestoreFromHistory()
childShell->GetAllowDNSPrefetch(&allowDNSPrefetch);
bool allowContentRetargeting = childShell->GetAllowContentRetargeting();
- bool allowContentRetargetingOnChildren = childShell->GetAllowContentRetargetingOnChildren();
+ bool allowContentRetargetingOnChildren =
+ childShell->GetAllowContentRetargetingOnChildren();
uint32_t defaultLoadFlags;
childShell->GetDefaultLoadFlags(&defaultLoadFlags);
@@ -8804,7 +8794,8 @@ nsDocShell::RestoreFromHistory()
childShell->SetAllowMedia(allowMedia);
childShell->SetAllowDNSPrefetch(allowDNSPrefetch);
childShell->SetAllowContentRetargeting(allowContentRetargeting);
- childShell->SetAllowContentRetargetingOnChildren(allowContentRetargetingOnChildren);
+ childShell->SetAllowContentRetargetingOnChildren(
+ allowContentRetargetingOnChildren);
childShell->SetDefaultLoadFlags(defaultLoadFlags);
rv = childShell->BeginRestore(nullptr, false);
@@ -9085,8 +9076,9 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType,
aOpenedChannel->SetLoadFlags(loadFlags);
mLoadGroup->AddRequest(aRequest, nullptr);
- if (currentLoadGroup)
+ if (currentLoadGroup) {
currentLoadGroup->RemoveRequest(aRequest, nullptr, NS_BINDING_RETARGETED);
+ }
// Update the notification callbacks, so that progress and
// status information are sent to the right docshell...
@@ -9405,6 +9397,7 @@ nsDocShell::CheckLoadingPermissions()
//*****************************************************************************
// nsDocShell: Site Loading
//*****************************************************************************
+
namespace {
#ifdef MOZ_PLACES
@@ -9515,7 +9508,8 @@ public:
}
}
- NS_IMETHOD Run()
+ NS_IMETHOD
+ Run()
{
return mDocShell->InternalLoad(mURI, mReferrer,
mReferrerPolicy,
@@ -11222,7 +11216,7 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel, nsISupports* aOwner,
updateSHistory = false;
updateGHistory = false; // XXX Why global history too?
}
- } // rootSH
+ }
// Check if the url to be loaded is the same as the one already loaded.
if (mCurrentURI) {
@@ -11823,9 +11817,9 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
nsCOMPtr child;
shContainer->GetChildAt(i, getter_AddRefs(child));
shContainer->RemoveChild(child);
- } // for
+ }
entry->AbandonBFCacheEntry();
- } // shContainer
+ }
}
// Create a new entry if necessary.
@@ -12166,7 +12160,8 @@ nsDocShell::WalkHistoryEntries(nsISHEntry* aRootEntry,
if (aRootShell) {
// Walk the children of aRootShell and see if one of them
// has srcChild as a SHEntry.
- nsTObserverArray::ForwardIterator iter(aRootShell->mChildList);
+ nsTObserverArray::ForwardIterator iter(
+ aRootShell->mChildList);
while (iter.HasMore()) {
nsDocShell* child = static_cast(iter.GetNext());
@@ -12939,10 +12934,6 @@ nsDocShell::SetLayoutHistoryState(nsILayoutHistoryState* aLayoutHistoryState)
return NS_OK;
}
-//*****************************************************************************
-//*** nsRefreshTimer: Object Management
-//*****************************************************************************
-
nsRefreshTimer::nsRefreshTimer()
: mDelay(0), mRepeat(false), mMetaRefresh(false)
{
@@ -12952,10 +12943,6 @@ nsRefreshTimer::~nsRefreshTimer()
{
}
-//*****************************************************************************
-// nsRefreshTimer::nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF(nsRefreshTimer)
NS_IMPL_RELEASE(nsRefreshTimer)
@@ -12964,9 +12951,6 @@ NS_INTERFACE_MAP_BEGIN(nsRefreshTimer)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_END_THREADSAFE
-///*****************************************************************************
-// nsRefreshTimer::nsITimerCallback
-//******************************************************************************
NS_IMETHODIMP
nsRefreshTimer::Notify(nsITimer* aTimer)
{
@@ -12981,9 +12965,6 @@ nsRefreshTimer::Notify(nsITimer* aTimer)
return NS_OK;
}
-//*****************************************************************************
-// nsDocShell::InterfaceRequestorProxy
-//*****************************************************************************
nsDocShell::InterfaceRequestorProxy::InterfaceRequestorProxy(
nsIInterfaceRequestor* aRequestor)
{
@@ -13022,8 +13003,9 @@ nsDocShell::SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer)
nsCOMPtr baseURI;
nsresult rv = NS_ERROR_NOT_AVAILABLE;
- if (sURIFixup)
+ if (sURIFixup) {
rv = sURIFixup->CreateExposableURI(mCurrentURI, getter_AddRefs(baseURI));
+ }
// Get the current document and set the base uri
if (baseURI) {
@@ -13069,6 +13051,7 @@ nsDocShell::GetAuthPrompt(uint32_t aPromptReason, const nsIID& aIID,
//*****************************************************************************
// nsDocShell::nsILoadContext
//*****************************************************************************
+
NS_IMETHODIMP
nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
{
@@ -13321,8 +13304,6 @@ nsDocShell::SelectNone(void)
return DoCommand("cmd_selectNone");
}
-//----------------------------------------------------------------------
-
// link handling
class OnLinkClickEvent : public nsRunnable
@@ -13382,8 +13363,6 @@ OnLinkClickEvent::OnLinkClickEvent(nsDocShell* aHandler,
{
}
-//----------------------------------------
-
NS_IMETHODIMP
nsDocShell::OnLinkClick(nsIContent* aContent,
nsIURI* aURI,
@@ -13934,7 +13913,6 @@ nsDocShell::GetURLSearchParams()
class JavascriptTimelineMarker : public TimelineMarker
{
public:
-
JavascriptTimelineMarker(nsDocShell* aDocShell, const char* aName,
const char* aReason)
: TimelineMarker(aDocShell, aName, TRACING_INTERVAL_START,
@@ -13949,7 +13927,7 @@ public:
};
void
-nsDocShell::NotifyJSRunToCompletionStart(const char *aReason)
+nsDocShell::NotifyJSRunToCompletionStart(const char* aReason)
{
bool timelineOn = nsIDocShell::GetRecordProfileTimelineMarkers();
@@ -14009,7 +13987,8 @@ nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
}
NS_IMETHODIMP
-nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aShouldIntercept)
+nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
+ bool* aShouldIntercept)
{
*aShouldIntercept = false;
if (mSandboxFlags) {
@@ -14017,7 +13996,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aSho
return NS_OK;
}
- nsCOMPtr swm = mozilla::services::GetServiceWorkerManager();
+ nsCOMPtr swm = services::GetServiceWorkerManager();
if (!swm) {
return NS_OK;
}
@@ -14037,7 +14016,7 @@ nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aSho
NS_IMETHODIMP
nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
{
- nsCOMPtr swm = mozilla::services::GetServiceWorkerManager();
+ nsCOMPtr swm = services::GetServiceWorkerManager();
if (!swm) {
aChannel->Cancel();
return NS_OK;
diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h
index 8c83e681780..7c6d1cad70b 100644
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -89,9 +89,6 @@ class nsIURILoader;
class nsIWebBrowserFind;
class nsIWidget;
-/* load commands were moved to nsIDocShell.h */
-/* load types were moved to nsDocShellLoadTypes.h */
-
/* internally used ViewMode types */
enum ViewMode
{
@@ -99,10 +96,6 @@ enum ViewMode
viewSource = 0x1
};
-//*****************************************************************************
-//*** nsRefreshTimer
-//*****************************************************************************
-
class nsRefreshTimer : public nsITimerCallback
{
public:
@@ -130,10 +123,6 @@ enum eCharsetReloadState
eCharsetReloadStopOrigional
};
-//*****************************************************************************
-//*** nsDocShell
-//*****************************************************************************
-
class nsDocShell final
: public nsDocLoader
, public nsIDocShell
@@ -159,7 +148,7 @@ class nsDocShell final
public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
- // Object Management
+
nsDocShell();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@@ -186,7 +175,8 @@ public:
NS_DECL_NSINETWORKINTERCEPTCONTROLLER
NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
- NS_IMETHOD Stop() override {
+ NS_IMETHOD Stop() override
+ {
// Need this here because otherwise nsIWebNavigation::Stop
// overrides the docloader's Stop()
return nsDocLoader::Stop();
@@ -219,7 +209,7 @@ public:
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(
- nsDocShellInfoLoadType aDocShellLoadType);
+ nsDocShellInfoLoadType aDocShellLoadType);
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
@@ -237,10 +227,10 @@ public:
// Restores a cached presentation from history (mLSHE).
// This method swaps out the content viewer and simulates loads for
- // subframes. It then simulates the completion of the toplevel load.
+ // subframes. It then simulates the completion of the toplevel load.
nsresult RestoreFromHistory();
- // Perform a URI load from a refresh timer. This is just like the
+ // Perform a URI load from a refresh timer. This is just like the
// ForceRefreshURI method on nsIRefreshURI, but makes sure to take
// the timer involved out of mRefreshURIList if it's there.
// aTimer must not be null.
@@ -269,8 +259,7 @@ public:
// Add new profile timeline markers to this docShell. This will only add
// markers if the docShell is currently recording profile timeline markers.
// See nsIDocShell::recordProfileTimelineMarkers
- void AddProfileTimelineMarker(const char* aName,
- TracingMetadata aMetaData);
+ void AddProfileTimelineMarker(const char* aName, TracingMetadata aMetaData);
void AddProfileTimelineMarker(mozilla::UniquePtr&& aMarker);
// Global counter for how many docShells are currently recording profile
@@ -283,13 +272,12 @@ public:
bool aInPrivateBrowsing);
protected:
- // Object Management
virtual ~nsDocShell();
virtual void DestroyChildren() override;
// Content Viewer Management
nsresult EnsureContentViewer();
- // aPrincipal can be passed in if the caller wants. If null is
+ // aPrincipal can be passed in if the caller wants. If null is
// passed in, the about:blank principal will end up being used.
nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
nsIURI* aBaseURI,
@@ -307,16 +295,16 @@ protected:
nsresult GetEldestPresContext(nsPresContext** aPresContext);
- // Get the principal that we'll set on the channel if we're inheriting. If
+ // Get the principal that we'll set on the channel if we're inheriting. If
// aConsiderCurrentDocument is true, we try to use the current document if
- // at all possible. If that fails, we fall back on the parent document.
+ // at all possible. If that fails, we fall back on the parent document.
// If that fails too, we force creation of a content viewer and use the
- // resulting principal. If aConsiderCurrentDocument is false, we just look
+ // resulting principal. If aConsiderCurrentDocument is false, we just look
// at the parent.
nsIPrincipal* GetInheritedPrincipal(bool aConsiderCurrentDocument);
- // Actually open a channel and perform a URI load. Note: whatever owner is
- // passed to this function will be set on the channel. Callers who wish to
+ // Actually open a channel and perform a URI load. Note: whatever owner is
+ // passed to this function will be set on the channel. Callers who wish to
// not have an owner on the channel should just pass null.
// If aSrcdoc is not void, the load will be considered as a srcdoc load,
// and the contents of aSrcdoc will be loaded instead of aURI.
@@ -361,7 +349,7 @@ protected:
// In this case it is the caller's responsibility to ensure
// FireOnLocationChange is called.
// In all other cases false is returned.
- // Either aChannel or aOwner must be null. If aChannel is
+ // Either aChannel or aOwner must be null. If aChannel is
// present, the owner should be gotten from it.
// If OnNewURI calls AddToSessionHistory, it will pass its
// aCloneSHChildren argument as aCloneChildren.
@@ -376,10 +364,10 @@ protected:
// Session History
bool ShouldAddToSessionHistory(nsIURI* aURI);
- // Either aChannel or aOwner must be null. If aChannel is
+ // Either aChannel or aOwner must be null. If aChannel is
// present, the owner should be gotten from it.
// If aCloneChildren is true, then our current session history's
- // children will be cloned onto the new entry. This should be
+ // children will be cloned onto the new entry. This should be
// used when we aren't actually changing the document while adding
// the new session history entry.
nsresult AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
@@ -399,7 +387,7 @@ protected:
// Clone a session history tree for subframe navigation.
// The tree rooted at |aSrcEntry| will be cloned into |aDestEntry|, except
// for the entry with id |aCloneID|, which will be replaced with
- // |aReplaceEntry|. |aSrcShell| is a (possibly null) docshell which
+ // |aReplaceEntry|. |aSrcShell| is a (possibly null) docshell which
// corresponds to |aSrcEntry| via its mLSHE or mOHE pointers, and will
// have that pointer updated to point to the cloned history entry.
// If aCloneChildren is true then the children of the entry with id
@@ -430,7 +418,7 @@ protected:
void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry);
// Call this method to swap in a new history entry to m[OL]SHE, rather than
- // setting it directly. This completes the navigation in all docshells
+ // setting it directly. This completes the navigation in all docshells
// in the case of a subframe navigation.
void SetHistoryEntry(nsCOMPtr* aPtr, nsISHEntry* aEntry);
@@ -448,7 +436,7 @@ protected:
void* aData);
// For each child of aRootEntry, find the corresponding docshell which is
- // a child of aRootShell, and call aCallback. The opaque pointer aData
+ // a child of aRootShell, and call aCallback. The opaque pointer aData
// is passed to the callback.
static nsresult WalkHistoryEntries(nsISHEntry* aRootEntry,
nsDocShell* aRootShell,
@@ -477,7 +465,7 @@ protected:
* channel.
*
* This method first checks the channel's property bag to see if previous
- * info has been saved. If not, it gives back the referrer of the channel.
+ * info has been saved. If not, it gives back the referrer of the channel.
*
* @param aChannel
* The channel we are transitioning to
@@ -506,7 +494,7 @@ protected:
uint32_t aChannelRedirectFlags);
/**
- * Helper function for adding a URI visit using IHistory. If IHistory is
+ * Helper function for adding a URI visit using IHistory. If IHistory is
* not available, the method tries nsIGlobalHistory2.
*
* The IHistory API maintains chains of visits, tracking both HTTP referrers
@@ -514,7 +502,7 @@ protected:
* the previous URI in the chain.
*
* Visits can be saved either during a redirect or when the request has
- * reached its final destination. The previous URI in the visit may be
+ * reached its final destination. The previous URI in the visit may be
* from another redirect or it may be the referrer.
*
* @pre aURI is not null.
@@ -583,13 +571,13 @@ protected:
nsresult aResult);
// Sets the current document's current state object to the given SHEntry's
- // state object. The current state object is eventually given to the page
+ // state object. The current state object is eventually given to the page
// in the PopState event.
nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
nsresult CheckLoadingPermissions();
- // Security checks to prevent frameset spoofing. See comments at
+ // Security checks to prevent frameset spoofing. See comments at
// implementation sites.
static bool CanAccessItem(nsIDocShellTreeItem* aTargetItem,
nsIDocShellTreeItem* aAccessingItem,
@@ -610,33 +598,33 @@ protected:
// in session history.
// mContentViewer points to the current content viewer associated with
- // this docshell. When loading a new document, the content viewer is
- // either destroyed or stored into a session history entry. To make sure
+ // this docshell. When loading a new document, the content viewer is
+ // either destroyed or stored into a session history entry. To make sure
// that destruction happens in a controlled fashion, a given content viewer
// is always owned in exactly one of these ways:
// 1) The content viewer is active and owned by a docshell's
// mContentViewer.
// 2) The content viewer is still being displayed while we begin loading
- // a new document. The content viewer is owned by the _new_
+ // a new document. The content viewer is owned by the _new_
// content viewer's mPreviousViewer, and has a pointer to the
- // nsISHEntry where it will eventually be stored. The content viewer
+ // nsISHEntry where it will eventually be stored. The content viewer
// has been close()d by the docshell, which detaches the document from
// the window object.
- // 3) The content viewer is cached in session history. The nsISHEntry
- // has the only owning reference to the content viewer. The viewer
+ // 3) The content viewer is cached in session history. The nsISHEntry
+ // has the only owning reference to the content viewer. The viewer
// has released its nsISHEntry pointer to prevent circular ownership.
//
// When restoring a content viewer from session history, open() is called
- // to reattach the document to the window object. The content viewer is
+ // to reattach the document to the window object. The content viewer is
// then placed into mContentViewer and removed from the history entry.
// (mContentViewer is put into session history as described above, if
// applicable).
// Determines whether we can safely cache the current mContentViewer in
- // session history. This checks a number of factors such as cache policy,
+ // session history. This checks a number of factors such as cache policy,
// pending requests, and unload handlers.
// |aLoadType| should be the load type that will replace the current
- // presentation. |aNewRequest| should be the request for the document to
+ // presentation. |aNewRequest| should be the request for the document to
// be loaded in place of the current document, or null if such a request
// has not been created yet. |aNewDocument| should be the document that will
// replace the current document.
@@ -662,7 +650,7 @@ protected:
int32_t* aHeight);
// Call this when a URI load is handed to us (via OnLinkClick or
- // InternalLoad). This makes sure that we're not inside unload, or that if
+ // InternalLoad). This makes sure that we're not inside unload, or that if
// we are it's still OK to load this URI.
bool IsOKToLoadURI(nsIURI* aURI);
@@ -680,7 +668,7 @@ protected:
bool ShouldBlockLoadingForBackButton();
- // Convenience method for getting our parent docshell. Can return null
+ // Convenience method for getting our parent docshell. Can return null
already_AddRefed GetParentDocshell();
// Check if we have an app redirect registered for the URI and redirect if
@@ -788,7 +776,7 @@ protected:
nsCOMPtr mLSHE;
// Holds a weak pointer to a RestorePresentationEvent object if any that
- // holds a weak pointer back to us. We use this pointer to possibly revoke
+ // holds a weak pointer back to us. We use this pointer to possibly revoke
// the event whenever necessary.
nsRevocableEventPtr mRestorePresentationEvent;
@@ -801,9 +789,9 @@ protected:
// Secure browser UI object
nsCOMPtr mSecurityUI;
- // The URI we're currently loading. This is only relevant during the
- // firing of a pagehide/unload. The caller of FirePageHideNotification()
- // is responsible for setting it and unsetting it. It may be null if the
+ // The URI we're currently loading. This is only relevant during the
+ // firing of a pagehide/unload. The caller of FirePageHideNotification()
+ // is responsible for setting it and unsetting it. It may be null if the
// pagehide/unload is happening for some reason other than just loading a
// new URI.
nsCOMPtr mLoadingURI;
@@ -824,11 +812,11 @@ protected:
nsCOMPtr mMixedContentChannel;
// WEAK REFERENCES BELOW HERE.
- // Note these are intentionally not addrefd. Doing so will create a cycle.
+ // Note these are intentionally not addrefd. Doing so will create a cycle.
// For that reasons don't use nsCOMPtr.
nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
- mozilla::dom::EventTarget* mChromeEventHandler; //Weak Reference
+ mozilla::dom::EventTarget* mChromeEventHandler; // Weak Reference
eCharsetReloadState mCharsetReloadState;
@@ -842,7 +830,7 @@ protected:
int32_t mMarginWidth;
int32_t mMarginHeight;
- // This can either be a content docshell or a chrome docshell. After
+ // This can either be a content docshell or a chrome docshell. After
// Create() is called, the type is not expected to change.
int32_t mItemType;
@@ -910,7 +898,7 @@ protected:
void RecomputeCanExecuteScripts();
// This boolean is set to true right before we fire pagehide and generally
- // unset when we embed a new content viewer. While it's true no navigation
+ // unset when we embed a new content viewer. While it's true no navigation
// is allowed in this docshell.
bool mFiredUnloadEvent;
@@ -957,7 +945,7 @@ protected:
FrameType mFrameType;
// We only expect mOwnOrContainingAppId to be something other than
- // UNKNOWN_APP_ID if mFrameType != eFrameTypeRegular. For vanilla iframes
+ // UNKNOWN_APP_ID if mFrameType != eFrameTypeRegular. For vanilla iframes
// inside an app, we'll retrieve the containing app-id by walking up the
// docshell hierarchy.
//
diff --git a/docshell/base/nsDocShellEditorData.h b/docshell/base/nsDocShellEditorData.h
index 53036b98e6d..272190503cc 100644
--- a/docshell/base/nsDocShellEditorData.h
+++ b/docshell/base/nsDocShellEditorData.h
@@ -58,7 +58,6 @@ protected:
// Backup for the corresponding nsIHTMLDocument's editing state while
// the editor is detached.
nsIHTMLDocument::EditingState mDetachedEditingState;
-
};
#endif // nsDocShellEditorData_h__
diff --git a/docshell/base/nsDocShellEnumerator.h b/docshell/base/nsDocShellEnumerator.h
index a299aa0f350..87de74f0f77 100644
--- a/docshell/base/nsDocShellEnumerator.h
+++ b/docshell/base/nsDocShellEnumerator.h
@@ -89,7 +89,6 @@ public:
protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray& aItemArray);
-
};
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
diff --git a/docshell/base/nsDocShellLoadInfo.cpp b/docshell/base/nsDocShellLoadInfo.cpp
index a81884687f6..5f2bf2d55f1 100644
--- a/docshell/base/nsDocShellLoadInfo.cpp
+++ b/docshell/base/nsDocShellLoadInfo.cpp
@@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// Local Includes
#include "nsDocShellLoadInfo.h"
#include "nsISHEntry.h"
#include "nsIInputStream.h"
@@ -12,10 +11,6 @@
#include "nsIDocShell.h"
#include "mozilla/net/ReferrerPolicy.h"
-//*****************************************************************************
-//*** nsDocShellLoadInfo: Object Management
-//*****************************************************************************
-
nsDocShellLoadInfo::nsDocShellLoadInfo()
: mInheritOwner(false)
, mOwnerIsExplicit(false)
@@ -30,10 +25,6 @@ nsDocShellLoadInfo::~nsDocShellLoadInfo()
{
}
-//*****************************************************************************
-// nsDocShellLoadInfo::nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF(nsDocShellLoadInfo)
NS_IMPL_RELEASE(nsDocShellLoadInfo)
@@ -42,10 +33,6 @@ NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
NS_INTERFACE_MAP_END
-//*****************************************************************************
-// nsDocShellLoadInfo::nsIDocShellLoadInfo
-//*****************************************************************************
-
NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
{
diff --git a/docshell/base/nsDocShellLoadTypes.h b/docshell/base/nsDocShellLoadTypes.h
index 518df7d1019..273dd87b0d6 100644
--- a/docshell/base/nsDocShellLoadTypes.h
+++ b/docshell/base/nsDocShellLoadTypes.h
@@ -27,8 +27,8 @@
* above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would
* just shift them out anyway.
*/
-#define EXTRA_LOAD_FLAGS (LOAD_FLAGS_FIRST_LOAD | \
- LOAD_FLAGS_ALLOW_POPUPS | \
+#define EXTRA_LOAD_FLAGS (LOAD_FLAGS_FIRST_LOAD | \
+ LOAD_FLAGS_ALLOW_POPUPS | \
0xffff0000)
/* load types are legal combinations of load commands and flags
@@ -65,7 +65,8 @@ enum LoadType
* Docshell. Instead, Docshell triggers the load itself when a
* consumer-triggered load failed.
*/
- LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
+ LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
+ LOAD_FLAGS_ERROR_PAGE)
// NOTE: Adding a new value? Remember to update IsValidLoadType!
};
diff --git a/docshell/base/nsDocShellTransferableHooks.cpp b/docshell/base/nsDocShellTransferableHooks.cpp
index 890bd05f6ca..441ade12873 100644
--- a/docshell/base/nsDocShellTransferableHooks.cpp
+++ b/docshell/base/nsDocShellTransferableHooks.cpp
@@ -17,10 +17,6 @@ nsTransferableHookData::~nsTransferableHookData()
{
}
-//*****************************************************************************
-// nsIClipboardDragDropHookList
-//*****************************************************************************
-
NS_IMPL_ISUPPORTS(nsTransferableHookData, nsIClipboardDragDropHookList)
NS_IMETHODIMP
diff --git a/docshell/base/nsDownloadHistory.cpp b/docshell/base/nsDownloadHistory.cpp
index 46005600903..32513ef0026 100644
--- a/docshell/base/nsDownloadHistory.cpp
+++ b/docshell/base/nsDownloadHistory.cpp
@@ -12,14 +12,8 @@
#include "nsIURI.h"
#include "mozilla/Services.h"
-////////////////////////////////////////////////////////////////////////////////
-//// nsDownloadHistory
-
NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
-////////////////////////////////////////////////////////////////////////////////
-//// nsIDownloadHistory
-
NS_IMETHODIMP
nsDownloadHistory::AddDownload(nsIURI* aSource,
nsIURI* aReferrer,
@@ -42,8 +36,7 @@ nsDownloadHistory::AddDownload(nsIURI* aSource,
NS_ENSURE_SUCCESS(rv, rv);
if (!visited) {
- nsCOMPtr os =
- mozilla::services::GetObserverService();
+ nsCOMPtr os = mozilla::services::GetObserverService();
if (os) {
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
}
diff --git a/docshell/base/nsILinkHandler.h b/docshell/base/nsILinkHandler.h
index 797b3fe1340..7cdcd566dfa 100644
--- a/docshell/base/nsILinkHandler.h
+++ b/docshell/base/nsILinkHandler.h
@@ -14,7 +14,6 @@ class nsIDocShell;
class nsIInputStream;
class nsIRequest;
-// Interface ID for nsILinkHandler
#define NS_ILINKHANDLER_IID \
{ 0xceb9aade, 0x43da, 0x4f1a, \
{ 0xac, 0x8a, 0xc7, 0x09, 0xfb, 0x22, 0x46, 0x64 } }
diff --git a/docshell/base/nsIWebShellServices.h b/docshell/base/nsIWebShellServices.h
index 2781da289a3..c67de0ff72f 100644
--- a/docshell/base/nsIWebShellServices.h
+++ b/docshell/base/nsIWebShellServices.h
@@ -9,20 +9,16 @@
#include "nsISupports.h"
#include "nsCharsetSource.h"
-// Interface ID for nsIWebShellServices
-
/* 0c628af0-5638-4703-8f99-ed6134c9de18 */
#define NS_IWEB_SHELL_SERVICES_IID \
{ 0x0c628af0, 0x5638, 0x4703, {0x8f, 0x99, 0xed, 0x61, 0x34, 0xc9, 0xde, 0x18} }
-//----------------------------------------------------------------------
-
class nsIWebShellServices : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
- NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
+ NS_IMETHOD ReloadDocument(const char* aCharset = nullptr,
int32_t aSource = kCharsetUninitialized) = 0;
NS_IMETHOD StopDocumentLoad(void) = 0;
};
diff --git a/docshell/base/nsWebNavigationInfo.h b/docshell/base/nsWebNavigationInfo.h
index 430fb95aa84..2b54156f7ed 100644
--- a/docshell/base/nsWebNavigationInfo.h
+++ b/docshell/base/nsWebNavigationInfo.h
@@ -14,7 +14,6 @@
class nsCString;
-// Class ID for webnavigationinfo
#define NS_WEBNAVIGATION_INFO_CID \
{ 0xf30bc0a2, 0x958b, 0x4287,{0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e}}
diff --git a/docshell/build/nsDocShellCID.h b/docshell/build/nsDocShellCID.h
index 6049688f4d9..35432ee1b51 100644
--- a/docshell/build/nsDocShellCID.h
+++ b/docshell/build/nsDocShellCID.h
@@ -7,8 +7,7 @@
#ifndef nsDocShellCID_h__
#define nsDocShellCID_h__
-#define NS_GLOBALHISTORY2_CONTRACTID \
- "@mozilla.org/browser/global-history;2"
+#define NS_GLOBALHISTORY2_CONTRACTID "@mozilla.org/browser/global-history;2"
/**
* A contract for a service that will track download history. This can be
@@ -17,16 +16,14 @@
*
* @implements nsIDownloadHistory
*/
-#define NS_DOWNLOADHISTORY_CONTRACTID \
- "@mozilla.org/browser/download-history;1"
+#define NS_DOWNLOADHISTORY_CONTRACTID "@mozilla.org/browser/download-history;1"
/**
* A contract that can be used to get a service that provides
* meta-information about nsIWebNavigation objects' capabilities.
* @implements nsIWebNavigationInfo
*/
-#define NS_WEBNAVIGATION_INFO_CONTRACTID \
- "@mozilla.org/webnavigation-info;1"
+#define NS_WEBNAVIGATION_INFO_CONTRACTID "@mozilla.org/webnavigation-info;1"
/**
* Class and contract ID for the docshell. This is the container for a web
@@ -34,9 +31,9 @@
* exact ones keep changing; if they stabilize somewhat that will get
* documented.
*/
-#define NS_DOCSHELL_CID \
- { 0xf1eac762, 0x87e9, 0x11d3, \
- { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } }
+#define NS_DOCSHELL_CID \
+ { 0xf1eac762, 0x87e9, 0x11d3, \
+ { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } }
#define NS_DOCSHELL_CONTRACTID "@mozilla.org/docshell/html;1"
/**
@@ -51,7 +48,8 @@
*
* @implements nsIExternalURLHandlerService
*/
-#define NS_EXTERNALURLHANDLERSERVICE_CONTRACTID "@mozilla.org/uriloader/external-url-handler-service;1"
+#define NS_EXTERNALURLHANDLERSERVICE_CONTRACTID \
+ "@mozilla.org/uriloader/external-url-handler-service;1"
/**
* An observer service topic that can be listened to to catch creation
diff --git a/docshell/build/nsDocShellModule.cpp b/docshell/build/nsDocShellModule.cpp
index 790b0b8c2bf..d75286e7bd9 100644
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -23,7 +23,7 @@
#include "nsLocalHandlerApp.h"
#ifdef MOZ_ENABLE_DBUS
#include "nsDBusHandlerApp.h"
-#endif
+#endif
#if defined(MOZ_WIDGET_ANDROID)
#include "nsExternalSharingAppService.h"
#include "nsExternalURLHandlerService.h"
@@ -81,7 +81,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineCacheUpdate)
NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
#ifdef MOZ_ENABLE_DBUS
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
-#endif
+#endif
#if defined(MOZ_WIDGET_ANDROID)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
@@ -120,7 +120,6 @@ NS_DEFINE_NAMED_CID(NS_SHISTORY_CID);
NS_DEFINE_NAMED_CID(NS_SHISTORY_INTERNAL_CID);
NS_DEFINE_NAMED_CID(NS_DOWNLOADHISTORY_CID);
-
const mozilla::Module::CIDEntry kDocShellCIDs[] = {
{ &kNS_DOCSHELL_CID, false, nullptr, nsDocShellConstructor },
{ &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor },
diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp
index 065d8898be2..baf30539632 100644
--- a/docshell/shistory/src/nsSHEntry.cpp
+++ b/docshell/shistory/src/nsSHEntry.cpp
@@ -3,7 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// Local Includes
#include "nsSHEntry.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIDocShellTreeItem.h"
@@ -22,13 +21,9 @@ namespace dom = mozilla::dom;
static uint32_t gEntryID = 0;
-//*****************************************************************************
-//*** nsSHEntry: Object Management
-//*****************************************************************************
-
-
nsSHEntry::nsSHEntry()
- : mReferrerPolicy(mozilla::net::RP_Default)
+ : mShared(new nsSHEntryShared())
+ , mReferrerPolicy(mozilla::net::RP_Default)
, mLoadType(0)
, mID(gEntryID++)
, mScrollPositionX(0)
@@ -37,26 +32,25 @@ nsSHEntry::nsSHEntry()
, mURIWasModified(false)
, mIsSrcdocEntry(false)
{
- mShared = new nsSHEntryShared();
}
-nsSHEntry::nsSHEntry(const nsSHEntry &other)
- : mShared(other.mShared)
- , mURI(other.mURI)
- , mReferrerURI(other.mReferrerURI)
- , mReferrerPolicy(other.mReferrerPolicy)
- , mTitle(other.mTitle)
- , mPostData(other.mPostData)
+nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
+ : mShared(aOther.mShared)
+ , mURI(aOther.mURI)
+ , mReferrerURI(aOther.mReferrerURI)
+ , mReferrerPolicy(aOther.mReferrerPolicy)
+ , mTitle(aOther.mTitle)
+ , mPostData(aOther.mPostData)
, mLoadType(0) // XXX why not copy?
- , mID(other.mID)
+ , mID(aOther.mID)
, mScrollPositionX(0) // XXX why not copy?
, mScrollPositionY(0) // XXX why not copy?
- , mParent(other.mParent)
- , mURIWasModified(other.mURIWasModified)
- , mStateData(other.mStateData)
- , mIsSrcdocEntry(other.mIsSrcdocEntry)
- , mSrcdocData(other.mSrcdocData)
- , mBaseURI(other.mBaseURI)
+ , mParent(aOther.mParent)
+ , mURIWasModified(aOther.mURIWasModified)
+ , mStateData(aOther.mStateData)
+ , mIsSrcdocEntry(aOther.mIsSrcdocEntry)
+ , mSrcdocData(aOther.mSrcdocData)
+ , mBaseURI(aOther.mBaseURI)
{
}
@@ -75,88 +69,90 @@ nsSHEntry::~nsSHEntry()
mChildren.EnumerateForwards(ClearParentPtr, nullptr);
}
-//*****************************************************************************
-// nsSHEntry: nsISupports
-//*****************************************************************************
-
NS_IMPL_ISUPPORTS(nsSHEntry, nsISHContainer, nsISHEntry, nsISHEntryInternal)
-//*****************************************************************************
-// nsSHEntry: nsISHEntry
-//*****************************************************************************
-
-NS_IMETHODIMP nsSHEntry::SetScrollPosition(int32_t x, int32_t y)
+NS_IMETHODIMP
+nsSHEntry::SetScrollPosition(int32_t aX, int32_t aY)
{
- mScrollPositionX = x;
- mScrollPositionY = y;
+ mScrollPositionX = aX;
+ mScrollPositionY = aY;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetScrollPosition(int32_t *x, int32_t *y)
+NS_IMETHODIMP
+nsSHEntry::GetScrollPosition(int32_t* aX, int32_t* aY)
{
- *x = mScrollPositionX;
- *y = mScrollPositionY;
+ *aX = mScrollPositionX;
+ *aY = mScrollPositionY;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetURIWasModified(bool* aOut)
+NS_IMETHODIMP
+nsSHEntry::GetURIWasModified(bool* aOut)
{
*aOut = mURIWasModified;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetURIWasModified(bool aIn)
+NS_IMETHODIMP
+nsSHEntry::SetURIWasModified(bool aIn)
{
mURIWasModified = aIn;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI)
+NS_IMETHODIMP
+nsSHEntry::GetURI(nsIURI** aURI)
{
*aURI = mURI;
NS_IF_ADDREF(*aURI);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetURI(nsIURI* aURI)
+NS_IMETHODIMP
+nsSHEntry::SetURI(nsIURI* aURI)
{
mURI = aURI;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetReferrerURI(nsIURI **aReferrerURI)
+NS_IMETHODIMP
+nsSHEntry::GetReferrerURI(nsIURI** aReferrerURI)
{
*aReferrerURI = mReferrerURI;
NS_IF_ADDREF(*aReferrerURI);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetReferrerURI(nsIURI *aReferrerURI)
+NS_IMETHODIMP
+nsSHEntry::SetReferrerURI(nsIURI* aReferrerURI)
{
mReferrerURI = aReferrerURI;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetReferrerPolicy(uint32_t *aReferrerPolicy)
+NS_IMETHODIMP
+nsSHEntry::GetReferrerPolicy(uint32_t* aReferrerPolicy)
{
*aReferrerPolicy = mReferrerPolicy;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetReferrerPolicy(uint32_t aReferrerPolicy)
+NS_IMETHODIMP
+nsSHEntry::SetReferrerPolicy(uint32_t aReferrerPolicy)
{
mReferrerPolicy = aReferrerPolicy;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::SetContentViewer(nsIContentViewer *aViewer)
+nsSHEntry::SetContentViewer(nsIContentViewer* aViewer)
{
return mShared->SetContentViewer(aViewer);
}
NS_IMETHODIMP
-nsSHEntry::GetContentViewer(nsIContentViewer **aResult)
+nsSHEntry::GetContentViewer(nsIContentViewer** aResult)
{
*aResult = mShared->mContentViewer;
NS_IF_ADDREF(*aResult);
@@ -164,15 +160,15 @@ nsSHEntry::GetContentViewer(nsIContentViewer **aResult)
}
NS_IMETHODIMP
-nsSHEntry::GetAnyContentViewer(nsISHEntry **aOwnerEntry,
- nsIContentViewer **aResult)
+nsSHEntry::GetAnyContentViewer(nsISHEntry** aOwnerEntry,
+ nsIContentViewer** aResult)
{
// Find a content viewer in the root node or any of its children,
// assuming that there is only one content viewer total in any one
// nsSHEntry tree
GetContentViewer(aResult);
if (*aResult) {
-#ifdef DEBUG_PAGE_CACHE
+#ifdef DEBUG_PAGE_CACHE
printf("Found content viewer\n");
#endif
*aOwnerEntry = this;
@@ -203,124 +199,142 @@ nsSHEntry::SetSticky(bool aSticky)
}
NS_IMETHODIMP
-nsSHEntry::GetSticky(bool *aSticky)
+nsSHEntry::GetSticky(bool* aSticky)
{
*aSticky = mShared->mSticky;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetTitle(char16_t** aTitle)
+NS_IMETHODIMP
+nsSHEntry::GetTitle(char16_t** aTitle)
{
// Check for empty title...
if (mTitle.IsEmpty() && mURI) {
// Default title is the URL.
nsAutoCString spec;
- if (NS_SUCCEEDED(mURI->GetSpec(spec)))
+ if (NS_SUCCEEDED(mURI->GetSpec(spec))) {
AppendUTF8toUTF16(spec, mTitle);
+ }
}
*aTitle = ToNewUnicode(mTitle);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetTitle(const nsAString &aTitle)
+NS_IMETHODIMP
+nsSHEntry::SetTitle(const nsAString& aTitle)
{
mTitle = aTitle;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetPostData(nsIInputStream** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetPostData(nsIInputStream** aResult)
{
*aResult = mPostData;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetPostData(nsIInputStream* aPostData)
+NS_IMETHODIMP
+nsSHEntry::SetPostData(nsIInputStream* aPostData)
{
mPostData = aPostData;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult)
{
*aResult = mShared->mLayoutHistoryState;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState)
+NS_IMETHODIMP
+nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState)
{
mShared->mLayoutHistoryState = aState;
if (mShared->mLayoutHistoryState) {
- mShared->mLayoutHistoryState->
- SetScrollPositionOnly(!mShared->mSaveLayoutState);
+ mShared->mLayoutHistoryState->SetScrollPositionOnly(
+ !mShared->mSaveLayoutState);
}
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetLoadType(uint32_t * aResult)
+NS_IMETHODIMP
+nsSHEntry::GetLoadType(uint32_t* aResult)
{
*aResult = mLoadType;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetLoadType(uint32_t aLoadType)
+NS_IMETHODIMP
+nsSHEntry::SetLoadType(uint32_t aLoadType)
{
mLoadType = aLoadType;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetID(uint32_t * aResult)
+NS_IMETHODIMP
+nsSHEntry::GetID(uint32_t* aResult)
{
*aResult = mID;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetID(uint32_t aID)
+NS_IMETHODIMP
+nsSHEntry::SetID(uint32_t aID)
{
mID = aID;
return NS_OK;
}
-nsSHEntryShared* nsSHEntry::GetSharedState()
+nsSHEntryShared*
+nsSHEntry::GetSharedState()
{
return mShared;
}
-NS_IMETHODIMP nsSHEntry::GetIsSubFrame(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetIsSubFrame(bool* aFlag)
{
*aFlag = mShared->mIsFrameNavigation;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetIsSubFrame(bool aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetIsSubFrame(bool aFlag)
{
mShared->mIsFrameNavigation = aFlag;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetCacheKey(nsISupports** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetCacheKey(nsISupports** aResult)
{
*aResult = mShared->mCacheKey;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetCacheKey(nsISupports* aCacheKey)
+NS_IMETHODIMP
+nsSHEntry::SetCacheKey(nsISupports* aCacheKey)
{
mShared->mCacheKey = aCacheKey;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetSaveLayoutStateFlag(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetSaveLayoutStateFlag(bool* aFlag)
{
*aFlag = mShared->mSaveLayoutState;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetSaveLayoutStateFlag(bool aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetSaveLayoutStateFlag(bool aFlag)
{
mShared->mSaveLayoutState = aFlag;
if (mShared->mLayoutHistoryState) {
@@ -330,44 +344,48 @@ NS_IMETHODIMP nsSHEntry::SetSaveLayoutStateFlag(bool aFlag)
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetExpirationStatus(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetExpirationStatus(bool* aFlag)
{
*aFlag = mShared->mExpired;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetExpirationStatus(bool aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetExpirationStatus(bool aFlag)
{
mShared->mExpired = aFlag;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::GetContentType(nsACString& aContentType)
+NS_IMETHODIMP
+nsSHEntry::GetContentType(nsACString& aContentType)
{
aContentType = mShared->mContentType;
return NS_OK;
}
-NS_IMETHODIMP nsSHEntry::SetContentType(const nsACString& aContentType)
+NS_IMETHODIMP
+nsSHEntry::SetContentType(const nsACString& aContentType)
{
mShared->mContentType = aContentType;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
- nsIInputStream * aInputStream,
- nsILayoutHistoryState * aLayoutHistoryState,
- nsISupports * aCacheKey, const nsACString& aContentType,
- nsISupports* aOwner,
- uint64_t aDocShellID, bool aDynamicCreation)
+nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
+ nsIInputStream* aInputStream,
+ nsILayoutHistoryState* aLayoutHistoryState,
+ nsISupports* aCacheKey, const nsACString& aContentType,
+ nsISupports* aOwner, uint64_t aDocShellID,
+ bool aDynamicCreation)
{
mURI = aURI;
mTitle = aTitle;
mPostData = aInputStream;
// Set the LoadType by default to loadHistory during creation
- mLoadType = (uint32_t) nsIDocShellLoadInfo::loadHistory;
+ mLoadType = (uint32_t)nsIDocShellLoadInfo::loadHistory;
mShared->mCacheKey = aCacheKey;
mShared->mContentType = aContentType;
@@ -375,7 +393,7 @@ nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
mShared->mDocShellID = aDocShellID;
mShared->mDynamicallyCreated = aDynamicCreation;
- // By default all entries are set false for subframe flag.
+ // By default all entries are set false for subframe flag.
// nsDocShell::CloneAndReplace() which creates entries for
// all subframe navigations, sets the flag to true.
mShared->mIsFrameNavigation = false;
@@ -384,7 +402,7 @@ nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
mShared->mSaveLayoutState = true;
mShared->mLayoutHistoryState = aLayoutHistoryState;
- //By default the page is not expired
+ // By default the page is not expired
mShared->mExpired = false;
mIsSrcdocEntry = false;
@@ -394,7 +412,7 @@ nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
}
NS_IMETHODIMP
-nsSHEntry::Clone(nsISHEntry ** aResult)
+nsSHEntry::Clone(nsISHEntry** aResult)
{
*aResult = new nsSHEntry(*this);
NS_ADDREF(*aResult);
@@ -402,7 +420,7 @@ nsSHEntry::Clone(nsISHEntry ** aResult)
}
NS_IMETHODIMP
-nsSHEntry::GetParent(nsISHEntry ** aResult)
+nsSHEntry::GetParent(nsISHEntry** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mParent;
@@ -411,7 +429,7 @@ nsSHEntry::GetParent(nsISHEntry ** aResult)
}
NS_IMETHODIMP
-nsSHEntry::SetParent(nsISHEntry * aParent)
+nsSHEntry::SetParent(nsISHEntry* aParent)
{
/* parent not Addrefed on purpose to avoid cyclic reference
* Null parent is OK
@@ -423,49 +441,49 @@ nsSHEntry::SetParent(nsISHEntry * aParent)
}
NS_IMETHODIMP
-nsSHEntry::SetWindowState(nsISupports *aState)
+nsSHEntry::SetWindowState(nsISupports* aState)
{
mShared->mWindowState = aState;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::GetWindowState(nsISupports **aState)
+nsSHEntry::GetWindowState(nsISupports** aState)
{
NS_IF_ADDREF(*aState = mShared->mWindowState);
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::SetViewerBounds(const nsIntRect &aBounds)
+nsSHEntry::SetViewerBounds(const nsIntRect& aBounds)
{
mShared->mViewerBounds = aBounds;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::GetViewerBounds(nsIntRect &aBounds)
+nsSHEntry::GetViewerBounds(nsIntRect& aBounds)
{
aBounds = mShared->mViewerBounds;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::GetOwner(nsISupports **aOwner)
+nsSHEntry::GetOwner(nsISupports** aOwner)
{
NS_IF_ADDREF(*aOwner = mShared->mOwner);
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::SetOwner(nsISupports *aOwner)
+nsSHEntry::SetOwner(nsISupports* aOwner)
{
mShared->mOwner = aOwner;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry **aEntry)
+nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry** aEntry)
{
NS_ENSURE_ARG_POINTER(aEntry);
NS_IF_ADDREF(*aEntry = mShared);
@@ -473,18 +491,18 @@ nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry **aEntry)
}
bool
-nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry *aEntry)
+nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry)
{
return static_cast(mShared) == aEntry;
}
NS_IMETHODIMP
-nsSHEntry::AdoptBFCacheEntry(nsISHEntry *aEntry)
+nsSHEntry::AdoptBFCacheEntry(nsISHEntry* aEntry)
{
nsCOMPtr shEntry = do_QueryInterface(aEntry);
NS_ENSURE_STATE(shEntry);
- nsSHEntryShared *shared = shEntry->GetSharedState();
+ nsSHEntryShared* shared = shEntry->GetSharedState();
NS_ENSURE_STATE(shared);
mShared = shared;
@@ -492,11 +510,11 @@ nsSHEntry::AdoptBFCacheEntry(nsISHEntry *aEntry)
}
NS_IMETHODIMP
-nsSHEntry::SharesDocumentWith(nsISHEntry *aEntry, bool *aOut)
+nsSHEntry::SharesDocumentWith(nsISHEntry* aEntry, bool* aOut)
{
NS_ENSURE_ARG_POINTER(aOut);
- nsCOMPtr internal = do_QueryInterface(aEntry);
+ nsCOMPtr internal = do_QueryInterface(aEntry);
NS_ENSURE_STATE(internal);
*aOut = mShared == internal->GetSharedState();
@@ -518,14 +536,14 @@ nsSHEntry::GetIsSrcdocEntry(bool* aIsSrcdocEntry)
}
NS_IMETHODIMP
-nsSHEntry::GetSrcdocData(nsAString &aSrcdocData)
+nsSHEntry::GetSrcdocData(nsAString& aSrcdocData)
{
aSrcdocData = mSrcdocData;
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::SetSrcdocData(const nsAString &aSrcdocData)
+nsSHEntry::SetSrcdocData(const nsAString& aSrcdocData)
{
mSrcdocData = aSrcdocData;
mIsSrcdocEntry = true;
@@ -533,7 +551,7 @@ nsSHEntry::SetSrcdocData(const nsAString &aSrcdocData)
}
NS_IMETHODIMP
-nsSHEntry::GetBaseURI(nsIURI **aBaseURI)
+nsSHEntry::GetBaseURI(nsIURI** aBaseURI)
{
*aBaseURI = mBaseURI;
NS_IF_ADDREF(*aBaseURI);
@@ -541,25 +559,21 @@ nsSHEntry::GetBaseURI(nsIURI **aBaseURI)
}
NS_IMETHODIMP
-nsSHEntry::SetBaseURI(nsIURI *aBaseURI)
+nsSHEntry::SetBaseURI(nsIURI* aBaseURI)
{
mBaseURI = aBaseURI;
return NS_OK;
}
-//*****************************************************************************
-// nsSHEntry: nsISHContainer
-//*****************************************************************************
-
-NS_IMETHODIMP
-nsSHEntry::GetChildCount(int32_t * aCount)
+NS_IMETHODIMP
+nsSHEntry::GetChildCount(int32_t* aCount)
{
*aCount = mChildren.Count();
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
+nsSHEntry::AddChild(nsISHEntry* aChild, int32_t aOffset)
{
if (aChild) {
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
@@ -579,7 +593,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
//
// Assert that aOffset will not be so high as to grow us a lot.
//
- NS_ASSERTION(aOffset < (mChildren.Count()+1023), "Large frames array!\n");
+ NS_ASSERTION(aOffset < (mChildren.Count() + 1023), "Large frames array!\n");
bool newChildIsDyn = false;
if (aChild) {
@@ -634,7 +648,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
}
}
}
-
+
if (dynEntry) {
nsCOMArray tmp;
tmp.SetCount(aOffset - dynEntryIndex + 1);
@@ -642,7 +656,6 @@ nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
NS_ASSERTION(mChildren[aOffset + 1] == dynEntry, "Whaat?");
}
}
-
// Make sure there isn't anything at aOffset.
if (aOffset < mChildren.Count()) {
@@ -664,7 +677,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
}
NS_IMETHODIMP
-nsSHEntry::RemoveChild(nsISHEntry * aChild)
+nsSHEntry::RemoveChild(nsISHEntry* aChild)
{
NS_ENSURE_TRUE(aChild, NS_ERROR_FAILURE);
bool childRemoved = false;
@@ -692,7 +705,7 @@ nsSHEntry::RemoveChild(nsISHEntry * aChild)
}
NS_IMETHODIMP
-nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry ** aResult)
+nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry** aResult)
{
if (aIndex >= 0 && aIndex < mChildren.Count()) {
*aResult = mChildren[aIndex];
@@ -727,7 +740,7 @@ nsSHEntry::ReplaceChild(nsISHEntry* aNewEntry)
}
NS_IMETHODIMP
-nsSHEntry::AddChildShell(nsIDocShellTreeItem *aShell)
+nsSHEntry::AddChildShell(nsIDocShellTreeItem* aShell)
{
NS_ASSERTION(aShell, "Null child shell added to history entry");
mShared->mChildShells.AppendObject(aShell);
@@ -735,7 +748,7 @@ nsSHEntry::AddChildShell(nsIDocShellTreeItem *aShell)
}
NS_IMETHODIMP
-nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem **aShell)
+nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell)
{
NS_IF_ADDREF(*aShell = mShared->mChildShells.SafeObjectAt(aIndex));
return NS_OK;
@@ -749,14 +762,14 @@ nsSHEntry::ClearChildShells()
}
NS_IMETHODIMP
-nsSHEntry::GetRefreshURIList(nsISupportsArray **aList)
+nsSHEntry::GetRefreshURIList(nsISupportsArray** aList)
{
NS_IF_ADDREF(*aList = mShared->mRefreshURIList);
return NS_OK;
}
NS_IMETHODIMP
-nsSHEntry::SetRefreshURIList(nsISupportsArray *aList)
+nsSHEntry::SetRefreshURIList(nsISupportsArray* aList)
{
mShared->mRefreshURIList = aList;
return NS_OK;
@@ -804,7 +817,7 @@ nsSHEntry::HasDetachedEditor()
}
NS_IMETHODIMP
-nsSHEntry::GetStateData(nsIStructuredCloneContainer **aContainer)
+nsSHEntry::GetStateData(nsIStructuredCloneContainer** aContainer)
{
NS_ENSURE_ARG_POINTER(aContainer);
NS_IF_ADDREF(*aContainer = mStateData);
@@ -812,7 +825,7 @@ nsSHEntry::GetStateData(nsIStructuredCloneContainer **aContainer)
}
NS_IMETHODIMP
-nsSHEntry::SetStateData(nsIStructuredCloneContainer *aContainer)
+nsSHEntry::SetStateData(nsIStructuredCloneContainer* aContainer)
{
mStateData = aContainer;
return NS_OK;
@@ -855,9 +868,8 @@ nsSHEntry::SetDocshellID(uint64_t aID)
return NS_OK;
}
-
NS_IMETHODIMP
-nsSHEntry::GetLastTouched(uint32_t *aLastTouched)
+nsSHEntry::GetLastTouched(uint32_t* aLastTouched)
{
*aLastTouched = mShared->mLastTouched;
return NS_OK;
diff --git a/docshell/shistory/src/nsSHEntry.h b/docshell/shistory/src/nsSHEntry.h
index 19e3827faa4..ff771cc4e02 100644
--- a/docshell/shistory/src/nsSHEntry.h
+++ b/docshell/shistory/src/nsSHEntry.h
@@ -26,9 +26,9 @@ class nsSHEntry final : public nsISHEntry,
public nsISHContainer,
public nsISHEntryInternal
{
-public:
+public:
nsSHEntry();
- nsSHEntry(const nsSHEntry &other);
+ nsSHEntry(const nsSHEntry& aOther);
NS_DECL_ISUPPORTS
NS_DECL_NSISHENTRY
@@ -39,7 +39,7 @@ public:
static nsresult Startup();
static void Shutdown();
-
+
private:
~nsSHEntry();
@@ -48,22 +48,22 @@ private:
nsRefPtr mShared;
// See nsSHEntry.idl for comments on these members.
- nsCOMPtr mURI;
- nsCOMPtr mReferrerURI;
- uint32_t mReferrerPolicy;
- nsString mTitle;
+ nsCOMPtr mURI;
+ nsCOMPtr mReferrerURI;
+ uint32_t mReferrerPolicy;
+ nsString mTitle;
nsCOMPtr mPostData;
- uint32_t mLoadType;
- uint32_t mID;
- int32_t mScrollPositionX;
- int32_t mScrollPositionY;
- nsISHEntry* mParent;
- nsCOMArray mChildren;
- bool mURIWasModified;
+ uint32_t mLoadType;
+ uint32_t mID;
+ int32_t mScrollPositionX;
+ int32_t mScrollPositionY;
+ nsISHEntry* mParent;
+ nsCOMArray mChildren;
+ bool mURIWasModified;
nsCOMPtr mStateData;
- bool mIsSrcdocEntry;
- nsString mSrcdocData;
- nsCOMPtr mBaseURI;
+ bool mIsSrcdocEntry;
+ nsString mSrcdocData;
+ nsCOMPtr mBaseURI;
};
#endif /* nsSHEntry_h */
diff --git a/docshell/shistory/src/nsSHEntryShared.cpp b/docshell/shistory/src/nsSHEntryShared.cpp
index 2c3a6fedbba..c4aba9293b9 100644
--- a/docshell/shistory/src/nsSHEntryShared.cpp
+++ b/docshell/shistory/src/nsSHEntryShared.cpp
@@ -29,10 +29,11 @@ uint64_t gSHEntrySharedID = 0;
#define CONTENT_VIEWER_TIMEOUT_SECONDS "browser.sessionhistory.contentViewerTimeout"
// Default this to time out unused content viewers after 30 minutes
-#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30*60)
+#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30 * 60)
typedef nsExpirationTracker HistoryTrackerBase;
-class HistoryTracker final : public HistoryTrackerBase {
+class HistoryTracker final : public HistoryTrackerBase
+{
public:
explicit HistoryTracker(uint32_t aTimeout)
: HistoryTrackerBase(1000 * aTimeout / 2)
@@ -40,13 +41,14 @@ public:
}
protected:
- virtual void NotifyExpired(nsSHEntryShared *aObj) {
+ virtual void NotifyExpired(nsSHEntryShared* aObj)
+ {
RemoveObject(aObj);
aObj->Expire();
}
};
-static HistoryTracker *gHistoryTracker = nullptr;
+static HistoryTracker* gHistoryTracker = nullptr;
void
nsSHEntryShared::EnsureHistoryTracker()
@@ -88,10 +90,9 @@ nsSHEntryShared::~nsSHEntryShared()
if (gHistoryTracker) {
// Check that we're not still on track to expire. We shouldn't be, because
// we just removed ourselves!
- nsExpirationTracker::Iterator
- iterator(gHistoryTracker);
+ nsExpirationTracker::Iterator iterator(gHistoryTracker);
- nsSHEntryShared *elem;
+ nsSHEntryShared* elem;
while ((elem = iterator.Next()) != nullptr) {
NS_ASSERTION(elem != this, "Found dead entry still in the tracker!");
}
@@ -106,7 +107,7 @@ nsSHEntryShared::~nsSHEntryShared()
NS_IMPL_ISUPPORTS(nsSHEntryShared, nsIBFCacheEntry, nsIMutationObserver)
already_AddRefed
-nsSHEntryShared::Duplicate(nsSHEntryShared *aEntry)
+nsSHEntryShared::Duplicate(nsSHEntryShared* aEntry)
{
nsRefPtr newEntry = new nsSHEntryShared();
@@ -124,7 +125,8 @@ nsSHEntryShared::Duplicate(nsSHEntryShared *aEntry)
return newEntry.forget();
}
-void nsSHEntryShared::RemoveFromExpirationTracker()
+void
+nsSHEntryShared::RemoveFromExpirationTracker()
{
if (gHistoryTracker && GetExpirationState()->IsTracked()) {
gHistoryTracker->RemoveObject(this);
@@ -197,7 +199,7 @@ nsSHEntryShared::Expire()
}
nsresult
-nsSHEntryShared::SetContentViewer(nsIContentViewer *aViewer)
+nsSHEntryShared::SetContentViewer(nsIContentViewer* aViewer)
{
NS_PRECONDITION(!aViewer || !mContentViewer,
"SHEntryShared already contains viewer");
@@ -229,8 +231,7 @@ nsSHEntryShared::SetContentViewer(nsIContentViewer *aViewer)
nsresult
nsSHEntryShared::RemoveFromBFCacheSync()
{
- NS_ASSERTION(mContentViewer && mDocument,
- "we're not in the bfcache!");
+ NS_ASSERTION(mContentViewer && mDocument, "we're not in the bfcache!");
nsCOMPtr viewer = mContentViewer;
DropPresentationState();
@@ -249,9 +250,10 @@ class DestroyViewerEvent : public nsRunnable
{
public:
DestroyViewerEvent(nsIContentViewer* aViewer, nsIDocument* aDocument)
- : mViewer(aViewer),
- mDocument(aDocument)
- {}
+ : mViewer(aViewer)
+ , mDocument(aDocument)
+ {
+ }
NS_IMETHOD Run()
{
@@ -268,14 +270,12 @@ public:
nsresult
nsSHEntryShared::RemoveFromBFCacheAsync()
{
- NS_ASSERTION(mContentViewer && mDocument,
- "we're not in the bfcache!");
+ NS_ASSERTION(mContentViewer && mDocument, "we're not in the bfcache!");
// Release the reference to the contentviewer asynchronously so that the
// document doesn't get nuked mid-mutation.
- nsCOMPtr evt =
- new DestroyViewerEvent(mContentViewer, mDocument);
+ nsCOMPtr evt = new DestroyViewerEvent(mContentViewer, mDocument);
nsresult rv = NS_DispatchToCurrentThread(evt);
if (NS_FAILED(rv)) {
NS_WARNING("failed to dispatch DestroyViewerEvent");
@@ -293,16 +293,12 @@ nsSHEntryShared::RemoveFromBFCacheAsync()
}
nsresult
-nsSHEntryShared::GetID(uint64_t *aID)
+nsSHEntryShared::GetID(uint64_t* aID)
{
*aID = mID;
return NS_OK;
}
-//*****************************************************************************
-// nsSHEntryShared: nsIMutationObserver
-//*****************************************************************************
-
void
nsSHEntryShared::NodeWillBeDestroyed(const nsINode* aNode)
{
@@ -372,6 +368,6 @@ nsSHEntryShared::ContentRemoved(nsIDocument* aDocument,
}
void
-nsSHEntryShared::ParentChainChanged(nsIContent *aContent)
+nsSHEntryShared::ParentChainChanged(nsIContent* aContent)
{
}
diff --git a/docshell/shistory/src/nsSHEntryShared.h b/docshell/shistory/src/nsSHEntryShared.h
index 6559fa51634..5b619201b02 100644
--- a/docshell/shistory/src/nsSHEntryShared.h
+++ b/docshell/shistory/src/nsSHEntryShared.h
@@ -30,64 +30,65 @@ class nsISupportsArray;
// back/forward cache.
//
// nsSHEntryShared is the vehicle for this sharing.
-class nsSHEntryShared final : public nsIBFCacheEntry,
- public nsIMutationObserver
+class nsSHEntryShared final
+ : public nsIBFCacheEntry
+ , public nsIMutationObserver
{
- public:
- static void EnsureHistoryTracker();
- static void Shutdown();
+public:
+ static void EnsureHistoryTracker();
+ static void Shutdown();
- nsSHEntryShared();
+ nsSHEntryShared();
- NS_DECL_ISUPPORTS
- NS_DECL_NSIMUTATIONOBSERVER
- NS_DECL_NSIBFCACHEENTRY
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIMUTATIONOBSERVER
+ NS_DECL_NSIBFCACHEENTRY
- private:
- ~nsSHEntryShared();
+private:
+ ~nsSHEntryShared();
- friend class nsSHEntry;
+ friend class nsSHEntry;
- friend class HistoryTracker;
- friend class nsExpirationTracker;
- nsExpirationState *GetExpirationState() { return &mExpirationState; }
+ friend class HistoryTracker;
+ friend class nsExpirationTracker;
+ nsExpirationState *GetExpirationState() { return &mExpirationState; }
- static already_AddRefed Duplicate(nsSHEntryShared *aEntry);
+ static already_AddRefed Duplicate(nsSHEntryShared* aEntry);
- void RemoveFromExpirationTracker();
- void Expire();
- nsresult SyncPresentationState();
- void DropPresentationState();
+ void RemoveFromExpirationTracker();
+ void Expire();
+ nsresult SyncPresentationState();
+ void DropPresentationState();
- nsresult SetContentViewer(nsIContentViewer *aViewer);
+ nsresult SetContentViewer(nsIContentViewer* aViewer);
- // See nsISHEntry.idl for an explanation of these members.
+ // See nsISHEntry.idl for an explanation of these members.
- // These members are copied by nsSHEntryShared::Duplicate(). If you add a
- // member here, be sure to update the Duplicate() implementation.
- uint64_t mDocShellID;
- nsCOMArray mChildShells;
- nsCOMPtr mOwner;
- nsCString mContentType;
- bool mIsFrameNavigation;
- bool mSaveLayoutState;
- bool mSticky;
- bool mDynamicallyCreated;
- nsCOMPtr mCacheKey;
- uint32_t mLastTouched;
+ // These members are copied by nsSHEntryShared::Duplicate(). If you add a
+ // member here, be sure to update the Duplicate() implementation.
+ uint64_t mDocShellID;
+ nsCOMArray mChildShells;
+ nsCOMPtr mOwner;
+ nsCString mContentType;
+ bool mIsFrameNavigation;
+ bool mSaveLayoutState;
+ bool mSticky;
+ bool mDynamicallyCreated;
+ nsCOMPtr mCacheKey;
+ uint32_t mLastTouched;
- // These members aren't copied by nsSHEntryShared::Duplicate() because
- // they're specific to a particular content viewer.
- uint64_t mID;
- nsCOMPtr mContentViewer;
- nsCOMPtr mDocument;
- nsCOMPtr mLayoutHistoryState;
- bool mExpired;
- nsCOMPtr mWindowState;
- nsIntRect mViewerBounds;
- nsCOMPtr mRefreshURIList;
- nsExpirationState mExpirationState;
- nsAutoPtr mEditorData;
+ // These members aren't copied by nsSHEntryShared::Duplicate() because
+ // they're specific to a particular content viewer.
+ uint64_t mID;
+ nsCOMPtr mContentViewer;
+ nsCOMPtr mDocument;
+ nsCOMPtr mLayoutHistoryState;
+ bool mExpired;
+ nsCOMPtr mWindowState;
+ nsIntRect mViewerBounds;
+ nsCOMPtr mRefreshURIList;
+ nsExpirationState mExpirationState;
+ nsAutoPtr mEditorData;
};
#endif
diff --git a/docshell/shistory/src/nsSHTransaction.cpp b/docshell/shistory/src/nsSHTransaction.cpp
index 1768a44efdd..71c42c14150 100644
--- a/docshell/shistory/src/nsSHTransaction.cpp
+++ b/docshell/shistory/src/nsSHTransaction.cpp
@@ -4,80 +4,66 @@
* 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/. */
-// Local Includes
#include "nsSHTransaction.h"
#include "nsISHEntry.h"
-//*****************************************************************************
-//*** nsSHTransaction: Object Management
-//*****************************************************************************
-
-nsSHTransaction::nsSHTransaction() : mPersist(true), mPrev(nullptr)
+nsSHTransaction::nsSHTransaction()
+ : mPersist(true)
+ , mPrev(nullptr)
{
}
-
nsSHTransaction::~nsSHTransaction()
{
}
-//*****************************************************************************
-// nsSHTransaction: nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF(nsSHTransaction)
NS_IMPL_RELEASE(nsSHTransaction)
NS_INTERFACE_MAP_BEGIN(nsSHTransaction)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
- NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
+ NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
NS_INTERFACE_MAP_END
-//*****************************************************************************
-// nsSHTransaction: nsISHTransaction
-//*****************************************************************************
-
NS_IMETHODIMP
nsSHTransaction::Create(nsISHEntry* aSHEntry, nsISHTransaction* aPrev)
{
- SetSHEntry(aSHEntry);
- if(aPrev)
- aPrev->SetNext(this);
+ SetSHEntry(aSHEntry);
+ if (aPrev) {
+ aPrev->SetNext(this);
+ }
- SetPrev(aPrev);
- return NS_OK;
+ SetPrev(aPrev);
+ return NS_OK;
}
NS_IMETHODIMP
-nsSHTransaction::GetSHEntry(nsISHEntry ** aResult)
+nsSHTransaction::GetSHEntry(nsISHEntry** aResult)
{
- NS_ENSURE_ARG_POINTER(aResult);
- *aResult = mSHEntry;
- NS_IF_ADDREF(*aResult);
- return NS_OK;
+ NS_ENSURE_ARG_POINTER(aResult);
+ *aResult = mSHEntry;
+ NS_IF_ADDREF(*aResult);
+ return NS_OK;
}
-
NS_IMETHODIMP
-nsSHTransaction::SetSHEntry(nsISHEntry * aSHEntry)
+nsSHTransaction::SetSHEntry(nsISHEntry* aSHEntry)
{
- mSHEntry = aSHEntry;
- return NS_OK;
+ mSHEntry = aSHEntry;
+ return NS_OK;
}
-
NS_IMETHODIMP
-nsSHTransaction::GetNext(nsISHTransaction * * aResult)
+nsSHTransaction::GetNext(nsISHTransaction** aResult)
{
- NS_ENSURE_ARG_POINTER(aResult);
- *aResult = mNext;
- NS_IF_ADDREF(*aResult);
- return NS_OK;
+ NS_ENSURE_ARG_POINTER(aResult);
+ *aResult = mNext;
+ NS_IF_ADDREF(*aResult);
+ return NS_OK;
}
-
NS_IMETHODIMP
-nsSHTransaction::SetNext(nsISHTransaction * aNext)
+nsSHTransaction::SetNext(nsISHTransaction* aNext)
{
if (aNext) {
NS_ENSURE_SUCCESS(aNext->SetPrev(this), NS_ERROR_FAILURE);
@@ -88,34 +74,34 @@ nsSHTransaction::SetNext(nsISHTransaction * aNext)
}
NS_IMETHODIMP
-nsSHTransaction::SetPrev(nsISHTransaction * aPrev)
+nsSHTransaction::SetPrev(nsISHTransaction* aPrev)
{
- /* This is weak reference to parent. Do not Addref it */
- mPrev = aPrev;
- return NS_OK;
+ /* This is weak reference to parent. Do not Addref it */
+ mPrev = aPrev;
+ return NS_OK;
}
nsresult
-nsSHTransaction::GetPrev(nsISHTransaction ** aResult)
+nsSHTransaction::GetPrev(nsISHTransaction** aResult)
{
- NS_ENSURE_ARG_POINTER(aResult);
- *aResult = mPrev;
- NS_IF_ADDREF(*aResult);
- return NS_OK;
+ NS_ENSURE_ARG_POINTER(aResult);
+ *aResult = mPrev;
+ NS_IF_ADDREF(*aResult);
+ return NS_OK;
}
NS_IMETHODIMP
nsSHTransaction::SetPersist(bool aPersist)
{
- mPersist = aPersist;
- return NS_OK;
+ mPersist = aPersist;
+ return NS_OK;
}
NS_IMETHODIMP
nsSHTransaction::GetPersist(bool* aPersist)
{
- NS_ENSURE_ARG_POINTER(aPersist);
+ NS_ENSURE_ARG_POINTER(aPersist);
- *aPersist = mPersist;
- return NS_OK;
+ *aPersist = mPersist;
+ return NS_OK;
}
diff --git a/docshell/shistory/src/nsSHTransaction.h b/docshell/shistory/src/nsSHTransaction.h
index 8c7ba2afd5c..c4c7d0763b1 100644
--- a/docshell/shistory/src/nsSHTransaction.h
+++ b/docshell/shistory/src/nsSHTransaction.h
@@ -15,25 +15,23 @@
class nsISHEntry;
-class nsSHTransaction: public nsISHTransaction
+class nsSHTransaction : public nsISHTransaction
{
public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSISHTRANSACTION
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSISHTRANSACTION
- nsSHTransaction();
+ nsSHTransaction();
protected:
- virtual ~nsSHTransaction();
-
+ virtual ~nsSHTransaction();
protected:
- bool mPersist;
+ bool mPersist;
- nsISHTransaction * mPrev; // Weak Reference
- nsCOMPtr mNext;
- nsCOMPtr mSHEntry;
+ nsISHTransaction* mPrev; // Weak Reference
+ nsCOMPtr mNext;
+ nsCOMPtr mSHEntry;
};
-
-#endif /* nsSHTransaction_h */
+#endif /* nsSHTransaction_h */
diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp
index d8f104a02e8..ccf91bb1d26 100644
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// Local Includes
#include "nsSHistory.h"
#include
@@ -47,9 +46,9 @@ static const char* kObservedPrefs[] = {
nullptr
};
-static int32_t gHistoryMaxSize = 50;
+static int32_t gHistoryMaxSize = 50;
// Max viewers allowed per SHistory objects
-static const int32_t gHistoryMaxViewers = 3;
+static const int32_t gHistoryMaxViewers = 3;
// List of all SHistory objects, used for content viewer cache eviction
static PRCList gSHistoryList;
// Max viewers allowed total, across all SHistory objects - negative default
@@ -65,9 +64,10 @@ static uint32_t gTouchCounter = 0;
static PRLogModuleInfo*
GetSHistoryLog()
{
- static PRLogModuleInfo *sLog;
- if (!sLog)
+ static PRLogModuleInfo* sLog;
+ if (!sLog) {
sLog = PR_NewLogModule("nsSHistory");
+ }
return sLog;
}
#define LOG(format) PR_LOG(GetSHistoryLog(), PR_LOG_DEBUG, format)
@@ -155,20 +155,16 @@ GetSHistoryLog()
} \
PR_END_MACRO
-enum HistCmd{
+enum HistCmd
+{
HIST_CMD_BACK,
HIST_CMD_FORWARD,
HIST_CMD_GOTOINDEX,
HIST_CMD_RELOAD
-} ;
-
-//*****************************************************************************
-//*** nsSHistoryObserver
-//*****************************************************************************
+};
class nsSHistoryObserver final : public nsIObserver
{
-
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
@@ -184,8 +180,8 @@ StaticRefPtr gObserver;
NS_IMPL_ISUPPORTS(nsSHistoryObserver, nsIObserver)
NS_IMETHODIMP
-nsSHistoryObserver::Observe(nsISupports *aSubject, const char *aTopic,
- const char16_t *aData)
+nsSHistoryObserver::Observe(nsISupports* aSubject, const char* aTopic,
+ const char16_t* aData)
{
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
nsSHistory::UpdatePrefs();
@@ -201,7 +197,7 @@ nsSHistoryObserver::Observe(nsISupports *aSubject, const char *aTopic,
namespace {
already_AddRefed
-GetContentViewerForTransaction(nsISHTransaction *aTrans)
+GetContentViewerForTransaction(nsISHTransaction* aTrans)
{
nsCOMPtr entry;
aTrans->GetSHEntry(getter_AddRefs(entry));
@@ -217,7 +213,7 @@ GetContentViewerForTransaction(nsISHTransaction *aTrans)
}
void
-EvictContentViewerForTransaction(nsISHTransaction *aTrans)
+EvictContentViewerForTransaction(nsISHTransaction* aTrans)
{
nsCOMPtr entry;
aTrans->GetSHEntry(getter_AddRefs(entry));
@@ -226,12 +222,12 @@ EvictContentViewerForTransaction(nsISHTransaction *aTrans)
entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
getter_AddRefs(viewer));
if (viewer) {
- NS_ASSERTION(ownerEntry,
- "Content viewer exists but its SHEntry is null");
+ NS_ASSERTION(ownerEntry, "Content viewer exists but its SHEntry is null");
LOG_SHENTRY_SPEC(("Evicting content viewer 0x%p for "
"owning SHEntry 0x%p at %s.",
- viewer.get(), ownerEntry.get(), _spec), ownerEntry);
+ viewer.get(), ownerEntry.get(), _spec),
+ ownerEntry);
// Drop the presentation state before destroying the viewer, so that
// document teardown is able to correctly persist the state.
@@ -243,41 +239,31 @@ EvictContentViewerForTransaction(nsISHTransaction *aTrans)
} // anonymous namespace
-//*****************************************************************************
-//*** nsSHistory: Object Management
-//*****************************************************************************
-
-nsSHistory::nsSHistory() : mListRoot(nullptr), mIndex(-1), mLength(0), mRequestedIndex(-1)
+nsSHistory::nsSHistory()
+ : mIndex(-1)
+ , mLength(0)
+ , mRequestedIndex(-1)
{
// Add this new SHistory object to the list
PR_APPEND_LINK(this, &gSHistoryList);
}
-
nsSHistory::~nsSHistory()
{
// Remove this SHistory object from the list
PR_REMOVE_LINK(this);
}
-//*****************************************************************************
-// nsSHistory: nsISupports
-//*****************************************************************************
-
NS_IMPL_ADDREF(nsSHistory)
NS_IMPL_RELEASE(nsSHistory)
NS_INTERFACE_MAP_BEGIN(nsSHistory)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
- NS_INTERFACE_MAP_ENTRY(nsISHistory)
- NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
- NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
+ NS_INTERFACE_MAP_ENTRY(nsISHistory)
+ NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
+ NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
NS_INTERFACE_MAP_END
-//*****************************************************************************
-// nsSHistory: nsISHistory
-//*****************************************************************************
-
// static
uint32_t
nsSHistory::CalcMaxTotalViewers()
@@ -301,14 +287,16 @@ nsSHistory::CalcMaxTotalViewers()
// 4096 Mb 8
uint64_t bytes = PR_GetPhysicalMemorySize();
- if (bytes == 0)
+ if (bytes == 0) {
return 0;
+ }
// Conversion from unsigned int64_t to double doesn't work on all platforms.
// We need to truncate the value at INT64_MAX to make sure we don't
// overflow.
- if (bytes > INT64_MAX)
+ if (bytes > INT64_MAX) {
bytes = INT64_MAX;
+ }
double kBytesD = (double)(bytes >> 10);
@@ -316,10 +304,10 @@ nsSHistory::CalcMaxTotalViewers()
// except that we divide the final memory calculation by 4, since
// we assume each ContentViewer takes on average 4MB
uint32_t viewers = 0;
- double x = std::log(kBytesD)/std::log(2.0) - 14;
+ double x = std::log(kBytesD) / std::log(2.0) - 14;
if (x > 0) {
- viewers = (uint32_t)(x * x - x + 2.001); // add .001 for rounding
- viewers /= 4;
+ viewers = (uint32_t)(x * x - x + 2.001); // add .001 for rounding
+ viewers /= 4;
}
// Cap it off at 8 max
@@ -356,7 +344,7 @@ nsSHistory::Startup()
if (gHistoryMaxSize < defaultHistoryMaxSize) {
gHistoryMaxSize = defaultHistoryMaxSize;
}
-
+
// Allow the user to override the max total number of cached viewers,
// but keep the per SHistory cached viewer limit constant
if (!gObserver) {
@@ -368,8 +356,7 @@ nsSHistory::Startup()
if (obsSvc) {
// Observe empty-cache notifications so tahat clearing the disk/memory
// cache will also evict all content viewers.
- obsSvc->AddObserver(gObserver,
- "cacheservice:empty-cache", false);
+ obsSvc->AddObserver(gObserver, "cacheservice:empty-cache", false);
// Same for memory-pressure notifications
obsSvc->AddObserver(gObserver, "memory-pressure", false);
@@ -397,34 +384,36 @@ nsSHistory::Shutdown()
}
}
-/* Add an entry to the History list at mIndex and
+/* Add an entry to the History list at mIndex and
* increment the index to point to the new entry
*/
NS_IMETHODIMP
-nsSHistory::AddEntry(nsISHEntry * aSHEntry, bool aPersist)
+nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
{
NS_ENSURE_ARG(aSHEntry);
nsCOMPtr currentTxn;
- if(mListRoot)
+ if (mListRoot) {
GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
+ }
bool currentPersist = true;
- if(currentTxn)
+ if (currentTxn) {
currentTxn->GetPersist(¤tPersist);
+ }
int32_t currentIndex = mIndex;
- if(!currentPersist)
- {
+ if (!currentPersist) {
NOTIFY_LISTENERS(OnHistoryReplaceEntry, (currentIndex));
- NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry),NS_ERROR_FAILURE);
+ NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry), NS_ERROR_FAILURE);
currentTxn->SetPersist(aPersist);
return NS_OK;
}
- nsCOMPtr txn(do_CreateInstance(NS_SHTRANSACTION_CONTRACTID));
+ nsCOMPtr txn(
+ do_CreateInstance(NS_SHTRANSACTION_CONTRACTID));
NS_ENSURE_TRUE(txn, NS_ERROR_FAILURE);
nsCOMPtr uri;
@@ -437,31 +426,33 @@ nsSHistory::AddEntry(nsISHEntry * aSHEntry, bool aPersist)
GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
}
- // Set the ShEntry and parent for the transaction. setting the
+ // Set the ShEntry and parent for the transaction. setting the
// parent will properly set the parent child relationship
txn->SetPersist(aPersist);
NS_ENSURE_SUCCESS(txn->Create(aSHEntry, currentTxn), NS_ERROR_FAILURE);
-
+
// A little tricky math here... Basically when adding an object regardless of
// what the length was before, it should always be set back to the current and
// lop off the forward.
mLength = (++mIndex + 1);
// If this is the very first transaction, initialize the list
- if(!mListRoot)
+ if (!mListRoot) {
mListRoot = txn;
+ }
// Purge History list if it is too long
- if ((gHistoryMaxSize >= 0) && (mLength > gHistoryMaxSize))
- PurgeHistory(mLength-gHistoryMaxSize);
-
+ if (gHistoryMaxSize >= 0 && mLength > gHistoryMaxSize) {
+ PurgeHistory(mLength - gHistoryMaxSize);
+ }
+
RemoveDynEntries(mIndex - 1, mIndex);
return NS_OK;
}
/* Get size of the history list */
NS_IMETHODIMP
-nsSHistory::GetCount(int32_t * aResult)
+nsSHistory::GetCount(int32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = mLength;
@@ -470,7 +461,7 @@ nsSHistory::GetCount(int32_t * aResult)
/* Get index of the history list */
NS_IMETHODIMP
-nsSHistory::GetIndex(int32_t * aResult)
+nsSHistory::GetIndex(int32_t* aResult)
{
NS_PRECONDITION(aResult, "null out param?");
*aResult = mIndex;
@@ -479,7 +470,7 @@ nsSHistory::GetIndex(int32_t * aResult)
/* Get the requestedIndex */
NS_IMETHODIMP
-nsSHistory::GetRequestedIndex(int32_t * aResult)
+nsSHistory::GetRequestedIndex(int32_t* aResult)
{
NS_PRECONDITION(aResult, "null out param?");
*aResult = mRequestedIndex;
@@ -488,7 +479,8 @@ nsSHistory::GetRequestedIndex(int32_t * aResult)
/* Get the entry at a given index */
NS_IMETHODIMP
-nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aResult)
+nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex,
+ nsISHEntry** aResult)
{
nsresult rv;
nsCOMPtr txn;
@@ -496,45 +488,47 @@ nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aRes
/* GetTransactionAtIndex ensures aResult is valid and validates aIndex */
rv = GetTransactionAtIndex(aIndex, getter_AddRefs(txn));
if (NS_SUCCEEDED(rv) && txn) {
- //Get the Entry from the transaction
+ // Get the Entry from the transaction
rv = txn->GetSHEntry(aResult);
if (NS_SUCCEEDED(rv) && (*aResult)) {
// Set mIndex to the requested index, if asked to do so..
if (aModifyIndex) {
mIndex = aIndex;
}
- } //entry
- } //Transaction
+ }
+ }
return rv;
}
/* Get the transaction at a given index */
NS_IMETHODIMP
-nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult)
+nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aResult);
- if ((mLength <= 0) || (aIndex < 0) || (aIndex >= mLength))
+ if (mLength <= 0 || aIndex < 0 || aIndex >= mLength) {
return NS_ERROR_FAILURE;
+ }
- if (!mListRoot)
+ if (!mListRoot) {
return NS_ERROR_FAILURE;
+ }
- if (aIndex == 0)
- {
+ if (aIndex == 0) {
*aResult = mListRoot;
NS_ADDREF(*aResult);
return NS_OK;
- }
- int32_t cnt=0;
- nsCOMPtr tempPtr;
+ }
+ int32_t cnt = 0;
+ nsCOMPtr tempPtr;
rv = GetRootTransaction(getter_AddRefs(tempPtr));
- if (NS_FAILED(rv) || !tempPtr)
+ if (NS_FAILED(rv) || !tempPtr) {
return NS_ERROR_FAILURE;
+ }
- while(1) {
+ while (true) {
nsCOMPtr ptr;
rv = tempPtr->GetNext(getter_AddRefs(ptr));
if (NS_SUCCEEDED(rv) && ptr) {
@@ -542,23 +536,22 @@ nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult)
if (cnt == aIndex) {
ptr.forget(aResult);
break;
- }
- else {
+ } else {
tempPtr = ptr;
continue;
}
- } //NS_SUCCEEDED
- else
+ } else {
return NS_ERROR_FAILURE;
- } // while
-
+ }
+ }
+
return NS_OK;
}
-
/* Get the index of a given entry */
NS_IMETHODIMP
-nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult) {
+nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult)
+{
NS_ENSURE_ARG(aSHEntry);
NS_ENSURE_ARG_POINTER(aResult);
*aResult = -1;
@@ -598,31 +591,32 @@ nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult) {
return NS_OK;
}
-
#ifdef DEBUG
nsresult
nsSHistory::PrintHistory()
{
-
- nsCOMPtr txn;
+ nsCOMPtr txn;
int32_t index = 0;
nsresult rv;
- if (!mListRoot)
+ if (!mListRoot) {
return NS_ERROR_FAILURE;
+ }
txn = mListRoot;
-
+
while (1) {
- if (!txn)
+ if (!txn) {
break;
- nsCOMPtr entry;
+ }
+ nsCOMPtr entry;
rv = txn->GetSHEntry(getter_AddRefs(entry));
- if (NS_FAILED(rv) && !entry)
+ if (NS_FAILED(rv) && !entry) {
return NS_ERROR_FAILURE;
+ }
nsCOMPtr layoutHistoryState;
- nsCOMPtr uri;
+ nsCOMPtr uri;
nsXPIDLString title;
entry->GetLayoutHistoryState(getter_AddRefs(layoutHistoryState));
@@ -631,8 +625,9 @@ nsSHistory::PrintHistory()
#if 0
nsAutoCString url;
- if (uri)
- uri->GetSpec(url);
+ if (uri) {
+ uri->GetSpec(url);
+ }
printf("**** SH Transaction #%d, Entry = %x\n", index, entry.get());
printf("\t\t URL = %s\n", url.get());
@@ -647,28 +642,27 @@ nsSHistory::PrintHistory()
txn = next;
index++;
continue;
- }
- else
+ } else {
break;
+ }
}
return NS_OK;
}
#endif
-
NS_IMETHODIMP
-nsSHistory::GetRootTransaction(nsISHTransaction ** aResult)
+nsSHistory::GetRootTransaction(nsISHTransaction** aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
- *aResult=mListRoot;
+ *aResult = mListRoot;
NS_IF_ADDREF(*aResult);
return NS_OK;
}
/* Get the max size of the history list */
NS_IMETHODIMP
-nsSHistory::GetMaxLength(int32_t * aResult)
+nsSHistory::GetMaxLength(int32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = gHistoryMaxSize;
@@ -679,23 +673,26 @@ nsSHistory::GetMaxLength(int32_t * aResult)
NS_IMETHODIMP
nsSHistory::SetMaxLength(int32_t aMaxSize)
{
- if (aMaxSize < 0)
+ if (aMaxSize < 0) {
return NS_ERROR_ILLEGAL_VALUE;
+ }
gHistoryMaxSize = aMaxSize;
- if (mLength > aMaxSize)
- PurgeHistory(mLength-aMaxSize);
+ if (mLength > aMaxSize) {
+ PurgeHistory(mLength - aMaxSize);
+ }
return NS_OK;
}
NS_IMETHODIMP
nsSHistory::PurgeHistory(int32_t aEntries)
{
- if (mLength <= 0 || aEntries <= 0)
+ if (mLength <= 0 || aEntries <= 0) {
return NS_ERROR_FAILURE;
+ }
aEntries = std::min(aEntries, mLength);
-
+
bool purgeHistory = true;
NOTIFY_LISTENERS_CANCELABLE(OnHistoryPurge, purgeHistory,
(aEntries, &purgeHistory));
@@ -716,7 +713,7 @@ nsSHistory::PurgeHistory(int32_t aEntries)
if (mListRoot) {
mListRoot->SetPrev(nullptr);
}
- cnt++;
+ cnt++;
}
mLength -= cnt;
mIndex -= cnt;
@@ -727,57 +724,58 @@ nsSHistory::PurgeHistory(int32_t aEntries)
mIndex = -1;
}
- if (mRootDocShell)
+ if (mRootDocShell) {
mRootDocShell->HistoryPurged(cnt);
+ }
return NS_OK;
}
-
NS_IMETHODIMP
-nsSHistory::AddSHistoryListener(nsISHistoryListener * aListener)
+nsSHistory::AddSHistoryListener(nsISHistoryListener* aListener)
{
NS_ENSURE_ARG_POINTER(aListener);
// Check if the listener supports Weak Reference. This is a must.
- // This listener functionality is used by embedders and we want to
+ // This listener functionality is used by embedders and we want to
// have the right ownership with who ever listens to SHistory
nsWeakPtr listener = do_GetWeakReference(aListener);
- if (!listener) return NS_ERROR_FAILURE;
+ if (!listener) {
+ return NS_ERROR_FAILURE;
+ }
return mListeners.AppendElementUnlessExists(listener) ?
NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
-
NS_IMETHODIMP
-nsSHistory::RemoveSHistoryListener(nsISHistoryListener * aListener)
+nsSHistory::RemoveSHistoryListener(nsISHistoryListener* aListener)
{
// Make sure the listener that wants to be removed is the
- // one we have in store.
+ // one we have in store.
nsWeakPtr listener = do_GetWeakReference(aListener);
mListeners.RemoveElement(listener);
return NS_OK;
}
-
/* Replace an entry in the History list at a particular index.
* Do not update index or count.
*/
NS_IMETHODIMP
-nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry * aReplaceEntry)
+nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry)
{
NS_ENSURE_ARG(aReplaceEntry);
nsresult rv;
nsCOMPtr currentTxn;
- if (!mListRoot) // Session History is not initialised.
+ if (!mListRoot) {
+ // Session History is not initialised.
return NS_ERROR_FAILURE;
+ }
rv = GetTransactionAtIndex(aIndex, getter_AddRefs(currentTxn));
- if(currentTxn)
- {
+ if (currentTxn) {
NOTIFY_LISTENERS(OnHistoryReplaceEntry, (aIndex));
// Set the replacement entry in the transaction
@@ -815,35 +813,30 @@ nsSHistory::EvictAllContentViewers()
while (trans) {
EvictContentViewerForTransaction(trans);
- nsISHTransaction *temp = trans;
+ nsISHTransaction* temp = trans;
temp->GetNext(getter_AddRefs(trans));
}
return NS_OK;
}
-
-
-//*****************************************************************************
-// nsSHistory: nsIWebNavigation
-//*****************************************************************************
-
NS_IMETHODIMP
-nsSHistory::GetCanGoBack(bool * aCanGoBack)
+nsSHistory::GetCanGoBack(bool* aCanGoBack)
{
NS_ENSURE_ARG_POINTER(aCanGoBack);
*aCanGoBack = false;
int32_t index = -1;
NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
- if(index > 0)
- *aCanGoBack = true;
+ if (index > 0) {
+ *aCanGoBack = true;
+ }
return NS_OK;
}
NS_IMETHODIMP
-nsSHistory::GetCanGoForward(bool * aCanGoForward)
+nsSHistory::GetCanGoForward(bool* aCanGoForward)
{
NS_ENSURE_ARG_POINTER(aCanGoForward);
*aCanGoForward = false;
@@ -854,8 +847,9 @@ nsSHistory::GetCanGoForward(bool * aCanGoForward)
NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(GetCount(&count), NS_ERROR_FAILURE);
- if((index >= 0) && (index < (count - 1)))
+ if (index >= 0 && index < (count - 1)) {
*aCanGoForward = true;
+ }
return NS_OK;
}
@@ -866,50 +860,41 @@ nsSHistory::GoBack()
bool canGoBack = false;
GetCanGoBack(&canGoBack);
- if (!canGoBack) // Can't go back
+ if (!canGoBack) {
return NS_ERROR_UNEXPECTED;
- return LoadEntry(mIndex-1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
+ }
+ return LoadEntry(mIndex - 1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
}
-
NS_IMETHODIMP
nsSHistory::GoForward()
{
bool canGoForward = false;
GetCanGoForward(&canGoForward);
- if (!canGoForward) // Can't go forward
+ if (!canGoForward) {
return NS_ERROR_UNEXPECTED;
- return LoadEntry(mIndex+1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_FORWARD);
+ }
+ return LoadEntry(mIndex + 1, nsIDocShellLoadInfo::loadHistory,
+ HIST_CMD_FORWARD);
}
NS_IMETHODIMP
nsSHistory::Reload(uint32_t aReloadFlags)
{
nsDocShellInfoLoadType loadType;
- if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
- aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
- {
+ if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
+ aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
loadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
- }
- else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY)
- {
+ } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) {
loadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
- }
- else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
- {
+ } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
loadType = nsIDocShellLoadInfo::loadReloadBypassCache;
- }
- else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE)
- {
+ } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE) {
loadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
- }
- else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT)
- {
+ } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
loadType = nsIDocShellLoadInfo::loadReloadMixedContent;
- }
- else
- {
+ } else {
loadType = nsIDocShellLoadInfo::loadReloadNormal;
}
@@ -922,8 +907,9 @@ nsSHistory::Reload(uint32_t aReloadFlags)
GetCurrentURI(getter_AddRefs(currentURI));
NOTIFY_LISTENERS_CANCELABLE(OnHistoryReload, canNavigate,
(currentURI, aReloadFlags, &canNavigate));
- if (!canNavigate)
+ if (!canNavigate) {
return NS_OK;
+ }
return LoadEntry(mIndex, loadType, HIST_CMD_RELOAD);
}
@@ -937,8 +923,9 @@ nsSHistory::ReloadCurrentEntry()
GetCurrentURI(getter_AddRefs(currentURI));
NOTIFY_LISTENERS_CANCELABLE(OnHistoryGotoIndex, canNavigate,
(mIndex, currentURI, &canNavigate));
- if (!canNavigate)
+ if (!canNavigate) {
return NS_OK;
+ }
return LoadEntry(mIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
}
@@ -992,7 +979,7 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
LOG(("EvictOutOfRangeWindowContentViewers(index=%d), "
"mLength=%d. Safe range [%d, %d]",
- aIndex, mLength, startSafeIndex, endSafeIndex));
+ aIndex, mLength, startSafeIndex, endSafeIndex));
// The content viewers in range aIndex -/+ gHistoryMaxViewers will not be
// evicted. Collect a set of them so we don't accidentally evict one of them
@@ -1003,7 +990,7 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
for (int32_t i = startSafeIndex; trans && i <= endSafeIndex; i++) {
nsCOMPtr viewer = GetContentViewerForTransaction(trans);
safeViewers.AppendObject(viewer);
- nsISHTransaction *temp = trans;
+ nsISHTransaction* temp = trans;
temp->GetNext(getter_AddRefs(trans));
}
@@ -1015,7 +1002,7 @@ nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
EvictContentViewerForTransaction(trans);
}
- nsISHTransaction *temp = trans;
+ nsISHTransaction* temp = trans;
temp->GetNext(getter_AddRefs(trans));
}
}
@@ -1025,7 +1012,7 @@ namespace {
class TransactionAndDistance
{
public:
- TransactionAndDistance(nsISHTransaction *aTrans, uint32_t aDist)
+ TransactionAndDistance(nsISHTransaction* aTrans, uint32_t aDist)
: mTransaction(aTrans)
, mDistance(aDist)
{
@@ -1044,7 +1031,7 @@ public:
}
}
- bool operator<(const TransactionAndDistance &aOther) const
+ bool operator<(const TransactionAndDistance& aOther) const
{
// Compare distances first, and fall back to last-accessed times.
if (aOther.mDistance != this->mDistance) {
@@ -1054,7 +1041,7 @@ public:
return this->mLastTouched < aOther.mLastTouched;
}
- bool operator==(const TransactionAndDistance &aOther) const
+ bool operator==(const TransactionAndDistance& aOther) const
{
// This is a little silly; we need == so the default comaprator can be
// instantiated, but this function is never actually called when we sort
@@ -1071,7 +1058,7 @@ public:
} // anonymous namespace
-//static
+// static
void
nsSHistory::GloballyEvictContentViewers()
{
@@ -1105,7 +1092,7 @@ nsSHistory::GloballyEvictContentViewers()
//
int32_t startIndex = std::max(0, shist->mIndex - gHistoryMaxViewers);
int32_t endIndex = std::min(shist->mLength - 1,
- shist->mIndex + gHistoryMaxViewers);
+ shist->mIndex + gHistoryMaxViewers);
nsCOMPtr trans;
shist->GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
for (int32_t i = startIndex; trans && i <= endIndex; i++) {
@@ -1119,23 +1106,25 @@ nsSHistory::GloballyEvictContentViewers()
// distance from the SHistory's index and continue.
bool found = false;
for (uint32_t j = 0; j < shTransactions.Length(); j++) {
- TransactionAndDistance &container = shTransactions[j];
+ TransactionAndDistance& container = shTransactions[j];
if (container.mViewer == contentViewer) {
- container.mDistance = std::min(container.mDistance, DeprecatedAbs(i - shist->mIndex));
+ container.mDistance = std::min(container.mDistance,
+ DeprecatedAbs(i - shist->mIndex));
found = true;
break;
}
}
- // If we didn't find a TransactionAndDistance for this content viewer, make a new
- // one.
+ // If we didn't find a TransactionAndDistance for this content viewer,
+ // make a new one.
if (!found) {
- TransactionAndDistance container(trans, DeprecatedAbs(i - shist->mIndex));
+ TransactionAndDistance container(trans,
+ DeprecatedAbs(i - shist->mIndex));
shTransactions.AppendElement(container);
}
}
- nsISHTransaction *temp = trans;
+ nsISHTransaction* temp = trans;
temp->GetNext(getter_AddRefs(trans));
}
@@ -1157,20 +1146,17 @@ nsSHistory::GloballyEvictContentViewers()
// so let's not worry about it.)
transactions.Sort();
- for (int32_t i = transactions.Length() - 1;
- i >= sHistoryMaxTotalViewers; --i) {
-
+ for (int32_t i = transactions.Length() - 1; i >= sHistoryMaxTotalViewers;
+ --i) {
EvictContentViewerForTransaction(transactions[i].mTransaction);
-
}
}
nsresult
-nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry *aEntry)
+nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aEntry)
{
int32_t startIndex = std::max(0, mIndex - gHistoryMaxViewers);
- int32_t endIndex = std::min(mLength - 1,
- mIndex + gHistoryMaxViewers);
+ int32_t endIndex = std::min(mLength - 1, mIndex + gHistoryMaxViewers);
nsCOMPtr trans;
GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
@@ -1184,12 +1170,13 @@ nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry *aEntry)
break;
}
- nsISHTransaction *temp = trans;
+ nsISHTransaction* temp = trans;
temp->GetNext(getter_AddRefs(trans));
}
- if (i > endIndex)
+ if (i > endIndex) {
return NS_OK;
-
+ }
+
if (i == mIndex) {
NS_WARNING("How did the current SHEntry expire?");
return NS_OK;
@@ -1205,7 +1192,7 @@ nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry *aEntry)
// objects for each viewer to be evicted. However, this method is called
// infrequently -- only when the disk or memory cache is cleared.
-//static
+// static
void
nsSHistory::GloballyEvictAllContentViewers()
{
@@ -1215,9 +1202,10 @@ nsSHistory::GloballyEvictAllContentViewers()
sHistoryMaxTotalViewers = maxViewers;
}
-void GetDynamicChildren(nsISHContainer* aContainer,
- nsTArray& aDocshellIDs,
- bool aOnlyTopLevelDynamic)
+void
+GetDynamicChildren(nsISHContainer* aContainer,
+ nsTArray& aDocshellIDs,
+ bool aOnlyTopLevelDynamic)
{
int32_t count = 0;
aContainer->GetChildCount(&count);
@@ -1277,8 +1265,9 @@ RemoveFromSessionHistoryContainer(nsISHContainer* aContainer,
return didRemove;
}
-bool RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
- nsTArray& aEntryIDs)
+bool
+RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
+ nsTArray& aEntryIDs)
{
nsCOMPtr rootHE;
aHistory->GetEntryAtIndex(aIndex, false, getter_AddRefs(rootHE));
@@ -1286,7 +1275,8 @@ bool RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
return root ? RemoveFromSessionHistoryContainer(root, aEntryIDs) : false;
}
-bool IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
+bool
+IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
{
if (!aEntry1 && !aEntry2) {
return true;
@@ -1316,7 +1306,7 @@ bool IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
return false;
}
}
-
+
return true;
}
@@ -1391,11 +1381,13 @@ NS_IMETHODIMP_(void)
nsSHistory::RemoveEntries(nsTArray& aIDs, int32_t aStartIndex)
{
int32_t index = aStartIndex;
- while(index >= 0 && RemoveChildEntries(this, --index, aIDs));
+ while (index >= 0 && RemoveChildEntries(this, --index, aIDs)) {
+ }
int32_t minIndex = index;
index = aStartIndex;
- while(index >= 0 && RemoveChildEntries(this, index++, aIDs));
-
+ while (index >= 0 && RemoveChildEntries(this, index++, aIDs)) {
+ }
+
// We need to remove duplicate nsSHEntry trees.
bool didRemove = false;
while (index > minIndex) {
@@ -1447,7 +1439,7 @@ nsSHistory::RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex)
NS_IMETHODIMP
nsSHistory::UpdateIndex()
{
- // Update the actual index with the right value.
+ // Update the actual index with the right value.
if (mIndex != mRequestedIndex && mRequestedIndex != -1) {
RemoveDynEntries(mIndex, mRequestedIndex);
mIndex = mRequestedIndex;
@@ -1460,11 +1452,10 @@ nsSHistory::UpdateIndex()
NS_IMETHODIMP
nsSHistory::Stop(uint32_t aStopFlags)
{
- //Not implemented
+ // Not implemented
return NS_OK;
}
-
NS_IMETHODIMP
nsSHistory::GetDocument(nsIDOMDocument** aDocument)
{
@@ -1472,7 +1463,6 @@ nsSHistory::GetDocument(nsIDOMDocument** aDocument)
return NS_OK;
}
-
NS_IMETHODIMP
nsSHistory::GetCurrentURI(nsIURI** aResultURI)
{
@@ -1481,12 +1471,13 @@ nsSHistory::GetCurrentURI(nsIURI** aResultURI)
nsCOMPtr currentEntry;
rv = GetEntryAtIndex(mIndex, false, getter_AddRefs(currentEntry));
- if (NS_FAILED(rv) && !currentEntry) return rv;
+ if (NS_FAILED(rv) && !currentEntry) {
+ return rv;
+ }
rv = currentEntry->GetURI(aResultURI);
return rv;
}
-
NS_IMETHODIMP
nsSHistory::GetReferringURI(nsIURI** aURI)
{
@@ -1495,7 +1486,6 @@ nsSHistory::GetReferringURI(nsIURI** aURI)
return NS_OK;
}
-
NS_IMETHODIMP
nsSHistory::SetSessionHistory(nsISHistory* aSessionHistory)
{
@@ -1503,7 +1493,6 @@ nsSHistory::SetSessionHistory(nsISHistory* aSessionHistory)
return NS_OK;
}
-
NS_IMETHODIMP
nsSHistory::GetSessionHistory(nsISHistory** aSessionHistory)
{
@@ -1536,11 +1525,13 @@ nsSHistory::LoadURI(const char16_t* aURI,
NS_IMETHODIMP
nsSHistory::GotoIndex(int32_t aIndex)
{
- return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
+ return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory,
+ HIST_CMD_GOTOINDEX);
}
nsresult
-nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd)
+nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
+ uint32_t aHistCmd)
{
mRequestedIndex = -1;
if (aNewIndex < mIndex) {
@@ -1597,42 +1588,42 @@ nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd)
}
if (!canNavigate) {
- // If the listener asked us not to proceed with
- // the operation, simply return.
+ // If the listener asked us not to proceed with
+ // the operation, simply return.
mRequestedIndex = -1;
return NS_OK; // XXX Maybe I can return some other error code?
}
nsCOMPtr nexturi;
- int32_t pCount=0, nCount=0;
+ int32_t pCount = 0;
+ int32_t nCount = 0;
nsCOMPtr prevAsContainer(do_QueryInterface(prevEntry));
nsCOMPtr nextAsContainer(do_QueryInterface(nextEntry));
if (prevAsContainer && nextAsContainer) {
prevAsContainer->GetChildCount(&pCount);
nextAsContainer->GetChildCount(&nCount);
}
-
+
nsCOMPtr loadInfo;
if (mRequestedIndex == mIndex) {
- // Possibly a reload case
+ // Possibly a reload case
docShell = mRootDocShell;
- }
- else {
+ } else {
// Going back or forward.
- if ((pCount > 0) && (nCount > 0)) {
- /* THis is a subframe navigation. Go find
+ if (pCount > 0 && nCount > 0) {
+ /* THis is a subframe navigation. Go find
* the docshell in which load should happen
*/
bool frameFound = false;
- nsresult rv = CompareFrames(prevEntry, nextEntry, mRootDocShell, aLoadType, &frameFound);
+ nsresult rv = CompareFrames(prevEntry, nextEntry, mRootDocShell,
+ aLoadType, &frameFound);
if (!frameFound) {
// We did not successfully find the subframe in which
// the new url was to be loaded. Go further in the history.
return LoadNextPossibleEntry(aIndex, aLoadType, aHistCmd);
}
return rv;
- } // (pCount >0)
- else {
+ } else {
// Loading top level page.
uint32_t prevID = 0;
uint32_t nextID = 0;
@@ -1659,10 +1650,13 @@ nsSHistory::LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd)
}
nsresult
-nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsIDocShell * aParent, long aLoadType, bool * aIsFrameFound)
+nsSHistory::CompareFrames(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
+ nsIDocShell* aParent, long aLoadType,
+ bool* aIsFrameFound)
{
- if (!aPrevEntry || !aNextEntry || !aParent)
+ if (!aPrevEntry || !aNextEntry || !aParent) {
return NS_ERROR_FAILURE;
+ }
// We should be comparing only entries which were created for the
// same docshell. This is here to just prevent anything strange happening.
@@ -1677,27 +1671,29 @@ nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsID
aPrevEntry->GetID(&prevID);
aNextEntry->GetID(&nextID);
-
+
// Check the IDs to verify if the pages are different.
if (prevID != nextID) {
- if (aIsFrameFound)
+ if (aIsFrameFound) {
*aIsFrameFound = true;
+ }
// Set the Subframe flag of the entry to indicate that
- // it is subframe navigation
+ // it is subframe navigation
aNextEntry->SetIsSubFrame(true);
InitiateLoad(aNextEntry, aParent, aLoadType);
return NS_OK;
}
- /* The root entries are the same, so compare any child frames */
- int32_t pcnt=0, ncnt=0, dsCount=0;
- nsCOMPtr prevContainer(do_QueryInterface(aPrevEntry));
- nsCOMPtr nextContainer(do_QueryInterface(aNextEntry));
+ // The root entries are the same, so compare any child frames
+ int32_t pcnt = 0;
+ int32_t ncnt = 0;
+ int32_t dsCount = 0;
+ nsCOMPtr prevContainer(do_QueryInterface(aPrevEntry));
+ nsCOMPtr nextContainer(do_QueryInterface(aNextEntry));
- if (!aParent)
- return NS_ERROR_FAILURE;
- if (!prevContainer || !nextContainer)
+ if (!aParent || !prevContainer || !nextContainer) {
return NS_ERROR_FAILURE;
+ }
prevContainer->GetChildCount(&pcnt);
nextContainer->GetChildCount(&ncnt);
@@ -1761,13 +1757,13 @@ nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsID
// This will either load a new page to shell or some subshell or
// do nothing.
CompareFrames(pChild, nChild, dsChild, aLoadType, aIsFrameFound);
- }
+ }
return result;
}
-
-nsresult
-nsSHistory::InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType)
+nsresult
+nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
+ long aLoadType)
{
NS_ENSURE_STATE(aFrameDS && aFrameEntry);
@@ -1777,8 +1773,8 @@ nsSHistory::InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long
* This will be passed on to child subframes later in nsDocShell,
* so that proper loadType is maintained through out a frameset
*/
- aFrameEntry->SetLoadType(aLoadType);
- aFrameDS->CreateLoadInfo (getter_AddRefs(loadInfo));
+ aFrameEntry->SetLoadType(aLoadType);
+ aFrameDS->CreateLoadInfo(getter_AddRefs(loadInfo));
loadInfo->SetLoadType(aLoadType);
loadInfo->SetSHEntry(aFrameEntry);
@@ -1786,12 +1782,13 @@ nsSHistory::InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long
nsCOMPtr nextURI;
aFrameEntry->GetURI(getter_AddRefs(nextURI));
// Time to initiate a document load
- return aFrameDS->LoadURI(nextURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+ return aFrameDS->LoadURI(nextURI, loadInfo,
+ nsIWebNavigation::LOAD_FLAGS_NONE, false);
}
NS_IMETHODIMP
-nsSHistory::SetRootDocShell(nsIDocShell * aDocShell)
+nsSHistory::SetRootDocShell(nsIDocShell* aDocShell)
{
mRootDocShell = aDocShell;
return NS_OK;
@@ -1806,12 +1803,7 @@ nsSHistory::GetSHistoryEnumerator(nsISimpleEnumerator** aEnumerator)
return NS_OK;
}
-
-//*****************************************************************************
-//*** nsSHEnumerator: Object Management
-//*****************************************************************************
-
-nsSHEnumerator::nsSHEnumerator(nsSHistory * aSHistory):mIndex(-1)
+nsSHEnumerator::nsSHEnumerator(nsSHistory* aSHistory) : mIndex(-1)
{
mSHistory = aSHistory;
}
@@ -1824,32 +1816,32 @@ nsSHEnumerator::~nsSHEnumerator()
NS_IMPL_ISUPPORTS(nsSHEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP
-nsSHEnumerator::HasMoreElements(bool * aReturn)
+nsSHEnumerator::HasMoreElements(bool* aReturn)
{
int32_t cnt;
*aReturn = false;
mSHistory->GetCount(&cnt);
- if (mIndex >= -1 && mIndex < (cnt-1) ) {
+ if (mIndex >= -1 && mIndex < (cnt - 1)) {
*aReturn = true;
}
return NS_OK;
}
-
-NS_IMETHODIMP
-nsSHEnumerator::GetNext(nsISupports **aItem)
+NS_IMETHODIMP
+nsSHEnumerator::GetNext(nsISupports** aItem)
{
NS_ENSURE_ARG_POINTER(aItem);
- int32_t cnt= 0;
+ int32_t cnt = 0;
- nsresult result = NS_ERROR_FAILURE;
+ nsresult result = NS_ERROR_FAILURE;
mSHistory->GetCount(&cnt);
- if (mIndex < (cnt-1)) {
+ if (mIndex < (cnt - 1)) {
mIndex++;
nsCOMPtr hEntry;
result = mSHistory->GetEntryAtIndex(mIndex, false, getter_AddRefs(hEntry));
- if (hEntry)
+ if (hEntry) {
result = CallQueryInterface(hEntry, aItem);
+ }
}
return result;
}
diff --git a/docshell/shistory/src/nsSHistory.h b/docshell/shistory/src/nsSHistory.h
index 36af8855f68..245e1ebc913 100644
--- a/docshell/shistory/src/nsSHistory.h
+++ b/docshell/shistory/src/nsSHistory.h
@@ -7,10 +7,7 @@
#ifndef nsSHistory_h
#define nsSHistory_h
-// Helper Classes
#include "nsCOMPtr.h"
-
-//Interfaces Needed
#include "nsISHistory.h"
#include "nsISHistoryInternal.h"
#include "nsIWebNavigation.h"
@@ -18,7 +15,6 @@
#include "nsTObserverArray.h"
#include "nsWeakPtr.h"
-// Needed to maintain global list of all SHistory objects
#include "prclist.h"
class nsIDocShell;
@@ -34,7 +30,6 @@ class nsSHistory final : public PRCList,
{
public:
nsSHistory();
-
NS_DECL_ISUPPORTS
NS_DECL_NSISHISTORY
NS_DECL_NSISHISTORYINTERNAL
@@ -56,15 +51,18 @@ protected:
friend class nsSHEnumerator;
friend class nsSHistoryObserver;
- // Could become part of nsIWebNavigation
- NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult);
- nsresult CompareFrames(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, long aLoadType, bool * aIsFrameFound);
- nsresult InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType);
+ // Could become part of nsIWebNavigation
+ NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult);
+ nsresult CompareFrames(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
+ nsIDocShell* aRootDocShell, long aLoadType,
+ bool* aIsFrameFound);
+ nsresult InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
+ long aLoadType);
- NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t histCmd);
+ NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd);
#ifdef DEBUG
- nsresult PrintHistory();
+ nsresult PrintHistory();
#endif
// Evict content viewers in this window which don't lie in the "safe" range
@@ -79,7 +77,9 @@ protected:
void RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex);
- nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd);
+ nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
+ uint32_t aHistCmd);
+
protected:
// aIndex is the index of the transaction which may be removed.
// If aKeepNext is true, aIndex is compared to aIndex + 1,
@@ -93,29 +93,27 @@ protected:
// Session History listeners
nsAutoTObserverArray mListeners;
// Weak reference. Do not refcount this.
- nsIDocShell * mRootDocShell;
+ nsIDocShell* mRootDocShell;
// Max viewers allowed total, across all SHistory objects
- static int32_t sHistoryMaxTotalViewers;
+ static int32_t sHistoryMaxTotalViewers;
};
-//*****************************************************************************
-//*** nsSHEnumerator: Object Management
-//*****************************************************************************
+
class nsSHEnumerator : public nsISimpleEnumerator
{
public:
-
NS_DECL_ISUPPORTS
NS_DECL_NSISIMPLEENUMERATOR
- explicit nsSHEnumerator(nsSHistory * aHistory);
-
+ explicit nsSHEnumerator(nsSHistory* aHistory);
+
protected:
friend class nsSHistory;
virtual ~nsSHEnumerator();
+
private:
- int32_t mIndex;
- nsSHistory * mSHistory;
+ int32_t mIndex;
+ nsSHistory* mSHistory;
};
-#endif /* nsSHistory */
+#endif /* nsSHistory */
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 44e39e0b60a..582d93ee65f 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -270,14 +270,14 @@ nsIdentifierMapEntry::Traverse(nsCycleCollectionTraversalCallback* aCallback)
bool
nsIdentifierMapEntry::IsEmpty()
{
- return mIdContentList.Count() == 0 && !mNameContentList &&
+ return mIdContentList.IsEmpty() && !mNameContentList &&
!mChangeCallbacks && !mImageElement;
}
Element*
nsIdentifierMapEntry::GetIdElement()
{
- return static_cast(mIdContentList.SafeElementAt(0));
+ return mIdContentList.SafeElementAt(0);
}
Element*
@@ -289,8 +289,8 @@ nsIdentifierMapEntry::GetImageIdElement()
void
nsIdentifierMapEntry::AppendAllIdContent(nsCOMArray* aElements)
{
- for (int32_t i = 0; i < mIdContentList.Count(); ++i) {
- aElements->AppendObject(static_cast(mIdContentList[i]));
+ for (size_t i = 0; i < mIdContentList.Length(); ++i) {
+ aElements->AppendObject(mIdContentList[i]);
}
}
@@ -592,16 +592,15 @@ bool
nsIdentifierMapEntry::AddIdElement(Element* aElement)
{
NS_PRECONDITION(aElement, "Must have element");
- NS_PRECONDITION(mIdContentList.IndexOf(nullptr) < 0,
+ NS_PRECONDITION(!mIdContentList.Contains(nullptr),
"Why is null in our list?");
#ifdef DEBUG
- Element* currentElement =
- static_cast(mIdContentList.SafeElementAt(0));
+ Element* currentElement = mIdContentList.SafeElementAt(0);
#endif
// Common case
- if (mIdContentList.Count() == 0) {
+ if (mIdContentList.IsEmpty()) {
if (!mIdContentList.AppendElement(aElement))
return false;
NS_ASSERTION(currentElement == nullptr, "How did that happen?");
@@ -613,7 +612,7 @@ nsIdentifierMapEntry::AddIdElement(Element* aElement)
// with us. Search for the right place to insert the content.
size_t idx;
- if (BinarySearchIf(mIdContentList, 0, mIdContentList.Count(),
+ if (BinarySearchIf(mIdContentList, 0, mIdContentList.Length(),
PositionComparator(aElement), &idx)) {
// Already in the list, so already in the right spot. Get out of here.
// XXXbz this only happens because XUL does all sorts of random
@@ -621,12 +620,12 @@ nsIdentifierMapEntry::AddIdElement(Element* aElement)
return true;
}
- if (!mIdContentList.InsertElementAt(aElement, idx))
+ if (!mIdContentList.InsertElementAt(idx, aElement)) {
return false;
+ }
if (idx == 0) {
- Element* oldElement =
- static_cast(mIdContentList.SafeElementAt(1));
+ Element* oldElement = mIdContentList.SafeElementAt(1);
NS_ASSERTION(currentElement == oldElement, "How did that happen?");
FireChangeCallbacks(oldElement, aElement);
}
@@ -645,17 +644,15 @@ nsIdentifierMapEntry::RemoveIdElement(Element* aElement)
// Only assert this in HTML documents for now as XUL does all sorts of weird
// crap.
NS_ASSERTION(!aElement->OwnerDoc()->IsHTMLDocument() ||
- mIdContentList.IndexOf(aElement) >= 0,
+ mIdContentList.Contains(aElement),
"Removing id entry that doesn't exist");
// XXXbz should this ever Compact() I guess when all the content is gone
// we'll just get cleaned up in the natural order of things...
- Element* currentElement =
- static_cast(mIdContentList.SafeElementAt(0));
+ Element* currentElement = mIdContentList.SafeElementAt(0);
mIdContentList.RemoveElement(aElement);
if (currentElement == aElement) {
- FireChangeCallbacks(currentElement,
- static_cast(mIdContentList.SafeElementAt(0)));
+ FireChangeCallbacks(currentElement, mIdContentList.SafeElementAt(0));
}
}
@@ -5048,7 +5045,7 @@ nsDocument::GetElementById(const nsAString& aElementId)
return entry ? entry->GetIdElement() : nullptr;
}
-const nsSmallVoidArray*
+const nsTArray*
nsDocument::GetAllElementsForId(const nsAString& aElementId) const
{
if (aElementId.IsEmpty()) {
@@ -5056,7 +5053,7 @@ nsDocument::GetAllElementsForId(const nsAString& aElementId) const
}
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aElementId);
- return entry ? entry->GetIdElements() : nullptr;
+ return entry ? &entry->GetIdElements() : nullptr;
}
NS_IMETHODIMP
diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
index 8771395d788..288bf41c3a3 100644
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -18,7 +18,6 @@
#include "nsCRT.h"
#include "nsWeakReference.h"
#include "nsWeakPtr.h"
-#include "nsVoidArray.h"
#include "nsTArray.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOMDocumentXBL.h"
@@ -151,8 +150,8 @@ public:
/**
* Returns the list of all elements associated with this id.
*/
- const nsSmallVoidArray* GetIdElements() const {
- return &mIdContentList;
+ const nsTArray& GetIdElements() const {
+ return mIdContentList;
}
/**
* If this entry has a non-null image element set (using SetImageElement),
@@ -228,7 +227,7 @@ private:
// empty if there are no elements with this ID.
// The elements are stored as weak pointers.
- nsSmallVoidArray mIdContentList;
+ nsTArray mIdContentList;
nsRefPtr mNameContentList;
nsAutoPtr > mChangeCallbacks;
nsRefPtr mImageElement;
@@ -1141,7 +1140,7 @@ public:
virtual void SetChangeScrollPosWhenScrollingToRef(bool aValue) override;
virtual Element *GetElementById(const nsAString& aElementId) override;
- virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const override;
+ virtual const nsTArray* GetAllElementsForId(const nsAString& aElementId) const override;
virtual Element *LookupImageElement(const nsAString& aElementId) override;
virtual void MozSetImageElement(const nsAString& aImageElementId,
diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h
index d095ae06740..df79a833a49 100644
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -78,7 +78,6 @@ class nsSMILAnimationController;
class nsStyleSet;
class nsTextNode;
class nsWindowSizes;
-class nsSmallVoidArray;
class nsDOMCaretPosition;
class nsViewportInfo;
class nsIGlobalObject;
@@ -2078,9 +2077,8 @@ public:
/**
* This method returns _all_ the elements in this document which
* have id aElementId, if there are any. Otherwise it returns null.
- * The entries of the nsSmallVoidArray are Element*
*/
- virtual const nsSmallVoidArray* GetAllElementsForId(const nsAString& aElementId) const = 0;
+ virtual const nsTArray* GetAllElementsForId(const nsAString& aElementId) const = 0;
/**
* Lookup an image element using its associated ID, which is usually provided
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
index 6bcf1bd59e5..af9f7207b01 100644
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2478,8 +2478,7 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
"document if it's in the document. Note that document fragments "
"can't be IsInDoc(), so should never show up here.");
- const nsSmallVoidArray* elements = aRoot->OwnerDoc()->GetAllElementsForId(aId);
-
+ const nsTArray* elements = aRoot->OwnerDoc()->GetAllElementsForId(aId);
if (!elements) {
// Nothing to do; we're done
return;
@@ -2487,8 +2486,8 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
// XXXbz: Should we fall back to the tree walk if aRoot is not the
// document and |elements| is long, for some value of "long"?
- for (int32_t i = 0; i < elements->Count(); ++i) {
- Element *element = static_cast(elements->ElementAt(i));
+ for (size_t i = 0; i < elements->Length(); ++i) {
+ Element* element = (*elements)[i];
if (!aRoot->IsElement() ||
(element != aRoot &&
nsContentUtils::ContentIsDescendantOf(element, aRoot))) {
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
index b97e02b43e7..a2b43f7aab7 100644
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -54,7 +54,6 @@
#include "mozilla/net/NeckoChild.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginModuleParent.h"
-#include "mozilla/media/webrtc/WebrtcGlobalChild.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#if defined(MOZ_CONTENT_SANDBOX)
@@ -121,6 +120,10 @@
#include "nsIScriptSecurityManager.h"
+#ifdef MOZ_WEBRTC
+#include "signaling/src/peerconnection/WebrtcGlobalChild.h"
+#endif
+
#ifdef MOZ_PERMISSIONS
#include "nsPermission.h"
#include "nsPermissionManager.h"
@@ -1821,15 +1824,23 @@ ContentChild::DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor)
PWebrtcGlobalChild *
ContentChild::AllocPWebrtcGlobalChild()
{
+#ifdef MOZ_WEBRTC
WebrtcGlobalChild *child = new WebrtcGlobalChild();
return child;
+#else
+ return nullptr;
+#endif
}
bool
ContentChild::DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor)
{
+#ifdef MOZ_WEBRTC
delete static_cast(aActor);
return true;
+#else
+ return false;
+#endif
}
diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
index 76656801da2..1bdc40a7e56 100755
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -87,7 +87,6 @@
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/unused.h"
-#include "mozilla/media/webrtc/WebrtcGlobalParent.h"
#include "nsAnonymousTemporaryFile.h"
#include "nsAppRunner.h"
#include "nsAutoPtr.h"
@@ -167,6 +166,10 @@
#include "nsIBidiKeyboard.h"
+#ifdef MOZ_WEBRTC
+#include "signaling/src/peerconnection/WebrtcGlobalParent.h"
+#endif
+
#if defined(ANDROID) || defined(LINUX)
#include "nsSystemInfo.h"
#endif
@@ -4950,14 +4953,22 @@ ContentParent::DeallocPOfflineCacheUpdateParent(POfflineCacheUpdateParent* aActo
PWebrtcGlobalParent *
ContentParent::AllocPWebrtcGlobalParent()
{
+#ifdef MOZ_WEBRTC
return WebrtcGlobalParent::Alloc();
+#else
+ return nullptr;
+#endif
}
bool
ContentParent::DeallocPWebrtcGlobalParent(PWebrtcGlobalParent *aActor)
{
+#ifdef MOZ_WEBRTC
WebrtcGlobalParent::Dealloc(static_cast(aActor));
return true;
+#else
+ return false;
+#endif
}
bool
diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build
index 3a8111613f7..7a4b40a96d2 100644
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -139,6 +139,7 @@ LOCAL_INCLUDES += [
'/gfx/2d',
'/hal/sandbox',
'/layout/base',
+ '/media/webrtc',
'/netwerk/base',
'/toolkit/xre',
'/uriloader/exthandler',
diff --git a/dom/media/Intervals.h b/dom/media/Intervals.h
new file mode 100644
index 00000000000..a589ad51bea
--- /dev/null
+++ b/dom/media/Intervals.h
@@ -0,0 +1,525 @@
+/* -*- 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/. */
+
+#ifndef INTERVALS_H
+#define INTERVALS_H
+
+#include
+#include "mozilla/TypeTraits.h"
+#include "nsTArray.h"
+
+namespace mozilla {
+namespace media {
+
+/* Interval defines an interval between two points. Unlike a traditional
+ interval [A,B] where A <= x <= B, the upper boundary B is exclusive: A <= x < B
+ (e.g [A,B[ or [A,B) depending on where you're living)
+ It provides basic interval arithmetic and fuzzy edges.
+ The type T must provides a default constructor and +, -, <, <= and ==
+ operators.
+ */
+template
+class Interval
+{
+public:
+ typedef Interval SelfType;
+
+ Interval()
+ : mStart(T())
+ , mEnd(T())
+ , mFuzz(T())
+ {}
+
+ template
+ Interval(StartArg&& aStart, EndArg&& aEnd)
+ : mStart(Forward(aStart))
+ , mEnd(Forward(aEnd))
+ , mFuzz()
+ {
+ MOZ_ASSERT(aStart <= aEnd);
+ }
+
+ template
+ Interval(StartArg&& aStart, EndArg&& aEnd, FuzzArg&& aFuzz)
+ : mStart(Forward(aStart))
+ , mEnd(Forward(aEnd))
+ , mFuzz(Forward(aFuzz))
+ {
+ MOZ_ASSERT(aStart <= aEnd);
+ }
+
+ Interval(const SelfType& aOther)
+ : mStart(aOther.mStart)
+ , mEnd(aOther.mEnd)
+ , mFuzz(aOther.mFuzz)
+ {}
+
+ Interval(SelfType&& aOther)
+ : mStart(Move(aOther.mStart))
+ , mEnd(Move(aOther.mEnd))
+ , mFuzz(Move(aOther.mFuzz))
+ { }
+
+ SelfType& operator= (const SelfType& aOther)
+ {
+ mStart = aOther.mStart;
+ mEnd = aOther.mEnd;
+ mFuzz = aOther.mFuzz;
+ return *this;
+ }
+
+ SelfType& operator= (SelfType&& aOther)
+ {
+ MOZ_ASSERT(&aOther != this, "self-moves are prohibited");
+ this->~Interval();
+ new(this) Interval(Move(aOther));
+ return *this;
+ }
+
+ // Basic interval arithmetic operator definition.
+ SelfType operator+ (const SelfType& aOther) const
+ {
+ return SelfType(mStart + aOther.mStart,
+ mEnd + aOther.mEnd,
+ mFuzz + aOther.mFuzz);
+ }
+
+ // Basic interval arithmetic operator definition.
+ SelfType operator- (const SelfType& aOther) const
+ {
+ return SelfType(mStart - aOther.mEnd,
+ mEnd - aOther.mStart,
+ mFuzz + aOther.mFuzz);
+ }
+
+ bool operator== (const SelfType& aOther) const
+ {
+ return mStart == aOther.mStart && mEnd == aOther.mEnd;
+ }
+
+ bool operator!= (const SelfType& aOther) const
+ {
+ return !(*this == aOther);
+ }
+
+ bool Contains(const T& aX) const
+ {
+ return mStart - mFuzz <= aX && aX < mEnd + mFuzz;
+ }
+
+ bool ContainsStrict(const T& aX) const
+ {
+ return mStart <= aX && aX < mEnd;
+ }
+
+ bool Contains(const SelfType& aOther) const
+ {
+ return (mStart - mFuzz <= aOther.mStart + aOther.mFuzz) &&
+ (aOther.mEnd + aOther.mFuzz <= mEnd - mFuzz);
+ }
+
+ bool ContainsStrict(const SelfType& aOther) const
+ {
+ return mStart <= aOther.mStart && aOther.mEnd <= mEnd;
+ }
+
+ bool Intersects(const SelfType& aOther) const
+ {
+ return (mStart - mFuzz <= aOther.mEnd + aOther.mFuzz) &&
+ (aOther.mStart - aOther.mFuzz <= mEnd + mFuzz);
+ }
+
+ // Returns true if aOther is strictly to the right of this and contiguous.
+ // This operation isn't commutative.
+ bool Contiguous(const SelfType& aOther) const
+ {
+ return mEnd <= aOther.mStart && aOther.mStart - mEnd <= mFuzz + aOther.mFuzz;
+ }
+
+ SelfType Union(const SelfType& aOther) const
+ {
+ SelfType result(*this);
+ if (aOther.mStart < mStart) {
+ result.mStart = aOther.mStart;
+ }
+ if (mEnd < aOther.mEnd) {
+ result.mEnd = aOther.mEnd;
+ }
+ if (mFuzz < aOther.mFuzz) {
+ result.mFuzz = aOther.mFuzz;
+ }
+ return result;
+ }
+
+ SelfType Intersection(const SelfType& aOther) const
+ {
+ const T& s = std::max(mStart, aOther.mStart);
+ const T& e = std::min(mEnd, aOther.mEnd);
+ const T& f = std::max(mFuzz, aOther.mFuzz);
+ if (s < e) {
+ return SelfType(s, e, f);
+ }
+ // Return an empty interval.
+ return SelfType();
+ }
+
+ T Length() const
+ {
+ return mEnd - mStart;
+ }
+
+ bool IsEmpty() const
+ {
+ return mStart == mEnd;
+ }
+
+ T mStart;
+ T mEnd;
+ T mFuzz;
+
+private:
+};
+
+template
+class IntervalSet
+{
+public:
+ typedef IntervalSet SelfType;
+ typedef Interval ElemType;
+ typedef nsAutoTArray ContainerType;
+ typedef typename ContainerType::index_type IndexType;
+
+ IntervalSet()
+ {
+ }
+ ~IntervalSet()
+ {
+ }
+
+ IntervalSet(const SelfType& aOther)
+ : mIntervals(aOther.mIntervals)
+ {
+ }
+
+ IntervalSet(SelfType&& aOther)
+ : mIntervals(Move(aOther.mIntervals))
+ {
+ }
+
+ explicit IntervalSet(const ElemType& aOther)
+ {
+ mIntervals.AppendElement(aOther);
+ }
+
+ explicit IntervalSet(ElemType&& aOther)
+ {
+ mIntervals.AppendElement(Move(aOther));
+ }
+
+ SelfType& operator= (const SelfType& aOther)
+ {
+ mIntervals = aOther.mIntervals;
+ return *this;
+ }
+
+ SelfType& operator= (SelfType&& aOther)
+ {
+ MOZ_ASSERT(&aOther != this, "self-moves are prohibited");
+ this->~IntervalSet();
+ new(this) IntervalSet(Move(aOther));
+ return *this;
+ }
+
+ SelfType& operator= (const ElemType& aInterval)
+ {
+ mIntervals.Clear();
+ mIntervals.AppendElement(aInterval);
+ return *this;
+ }
+
+ SelfType& operator= (ElemType&& aInterval)
+ {
+ mIntervals.Clear();
+ mIntervals.AppendElement(Move(aInterval));
+ return *this;
+ }
+
+ // + and += operator will append the provided interval or intervalset.
+ // Note that the result is not normalized. Call Normalize() as required.
+ // Alternatively, use Union()
+
+ SelfType& Add(const SelfType& aIntervals)
+ {
+ mIntervals.AppendElements(aIntervals.mIntervals);
+ return *this;
+ }
+
+ SelfType& Add(const ElemType& aInterval)
+ {
+ mIntervals.AppendElement(aInterval);
+ return *this;
+ }
+
+ SelfType& operator+= (const SelfType& aIntervals)
+ {
+ Add(aIntervals);
+ return *this;
+ }
+
+ SelfType& operator+= (const ElemType& aInterval)
+ {
+ Add(aInterval);
+ return *this;
+ }
+
+ SelfType operator+ (const SelfType& aIntervals) const
+ {
+ SelfType intervals(*this);
+ intervals.Add(aIntervals);
+ return intervals;
+ }
+
+ SelfType operator+ (const ElemType& aInterval)
+ {
+ SelfType intervals(*this);
+ intervals.Add(aInterval);
+ return intervals;
+ }
+
+ friend SelfType operator+ (const ElemType& aInterval,
+ const SelfType& aIntervals)
+ {
+ SelfType intervals;
+ intervals.Add(aInterval);
+ intervals.Add(aIntervals);
+ return intervals;
+ }
+
+ // Mutate this IntervalSet to be the union of this and aOther.
+ // Resulting IntervalSet is normalized.
+ SelfType& Union(const SelfType& aOther)
+ {
+ Add(aOther);
+ Normalize();
+ return *this;
+ }
+
+ SelfType& Union(const ElemType& aInterval)
+ {
+ Add(aInterval);
+ Normalize();
+ return *this;
+ }
+
+ // Mutate this TimeRange to be the intersection of this and aOther.
+ SelfType& Intersection(const SelfType& aOther)
+ {
+ ContainerType intersection;
+
+ const ContainerType& other = aOther.mIntervals;
+ IndexType i = 0, j = 0;
+ for (; i < mIntervals.Length() && j < other.Length();) {
+ if (mIntervals[i].Intersects(other[j])) {
+ intersection.AppendElement(mIntervals[i].Intersection(other[j]));
+ }
+ if (mIntervals[i].mEnd < other[j].mEnd) {
+ i++;
+ } else {
+ j++;
+ }
+ }
+
+ mIntervals = intersection;
+ return *this;
+ }
+
+ SelfType& Intersection(const ElemType& aInterval)
+ {
+ SelfType intervals(aInterval);
+ return Intersection(intervals);
+ }
+
+ const ElemType& operator[] (IndexType aIndex) const
+ {
+ return mIntervals[aIndex];
+ }
+
+ // Returns the start boundary of the first interval. Or a default constructed
+ // T if IntervalSet is empty (and aExists if provided will be set to false).
+ T GetStart(bool* aExists = nullptr) const
+ {
+ bool exists = !mIntervals.IsEmpty();
+
+ if (aExists) {
+ *aExists = exists;
+ }
+
+ if (exists) {
+ return mIntervals[0].mStart;
+ } else {
+ return T();
+ }
+ }
+
+ // Returns the end boundary of the last interval. Or a default constructed T
+ // if IntervalSet is empty (and aExists if provided will be set to false).
+ T GetEnd(bool* aExists = nullptr) const
+ {
+ bool exists = !mIntervals.IsEmpty();
+ if (aExists) {
+ *aExists = exists;
+ }
+
+ if (exists) {
+ return mIntervals.LastElement().mEnd;
+ } else {
+ return T();
+ }
+ }
+
+ IndexType Length() const
+ {
+ return mIntervals.Length();
+ }
+
+ T Start(IndexType aIndex) const
+ {
+ return mIntervals[aIndex].mStart;
+ }
+
+ T Start(IndexType aIndex, bool& aExists) const
+ {
+ aExists = aIndex < mIntervals.Length();
+
+ if (aExists) {
+ return mIntervals[aIndex].mStart;
+ } else {
+ return T();
+ }
+ }
+
+ T End(IndexType aIndex) const
+ {
+ return mIntervals[aIndex].mEnd;
+ }
+
+ T End(IndexType aIndex, bool& aExists) const
+ {
+ aExists = aIndex < mIntervals.Length();
+
+ if (aExists) {
+ return mIntervals[aIndex].mEnd;
+ } else {
+ return T();
+ }
+ }
+
+ bool Contains(const T& aX) {
+ for (const auto& interval : mIntervals) {
+ if (interval.Contains(aX)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ bool ContainsStrict(const T& aX) {
+ for (const auto& interval : mIntervals) {
+ if (interval.ContainsStrict(aX)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void Normalize()
+ {
+ if (mIntervals.Length() >= 2) {
+ ContainerType normalized;
+
+ mIntervals.Sort(CompareIntervals());
+
+ // This merges the intervals.
+ ElemType current(mIntervals[0]);
+ for (IndexType i = 1; i < mIntervals.Length(); i++) {
+ if (current.Contains(mIntervals[i])) {
+ continue;
+ }
+ if (current.Intersects(mIntervals[i])) {
+ current = current.Union(mIntervals[i]);
+ } else {
+ normalized.AppendElement(current);
+ current = mIntervals[i];
+ }
+ }
+
+ normalized.AppendElement(current);
+
+ mIntervals = normalized;
+ }
+ }
+
+ // Shift all values by aOffset.
+ void Shift(T aOffset)
+ {
+ for (auto& interval : mIntervals) {
+ interval.mStart += aOffset;
+ interval.mEnd += aOffset;
+ }
+ }
+
+ static const IndexType NoIndex = IndexType(-1);
+
+ IndexType Find(T aValue) const
+ {
+ for (IndexType i = 0; i < mIntervals.Length(); i++) {
+ if (mIntervals[i].Contains(aValue)) {
+ return i;
+ }
+ }
+ return NoIndex;
+ }
+
+protected:
+ ContainerType mIntervals;
+
+private:
+ struct CompareIntervals
+ {
+ bool Equals(const ElemType& aT1, const ElemType& aT2) const
+ {
+ return aT1.mStart == aT2.mStart && aT1.mEnd == aT2.mEnd;
+ }
+
+ bool LessThan(const ElemType& aT1, const ElemType& aT2) const {
+ return aT1.mStart - aT1.mFuzz < aT2.mStart + aT2.mFuzz;
+ }
+ };
+};
+
+ // clang doesn't allow for this to be defined inline of IntervalSet.
+template
+IntervalSet Union(const IntervalSet& aIntervals1,
+ const IntervalSet& aIntervals2)
+{
+ IntervalSet intervals(aIntervals1);
+ intervals.Union(aIntervals2);
+ return intervals;
+}
+
+template
+IntervalSet Intersection(const IntervalSet& aIntervals1,
+ const IntervalSet& aIntervals2)
+{
+ IntervalSet intersection(aIntervals1);
+ intersection.Intersection(aIntervals2);
+ return intersection;
+}
+
+} // namespace media
+} // namespace mozilla
+
+#endif // INTERVALS_H
diff --git a/dom/media/TimeUnits.h b/dom/media/TimeUnits.h
index 1af4be2033a..0380b7dc088 100644
--- a/dom/media/TimeUnits.h
+++ b/dom/media/TimeUnits.h
@@ -7,9 +7,11 @@
#ifndef TIME_UNITS_H
#define TIME_UNITS_H
+#include "Intervals.h"
#include "VideoUtils.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/FloatingPoint.h"
+#include "mozilla/dom/TimeRanges.h"
namespace mozilla {
namespace media {
@@ -40,6 +42,9 @@ struct Microseconds {
}
}
+ bool operator == (const Microseconds& aOther) const {
+ return mValue == aOther.mValue;
+ }
bool operator > (const Microseconds& aOther) const {
return mValue > aOther.mValue;
}
@@ -87,6 +92,10 @@ public:
return double(mValue.value()) / USECS_PER_S;
}
+ bool operator == (const TimeUnit& aOther) const {
+ MOZ_ASSERT(IsValid() && aOther.IsValid());
+ return mValue.value() == aOther.mValue.value();
+ }
bool operator >= (const TimeUnit& aOther) const {
MOZ_ASSERT(IsValid() && aOther.IsValid());
return mValue.value() >= aOther.mValue.value();
@@ -113,9 +122,18 @@ public:
return mValue.isValid();
}
+ TimeUnit()
+ : mValue(CheckedInt64(0))
+ {}
+
explicit TimeUnit(const Microseconds& aMicroseconds)
: mValue(aMicroseconds.mValue)
{}
+ TimeUnit& operator = (const Microseconds& aMicroseconds)
+ {
+ mValue = aMicroseconds.mValue;
+ return *this;
+ }
TimeUnit(const TimeUnit&) = default;
@@ -130,6 +148,64 @@ private:
CheckedInt64 mValue;
};
+typedef Interval TimeInterval;
+
+class TimeIntervals : public IntervalSet
+{
+public:
+ typedef IntervalSet BaseType;
+
+ // We can't use inherited constructors yet. So we have to duplicate all the
+ // constructors found in IntervalSet base class.
+ // all this could be later replaced with:
+ // using IntervalSet::IntervalSet;
+
+ // MOZ_IMPLICIT as we want to enable initialization in the form:
+ // TimeIntervals i = ... like we would do with IntervalSet i = ...
+ MOZ_IMPLICIT TimeIntervals(const BaseType& aOther)
+ : BaseType(aOther)
+ {}
+ MOZ_IMPLICIT TimeIntervals(BaseType&& aOther)
+ : BaseType(Move(aOther))
+ {}
+ explicit TimeIntervals(const BaseType::ElemType& aOther)
+ : BaseType(aOther)
+ {}
+ explicit TimeIntervals(BaseType::ElemType&& aOther)
+ : BaseType(Move(aOther))
+ {}
+
+ TimeIntervals() = default;
+
+ // Make TimeIntervals interchangeable with dom::TimeRanges.
+ explicit TimeIntervals(dom::TimeRanges* aRanges)
+ {
+ for (uint32_t i = 0; i < aRanges->Length(); i++) {
+ ErrorResult rv;
+ *this +=
+ TimeInterval(TimeUnit::FromSeconds(aRanges->Start(i, rv)),
+ TimeUnit::FromSeconds(aRanges->End(i, rv)));
+ }
+ }
+ TimeIntervals& operator = (dom::TimeRanges* aRanges)
+ {
+ *this = TimeIntervals(aRanges);
+ return *this;
+ }
+
+ static TimeIntervals FromTimeRanges(dom::TimeRanges* aRanges)
+ {
+ return TimeIntervals(aRanges);
+ }
+
+ void ToTimeRanges(dom::TimeRanges* aRanges) const
+ {
+ for (IndexType i = 0; i < Length(); i++) {
+ aRanges->Add(Start(i).ToSeconds(), End(i).ToSeconds());
+ }
+ }
+};
+
} // namespace media
} // namespace mozilla
diff --git a/dom/media/fmp4/MP4Reader.h b/dom/media/fmp4/MP4Reader.h
index d683e3f8bb2..886e7b53740 100644
--- a/dom/media/fmp4/MP4Reader.h
+++ b/dom/media/fmp4/MP4Reader.h
@@ -164,6 +164,9 @@ private:
virtual void ReleaseMediaResources() override {
mReader->ReleaseMediaResources();
}
+ virtual bool OnReaderTaskQueue() override {
+ return mReader->OnTaskQueue();
+ }
private:
MP4Reader* mReader;
TrackType mType;
diff --git a/dom/media/fmp4/PlatformDecoderModule.h b/dom/media/fmp4/PlatformDecoderModule.h
index 6d2ef5c77a1..e1b6b71ac0a 100644
--- a/dom/media/fmp4/PlatformDecoderModule.h
+++ b/dom/media/fmp4/PlatformDecoderModule.h
@@ -182,6 +182,8 @@ public:
virtual void NotifyResourcesStatusChanged() {};
virtual void ReleaseMediaResources() {};
+
+ virtual bool OnReaderTaskQueue() = 0;
};
// MediaDataDecoder is the interface exposed by decoders created by the
@@ -189,9 +191,13 @@ public:
// media data that the decoder accepts as valid input and produces as
// output is determined when the MediaDataDecoder is created.
//
-// All functions are only called on the decode task queue. Don't block
-// inside these functions, unless it's explicitly noted that you should
-// (like in Flush() and Drain()).
+// Unless otherwise noted, all functions are only called on the decode task
+// queue. An exception is the MediaDataDecoder in
+// MP4Reader::IsVideoAccelerated() for which all calls (Init(),
+// IsHardwareAccelerated(), and Shutdown()) are from the main thread.
+//
+// Don't block inside these functions, unless it's explicitly noted that you
+// should (like in Flush()).
//
// Decoding is done asynchronously. Any async work can be done on the
// MediaTaskQueue passed into the PlatformDecoderModules's Create*Decoder()
@@ -245,6 +251,7 @@ public:
// returned.
virtual nsresult Shutdown() = 0;
+ // Called from the state machine task queue or main thread.
virtual bool IsHardwareAccelerated() const { return false; }
// ConfigurationChanged will be called to inform the video or audio decoder
diff --git a/dom/media/fmp4/SharedDecoderManager.cpp b/dom/media/fmp4/SharedDecoderManager.cpp
index 7c35f02d724..a906f0f05ae 100644
--- a/dom/media/fmp4/SharedDecoderManager.cpp
+++ b/dom/media/fmp4/SharedDecoderManager.cpp
@@ -52,6 +52,11 @@ public:
mManager->mActiveCallback->ReleaseMediaResources();
}
}
+ virtual bool OnReaderTaskQueue() override
+ {
+ MOZ_ASSERT(mManager->mActiveCallback);
+ return mManager->mActiveCallback->OnReaderTaskQueue();
+ }
SharedDecoderManager* mManager;
};
@@ -186,6 +191,9 @@ SharedDecoderManager::DrainComplete()
void
SharedDecoderManager::Shutdown()
{
+ // Shutdown() should have been called on any proxies.
+ MOZ_ASSERT(!mActiveProxy);
+
if (mDecoder) {
mDecoder->Shutdown();
mDecoder = nullptr;
diff --git a/dom/media/fmp4/gmp/MediaDataDecoderProxy.h b/dom/media/fmp4/gmp/MediaDataDecoderProxy.h
index e6a20477788..54f72bedf82 100644
--- a/dom/media/fmp4/gmp/MediaDataDecoderProxy.h
+++ b/dom/media/fmp4/gmp/MediaDataDecoderProxy.h
@@ -116,6 +116,11 @@ public:
virtual void FlushComplete();
+ virtual bool OnReaderTaskQueue() override
+ {
+ return mProxyCallback->OnReaderTaskQueue();
+ }
+
private:
MediaDataDecoderProxy* mProxyDecoder;
MediaDataDecoderCallback* mProxyCallback;
diff --git a/dom/media/fmp4/wmf/WMFMediaDataDecoder.cpp b/dom/media/fmp4/wmf/WMFMediaDataDecoder.cpp
index d8d18c86a70..fd37503a245 100644
--- a/dom/media/fmp4/wmf/WMFMediaDataDecoder.cpp
+++ b/dom/media/fmp4/wmf/WMFMediaDataDecoder.cpp
@@ -30,6 +30,7 @@ WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager,
, mMonitor("WMFMediaDataDecoder")
, mIsDecodeTaskDispatched(false)
, mIsFlushing(false)
+ , mIsShutDown(false)
{
}
@@ -40,6 +41,9 @@ WMFMediaDataDecoder::~WMFMediaDataDecoder()
nsresult
WMFMediaDataDecoder::Init()
{
+ MOZ_ASSERT(!mDecoder);
+ MOZ_ASSERT(!mIsShutDown);
+
mDecoder = mMFTManager->Init();
NS_ENSURE_TRUE(mDecoder, NS_ERROR_FAILURE);
@@ -49,6 +53,8 @@ WMFMediaDataDecoder::Init()
nsresult
WMFMediaDataDecoder::Shutdown()
{
+ MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
+
if (mTaskQueue) {
mTaskQueue->Dispatch(
NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown));
@@ -62,6 +68,7 @@ WMFMediaDataDecoder::Shutdown()
MOZ_ASSERT(!mIsDecodeTaskDispatched);
}
#endif
+ mIsShutDown = true;
return NS_OK;
}
@@ -91,6 +98,9 @@ WMFMediaDataDecoder::EnsureDecodeTaskDispatched()
nsresult
WMFMediaDataDecoder::Input(MediaRawData* aSample)
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
+ MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
+
MonitorAutoLock mon(mMonitor);
mInput.push(aSample);
EnsureDecodeTaskDispatched();
@@ -172,6 +182,9 @@ WMFMediaDataDecoder::PurgeInputQueue()
nsresult
WMFMediaDataDecoder::Flush()
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
+ MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
+
MonitorAutoLock mon(mMonitor);
PurgeInputQueue();
mIsFlushing = true;
@@ -199,12 +212,17 @@ WMFMediaDataDecoder::ProcessDrain()
nsresult
WMFMediaDataDecoder::Drain()
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
+ MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
+
mTaskQueue->Dispatch(NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain));
return NS_OK;
}
bool
WMFMediaDataDecoder::IsHardwareAccelerated() const {
+ MOZ_ASSERT(!mIsShutDown);
+
return mMFTManager && mMFTManager->IsHardwareAccelerated();
}
diff --git a/dom/media/fmp4/wmf/WMFMediaDataDecoder.h b/dom/media/fmp4/wmf/WMFMediaDataDecoder.h
index 8e2547d76f6..3c1b1911565 100644
--- a/dom/media/fmp4/wmf/WMFMediaDataDecoder.h
+++ b/dom/media/fmp4/wmf/WMFMediaDataDecoder.h
@@ -101,6 +101,7 @@ private:
std::queue> mInput;
bool mIsDecodeTaskDispatched;
bool mIsFlushing;
+ bool mIsShutDown;
};
} // namespace mozilla
diff --git a/dom/media/gtest/TestIntervalSet.cpp b/dom/media/gtest/TestIntervalSet.cpp
new file mode 100644
index 00000000000..db6ac360778
--- /dev/null
+++ b/dom/media/gtest/TestIntervalSet.cpp
@@ -0,0 +1,591 @@
+/* -*- 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
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "gtest/gtest.h"
+#include "mozilla/dom/TimeRanges.h"
+#include "TimeUnits.h"
+#include "Intervals.h"
+#include
+#include
+
+using namespace mozilla;
+
+typedef media::Interval ByteInterval;
+typedef media::Interval IntInterval;
+
+ByteInterval CreateByteInterval(int32_t aStart, int32_t aEnd)
+{
+ ByteInterval test(aStart, aEnd);
+ return test;
+}
+
+media::IntervalSet CreateByteIntervalSet(int32_t aStart, int32_t aEnd)
+{
+ media::IntervalSet test;
+ test += ByteInterval(aStart, aEnd);
+ return test;
+}
+
+TEST(IntervalSet, Constructors)
+{
+ const int32_t start = 1;
+ const int32_t end = 2;
+ const int32_t fuzz = 0;
+
+ // Compiler exercise.
+ ByteInterval test1(start, end);
+ ByteInterval test2(test1);
+ ByteInterval test3(start, end, fuzz);
+ ByteInterval test4(test3);
+ ByteInterval test5 = CreateByteInterval(start, end);
+
+ media::IntervalSet blah1(test1);
+ media::IntervalSet blah2 = blah1;
+ media::IntervalSet blah3 = blah1 + test1;
+ media::IntervalSet blah4 = test1 + blah1;
+ media::IntervalSet blah5 = CreateByteIntervalSet(start, end);
+ (void)test1; (void)test2; (void)test3; (void)test4; (void)test5;
+ (void)blah1; (void)blah2; (void)blah3; (void)blah4; (void)blah5;
+}
+
+media::TimeInterval CreateTimeInterval(int32_t aStart, int32_t aEnd)
+{
+ // Copy constructor test
+ media::Microseconds startus(aStart);
+ media::TimeUnit start(startus);
+ media::TimeUnit end;
+ // operator= test
+ end = media::Microseconds(aEnd);
+ media::TimeInterval ti(start, end);
+ return ti;
+}
+
+media::TimeIntervals CreateTimeIntervals(int32_t aStart, int32_t aEnd)
+{
+ media::TimeIntervals test;
+ test += CreateTimeInterval(aStart, aEnd);
+ return test;
+}
+
+TEST(IntervalSet, TimeIntervalsConstructors)
+{
+ const media::Microseconds start(1);
+ const media::Microseconds end(2);
+ const media::Microseconds fuzz;
+
+ // Compiler exercise.
+ media::TimeInterval test1(start, end);
+ media::TimeInterval test2(test1);
+ media::TimeInterval test3(start, end, fuzz);
+ media::TimeInterval test4(test3);
+ media::TimeInterval test5 = CreateTimeInterval(start.mValue, end.mValue);
+
+ media::TimeIntervals blah1(test1);
+ media::TimeIntervals blah2(blah1);
+ media::TimeIntervals blah3 = blah1 + test1;
+ media::TimeIntervals blah4 = test1 + blah1;
+ media::TimeIntervals blah5 = CreateTimeIntervals(start.mValue, end.mValue);
+ (void)test1; (void)test2; (void)test3; (void)test4; (void)test5;
+ (void)blah1; (void)blah2; (void)blah3; (void)blah4; (void)blah5;
+}
+
+TEST(IntervalSet, Length)
+{
+ IntInterval i(15, 25);
+ EXPECT_EQ(10, i.Length());
+}
+
+TEST(IntervalSet, Intersection)
+{
+ IntInterval i0(10, 20);
+ IntInterval i1(15, 25);
+ IntInterval i = i0.Intersection(i1);
+ EXPECT_EQ(15, i.mStart);
+ EXPECT_EQ(20, i.mEnd);
+}
+
+TEST(IntervalSet, Equals)
+{
+ IntInterval i0(10, 20);
+ IntInterval i1(10, 20);
+ EXPECT_EQ(i0, i1);
+
+ IntInterval i2(5, 20);
+ EXPECT_NE(i0, i2);
+
+ IntInterval i3(10, 15);
+ EXPECT_NE(i0, i2);
+}
+
+TEST(IntervalSet, IntersectionIntervalSet)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10);
+ i0 += IntInterval(20, 25);
+ i0 += IntInterval(40, 60);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(16, 27));
+ i1.Add(IntInterval(45, 50));
+ i1.Add(IntInterval(53, 57));
+
+ media::IntervalSet i = media::Intersection(i0, i1);
+
+ EXPECT_EQ(4u, i.Length());
+
+ EXPECT_EQ(7, i[0].mStart);
+ EXPECT_EQ(10, i[0].mEnd);
+
+ EXPECT_EQ(20, i[1].mStart);
+ EXPECT_EQ(25, i[1].mEnd);
+
+ EXPECT_EQ(45, i[2].mStart);
+ EXPECT_EQ(50, i[2].mEnd);
+
+ EXPECT_EQ(53, i[3].mStart);
+ EXPECT_EQ(57, i[3].mEnd);
+}
+
+template
+static void Compare(media::IntervalSet aI1, media::IntervalSet aI2)
+{
+ media::IntervalSet i1(aI1);
+ media::IntervalSet i2(aI1);
+ EXPECT_EQ(i1.Length(), i2.Length());
+ if (i1.Length() != i2.Length()) {
+ return;
+ }
+ for (uint32_t i = 0; i < i1.Length(); i++) {
+ EXPECT_EQ(i1[i].mStart, i2[i].mStart);
+ EXPECT_EQ(i1[i].mEnd, i2[i].mEnd);
+ }
+}
+
+TEST(IntervalSet, IntersectionNormalizedIntervalSet)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10);
+ i0 += IntInterval(8, 25);
+ i0 += IntInterval(24, 60);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(10, 27));
+ i1.Add(IntInterval(45, 50));
+ i1.Add(IntInterval(53, 57));
+
+ // Compare intersections to ensure an intersection of normalized intervalsets
+ // is equal to the intersection of non-normalized intervalsets.
+ media::IntervalSet intersection = media::Intersection(i0, i1);
+
+ media::IntervalSet i0_normalize(i0);
+ i0_normalize.Normalize();
+ media::IntervalSet i1_normalize(i1);
+ i1_normalize.Normalize();
+ media::IntervalSet intersection_normalize =
+ media::Intersection(i0_normalize, i1_normalize);
+ Compare(intersection, intersection_normalize);
+}
+
+static void GeneratePermutations(media::IntervalSet aI1,
+ media::IntervalSet aI2)
+{
+ media::IntervalSet i_ref = media::Intersection(aI1, aI2);
+ // Test all permutations possible
+ std::vector comb1;
+ for (uint32_t i = 0; i < aI1.Length(); i++) {
+ comb1.push_back(i);
+ }
+ std::vector comb2;
+ for (uint32_t i = 0; i < aI2.Length(); i++) {
+ comb2.push_back(i);
+ }
+
+ do {
+ do {
+ // Create intervals according to new indexes.
+ media::IntervalSet i_0;
+ for (uint32_t i = 0; i < comb1.size(); i++) {
+ i_0 += aI1[comb1[i]];
+ }
+ media::IntervalSet i_1;
+ for (uint32_t i = 0; i < comb2.size(); i++) {
+ i_1 += aI2[comb2[i]];
+ }
+ // Check intersections yield the same result.
+ Compare(i_0.Intersection(i_1), i_ref);
+ } while (std::next_permutation(comb2.begin(), comb2.end()));
+ } while (std::next_permutation(comb1.begin(), comb1.end()));
+}
+
+TEST(IntervalSet, IntersectionUnorderedIntervalSet)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10);
+ i0 += IntInterval(20, 25);
+ i0 += IntInterval(40, 60);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(16, 27));
+ i1.Add(IntInterval(45, 50));
+ i1.Add(IntInterval(53, 57));
+
+ GeneratePermutations(i0, i1);
+}
+
+TEST(IntervalSet, IntersectionUnorderedNonNormalizedIntervalSet)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10);
+ i0 += IntInterval(8, 25);
+ i0 += IntInterval(24, 60);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(10, 27));
+ i1.Add(IntInterval(45, 50));
+ i1.Add(IntInterval(53, 57));
+
+ GeneratePermutations(i0, i1);
+}
+
+static media::IntervalSet Duplicate(const media::IntervalSet& aValue)
+{
+ media::IntervalSet value(aValue);
+ return value;
+}
+
+TEST(IntervalSet, Normalize)
+{
+ media::IntervalSet i;
+ // Test IntervalSet + Interval operator.
+ i = i + IntInterval(20, 30);
+ // Test Internal + IntervalSet operator.
+ i = IntInterval(2, 7) + i;
+ // Test Interval + IntervalSet operator
+ i = IntInterval(1, 8) + i;
+ media::IntervalSet interval;
+ interval += IntInterval(5, 10);
+ // Test += with move.
+ i += Duplicate(interval);
+ // Test = with move and add with move.
+ i = Duplicate(interval) + i;
+
+ media::IntervalSet o(i);
+ o.Normalize();
+
+ EXPECT_EQ(2u, o.Length());
+
+ EXPECT_EQ(1, o[0].mStart);
+ EXPECT_EQ(10, o[0].mEnd);
+
+ EXPECT_EQ(20, o[1].mStart);
+ EXPECT_EQ(30, o[1].mEnd);
+}
+
+TEST(IntervalSet, Union)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10);
+ i0 += IntInterval(20, 25);
+ i0 += IntInterval(40, 60);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(16, 27));
+ i1.Add(IntInterval(45, 50));
+ i1.Add(IntInterval(53, 57));
+
+ media::IntervalSet i = media::Union(i0, i1);
+
+ EXPECT_EQ(3u, i.Length());
+
+ EXPECT_EQ(5, i[0].mStart);
+ EXPECT_EQ(15, i[0].mEnd);
+
+ EXPECT_EQ(16, i[1].mStart);
+ EXPECT_EQ(27, i[1].mEnd);
+
+ EXPECT_EQ(40, i[2].mStart);
+ EXPECT_EQ(60, i[2].mEnd);
+}
+
+TEST(IntervalSet, UnionNotOrdered)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(20, 25);
+ i0 += IntInterval(40, 60);
+ i0 += IntInterval(5, 10);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(16, 27));
+ i1.Add(IntInterval(7, 15));
+ i1.Add(IntInterval(53, 57));
+ i1.Add(IntInterval(45, 50));
+
+ media::IntervalSet i = media::Union(i0, i1);
+
+ EXPECT_EQ(3u, i.Length());
+
+ EXPECT_EQ(5, i[0].mStart);
+ EXPECT_EQ(15, i[0].mEnd);
+
+ EXPECT_EQ(16, i[1].mStart);
+ EXPECT_EQ(27, i[1].mEnd);
+
+ EXPECT_EQ(40, i[2].mStart);
+ EXPECT_EQ(60, i[2].mEnd);
+}
+
+TEST(IntervalSet, NormalizeFuzz)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(11, 25, 0);
+ i0 += IntInterval(5, 10, 1);
+ i0 += IntInterval(40, 60, 1);
+ i0.Normalize();
+
+ EXPECT_EQ(2u, i0.Length());
+
+ EXPECT_EQ(5, i0[0].mStart);
+ EXPECT_EQ(25, i0[0].mEnd);
+
+ EXPECT_EQ(40, i0[1].mStart);
+ EXPECT_EQ(60, i0[1].mEnd);
+}
+
+TEST(IntervalSet, UnionFuzz)
+{
+ media::IntervalSet i0;
+ i0 += IntInterval(5, 10, 1);
+ i0 += IntInterval(11, 25, 0);
+ i0 += IntInterval(40, 60, 1);
+
+ media::IntervalSet i1;
+ i1.Add(IntInterval(7, 15, 1));
+ i1.Add(IntInterval(16, 27, 1));
+ i1.Add(IntInterval(45, 50, 1));
+ i1.Add(IntInterval(53, 57, 1));
+
+ media::IntervalSet i = media::Union(i0, i1);
+
+ EXPECT_EQ(2u, i.Length());
+
+ EXPECT_EQ(5, i[0].mStart);
+ EXPECT_EQ(27, i[0].mEnd);
+
+ EXPECT_EQ(40, i[1].mStart);
+ EXPECT_EQ(60, i[1].mEnd);
+
+ i0.Normalize();
+ EXPECT_EQ(2u, i0.Length());
+ EXPECT_EQ(5, i0[0].mStart);
+ EXPECT_EQ(25, i0[0].mEnd);
+ EXPECT_EQ(40, i0[1].mStart);
+ EXPECT_EQ(60, i0[1].mEnd);
+}
+
+TEST(IntervalSet, Contiguous)
+{
+ EXPECT_FALSE(IntInterval(5, 10).Contiguous(IntInterval(11, 25)));
+ EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(10, 25)));
+ EXPECT_TRUE(IntInterval(5, 10, 1).Contiguous(IntInterval(11, 25)));
+ EXPECT_TRUE(IntInterval(5, 10).Contiguous(IntInterval(11, 25, 1)));
+}
+
+TEST(IntervalSet, TimeRangesSeconds)
+{
+ media::TimeIntervals i0;
+ i0 += media::TimeInterval(media::TimeUnit::FromSeconds(20), media::TimeUnit::FromSeconds(25));
+ i0 += media::TimeInterval(media::TimeUnit::FromSeconds(40), media::TimeUnit::FromSeconds(60));
+ i0 += media::TimeInterval(media::TimeUnit::FromSeconds(5), media::TimeUnit::FromSeconds(10));
+
+ media::TimeIntervals i1;
+ i1.Add(media::TimeInterval(media::TimeUnit::FromSeconds(16), media::TimeUnit::FromSeconds(27)));
+ i1.Add(media::TimeInterval(media::TimeUnit::FromSeconds(7), media::TimeUnit::FromSeconds(15)));
+ i1.Add(media::TimeInterval(media::TimeUnit::FromSeconds(53), media::TimeUnit::FromSeconds(57)));
+ i1.Add(media::TimeInterval(media::TimeUnit::FromSeconds(45), media::TimeUnit::FromSeconds(50)));
+
+ media::TimeIntervals i(i0 + i1);
+ nsRefPtr tr = new dom::TimeRanges();
+ i.ToTimeRanges(tr);
+ EXPECT_EQ(tr->Length(), i.Length());
+ for (dom::TimeRanges::index_type index = 0; index < tr->Length(); index++) {
+ ErrorResult rv;
+ EXPECT_EQ(tr->Start(index, rv), i[index].mStart.ToSeconds());
+ EXPECT_EQ(tr->Start(index, rv), i.Start(index).ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i[index].mEnd.ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i.End(index).ToSeconds());
+ }
+
+ i.Normalize();
+ tr->Normalize();
+ EXPECT_EQ(tr->Length(), i.Length());
+ for (dom::TimeRanges::index_type index = 0; index < tr->Length(); index++) {
+ ErrorResult rv;
+ EXPECT_EQ(tr->Start(index, rv), i[index].mStart.ToSeconds());
+ EXPECT_EQ(tr->Start(index, rv), i.Start(index).ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i[index].mEnd.ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i.End(index).ToSeconds());
+ }
+}
+
+static void CheckTimeRanges(dom::TimeRanges* aTr, const media::TimeIntervals& aTi)
+{
+ EXPECT_EQ(aTr->Length(), aTi.Length());
+ for (dom::TimeRanges::index_type i = 0; i < aTr->Length(); i++) {
+ ErrorResult rv;
+ EXPECT_EQ(aTr->Start(i, rv), aTi[i].mStart.ToSeconds());
+ EXPECT_EQ(aTr->Start(i, rv), aTi.Start(i).ToSeconds());
+ EXPECT_EQ(aTr->End(i, rv), aTi[i].mEnd.ToSeconds());
+ EXPECT_EQ(aTr->End(i, rv), aTi.End(i).ToSeconds());
+ }
+}
+
+TEST(IntervalSet, TimeRangesConversion)
+{
+ nsRefPtr tr = new dom::TimeRanges();
+ tr->Add(20, 25);
+ tr->Add(40, 60);
+ tr->Add(5, 10);
+ tr->Add(16, 27);
+ tr->Add(53, 57);
+ tr->Add(45, 50);
+
+ // explicit copy constructor
+ media::TimeIntervals i1(tr);
+ CheckTimeRanges(tr, i1);
+
+ // static FromTimeRanges
+ media::TimeIntervals i2 = media::TimeIntervals::FromTimeRanges(tr);
+ CheckTimeRanges(tr, i2);
+
+ media::TimeIntervals i3;
+ // operator=(TimeRanges*)
+ i3 = tr;
+ CheckTimeRanges(tr, i3);
+
+ i1.Normalize();
+ tr->Normalize();
+
+ CheckTimeRanges(tr, i1);
+
+ // operator= test
+ i1 = tr.get();
+ CheckTimeRanges(tr, i1);
+}
+
+TEST(IntervalSet, TimeRangesMicroseconds)
+{
+ media::TimeIntervals i0;
+
+ // Test media::Microseconds and TimeUnit interchangeability (compilation only)
+ media::TimeUnit time1{media::Microseconds(5)};
+ media::Microseconds microseconds(5);
+ media::TimeUnit time2 = media::TimeUnit(microseconds);
+ EXPECT_EQ(time1, time2);
+
+ i0 += media::TimeInterval(media::Microseconds(20), media::Microseconds(25));
+ i0 += media::TimeInterval(media::Microseconds(40), media::Microseconds(60));
+ i0 += media::TimeInterval(media::Microseconds(5), media::Microseconds(10));
+
+ media::TimeIntervals i1;
+ i1.Add(media::TimeInterval(media::Microseconds(16), media::Microseconds(27)));
+ i1.Add(media::TimeInterval(media::Microseconds(7), media::Microseconds(15)));
+ i1.Add(media::TimeInterval(media::Microseconds(53), media::Microseconds(57)));
+ i1.Add(media::TimeInterval(media::Microseconds(45), media::Microseconds(50)));
+
+ media::TimeIntervals i(i0 + i1);
+ nsRefPtr tr = new dom::TimeRanges();
+ i.ToTimeRanges(tr);
+ EXPECT_EQ(tr->Length(), i.Length());
+ for (dom::TimeRanges::index_type index = 0; index < tr->Length(); index++) {
+ ErrorResult rv;
+ EXPECT_EQ(tr->Start(index, rv), i[index].mStart.ToSeconds());
+ EXPECT_EQ(tr->Start(index, rv), i.Start(index).ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i[index].mEnd.ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i.End(index).ToSeconds());
+ }
+
+ i.Normalize();
+ tr->Normalize();
+ EXPECT_EQ(tr->Length(), i.Length());
+ for (dom::TimeRanges::index_type index = 0; index < tr->Length(); index++) {
+ ErrorResult rv;
+ EXPECT_EQ(tr->Start(index, rv), i[index].mStart.ToSeconds());
+ EXPECT_EQ(tr->Start(index, rv), i.Start(index).ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i[index].mEnd.ToSeconds());
+ EXPECT_EQ(tr->End(index, rv), i.End(index).ToSeconds());
+ }
+}
+
+template
+class Foo
+{
+public:
+ Foo()
+ : mArg1(1)
+ , mArg2(2)
+ , mArg3(3)
+ {}
+
+ Foo(T a1, T a2, T a3)
+ : mArg1(a1)
+ , mArg2(a2)
+ , mArg3(a3)
+ {}
+
+ Foo operator+ (const Foo& aOther) const
+ {
+ Foo blah;
+ blah.mArg1 += aOther.mArg1;
+ blah.mArg2 += aOther.mArg2;
+ blah.mArg3 += aOther.mArg3;
+ return blah;
+ }
+ Foo operator- (const Foo& aOther) const
+ {
+ Foo blah;
+ blah.mArg1 -= aOther.mArg1;
+ blah.mArg2 -= aOther.mArg2;
+ blah.mArg3 -= aOther.mArg3;
+ return blah;
+ }
+ bool operator< (const Foo& aOther) const
+ {
+ return mArg1 < aOther.mArg1;
+ }
+ bool operator== (const Foo& aOther) const
+ {
+ return mArg1 == aOther.mArg1;
+ }
+ bool operator<= (const Foo& aOther) const
+ {
+ return mArg1 <= aOther.mArg1;
+ }
+
+private:
+ int32_t mArg1;
+ int32_t mArg2;
+ int32_t mArg3;
+};
+
+TEST(IntervalSet, FooIntervalSet)
+{
+ media::Interval> i(Foo(), Foo(4,5,6));
+ media::IntervalSet> is;
+ is += i;
+ is += i;
+ is.Add(i);
+ is = is + i;
+ is = i + is;
+ EXPECT_EQ(5u, is.Length());
+ is.Normalize();
+ EXPECT_EQ(1u, is.Length());
+ EXPECT_EQ(Foo(), is[0].mStart);
+ EXPECT_EQ(Foo(4,5,6), is[0].mEnd);
+}
diff --git a/dom/media/gtest/moz.build b/dom/media/gtest/moz.build
index 5abc1bb1901..7311123ec8d 100644
--- a/dom/media/gtest/moz.build
+++ b/dom/media/gtest/moz.build
@@ -9,6 +9,7 @@ UNIFIED_SOURCES += [
'TestAudioCompactor.cpp',
'TestGMPCrossOrigin.cpp',
'TestGMPRemoveAndDelete.cpp',
+ 'TestIntervalSet.cpp',
'TestMP4Demuxer.cpp',
'TestMP4Reader.cpp',
'TestTrackEncoder.cpp',
diff --git a/dom/media/moz.build b/dom/media/moz.build
index fdc6fe67494..8ccd120ba1b 100644
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -113,6 +113,7 @@ EXPORTS += [
'EncodedBufferCache.h',
'FileBlockCache.h',
'GraphDriver.h',
+ 'Intervals.h',
'Latency.h',
'MediaCache.h',
'MediaData.h',
@@ -156,6 +157,14 @@ EXPORTS.mozilla += [
'MediaManager.h',
]
+EXPORTS.mozilla.media.webrtc += [
+ 'webrtc/WebrtcGlobal.h',
+]
+
+IPDL_SOURCES += [
+ 'webrtc/PWebrtcGlobal.ipdl'
+]
+
if CONFIG['MOZ_B2G']:
EXPORTS.mozilla += [
'MediaPermissionGonk.h',
diff --git a/dom/media/webm/IntelWebMVideoDecoder.h b/dom/media/webm/IntelWebMVideoDecoder.h
index cc342847c80..13e7409bc9d 100644
--- a/dom/media/webm/IntelWebMVideoDecoder.h
+++ b/dom/media/webm/IntelWebMVideoDecoder.h
@@ -43,6 +43,11 @@ public:
virtual void InputExhausted() override;
virtual void Error() override;
+ virtual bool OnReaderTaskQueue() override
+ {
+ return mReader->OnTaskQueue();
+ }
+
IntelWebMVideoDecoder(WebMReader* aReader);
~IntelWebMVideoDecoder();
diff --git a/media/webrtc/signaling/src/peerconnection/PWebrtcGlobal.ipdl b/dom/media/webrtc/PWebrtcGlobal.ipdl
similarity index 100%
rename from media/webrtc/signaling/src/peerconnection/PWebrtcGlobal.ipdl
rename to dom/media/webrtc/PWebrtcGlobal.ipdl
diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobal.h b/dom/media/webrtc/WebrtcGlobal.h
similarity index 100%
rename from media/webrtc/signaling/src/peerconnection/WebrtcGlobal.h
rename to dom/media/webrtc/WebrtcGlobal.h
diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp
index e978307323c..cc9a24d5e4d 100644
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -394,7 +394,9 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar,
if (!CallNPN_GetValue_NPNVdocumentOrigin(&v, &result)) {
return NPERR_GENERIC_ERROR;
}
- if (result == NPERR_NO_ERROR) {
+ if (result == NPERR_NO_ERROR ||
+ (GetQuirks() &
+ PluginModuleChild::QUIRK_FLASH_RETURN_EMPTY_DOCUMENT_ORIGIN)) {
*static_cast(aValue) = ToNewCString(v);
}
return result;
diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp
index 54d1ef22663..6fdb97144b7 100644
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -2124,15 +2124,18 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
#endif
}
-#ifdef OS_WIN
if (specialType == nsPluginHost::eSpecialType_Flash) {
+ mQuirks |= QUIRK_FLASH_RETURN_EMPTY_DOCUMENT_ORIGIN;
+#ifdef OS_WIN
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
mQuirks |= QUIRK_FLASH_FIXUP_MOUSE_CAPTURE;
+#endif
}
+#ifdef OS_WIN
// QuickTime plugin usually loaded with audio/mpeg mimetype
NS_NAMED_LITERAL_CSTRING(quicktime, "npqtplugin");
if (FindInReadable(quicktime, mPluginFilename)) {
diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h
index ded7f426a44..47a9d940167 100644
--- a/dom/plugins/ipc/PluginModuleChild.h
+++ b/dom/plugins/ipc/PluginModuleChild.h
@@ -282,6 +282,10 @@ public:
// CGContextRef we pass to it in NPP_HandleEvent(NPCocoaEventDrawRect)
// outside of that call. See bug 804606.
QUIRK_FLASH_AVOID_CGMODE_CRASHES = 1 << 10,
+ // Work around a Flash bug where it fails to check the error code of a
+ // NPN_GetValue(NPNVdocumentOrigin) call before trying to dereference
+ // its char* output.
+ QUIRK_FLASH_RETURN_EMPTY_DOCUMENT_ORIGIN = 1 << 11,
};
int GetQuirks() { return mQuirks; }
diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
index be7f08b9a26..cea57fe6324 100644
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -135,35 +135,37 @@ PRLogModuleInfo* XULDocument::gXULLog;
//----------------------------------------------------------------------
-struct BroadcasterMapEntry : public PLDHashEntryHdr {
- Element* mBroadcaster; // [WEAK]
- nsSmallVoidArray mListeners; // [OWNING] of BroadcastListener objects
-};
-
struct BroadcastListener {
nsWeakPtr mListener;
nsCOMPtr mAttribute;
};
+struct BroadcasterMapEntry : public PLDHashEntryHdr
+{
+ Element* mBroadcaster; // [WEAK]
+ nsTArray mListeners; // [OWNING] of BroadcastListener objects
+};
+
Element*
nsRefMapEntry::GetFirstElement()
{
- return static_cast(mRefContentList.SafeElementAt(0));
+ return mRefContentList.SafeElementAt(0);
}
void
nsRefMapEntry::AppendAll(nsCOMArray* aElements)
{
- for (int32_t i = 0; i < mRefContentList.Count(); ++i) {
- aElements->AppendObject(static_cast(mRefContentList[i]));
+ for (size_t i = 0; i < mRefContentList.Length(); ++i) {
+ aElements->AppendObject(mRefContentList[i]);
}
}
bool
nsRefMapEntry::AddElement(Element* aElement)
{
- if (mRefContentList.IndexOf(aElement) >= 0)
+ if (mRefContentList.Contains(aElement)) {
return true;
+ }
return mRefContentList.AppendElement(aElement);
}
@@ -171,7 +173,7 @@ bool
nsRefMapEntry::RemoveElement(Element* aElement)
{
mRefContentList.RemoveElement(aElement);
- return mRefContentList.Count() == 0;
+ return mRefContentList.IsEmpty();
}
//----------------------------------------------------------------------
@@ -618,13 +620,14 @@ ClearBroadcasterMapEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
{
BroadcasterMapEntry* entry =
static_cast(aEntry);
- for (int32_t i = entry->mListeners.Count() - 1; i >= 0; --i) {
- delete (BroadcastListener*)entry->mListeners[i];
+ for (size_t i = entry->mListeners.Length() - 1; i != (size_t)-1; --i) {
+ delete entry->mListeners[i];
}
+ entry->mListeners.Clear();
// N.B. that we need to manually run the dtor because we
- // constructed the nsSmallVoidArray object in-place.
- entry->mListeners.~nsSmallVoidArray();
+ // constructed the nsTArray object in-place.
+ entry->mListeners.~nsTArray();
}
static bool
@@ -786,26 +789,22 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
entry->mBroadcaster = &aBroadcaster;
- // N.B. placement new to construct the nsSmallVoidArray object
- // in-place
- new (&entry->mListeners) nsSmallVoidArray();
+ // N.B. placement new to construct the nsTArray object in-place
+ new (&entry->mListeners) nsTArray();
}
// Only add the listener if it's not there already!
nsCOMPtr