Merge backout
authorChris Jones <jones.chris.g@gmail.com>
Thu, 19 Aug 2010 19:03:12 -0500
changeset 50967 cab73e98bb54b2ca34d730333208cc84ea726eeb
parent 50965 0a51470adf6a2dc433fdb2fa5ee6ef5b5276143e (current diff)
parent 50966 fba488e43c5a2fdba513261d57146f508ed0d51d (diff)
child 50969 ff12e02a5a465e0fdc76f2dc9ae365fcd46ee9df
push id15200
push usercjones@mozilla.com
push dateFri, 20 Aug 2010 00:06:25 +0000
treeherdermozilla-central@e75e9d539c40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b5pre
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
Merge backout
view/src/nsView.cpp
--- a/gfx/src/nsIDeviceContext.h
+++ b/gfx/src/nsIDeviceContext.h
@@ -164,18 +164,18 @@ typedef void * nsNativeDeviceContext;
 const PRUint8 kUseAltDCFor_NONE            = 0x00; // Do not use the AltDC for anything
 const PRUint8 kUseAltDCFor_FONTMETRICS     = 0x01; // Use it for only getting the font metrics
 const PRUint8 kUseAltDCFor_CREATERC_REFLOW = 0x02; // Use when creating RenderingContexts for Reflow
 const PRUint8 kUseAltDCFor_CREATERC_PAINT  = 0x04; // Use when creating RenderingContexts for Painting
 const PRUint8 kUseAltDCFor_SURFACE_DIM     = 0x08; // Use it for getting the Surface Dimensions
 #endif
 
 #define NS_IDEVICE_CONTEXT_IID   \
