Bug 617804 - Implement SetStatus in TabChild/TabParent, enables link tooltips. r=felipe

This commit is contained in:
Tom Schuster 2013-07-25 15:45:31 -04:00
parent 043432c180
commit f1700221b6
4 changed files with 56 additions and 5 deletions

View File

@ -190,6 +190,12 @@ parent:
SetCursor(uint32_t value);
SetBackgroundColor(nscolor color);
/**
* Used to set the current text of the status tooltip.
* Nowadays this is mainly used for link locations on hover.
*/
SetStatus(uint32_t type, nsString status);
/**
* Initiates an asynchronous request for permission for the
* provided principal.

View File

@ -744,8 +744,10 @@ NS_IMPL_RELEASE(TabChild)
NS_IMETHODIMP
TabChild::SetStatus(uint32_t aStatusType, const PRUnichar* aStatus)
{
// FIXME/bug 617804: should the platform support this?
return NS_OK;
return SetStatusWithContext(aStatusType,
aStatus ? static_cast<const nsString &>(nsDependentString(aStatus))
: EmptyString(),
nullptr);
}
NS_IMETHODIMP
@ -820,10 +822,13 @@ TabChild::ExitModalEventLoop(nsresult aStatus)
NS_IMETHODIMP
TabChild::SetStatusWithContext(uint32_t aStatusType,
const nsAString& aStatusText,
nsISupports* aStatusContext)
const nsAString& aStatusText,
nsISupports* aStatusContext)
{
// FIXME/bug 617804: should the platform support this?
// We can only send the status after the ipc machinery is set up,
// mRemoteFrame is a good indicator.
if (mRemoteFrame)
SendSetStatus(aStatusType, nsString(aStatusText));
return NS_OK;
}

View File

@ -41,6 +41,9 @@
#include "nsIURI.h"
#include "nsIMozBrowserFrame.h"
#include "nsIScriptSecurityManager.h"
#include "nsIWebBrowserChrome.h"
#include "nsIXULBrowserWindow.h"
#include "nsIXULWindow.h"
#include "nsViewManager.h"
#include "nsIWidget.h"
#include "nsIWindowWatcher.h"
@ -748,6 +751,42 @@ TabParent::RecvSetBackgroundColor(const nscolor& aColor)
return true;
}
bool
TabParent::RecvSetStatus(const uint32_t& aType, const nsString& aStatus)
{
nsCOMPtr<nsIContent> frame = do_QueryInterface(mFrameElement);
if (frame) {
nsCOMPtr<nsISupports> container = frame->OwnerDoc()->GetContainer();
if (!container)
return true;
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
if (!docShell)
return true;
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner)
return true;
nsCOMPtr<nsIXULWindow> window = do_GetInterface(treeOwner);
if (window) {
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
window->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
if (xulBrowserWindow) {
switch (aType)
{
case nsIWebBrowserChrome::STATUS_SCRIPT:
xulBrowserWindow->SetJSStatus(aStatus);
break;
case nsIWebBrowserChrome::STATUS_LINK:
xulBrowserWindow->SetOverLink(aStatus, nullptr);
break;
}
}
}
}
return true;
}
bool
TabParent::RecvNotifyIMEFocus(const bool& aFocus,
nsIMEUpdatePreference* aPreference,

View File

@ -153,6 +153,7 @@ public:
const int32_t& aFocusChange);
virtual bool RecvSetCursor(const uint32_t& aValue);
virtual bool RecvSetBackgroundColor(const nscolor& aValue);
virtual bool RecvSetStatus(const uint32_t& aType, const nsString& aStatus);
virtual bool RecvGetDPI(float* aValue);
virtual bool RecvGetDefaultScale(double* aValue);
virtual bool RecvGetWidgetNativeData(WindowsHandle* aValue);