2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Johnny Stenback <jst@netscape.com> (original author)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Class for managing loading of a subframe (creation of the docshell,
|
|
|
|
* handling of loads in it, recursion-checking).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsFrameLoader_h_
|
|
|
|
#define nsFrameLoader_h_
|
|
|
|
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsStringFwd.h"
|
|
|
|
#include "nsIFrameLoader.h"
|
2010-09-03 13:10:46 -07:00
|
|
|
#include "nsPoint.h"
|
2009-10-05 04:52:19 -07:00
|
|
|
#include "nsSize.h"
|
2008-03-21 04:44:09 -07:00
|
|
|
#include "nsIURI.h"
|
2009-06-30 13:39:22 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2010-02-20 09:05:20 -08:00
|
|
|
#include "nsFrameMessageManager.h"
|
2011-01-13 09:45:14 -08:00
|
|
|
#include "Layers.h"
|
2011-10-01 10:14:35 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsIURI;
|
2010-08-30 17:49:07 -07:00
|
|
|
class nsSubDocumentFrame;
|
2009-10-28 13:41:46 -07:00
|
|
|
class nsIView;
|
2010-05-18 05:28:37 -07:00
|
|
|
class nsIInProcessContentFrameMessageManager;
|
2010-05-28 12:34:50 -07:00
|
|
|
class AutoResetInShow;
|
2009-07-20 12:04:52 -07:00
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
namespace mozilla {
|
2010-07-19 11:33:33 -07:00
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class TabParent;
|
|
|
|
}
|
2010-08-20 16:24:41 -07:00
|
|
|
|
|
|
|
namespace layout {
|
|
|
|
class RenderFrameParent;
|
|
|
|
}
|
2009-06-30 13:39:22 -07:00
|
|
|
}
|
2009-10-28 13:41:46 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
|
|
|
typedef struct _GtkWidget GtkWidget;
|
|
|
|
#endif
|
2010-02-04 08:00:52 -08:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
class QX11EmbedContainer;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
/**
|
|
|
|
* Defines a target configuration for this <browser>'s content
|
|
|
|
* document's view. If the content document's actual view
|
|
|
|
* doesn't match this nsIContentView, then on paints its pixels
|
|
|
|
* are transformed to compensate for the difference.
|
|
|
|
*
|
|
|
|
* Used to support asynchronous re-paints of content pixels; see
|
|
|
|
* nsIContentView.
|
|
|
|
*/
|
|
|
|
class nsContentView : public nsIContentView
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-08-19 02:09:26 -07:00
|
|
|
public:
|
2011-01-13 09:45:14 -08:00
|
|
|
typedef mozilla::layers::FrameMetrics::ViewID ViewID;
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONTENTVIEW
|
|
|
|
|
|
|
|
struct ViewConfig {
|
|
|
|
ViewConfig()
|
|
|
|
: mScrollOffset(0, 0)
|
2010-09-03 13:10:46 -07:00
|
|
|
, mXScale(1.0)
|
|
|
|
, mYScale(1.0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// Default copy ctor and operator= are fine
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool operator==(const ViewConfig& aOther) const
|
2010-09-03 13:10:46 -07:00
|
|
|
{
|
2011-01-13 09:45:14 -08:00
|
|
|
return (mScrollOffset == aOther.mScrollOffset &&
|
2010-09-03 13:10:46 -07:00
|
|
|
mXScale == aOther.mXScale &&
|
|
|
|
mYScale == aOther.mYScale);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is the scroll offset the <browser> user wishes or expects
|
|
|
|
// its enclosed content document to have. "Scroll offset" here
|
|
|
|
// means the document pixel at pixel (0,0) within the CSS
|
|
|
|
// viewport. If the content document's actual scroll offset
|
|
|
|
// doesn't match |mScrollOffset|, the difference is used to define
|
|
|
|
// a translation transform when painting the content document.
|
|
|
|
nsPoint mScrollOffset;
|
|
|
|
// The scale at which the <browser> user wishes to paint its
|
|
|
|
// enclosed content document. If content-document layers have a
|
|
|
|
// lower or higher resolution than the desired scale, then the
|
|
|
|
// ratio is used to define a scale transform when painting the
|
|
|
|
// content document.
|
|
|
|
float mXScale;
|
|
|
|
float mYScale;
|
|
|
|
};
|
|
|
|
|
2011-07-18 11:04:47 -07:00
|
|
|
nsContentView(nsFrameLoader* aFrameLoader, ViewID aScrollId,
|
2011-01-13 09:45:14 -08:00
|
|
|
ViewConfig aConfig = ViewConfig())
|
2011-01-13 09:45:14 -08:00
|
|
|
: mViewportSize(0, 0)
|
|
|
|
, mContentSize(0, 0)
|
2011-11-17 15:52:29 -08:00
|
|
|
, mParentScaleX(1.0)
|
|
|
|
, mParentScaleY(1.0)
|
2011-07-18 11:04:47 -07:00
|
|
|
, mFrameLoader(aFrameLoader)
|
2011-01-13 09:45:14 -08:00
|
|
|
, mScrollId(aScrollId)
|
|
|
|
, mConfig(aConfig)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool IsRoot() const;
|
|
|
|
|
|
|
|
ViewID GetId() const
|
|
|
|
{
|
|
|
|
return mScrollId;
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewConfig GetViewConfig() const
|
|
|
|
{
|
|
|
|
return mConfig;
|
|
|
|
}
|
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
nsSize mViewportSize;
|
|
|
|
nsSize mContentSize;
|
2011-11-17 15:52:29 -08:00
|
|
|
float mParentScaleX;
|
|
|
|
float mParentScaleY;
|
2011-01-13 09:45:14 -08:00
|
|
|
|
2011-07-18 11:04:47 -07:00
|
|
|
nsFrameLoader* mFrameLoader; // WEAK
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult Update(const ViewConfig& aConfig);
|
|
|
|
|
|
|
|
ViewID mScrollId;
|
|
|
|
ViewConfig mConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class nsFrameLoader : public nsIFrameLoader,
|
|
|
|
public nsIContentViewManager
|
|
|
|
{
|
|
|
|
friend class AutoResetInShow;
|
|
|
|
typedef mozilla::dom::PBrowserParent PBrowserParent;
|
|
|
|
typedef mozilla::dom::TabParent TabParent;
|
|
|
|
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
|
|
|
|
|
|
|
|
protected:
|
2011-10-01 10:14:35 -07:00
|
|
|
nsFrameLoader(mozilla::dom::Element* aOwner, bool aNetworkCreated);
|
2011-01-13 09:45:14 -08:00
|
|
|
|
|
|
|
public:
|
2008-02-26 07:10:01 -08:00
|
|
|
~nsFrameLoader() {
|
2011-10-17 07:59:28 -07:00
|
|
|
mNeedsAsyncDestroy = true;
|
2010-02-20 09:05:20 -08:00
|
|
|
if (mMessageManager) {
|
|
|
|
mMessageManager->Disconnect();
|
|
|
|
}
|
2008-02-26 07:10:01 -08:00
|
|
|
nsFrameLoader::Destroy();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AsyncScrollEnabled() const
|
2011-01-13 09:45:14 -08:00
|
|
|
{
|
|
|
|
return !!(mRenderMode & RENDER_MODE_ASYNC_SCROLL);
|
|
|
|
}
|
|
|
|
|
2011-10-01 10:14:35 -07:00
|
|
|
static nsFrameLoader* Create(mozilla::dom::Element* aOwner,
|
|
|
|
bool aNetworkCreated);
|
2009-08-19 02:09:26 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2011-01-11 13:34:31 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_NSIFRAMELOADER
|
2011-01-13 09:45:14 -08:00
|
|
|
NS_DECL_NSICONTENTVIEWMANAGER
|
2007-07-17 00:43:36 -07:00
|
|
|
NS_HIDDEN_(nsresult) CheckForRecursiveLoad(nsIURI* aURI);
|
2008-03-21 04:44:09 -07:00
|
|
|
nsresult ReallyStartLoading();
|
2008-02-26 06:47:51 -08:00
|
|
|
void Finalize();
|
2008-04-24 03:33:22 -07:00
|
|
|
nsIDocShell* GetExistingDocShell() { return mDocShell; }
|
2011-06-23 19:18:00 -07:00
|
|
|
nsIDOMEventTarget* GetTabChildGlobalAsEventTarget();
|
2009-12-10 20:02:13 -08:00
|
|
|
nsresult CreateStaticClone(nsIFrameLoader* aDest);
|
|
|
|
|
2009-10-16 12:42:29 -07:00
|
|
|
/**
|
2009-10-16 12:42:29 -07:00
|
|
|
* Called from the layout frame associated with this frame loader;
|
|
|
|
* this notifies us to hook up with the widget and view.
|
2009-10-16 12:42:29 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Show(PRInt32 marginWidth, PRInt32 marginHeight,
|
2010-05-28 12:34:50 -07:00
|
|
|
PRInt32 scrollbarPrefX, PRInt32 scrollbarPrefY,
|
2010-08-30 17:49:07 -07:00
|
|
|
nsSubDocumentFrame* frame);
|
2009-10-16 12:42:29 -07:00
|
|
|
|
2011-05-13 10:41:00 -07:00
|
|
|
/**
|
|
|
|
* Called when the margin properties of the containing frame are changed.
|
|
|
|
*/
|
|
|
|
void MarginsChanged(PRUint32 aMarginWidth, PRUint32 aMarginHeight);
|
|
|
|
|
2009-10-16 12:42:29 -07:00
|
|
|
/**
|
2009-10-16 12:42:29 -07:00
|
|
|
* Called from the layout frame associated with this frame loader, when
|
|
|
|
* the frame is being torn down; this notifies us that out widget and view
|
|
|
|
* are going away and we should unhook from them.
|
2009-10-16 12:42:29 -07:00
|
|
|
*/
|
|
|
|
void Hide();
|
|
|
|
|
2009-12-10 20:02:13 -08:00
|
|
|
nsresult CloneForStatic(nsIFrameLoader* aOriginal);
|
|
|
|
|
2008-08-07 16:15:40 -07:00
|
|
|
// The guts of an nsIFrameLoaderOwner::SwapFrameLoader implementation. A
|
|
|
|
// frame loader owner needs to call this, and pass in the two references to
|
|
|
|
// nsRefPtrs for frame loaders that need to be swapped.
|
|
|
|
nsresult SwapWithOtherLoader(nsFrameLoader* aOther,
|
|
|
|
nsRefPtr<nsFrameLoader>& aFirstToSwap,
|
|
|
|
nsRefPtr<nsFrameLoader>& aSecondToSwap);
|
2009-10-29 10:58:31 -07:00
|
|
|
|
2010-04-11 17:34:02 -07:00
|
|
|
// When IPC is enabled, destroy any associated child process.
|
|
|
|
void DestroyChild();
|
|
|
|
|
2010-08-05 15:11:23 -07:00
|
|
|
/**
|
|
|
|
* Return the primary frame for our owning content, or null if it
|
|
|
|
* can't be found.
|
|
|
|
*/
|
|
|
|
nsIFrame* GetPrimaryFrameOfOwningContent() const
|
|
|
|
{
|
|
|
|
return mOwnerContent ? mOwnerContent->GetPrimaryFrame() : nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the document that owns this, or null if we don't have
|
|
|
|
* an owner.
|
|
|
|
*/
|
2012-05-11 00:47:40 -07:00
|
|
|
nsIDocument* GetOwnerDoc() const
|
2011-10-18 03:53:36 -07:00
|
|
|
{ return mOwnerContent ? mOwnerContent->OwnerDoc() : nsnull; }
|
2010-08-05 15:11:23 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserParent* GetRemoteBrowser();
|
2010-08-20 16:24:41 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The "current" render frame is the one on which the most recent
|
|
|
|
* remote layer-tree transaction was executed. If no content has
|
|
|
|
* been drawn yet, or the remote browser doesn't have any drawn
|
|
|
|
* content for whatever reason, return NULL. The returned render
|
|
|
|
* frame has an associated shadow layer tree.
|
|
|
|
*
|
|
|
|
* Note that the returned render frame might not be a frame
|
|
|
|
* constructed for this->GetURL(). This can happen, e.g., if the
|
|
|
|
* <browser> was just navigated to a new URL, but hasn't painted the
|
|
|
|
* new page yet. A render frame for the previous page may be
|
|
|
|
* returned. (In-process <browser> behaves similarly, and this
|
|
|
|
* behavior seems desirable.)
|
|
|
|
*/
|
|
|
|
RenderFrameParent* GetCurrentRemoteFrame() const
|
|
|
|
{
|
|
|
|
return mCurrentRemoteFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* |aFrame| can be null. If non-null, it must be the remote frame
|
|
|
|
* on which the most recent layer transaction completed for this's
|
|
|
|
* <browser>.
|
|
|
|
*/
|
|
|
|
void SetCurrentRemoteFrame(RenderFrameParent* aFrame)
|
|
|
|
{
|
|
|
|
mCurrentRemoteFrame = aFrame;
|
|
|
|
}
|
2010-02-20 09:05:20 -08:00
|
|
|
nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
|
|
|
|
|
2011-10-01 10:14:35 -07:00
|
|
|
mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; }
|
2011-12-05 04:38:46 -08:00
|
|
|
bool ShouldClipSubdocument() { return mClipSubdocument; }
|
|
|
|
|
2012-02-17 15:41:13 -08:00
|
|
|
bool ShouldClampScrollPosition() { return mClampScrollPosition; }
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
|
2012-05-08 09:20:35 -07:00
|
|
|
void SetOwnerContent(mozilla::dom::Element* aContent);
|
|
|
|
|
2009-10-16 12:42:27 -07:00
|
|
|
bool ShouldUseRemoteProcess();
|
|
|
|
|
2012-04-25 09:35:58 -07:00
|
|
|
/**
|
|
|
|
* Is this a frameloader for a bona fide <iframe mozbrowser>? (I.e., does
|
|
|
|
* the frame return true for nsIMozBrowserFrame::GetReallyIsBrowser()?)
|
|
|
|
*/
|
|
|
|
bool OwnerIsBrowserFrame();
|
|
|
|
|
2009-10-16 12:42:27 -07:00
|
|
|
/**
|
|
|
|
* If we are an IPC frame, set mRemoteFrame. Otherwise, create and
|
|
|
|
* initialize mDocShell.
|
|
|
|
*/
|
|
|
|
nsresult MaybeCreateDocShell();
|
2010-05-18 05:28:37 -07:00
|
|
|
nsresult EnsureMessageManager();
|
2009-12-15 17:33:05 -08:00
|
|
|
NS_HIDDEN_(void) GetURL(nsString& aURL);
|
2009-10-05 04:52:19 -07:00
|
|
|
|
|
|
|
// Properly retrieves documentSize of any subdocument type.
|
|
|
|
NS_HIDDEN_(nsIntSize) GetSubDocumentSize(const nsIFrame *aIFrame);
|
2011-07-15 14:46:56 -07:00
|
|
|
nsresult GetWindowDimensions(nsRect& aRect);
|
2009-10-05 04:52:19 -07:00
|
|
|
|
|
|
|
// Updates the subdocument position and size. This gets called only
|
|
|
|
// when we have our own in-process DocShell.
|
|
|
|
NS_HIDDEN_(nsresult) UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame);
|
2008-03-21 04:44:09 -07:00
|
|
|
nsresult CheckURILoad(nsIURI* aURI);
|
2010-02-24 18:45:43 -08:00
|
|
|
void FireErrorEvent();
|
|
|
|
nsresult ReallyStartLoadingInternal();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
// Return true if remote browser created; nothing else to do
|
|
|
|
bool TryRemoteBrowser();
|
2009-10-28 13:41:46 -07:00
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
// Tell the remote browser that it's now "virtually visible"
|
|
|
|
bool ShowRemoteFrame(const nsIntSize& size);
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIDocShell> mDocShell;
|
2008-03-21 04:44:09 -07:00
|
|
|
nsCOMPtr<nsIURI> mURIToLoad;
|
2011-10-01 10:14:35 -07:00
|
|
|
mozilla::dom::Element* mOwnerContent; // WEAK
|
2010-05-18 05:28:37 -07:00
|
|
|
public:
|
|
|
|
// public because a callback needs these.
|
|
|
|
nsRefPtr<nsFrameMessageManager> mMessageManager;
|
|
|
|
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
|
|
|
private:
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDepthTooGreat : 1;
|
|
|
|
bool mIsTopLevelContent : 1;
|
|
|
|
bool mDestroyCalled : 1;
|
|
|
|
bool mNeedsAsyncDestroy : 1;
|
|
|
|
bool mInSwap : 1;
|
|
|
|
bool mInShow : 1;
|
|
|
|
bool mHideCalled : 1;
|
2010-08-17 07:13:55 -07:00
|
|
|
// True when the object is created for an element which the parser has
|
|
|
|
// created using NS_FROM_PARSER_NETWORK flag. If the element is modified,
|
|
|
|
// it may lose the flag.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNetworkCreated : 1;
|
2009-06-30 13:39:22 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDelayRemoteDialogs : 1;
|
|
|
|
bool mRemoteBrowserShown : 1;
|
2011-12-05 04:38:46 -08:00
|
|
|
bool mRemoteFrame : 1;
|
|
|
|
bool mClipSubdocument : 1;
|
2012-02-17 15:41:13 -08:00
|
|
|
bool mClampScrollPosition : 1;
|
2011-12-05 04:38:46 -08:00
|
|
|
|
2009-06-30 13:39:22 -07:00
|
|
|
// XXX leaking
|
2010-04-11 17:24:45 -07:00
|
|
|
nsCOMPtr<nsIObserver> mChildHost;
|
2010-08-20 16:24:41 -07:00
|
|
|
RenderFrameParent* mCurrentRemoteFrame;
|
2010-07-19 11:33:33 -07:00
|
|
|
TabParent* mRemoteBrowser;
|
2010-06-07 13:38:02 -07:00
|
|
|
|
2011-01-13 09:45:14 -08:00
|
|
|
// See nsIFrameLoader.idl. Short story, if !(mRenderMode &
|
|
|
|
// RENDER_MODE_ASYNC_SCROLL), all the fields below are ignored in
|
|
|
|
// favor of what content tells.
|
|
|
|
PRUint32 mRenderMode;
|
2011-06-21 17:32:43 -07:00
|
|
|
|
|
|
|
// See nsIFrameLoader.idl. EVENT_MODE_NORMAL_DISPATCH automatically
|
|
|
|
// forwards some input events to out-of-process content.
|
|
|
|
PRUint32 mEventMode;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|