-{ 0x30a9d22f, 0x8e51, 0x40af, \
-  { 0xa1, 0xf5, 0x48, 0xe3, 0x00, 0xaa, 0xa9, 0x27 } }
+{ 0x41391E7C, 0x9ED5, 0x4A60, \
+  { 0x88, 0x72, 0x06, 0x15, 0x73, 0xF5, 0x0E, 0xE7 } }
 
   typedef enum {
     eSystemFont_Caption,         // css2
     eSystemFont_Icon,
     eSystemFont_Menu,
     eSystemFont_MessageBox,
     eSystemFont_SmallCaption,
     eSystemFont_StatusBar,
@@ -226,30 +226,40 @@ public:
    * Create a rendering context and initialize it from an nsIWidget
    * @param aWidget widget to initialize context from
    * @param aContext out parameter for new rendering context
    * @return error status
    */
   NS_IMETHOD  CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
 
   /**
-   * Create a rendering context and initialize it.
+   * Create a rendering context and initialize it. This API should *only* be called
+   * on device contexts whose SupportsNativeWidgets() method return PR_FALSE.
    * @param aContext out parameter for new rendering context
    * @return error status
    */
   NS_IMETHOD  CreateRenderingContext(nsIRenderingContext *&aContext) = 0;
 
   /**
    * Create an uninitalised rendering context.
    * @param aContext out parameter for new rendering context
    * @return error status
    */
   NS_IMETHOD  CreateRenderingContextInstance(nsIRenderingContext *&aContext) = 0;
 
   /**
+   * Query the device to see if it supports native widgets. If not, then
+   * nsIWidget->Create() calls should be avoided.
+   * @param aSupportsWidgets out paramater. If PR_TRUE, then native widgets
+   *        can be created.
+   * @return error status
+   */
+  NS_IMETHOD  SupportsNativeWidgets(PRBool &aSupportsWidgets) = 0;
+
+  /**
    * We are in the process of creating the native widget for aWidget.
    * Do any device-specific processing required to initialize the
    * native widget for this device. A pointer to some platform-specific data is
    * returned in aOut.
    *
    * GTK2 calls this to get the required visual for the window.
    */
   NS_IMETHOD PrepareNativeWidget(nsIWidget* aWidget, void** aOut) = 0;
--- a/gfx/src/thebes/nsThebesDeviceContext.cpp
+++ b/gfx/src/thebes/nsThebesDeviceContext.cpp
@@ -786,16 +786,23 @@ nsThebesDeviceContext::CreateRenderingCo
 
     aContext = renderingContext;
     NS_ADDREF(aContext);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
+nsThebesDeviceContext::SupportsNativeWidgets(PRBool &aSupportsWidgets)
+{
+    aSupportsWidgets = PR_TRUE;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
 nsThebesDeviceContext::ClearCachedSystemFonts()
 {
     //clear our cache of stored system fonts
     if (gSystemFonts) {
         delete gSystemFonts;
         gSystemFonts = nsnull;
     }
     return NS_OK;
--- a/gfx/src/thebes/nsThebesDeviceContext.h
+++ b/gfx/src/thebes/nsThebesDeviceContext.h
@@ -99,16 +99,17 @@ public:
 
     NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
                                 PRBool& aAliased);
 
     NS_IMETHOD CreateFontCache();
     NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
     NS_IMETHOD FlushFontCache(void);
 
+    NS_IMETHOD SupportsNativeWidgets(PRBool& aSupportsWidgets);
     NS_IMETHOD PrepareNativeWidget(nsIWidget *aWidget, void **aOut);
 
     NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
     NS_IMETHOD ClearCachedSystemFonts();
 
     NS_IMETHOD CheckFontExistence(const nsString& aFaceName);
 
     NS_IMETHOD GetDepth(PRUint32& aDepth);
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -692,18 +692,20 @@ nsObjectFrame::CreateWidget(nscoord aWid
     return NS_OK;       //XXX why OK? MMP
   }
 
   nsIViewManager* viewMan = view->GetViewManager();
   // mark the view as hidden since we don't know the (x,y) until Paint
   // XXX is the above comment correct?
   viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
 
+  PRBool usewidgets;
   nsCOMPtr<nsIDeviceContext> dx;
   viewMan->GetDeviceContext(*getter_AddRefs(dx));
+  dx->SupportsNativeWidgets(usewidgets);
 
   //this is ugly. it was ripped off from didreflow(). MMP
   // Position and size view relative to its parent, not relative to our
   // parent frame (our parent frame may not have a view).
   
   nsIView* parentWithView;
   nsPoint origin;
   nsRect r(0, 0, mRect.width, mRect.height);
@@ -712,17 +714,17 @@ nsObjectFrame::CreateWidget(nscoord aWid
   viewMan->ResizeView(view, r);
   viewMan->MoveViewTo(view, origin.x, origin.y);
 
   nsRootPresContext* rpc = PresContext()->GetRootPresContext();
   if (!rpc) {
     return NS_ERROR_FAILURE;
   }
 
-  if (!aViewOnly && !mWidget) {
+  if (!aViewOnly && !mWidget && usewidgets) {
     mInnerView = viewMan->CreateView(GetContentRect() - GetPosition(), view);
     if (!mInnerView) {
       NS_ERROR("Could not create inner view");
       return NS_ERROR_OUT_OF_MEMORY;
     }
     viewMan->InsertChild(view, mInnerView, nsnull, PR_TRUE);
 
     nsresult rv;
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -689,66 +689,77 @@ nsresult nsView::CreateWidget(const nsII
   }
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData
                                      ? aWidgetInitData->mWindowType
                                      : eWindowType_child);
 
   if (NS_OK == LoadWidget(aWindowIID))
   {
+    PRBool usewidgets;
     nsCOMPtr<nsIDeviceContext> dx;
     mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+    dx->SupportsNativeWidgets(usewidgets);
 
-    PRBool initDataPassedIn = PR_TRUE;
-    nsWidgetInitData initData;
-    if (!aWidgetInitData) {
-      // No initData, we're a child window
-      // Create initData to pass in params
-      initDataPassedIn = PR_FALSE;
-      initData.clipChildren = PR_TRUE; // Clip child window's children
-      initData.clipSiblings = PR_TRUE; // Clip child window's siblings
-      aWidgetInitData = &initData;
-    }
-    aWidgetInitData->mContentType = aContentType;
+    if (PR_TRUE == usewidgets)
+    {
+      PRBool initDataPassedIn = PR_TRUE;
+      nsWidgetInitData initData;
+      if (!aWidgetInitData) {
+        // No initData, we're a child window
+        // Create initData to pass in params
+        initDataPassedIn = PR_FALSE;
+        initData.clipChildren = PR_TRUE; // Clip child window's children
+        initData.clipSiblings = PR_TRUE; // Clip child window's siblings
+        aWidgetInitData = &initData;
+      }
+      aWidgetInitData->mContentType = aContentType;
 
-    if (aNative && aWidgetInitData->mWindowType != eWindowType_popup)
-      mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-    else
-    {
-      if (!initDataPassedIn && GetParent() && 
+      if (aNative && aWidgetInitData->mWindowType != eWindowType_popup)
+        mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+      else
+      {
+        if (!initDataPassedIn && GetParent() && 
           GetParent()->GetViewManager() != mViewManager)
-        initData.mListenForResizes = PR_TRUE;
-      if (aParentWidget) {
-        NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
-                     "popup widget type expected");
-        mWindow->Create(aParentWidget, nsnull, trect,
-                        ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-      }
-      else {
-        nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
-                                              : nsnull;
-        if (aWidgetInitData->mWindowType == eWindowType_popup) {
-          // Without a parent, we can't make a popup.  This can happen
-          // when printing
-          if (!parentWidget)
-            return NS_ERROR_FAILURE;
-          mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
-                          ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
-        } else {
-          mWindow->Create(parentWidget, nsnull, trect,
+          initData.mListenForResizes = PR_TRUE;
+        if (aParentWidget) {
+          NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
+                       "popup widget type expected");
+          mWindow->Create(aParentWidget, nsnull, trect,
                           ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
         }
+        else {
+          nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
+                                                : nsnull;
+          if (aWidgetInitData->mWindowType == eWindowType_popup) {
+            // Without a parent, we can't make a popup.  This can happen
+            // when printing
+            if (!parentWidget)
+              return NS_ERROR_FAILURE;
+            mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
+                            ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+          } else {
+            mWindow->Create(parentWidget, nsnull, trect,
+                            ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
+          }
+        }
       }
+      if (aEnableDragDrop) {
+        mWindow->EnableDragDrop(PR_TRUE);
+      }
+      
+      // propagate the z-index to the widget.
+      UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
+    } else {
+      // We should tell the widget its size even if we don't create a
+      // native widget.  (At the moment, this doesn't really matter,
+      // but we might want it to work at some point.)
+      mWindow->Resize(trect.x, trect.y, trect.width, trect.height,
+                      PR_FALSE);
     }
-    if (aEnableDragDrop) {
-      mWindow->EnableDragDrop(PR_TRUE);
-    }
-      
-    // propagate the z-index to the widget.
-    UpdateNativeWidgetZIndexes(this, FindNonAutoZIndex(this));
   }
 
   //make sure visibility state is accurate
 
   if (aResetVisibility) {
     SetVisibility(GetVisibility());
   }