bug 1257287 - add nsIDocShell.tabChild r=smaug

This commit is contained in:
Trevor Saunders 2016-03-16 15:18:38 -04:00
Родитель 2c05850952
Коммит a6f221b6a2
10 изменённых файлов: 59 добавлений и 40 удалений

Просмотреть файл

@ -499,7 +499,7 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
if (IPCAccessibilityActive()) {
nsIDocShell* docShell = aDocument->GetDocShell();
if (docShell) {
nsCOMPtr<nsITabChild> tabChild = do_GetInterface(docShell);
nsCOMPtr<nsITabChild> tabChild = docShell->GetTabChild();
// XXX We may need to handle the case that we don't have a tab child
// differently. It may be that this will cause us to fail to notify

Просмотреть файл

@ -1047,14 +1047,8 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
return treeOwner->QueryInterface(aIID, aSink);
}
} else if (aIID.Equals(NS_GET_IID(nsITabChild))) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
nsresult rv = GetTreeOwner(getter_AddRefs(treeOwner));
if (NS_SUCCEEDED(rv) && treeOwner) {
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(treeOwner);
if (ir) {
return ir->GetInterface(aIID, aSink);
}
}
*aSink = GetTabChild().take();
return *aSink ? NS_OK : NS_ERROR_FAILURE;
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
nsCOMPtr<nsITabChild> tabChild =
do_GetInterface(static_cast<nsIDocShell*>(this));
@ -14364,3 +14358,18 @@ nsDocShell::GetEditingSession(nsIEditingSession** aEditSession)
mEditorData->GetEditingSession(aEditSession);
return *aEditSession ? NS_OK : NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsDocShell::GetScriptableTabChild(nsITabChild** aTabChild)
{
*aTabChild = GetTabChild().take();
return *aTabChild ? NS_OK : NS_ERROR_FAILURE;
}
already_AddRefed<nsITabChild>
nsDocShell::GetTabChild()
{
nsCOMPtr<nsIDocShellTreeOwner> owner(mTreeOwner);
nsCOMPtr<nsITabChild> tc = do_GetInterface(owner);
return tc.forget();
}

Просмотреть файл

@ -41,6 +41,8 @@ interface nsIPrivacyTransitionObserver;
interface nsIReflowObserver;
interface nsIScrollObserver;
interface nsITabParent;
interface nsITabChild;
native TabChildRef(already_AddRefed<nsITabChild>);
typedef unsigned long nsLoadFlags;
@ -1097,4 +1099,10 @@ interface nsIDocShell : nsIDocShellTreeItem
* The editing session for this docshell.
*/
readonly attribute nsIEditingSession editingSession;
/**
* The tab child for this docshell.
*/
[binaryname(ScriptableTabChild)] readonly attribute nsITabChild tabChild;
[noscript,notxpcom,nostdcall] TabChildRef GetTabChild();
};

Просмотреть файл

