diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index f2f99340d778..e36f60b3c110 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -177,6 +177,7 @@ #ifdef MOZ_B2G_RIL @BINPATH@/components/dom_mms.xpt #endif +@BINPATH@/components/dom_browserelement.xpt @BINPATH@/components/dom_power.xpt @BINPATH@/components/dom_range.xpt @BINPATH@/components/dom_settings.xpt diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 733f3277f4b8..f2e159fe73c5 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -188,6 +188,7 @@ #ifdef MOZ_B2G_RIL @BINPATH@/components/dom_mms.xpt #endif +@BINPATH@/components/dom_browserelement.xpt @BINPATH@/components/dom_power.xpt @BINPATH@/components/dom_range.xpt @BINPATH@/components/dom_settings.xpt diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index 65ae329db437..0d3720a07809 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -2211,3 +2211,11 @@ nsFrameLoader::GetOwnerElement(nsIDOMElement **aElement) ownerElement.forget(aElement); return NS_OK; } + +void +nsFrameLoader::SetRemoteBrowser(nsITabParent* aTabParent) +{ + MOZ_ASSERT(!mRemoteBrowser); + MOZ_ASSERT(!mCurrentRemoteFrame); + mRemoteBrowser = static_cast(aTabParent); +} diff --git a/content/base/src/nsFrameLoader.h b/content/base/src/nsFrameLoader.h index 7eb3447c79f2..97f3bbd1fab2 100644 --- a/content/base/src/nsFrameLoader.h +++ b/content/base/src/nsFrameLoader.h @@ -27,6 +27,7 @@ class nsSubDocumentFrame; class nsIView; class nsIInProcessContentFrameMessageManager; class AutoResetInShow; +class nsITabParent; namespace mozilla { namespace dom { @@ -256,6 +257,16 @@ public: bool ShouldClampScrollPosition() { return mClampScrollPosition; } + /** + * Tell this FrameLoader to use a particular remote browser. + * + * This will assert if mRemoteBrowser or mCurrentRemoteFrame is non-null. In + * practice, this means you can't have successfully run TryRemoteBrowser() on + * this object, which means you can't have called ShowRemoteFrame() or + * ReallyStartLoading(). + */ + void SetRemoteBrowser(nsITabParent* aTabParent); + private: void SetOwnerContent(mozilla::dom::Element* aContent); diff --git a/content/html/content/src/nsGenericHTMLFrameElement.cpp b/content/html/content/src/nsGenericHTMLFrameElement.cpp index 43f84549dadb..b6e55fd67dc8 100644 --- a/content/html/content/src/nsGenericHTMLFrameElement.cpp +++ b/content/html/content/src/nsGenericHTMLFrameElement.cpp @@ -98,7 +98,7 @@ nsGenericHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow) nsresult nsGenericHTMLFrameElement::EnsureFrameLoader() { - if (!GetParent() || !IsInDoc() || mFrameLoader) { + if (!GetParent() || !IsInDoc() || mFrameLoader || mFrameLoaderCreationDisallowed) { // If frame loader is there, we just keep it around, cached return NS_OK; } @@ -113,6 +113,16 @@ nsGenericHTMLFrameElement::EnsureFrameLoader() return NS_OK; } +nsresult +nsGenericHTMLFrameElement::CreateRemoteFrameLoader(nsITabParent* aTabParent) +{ + MOZ_ASSERT(!mFrameLoader); + EnsureFrameLoader(); + NS_ENSURE_STATE(mFrameLoader); + mFrameLoader->SetRemoteBrowser(aTabParent); + return NS_OK; +} + NS_IMETHODIMP nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader) { @@ -296,3 +306,21 @@ nsGenericHTMLFrameElement::GetReallyIsBrowser(bool *aOut) *aOut = true; return NS_OK; } + +NS_IMETHODIMP +nsGenericHTMLFrameElement::DisallowCreateFrameLoader() +{ + MOZ_ASSERT(!mFrameLoader); + MOZ_ASSERT(!mFrameLoaderCreationDisallowed); + mFrameLoaderCreationDisallowed = true; + return NS_OK; +} + +NS_IMETHODIMP +nsGenericHTMLFrameElement::AllowCreateFrameLoader() +{ + MOZ_ASSERT(!mFrameLoader); + MOZ_ASSERT(mFrameLoaderCreationDisallowed); + mFrameLoaderCreationDisallowed = false; + return NS_OK; +} diff --git a/content/html/content/src/nsGenericHTMLFrameElement.h b/content/html/content/src/nsGenericHTMLFrameElement.h index 9792ce618db1..bcc426bf8a5c 100644 --- a/content/html/content/src/nsGenericHTMLFrameElement.h +++ b/content/html/content/src/nsGenericHTMLFrameElement.h @@ -25,6 +25,7 @@ public: : nsGenericHTMLElement(aNodeInfo) , mNetworkCreated(aFromParser == mozilla::dom::FROM_PARSER_NETWORK) , mBrowserFrameListenersRegistered(false) + , mFrameLoaderCreationDisallowed(false) { } @@ -99,4 +100,5 @@ protected: bool mNetworkCreated; bool mBrowserFrameListenersRegistered; + bool mFrameLoaderCreationDisallowed; }; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 16a40e7bd4ab..3dfab4199c7c 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -521,6 +521,8 @@ using mozilla::dom::indexedDB::IDBWrapperCache; #include "DOMError.h" #include "DOMRequest.h" +#include "nsIOpenWindowEventDetail.h" +#include "nsIDOMGlobalObjectConstructor.h" #include "DOMFileHandle.h" #include "FileRequest.h" @@ -531,8 +533,6 @@ using mozilla::dom::indexedDB::IDBWrapperCache; #undef None // something included above defines this preprocessor symbol, maybe Xlib headers #include "WebGLContext.h" -#include "nsIDOMGlobalObjectConstructor.h" - using namespace mozilla; using namespace mozilla::dom; @@ -1663,6 +1663,8 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(DOMRequest, nsEventTargetSH, EVENTTARGET_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(OpenWindowEventDetail, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA_WITH_NAME(DOMFileHandle, FileHandle, nsEventTargetSH, EVENTTARGET_SCRIPTABLE_FLAGS) @@ -4526,6 +4528,10 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(OpenWindowEventDetail, nsIOpenWindowEventDetail) + DOM_CLASSINFO_MAP_ENTRY(nsIOpenWindowEventDetail) + DOM_CLASSINFO_MAP_END + DOM_CLASSINFO_MAP_BEGIN(DOMFileHandle, nsIDOMFileHandle) DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileHandle) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 7407d1fe1eb5..82d494dd431a 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -532,6 +532,7 @@ DOMCI_CLASS(BluetoothAdapter) DOMCI_CLASS(DOMError) DOMCI_CLASS(DOMRequest) +DOMCI_CLASS(OpenWindowEventDetail) DOMCI_CLASS(DOMFileHandle) DOMCI_CLASS(FileRequest) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f1be6e7f1d2b..ec30d1366610 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8296,10 +8296,8 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink) else if (aIID.Equals(NS_GET_IID(nsIDocShell))) { FORWARD_TO_OUTER(GetInterface, (aIID, aSink), NS_ERROR_NOT_INITIALIZED); - nsCOMPtr docShell = do_QueryInterface(mDocShell); - if (docShell) { - docShell.forget(aSink); - } + nsCOMPtr docShell = mDocShell; + docShell.forget(aSink); } #ifdef NS_PRINTING else if (aIID.Equals(NS_GET_IID(nsIWebBrowserPrint))) { diff --git a/dom/browser-element/BrowserElementParent.cpp b/dom/browser-element/BrowserElementParent.cpp new file mode 100644 index 000000000000..ad7430aa7629 --- /dev/null +++ b/dom/browser-element/BrowserElementParent.cpp @@ -0,0 +1,209 @@ +/* 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/. */ + +#include "TabParent.h" + +// TabParent.h transitively includes , which does +// #define CreateEvent CreateEventW +// That messes up our call to nsEventDispatcher::CreateEvent below. + +#ifdef CreateEvent +#undef CreateEvent +#endif + +#include "BrowserElementParent.h" +#include "nsHTMLIFrameElement.h" +#include "nsOpenWindowEventDetail.h" +#include "nsEventDispatcher.h" +#include "nsIDOMCustomEvent.h" +#include "nsVariant.h" + +using mozilla::dom::Element; +using mozilla::dom::TabParent; + +namespace { + +/** + * Create an