From 7cba57c6bfa2f37fb3949d5b2d0b370b1724f97c Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 19 Aug 2010 13:49:35 -0500 Subject: [PATCH] Bug 582057, part b: Remove nsIDeviceContext::SupportsNativeWidgets because it's not used meaningfully, and will be confusing in content processes. sr=roc --- gfx/src/nsIDeviceContext.h | 16 +--- gfx/src/thebes/nsThebesDeviceContext.cpp | 7 -- gfx/src/thebes/nsThebesDeviceContext.h | 1 - layout/generic/nsObjectFrame.cpp | 4 +- view/src/nsView.cpp | 93 +++++++++++------------- 5 files changed, 45 insertions(+), 76 deletions(-) diff --git a/gfx/src/nsIDeviceContext.h b/gfx/src/nsIDeviceContext.h index 0a06d090ffc7..59d3b559c093 100644 --- a/gfx/src/nsIDeviceContext.h +++ b/gfx/src/nsIDeviceContext.h @@ -169,8 +169,8 @@ const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Sur #endif #define NS_IDEVICE_CONTEXT_IID \ -{ 0x41391E7C, 0x9ED5, 0x4A60, \ - { 0x88, 0x72, 0x06, 0x15, 0x73, 0xF5, 0x0E, 0xE7 } } +{ 0x30a9d22f, 0x8e51, 0x40af, \ + { 0xa1, 0xf5, 0x48, 0xe3, 0x00, 0xaa, 0xa9, 0x27 } } typedef enum { eSystemFont_Caption, // css2 @@ -231,8 +231,7 @@ public: NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0; /** - * Create a rendering context and initialize it. This API should *only* be called - * on device contexts whose SupportsNativeWidgets() method return PR_FALSE. + * Create a rendering context and initialize it. * @param aContext out parameter for new rendering context * @return error status */ @@ -245,15 +244,6 @@ public: */ 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 diff --git a/gfx/src/thebes/nsThebesDeviceContext.cpp b/gfx/src/thebes/nsThebesDeviceContext.cpp index 55aa9ef002fa..366aa64f42c0 100644 --- a/gfx/src/thebes/nsThebesDeviceContext.cpp +++ b/gfx/src/thebes/nsThebesDeviceContext.cpp @@ -790,13 +790,6 @@ nsThebesDeviceContext::CreateRenderingContextInstance(nsIRenderingContext *&aCon return NS_OK; } -NS_IMETHODIMP -nsThebesDeviceContext::SupportsNativeWidgets(PRBool &aSupportsWidgets) -{ - aSupportsWidgets = PR_TRUE; - return NS_OK; -} - NS_IMETHODIMP nsThebesDeviceContext::ClearCachedSystemFonts() { diff --git a/gfx/src/thebes/nsThebesDeviceContext.h b/gfx/src/thebes/nsThebesDeviceContext.h index 8e6b86a9fe5b..2ffe8ea720f0 100644 --- a/gfx/src/thebes/nsThebesDeviceContext.h +++ b/gfx/src/thebes/nsThebesDeviceContext.h @@ -104,7 +104,6 @@ public: 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; diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index a01581625a37..fa45b1a45694 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -697,10 +697,8 @@ nsObjectFrame::CreateWidget(nscoord aWidth, // XXX is the above comment correct? viewMan->SetViewVisibility(view, nsViewVisibility_kHide); - PRBool usewidgets; nsCOMPtr 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 @@ -719,7 +717,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth, return NS_ERROR_FAILURE; } - if (!aViewOnly && !mWidget && usewidgets) { + if (!aViewOnly && !mWidget) { mInnerView = viewMan->CreateView(GetContentRect() - GetPosition(), view); if (!mInnerView) { NS_ERROR("Could not create inner view"); diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index ff58451b2fc0..57dfc6f1403e 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -694,67 +694,56 @@ nsresult nsView::CreateWidget(const nsIID &aWindowIID, if (NS_OK == LoadWidget(aWindowIID)) { - PRBool usewidgets; nsCOMPtr dx; mViewManager->GetDeviceContext(*getter_AddRefs(dx)); - dx->SupportsNativeWidgets(usewidgets); - 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 { - 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 (!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, + 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); } - 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