Bug 565388 - Chrome option for the invisible docshell. r=bz
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Wed, 16 Oct 2013 15:18:42 +0200
changeset 164756 98fe3c07b042053f02dd65e9723ca8d3abe69f46
parent 164755 77a75238baa7f36a7138406e97852055b679734f
child 164757 9373baf8aec2c029e2be797eaec2b40bc100d026
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs565388
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 565388 - Chrome option for the invisible docshell. r=bz
xpfe/appshell/public/nsIAppShellService.idl
xpfe/appshell/src/nsAppShellService.cpp
--- a/xpfe/appshell/public/nsIAppShellService.idl
+++ b/xpfe/appshell/public/nsIAppShellService.idl
@@ -12,17 +12,17 @@ interface nsIDOMWindow;
 interface nsIAppShell;
 
 [ptr] native JSContext(JSContext);
 
 %{C++
 #include "js/TypeDecls.h"
 %}
 
-[scriptable, uuid(5c19ab54-67bf-46d0-ac5b-21abd9050c3b)]
+[scriptable, uuid(3927a495-575a-4a12-b9ab-6b948f76ec1f)]
 interface nsIAppShellService : nsISupports
 {
   /**
    * Create a window, which will be initially invisible.
    * @param aParent the parent window.  Can be null.
    * @param aUrl the contents of the new window.
    * @param aChromeMask chrome flags affecting the kind of OS border
    *                    given to the window. see nsIBrowserWindow for
@@ -39,17 +39,23 @@ interface nsIAppShellService : nsISuppor
    */
   const long SIZE_TO_CONTENT = -1;
   nsIXULWindow createTopLevelWindow(in nsIXULWindow aParent,
                                     in nsIURI aUrl, 
                                     in uint32_t aChromeMask,
                                     in long aInitialWidth,
                                     in long aInitialHeight);
 
-  nsIWebNavigation createWindowlessBrowser();
+  /**
+   * This is the constructor for creating an invisible DocShell.
+   * It is used to simulate DOM windows without an actual physical
+   * representation.
+   * @param aIsChrome Set true if you want to use it for chrome content.
+   */
+  nsIWebNavigation createWindowlessBrowser([optional] in bool aIsChrome);
 
   [noscript]
   void createHiddenWindow();
 
   void destroyHiddenWindow();
 
   /**
    * Return the (singleton) application hidden window, automatically created
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -343,17 +343,17 @@ NS_INTERFACE_MAP_BEGIN(WindowlessBrowser
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(WindowlessBrowserStub)
 NS_IMPL_RELEASE(WindowlessBrowserStub)
 
 
 NS_IMETHODIMP
-nsAppShellService::CreateWindowlessBrowser(nsIWebNavigation **aResult)
+nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, nsIWebNavigation **aResult)
 {
   /* First, we create an instance of nsWebBrowser. Instances of this class have
    * an associated doc shell, which is what we're interested in.
    */
   nsCOMPtr<nsIWebBrowser> browser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
   if (!browser) {
     NS_ERROR("Couldn't create instance of nsWebBrowser!");
     return NS_ERROR_FAILURE;
@@ -369,17 +369,18 @@ nsAppShellService::CreateWindowlessBrows
     NS_ERROR("Couldn't create instance of WebBrowserChrome2Stub!");
     return NS_ERROR_FAILURE;
   }
   browser->SetContainerWindow(stub);
 
   nsCOMPtr<nsIWebNavigation> navigation = do_QueryInterface(browser);
 
   nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(navigation);
-  item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
+  item->SetItemType(aIsChrome ? nsIDocShellTreeItem::typeChromeWrapper
+                              : nsIDocShellTreeItem::typeContentWrapper);
 
   /* A windowless web browser doesn't have an associated OS level window. To
    * accomplish this, we initialize the window associated with our instance of
    * nsWebBrowser with an instance of PuppetWidget, which provides a stub
    * implementation of nsIWidget.
    */
   nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(nullptr);
   if (!widget) {