Electrolysis-plugin-only bookkeeping commit.

This commit is contained in:
Benjamin Smedberg
2009-12-15 20:33:05 -05:00
parent 8e9d9a0522
commit 18e450f391
111 changed files with 101 additions and 10618 deletions

View File

@@ -23,7 +23,6 @@
* Contributor(s):
* Johnny Stenback <jst@netscape.com> (original author)
* Boris Zbarsky <bzbarsky@mit.edu>
* Frederic Plourde <frederic.plourde@polymtl.ca>
*
* 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"),
@@ -44,12 +43,6 @@
* handling of loads in it, recursion-checking).
*/
#ifdef MOZ_IPC
# include "base/basictypes.h"
#endif
#include "prenv.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMWindow.h"
@@ -84,7 +77,7 @@
#include "nsISHistory.h"
#include "nsISHistoryInternal.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsLayoutUtils.h"
#include "nsIView.h"
#include "nsIURI.h"
#include "nsIURL.h"
@@ -96,22 +89,6 @@
#include "nsThreadUtils.h"
#include "nsICSSStyleSheet.h"
#include "nsIContentViewer.h"
#include "nsIView.h"
#ifdef MOZ_WIDGET_GTK2
#include "mozcontainer.h"
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#endif
#ifdef MOZ_IPC
#include "ContentProcessParent.h"
#include "TabParent.h"
using namespace mozilla;
using namespace mozilla::dom;
#endif
class nsAsyncDocShellDestroyer : public nsRunnable
{
@@ -235,34 +212,11 @@ nsresult
nsFrameLoader::ReallyStartLoading()
{
NS_ENSURE_STATE(mURIToLoad && mOwnerContent && mOwnerContent->IsInDoc());
nsresult rv = MaybeCreateDocShell();
if (NS_FAILED(rv)) {
return rv;
}
#ifdef MOZ_IPC
if (mRemoteFrame) {
if (!mChildProcess) {
TryNewProcess();
}
if (!mChildProcess) {
NS_WARNING("Couldn't create child process for iframe.");
return NS_ERROR_FAILURE;
}
// FIXME get error codes from child
mChildProcess->LoadURL(mURIToLoad);
return NS_OK;
}
#endif
NS_ASSERTION(mDocShell,
"MaybeCreateDocShell succeeded with a null mDocShell");
// Just to be safe, recheck uri.
rv = CheckURILoad(mURIToLoad);
nsresult rv = CheckURILoad(mURIToLoad);
NS_ENSURE_SUCCESS(rv, rv);
rv = EnsureDocShell();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
@@ -326,15 +280,6 @@ nsFrameLoader::CheckURILoad(nsIURI* aURI)
}
// Bail out if this is an infinite recursion scenario
rv = MaybeCreateDocShell();
if (NS_FAILED(rv)) {
return rv;
}
#ifdef MOZ_IPC
if (mRemoteFrame) {
return NS_OK;
}
#endif
return CheckForRecursiveLoad(aURI);
}
@@ -347,17 +292,8 @@ nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
// that. If not, we're most likely in the middle of being torn down,
// then we just return null.
if (mOwnerContent) {
nsresult rv = MaybeCreateDocShell();
if (NS_FAILED(rv))
return rv;
#ifdef MOZ_IPC
if (mRemoteFrame) {
NS_WARNING("No docshells for remote frames!");
return NS_ERROR_NOT_AVAILABLE;
}
#endif
NS_ASSERTION(mDocShell,
"MaybeCreateDocShell succeeded, but null mDocShell");
nsresult rv = EnsureDocShell();
NS_ENSURE_SUCCESS(rv, rv);
}
*aDocShell = mDocShell;
@@ -544,64 +480,50 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight,
{
nsContentType contentType;
nsresult rv = MaybeCreateDocShell();
nsresult rv = EnsureDocShell();
if (NS_FAILED(rv)) {
return false;
}
#ifdef MOZ_IPC
if (mRemoteFrame) {
contentType = eContentTypeUI;
if (!mDocShell)
return false;
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (presShell)
return true;
mDocShell->SetMarginWidth(marginWidth);
mDocShell->SetMarginHeight(marginHeight);
nsCOMPtr<nsIScrollable> sc = do_QueryInterface(mDocShell);
if (sc) {
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
scrollbarPrefX);
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
scrollbarPrefY);
}
else
#endif
{
if (!mDocShell)
return false;
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (presShell)
return true;
mDocShell->SetMarginWidth(marginWidth);
mDocShell->SetMarginHeight(marginHeight);
nsCOMPtr<nsIScrollable> sc = do_QueryInterface(mDocShell);
if (sc) {
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X,
scrollbarPrefX);
sc->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,
scrollbarPrefY);
}
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
NS_ASSERTION(treeItem,
"Found a nsIDocShell that isn't a nsIDocShellTreeItem.");
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
NS_ASSERTION(treeItem,
"Found a nsIDocShell that isn't a nsIDocShellTreeItem.");
PRInt32 itemType;
treeItem->GetItemType(&itemType);
PRInt32 itemType;
treeItem->GetItemType(&itemType);
if (itemType == nsIDocShellTreeItem::typeChrome)
contentType = eContentTypeUI;
else {
nsCOMPtr<nsIDocShellTreeItem> sameTypeParent;
treeItem->GetSameTypeParent(getter_AddRefs(sameTypeParent));
contentType = sameTypeParent ? eContentTypeContentFrame : eContentTypeContent;
}
if (itemType == nsIDocShellTreeItem::typeChrome)
contentType = eContentTypeUI;
else {
nsCOMPtr<nsIDocShellTreeItem> sameTypeParent;
treeItem->GetSameTypeParent(getter_AddRefs(sameTypeParent));
contentType = sameTypeParent ? eContentTypeContentFrame : eContentTypeContent;
}
nsIView* view = frame->CreateViewAndWidget(contentType);
if (!view)
return false;
#ifdef MOZ_IPC
if (mRemoteFrame) {
return ShowRemoteFrame(frame, view);
}
#endif
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mDocShell);
NS_ASSERTION(baseWindow, "Found a nsIDocShell that isn't a nsIBaseWindow.");
baseWindow->InitWindow(nsnull, view->GetWidget(), 0, 0, 10, 10);
@@ -615,7 +537,6 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight,
// sub-document. This shouldn't be necessary, but given the way our
// editor works, it is. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=284245
nsCOMPtr<nsIPresShell> presShell;
mDocShell->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIDOMNSHTMLDocument> doc =
@@ -635,67 +556,6 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight,
return true;
}
#ifdef MOZ_IPC
bool
nsFrameLoader::ShowRemoteFrame(nsIFrameFrame* frame, nsIView* view)
{
NS_ASSERTION(mRemoteFrame, "ShowRemote only makes sense on remote frames.");
TryNewProcess();
if (!mChildProcess) {
NS_ERROR("Couldn't create child process.");
return false;
}
nsIWidget* w = view->GetWidget();
if (!w) {
NS_ERROR("Our view doesn't have a widget. Totally stuffed!");
return false;
}
nsIntSize size = GetSubDocumentSize(frame->GetFrame());
#ifdef XP_WIN
HWND parentwin =
static_cast<HWND>(w->GetNativeData(NS_NATIVE_WINDOW));
mChildProcess->SendcreateWidget(parentwin);
#elif defined(MOZ_WIDGET_GTK2)
GdkWindow* parent_win =
static_cast<GdkWindow*>(w->GetNativeData(NS_NATIVE_WINDOW));
gpointer user_data = nsnull;
gdk_window_get_user_data(parent_win, &user_data);
MozContainer* parentMozContainer = MOZ_CONTAINER(user_data);
GtkContainer* container = GTK_CONTAINER(parentMozContainer);
// create the socket for the child and add it to our view's widget
mRemoteSocket = gtk_socket_new();
gtk_widget_set_parent_window(mRemoteSocket, parent_win);
gtk_container_add(container, mRemoteSocket);
gtk_widget_realize(mRemoteSocket);
// set the child window's size and position
GtkAllocation alloc = { 0, 0, size.width, size.height };
gtk_widget_size_allocate(mRemoteSocket, &alloc);
gtk_widget_show(mRemoteSocket);
GdkNativeWindow id = gtk_socket_get_id(GTK_SOCKET(mRemoteSocket));
mChildProcess->SendcreateWidget(id);
#elif defined(XP_MACOSX)
# warning IMPLEMENT ME
#else
#error TODO for this platform
#endif
mChildProcess->Move(0, 0, size.width, size.height);
return true;
}
#endif
void
nsFrameLoader::Hide()
{
@@ -999,13 +859,6 @@ nsFrameLoader::Destroy()
mOwnerContent = nsnull;
}
#ifdef MOZ_IPC
if (mChildProcess) {
mChildProcess->SetOwnerElement(nsnull);
PIFrameEmbeddingParent::Send__delete__(mChildProcess);
mChildProcess = nsnull;
}
#endif
// Let the tree owner know we're gone.
if (mIsTopLevelContent) {
@@ -1019,7 +872,7 @@ nsFrameLoader::Destroy()
}
}
}
// Let our window know that we are gone
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
if (win_private) {
@@ -1050,64 +903,14 @@ nsFrameLoader::GetDepthTooGreat(PRBool* aDepthTooGreat)
return NS_OK;
}
#ifdef MOZ_IPC
bool
nsFrameLoader::ShouldUseRemoteProcess()
{
// Check for *disabled* multi-process first: environment, prefs, attribute
// Then check for *enabled* multi-process pref: attribute, prefs
// Default is not-remote.
if (PR_GetEnv("MOZ_DISABLE_OOP_TABS")) {
return false;
}
PRBool remoteDisabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.disabled",
PR_FALSE);
if (remoteDisabled) {
return false;
}
static nsIAtom* const *const remoteValues[] = {
&nsGkAtoms::_false,
&nsGkAtoms::_true,
nsnull
};
switch (mOwnerContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::Remote,
remoteValues, eCaseMatters)) {
case 0:
return false;
case 1:
return true;
}
PRBool remoteEnabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.enabled",
PR_FALSE);
return (bool) remoteEnabled;
}
#endif
nsresult
nsFrameLoader::MaybeCreateDocShell()
nsFrameLoader::EnsureDocShell()
{
if (mDocShell) {
return NS_OK;
}
#ifdef MOZ_IPC
if (mRemoteFrame) {
return NS_OK;
}
#endif
NS_ENSURE_STATE(!mDestroyCalled);
#ifdef MOZ_IPC
if (ShouldUseRemoteProcess()) {
mRemoteFrame = true;
return NS_OK;
}
#endif
// Get our parent docshell off the document of mOwnerContent
// XXXbz this is such a total hack.... We really need to have a
// better setup for doing this.
@@ -1132,7 +935,6 @@ nsFrameLoader::MaybeCreateDocShell()
// Get the frame name and tell the docshell about it.
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsAutoString frameName;
PRInt32 namespaceID = mOwnerContent->GetNameSpaceID();
@@ -1239,20 +1041,9 @@ nsFrameLoader::GetURL(nsString& aURI)
nsresult
nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI)
{
nsresult rv;
mDepthTooGreat = PR_FALSE;
rv = MaybeCreateDocShell();
if (NS_FAILED(rv)) {
return rv;
}
#ifdef MOZ_IPC
NS_ASSERTION(!mRemoteFrame,
"Shouldn't call CheckForRecursiveLoad on remote frames.");
#endif
if (!mDocShell) {
return NS_ERROR_FAILURE;
}
nsresult rv = EnsureDocShell();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
NS_ASSERTION(treeItem, "docshell must be a treeitem!");
@@ -1338,186 +1129,11 @@ nsFrameLoader::CheckForRecursiveLoad(nsIURI* aURI)
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::UpdatePositionAndSize(nsIFrame *aIFrame)
{
#ifdef MOZ_IPC
if (mRemoteFrame) {
if (mChildProcess) {
nsIntSize size = GetSubDocumentSize(aIFrame);
#ifdef MOZ_WIDGET_GTK2
if (mRemoteSocket) {
GtkAllocation alloc = {0, 0, size.width, size.height };
gtk_widget_size_allocate(mRemoteSocket, &alloc);
}
#endif
mChildProcess->Move(0, 0, size.width, size.height);
}
return NS_OK;
}
#endif
return UpdateBaseWindowPositionAndSize(aIFrame);
}
nsresult
nsFrameLoader::UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame)
{
nsCOMPtr<nsIDocShell> docShell;
GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(docShell));
// resize the sub document
if (baseWindow) {
PRInt32 x = 0;
PRInt32 y = 0;
nsWeakFrame weakFrame(aIFrame);
baseWindow->GetPositionAndSize(&x, &y, nsnull, nsnull);
if (!weakFrame.IsAlive()) {
// GetPositionAndSize() killed us
return NS_OK;
}
nsIntSize size = GetSubDocumentSize(aIFrame);
baseWindow->SetPositionAndSize(x, y, size.width, size.height, PR_FALSE);
}
return NS_OK;
}
nsIntSize
nsFrameLoader::GetSubDocumentSize(const nsIFrame *aIFrame)
{
nsAutoDisableGetUsedXAssertions disableAssert;
nsSize docSizeAppUnits;
nsPresContext* presContext = aIFrame->PresContext();
nsCOMPtr<nsIDOMHTMLFrameElement> frameElem =
do_QueryInterface(aIFrame->GetContent());
if (frameElem) {
docSizeAppUnits = aIFrame->GetSize();
} else {
docSizeAppUnits = aIFrame->GetContentRect().Size();
}
return nsIntSize(presContext->AppUnitsToDevPixels(docSizeAppUnits.width),
presContext->AppUnitsToDevPixels(docSizeAppUnits.height));
}
#ifdef MOZ_IPC
bool
nsFrameLoader::TryNewProcess()
{
NS_ASSERTION(!mChildProcess, "TryNewProcess called with a process already?");
nsIDocument* doc = mOwnerContent->GetDocument();
if (!doc) {
return false;
}
if (doc->GetDisplayDocument()) {
// Don't allow subframe loads in external reference documents
return false;
}
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
do_GetInterface(doc->GetScriptGlobalObject());
if (!parentAsWebNav) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsWebNav));
PRInt32 parentType;
parentAsItem->GetItemType(&parentType);
if (parentType != nsIDocShellTreeItem::typeChrome) {
return false;
}
if (!mOwnerContent->IsXUL()) {
return false;
}
nsAutoString value;
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, value);
if (!value.LowerCaseEqualsLiteral("content") &&
!StringBeginsWith(value, NS_LITERAL_STRING("content-"),
nsCaseInsensitiveStringComparator())) {
return false;
}
mChildProcess = ContentProcessParent::GetSingleton()->CreateTab();
if (mChildProcess) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
mChildProcess->SetOwnerElement(element);
}
return true;
}
#endif
#ifdef MOZ_IPC
mozilla::dom::PIFrameEmbeddingParent*
nsFrameLoader::GetChildProcess()
{
return mChildProcess;
}
#endif
NS_IMETHODIMP
nsFrameLoader::ActivateRemoteFrame() {
#ifdef MOZ_IPC
if (mChildProcess) {
mChildProcess->Activate();
return NS_OK;
}
#endif
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsFrameLoader::SendCrossProcessMouseEvent(const nsAString& aType,
float aX,
float aY,
PRInt32 aButton,
PRInt32 aClickCount,
PRInt32 aModifiers,
PRBool aIgnoreRootScrollFrame)
{
#ifdef MOZ_IPC
if (mChildProcess) {
mChildProcess->SendMouseEvent(aType, aX, aY, aButton,
aClickCount, aModifiers,
aIgnoreRootScrollFrame);
return NS_OK;
}
#endif
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsFrameLoader::ActivateFrameEvent(const nsAString& aType,
PRBool aCapture)
{
#ifdef MOZ_IPC
if (mChildProcess) {
mChildProcess->SendactivateFrameEvent(nsString(aType), aCapture);
return NS_OK;
}
#endif
return NS_ERROR_FAILURE;
}
nsresult
nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
{
nsFrameLoader* dest = static_cast<nsFrameLoader*>(aDest);
dest->MaybeCreateDocShell();
dest->EnsureDocShell();
NS_ENSURE_STATE(dest->mDocShell);
nsCOMPtr<nsIDOMDocument> dummy = do_GetInterface(dest->mDocShell);