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: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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
|
|
|
|
|
|
|
#ifndef nsDocShellTreeOwner_h__
|
|
|
|
#define nsDocShellTreeOwner_h__
|
|
|
|
|
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
// Interfaces Needed
|
|
|
|
#include "nsIBaseWindow.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-03-09 04:06:56 +03:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
2011-06-28 19:12:42 +04:00
|
|
|
#include "nsIDOMEventListener.h"
|
2001-03-13 15:21:34 +03:00
|
|
|
#include "nsIEmbeddingSiteWindow.h"
|
2001-02-01 00:03:40 +03:00
|
|
|
#include "nsIWebProgressListener.h"
|
|
|
|
#include "nsWeakReference.h"
|
2001-01-23 03:47:02 +03:00
|
|
|
#include "nsITimer.h"
|
2001-04-21 06:42:14 +04:00
|
|
|
#include "nsIPrompt.h"
|
2001-04-10 22:30:25 +04:00
|
|
|
#include "nsIAuthPrompt.h"
|
2001-07-13 13:20:07 +04:00
|
|
|
#include "nsITooltipListener.h"
|
2001-09-20 17:25:40 +04:00
|
|
|
#include "nsITooltipTextProvider.h"
|
|
|
|
#include "nsCTooltipTextProvider.h"
|
2010-04-18 22:27:18 +04:00
|
|
|
#include "nsIDroppedLinkHandler.h"
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2013-04-22 05:25:28 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2018-04-20 19:55:30 +03:00
|
|
|
class Event;
|
2013-04-22 05:25:28 +04:00
|
|
|
class EventTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
class nsWebBrowser;
|
2001-03-30 08:45:40 +04:00
|
|
|
class ChromeTooltipListener;
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDocShellTreeOwner final : public nsIDocShellTreeOwner,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIBaseWindow,
|
|
|
|
public nsIInterfaceRequestor,
|
|
|
|
public nsIWebProgressListener,
|
|
|
|
public nsIDOMEventListener,
|
|
|
|
public nsSupportsWeakReference {
|
2015-05-11 22:35:13 +03:00
|
|
|
friend class nsWebBrowser;
|
2000-03-09 04:06:56 +03:00
|
|
|
|
|
|
|
public:
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_DECL_NSIBASEWINDOW
|
|
|
|
NS_DECL_NSIDOCSHELLTREEOWNER
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
protected:
|
2015-05-11 22:35:13 +03:00
|
|
|
nsDocShellTreeOwner();
|
|
|
|
virtual ~nsDocShellTreeOwner();
|
2000-08-16 12:51:58 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
void WebBrowser(nsWebBrowser* aWebBrowser);
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsWebBrowser* WebBrowser();
|
|
|
|
NS_IMETHOD SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner);
|
|
|
|
NS_IMETHOD SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome);
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_IMETHOD AddChromeListeners();
|
|
|
|
NS_IMETHOD RemoveChromeListeners();
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
void EnsurePrompter();
|
|
|
|
void EnsureAuthPrompter();
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
void AddToWatcher();
|
|
|
|
void RemoveFromWatcher();
|
2001-02-07 08:02:06 +03:00
|
|
|
|
2015-11-12 08:08:28 +03:00
|
|
|
void EnsureContentTreeOwner();
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// These helper functions return the correct instances of the requested
|
|
|
|
// interfaces. If the object passed to SetWebBrowserChrome() implements
|
|
|
|
// nsISupportsWeakReference, then these functions call QueryReferent on
|
|
|
|
// that object. Otherwise, they return an addrefed pointer. If the
|
|
|
|
// WebBrowserChrome object doesn't exist, they return nullptr.
|
|
|
|
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
|
|
|
|
already_AddRefed<nsIEmbeddingSiteWindow> GetOwnerWin();
|
|
|
|
already_AddRefed<nsIInterfaceRequestor> GetOwnerRequestor();
|
2005-02-05 02:32:32 +03:00
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
protected:
|
2015-05-11 22:35:13 +03:00
|
|
|
// Weak References
|
|
|
|
nsWebBrowser* mWebBrowser;
|
|
|
|
nsIDocShellTreeOwner* mTreeOwner;
|
|
|
|
nsIDocShellTreeItem* mPrimaryContentShell;
|
2000-03-09 04:06:56 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsIWebBrowserChrome* mWebBrowserChrome;
|
|
|
|
nsIEmbeddingSiteWindow* mOwnerWin;
|
|
|
|
nsIInterfaceRequestor* mOwnerRequestor;
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsWeakPtr mWebBrowserChromeWeak; // nsIWebBrowserChrome
|
2005-02-05 02:32:32 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// the objects that listen for chrome events like context menus and tooltips.
|
|
|
|
// They are separate objects to avoid circular references between |this|
|
|
|
|
// and the DOM.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ChromeTooltipListener> mChromeTooltipListener;
|
2001-04-21 06:42:14 +04:00
|
|
|
|
2015-11-12 08:08:28 +03:00
|
|
|
RefPtr<nsDocShellTreeOwner> mContentTreeOwner;
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
nsCOMPtr<nsIPrompt> mPrompter;
|
|
|
|
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
2019-04-09 23:59:37 +03:00
|
|
|
nsCOMPtr<nsIRemoteTab> mPrimaryRemoteTab;
|
2000-03-09 04:06:56 +03:00
|
|
|
};
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// The class that listens to the chrome events and tells the embedding chrome to
|
|
|
|
// show tooltips, as appropriate. Handles registering itself with the DOM with
|
|
|
|
// AddChromeListeners() and removing itself with RemoveChromeListeners().
|
2015-03-21 19:28:04 +03:00
|
|
|
class ChromeTooltipListener final : public nsIDOMEventListener {
|
2014-07-01 02:11:52 +04:00
|
|
|
protected:
|
2014-12-16 20:18:01 +03:00
|
|
|
virtual ~ChromeTooltipListener();
|
2014-07-01 02:11:52 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2014-12-16 20:18:01 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
ChromeTooltipListener(nsWebBrowser* aInBrowser,
|
|
|
|
nsIWebBrowserChrome* aInChrome);
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2018-04-20 07:49:29 +03:00
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
2018-04-20 19:55:30 +03:00
|
|
|
NS_IMETHOD MouseMove(mozilla::dom::Event* aMouseEvent);
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// Add/remove the relevant listeners, based on what interfaces the embedding
|
|
|
|
// chrome implements.
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMETHOD AddChromeListeners();
|
|
|
|
NS_IMETHOD RemoveChromeListeners();
|
|
|
|
|
|
|
|
private:
|
2015-05-11 22:35:13 +03:00
|
|
|
// various delays for tooltips
|
|
|
|
enum {
|
|
|
|
kTooltipAutoHideTime = 5000, // ms
|
|
|
|
kTooltipMouseMoveTolerance = 7 // pixel tolerance for mousemove event
|
2001-03-30 08:45:40 +04:00
|
|
|
};
|
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
NS_IMETHOD AddTooltipListener();
|
|
|
|
NS_IMETHOD RemoveTooltipListener();
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
NS_IMETHOD ShowTooltip(int32_t aInXCoords, int32_t aInYCoords,
|
2016-04-12 23:47:25 +03:00
|
|
|
const nsAString& aInTipText,
|
|
|
|
const nsAString& aDirText);
|
2014-12-16 20:18:01 +03:00
|
|
|
NS_IMETHOD HideTooltip();
|
2018-05-31 01:57:59 +03:00
|
|
|
nsITooltipTextProvider* GetTooltipTextProvider();
|
2001-03-30 08:45:40 +04:00
|
|
|
|
2001-01-23 03:47:02 +03:00
|
|
|
nsWebBrowser* mWebBrowser;
|
2013-04-22 05:25:28 +04:00
|
|
|
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
|
2001-07-13 13:20:07 +04:00
|
|
|
nsCOMPtr<nsITooltipTextProvider> mTooltipTextProvider;
|
2013-04-22 05:25:28 +04:00
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// This must be a strong ref in order to make sure we can hide the tooltip if
|
|
|
|
// the window goes away while we're displaying one. If we don't hold a strong
|
|
|
|
// ref, the chrome might have been disposed of before we get a chance to tell
|
|
|
|
// it, and no one would ever tell us of that fact.
|
2001-01-23 07:41:17 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome;
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mTooltipListenerInstalled;
|
2001-01-23 03:47:02 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsITimer> mTooltipTimer;
|
2014-12-16 20:18:01 +03:00
|
|
|
static void sTooltipCallback(nsITimer* aTimer, void* aListener);
|
2015-05-11 22:35:13 +03:00
|
|
|
|
|
|
|
// Mouse coordinates for last mousemove event we saw
|
|
|
|
int32_t mMouseClientX;
|
|
|
|
int32_t mMouseClientY;
|
|
|
|
|
|
|
|
// Mouse coordinates for tooltip event
|
|
|
|
int32_t mMouseScreenX;
|
|
|
|
int32_t mMouseScreenY;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mShowingTooltip;
|
2018-09-19 03:56:59 +03:00
|
|
|
|
2014-10-09 20:21:15 +04:00
|
|
|
bool mTooltipShownOnce;
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2018-09-19 03:56:59 +03:00
|
|
|
// The string of text that we last displayed.
|
|
|
|
nsString mLastShownTooltipText;
|
|
|
|
|
2015-05-11 22:35:13 +03:00
|
|
|
// The node hovered over that fired the timer. This may turn into the node
|
|
|
|
// that triggered the tooltip, but only if the timer ever gets around to
|
|
|
|
// firing. This is a strong reference, because the tooltip content can be
|
2018-09-19 03:56:59 +03:00
|
|
|
// destroyed while we're waiting for the tooltip to pop up, and we need to
|
2015-05-11 22:35:13 +03:00
|
|
|
// detect that. It's set only when the tooltip timer is created and launched.
|
|
|
|
// The timer must either fire or be cancelled (or possibly released?), and we
|
|
|
|
// release this reference in each of those cases. So we don't leak.
|
2018-05-30 05:58:48 +03:00
|
|
|
nsCOMPtr<nsINode> mPossibleTooltipNode;
|
2015-05-11 22:35:13 +03:00
|
|
|
};
|
2001-01-23 03:47:02 +03:00
|
|
|
|
2000-03-09 04:06:56 +03:00
|
|
|
#endif /* nsDocShellTreeOwner_h__ */
|