2015-05-12 09:30:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-03-09 04:06:56 +03:00
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsDocShellTreeOwner.h"
|
|
|
|
#include "nsWebBrowser.h"
|
|
|
|
|
|
|
|
// Helper Classes
|
2017-04-25 13:22:25 +03:00
|
|
|
#include "nsContentUtils.h"
|
2000-03-14 10:10:08 +03:00
|
|
|
#include "nsStyleCoord.h"
|
2001-08-10 00:22:39 +04:00
|
|
|
#include "nsSize.h"
|
2016-07-21 13:36:34 +03:00
|
|
|
#include "mozilla/ReflowInput.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2002-02-17 22:32:08 +03:00
|
|
|
#include "nsComponentManagerUtils.h"
|
2017-08-17 08:29:03 +03:00
|
|
|
#include "nsString.h"
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2001-09-29 12:28:41 +04:00
|
|
|
#include "nsReadableUtils.h"
|
2001-12-16 14:58:03 +03:00
|
|
|
#include "nsUnicharUtils.h"
|
2002-02-08 18:21:26 +03:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2011-12-16 13:18:48 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2000-03-09 04:06:56 +03:00
|
|
|
|
|
|
|
// Interfaces needed to be included
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2001-01-23 03:47:02 +03:00
|
|
|
#include "nsITooltipListener.h"
|
2018-05-30 05:58:48 +03:00
|
|
|
#include "nsINode.h"
|
2010-03-13 13:32:19 +03:00
|
|
|
#include "Link.h"
|
2012-11-15 02:10:07 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2018-03-20 07:16:05 +03:00
|
|
|
#include "mozilla/dom/MouseEvent.h"
|
2013-01-08 07:22:41 +04:00
|
|
|
#include "mozilla/dom/SVGTitleElement.h"
|
2010-05-12 11:17:07 +04:00
|
|
|
#include "nsIFormControl.h"
|
2006-09-09 08:28:22 +04:00
|
|
|
#include "nsIImageLoadingContent.h"
|
2002-02-17 22:32:08 +03:00
|
|
|
#include "nsIWebNavigation.h"
|
2000-03-14 10:10:08 +03:00
|
|
|
#include "nsIPresShell.h"
|
2016-03-17 02:07:51 +03:00
|
|
|
#include "nsIStringBundle.h"
|
2000-12-02 01:13:45 +03:00
|
|
|
#include "nsPIDOMWindow.h"
|
2010-02-20 19:07:03 +03:00
|
|
|
#include "nsPIWindowRoot.h"
|
2001-02-07 08:02:06 +03:00
|
|
|
#include "nsIWindowWatcher.h"
|
|
|
|
#include "nsPIWindowWatcher.h"
|
2001-04-10 22:30:25 +04:00
|
|
|
#include "nsIPrompt.h"
|
2015-10-01 20:06:51 +03:00
|
|
|
#include "nsITabParent.h"
|
2016-05-11 12:44:57 +03:00
|
|
|
#include "nsITabChild.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsRect.h"
|
2001-04-25 06:04:56 +04:00
|
|
|
#include "nsIWebBrowserChromeFocus.h"
|
2002-05-29 00:31:39 +04:00
|
|
|
#include "nsIContent.h"
|
2002-09-16 04:13:37 +04:00
|
|
|
#include "imgIContainer.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2013-01-03 17:23:11 +04:00
|
|
|
#include "nsView.h"
|
2010-08-27 09:46:17 +04:00
|
|
|
#include "nsIConstraintValidation.h"
|
2012-07-11 07:58:57 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-03-17 10:56:53 +04:00
|
|
|
#include "mozilla/EventListenerManager.h"
|
2018-03-17 05:25:25 +03:00
|
|
|
#include "mozilla/dom/DragEvent.h"
|
2018-04-20 07:49:29 +03:00
|
|
|
#include "mozilla/dom/Event.h" // for Event
|
2016-03-17 02:07:51 +03:00
|
|
|
#include "mozilla/dom/File.h" // for input type=file
|
|
|
|
#include "mozilla/dom/FileList.h" // for input type=file
|
2017-01-19 21:57:11 +03:00
|
|
|
#include "mozilla/TextEvents.h"
|
2001-02-07 08:02:06 +03:00
|
|
|
|
2011-12-16 13:18:48 +04:00
|
|
|
using namespace mozilla;
|
2013-04-22 05:25:28 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-12-16 13:18:48 +04:00
|
|
|
|
2002-02-17 22:32:08 +03:00
|
|
|
// A helper routine that navigates the tricky path from a |nsWebBrowser| to
|
2013-04-22 05:25:28 +04:00
|
|
|
// a |EventTarget| via the window root and chrome event handler.
|
2002-02-17 22:32:08 +03:00
|
|
|
static nsresult
|
2015-05-11 22:35:13 +03:00
|
|
|
GetDOMEventTarget(nsWebBrowser* aInBrowser, EventTarget** aTarget)
|
2002-02-17 22:32:08 +03:00
|
|
|
{
|
2015-07-21 06:16:27 +03:00
|
|
|
if (!aInBrowser) {
|
|
|
|
return NS_ERROR_INVALID_POINTER;
|
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
2015-05-11 22:35:13 +03:00
|
|
|
aInBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
2015-07-21 06:16:27 +03:00
|
|
|
if (!domWindow) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2002-02-17 22:32:08 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
auto* outerWindow = nsPIDOMWindowOuter::From(domWindow);
|
|
|
|
nsPIDOMWindowOuter* rootWindow = outerWindow->GetPrivateRoot();
|
2002-02-17 22:32:08 +03:00
|
|
|
NS_ENSURE_TRUE(rootWindow, NS_ERROR_FAILURE);
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<EventTarget> target = rootWindow->GetChromeEventHandler();
|
2011-06-24 06:18:01 +04:00
|
|
|
NS_ENSURE_TRUE(target, NS_ERROR_FAILURE);
|
|
|
|
target.forget(aTarget);
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2002-02-17 22:32:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDocShellTreeOwner::nsDocShellTreeOwner()
|
|
|
|
: mWebBrowser(nullptr)
|
|
|
|
, mTreeOwner(nullptr)
|
|
|
|
, mPrimaryContentShell(nullptr)
|
|
|
|
, mWebBrowserChrome(nullptr)
|
|
|
|
, mOwnerWin(nullptr)
|
|
|
|
, mOwnerRequestor(nullptr)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDocShellTreeOwner::~nsDocShellTreeOwner()
|
|
|
|
{
|
2001-03-30 08:45:40 +04:00
|
|
|
RemoveChromeListeners();
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsDocShellTreeOwner)
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMPL_RELEASE(nsDocShellTreeOwner)
|
2001-02-02 15:52:44 +03:00
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDocShellTreeOwner)
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2000-03-09 04:06:56 +03:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsDocShellTreeOwner::nsIInterfaceRequestor
|
2014-12-16 20:18:01 +03:00
|
|
|
//*****************************************************************************
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2001-04-21 06:42:14 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aSink);
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (NS_SUCCEEDED(QueryInterface(aIID, aSink))) {
|
2001-04-21 06:42:14 +04:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2005-02-05 02:32:32 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChromeFocus))) {
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mWebBrowserChromeWeak != nullptr) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return mWebBrowserChromeWeak->QueryReferent(aIID, aSink);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-25 06:04:56 +04:00
|
|
|
return mOwnerWin->QueryInterface(aIID, aSink);
|
2005-02-05 02:32:32 +03:00
|
|
|
}
|
2001-04-25 06:04:56 +04:00
|
|
|
|
2001-04-21 06:42:14 +04:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIPrompt))) {
|
2014-12-16 20:18:01 +03:00
|
|
|
nsCOMPtr<nsIPrompt> prompt;
|
2001-04-21 06:42:14 +04:00
|
|
|
EnsurePrompter();
|
|
|
|
prompt = mPrompter;
|
|
|
|
if (prompt) {
|
2014-12-16 20:18:01 +03:00
|
|
|
prompt.forget(aSink);
|
2000-03-14 10:10:08 +03:00
|
|
|
return NS_OK;
|
2001-04-21 06:42:14 +04:00
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2001-04-21 06:42:14 +04:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
|
2014-12-16 20:18:01 +03:00
|
|
|
nsCOMPtr<nsIAuthPrompt> prompt;
|
2001-04-21 06:42:14 +04:00
|
|
|
EnsureAuthPrompter();
|
|
|
|
prompt = mAuthPrompter;
|
|
|
|
if (prompt) {
|
2014-12-16 20:18:01 +03:00
|
|
|
prompt.forget(aSink);
|
2001-04-21 06:42:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req = GetOwnerRequestor();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (req) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return req->GetInterface(aIID, aSink);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2001-04-21 06:42:14 +04:00
|
|
|
return NS_NOINTERFACE;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsDocShellTreeOwner::nsIDocShellTreeOwner
|
2014-12-16 20:18:01 +03:00
|
|
|
//*****************************************************************************
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::EnsurePrompter()
|
2001-04-21 06:42:14 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mPrompter) {
|
2001-04-21 06:42:14 +04:00
|
|
|
return;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2002-08-06 10:20:45 +04:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
2001-04-21 06:42:14 +04:00
|
|
|
if (wwatch && mWebBrowser) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
2001-04-21 06:42:14 +04:00
|
|
|
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
2015-05-11 22:35:13 +03:00
|
|
|
if (domWindow) {
|
2001-04-21 06:42:14 +04:00
|
|
|
wwatch->GetNewPrompter(domWindow, getter_AddRefs(mPrompter));
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::EnsureAuthPrompter()
|
2001-04-21 06:42:14 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mAuthPrompter) {
|
2001-04-21 06:42:14 +04:00
|
|
|
return;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2002-08-06 10:20:45 +04:00
|
|
|
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
2001-04-21 06:42:14 +04:00
|
|
|
if (wwatch && mWebBrowser) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
2001-04-21 06:42:14 +04:00
|
|
|
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
2015-05-11 22:35:13 +03:00
|
|
|
if (domWindow) {
|
2001-04-21 06:42:14 +04:00
|
|
|
wwatch->GetNewAuthPrompter(domWindow, getter_AddRefs(mAuthPrompter));
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::AddToWatcher()
|
|
|
|
{
|
2001-02-07 08:02:06 +03:00
|
|
|
if (mWebBrowser) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
2001-02-07 08:02:06 +03:00
|
|
|
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (domWindow) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsPIWindowWatcher> wwatch(
|
|
|
|
do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
2005-02-05 02:32:32 +03:00
|
|
|
if (wwatch) {
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (webBrowserChrome) {
|
2005-02-05 02:32:32 +03:00
|
|
|
wwatch->AddWindow(domWindow, webBrowserChrome);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2005-02-05 02:32:32 +03:00
|
|
|
}
|
2001-02-07 08:02:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-15 07:32:16 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::RemoveFromWatcher()
|
|
|
|
{
|
2001-02-07 08:02:06 +03:00
|
|
|
if (mWebBrowser) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> domWindow;
|
2001-02-07 08:02:06 +03:00
|
|
|
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (domWindow) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsPIWindowWatcher> wwatch(
|
|
|
|
do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
|
|
|
if (wwatch) {
|
2001-02-07 08:02:06 +03:00
|
|
|
wwatch->RemoveWindow(domWindow);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-02-07 08:02:06 +03:00
|
|
|
}
|
|
|
|
}
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2015-11-12 08:08:28 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::EnsureContentTreeOwner()
|
|
|
|
{
|
|
|
|
if (mContentTreeOwner) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mContentTreeOwner = new nsDocShellTreeOwner();
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
|
|
|
|
if (browserChrome) {
|
|
|
|
mContentTreeOwner->SetWebBrowserChrome(browserChrome);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mWebBrowser) {
|
|
|
|
mContentTreeOwner->WebBrowser(mWebBrowser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
|
2016-12-09 00:12:36 +03:00
|
|
|
bool aPrimary)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mTreeOwner)
|
2016-12-09 00:12:36 +03:00
|
|
|
return mTreeOwner->ContentShellAdded(aContentShell, aPrimary);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-11-12 08:08:28 +03:00
|
|
|
EnsureContentTreeOwner();
|
|
|
|
aContentShell->SetTreeOwner(mContentTreeOwner);
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (aPrimary) {
|
|
|
|
mPrimaryContentShell = aContentShell;
|
2015-10-01 20:06:51 +03:00
|
|
|
mPrimaryTabParent = nullptr;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2007-10-06 03:37:25 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
|
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mTreeOwner) {
|
2007-10-06 03:37:25 +04:00
|
|
|
return mTreeOwner->ContentShellRemoved(aContentShell);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2007-10-06 03:37:25 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mPrimaryContentShell == aContentShell) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mPrimaryContentShell = nullptr;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2007-10-06 03:37:25 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aShell);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mTreeOwner) {
|
|
|
|
return mTreeOwner->GetPrimaryContentShell(aShell);
|
|
|
|
}
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> shell;
|
2015-10-01 20:06:51 +03:00
|
|
|
if (!mPrimaryTabParent) {
|
|
|
|
shell =
|
|
|
|
mPrimaryContentShell ? mPrimaryContentShell : mWebBrowser->mDocShell;
|
|
|
|
}
|
2015-05-11 22:35:13 +03:00
|
|
|
shell.forget(aShell);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_OK;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2015-10-01 20:06:51 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::TabParentAdded(nsITabParent* aTab, bool aPrimary)
|
|
|
|
{
|
|
|
|
if (mTreeOwner) {
|
|
|
|
return mTreeOwner->TabParentAdded(aTab, aPrimary);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPrimary) {
|
|
|
|
mPrimaryTabParent = aTab;
|
|
|
|
mPrimaryContentShell = nullptr;
|
|
|
|
} else if (mPrimaryTabParent == aTab) {
|
|
|
|
mPrimaryTabParent = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::TabParentRemoved(nsITabParent* aTab)
|
|
|
|
{
|
|
|
|
if (mTreeOwner) {
|
|
|
|
return mTreeOwner->TabParentRemoved(aTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTab == mPrimaryTabParent) {
|
|
|
|
mPrimaryTabParent = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetPrimaryTabParent(nsITabParent** aTab)
|
|
|
|
{
|
|
|
|
if (mTreeOwner) {
|
|
|
|
return mTreeOwner->GetPrimaryTabParent(aTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsITabParent> tab = mPrimaryTabParent;
|
|
|
|
tab.forget(aTab);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:31:41 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetPrimaryContentSize(int32_t* aWidth,
|
|
|
|
int32_t* aHeight)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetPrimaryContentSize(int32_t aWidth,
|
|
|
|
int32_t aHeight)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetRootShellSize(int32_t* aWidth,
|
|
|
|
int32_t* aHeight)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetRootShellSize(int32_t aWidth,
|
|
|
|
int32_t aHeight)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCX, int32_t aCY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
2005-02-05 02:32:32 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_ENSURE_STATE(mTreeOwner || webBrowserChrome);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mTreeOwner) {
|
|
|
|
return mTreeOwner->SizeShellTo(aShellItem, aCX, aCY);
|
|
|
|
}
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (aShellItem == mWebBrowser->mDocShell) {
|
2016-05-11 12:44:57 +03:00
|
|
|
nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(webBrowserChrome);
|
|
|
|
if (tabChild) {
|
|
|
|
// The XUL window to resize is in the parent process, but there we
|
|
|
|
// won't be able to get aShellItem to do the hack in nsXULWindow::SizeShellTo,
|
|
|
|
// so let's send the width and height of aShellItem too.
|
|
|
|
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(aShellItem));
|
|
|
|
NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
int32_t width = 0;
|
|
|
|
int32_t height = 0;
|
|
|
|
shellAsWin->GetSize(&width, &height);
|
|
|
|
return tabChild->RemoteSizeShellTo(aCX, aCY, width, height);
|
|
|
|
}
|
2018-09-26 12:39:44 +03:00
|
|
|
// XXX: this is weird, but we used to call a method here
|
|
|
|
// (webBrowserChrome->SizeBrowserTo()) whose implementations all failed
|
|
|
|
// like this, so...
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2018-01-31 23:18:10 +03:00
|
|
|
NS_ENSURE_TRUE(aShellItem, NS_ERROR_FAILURE);
|
2000-03-15 07:32:16 +03:00
|
|
|
|
2018-01-31 23:18:10 +03:00
|
|
|
nsCOMPtr<nsIDocument> document = aShellItem->GetDocument();
|
|
|
|
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
2000-03-15 07:32:16 +03:00
|
|
|
|
2018-01-31 23:18:10 +03:00
|
|
|
NS_ENSURE_TRUE(document->GetDocumentElement(), NS_ERROR_FAILURE);
|
2000-03-15 07:32:16 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// Set the preferred Size
|
|
|
|
//XXX
|
|
|
|
NS_ERROR("Implement this");
|
|
|
|
/*
|
|
|
|
Set the preferred size on the aShellItem.
|
|
|
|
*/
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPresContext> presContext;
|
2015-05-11 22:35:13 +03:00
|
|
|
mWebBrowser->mDocShell->GetPresContext(getter_AddRefs(presContext));
|
|
|
|
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsIPresShell* presShell = presContext->GetPresShell();
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_ENSURE_SUCCESS(
|
|
|
|
presShell->ResizeReflow(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
|
|
|
NS_ERROR_FAILURE);
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2018-09-26 12:39:44 +03:00
|
|
|
// XXX: this is weird, but we used to call a method here
|
|
|
|
// (webBrowserChrome->SizeBrowserTo()) whose implementations all failed like
|
|
|
|
// this, so...
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2001-03-09 05:04:06 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::SetPersistence(bool aPersistPosition,
|
|
|
|
bool aPersistSize,
|
|
|
|
bool aPersistSizeMode)
|
2001-03-09 05:04:06 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::GetPersistence(bool* aPersistPosition,
|
|
|
|
bool* aPersistSize,
|
|
|
|
bool* aPersistSizeMode)
|
2001-03-09 05:04:06 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2001-02-02 15:52:44 +03:00
|
|
|
|
2011-04-15 01:27:53 +04:00
|
|
|
NS_IMETHODIMP
|
2016-12-09 05:41:45 +03:00
|
|
|
nsDocShellTreeOwner::GetTabCount(uint32_t* aResult)
|
2011-04-15 01:27:53 +04:00
|
|
|
{
|
2014-12-16 20:18:01 +03:00
|
|
|
if (mTreeOwner) {
|
2016-12-09 05:41:45 +03:00
|
|
|
return mTreeOwner->GetTabCount(aResult);
|
2011-04-15 01:27:53 +04:00
|
|
|
}
|
|
|
|
|
2016-12-09 05:41:45 +03:00
|
|
|
*aResult = 0;
|
2011-04-15 01:27:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-14 23:31:41 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetHasPrimaryContent(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mPrimaryTabParent || mPrimaryContentShell;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsDocShellTreeOwner::nsIBaseWindow
|
2014-12-16 20:18:01 +03:00
|
|
|
//*****************************************************************************
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
|
2012-08-22 19:56:38 +04:00
|
|
|
nsIWidget* aParentWidget, int32_t aX,
|
2014-12-16 20:18:01 +03:00
|
|
|
int32_t aY, int32_t aCX, int32_t aCY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::Create()
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::Destroy()
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (webBrowserChrome) {
|
2018-09-26 12:39:44 +03:00
|
|
|
// XXX: this is weird, but we used to call a method here
|
|
|
|
// (webBrowserChrome->DestroyBrowserWindow()) whose implementations all
|
|
|
|
// failed like this, so...
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2012-10-16 23:41:19 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDocShellTreeOwner::GetUnscaledDevicePixelsPerCSSPixel(double* aScale)
|
2012-10-16 23:41:19 +04:00
|
|
|
{
|
|
|
|
if (mWebBrowser) {
|
|
|
|
return mWebBrowser->GetUnscaledDevicePixelsPerCSSPixel(aScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aScale = 1.0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-11-25 22:12:07 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetDevicePixelsPerDesktopPixel(double* aScale)
|
|
|
|
{
|
|
|
|
if (mWebBrowser) {
|
|
|
|
return mWebBrowser->GetDevicePixelsPerDesktopPixel(aScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aScale = 1.0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-02-18 13:46:16 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY)
|
|
|
|
{
|
2016-03-02 15:15:19 +03:00
|
|
|
if (mWebBrowser) {
|
2016-05-11 12:44:57 +03:00
|
|
|
nsresult rv = mWebBrowser->SetPositionDesktopPix(aX, aY);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-03-02 15:15:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
double scale = 1.0;
|
|
|
|
GetDevicePixelsPerDesktopPixel(&scale);
|
|
|
|
return SetPosition(NSToIntRound(aX * scale), NSToIntRound(aY * scale));
|
2016-02-18 13:46:16 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::SetPosition(int32_t aX, int32_t aY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
|
|
|
|
aX, aY, 0, 0);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::GetPosition(int32_t* aX, int32_t* aY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
|
2012-07-30 18:20:58 +04:00
|
|
|
aX, aY, nullptr, nullptr);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->SetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
|
|
|
|
0, 0, aCX, aCY);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::GetSize(int32_t* aCX, int32_t* aCY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->GetDimensions(nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, nullptr, aCX, aCY);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX,
|
2016-05-12 03:07:45 +03:00
|
|
|
int32_t aCY, uint32_t aFlags)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
|
|
|
return ownerWin->SetDimensions(
|
|
|
|
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
|
|
|
|
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
|
|
|
|
aX, aY, aCX, aCY);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDocShellTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aCX,
|
|
|
|
int32_t* aCY)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
|
|
|
return ownerWin->GetDimensions(
|
|
|
|
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER |
|
|
|
|
nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION,
|
|
|
|
aX, aY, aCX, aCY);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::Repaint(bool aForce)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetParentWidget(nsIWidget** aParentWidget)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetParentWidget(nsIWidget* aParentWidget)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->GetSiteWindow(aParentNativeWindow);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2012-07-25 05:35:32 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetNativeHandle(nsAString& aNativeHandle)
|
|
|
|
{
|
|
|
|
// the nativeHandle should be accessed from nsIXULWindow
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::GetVisibility(bool* aVisibility)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->GetVisibility(aVisibility);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::SetVisibility(bool aVisibility)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->SetVisibility(aVisibility);
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDocShellTreeOwner::GetEnabled(bool* aEnabled)
|
2002-03-01 02:22:55 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEnabled);
|
2011-10-17 18:59:28 +04:00
|
|
|
*aEnabled = true;
|
2002-03-01 02:22:55 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsDocShellTreeOwner::SetEnabled(bool aEnabled)
|
2002-03-01 02:22:55 +03:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::GetMainWidget(nsIWidget** aMainWidget)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetFocus()
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->SetFocus();
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2017-09-25 06:10:51 +03:00
|
|
|
nsDocShellTreeOwner::GetTitle(nsAString& aTitle)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->GetTitle(aTitle);
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
2017-09-25 06:10:51 +03:00
|
|
|
nsDocShellTreeOwner::SetTitle(const nsAString& aTitle)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin = GetOwnerWin();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (ownerWin) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return ownerWin->SetTitle(aTitle);
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-03-14 10:10:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsDocShellTreeOwner::nsIWebProgressListener
|
2014-12-16 20:18:01 +03:00
|
|
|
//*****************************************************************************
|
2000-03-14 10:10:08 +03:00
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::OnProgressChange(nsIWebProgress* aProgress,
|
|
|
|
nsIRequest* aRequest,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCurSelfProgress,
|
2014-12-16 20:18:01 +03:00
|
|
|
int32_t aMaxSelfProgress,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aCurTotalProgress,
|
|
|
|
int32_t aMaxTotalProgress)
|
2000-03-14 10:10:08 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
// In the absence of DOM document creation event, this method is the
|
|
|
|
// most convenient place to install the mouse listener on the
|
|
|
|
// DOM document.
|
|
|
|
return AddChromeListeners();
|
2000-03-14 10:10:08 +03:00
|
|
|
}
|
|
|
|
|
2000-06-19 09:54:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::OnStateChange(nsIWebProgress* aProgress,
|
|
|
|
nsIRequest* aRequest,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aProgressStateFlags,
|
2000-06-19 09:54:37 +04:00
|
|
|
nsresult aStatus)
|
2000-03-14 10:10:08 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_OK;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
2011-11-10 18:01:11 +04:00
|
|
|
nsIURI* aURI,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
2000-03-25 04:00:05 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_OK;
|
2000-07-25 09:45:56 +04:00
|
|
|
}
|
|
|
|
|
2014-12-16 20:18:01 +03:00
|
|
|
NS_IMETHODIMP
|
2000-07-25 09:45:56 +04:00
|
|
|
nsDocShellTreeOwner::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aMessage)
|
2000-07-25 09:45:56 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_OK;
|
2000-03-25 04:00:05 +03:00
|
|
|
}
|
|
|
|
|
2014-12-16 20:18:01 +03:00
|
|
|
NS_IMETHODIMP
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDocShellTreeOwner::OnSecurityChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
2018-09-23 03:29:07 +03:00
|
|
|
uint32_t aOldState,
|
|
|
|
uint32_t aState,
|
|
|
|
const nsAString& aContentBlockingLogJSON)
|
2000-09-15 02:56:56 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return NS_OK;
|
2000-09-15 02:56:56 +04:00
|
|
|
}
|
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
//*****************************************************************************
|
|
|
|
// nsDocShellTreeOwner: Accessors
|
2014-12-16 20:18:01 +03:00
|
|
|
//*****************************************************************************
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
void
|
|
|
|
nsDocShellTreeOwner::WebBrowser(nsWebBrowser* aWebBrowser)
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!aWebBrowser) {
|
2001-03-30 08:45:40 +04:00
|
|
|
RemoveChromeListeners();
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-04-21 06:42:14 +04:00
|
|
|
if (aWebBrowser != mWebBrowser) {
|
2014-12-16 20:18:01 +03:00
|
|
|
mPrompter = nullptr;
|
|
|
|
mAuthPrompter = nullptr;
|
2001-04-21 06:42:14 +04:00
|
|
|
}
|
2001-03-30 08:45:40 +04:00
|
|
|
|
2001-02-07 08:02:06 +03:00
|
|
|
mWebBrowser = aWebBrowser;
|
2015-11-12 08:08:28 +03:00
|
|
|
|
|
|
|
if (mContentTreeOwner) {
|
|
|
|
mContentTreeOwner->WebBrowser(aWebBrowser);
|
|
|
|
if (!aWebBrowser) {
|
|
|
|
mContentTreeOwner = nullptr;
|
|
|
|
}
|
|
|
|
}
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsWebBrowser*
|
2003-11-19 04:20:56 +03:00
|
|
|
nsDocShellTreeOwner::WebBrowser()
|
2000-03-09 04:06:56 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
return mWebBrowser;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner)
|
2014-12-16 20:18:01 +03:00
|
|
|
{
|
2014-12-16 20:18:01 +03:00
|
|
|
if (aTreeOwner) {
|
2003-11-19 04:20:56 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome(do_GetInterface(aTreeOwner));
|
|
|
|
NS_ENSURE_TRUE(webBrowserChrome, NS_ERROR_INVALID_ARG);
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_ENSURE_SUCCESS(SetWebBrowserChrome(webBrowserChrome),
|
|
|
|
NS_ERROR_INVALID_ARG);
|
2003-11-19 04:20:56 +03:00
|
|
|
mTreeOwner = aTreeOwner;
|
2014-12-16 20:18:01 +03:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
mTreeOwner = nullptr;
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!webBrowserChrome) {
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_SUCCESS(SetWebBrowserChrome(nullptr), NS_ERROR_FAILURE);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
2000-03-11 04:10:13 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_OK;
|
2000-03-09 04:06:56 +03:00
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDocShellTreeOwner::SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome)
|
|
|
|
{
|
2014-12-16 20:18:01 +03:00
|
|
|
if (!aWebBrowserChrome) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mWebBrowserChrome = nullptr;
|
|
|
|
mOwnerWin = nullptr;
|
|
|
|
mOwnerRequestor = nullptr;
|
2014-12-16 20:18:01 +03:00
|
|
|
mWebBrowserChromeWeak = nullptr;
|
2003-11-19 04:20:56 +03:00
|
|
|
} else {
|
2005-02-05 02:32:32 +03:00
|
|
|
nsCOMPtr<nsISupportsWeakReference> supportsweak =
|
2015-05-11 22:35:13 +03:00
|
|
|
do_QueryInterface(aWebBrowserChrome);
|
2005-02-05 02:32:32 +03:00
|
|
|
if (supportsweak) {
|
|
|
|
supportsweak->GetWeakReference(getter_AddRefs(mWebBrowserChromeWeak));
|
|
|
|
} else {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> ownerWin(
|
|
|
|
do_QueryInterface(aWebBrowserChrome));
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> requestor(
|
|
|
|
do_QueryInterface(aWebBrowserChrome));
|
2005-02-05 02:32:32 +03:00
|
|
|
|
|
|
|
// it's ok for ownerWin or requestor to be null.
|
|
|
|
mWebBrowserChrome = aWebBrowserChrome;
|
|
|
|
mOwnerWin = ownerWin;
|
|
|
|
mOwnerRequestor = requestor;
|
|
|
|
}
|
2003-11-19 04:20:56 +03:00
|
|
|
}
|
2015-11-12 08:08:28 +03:00
|
|
|
|
|
|
|
if (mContentTreeOwner) {
|
|
|
|
mContentTreeOwner->SetWebBrowserChrome(aWebBrowserChrome);
|
|
|
|
}
|
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
return NS_OK;
|
2000-03-11 04:10:13 +03:00
|
|
|
}
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// Hook up things to the chrome like context menus and tooltips, if the chrome
|
|
|
|
// has implemented the right interfaces.
|
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
nsDocShellTreeOwner::AddChromeListeners()
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2005-02-05 02:32:32 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!webBrowserChrome) {
|
2005-02-05 02:32:32 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2005-02-05 02:32:32 +03:00
|
|
|
|
2001-03-30 08:45:40 +04:00
|
|
|
// install tooltips
|
2014-12-16 20:18:01 +03:00
|
|
|
if (!mChromeTooltipListener) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsITooltipListener> tooltipListener(
|
|
|
|
do_QueryInterface(webBrowserChrome));
|
2014-12-16 20:18:01 +03:00
|
|
|
if (tooltipListener) {
|
2005-02-05 02:32:32 +03:00
|
|
|
mChromeTooltipListener = new ChromeTooltipListener(mWebBrowser,
|
|
|
|
webBrowserChrome);
|
2014-12-16 20:18:01 +03:00
|
|
|
rv = mChromeTooltipListener->AddChromeListeners();
|
2001-03-30 08:45:40 +04:00
|
|
|
}
|
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2010-04-18 22:27:18 +04:00
|
|
|
// register dragover and drop event listeners with the listener manager
|
2013-04-22 05:25:28 +04:00
|
|
|
nsCOMPtr<EventTarget> target;
|
2011-06-24 06:18:01 +04:00
|
|
|
GetDOMEventTarget(mWebBrowser, getter_AddRefs(target));
|
2010-04-18 22:27:18 +04:00
|
|
|
|
2014-03-17 10:56:53 +04:00
|
|
|
EventListenerManager* elmP = target->GetOrCreateListenerManager();
|
2011-08-18 13:45:00 +04:00
|
|
|
if (elmP) {
|
|
|
|
elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"),
|
2014-03-17 10:56:52 +04:00
|
|
|
TrustedEventsAtSystemGroupBubble());
|
2011-08-18 13:45:00 +04:00
|
|
|
elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"),
|
2014-03-17 10:56:52 +04:00
|
|
|
TrustedEventsAtSystemGroupBubble());
|
2002-02-17 22:32:08 +03:00
|
|
|
}
|
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
return rv;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2001-03-30 08:45:40 +04:00
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
nsDocShellTreeOwner::RemoveChromeListeners()
|
2001-03-30 08:45:40 +04:00
|
|
|
{
|
2014-12-16 20:18:01 +03:00
|
|
|
if (mChromeTooltipListener) {
|
2001-03-30 08:45:40 +04:00
|
|
|
mChromeTooltipListener->RemoveChromeListeners();
|
2014-12-16 20:18:01 +03:00
|
|
|
mChromeTooltipListener = nullptr;
|
2001-03-30 08:45:40 +04:00
|
|
|
}
|
2010-04-18 22:27:18 +04:00
|
|
|
|
2013-04-22 05:25:28 +04:00
|
|
|
nsCOMPtr<EventTarget> piTarget;
|
2011-06-24 06:18:01 +04:00
|
|
|
GetDOMEventTarget(mWebBrowser, getter_AddRefs(piTarget));
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!piTarget) {
|
2010-06-30 04:06:28 +04:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2010-04-18 22:27:18 +04:00
|
|
|
|
2014-03-17 10:56:53 +04:00
|
|
|
EventListenerManager* elmP = piTarget->GetOrCreateListenerManager();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (elmP) {
|
2011-06-24 06:18:02 +04:00
|
|
|
elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("dragover"),
|
2014-03-17 10:56:52 +04:00
|
|
|
TrustedEventsAtSystemGroupBubble());
|
2011-06-24 06:18:02 +04:00
|
|
|
elmP->RemoveEventListenerByType(this, NS_LITERAL_STRING("drop"),
|
2014-03-17 10:56:52 +04:00
|
|
|
TrustedEventsAtSystemGroupBubble());
|
2010-04-18 22:27:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2018-04-20 07:49:29 +03:00
|
|
|
nsDocShellTreeOwner::HandleEvent(Event* aEvent)
|
2010-04-18 22:27:18 +04:00
|
|
|
{
|
2018-04-20 07:49:30 +03:00
|
|
|
DragEvent* dragEvent = aEvent ? aEvent->AsDragEvent() : nullptr;
|
2018-03-17 05:25:25 +03:00
|
|
|
if (NS_WARN_IF(!dragEvent)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2010-04-18 22:27:18 +04:00
|
|
|
|
2018-03-17 05:25:25 +03:00
|
|
|
if (dragEvent->DefaultPrevented()) {
|
2012-08-04 11:44:00 +04:00
|
|
|
return NS_OK;
|
2010-04-18 22:27:18 +04:00
|
|
|
}
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsIDroppedLinkHandler> handler =
|
|
|
|
do_GetService("@mozilla.org/content/dropped-link-handler;1");
|
2018-02-28 04:36:44 +03:00
|
|
|
if (!handler) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
|
|
|
if (eventType.EqualsLiteral("dragover")) {
|
|
|
|
bool canDropLink = false;
|
|
|
|
handler->CanDropLink(dragEvent, false, &canDropLink);
|
|
|
|
if (canDropLink) {
|
|
|
|
aEvent->PreventDefault();
|
|
|
|
}
|
|
|
|
} else if (eventType.EqualsLiteral("drop")) {
|
|
|
|
nsIWebNavigation* webnav = static_cast<nsIWebNavigation*>(mWebBrowser);
|
|
|
|
|
|
|
|
uint32_t linksCount;
|
|
|
|
nsIDroppedLinkItem** links;
|
|
|
|
if (webnav &&
|
|
|
|
NS_SUCCEEDED(handler->DropLinks(dragEvent, true, &linksCount, &links))) {
|
|
|
|
if (linksCount >= 1) {
|
|
|
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
|
|
|
handler->GetTriggeringPrincipal(dragEvent,
|
|
|
|
getter_AddRefs(triggeringPrincipal));
|
|
|
|
if (triggeringPrincipal) {
|
2015-11-11 01:35:12 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome = GetWebBrowserChrome();
|
|
|
|
if (webBrowserChrome) {
|
|
|
|
nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(webBrowserChrome);
|
|
|
|
if (tabChild) {
|
2017-06-07 15:25:46 +03:00
|
|
|
nsresult rv = tabChild->RemoteDropLinks(linksCount, links);
|
2015-11-11 01:35:12 +03:00
|
|
|
for (uint32_t i = 0; i < linksCount; i++) {
|
|
|
|
NS_RELEASE(links[i]);
|
|
|
|
}
|
|
|
|
free(links);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsAutoString url;
|
|
|
|
if (NS_SUCCEEDED(links[0]->GetUrl(url))) {
|
|
|
|
if (!url.IsEmpty()) {
|
2018-11-05 17:03:28 +03:00
|
|
|
#ifndef ANDROID
|
|
|
|
MOZ_ASSERT(triggeringPrincipal, "nsDocShellTreeOwner::HandleEvent: Need a valid triggeringPrincipal");
|
|
|
|
#endif
|
2018-09-05 06:42:16 +03:00
|
|
|
webnav->LoadURI(url, 0, nullptr, nullptr, nullptr,
|
2018-02-28 04:36:44 +03:00
|
|
|
triggeringPrincipal);
|
2015-11-11 01:35:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < linksCount; i++) {
|
|
|
|
NS_RELEASE(links[i]);
|
|
|
|
}
|
|
|
|
free(links);
|
2010-04-18 22:27:18 +04:00
|
|
|
}
|
|
|
|
}
|
2018-02-28 04:36:44 +03:00
|
|
|
} else {
|
|
|
|
aEvent->StopPropagation();
|
|
|
|
aEvent->PreventDefault();
|
2010-04-18 22:27:18 +04:00
|
|
|
}
|
|
|
|
}
|
2002-02-17 22:32:08 +03:00
|
|
|
|
2001-03-30 08:45:40 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-05 02:32:32 +03:00
|
|
|
already_AddRefed<nsIWebBrowserChrome>
|
|
|
|
nsDocShellTreeOwner::GetWebBrowserChrome()
|
|
|
|
{
|
2011-07-15 14:32:40 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
|
|
|
if (mWebBrowserChromeWeak) {
|
|
|
|
chrome = do_QueryReferent(mWebBrowserChromeWeak);
|
2005-02-05 02:32:32 +03:00
|
|
|
} else if (mWebBrowserChrome) {
|
|
|
|
chrome = mWebBrowserChrome;
|
|
|
|
}
|
2011-07-15 14:32:40 +04:00
|
|
|
return chrome.forget();
|
2005-02-05 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIEmbeddingSiteWindow>
|
|
|
|
nsDocShellTreeOwner::GetOwnerWin()
|
|
|
|
{
|
2011-07-15 14:32:40 +04:00
|
|
|
nsCOMPtr<nsIEmbeddingSiteWindow> win;
|
|
|
|
if (mWebBrowserChromeWeak) {
|
|
|
|
win = do_QueryReferent(mWebBrowserChromeWeak);
|
2005-02-05 02:32:32 +03:00
|
|
|
} else if (mOwnerWin) {
|
|
|
|
win = mOwnerWin;
|
|
|
|
}
|
2011-07-15 14:32:40 +04:00
|
|
|
return win.forget();
|
2005-02-05 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsIInterfaceRequestor>
|
|
|
|
nsDocShellTreeOwner::GetOwnerRequestor()
|
|
|
|
{
|
2011-07-15 14:32:40 +04:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> req;
|
|
|
|
if (mWebBrowserChromeWeak) {
|
|
|
|
req = do_QueryReferent(mWebBrowserChromeWeak);
|
2005-02-05 02:32:32 +03:00
|
|
|
} else if (mOwnerRequestor) {
|
|
|
|
req = mOwnerRequestor;
|
|
|
|
}
|
2011-07-15 14:32:40 +04:00
|
|
|
return req.forget();
|
2005-02-05 02:32:32 +03:00
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ChromeTooltipListener, nsIDOMEventListener)
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
ChromeTooltipListener::ChromeTooltipListener(nsWebBrowser* aInBrowser,
|
|
|
|
nsIWebBrowserChrome* aInChrome)
|
|
|
|
: mWebBrowser(aInBrowser)
|
|
|
|
, mWebBrowserChrome(aInChrome)
|
|
|
|
, mTooltipListenerInstalled(false)
|
|
|
|
, mMouseClientX(0)
|
|
|
|
, mMouseClientY(0)
|
2016-07-26 09:05:00 +03:00
|
|
|
, mMouseScreenX(0)
|
|
|
|
, mMouseScreenY(0)
|
2015-05-11 22:35:13 +03:00
|
|
|
, mShowingTooltip(false)
|
|
|
|
, mTooltipShownOnce(false)
|
2000-08-16 12:51:58 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
ChromeTooltipListener::~ChromeTooltipListener()
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-03-30 08:45:40 +04:00
|
|
|
|
2018-05-31 01:57:59 +03:00
|
|
|
nsITooltipTextProvider*
|
|
|
|
ChromeTooltipListener::GetTooltipTextProvider() {
|
|
|
|
if (!mTooltipTextProvider) {
|
|
|
|
mTooltipTextProvider = do_GetService(NS_TOOLTIPTEXTPROVIDER_CONTRACTID);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mTooltipTextProvider) {
|
|
|
|
mTooltipTextProvider = do_GetService(NS_DEFAULTTOOLTIPTEXTPROVIDER_CONTRACTID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mTooltipTextProvider;
|
|
|
|
}
|
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// Hook up things to the chrome like context menus and tooltips, if the chrome
|
|
|
|
// has implemented the right interfaces.
|
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
ChromeTooltipListener::AddChromeListeners()
|
2013-04-22 05:25:28 +04:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!mEventTarget) {
|
2011-06-24 06:18:01 +04:00
|
|
|
GetDOMEventTarget(mWebBrowser, getter_AddRefs(mEventTarget));
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// Register the appropriate events for tooltips, but only if
|
|
|
|
// the embedding chrome cares.
|
2001-03-30 08:45:40 +04:00
|
|
|
nsresult rv = NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsITooltipListener> tooltipListener(
|
|
|
|
do_QueryInterface(mWebBrowserChrome));
|
2014-12-16 20:18:01 +03:00
|
|
|
if (tooltipListener && !mTooltipListenerInstalled) {
|
2001-01-23 03:47:02 +03:00
|
|
|
rv = AddTooltipListener();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2001-01-23 03:47:02 +03:00
|
|
|
return rv;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
return rv;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// Subscribe to the events that will allow us to track tooltips. We need "mouse"
|
|
|
|
// for mouseExit, "mouse motion" for mouseMove, and "key" for keyDown. As we
|
|
|
|
// add the listeners, keep track of how many succeed so we can clean up
|
|
|
|
// correctly in Release().
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
ChromeTooltipListener::AddTooltipListener()
|
2000-08-16 12:51:58 +04:00
|
|
|
{
|
2007-05-14 13:11:38 +04:00
|
|
|
if (mEventTarget) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsresult rv = NS_OK;
|
2017-01-19 21:57:11 +03:00
|
|
|
#ifndef XP_WIN
|
2015-05-11 22:35:13 +03:00
|
|
|
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("keydown"),
|
|
|
|
this, false, false);
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2017-01-19 21:57:11 +03:00
|
|
|
#endif
|
2015-05-11 22:35:13 +03:00
|
|
|
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
|
|
|
this, false, false);
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2015-05-11 22:35:13 +03:00
|
|
|
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mouseout"),
|
|
|
|
this, false, false);
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2015-05-11 22:35:13 +03:00
|
|
|
rv = mEventTarget->AddSystemEventListener(NS_LITERAL_STRING("mousemove"),
|
|
|
|
this, false, false);
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mTooltipListenerInstalled = true;
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
return NS_OK;
|
2000-08-16 12:51:58 +04:00
|
|
|
}
|
|
|
|
|
2001-03-30 08:45:40 +04:00
|
|
|
// Unsubscribe from the various things we've hooked up to the window root.
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMETHODIMP
|
2014-12-16 20:18:01 +03:00
|
|
|
ChromeTooltipListener::RemoveChromeListeners()
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
2001-01-23 07:41:17 +03:00
|
|
|
HideTooltip();
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mTooltipListenerInstalled) {
|
2001-01-23 03:47:02 +03:00
|
|
|
RemoveTooltipListener();
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mEventTarget = nullptr;
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// it really doesn't matter if these fail...
|
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// Unsubscribe from all the various tooltip events that we were listening to.
|
2014-12-16 20:18:01 +03:00
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
ChromeTooltipListener::RemoveTooltipListener()
|
2000-08-16 12:51:58 +04:00
|
|
|
{
|
2007-05-14 13:11:38 +04:00
|
|
|
if (mEventTarget) {
|
2017-01-19 21:57:11 +03:00
|
|
|
#ifndef XP_WIN
|
2018-04-05 20:42:40 +03:00
|
|
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("keydown"),
|
|
|
|
this, false);
|
2017-01-19 21:57:11 +03:00
|
|
|
#endif
|
2018-04-05 20:42:40 +03:00
|
|
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousedown"),
|
|
|
|
this, false);
|
|
|
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mouseout"),
|
|
|
|
this, false);
|
|
|
|
mEventTarget->RemoveSystemEventListener(NS_LITERAL_STRING("mousemove"),
|
|
|
|
this, false);
|
2011-10-17 18:59:28 +04:00
|
|
|
mTooltipListenerInstalled = false;
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-08-16 12:51:58 +04:00
|
|
|
}
|
|
|
|
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_IMETHODIMP
|
2018-04-20 07:49:29 +03:00
|
|
|
ChromeTooltipListener::HandleEvent(Event* aEvent)
|
2000-08-16 12:51:58 +04:00
|
|
|
{
|
2011-06-28 19:12:42 +04:00
|
|
|
nsAutoString eventType;
|
|
|
|
aEvent->GetType(eventType);
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2017-01-19 21:57:11 +03:00
|
|
|
if (eventType.EqualsLiteral("mousedown")) {
|
2011-06-28 19:12:42 +04:00
|
|
|
return HideTooltip();
|
2017-01-19 21:57:11 +03:00
|
|
|
} else if (eventType.EqualsLiteral("keydown")) {
|
|
|
|
WidgetKeyboardEvent* keyEvent = aEvent->WidgetEventPtr()->AsKeyboardEvent();
|
|
|
|
if (!keyEvent->IsModifierKeyEvent()) {
|
|
|
|
return HideTooltip();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2014-12-16 20:18:01 +03:00
|
|
|
} else if (eventType.EqualsLiteral("mouseout")) {
|
2014-10-09 20:21:15 +04:00
|
|
|
// Reset flag so that tooltip will display on the next MouseMove
|
|
|
|
mTooltipShownOnce = false;
|
|
|
|
return HideTooltip();
|
2014-12-16 20:18:01 +03:00
|
|
|
} else if (eventType.EqualsLiteral("mousemove")) {
|
2011-06-28 19:12:42 +04:00
|
|
|
return MouseMove(aEvent);
|
2014-10-09 20:21:15 +04:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2011-06-28 19:12:42 +04:00
|
|
|
NS_ERROR("Unexpected event type");
|
2001-01-23 03:47:02 +03:00
|
|
|
return NS_OK;
|
2000-08-16 12:51:58 +04:00
|
|
|
}
|
2000-08-25 22:39:46 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// If we're a tooltip, fire off a timer to see if a tooltip should be shown. If
|
|
|
|
// the timer fires, we cache the node in |mPossibleTooltipNode|.
|
2001-01-23 03:47:02 +03:00
|
|
|
nsresult
|
2018-04-20 19:55:30 +03:00
|
|
|
ChromeTooltipListener::MouseMove(Event* aMouseEvent)
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
2018-04-20 19:55:30 +03:00
|
|
|
MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (!mouseEvent) {
|
2001-01-23 03:47:02 +03:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// stash the coordinates of the event so that we can still get back to it from
|
|
|
|
// within the timer callback. On win32, we'll get a MouseMove event even when
|
|
|
|
// a popup goes away -- even when the mouse doesn't change position! To get
|
|
|
|
// around this, we make sure the mouse has really moved before proceeding.
|
2018-03-20 07:16:05 +03:00
|
|
|
int32_t newMouseX = mouseEvent->ClientX();
|
|
|
|
int32_t newMouseY = mouseEvent->ClientY();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (mMouseClientX == newMouseX && mMouseClientY == newMouseY) {
|
2001-01-23 03:47:02 +03:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-10-09 20:21:15 +04:00
|
|
|
|
|
|
|
// Filter out minor mouse movements.
|
|
|
|
if (mShowingTooltip &&
|
|
|
|
(abs(mMouseClientX - newMouseX) <= kTooltipMouseMoveTolerance) &&
|
2015-05-11 22:35:13 +03:00
|
|
|
(abs(mMouseClientY - newMouseY) <= kTooltipMouseMoveTolerance)) {
|
2014-10-09 20:21:15 +04:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-10-09 20:21:15 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
mMouseClientX = newMouseX;
|
|
|
|
mMouseClientY = newMouseY;
|
2018-03-20 07:16:05 +03:00
|
|
|
mMouseScreenX = mouseEvent->ScreenX(CallerType::System);
|
|
|
|
mMouseScreenY = mouseEvent->ScreenY(CallerType::System);
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2014-12-16 20:18:01 +03:00
|
|
|
if (mTooltipTimer) {
|
2001-01-23 03:47:02 +03:00
|
|
|
mTooltipTimer->Cancel();
|
2018-09-19 03:56:59 +03:00
|
|
|
mTooltipTimer = nullptr;
|
2014-10-09 20:21:15 +04:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2018-09-19 03:56:59 +03:00
|
|
|
if (!mShowingTooltip) {
|
2017-09-25 05:57:48 +03:00
|
|
|
nsIEventTarget* target = nullptr;
|
2018-09-19 03:56:59 +03:00
|
|
|
if (nsCOMPtr<EventTarget> eventTarget = aMouseEvent->GetComposedTarget()) {
|
2017-09-25 05:57:48 +03:00
|
|
|
mPossibleTooltipNode = do_QueryInterface(eventTarget);
|
|
|
|
nsCOMPtr<nsIGlobalObject> global(eventTarget->GetOwnerGlobal());
|
|
|
|
if (global) {
|
|
|
|
target = global->EventTargetFor(TaskCategory::UI);
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2017-09-25 05:57:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mPossibleTooltipNode) {
|
|
|
|
nsresult rv = NS_NewTimerWithFuncCallback(
|
|
|
|
getter_AddRefs(mTooltipTimer),
|
|
|
|
sTooltipCallback,
|
|
|
|
this,
|
|
|
|
LookAndFeel::GetInt(LookAndFeel::eIntID_TooltipDelay, 500),
|
|
|
|
nsITimer::TYPE_ONE_SHOT,
|
|
|
|
"ChromeTooltipListener::MouseMove",
|
|
|
|
target);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
mPossibleTooltipNode = nullptr;
|
|
|
|
NS_WARNING("Could not create a timer for tooltip tracking");
|
2014-10-09 20:21:15 +04:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
}
|
|
|
|
} else {
|
2014-10-09 20:21:15 +04:00
|
|
|
mTooltipShownOnce = true;
|
|
|
|
return HideTooltip();
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
return NS_OK;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// Tell the registered chrome that they should show the tooltip.
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMETHODIMP
|
2015-05-11 22:35:13 +03:00
|
|
|
ChromeTooltipListener::ShowTooltip(int32_t aInXCoords, int32_t aInYCoords,
|
2016-04-12 23:47:25 +03:00
|
|
|
const nsAString& aInTipText,
|
|
|
|
const nsAString& aTipDir)
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// do the work to call the client
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsITooltipListener> tooltipListener(
|
|
|
|
do_QueryInterface(mWebBrowserChrome));
|
2014-12-16 20:18:01 +03:00
|
|
|
if (tooltipListener) {
|
2015-05-11 22:35:13 +03:00
|
|
|
rv = tooltipListener->OnShowTooltip(aInXCoords, aInYCoords,
|
2016-04-12 23:47:25 +03:00
|
|
|
PromiseFlatString(aInTipText).get(),
|
|
|
|
PromiseFlatString(aTipDir).get());
|
2015-05-11 22:35:13 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mShowingTooltip = true;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// Tell the registered chrome that they should rollup the tooltip
|
|
|
|
// NOTE: This routine is safe to call even if the popup is already closed.
|
|
|
|
NS_IMETHODIMP
|
2003-11-19 04:20:56 +03:00
|
|
|
ChromeTooltipListener::HideTooltip()
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// shut down the relevant timers
|
2014-12-16 20:18:01 +03:00
|
|
|
if (mTooltipTimer) {
|
2001-01-23 03:47:02 +03:00
|
|
|
mTooltipTimer->Cancel();
|
2012-07-30 18:20:58 +04:00
|
|
|
mTooltipTimer = nullptr;
|
2001-01-23 03:47:02 +03:00
|
|
|
// release tooltip target
|
2012-07-30 18:20:58 +04:00
|
|
|
mPossibleTooltipNode = nullptr;
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we're showing the tip, tell the chrome to hide it
|
2014-12-16 20:18:01 +03:00
|
|
|
if (mShowingTooltip) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsITooltipListener> tooltipListener(
|
|
|
|
do_QueryInterface(mWebBrowserChrome));
|
2014-12-16 20:18:01 +03:00
|
|
|
if (tooltipListener) {
|
2014-12-16 20:18:01 +03:00
|
|
|
rv = tooltipListener->OnHideTooltip();
|
2015-05-11 22:35:13 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mShowingTooltip = false;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
|
|
|
// A timer callback, fired when the mouse has hovered inside of a frame for the
|
2015-05-11 22:35:13 +03:00
|
|
|
// appropriate amount of time. Getting to this point means that we should show
|
|
|
|
// the tooltip, but only after we determine there is an appropriate TITLE
|
|
|
|
// element.
|
2001-01-23 03:47:02 +03:00
|
|
|
//
|
2015-05-11 22:35:13 +03:00
|
|
|
// This relies on certain things being cached into the |aChromeTooltipListener|
|
|
|
|
// object passed to us by the timer:
|
2001-01-23 03:47:02 +03:00
|
|
|
// -- the x/y coordinates of the mouse (mMouseClientY, mMouseClientX)
|
|
|
|
// -- the dom node the user hovered over (mPossibleTooltipNode)
|
|
|
|
void
|
2015-05-11 22:35:13 +03:00
|
|
|
ChromeTooltipListener::sTooltipCallback(nsITimer* aTimer,
|
|
|
|
void* aChromeTooltipListener)
|
2001-01-23 03:47:02 +03:00
|
|
|
{
|
2015-05-11 22:35:13 +03:00
|
|
|
auto self = static_cast<ChromeTooltipListener*>(aChromeTooltipListener);
|
2014-12-16 20:18:01 +03:00
|
|
|
if (self && self->mPossibleTooltipNode) {
|
2018-07-14 04:48:19 +03:00
|
|
|
if (!self->mPossibleTooltipNode->IsInComposedDoc()) {
|
|
|
|
// release tooltip target if there is one, NO MATTER WHAT
|
|
|
|
self->mPossibleTooltipNode = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-19 03:08:48 +04:00
|
|
|
// The actual coordinates we want to put the tooltip at are relative to the
|
|
|
|
// toplevel docshell of our mWebBrowser. We know what the screen
|
|
|
|
// coordinates of the mouse event were, which means we just need the screen
|
|
|
|
// coordinates of the docshell. Unfortunately, there is no good way to
|
|
|
|
// find those short of groveling for the presentation in that docshell and
|
|
|
|
// finding the screen coords of its toplevel widget...
|
|
|
|
nsCOMPtr<nsIDocShell> docShell =
|
2007-07-08 11:08:04 +04:00
|
|
|
do_GetInterface(static_cast<nsIWebBrowser*>(self->mWebBrowser));
|
2005-09-19 03:08:48 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
if (docShell) {
|
2012-12-29 05:56:42 +04:00
|
|
|
shell = docShell->GetPresShell();
|
2005-09-19 03:08:48 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIWidget* widget = nullptr;
|
2005-09-19 03:08:48 +04:00
|
|
|
if (shell) {
|
2013-01-05 07:12:24 +04:00
|
|
|
nsViewManager* vm = shell->GetViewManager();
|
2005-09-19 03:08:48 +04:00
|
|
|
if (vm) {
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = vm->GetRootView();
|
2005-09-19 03:08:48 +04:00
|
|
|
if (view) {
|
|
|
|
nsPoint offset;
|
|
|
|
widget = view->GetNearestWidget(&offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!widget) {
|
|
|
|
// release tooltip target if there is one, NO MATTER WHAT
|
2012-07-30 18:20:58 +04:00
|
|
|
self->mPossibleTooltipNode = nullptr;
|
2005-09-19 03:08:48 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-07-13 13:20:07 +04:00
|
|
|
|
|
|
|
// if there is text associated with the node, show the tip and fire
|
|
|
|
// off a timer to auto-hide it.
|
2018-05-31 01:57:59 +03:00
|
|
|
nsITooltipTextProvider* tooltipProvider = self->GetTooltipTextProvider();
|
|
|
|
if (tooltipProvider) {
|
2017-08-08 09:07:55 +03:00
|
|
|
nsString tooltipText;
|
|
|
|
nsString directionText;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool textFound = false;
|
2018-05-31 01:57:59 +03:00
|
|
|
tooltipProvider->GetNodeText(
|
2016-04-12 23:47:25 +03:00
|
|
|
self->mPossibleTooltipNode, getter_Copies(tooltipText),
|
|
|
|
getter_Copies(directionText), &textFound);
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2018-09-19 03:56:59 +03:00
|
|
|
if (textFound &&
|
|
|
|
(!self->mTooltipShownOnce ||
|
|
|
|
tooltipText != self->mLastShownTooltipText)) {
|
2015-02-04 23:21:03 +03:00
|
|
|
LayoutDeviceIntPoint screenDot = widget->WidgetToScreenOffset();
|
2015-03-31 23:39:02 +03:00
|
|
|
double scaleFactor = 1.0;
|
|
|
|
if (shell->GetPresContext()) {
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDeviceContext* dc = shell->GetPresContext()->DeviceContext();
|
2018-08-11 07:46:23 +03:00
|
|
|
scaleFactor = double(AppUnitsPerCSSPixel()) /
|
2015-05-11 22:35:13 +03:00
|
|
|
dc->AppUnitsPerDevPixelAtUnitFullZoom();
|
2015-03-31 23:39:02 +03:00
|
|
|
}
|
|
|
|
// ShowTooltip expects widget-relative position.
|
|
|
|
self->ShowTooltip(self->mMouseScreenX - screenDot.x / scaleFactor,
|
2015-05-11 22:35:13 +03:00
|
|
|
self->mMouseScreenY - screenDot.y / scaleFactor,
|
2017-08-08 09:07:55 +03:00
|
|
|
tooltipText, directionText);
|
2018-09-19 03:56:59 +03:00
|
|
|
self->mLastShownTooltipText = std::move(tooltipText);
|
2001-07-13 13:20:07 +04:00
|
|
|
}
|
2001-01-23 03:47:02 +03:00
|
|
|
}
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
// release tooltip target if there is one, NO MATTER WHAT
|
2012-07-30 18:20:58 +04:00
|
|
|
self->mPossibleTooltipNode = nullptr;
|
2015-05-11 22:35:13 +03:00
|
|
|
}
|
|
|
|
}
|