2015-02-05 02:15:12 +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/. */
1999-10-22 06:35:18 +04:00
2000-02-14 11:53:45 +03:00
// Local Includes
# include "nsWebBrowser.h"
// Helper Classes
1999-10-27 06:45:49 +04:00
# include "nsGfxCIID.h"
# include "nsWidgetsCID.h"
2000-02-14 11:53:45 +03:00
2014-11-24 03:04:33 +03:00
# include "gfxUtils.h"
# include "mozilla/gfx/2D.h"
2000-02-14 11:53:45 +03:00
//Interfaces Needed
2001-09-29 12:28:41 +04:00
# include "nsReadableUtils.h"
2000-02-14 11:53:45 +03:00
# include "nsIComponentManager.h"
1999-11-02 04:04:25 +03:00
# include "nsIDOMDocument.h"
2000-09-02 01:10:23 +04:00
# include "nsIDOMWindow.h"
2001-05-11 18:19:39 +04:00
# include "nsIDOMElement.h"
1999-11-18 12:17:07 +03:00
# include "nsIInterfaceRequestor.h"
2001-09-06 01:28:38 +04:00
# include "nsIInterfaceRequestorUtils.h"
1999-11-18 12:17:07 +03:00
# include "nsIWebBrowserChrome.h"
2000-11-17 22:57:16 +03:00
# include "nsPIDOMWindow.h"
2001-01-19 09:00:23 +03:00
# include "nsIWebProgress.h"
2001-02-01 00:03:40 +03:00
# include "nsIWebProgressListener.h"
2001-01-31 03:34:28 +03:00
# include "nsIWebBrowserFocus.h"
2004-05-29 21:43:59 +04:00
# include "nsIWebBrowserStream.h"
2001-04-01 21:51:12 +04:00
# include "nsIPresShell.h"
2001-07-16 06:40:48 +04:00
# include "nsIURIContentListener.h"
2001-10-02 01:07:26 +04:00
# include "nsISHistoryListener.h"
2001-11-01 17:39:26 +03:00
# include "nsIURI.h"
# include "nsIWebBrowserPersist.h"
# include "nsCWebBrowserPersist.h"
2002-02-01 17:52:11 +03:00
# include "nsIServiceManager.h"
2006-03-22 21:36:36 +03:00
# include "nsAutoPtr.h"
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
# include "nsFocusManager.h"
2010-03-01 11:03:49 +03:00
# include "Layers.h"
# include "gfxContext.h"
2013-10-08 06:21:07 +04:00
# include "nsILoadContext.h"
1999-10-22 06:35:18 +04:00
2001-05-07 17:49:59 +04:00
// for painting the background window
2011-09-09 06:27:12 +04:00
# include "mozilla/LookAndFeel.h"
2001-05-07 17:49:59 +04:00
2001-03-27 16:04:30 +04:00
// Printing Includes
2005-09-16 06:25:37 +04:00
# ifdef NS_PRINTING
# include "nsIWebBrowserPrint.h"
2001-03-27 16:04:30 +04:00
# include "nsIContentViewer.h"
2005-09-16 06:25:37 +04:00
# endif
2001-03-27 16:04:30 +04:00
2001-06-02 04:35:39 +04:00
// PSM2 includes
# include "nsISecureBrowserUI.h"
2010-08-11 00:06:38 +04:00
# include "nsXULAppAPI.h"
2001-06-02 04:35:39 +04:00
2011-09-09 06:27:12 +04:00
using namespace mozilla ;
2014-11-24 03:04:33 +03:00
using namespace mozilla : : gfx ;
2010-03-01 11:03:49 +03:00
using namespace mozilla : : layers ;
2001-10-02 07:10:56 +04:00
static NS_DEFINE_CID ( kChildCID , NS_CHILD_CID ) ;
1999-10-27 06:45:49 +04:00
2001-11-01 17:39:26 +03:00
1999-10-22 06:35:18 +04:00
//*****************************************************************************
//*** nsWebBrowser: Object Management
//*****************************************************************************
2014-12-16 20:18:02 +03:00
nsWebBrowser : : nsWebBrowser ( ) :
2015-02-05 02:15:12 +03:00
mInitInfo ( new nsWebBrowserInitInfo ( ) ) ,
mContentType ( typeContentWrapper ) ,
mActivating ( false ) ,
mShouldEnableHistory ( true ) ,
mIsActive ( true ) ,
mParentNativeWindow ( nullptr ) ,
mProgressListener ( nullptr ) ,
mBackgroundColor ( 0 ) ,
mPersistCurrentState ( nsIWebBrowserPersist : : PERSIST_STATE_READY ) ,
mPersistResult ( NS_OK ) ,
mPersistFlags ( nsIWebBrowserPersist : : PERSIST_FLAGS_NONE ) ,
mParentWidget ( nullptr )
{
mWWatch = do_GetService ( NS_WINDOWWATCHER_CONTRACTID ) ;
NS_ASSERTION ( mWWatch , " failed to get WindowWatcher " ) ;
1999-10-22 06:35:18 +04:00
}
nsWebBrowser : : ~ nsWebBrowser ( )
{
2015-02-05 02:15:12 +03:00
InternalDestroy ( ) ;
2000-04-03 01:01:18 +04:00
}
NS_IMETHODIMP nsWebBrowser : : InternalDestroy ( )
{
2015-02-05 02:15:12 +03:00
if ( mInternalWidget ) {
mInternalWidget - > SetWidgetListener ( nullptr ) ;
mInternalWidget - > Destroy ( ) ;
mInternalWidget = nullptr ; // Force release here.
}
2000-11-17 22:57:16 +03:00
2015-02-05 02:15:12 +03:00
SetDocShell ( nullptr ) ;
2000-04-03 01:01:18 +04:00
2015-02-05 02:15:12 +03:00
if ( mDocShellTreeOwner ) {
mDocShellTreeOwner - > WebBrowser ( nullptr ) ;
mDocShellTreeOwner = nullptr ;
}
2014-12-16 20:18:02 +03:00
2015-02-05 02:15:12 +03:00
mInitInfo = nullptr ;
2000-04-03 01:01:18 +04:00
2015-02-05 02:15:12 +03:00
mListenerArray = nullptr ;
2001-02-01 00:03:40 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-22 06:35:18 +04:00
}
2000-08-16 12:50:00 +04:00
1999-10-22 06:35:18 +04:00
//*****************************************************************************
// nsWebBrowser::nsISupports
2014-12-16 20:18:01 +03:00
//*****************************************************************************
1999-10-22 06:35:18 +04:00
1999-11-17 12:00:05 +03:00
NS_IMPL_ADDREF ( nsWebBrowser )
NS_IMPL_RELEASE ( nsWebBrowser )
2000-02-24 06:51:35 +03:00
NS_INTERFACE_MAP_BEGIN ( nsWebBrowser )
2015-02-05 02:15:12 +03:00
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS ( nsISupports , nsIWebBrowser )
NS_INTERFACE_MAP_ENTRY ( nsIWebBrowser )
NS_INTERFACE_MAP_ENTRY ( nsIWebNavigation )
NS_INTERFACE_MAP_ENTRY ( nsIBaseWindow )
NS_INTERFACE_MAP_ENTRY ( nsIScrollable )
NS_INTERFACE_MAP_ENTRY ( nsITextScroll )
NS_INTERFACE_MAP_ENTRY ( nsIDocShellTreeItem )
NS_INTERFACE_MAP_ENTRY ( nsIInterfaceRequestor )
NS_INTERFACE_MAP_ENTRY ( nsIWebBrowserSetup )
NS_INTERFACE_MAP_ENTRY ( nsIWebBrowserPersist )
NS_INTERFACE_MAP_ENTRY ( nsICancelable )
NS_INTERFACE_MAP_ENTRY ( nsIWebBrowserFocus )
NS_INTERFACE_MAP_ENTRY ( nsIWebProgressListener )
NS_INTERFACE_MAP_ENTRY ( nsIWebBrowserStream )
NS_INTERFACE_MAP_ENTRY ( nsISupportsWeakReference )
2000-02-24 06:51:35 +03:00
NS_INTERFACE_MAP_END
1999-10-22 06:35:18 +04:00
2000-03-11 04:12:46 +03:00
///*****************************************************************************
// nsWebBrowser::nsIInterfaceRequestor
2014-12-16 20:18:01 +03:00
//*****************************************************************************
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetInterface ( const nsIID & aIID , void * * aSink )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aSink ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
if ( NS_SUCCEEDED ( QueryInterface ( aIID , aSink ) ) ) {
return NS_OK ;
}
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
if ( mDocShell ) {
2005-09-16 06:25:37 +04:00
# ifdef NS_PRINTING
2015-02-05 02:15:12 +03:00
if ( aIID . Equals ( NS_GET_IID ( nsIWebBrowserPrint ) ) ) {
nsCOMPtr < nsIContentViewer > viewer ;
mDocShell - > GetContentViewer ( getter_AddRefs ( viewer ) ) ;
if ( ! viewer ) {
return NS_NOINTERFACE ;
}
nsCOMPtr < nsIWebBrowserPrint > webBrowserPrint ( do_QueryInterface ( viewer ) ) ;
nsIWebBrowserPrint * print = ( nsIWebBrowserPrint * ) webBrowserPrint . get ( ) ;
NS_ASSERTION ( print , " This MUST support this interface! " ) ;
NS_ADDREF ( print ) ;
* aSink = print ;
return NS_OK ;
}
2005-09-16 06:25:37 +04:00
# endif
2015-02-05 02:15:12 +03:00
return mDocShellAsReq - > GetInterface ( aIID , aSink ) ;
}
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_NOINTERFACE ;
2000-03-11 04:12:46 +03:00
}
1999-10-22 06:35:18 +04:00
//*****************************************************************************
// nsWebBrowser::nsIWebBrowser
2014-12-16 20:18:01 +03:00
//*****************************************************************************
1999-10-22 06:35:18 +04:00
2001-01-19 09:00:23 +03:00
// listeners that currently support registration through AddWebBrowserListener:
// - nsIWebProgressListener
2001-02-14 06:12:33 +03:00
NS_IMETHODIMP nsWebBrowser : : AddWebBrowserListener ( nsIWeakReference * aListener , const nsIID & aIID )
2014-12-16 20:18:01 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aListener ) ;
2001-02-01 00:03:40 +03:00
2015-02-05 02:15:12 +03:00
nsresult rv = NS_OK ;
if ( ! mWebProgress ) {
// The window hasn't been created yet, so queue up the listener. They'll be
// registered when the window gets created.
if ( ! mListenerArray ) {
mListenerArray = new nsTArray < nsWebBrowserListenerState > ( ) ;
2001-01-19 09:00:23 +03:00
}
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
nsWebBrowserListenerState * state = mListenerArray - > AppendElement ( ) ;
state - > mWeakPtr = aListener ;
state - > mID = aIID ;
} else {
nsCOMPtr < nsISupports > supports ( do_QueryReferent ( aListener ) ) ;
if ( ! supports ) return NS_ERROR_INVALID_ARG ;
rv = BindListener ( supports , aIID ) ;
}
return rv ;
2001-02-01 00:03:40 +03:00
}
NS_IMETHODIMP nsWebBrowser : : BindListener ( nsISupports * aListener , const nsIID & aIID ) {
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aListener ) ;
NS_ASSERTION ( mWebProgress , " this should only be called after we've retrieved a progress iface " ) ;
nsresult rv = NS_OK ;
// register this listener for the specified interface id
if ( aIID . Equals ( NS_GET_IID ( nsIWebProgressListener ) ) ) {
nsCOMPtr < nsIWebProgressListener > listener = do_QueryInterface ( aListener , & rv ) ;
if ( NS_FAILED ( rv ) ) return rv ;
NS_ENSURE_STATE ( mWebProgress ) ;
rv = mWebProgress - > AddProgressListener ( listener , nsIWebProgress : : NOTIFY_ALL ) ;
} else if ( aIID . Equals ( NS_GET_IID ( nsISHistoryListener ) ) ) {
nsCOMPtr < nsISHistory > shistory ( do_GetInterface ( mDocShell , & rv ) ) ;
if ( NS_FAILED ( rv ) ) return rv ;
nsCOMPtr < nsISHistoryListener > listener ( do_QueryInterface ( aListener , & rv ) ) ;
if ( NS_FAILED ( rv ) ) return rv ;
rv = shistory - > AddSHistoryListener ( listener ) ;
}
return rv ;
1999-10-22 06:35:18 +04:00
}
2001-02-14 06:12:33 +03:00
NS_IMETHODIMP nsWebBrowser : : RemoveWebBrowserListener ( nsIWeakReference * aListener , const nsIID & aIID )
1999-10-22 06:35:18 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aListener ) ;
2001-02-01 00:03:40 +03:00
2015-02-05 02:15:12 +03:00
nsresult rv = NS_OK ;
if ( ! mWebProgress ) {
// if there's no-one to register the listener w/, and we don't have a queue going,
// the the called is calling Remove before an Add which doesn't make sense.
if ( ! mListenerArray ) return NS_ERROR_FAILURE ;
// iterate the array and remove the queued listener
int32_t count = mListenerArray - > Length ( ) ;
while ( count > 0 ) {
if ( mListenerArray - > ElementAt ( count ) . Equals ( aListener , aIID ) ) {
mListenerArray - > RemoveElementAt ( count ) ;
break ;
}
count - - ;
2001-01-19 09:00:23 +03:00
}
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
// if we've emptied the array, get rid of it.
if ( 0 > = mListenerArray - > Length ( ) ) {
mListenerArray = nullptr ;
}
} else {
nsCOMPtr < nsISupports > supports ( do_QueryReferent ( aListener ) ) ;
if ( ! supports ) return NS_ERROR_INVALID_ARG ;
rv = UnBindListener ( supports , aIID ) ;
}
return rv ;
1999-10-22 06:35:18 +04:00
}
2001-02-01 00:03:40 +03:00
NS_IMETHODIMP nsWebBrowser : : UnBindListener ( nsISupports * aListener , const nsIID & aIID ) {
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aListener ) ;
NS_ASSERTION ( mWebProgress , " this should only be called after we've retrieved a progress iface " ) ;
nsresult rv = NS_OK ;
// remove the listener for the specified interface id
if ( aIID . Equals ( NS_GET_IID ( nsIWebProgressListener ) ) ) {
nsCOMPtr < nsIWebProgressListener > listener = do_QueryInterface ( aListener , & rv ) ;
if ( NS_FAILED ( rv ) ) return rv ;
NS_ENSURE_STATE ( mWebProgress ) ;
rv = mWebProgress - > RemoveProgressListener ( listener ) ;
} else if ( aIID . Equals ( NS_GET_IID ( nsISHistoryListener ) ) ) {
nsCOMPtr < nsISHistory > shistory ( do_GetInterface ( mDocShell , & rv ) ) ;
if ( NS_FAILED ( rv ) ) return rv ;
nsCOMPtr < nsISHistoryListener > listener ( do_QueryInterface ( aListener , & rv ) ) ;
if ( NS_FAILED ( rv ) ) return rv ;
rv = shistory - > RemoveSHistoryListener ( listener ) ;
}
return rv ;
2001-02-01 00:03:40 +03:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : EnableGlobalHistory ( bool aEnable )
2001-05-19 22:31:20 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
return mDocShell - > SetUseGlobalHistory ( aEnable ) ;
2001-05-19 22:31:20 +04:00
}
2000-08-25 22:39:46 +04:00
NS_IMETHODIMP nsWebBrowser : : GetContainerWindow ( nsIWebBrowserChrome * * aTopWindow )
1999-11-18 12:17:07 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aTopWindow ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIWebBrowserChrome > top ;
if ( mDocShellTreeOwner ) {
top = mDocShellTreeOwner - > GetWebBrowserChrome ( ) ;
}
1999-11-18 12:17:07 +03:00
2015-02-05 02:15:12 +03:00
top . forget ( aTopWindow ) ;
2014-12-16 20:18:02 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-11-18 12:17:07 +03:00
}
2000-08-25 22:39:46 +04:00
NS_IMETHODIMP nsWebBrowser : : SetContainerWindow ( nsIWebBrowserChrome * aTopWindow )
1999-11-18 12:17:07 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( EnsureDocShellTreeOwner ( ) , NS_ERROR_FAILURE ) ;
return mDocShellTreeOwner - > SetWebBrowserChrome ( aTopWindow ) ;
1999-11-18 12:17:07 +03:00
}
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : GetParentURIContentListener ( nsIURIContentListener * * aParentContentListener )
2000-04-03 01:01:18 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aParentContentListener ) ;
* aParentContentListener = nullptr ;
2000-04-03 01:01:18 +04:00
2015-02-05 02:15:12 +03:00
// get the interface from the docshell
nsCOMPtr < nsIURIContentListener > listener ( do_GetInterface ( mDocShell ) ) ;
2001-04-06 03:20:49 +04:00
2015-02-05 02:15:12 +03:00
if ( listener )
return listener - > GetParentContentListener ( aParentContentListener ) ;
return NS_OK ;
2000-04-03 01:01:18 +04:00
}
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : SetParentURIContentListener ( nsIURIContentListener * aParentContentListener )
2000-04-03 01:01:18 +04:00
{
2015-02-05 02:15:12 +03:00
// get the interface from the docshell
nsCOMPtr < nsIURIContentListener > listener ( do_GetInterface ( mDocShell ) ) ;
2000-04-03 01:01:18 +04:00
2015-02-05 02:15:12 +03:00
if ( listener )
return listener - > SetParentContentListener ( aParentContentListener ) ;
return NS_ERROR_FAILURE ;
2000-04-03 01:01:18 +04:00
}
2000-09-02 01:10:23 +04:00
NS_IMETHODIMP nsWebBrowser : : GetContentDOMWindow ( nsIDOMWindow * * _retval )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
nsCOMPtr < nsIDOMWindow > retval = mDocShell - > GetWindow ( ) ;
retval . forget ( _retval ) ;
return * _retval ? NS_OK : NS_ERROR_FAILURE ;
2000-09-02 01:10:23 +04:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : GetIsActive ( bool * rv )
2010-08-05 19:27:52 +04:00
{
* rv = mIsActive ;
return NS_OK ;
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : SetIsActive ( bool aIsActive )
2010-08-05 19:27:52 +04:00
{
// Set our copy of the value
mIsActive = aIsActive ;
// If we have a docshell, pass on the request
if ( mDocShell )
return mDocShell - > SetIsActive ( aIsActive ) ;
return NS_OK ;
}
1999-10-23 11:56:27 +04:00
//*****************************************************************************
2000-03-11 04:12:46 +03:00
// nsWebBrowser::nsIDocShellTreeItem
2014-12-16 20:18:01 +03:00
//*****************************************************************************
1999-10-23 11:56:27 +04:00
2013-03-20 05:47:47 +04:00
NS_IMETHODIMP nsWebBrowser : : GetName ( nsAString & aName )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mDocShell )
mDocShell - > GetName ( aName ) ;
else
aName = mInitInfo - > name ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2013-03-20 05:47:47 +04:00
NS_IMETHODIMP nsWebBrowser : : SetName ( const nsAString & aName )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mDocShell ) {
return mDocShell - > SetName ( aName ) ;
} else {
mInitInfo - > name = aName ;
}
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2014-01-04 19:02:17 +04:00
NS_IMETHODIMP nsWebBrowser : : NameEquals ( const char16_t * aName , bool * _retval )
2001-10-20 15:42:35 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aName ) ;
NS_ENSURE_ARG_POINTER ( _retval ) ;
if ( mDocShell ) {
return mDocShell - > NameEquals ( aName , _retval ) ;
} else {
* _retval = mInitInfo - > name . Equals ( aName ) ;
}
2001-10-20 15:42:35 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
2001-10-20 15:42:35 +04:00
}
2014-01-20 11:58:26 +04:00
/* virtual */ int32_t
nsWebBrowser : : ItemType ( )
{
2015-02-05 02:15:12 +03:00
return mContentType ;
2014-01-20 11:58:26 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetItemType ( int32_t * aItemType )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aItemType ) ;
1999-11-01 22:57:15 +03:00
2015-02-05 02:15:12 +03:00
* aItemType = ItemType ( ) ;
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetItemType ( int32_t aItemType )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_TRUE ( ( aItemType = = typeContentWrapper | | aItemType = = typeChromeWrapper ) , NS_ERROR_FAILURE ) ;
mContentType = aItemType ;
if ( mDocShell ) {
mDocShell - > SetItemType ( mContentType = = typeChromeWrapper
? static_cast < int32_t > ( typeChrome )
: static_cast < int32_t > ( typeContent ) ) ;
}
2015-02-05 02:15:12 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetParent ( nsIDocShellTreeItem * * aParent )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
* aParent = nullptr ;
return NS_OK ;
2000-03-11 04:12:46 +03:00
}
NS_IMETHODIMP nsWebBrowser : : GetSameTypeParent ( nsIDocShellTreeItem * * aParent )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
* aParent = nullptr ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetRootTreeItem ( nsIDocShellTreeItem * * aRootTreeItem )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aRootTreeItem ) ;
* aRootTreeItem = static_cast < nsIDocShellTreeItem * > ( this ) ;
1999-11-02 04:04:25 +03:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIDocShellTreeItem > parent ;
NS_ENSURE_SUCCESS ( GetParent ( getter_AddRefs ( parent ) ) , NS_ERROR_FAILURE ) ;
while ( parent ) {
* aRootTreeItem = parent ;
NS_ENSURE_SUCCESS ( ( * aRootTreeItem ) - > GetParent ( getter_AddRefs ( parent ) ) , NS_ERROR_FAILURE ) ;
}
NS_ADDREF ( * aRootTreeItem ) ;
return NS_OK ;
2000-03-11 04:12:46 +03:00
}
1999-11-02 04:04:25 +03:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetSameTypeRootTreeItem ( nsIDocShellTreeItem * * aRootTreeItem )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aRootTreeItem ) ;
* aRootTreeItem = static_cast < nsIDocShellTreeItem * > ( this ) ;
1999-11-02 04:04:25 +03:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIDocShellTreeItem > parent ;
NS_ENSURE_SUCCESS ( GetSameTypeParent ( getter_AddRefs ( parent ) ) , NS_ERROR_FAILURE ) ;
while ( parent ) {
* aRootTreeItem = parent ;
NS_ENSURE_SUCCESS ( ( * aRootTreeItem ) - > GetSameTypeParent ( getter_AddRefs ( parent ) ) ,
NS_ERROR_FAILURE ) ;
}
NS_ADDREF ( * aRootTreeItem ) ;
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2014-12-16 20:18:01 +03:00
NS_IMETHODIMP nsWebBrowser : : FindItemWithName ( const char16_t * aName ,
2015-02-05 02:15:12 +03:00
nsISupports * aRequestor ,
nsIDocShellTreeItem * aOriginalRequestor ,
nsIDocShellTreeItem * * _retval )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
NS_ASSERTION ( mDocShellTreeOwner , " This should always be set when in this situation " ) ;
1999-10-26 06:37:14 +04:00
2015-02-05 02:15:12 +03:00
return mDocShell - > FindItemWithName ( aName ,
static_cast < nsIDocShellTreeOwner * > ( mDocShellTreeOwner ) ,
aOriginalRequestor , _retval ) ;
2000-03-11 04:12:46 +03:00
}
2014-01-10 06:03:47 +04:00
nsIDocument *
nsWebBrowser : : GetDocument ( )
{
return mDocShell ? mDocShell - > GetDocument ( ) : nullptr ;
}
nsPIDOMWindow *
nsWebBrowser : : GetWindow ( )
{
return mDocShell ? mDocShell - > GetWindow ( ) : nullptr ;
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetTreeOwner ( nsIDocShellTreeOwner * * aTreeOwner )
2014-12-16 20:18:01 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aTreeOwner ) ;
* aTreeOwner = nullptr ;
if ( mDocShellTreeOwner ) {
if ( mDocShellTreeOwner - > mTreeOwner ) {
* aTreeOwner = mDocShellTreeOwner - > mTreeOwner ;
} else {
* aTreeOwner = mDocShellTreeOwner ;
2000-08-25 22:39:46 +04:00
}
2015-02-05 02:15:12 +03:00
}
NS_IF_ADDREF ( * aTreeOwner ) ;
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : SetTreeOwner ( nsIDocShellTreeOwner * aTreeOwner )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( EnsureDocShellTreeOwner ( ) , NS_ERROR_FAILURE ) ;
return mDocShellTreeOwner - > SetTreeOwner ( aTreeOwner ) ;
2000-03-11 04:12:46 +03:00
}
2007-05-07 01:06:28 +04:00
//*****************************************************************************
// nsWebBrowser::nsIDocShellTreeItem
//*****************************************************************************
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetChildCount ( int32_t * aChildCount )
2007-05-07 01:06:28 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aChildCount ) ;
* aChildCount = 0 ;
return NS_OK ;
2007-05-07 01:06:28 +04:00
}
NS_IMETHODIMP nsWebBrowser : : AddChild ( nsIDocShellTreeItem * aChild )
{
2015-02-05 02:15:12 +03:00
return NS_ERROR_UNEXPECTED ;
2007-05-07 01:06:28 +04:00
}
NS_IMETHODIMP nsWebBrowser : : RemoveChild ( nsIDocShellTreeItem * aChild )
{
2015-02-05 02:15:12 +03:00
return NS_ERROR_UNEXPECTED ;
2007-05-07 01:06:28 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetChildAt ( int32_t aIndex ,
2007-05-07 01:06:28 +04:00
nsIDocShellTreeItem * * aChild )
{
2015-02-05 02:15:12 +03:00
return NS_ERROR_UNEXPECTED ;
2007-05-07 01:06:28 +04:00
}
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : FindChildWithName ( const char16_t * aName ,
bool aRecurse , bool aSameType ,
nsIDocShellTreeItem * aRequestor ,
nsIDocShellTreeItem * aOriginalRequestor ,
nsIDocShellTreeItem * * _retval )
2007-05-07 01:06:28 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( _retval ) ;
2007-05-07 01:06:28 +04:00
2015-02-05 02:15:12 +03:00
* _retval = nullptr ;
return NS_OK ;
2007-05-07 01:06:28 +04:00
}
2000-03-11 04:12:46 +03:00
//*****************************************************************************
// nsWebBrowser::nsIWebNavigation
//*****************************************************************************
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : GetCanGoBack ( bool * aCanGoBack )
1999-11-07 13:06:38 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-11-07 13:06:38 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GetCanGoBack ( aCanGoBack ) ;
2000-03-11 04:12:46 +03:00
}
1999-11-07 13:06:38 +03:00
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : GetCanGoForward ( bool * aCanGoForward )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-11-07 13:06:38 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GetCanGoForward ( aCanGoForward ) ;
2000-03-11 04:12:46 +03:00
}
1999-11-07 13:06:38 +03:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GoBack ( )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GoBack ( ) ;
2000-03-11 04:12:46 +03:00
}
NS_IMETHODIMP nsWebBrowser : : GoForward ( )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GoForward ( ) ;
2000-03-11 04:12:46 +03:00
}
2014-02-20 17:43:53 +04:00
NS_IMETHODIMP nsWebBrowser : : LoadURIWithBase ( const char16_t * aURI ,
uint32_t aLoadFlags ,
nsIURI * aReferringURI ,
nsIInputStream * aPostDataStream ,
nsIInputStream * aExtraHeaderStream ,
nsIURI * aBaseURI )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2014-02-20 17:43:53 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > LoadURIWithBase ( aURI ,
aLoadFlags ,
aReferringURI ,
aPostDataStream ,
aExtraHeaderStream ,
aBaseURI ) ;
2014-02-20 17:43:53 +04:00
}
2014-01-04 19:02:17 +04:00
NS_IMETHODIMP nsWebBrowser : : LoadURI ( const char16_t * aURI ,
2012-08-22 19:56:38 +04:00
uint32_t aLoadFlags ,
2003-02-13 02:50:14 +03:00
nsIURI * aReferringURI ,
2001-12-01 01:35:33 +03:00
nsIInputStream * aPostDataStream ,
nsIInputStream * aExtraHeaderStream )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > LoadURI ( aURI ,
aLoadFlags ,
aReferringURI ,
aPostDataStream ,
aExtraHeaderStream ) ;
2000-03-11 04:12:46 +03:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : Reload ( uint32_t aReloadFlags )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > Reload ( aReloadFlags ) ;
2000-03-11 04:12:46 +03:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GotoIndex ( int32_t aIndex )
2000-06-24 03:54:30 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-06-24 03:54:30 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GotoIndex ( aIndex ) ;
2000-06-24 03:54:30 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : Stop ( uint32_t aStopFlags )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > Stop ( aStopFlags ) ;
2000-03-11 04:12:46 +03:00
}
2000-08-30 15:37:41 +04:00
NS_IMETHODIMP nsWebBrowser : : GetCurrentURI ( nsIURI * * aURI )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GetCurrentURI ( aURI ) ;
1999-11-07 13:06:38 +03:00
}
2003-02-13 02:50:14 +03:00
NS_IMETHODIMP nsWebBrowser : : GetReferringURI ( nsIURI * * aURI )
2001-12-01 01:35:33 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2001-12-01 01:35:33 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GetReferringURI ( aURI ) ;
2001-12-01 01:35:33 +03:00
}
2000-02-24 06:51:35 +03:00
NS_IMETHODIMP nsWebBrowser : : SetSessionHistory ( nsISHistory * aSessionHistory )
{
2015-02-05 02:15:12 +03:00
if ( mDocShell )
return mDocShellAsNav - > SetSessionHistory ( aSessionHistory ) ;
else
mInitInfo - > sessionHistory = aSessionHistory ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
2000-02-24 06:51:35 +03:00
}
NS_IMETHODIMP nsWebBrowser : : GetSessionHistory ( nsISHistory * * aSessionHistory )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aSessionHistory ) ;
if ( mDocShell )
return mDocShellAsNav - > GetSessionHistory ( aSessionHistory ) ;
else
* aSessionHistory = mInitInfo - > sessionHistory ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
NS_IF_ADDREF ( * aSessionHistory ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
2000-02-24 06:51:35 +03:00
}
1999-10-23 11:56:27 +04:00
2000-08-25 22:39:46 +04:00
NS_IMETHODIMP nsWebBrowser : : GetDocument ( nsIDOMDocument * * aDocument )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-03-14 10:05:08 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsNav - > GetDocument ( aDocument ) ;
1999-10-23 11:56:27 +04:00
}
2000-08-25 22:39:46 +04:00
//*****************************************************************************
// nsWebBrowser::nsIWebBrowserSetup
//*****************************************************************************
2000-03-14 10:05:08 +03:00
2000-08-25 22:39:46 +04:00
/* void setProperty (in unsigned long aId, in unsigned long aValue); */
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetProperty ( uint32_t aId , uint32_t aValue )
2000-08-25 22:39:46 +04:00
{
2015-02-05 02:15:12 +03:00
nsresult rv = NS_OK ;
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
switch ( aId ) {
case nsIWebBrowserSetup : : SETUP_ALLOW_PLUGINS :
2000-08-25 22:39:46 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowPlugins ( ! ! aValue ) ;
break ;
}
case nsIWebBrowserSetup : : SETUP_ALLOW_JAVASCRIPT :
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowJavascript ( ! ! aValue ) ;
break ;
}
case nsIWebBrowserSetup : : SETUP_ALLOW_META_REDIRECTS :
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowMetaRedirects ( ! ! aValue ) ;
break ;
}
2001-04-22 02:22:15 +04:00
case nsIWebBrowserSetup : : SETUP_ALLOW_SUBFRAMES :
2015-02-05 02:15:12 +03:00
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowSubframes ( ! ! aValue ) ;
2001-04-22 02:22:15 +04:00
break ;
2015-02-05 02:15:12 +03:00
}
2001-05-22 02:42:46 +04:00
case nsIWebBrowserSetup : : SETUP_ALLOW_IMAGES :
2015-02-05 02:15:12 +03:00
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowImages ( ! ! aValue ) ;
2001-05-22 03:20:18 +04:00
break ;
2015-02-05 02:15:12 +03:00
}
2009-05-17 18:22:54 +04:00
case nsIWebBrowserSetup : : SETUP_ALLOW_DNS_PREFETCH :
2015-02-05 02:15:12 +03:00
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
mDocShell - > SetAllowDNSPrefetch ( ! ! aValue ) ;
2010-08-11 00:06:38 +04:00
break ;
2015-02-05 02:15:12 +03:00
}
2001-05-19 22:31:20 +04:00
case nsIWebBrowserSetup : : SETUP_USE_GLOBAL_HISTORY :
2015-02-05 02:15:12 +03:00
{
NS_ENSURE_STATE ( mDocShell ) ;
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
rv = EnableGlobalHistory ( ! ! aValue ) ;
mShouldEnableHistory = aValue ;
2001-05-19 22:31:20 +04:00
break ;
2015-02-05 02:15:12 +03:00
}
2001-06-26 05:19:11 +04:00
case nsIWebBrowserSetup : : SETUP_FOCUS_DOC_BEFORE_CONTENT :
2015-02-05 02:15:12 +03:00
{
// obsolete
2001-06-26 05:19:11 +04:00
break ;
2015-02-05 02:15:12 +03:00
}
2002-03-09 02:58:50 +03:00
case nsIWebBrowserSetup : : SETUP_IS_CHROME_WRAPPER :
2015-02-05 02:15:12 +03:00
{
NS_ENSURE_TRUE ( ( aValue = = static_cast < uint32_t > ( true ) | |
aValue = = static_cast < uint32_t > ( false ) ) ,
NS_ERROR_INVALID_ARG ) ;
SetItemType ( aValue ? static_cast < int32_t > ( typeChromeWrapper )
: static_cast < int32_t > ( typeContentWrapper ) ) ;
2002-03-09 02:58:50 +03:00
break ;
2015-02-05 02:15:12 +03:00
}
default :
rv = NS_ERROR_INVALID_ARG ;
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
}
return rv ;
1999-10-23 11:56:27 +04:00
}
2001-09-24 01:03:03 +04:00
//*****************************************************************************
// nsWebBrowser::nsIWebProgressListener
//*****************************************************************************
2002-05-17 00:57:37 +04:00
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : OnStateChange ( nsIWebProgress * aWebProgress ,
nsIRequest * aRequest ,
uint32_t aStateFlags ,
nsresult aStatus )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mPersist ) {
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
}
if ( aStateFlags & STATE_IS_NETWORK & & aStateFlags & STATE_STOP ) {
mPersist = nullptr ;
}
if ( mProgressListener ) {
return mProgressListener - > OnStateChange ( aWebProgress , aRequest , aStateFlags , aStatus ) ;
}
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : OnProgressChange ( nsIWebProgress * aWebProgress ,
nsIRequest * aRequest ,
int32_t aCurSelfProgress ,
int32_t aMaxSelfProgress ,
int32_t aCurTotalProgress ,
int32_t aMaxTotalProgress )
{
if ( mPersist ) {
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
}
if ( mProgressListener ) {
return mProgressListener - > OnProgressChange ( aWebProgress , aRequest , aCurSelfProgress , aMaxSelfProgress , aCurTotalProgress , aMaxTotalProgress ) ;
}
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
2011-11-10 18:01:11 +04:00
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : OnLocationChange ( nsIWebProgress * aWebProgress ,
nsIRequest * aRequest ,
nsIURI * location ,
uint32_t aFlags )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mProgressListener ) {
return mProgressListener - > OnLocationChange ( aWebProgress , aRequest , location , aFlags ) ;
}
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : OnStatusChange ( nsIWebProgress * aWebProgress ,
nsIRequest * aRequest ,
nsresult aStatus ,
const char16_t * aMessage )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mProgressListener ) {
return mProgressListener - > OnStatusChange ( aWebProgress , aRequest , aStatus , aMessage ) ;
}
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
2002-05-17 00:57:37 +04:00
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : OnSecurityChange ( nsIWebProgress * aWebProgress ,
nsIRequest * aRequest ,
uint32_t state )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
if ( mProgressListener ) {
return mProgressListener - > OnSecurityChange ( aWebProgress , aRequest , state ) ;
}
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
2000-11-30 03:43:42 +03:00
//*****************************************************************************
// nsWebBrowser::nsIWebBrowserPersist
//*****************************************************************************
2001-09-24 01:03:03 +04:00
/* attribute unsigned long persistFlags; */
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetPersistFlags ( uint32_t * aPersistFlags )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aPersistFlags ) ;
nsresult rv = NS_OK ;
if ( mPersist ) {
rv = mPersist - > GetPersistFlags ( & mPersistFlags ) ;
}
* aPersistFlags = mPersistFlags ;
return rv ;
2001-09-24 01:03:03 +04:00
}
2015-02-05 02:15:12 +03:00
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetPersistFlags ( uint32_t aPersistFlags )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
nsresult rv = NS_OK ;
mPersistFlags = aPersistFlags ;
if ( mPersist ) {
rv = mPersist - > SetPersistFlags ( mPersistFlags ) ;
mPersist - > GetPersistFlags ( & mPersistFlags ) ;
}
return rv ;
2001-09-24 01:03:03 +04:00
}
/* readonly attribute unsigned long currentState; */
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetCurrentState ( uint32_t * aCurrentState )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aCurrentState ) ;
if ( mPersist ) {
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
}
* aCurrentState = mPersistCurrentState ;
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
2012-08-06 16:02:31 +04:00
/* readonly attribute nsresult result; */
NS_IMETHODIMP nsWebBrowser : : GetResult ( nsresult * aResult )
2001-09-24 01:03:03 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aResult ) ;
if ( mPersist ) {
mPersist - > GetResult ( & mPersistResult ) ;
}
* aResult = mPersistResult ;
return NS_OK ;
2001-09-24 01:03:03 +04:00
}
2000-11-30 03:43:42 +03:00
/* attribute nsIWebBrowserPersistProgress progressListener; */
2001-09-24 01:03:03 +04:00
NS_IMETHODIMP nsWebBrowser : : GetProgressListener ( nsIWebProgressListener * * aProgressListener )
2000-11-30 03:43:42 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aProgressListener ) ;
* aProgressListener = mProgressListener ;
NS_IF_ADDREF ( * aProgressListener ) ;
return NS_OK ;
2000-11-30 03:43:42 +03:00
}
2014-12-16 20:18:01 +03:00
2001-09-24 01:03:03 +04:00
NS_IMETHODIMP nsWebBrowser : : SetProgressListener ( nsIWebProgressListener * aProgressListener )
2000-11-30 03:43:42 +03:00
{
2015-02-05 02:15:12 +03:00
mProgressListener = aProgressListener ;
return NS_OK ;
2000-11-30 03:43:42 +03:00
}
2000-03-14 10:05:08 +03:00
2014-11-18 16:47:14 +03:00
/* void saveURI (in nsIURI aURI, in nsIURI aReferrer, in unsigned long aReferrerPolicy
2003-01-09 02:53:10 +03:00
in nsISupports aCacheKey , in nsIInputStream aPostData , in wstring aExtraHeaders ,
2012-10-04 23:07:51 +04:00
in nsISupports aFile , in nsILoadContext aPrivacyContext ) ; */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : SaveURI ( nsIURI * aURI ,
nsISupports * aCacheKey ,
nsIURI * aReferrer ,
uint32_t aReferrerPolicy ,
nsIInputStream * aPostData ,
const char * aExtraHeaders ,
nsISupports * aFile ,
nsILoadContext * aPrivacyContext )
{
return SavePrivacyAwareURI ( aURI , aCacheKey , aReferrer , aReferrerPolicy ,
aPostData , aExtraHeaders ,
aFile , aPrivacyContext & & aPrivacyContext - > UsePrivateBrowsing ( ) ) ;
}
NS_IMETHODIMP nsWebBrowser : : SavePrivacyAwareURI ( nsIURI * aURI ,
nsISupports * aCacheKey ,
nsIURI * aReferrer ,
uint32_t aReferrerPolicy ,
nsIInputStream * aPostData ,
const char * aExtraHeaders ,
nsISupports * aFile ,
bool aIsPrivate )
{
if ( mPersist ) {
uint32_t currentState ;
mPersist - > GetCurrentState ( & currentState ) ;
if ( currentState = = PERSIST_STATE_FINISHED ) {
mPersist = nullptr ;
2015-02-05 02:15:12 +03:00
} else {
2015-02-05 02:15:12 +03:00
// You can't save again until the last save has completed
return NS_ERROR_FAILURE ;
2001-09-24 01:03:03 +04:00
}
2015-02-05 02:15:12 +03:00
}
2001-09-24 01:03:03 +04:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIURI > uri ;
if ( aURI ) {
uri = aURI ;
} else {
nsresult rv = GetCurrentURI ( getter_AddRefs ( uri ) ) ;
2015-02-05 02:15:12 +03:00
if ( NS_FAILED ( rv ) ) {
2015-02-05 02:15:12 +03:00
return NS_ERROR_FAILURE ;
2000-11-30 03:43:42 +03:00
}
2015-02-05 02:15:12 +03:00
}
// Create a throwaway persistence object to do the work
nsresult rv ;
mPersist = do_CreateInstance ( NS_WEBBROWSERPERSIST_CONTRACTID , & rv ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
mPersist - > SetProgressListener ( this ) ;
mPersist - > SetPersistFlags ( mPersistFlags ) ;
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
rv = mPersist - > SavePrivacyAwareURI ( uri , aCacheKey , aReferrer , aReferrerPolicy ,
aPostData , aExtraHeaders , aFile , aIsPrivate ) ;
if ( NS_FAILED ( rv ) ) {
mPersist = nullptr ;
}
return rv ;
2000-11-30 03:43:42 +03:00
}
2004-09-07 18:42:23 +04:00
/* void saveChannel (in nsIChannel aChannel, in nsISupports aFile); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : SaveChannel ( nsIChannel * aChannel , nsISupports * aFile )
{
if ( mPersist ) {
uint32_t currentState ;
mPersist - > GetCurrentState ( & currentState ) ;
if ( currentState = = PERSIST_STATE_FINISHED ) {
mPersist = nullptr ;
} else {
// You can't save again until the last save has completed
return NS_ERROR_FAILURE ;
2004-09-07 18:42:23 +04:00
}
2015-02-05 02:15:12 +03:00
}
2004-09-07 18:42:23 +04:00
2015-02-05 02:15:12 +03:00
// Create a throwaway persistence object to do the work
nsresult rv ;
mPersist = do_CreateInstance ( NS_WEBBROWSERPERSIST_CONTRACTID , & rv ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
mPersist - > SetProgressListener ( this ) ;
mPersist - > SetPersistFlags ( mPersistFlags ) ;
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
rv = mPersist - > SaveChannel ( aChannel , aFile ) ;
if ( NS_FAILED ( rv ) ) {
mPersist = nullptr ;
}
return rv ;
2004-09-07 18:42:23 +04:00
}
2002-01-14 15:41:27 +03:00
/* void saveDocument (in nsIDOMDocument document, in nsISupports aFile, in nsISupports aDataPath); */
2015-02-05 02:15:12 +03:00
NS_IMETHODIMP nsWebBrowser : : SaveDocument ( nsIDOMDocument * aDocument ,
nsISupports * aFile ,
nsISupports * aDataPath ,
const char * aOutputContentType ,
uint32_t aEncodingFlags ,
uint32_t aWrapColumn )
{
if ( mPersist ) {
uint32_t currentState ;
mPersist - > GetCurrentState ( & currentState ) ;
if ( currentState = = PERSIST_STATE_FINISHED ) {
mPersist = nullptr ;
} else {
// You can't save again until the last save has completed
return NS_ERROR_FAILURE ;
2000-11-30 03:43:42 +03:00
}
2015-02-05 02:15:12 +03:00
}
2000-11-30 03:43:42 +03:00
2015-02-05 02:15:12 +03:00
// Use the specified DOM document, or if none is specified, the one
// attached to the web browser.
2000-11-30 03:43:42 +03:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIDOMDocument > doc ;
if ( aDocument ) {
doc = do_QueryInterface ( aDocument ) ;
} else {
GetDocument ( getter_AddRefs ( doc ) ) ;
}
if ( ! doc ) {
return NS_ERROR_FAILURE ;
}
2000-11-30 03:43:42 +03:00
2015-02-05 02:15:12 +03:00
// Create a throwaway persistence object to do the work
nsresult rv ;
mPersist = do_CreateInstance ( NS_WEBBROWSERPERSIST_CONTRACTID , & rv ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
mPersist - > SetProgressListener ( this ) ;
mPersist - > SetPersistFlags ( mPersistFlags ) ;
mPersist - > GetCurrentState ( & mPersistCurrentState ) ;
rv = mPersist - > SaveDocument ( doc , aFile , aDataPath , aOutputContentType , aEncodingFlags , aWrapColumn ) ;
if ( NS_FAILED ( rv ) ) {
mPersist = nullptr ;
}
return rv ;
2000-11-30 03:43:42 +03:00
}
2001-09-24 01:03:03 +04:00
/* void cancelSave(); */
NS_IMETHODIMP nsWebBrowser : : CancelSave ( )
{
2015-02-05 02:15:12 +03:00
if ( mPersist ) {
return mPersist - > CancelSave ( ) ;
}
2001-09-24 01:03:03 +04:00
return NS_OK ;
}
2005-04-10 16:37:36 +04:00
/* void cancel(nsresult aReason); */
NS_IMETHODIMP nsWebBrowser : : Cancel ( nsresult aReason )
{
2015-02-05 02:15:12 +03:00
if ( mPersist ) {
return mPersist - > Cancel ( aReason ) ;
}
return NS_OK ;
2005-04-10 16:37:36 +04:00
}
1999-10-23 11:56:27 +04:00
//*****************************************************************************
1999-11-17 12:00:05 +03:00
// nsWebBrowser::nsIBaseWindow
1999-10-23 11:56:27 +04:00
//*****************************************************************************
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : InitWindow ( nativeWindow aParentNativeWindow ,
2014-12-16 20:18:01 +03:00
nsIWidget * aParentWidget , int32_t aX , int32_t aY , int32_t aCX , int32_t aCY )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG ( aParentNativeWindow | | aParentWidget ) ;
NS_ENSURE_STATE ( ! mDocShell | | mInitInfo ) ;
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
if ( aParentWidget )
NS_ENSURE_SUCCESS ( SetParentWidget ( aParentWidget ) , NS_ERROR_FAILURE ) ;
else
NS_ENSURE_SUCCESS ( SetParentNativeWindow ( aParentNativeWindow ) ,
NS_ERROR_FAILURE ) ;
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( SetPositionAndSize ( aX , aY , aCX , aCY , false ) ,
NS_ERROR_FAILURE ) ;
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-27 06:45:49 +04:00
}
1999-10-23 11:56:27 +04:00
1999-10-27 06:45:49 +04:00
NS_IMETHODIMP nsWebBrowser : : Create ( )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( ! mDocShell & & ( mParentNativeWindow | | mParentWidget ) ) ;
nsresult rv = EnsureDocShellTreeOwner ( ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIWidget > docShellParentWidget ( mParentWidget ) ;
if ( ! mParentWidget ) {
// Create the widget
mInternalWidget = do_CreateInstance ( kChildCID , & rv ) ;
2009-07-23 02:31:04 +04:00
NS_ENSURE_SUCCESS ( rv , rv ) ;
2000-03-28 11:40:10 +04:00
2015-02-05 02:15:12 +03:00
docShellParentWidget = mInternalWidget ;
nsWidgetInitData widgetInit ;
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
widgetInit . clipChildren = true ;
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
widgetInit . mWindowType = eWindowType_child ;
nsIntRect bounds ( mInitInfo - > x , mInitInfo - > y , mInitInfo - > cx , mInitInfo - > cy ) ;
2003-03-07 02:07:00 +03:00
2015-02-05 02:15:12 +03:00
mInternalWidget - > SetWidgetListener ( this ) ;
mInternalWidget - > Create ( nullptr , mParentNativeWindow , bounds , nullptr , & widgetInit ) ;
}
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIDocShell > docShell ( do_CreateInstance ( " @mozilla.org/docshell;1 " , & rv ) ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
rv = SetDocShell ( docShell ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
// get the system default window background colour
LookAndFeel : : GetColor ( LookAndFeel : : eColorID_WindowBackground ,
& mBackgroundColor ) ;
// the docshell has been set so we now have our listener registrars.
if ( mListenerArray ) {
// we had queued up some listeners, let's register them now.
uint32_t count = mListenerArray - > Length ( ) ;
uint32_t i = 0 ;
NS_ASSERTION ( count > 0 , " array construction problem " ) ;
while ( i < count ) {
nsWebBrowserListenerState & state = mListenerArray - > ElementAt ( i ) ;
nsCOMPtr < nsISupports > listener = do_QueryReferent ( state . mWeakPtr ) ;
NS_ASSERTION ( listener , " bad listener " ) ;
( void ) BindListener ( listener , state . mID ) ;
i + + ;
}
mListenerArray = nullptr ;
}
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
// HACK ALERT - this registration registers the nsDocShellTreeOwner as a
// nsIWebBrowserListener so it can setup its MouseListener in one of the
// progress callbacks. If we can register the MouseListener another way, this
// registration can go away, and nsDocShellTreeOwner can stop implementing
// nsIWebProgressListener.
nsCOMPtr < nsISupports > supports = nullptr ;
( void ) mDocShellTreeOwner - > QueryInterface ( NS_GET_IID ( nsIWebProgressListener ) ,
static_cast < void * * > ( getter_AddRefs ( supports ) ) ) ;
( void ) BindListener ( supports , NS_GET_IID ( nsIWebProgressListener ) ) ;
NS_ENSURE_SUCCESS ( mDocShellAsWin - > InitWindow ( nullptr ,
docShellParentWidget , mInitInfo - > x , mInitInfo - > y , mInitInfo - > cx ,
mInitInfo - > cy ) , NS_ERROR_FAILURE ) ;
mDocShell - > SetName ( mInitInfo - > name ) ;
if ( mContentType = = typeChromeWrapper ) {
mDocShell - > SetItemType ( nsIDocShellTreeItem : : typeChrome ) ;
} else {
mDocShell - > SetItemType ( nsIDocShellTreeItem : : typeContent ) ;
}
mDocShell - > SetTreeOwner ( mDocShellTreeOwner ) ;
2002-04-24 03:21:25 +04:00
2015-02-05 02:15:12 +03:00
// If the webbrowser is a content docshell item then we won't hear any
// events from subframes. To solve that we install our own chrome event handler
// that always gets called (even for subframes) for any bubbling event.
2010-08-11 00:06:38 +04:00
2015-02-05 02:15:12 +03:00
if ( ! mInitInfo - > sessionHistory ) {
mInitInfo - > sessionHistory = do_CreateInstance ( NS_SHISTORY_CONTRACTID , & rv ) ;
NS_ENSURE_SUCCESS ( rv , rv ) ;
}
mDocShellAsNav - > SetSessionHistory ( mInitInfo - > sessionHistory ) ;
2001-06-02 04:35:39 +04:00
2015-02-05 02:15:12 +03:00
if ( XRE_GetProcessType ( ) = = GeckoProcessType_Default ) {
// Hook up global history. Do not fail if we can't - just warn.
rv = EnableGlobalHistory ( mShouldEnableHistory ) ;
NS_WARN_IF_FALSE ( NS_SUCCEEDED ( rv ) , " EnableGlobalHistory() failed " ) ;
}
2000-03-11 04:12:46 +03:00
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( mDocShellAsWin - > Create ( ) , NS_ERROR_FAILURE ) ;
// Hook into the OnSecurityChange() notification for lock/unlock icon
// updates
nsCOMPtr < nsIDOMWindow > domWindow ;
rv = GetContentDOMWindow ( getter_AddRefs ( domWindow ) ) ;
if ( NS_SUCCEEDED ( rv ) ) {
// this works because the implementation of nsISecureBrowserUI
// (nsSecureBrowserUIImpl) gets a docShell from the domWindow,
// and calls docShell->SetSecurityUI(this);
nsCOMPtr < nsISecureBrowserUI > securityUI =
do_CreateInstance ( NS_SECURE_BROWSER_UI_CONTRACTID , & rv ) ;
if ( NS_SUCCEEDED ( rv ) )
securityUI - > Init ( domWindow ) ;
}
2001-06-02 04:35:39 +04:00
2015-02-05 02:15:12 +03:00
mDocShellTreeOwner - > AddToWatcher ( ) ; // evil twin of Remove in SetDocShell(0)
mDocShellTreeOwner - > AddChromeListeners ( ) ;
2001-02-07 08:03:09 +03:00
2015-02-05 02:15:12 +03:00
mInitInfo = nullptr ;
2000-08-16 12:50:00 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : Destroy ( )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
InternalDestroy ( ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
if ( ! mInitInfo ) {
mInitInfo = new nsWebBrowserInitInfo ( ) ;
}
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2012-10-16 23:41:19 +04:00
NS_IMETHODIMP nsWebBrowser : : GetUnscaledDevicePixelsPerCSSPixel ( double * aScale )
{
2013-09-18 04:45:19 +04:00
* aScale = mParentWidget ? mParentWidget - > GetDefaultScale ( ) . scale : 1.0 ;
2012-10-16 23:41:19 +04:00
return NS_OK ;
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetPosition ( int32_t aX , int32_t aY )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
int32_t cx = 0 ;
int32_t cy = 0 ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
GetSize ( & cx , & cy ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return SetPositionAndSize ( aX , aY , cx , cy , false ) ;
2000-03-11 04:12:46 +03:00
}
1999-10-27 06:45:49 +04:00
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetPosition ( int32_t * aX , int32_t * aY )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
return GetPositionAndSize ( aX , aY , nullptr , nullptr ) ;
1999-10-23 11:56:27 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetSize ( int32_t aCX , int32_t aCY , bool aRepaint )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
int32_t x = 0 ;
int32_t y = 0 ;
1999-10-26 06:26:57 +04:00
2015-02-05 02:15:12 +03:00
GetPosition ( & x , & y ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return SetPositionAndSize ( x , y , aCX , aCY , aRepaint ) ;
2000-03-11 04:12:46 +03:00
}
1999-10-27 06:45:49 +04:00
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetSize ( int32_t * aCX , int32_t * aCY )
2000-03-11 04:12:46 +03:00
{
2015-02-05 02:15:12 +03:00
return GetPositionAndSize ( nullptr , nullptr , aCX , aCY ) ;
1999-10-23 11:56:27 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetPositionAndSize ( int32_t aX , int32_t aY ,
2015-02-05 02:15:12 +03:00
int32_t aCX , int32_t aCY ,
bool aRepaint )
{
if ( ! mDocShell ) {
mInitInfo - > x = aX ;
mInitInfo - > y = aY ;
mInitInfo - > cx = aCX ;
mInitInfo - > cy = aCY ;
} else {
int32_t doc_x = aX ;
int32_t doc_y = aY ;
// If there is an internal widget we need to make the docShell coordinates
// relative to the internal widget rather than the calling app's parent.
// We also need to resize our widget then.
if ( mInternalWidget ) {
doc_x = doc_y = 0 ;
NS_ENSURE_SUCCESS ( mInternalWidget - > Resize ( aX , aY , aCX , aCY , aRepaint ) ,
NS_ERROR_FAILURE ) ;
}
// Now reposition/ resize the doc
NS_ENSURE_SUCCESS ( mDocShellAsWin - > SetPositionAndSize ( doc_x , doc_y , aCX , aCY ,
aRepaint ) , NS_ERROR_FAILURE ) ;
}
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2014-12-16 20:18:01 +03:00
NS_IMETHODIMP nsWebBrowser : : GetPositionAndSize ( int32_t * aX , int32_t * aY ,
2015-02-05 02:15:12 +03:00
int32_t * aCX , int32_t * aCY )
{
if ( ! mDocShell ) {
2015-02-05 02:15:12 +03:00
if ( aX ) {
2015-02-05 02:15:12 +03:00
* aX = mInitInfo - > x ;
2015-02-05 02:15:12 +03:00
}
if ( aY ) {
2015-02-05 02:15:12 +03:00
* aY = mInitInfo - > y ;
2015-02-05 02:15:12 +03:00
}
if ( aCX ) {
2015-02-05 02:15:12 +03:00
* aCX = mInitInfo - > cx ;
2015-02-05 02:15:12 +03:00
}
if ( aCY ) {
2015-02-05 02:15:12 +03:00
* aCY = mInitInfo - > cy ;
2015-02-05 02:15:12 +03:00
}
2015-02-05 02:15:12 +03:00
} else if ( mInternalWidget ) {
nsIntRect bounds ;
NS_ENSURE_SUCCESS ( mInternalWidget - > GetBounds ( bounds ) , NS_ERROR_FAILURE ) ;
2015-02-05 02:15:12 +03:00
if ( aX ) {
2015-02-05 02:15:12 +03:00
* aX = bounds . x ;
2015-02-05 02:15:12 +03:00
}
if ( aY ) {
2015-02-05 02:15:12 +03:00
* aY = bounds . y ;
2015-02-05 02:15:12 +03:00
}
if ( aCX ) {
2015-02-05 02:15:12 +03:00
* aCX = bounds . width ;
2015-02-05 02:15:12 +03:00
}
if ( aCY ) {
2015-02-05 02:15:12 +03:00
* aCY = bounds . height ;
2015-02-05 02:15:12 +03:00
}
2015-02-05 02:15:12 +03:00
return NS_OK ;
} else {
// Can directly return this as it is the
// same interface, thus same returns.
return mDocShellAsWin - > GetPositionAndSize ( aX , aY , aCX , aCY ) ;
}
return NS_OK ;
2000-02-01 03:14:12 +03:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : Repaint ( bool aForce )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
// Can directly return this as it is the
// same interface, thus same returns.
return mDocShellAsWin - > Repaint ( aForce ) ;
2015-02-05 02:15:12 +03:00
}
1999-10-23 11:56:27 +04:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetParentWidget ( nsIWidget * * aParentWidget )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aParentWidget ) ;
1999-10-26 06:26:57 +04:00
2015-02-05 02:15:12 +03:00
* aParentWidget = mParentWidget ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
NS_IF_ADDREF ( * aParentWidget ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : SetParentWidget ( nsIWidget * aParentWidget )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( ! mDocShell ) ;
1999-10-23 11:56:27 +04:00
2015-02-05 02:15:12 +03:00
mParentWidget = aParentWidget ;
if ( mParentWidget )
mParentNativeWindow = mParentWidget - > GetNativeData ( NS_NATIVE_WIDGET ) ;
else
mParentNativeWindow = nullptr ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-27 06:45:49 +04:00
}
1999-10-23 11:56:27 +04:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : GetParentNativeWindow ( nativeWindow * aParentNativeWindow )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aParentNativeWindow ) ;
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
* aParentNativeWindow = mParentNativeWindow ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : SetParentNativeWindow ( nativeWindow aParentNativeWindow )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( ! mDocShell ) ;
2007-10-02 03:20:37 +04:00
2015-02-05 02:15:12 +03:00
mParentNativeWindow = aParentNativeWindow ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2012-07-25 05:35:32 +04:00
NS_IMETHODIMP nsWebBrowser : : GetNativeHandle ( nsAString & aNativeHandle )
{
2015-02-05 02:15:12 +03:00
// the nativeHandle should be accessed from nsIXULWindow
return NS_ERROR_NOT_IMPLEMENTED ;
2012-07-25 05:35:32 +04:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : GetVisibility ( bool * visibility )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( visibility ) ;
1999-10-26 06:26:57 +04:00
2015-02-05 02:15:12 +03:00
if ( ! mDocShell )
* visibility = mInitInfo - > visible ;
else
NS_ENSURE_SUCCESS ( mDocShellAsWin - > GetVisibility ( visibility ) , NS_ERROR_FAILURE ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : SetVisibility ( bool aVisibility )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
if ( ! mDocShell ) {
mInitInfo - > visible = aVisibility ;
} else {
NS_ENSURE_SUCCESS ( mDocShellAsWin - > SetVisibility ( aVisibility ) , NS_ERROR_FAILURE ) ;
if ( mInternalWidget ) {
mInternalWidget - > Show ( aVisibility ) ;
}
}
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2012-07-23 09:19:08 +04:00
NS_IMETHODIMP nsWebBrowser : : GetEnabled ( bool * aEnabled )
2002-03-01 02:22:55 +03:00
{
2012-07-23 09:19:08 +04:00
if ( mInternalWidget ) {
* aEnabled = mInternalWidget - > IsEnabled ( ) ;
return NS_OK ;
}
2002-03-01 02:22:55 +03:00
return NS_ERROR_FAILURE ;
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : SetEnabled ( bool aEnabled )
2002-03-01 02:22:55 +03:00
{
if ( mInternalWidget )
return mInternalWidget - > Enable ( aEnabled ) ;
return NS_ERROR_FAILURE ;
}
1999-10-23 11:56:27 +04:00
NS_IMETHODIMP nsWebBrowser : : GetMainWidget ( nsIWidget * * mainWidget )
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( mainWidget ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
if ( mInternalWidget )
* mainWidget = mInternalWidget ;
else
* mainWidget = mParentWidget ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
NS_IF_ADDREF ( * mainWidget ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
NS_IMETHODIMP nsWebBrowser : : SetFocus ( )
{
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDOMWindow > window = GetWindow ( ) ;
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
NS_ENSURE_TRUE ( window , NS_ERROR_FAILURE ) ;
1999-11-05 12:07:57 +03:00
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
return fm ? fm - > SetFocusedWindow ( window ) : NS_OK ;
1999-10-23 11:56:27 +04:00
}
2014-01-04 19:02:17 +04:00
NS_IMETHODIMP nsWebBrowser : : GetTitle ( char16_t * * aTitle )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_ARG_POINTER ( aTitle ) ;
NS_ENSURE_STATE ( mDocShell ) ;
1999-10-26 06:26:57 +04:00
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( mDocShellAsWin - > GetTitle ( aTitle ) , NS_ERROR_FAILURE ) ;
1999-11-05 12:07:57 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
2014-01-04 19:02:17 +04:00
NS_IMETHODIMP nsWebBrowser : : SetTitle ( const char16_t * aTitle )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-11-05 12:07:57 +03:00
2015-02-05 02:15:12 +03:00
NS_ENSURE_SUCCESS ( mDocShellAsWin - > SetTitle ( aTitle ) , NS_ERROR_FAILURE ) ;
1999-11-05 12:07:57 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
1999-10-23 11:56:27 +04:00
}
//*****************************************************************************
// nsWebBrowser::nsIScrollable
//*****************************************************************************
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : GetDefaultScrollbarPreferences ( int32_t aScrollOrientation ,
2015-02-05 02:15:12 +03:00
int32_t * aScrollbarPref )
2000-02-29 09:51:48 +03:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
2000-02-29 09:51:48 +03:00
2015-02-05 02:15:12 +03:00
return mDocShellAsScrollable - > GetDefaultScrollbarPreferences ( aScrollOrientation ,
aScrollbarPref ) ;
2000-02-29 09:51:48 +03:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : SetDefaultScrollbarPreferences ( int32_t aScrollOrientation ,
2015-02-05 02:15:12 +03:00
int32_t aScrollbarPref )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsScrollable - > SetDefaultScrollbarPreferences ( aScrollOrientation ,
aScrollbarPref ) ;
2000-02-29 09:51:48 +03:00
}
2011-09-29 10:19:26 +04:00
NS_IMETHODIMP nsWebBrowser : : GetScrollbarVisibility ( bool * aVerticalVisible ,
2015-02-05 02:15:12 +03:00
bool * aHorizontalVisible )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsScrollable - > GetScrollbarVisibility ( aVerticalVisible ,
aHorizontalVisible ) ;
1999-10-23 11:56:27 +04:00
}
//*****************************************************************************
// nsWebBrowser::nsITextScroll
2014-12-16 20:18:01 +03:00
//*****************************************************************************
1999-10-23 11:56:27 +04:00
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : ScrollByLines ( int32_t aNumLines )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsTextScroll - > ScrollByLines ( aNumLines ) ;
1999-10-23 11:56:27 +04:00
}
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : ScrollByPages ( int32_t aNumPages )
1999-10-23 11:56:27 +04:00
{
2015-02-05 02:15:12 +03:00
NS_ENSURE_STATE ( mDocShell ) ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
return mDocShellAsTextScroll - > ScrollByPages ( aNumPages ) ;
1999-10-26 06:26:57 +04:00
}
//*****************************************************************************
// nsWebBrowser: Listener Helpers
2014-12-16 20:18:01 +03:00
//*****************************************************************************
1999-10-26 06:26:57 +04:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : SetDocShell ( nsIDocShell * aDocShell )
1999-10-27 06:45:49 +04:00
{
2015-02-05 02:15:12 +03:00
nsCOMPtr < nsIDocShell > kungFuDeathGrip ( mDocShell ) ;
if ( aDocShell ) {
NS_ENSURE_TRUE ( ! mDocShell , NS_ERROR_FAILURE ) ;
nsCOMPtr < nsIInterfaceRequestor > req ( do_QueryInterface ( aDocShell ) ) ;
nsCOMPtr < nsIBaseWindow > baseWin ( do_QueryInterface ( aDocShell ) ) ;
nsCOMPtr < nsIWebNavigation > nav ( do_QueryInterface ( aDocShell ) ) ;
nsCOMPtr < nsIScrollable > scrollable ( do_QueryInterface ( aDocShell ) ) ;
nsCOMPtr < nsITextScroll > textScroll ( do_QueryInterface ( aDocShell ) ) ;
nsCOMPtr < nsIWebProgress > progress ( do_GetInterface ( aDocShell ) ) ;
NS_ENSURE_TRUE ( req & & baseWin & & nav & & scrollable & & textScroll & & progress ,
NS_ERROR_FAILURE ) ;
mDocShell = aDocShell ;
mDocShellAsReq = req ;
mDocShellAsWin = baseWin ;
mDocShellAsNav = nav ;
mDocShellAsScrollable = scrollable ;
mDocShellAsTextScroll = textScroll ;
mWebProgress = progress ;
// By default, do not allow DNS prefetch, so we don't break our frozen
// API. Embeddors who decide to enable it should do so manually.
mDocShell - > SetAllowDNSPrefetch ( false ) ;
// It's possible to call setIsActive() on us before we have a docshell.
// If we're getting a docshell now, pass along our desired value. The
// default here (true) matches the default of the docshell, so this is
// a no-op unless setIsActive(false) has been called on us.
mDocShell - > SetIsActive ( mIsActive ) ;
} else {
if ( mDocShellTreeOwner )
mDocShellTreeOwner - > RemoveFromWatcher ( ) ; // evil twin of Add in Create()
if ( mDocShellAsWin )
mDocShellAsWin - > Destroy ( ) ;
mDocShell = nullptr ;
mDocShellAsReq = nullptr ;
mDocShellAsWin = nullptr ;
mDocShellAsNav = nullptr ;
mDocShellAsScrollable = nullptr ;
mDocShellAsTextScroll = nullptr ;
mWebProgress = nullptr ;
}
return NS_OK ;
2000-03-11 04:12:46 +03:00
}
1999-10-27 06:45:49 +04:00
2000-03-11 04:12:46 +03:00
NS_IMETHODIMP nsWebBrowser : : EnsureDocShellTreeOwner ( )
{
2015-02-05 02:15:12 +03:00
if ( mDocShellTreeOwner )
return NS_OK ;
1999-10-27 06:45:49 +04:00
2015-02-05 02:15:12 +03:00
mDocShellTreeOwner = new nsDocShellTreeOwner ( ) ;
mDocShellTreeOwner - > WebBrowser ( this ) ;
2014-12-16 20:18:01 +03:00
2015-02-05 02:15:12 +03:00
return NS_OK ;
2000-03-11 04:12:46 +03:00
}
2000-04-03 01:01:18 +04:00
2014-09-26 21:06:08 +04:00
static void DrawPaintedLayer ( PaintedLayer * aLayer ,
2015-02-05 02:15:12 +03:00
gfxContext * aContext ,
const nsIntRegion & aRegionToDraw ,
DrawRegionClip aClip ,
const nsIntRegion & aRegionToInvalidate ,
void * aCallbackData )
2010-05-21 07:20:48 +04:00
{
2014-11-24 03:04:33 +03:00
DrawTarget & aDrawTarget = * aContext - > GetDrawTarget ( ) ;
ColorPattern color ( ToDeviceColor ( * static_cast < nscolor * > ( aCallbackData ) ) ) ;
2010-05-21 07:20:48 +04:00
nsIntRect dirtyRect = aRegionToDraw . GetBounds ( ) ;
2014-11-24 03:04:33 +03:00
aDrawTarget . FillRect ( Rect ( dirtyRect . x , dirtyRect . y ,
dirtyRect . width , dirtyRect . height ) ,
color ) ;
2010-05-21 07:20:48 +04:00
}
2012-08-15 22:52:42 +04:00
void nsWebBrowser : : WindowRaised ( nsIWidget * aWidget )
2000-11-17 22:57:16 +03:00
{
2009-11-05 19:14:24 +03:00
# if defined(DEBUG_smaug)
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDocument > document = mDocShell - > GetDocument ( ) ;
2012-08-15 22:52:42 +04:00
nsAutoString documentURI ;
2014-01-10 06:03:47 +04:00
document - > GetDocumentURI ( documentURI ) ;
2012-08-16 22:07:58 +04:00
printf ( " nsWebBrowser::NS_ACTIVATE %p %s \n " , ( void * ) this ,
2012-08-15 22:52:42 +04:00
NS_ConvertUTF16toUTF8 ( documentURI ) . get ( ) ) ;
2009-11-05 19:14:24 +03:00
# endif
2012-08-15 22:52:42 +04:00
Activate ( ) ;
}
2009-11-05 19:14:24 +03:00
2012-08-15 22:52:42 +04:00
void nsWebBrowser : : WindowLowered ( nsIWidget * aWidget )
{
2009-11-05 19:14:24 +03:00
# if defined(DEBUG_smaug)
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDocument > document = mDocShell - > GetDocument ( ) ;
2012-08-15 22:52:42 +04:00
nsAutoString documentURI ;
2014-01-10 06:03:47 +04:00
document - > GetDocumentURI ( documentURI ) ;
2012-08-16 22:07:58 +04:00
printf ( " nsWebBrowser::NS_DEACTIVATE %p %s \n " , ( void * ) this ,
2012-08-15 22:52:42 +04:00
NS_ConvertUTF16toUTF8 ( documentURI ) . get ( ) ) ;
2009-11-05 19:14:24 +03:00
# endif
2012-08-15 22:52:42 +04:00
Deactivate ( ) ;
}
2013-05-23 18:49:18 +04:00
bool nsWebBrowser : : PaintWindow ( nsIWidget * aWidget , nsIntRegion aRegion )
2012-08-15 22:52:42 +04:00
{
LayerManager * layerManager = aWidget - > GetLayerManager ( ) ;
NS_ASSERTION ( layerManager , " Must be in paint event " ) ;
2009-11-05 19:14:24 +03:00
2012-08-15 22:52:42 +04:00
layerManager - > BeginTransaction ( ) ;
2014-09-26 21:06:08 +04:00
nsRefPtr < PaintedLayer > root = layerManager - > CreatePaintedLayer ( ) ;
2012-08-15 22:52:42 +04:00
if ( root ) {
nsIntRect dirtyRect = aRegion . GetBounds ( ) ;
root - > SetVisibleRegion ( dirtyRect ) ;
layerManager - > SetRoot ( root ) ;
2000-11-17 22:57:16 +03:00
}
2014-09-26 21:06:08 +04:00
layerManager - > EndTransaction ( DrawPaintedLayer , & mBackgroundColor ) ;
2012-08-15 22:52:42 +04:00
return true ;
2000-11-17 22:57:16 +03:00
}
2011-07-15 14:31:34 +04:00
NS_IMETHODIMP nsWebBrowser : : GetPrimaryContentWindow ( nsIDOMWindow * * aDOMWindow )
2000-11-17 22:57:16 +03:00
{
2014-12-16 20:18:02 +03:00
* aDOMWindow = nullptr ;
2000-08-16 12:50:00 +04:00
2000-11-17 22:57:16 +03:00
nsCOMPtr < nsIDocShellTreeItem > item ;
2002-05-07 00:35:17 +04:00
NS_ENSURE_TRUE ( mDocShellTreeOwner , NS_ERROR_FAILURE ) ;
2000-11-17 22:57:16 +03:00
mDocShellTreeOwner - > GetPrimaryContentShell ( getter_AddRefs ( item ) ) ;
NS_ENSURE_TRUE ( item , NS_ERROR_FAILURE ) ;
2000-08-16 12:50:00 +04:00
2000-11-17 22:57:16 +03:00
nsCOMPtr < nsIDocShell > docShell ;
docShell = do_QueryInterface ( item ) ;
NS_ENSURE_TRUE ( docShell , NS_ERROR_FAILURE ) ;
2014-12-16 20:18:01 +03:00
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDOMWindow > domWindow = docShell - > GetWindow ( ) ;
2000-11-17 22:57:16 +03:00
NS_ENSURE_TRUE ( domWindow , NS_ERROR_FAILURE ) ;
* aDOMWindow = domWindow ;
NS_ADDREF ( * aDOMWindow ) ;
return NS_OK ;
}
2015-02-05 02:15:12 +03:00
2001-01-31 03:34:28 +03:00
//*****************************************************************************
// nsWebBrowser::nsIWebBrowserFocus
2014-12-16 20:18:01 +03:00
//*****************************************************************************
2001-01-31 03:34:28 +03:00
/* void activate (); */
NS_IMETHODIMP nsWebBrowser : : Activate ( void )
{
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDOMWindow > window = GetWindow ( ) ;
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
if ( fm & & window )
return fm - > WindowRaised ( window ) ;
2001-04-17 00:34:33 +04:00
return NS_OK ;
2001-01-31 03:34:28 +03:00
}
/* void deactivate (); */
NS_IMETHODIMP nsWebBrowser : : Deactivate ( void )
{
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDOMWindow > window = GetWindow ( ) ;
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
if ( fm & & window )
return fm - > WindowLowered ( window ) ;
2002-01-30 00:42:07 +03:00
return NS_OK ;
2001-01-31 03:34:28 +03:00
}
/* void setFocusAtFirstElement (); */
NS_IMETHODIMP nsWebBrowser : : SetFocusAtFirstElement ( void )
{
return NS_OK ;
}
/* void setFocusAtLastElement (); */
NS_IMETHODIMP nsWebBrowser : : SetFocusAtLastElement ( void )
{
return NS_OK ;
}
/* attribute nsIDOMWindow focusedWindow; */
NS_IMETHODIMP nsWebBrowser : : GetFocusedWindow ( nsIDOMWindow * * aFocusedWindow )
{
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
NS_ENSURE_ARG_POINTER ( aFocusedWindow ) ;
2012-07-30 18:20:58 +04:00
* aFocusedWindow = nullptr ;
2001-02-07 09:03:35 +03:00
2014-01-10 06:03:47 +04:00
NS_ENSURE_TRUE ( mDocShell , NS_ERROR_FAILURE ) ;
nsCOMPtr < nsIDOMWindow > window = mDocShell - > GetWindow ( ) ;
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
NS_ENSURE_TRUE ( window , NS_ERROR_FAILURE ) ;
2001-02-07 09:03:35 +03:00
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIDOMElement > focusedElement ;
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
2011-10-17 18:59:28 +04:00
return fm ? fm - > GetFocusedElementForWindow ( window , true , aFocusedWindow ,
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
getter_AddRefs ( focusedElement ) ) : NS_OK ;
2001-01-31 03:34:28 +03:00
}
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
2001-01-31 03:34:28 +03:00
NS_IMETHODIMP nsWebBrowser : : SetFocusedWindow ( nsIDOMWindow * aFocusedWindow )
{
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
return fm ? fm - > SetFocusedWindow ( aFocusedWindow ) : NS_OK ;
2001-01-31 03:34:28 +03:00
}
/* attribute nsIDOMElement focusedElement; */
NS_IMETHODIMP nsWebBrowser : : GetFocusedElement ( nsIDOMElement * * aFocusedElement )
{
2001-05-11 18:19:39 +04:00
NS_ENSURE_ARG_POINTER ( aFocusedElement ) ;
2014-01-10 06:03:47 +04:00
NS_ENSURE_TRUE ( mDocShell , NS_ERROR_FAILURE ) ;
2001-05-11 18:19:39 +04:00
2014-01-10 06:03:47 +04:00
nsCOMPtr < nsIDOMWindow > window = mDocShell - > GetWindow ( ) ;
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
NS_ENSURE_TRUE ( window , NS_ERROR_FAILURE ) ;
2001-05-11 18:19:39 +04:00
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
2012-07-30 18:20:58 +04:00
return fm ? fm - > GetFocusedElementForWindow ( window , true , nullptr , aFocusedElement ) : NS_OK ;
2001-01-31 03:34:28 +03:00
}
2001-05-11 18:19:39 +04:00
2001-01-31 03:34:28 +03:00
NS_IMETHODIMP nsWebBrowser : : SetFocusedElement ( nsIDOMElement * aFocusedElement )
{
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
nsCOMPtr < nsIFocusManager > fm = do_GetService ( FOCUSMANAGER_CONTRACTID ) ;
return fm ? fm - > SetFocus ( aFocusedElement , 0 ) : NS_OK ;
2001-01-31 03:34:28 +03:00
}
2001-03-27 16:04:30 +04:00
2004-05-29 21:43:59 +04:00
//*****************************************************************************
// nsWebBrowser::nsIWebBrowserStream
2014-12-16 20:18:01 +03:00
//*****************************************************************************
2004-05-29 21:43:59 +04:00
2004-11-13 01:47:50 +03:00
/* void openStream(in nsIURI aBaseURI, in ACString aContentType); */
NS_IMETHODIMP nsWebBrowser : : OpenStream ( nsIURI * aBaseURI , const nsACString & aContentType )
2004-05-29 21:43:59 +04:00
{
nsresult rv ;
if ( ! mStream ) {
mStream = new nsEmbedStream ( ) ;
mStream - > InitOwner ( this ) ;
rv = mStream - > Init ( ) ;
if ( NS_FAILED ( rv ) )
return rv ;
}
return mStream - > OpenStream ( aBaseURI , aContentType ) ;
}
2004-11-13 01:47:50 +03:00
/* void appendToStream([const, array, size_is(aLen)] in octet aData,
* in unsigned long aLen ) ; */
2012-08-22 19:56:38 +04:00
NS_IMETHODIMP nsWebBrowser : : AppendToStream ( const uint8_t * aData , uint32_t aLen )
2004-05-29 21:43:59 +04:00
{
if ( ! mStream )
return NS_ERROR_FAILURE ;
return mStream - > AppendToStream ( aData , aLen ) ;
}
/* void closeStream (); */
NS_IMETHODIMP nsWebBrowser : : CloseStream ( )
{
nsresult rv ;
if ( ! mStream )
return NS_ERROR_FAILURE ;
rv = mStream - > CloseStream ( ) ;
2014-12-16 20:18:02 +03:00
mStream = nullptr ;
2004-05-29 21:43:59 +04:00
return rv ;
}