@ -303,7 +303,8 @@ MarkWindowList(nsISimpleEnumerator* aWindowList, bool aCleanupJS,
MarkDocShell(rootDocShell, aCleanupJS, aPrepareForCC);
nsCOMPtr<nsITabChild> tabChild = do_GetInterface(rootDocShell);
nsCOMPtr<nsITabChild> tabChild =
rootDocShell ? rootDocShell->GetTabChild() : nullptr;
if (tabChild) {
nsCOMPtr<nsIContentFrameMessageManager> mm;
tabChild->GetMessageManager(getter_AddRefs(mm));

Просмотреть файл

@ -869,9 +869,11 @@ nsFocusManager::WindowShown(mozIDOMWindowProxy* aWindow, bool aNeedsFocus)
}
}
if (nsCOMPtr<nsITabChild> child = do_GetInterface(window->GetDocShell())) {
bool active = static_cast<TabChild*>(child.get())->ParentIsActive();
ActivateOrDeactivate(window, active);
if (nsIDocShell* docShell = window->GetDocShell()) {
if (nsCOMPtr<nsITabChild> child = docShell->GetTabChild()) {
bool active = static_cast<TabChild*>(child.get())->ParentIsActive();
ActivateOrDeactivate(window, active);
}
}
if (mFocusedWindow != window)
@ -1632,7 +1634,7 @@ nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
if (aAdjustWidgets && objectFrame && !sTestMode) {
if (XRE_IsContentProcess()) {
// set focus to the top level window via the chrome process.
nsCOMPtr<nsITabChild> tabChild = do_GetInterface(docShell);
nsCOMPtr<nsITabChild> tabChild = docShell->GetTabChild();
if (tabChild) {
static_cast<TabChild*>(tabChild.get())->SendDispatchFocusToTopLevelWindow();
}

Просмотреть файл

@ -9061,9 +9061,12 @@ nsresult
nsGlobalWindow::UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason)
{
// If this is a child process, redirect to the parent process.
if (nsCOMPtr<nsITabChild> child = do_GetInterface(GetDocShell())) {
nsContentUtils::AddScriptRunner(new ChildCommandDispatcher(this, child, anAction));
return NS_OK;
if (nsIDocShell* docShell = GetDocShell()) {
if (nsCOMPtr<nsITabChild> child = docShell->GetTabChild()) {
nsContentUtils::AddScriptRunner(new ChildCommandDispatcher(this, child,
anAction));
return NS_OK;
}
}
nsPIDOMWindowOuter *rootWindow = nsGlobalWindow::GetPrivateRoot();
@ -10685,7 +10688,8 @@ nsGlobalWindow::ShowSlowScriptDialog()
ProcessHangMonitor::Get()) {
ProcessHangMonitor::SlowScriptAction action;
RefPtr<ProcessHangMonitor> monitor = ProcessHangMonitor::Get();
nsCOMPtr<nsITabChild> child = do_GetInterface(GetDocShell());
nsIDocShell* docShell = GetDocShell();
nsCOMPtr<nsITabChild> child = docShell ? docShell->GetTabChild() : nullptr;
action = monitor->NotifySlowScript(child,
filename.get(),
lineno);

Просмотреть файл

@ -981,7 +981,9 @@ EventStateManager::ExecuteAccessKey(nsTArray<uint32_t>& aAccessCharCodes,
if (focusChanged && aIsTrustedEvent) {
// If this is a child process, inform the parent that we want the focus, but
// pass false since we don't want to change the window order.
nsCOMPtr<nsITabChild> child = do_GetInterface(mPresContext->GetDocShell());
nsIDocShell* docShell = mPresContext->GetDocShell();
nsCOMPtr<nsITabChild> child =
docShell ? docShell->GetTabChild() : nullptr;
if (child) {
child->SendRequestFocus(false);
}

Просмотреть файл

@ -512,7 +512,11 @@ public:
static inline TabChild*
GetFrom(nsIDocShell* aDocShell)
{
nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
if (!aDocShell) {
return nullptr;
}
nsCOMPtr<nsITabChild> tc = aDocShell->GetTabChild();
return static_cast<TabChild*>(tc.get());
}

Просмотреть файл

@ -73,23 +73,20 @@ nsPrintingProxy::ShowPrintDialog(mozIDOMWindowProxy *parent,
NS_ENSURE_ARG(webBrowserPrint);
NS_ENSURE_ARG(printSettings);
// Get the root docshell owner of this nsIDOMWindow, which
// should map to a TabChild, which we can then pass up to
// Get the TabChild for this nsIDOMWindow, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(parent);
NS_ENSURE_STATE(pwin);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDocShellTreeOwner> owner;
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(owner));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
nsCOMPtr<nsITabChild> tabchild = docShell->GetTabChild();
NS_ENSURE_STATE(tabchild);
TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
// Next, serialize the nsIWebBrowserPrint and nsIPrintSettings we were given.
nsresult rv = NS_OK;
nsCOMPtr<nsIPrintOptions> po =
do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -134,17 +131,13 @@ nsPrintingProxy::ShowProgress(mozIDOMWindowProxy* parent,
NS_ENSURE_ARG(printProgressParams);
NS_ENSURE_ARG(notifyOnOpen);
// Get the root docshell owner of this nsIDOMWindow, which
// should map to a TabChild, which we can then pass up to
// Get the TabChild for this nsIDOMWindow, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(parent);
NS_ENSURE_STATE(pwin);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDocShellTreeOwner> owner;
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(owner));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
nsCOMPtr<nsITabChild> tabchild = docShell->GetTabChild();
TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
RefPtr<PrintProgressDialogChild> dialogChild =
@ -152,6 +145,7 @@ nsPrintingProxy::ShowProgress(mozIDOMWindowProxy* parent,
SendPPrintProgressDialogConstructor(dialogChild);
nsresult rv = NS_OK;
mozilla::Unused << SendShowProgress(pBrowser, dialogChild,
isForPrinting, notifyOnOpen, &rv);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -379,18 +379,13 @@ OfflineCacheUpdateChild::Schedule()
NS_ASSERTION(mWindow, "Window must be provided to the offline cache update child");
nsCOMPtr<nsPIDOMWindowInner> window = mWindow.forget();
nsIDocShell *docshell = window->GetDocShell();
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
if (!item) {
nsCOMPtr<nsIDocShell >docshell = window->GetDocShell();
if (!docshell) {
NS_WARNING("doc shell tree item is null");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocShellTreeOwner> owner;
item->GetTreeOwner(getter_AddRefs(owner));
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
nsCOMPtr<nsITabChild> tabchild = docshell->GetTabChild();
// because owner implements nsITabChild, we can assume that it is
// the one and only TabChild.
TabChild* child = tabchild ? static_cast<TabChild*>(tabchild.get()) : nullptr;