Bug 1336763 - Use mTabChild instead of nsDocShell->GetTabChild() inside nsGlobalWindow. r?ehsan
MozReview-Commit-ID: 8ElS1U1QdnI
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7374,22 +7374,18 @@ nsGlobalWindow::CanMoveResizeWindows(Cal
if (!CanSetProperty("dom.disable_window_move_resize")) {
return false;
}
// Ignore the request if we have more than one tab in the window.
uint32_t itemCount = 0;
if (XRE_IsContentProcess()) {
- nsCOMPtr<nsIDocShell> docShell = GetDocShell();
- if (docShell) {
- nsCOMPtr<nsITabChild> child = docShell->GetTabChild();
- if (child) {
- child->SendGetTabCount(&itemCount);
- }
+ if (mTabChild) {
+ mTabChild->SendGetTabCount(&itemCount);
}
} else {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
if (!treeOwner || NS_FAILED(treeOwner->GetTabCount(&itemCount))) {
itemCount = 0;
}
}
if (itemCount > 1) {
@@ -10015,22 +10011,20 @@ public:
nsCOMPtr<nsIDOMXULCommandDispatcher> mDispatcher;
nsString mAction;
};
nsresult
nsGlobalWindow::UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason)
{
// If this is a child process, redirect to the parent process.
- if (nsIDocShell* docShell = GetDocShell()) {
- if (nsCOMPtr<nsITabChild> child = docShell->GetTabChild()) {
- nsContentUtils::AddScriptRunner(new ChildCommandDispatcher(this, child,
- anAction));
- return NS_OK;
- }
+ if (mTabChild) {
+ nsContentUtils::AddScriptRunner(new ChildCommandDispatcher(this, mTabChild,
+ anAction));
+ return NS_OK;
}
nsPIDOMWindowOuter *rootWindow = nsGlobalWindow::GetPrivateRoot();
if (!rootWindow)
return NS_OK;
nsCOMPtr<nsIDOMXULDocument> xulDoc =
do_QueryInterface(rootWindow->GetExtantDoc());
@@ -11598,20 +11592,17 @@ nsGlobalWindow::ShowSlowScriptDialog()
Telemetry::Accumulate(Telemetry::SLOW_SCRIPT_PAGE_COUNT, 1);
}
mHasHadSlowScript = true;
if (XRE_IsContentProcess() &&
ProcessHangMonitor::Get()) {
ProcessHangMonitor::SlowScriptAction action;
RefPtr<ProcessHangMonitor> monitor = ProcessHangMonitor::Get();
- nsIDocShell* docShell = GetDocShell();
- nsCOMPtr<nsITabChild> child = docShell ? docShell->GetTabChild() : nullptr;
- action = monitor->NotifySlowScript(child,
- filename.get());
+ action = monitor->NotifySlowScript(mTabChild, filename.get());
if (action == ProcessHangMonitor::Terminate) {
return KillSlowScript;
}
if (action == ProcessHangMonitor::StartDebugger) {
// Spin a nested event loop so that the debugger in the parent can fetch
// any information it needs. Once the debugger has started, return to the
// script.