Bug 515446 - Combine the two Create methods of nsIWidget into one. Also remove nsCocoaWindow's capability of adapting its NSWindow from aNativeParent. r=josh, sr=roc

This commit is contained in:
Markus Stange 2009-09-24 18:18:10 +12:00
Родитель 4ef626577f
Коммит 5714a2fee4
23 изменённых файлов: 136 добавлений и 558 удалений

Просмотреть файл

@ -1135,7 +1135,7 @@ NS_IMETHODIMP nsWebBrowser::Create()
nsIntRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy);
mInternalWidget->SetClientData(static_cast<nsWebBrowser *>(this));
mInternalWidget->Create(mParentNativeWindow, bounds, nsWebBrowser::HandleEvent,
mInternalWidget->Create(nsnull, mParentNativeWindow, bounds, nsWebBrowser::HandleEvent,
nsnull, nsnull, nsnull, &widgetInit);
}

Просмотреть файл

@ -720,7 +720,7 @@ nsObjectFrame::CreateWidget(nscoord aWidth,
// allow the view to attach its event handler to mWidget even though
// mWidget isn't the view's designated widget.
EVENT_CALLBACK eventHandler = view->AttachWidgetEventHandler(mWidget);
mWidget->Create(parentWidget, nsIntRect(0,0,0,0),
mWidget->Create(parentWidget, nsnull, nsIntRect(0,0,0,0),
eventHandler, dx, nsnull, nsnull, &initData);
mWidget->EnableDragDrop(PR_TRUE);

Просмотреть файл

@ -648,7 +648,7 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID,
aWidgetInitData->mContentType = aContentType;
if (aNative && aWidgetInitData->mWindowType != eWindowType_popup)
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
mWindow->Create(nsnull, aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
else
{
if (!initDataPassedIn && GetParent() &&
@ -657,7 +657,7 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID,
if (aParentWidget) {
NS_ASSERTION(aWidgetInitData->mWindowType == eWindowType_popup,
"popup widget type expected");
mWindow->Create(aParentWidget, trect,
mWindow->Create(aParentWidget, nsnull, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
else {
@ -668,10 +668,10 @@ nsresult nsIView::CreateWidget(const nsIID &aWindowIID,
// when printing
if (!parentWidget)
return NS_ERROR_FAILURE;
mWindow->Create(parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
mWindow->Create(nsnull, parentWidget->GetNativeData(NS_NATIVE_WIDGET), trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
} else {
mWindow->Create(parentWidget, trect,
mWindow->Create(parentWidget, nsnull, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
}

Просмотреть файл

@ -188,9 +188,6 @@ class nsIWidget : public nsISupports {
/**
* Create and initialize a widget.
*
* The widget represents a window that can be drawn into. It also is the
* base class for user-interface widgets such as buttons and text boxes.
*
* All the arguments can be NULL in which case a top level window
* with size 0 is created. The event callback function has to be
* provided only if the caller wants to deal with the events this
@ -203,54 +200,29 @@ class nsIWidget : public nsISupports {
* calling code must handle paint messages and clear the background
* itself.
*
* aInitData cannot be eWindowType_popup here; popups cannot be
* hooked into the nsIWidget hierarchy.
* In practice at least one of aParent and aNativeParent will be null. If
* both are null the widget isn't parented (e.g. context menus or
* independent top level windows).
*
* @param parent or null if it's a top level window
* @param aRect the widget dimension
* @param aParent parent nsIWidget
* @param aNativeParent native parent widget
* @param aRect the widget dimension
* @param aHandleEventFunction the event handler callback function
* @param aContext
* @param aAppShell the parent application shell. If nsnull,
* the parent window's application shell will be used.
* @param aAppShell the parent application shell. If nsnull,
* the parent window's application shell will be used.
* @param aToolkit
* @param aInitData data that is used for widget initialization
* @param aInitData data that is used for widget initialization
*
*/
NS_IMETHOD Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull) = 0;
/**
* Create and initialize a widget with a native window parent
*
* The widget represents a window that can be drawn into. It also is the
* base class for user-interface widgets such as buttons and text boxes.
*
* All the arguments can be NULL in which case a top level window
* with size 0 is created. The event callback function has to be
* provided only if the caller wants to deal with the events this
* widget receives. The event callback is basically a preprocess
* hook called synchronously. The return value determines whether
* the event goes to the default window procedure or it is hidden
* to the os. The assumption is that if the event handler returns
* false the widget does not see the event.
*
* @param aParent native window.
* @param aRect the widget dimension
* @param aHandleEventFunction the event handler callback function
*/
NS_IMETHOD Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull) = 0;
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull) = 0;
/**
* Accessor functions to get and set the client data associated with the

Просмотреть файл

@ -41,19 +41,14 @@ nsChildView::nsChildView() : nsWindow()
}
//-------------------------------------------------------------------------
//
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
//-------------------------------------------------------------------------
nsresult nsChildView::StandardWindowCreate(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
nsresult nsChildView::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
NS_ASSERTION(aInitData->mWindowType == eWindowType_child

Просмотреть файл

@ -47,18 +47,5 @@ public:
NS_IMETHOD Show(PRBool bState);
NS_IMETHOD SetTitle(const nsAString& aTitle);
protected:
virtual nsresult StandardWindowCreate(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
};
#endif //nsChildView_h__

Просмотреть файл

@ -442,19 +442,14 @@ NS_IMETHODIMP nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
//-------------------------------------------------------------------------
nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
nsresult nsWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
//Do as little as possible for invisible windows, why are these needed?
@ -556,80 +551,6 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Create the proper widget
//
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// Switch to the "main gui thread" if necessary... This method must
// be executed on the "gui thread"...
nsToolkit* toolkit = (nsToolkit *)mToolkit;
if (toolkit && !toolkit->IsGuiThread())
{
nsCOMPtr<nsIWidget> widgetProxy;
nsresult rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
NS_GET_IID(nsIWidget),
this,
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(widgetProxy));
if (NS_FAILED(rv))
return rv;
return widgetProxy->Create(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
}
return(StandardWindowCreate(aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData,
nsnull));
}
//-------------------------------------------------------------------------
//
// create with a native parent
//
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// Switch to the "main gui thread" if necessary... This method must
// be executed on the "gui thread"...
nsToolkit* toolkit = (nsToolkit *)mToolkit;
if (toolkit && !toolkit->IsGuiThread())
{
nsCOMPtr<nsIWidget> widgetProxy;
nsresult rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
NS_GET_IID(nsIWidget),
this,
NS_PROXY_SYNC | NS_PROXY_ALWAYS,
getter_AddRefs(widgetProxy));
if (NS_FAILED(rv))
return rv;
return widgetProxy->Create(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
}
return(StandardWindowCreate(nsnull, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData,
aParent));
}
gfxASurface*
nsWindow::GetThebesSurface()
{

Просмотреть файл

@ -94,13 +94,7 @@ public:
// nsIWidget interface
NS_IMETHOD Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsNativeWidget aParent,
nsNativeWidget aNativeParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -108,19 +102,7 @@ public:
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
virtual nsresult StandardWindowCreate(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
gfxASurface* GetThebesSurface();

Просмотреть файл

@ -313,31 +313,13 @@ public:
// nsIWidget interface
NS_IMETHOD Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
virtual nsresult StandardCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
NS_IMETHOD Destroy();

Просмотреть файл

@ -774,16 +774,14 @@ nsChildView::~nsChildView()
NS_IMPL_ISUPPORTS_INHERITED1(nsChildView, nsBaseWidget, nsIPluginWidget)
// Utility method for implementing both Create(nsIWidget ...)
// and Create(nsNativeWidget...)
nsresult nsChildView::StandardCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
nsresult nsChildView::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -797,12 +795,13 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
mBounds = aRect;
BaseCreate(aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
aContext, aAppShell, aToolkit, aInitData);
// inherit things from the parent view and create our parallel
// NSView in the Cocoa display system
mParentView = nil;
if (aParent) {
// This is the case when we're the popup content view of a popup window.
SetBackgroundColor(aParent->GetBackgroundColor());
SetForegroundColor(aParent->GetForegroundColor());
@ -811,9 +810,12 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
// with windows).
mParentView = (NSView*)aParent->GetNativeData(NS_NATIVE_WIDGET);
mParentWidget = aParent;
}
else
} else {
// This is the normal case. When we're the root widget of the view hiararchy,
// aNativeParent will be the contentView of our window, since that's what
// nsCocoaWindow returns when asked for an NS_NATIVE_VIEW.
mParentView = reinterpret_cast<NSView*>(aNativeParent);
}
// create our parallel NSView and hook it up to our parent. Recall
// that NS_NATIVE_WIDGET is the NSView.
@ -905,33 +907,6 @@ nsChildView::GetXULWindowWidget()
return nsnull;
}
// create a nsChildView
NS_IMETHODIMP nsChildView::Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return(StandardCreate(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData, nsnull));
}
// Creates a main nsChildView using a native widget (an NSView)
NS_IMETHODIMP nsChildView::Create(nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// what we're passed in |aNativeParent| is an NSView.
return(StandardCreate(nsnull, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData, aNativeParent));
}
NS_IMETHODIMP nsChildView::Destroy()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;

Просмотреть файл

@ -178,15 +178,8 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSPIWIDGETCOCOA
NS_IMETHOD Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsIWidget* aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -271,16 +264,6 @@ public:
protected:
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
nsresult StandardCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeWindow = nsnull);
nsresult CreateNativeWindow(const NSRect &aRect,
nsBorderStyle aBorderStyle,
PRBool aRectIsFrameRect);

Просмотреть файл

@ -214,16 +214,14 @@ static PRBool UseNativePopupWindows()
return (NS_SUCCEEDED(rv) && useNativePopupWindows);
}
// Utility method for implementing both Create(nsIWidget ...) and
// Create(nsNativeWidget...)
nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeWindow)
nsresult nsCocoaWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -237,20 +235,16 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
SetWindowType(aInitData ? aInitData->mWindowType : eWindowType_toplevel);
SetBorderStyle(aInitData ? aInitData->mBorderStyle : eBorderStyle_default);
// Create a window if we aren't given one, or if this should be a non-native popup.
if ((mWindowType == eWindowType_popup) ? !UseNativePopupWindows() : !aNativeWindow) {
nsresult rv = CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(aRect),
mBorderStyle, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// Applications that use native popups don't want us to create popup windows.
if ((mWindowType == eWindowType_popup) && UseNativePopupWindows())
return NS_OK;
if (mWindowType == eWindowType_popup) {
rv = CreatePopupContentView(aRect, aHandleEventFunction, aContext, aAppShell, aToolkit);
NS_ENSURE_SUCCESS(rv, rv);
}
} else {
mWindow = (NSWindow*)aNativeWindow;
[[WindowDataMap sharedWindowDataMap] ensureDataForWindow:mWindow];
}
nsresult rv = CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(aRect),
mBorderStyle, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
if (mWindowType == eWindowType_popup)
return CreatePopupContentView(aRect, aHandleEventFunction, aContext, aAppShell, aToolkit);
return NS_OK;
@ -423,8 +417,8 @@ NS_IMETHODIMP nsCocoaWindow::CreatePopupContentView(const nsIntRect &aRect,
NS_ADDREF(mPopupContentView);
nsIWidget* thisAsWidget = static_cast<nsIWidget*>(this);
mPopupContentView->StandardCreate(thisAsWidget, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, nsnull, nsnull);
mPopupContentView->Create(thisAsWidget, nsnull, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, nsnull);
ChildView* newContentView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
[mWindow setContentView:newContentView];
@ -434,31 +428,6 @@ NS_IMETHODIMP nsCocoaWindow::CreatePopupContentView(const nsIntRect &aRect,
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
// Create a nsCocoaWindow using a native window provided by the application
NS_IMETHODIMP nsCocoaWindow::Create(nsNativeWidget aNativeWindow,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return(StandardCreate(nsnull, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData, aNativeWindow));
}
NS_IMETHODIMP nsCocoaWindow::Create(nsIWidget* aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
return(StandardCreate(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData, nsnull));
}
NS_IMETHODIMP nsCocoaWindow::Destroy()
{
if (mPopupContentView)

Просмотреть файл

@ -609,34 +609,6 @@ nsWindow::AreBoundsSane(void)
return PR_FALSE;
}
NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
nsresult rv = NativeCreate(aParent, nsnull, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
return rv;
}
NS_IMETHODIMP
nsWindow::Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
nsresult rv = NativeCreate(nsnull, aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
return rv;
}
static GtkWidget*
EnsureInvisibleContainer()
{
@ -3753,14 +3725,14 @@ CreateGdkWindow(GdkWindow *parent, GtkWidget *widget)
}
nsresult
nsWindow::NativeCreate(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
nsWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// only set the base parent if we're going to be a dialog or a
// toplevel

Просмотреть файл

@ -133,13 +133,7 @@ public:
// nsIWidget
NS_IMETHOD Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
NS_IMETHOD Create(nsNativeWidget aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -270,16 +264,6 @@ public:
void OnDragLeave(void);
void OnDragEnter(nscoord aX, nscoord aY);
nsresult NativeCreate(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
virtual void NativeResize(PRInt32 aWidth,
PRInt32 aHeight,
PRBool aRepaint);

Просмотреть файл

@ -910,55 +910,31 @@ void nsWindow::RealDoCreate( HWND hwndP,
//
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
HWND hwndP = aParent ? (HWND)aParent->GetNativeData( NS_NATIVE_WINDOW)
: HWND_DESKTOP;
HWND hwndP = (HWND)aNativeParent;
if (!hwndP) {
HWND hwndP = aParent ? (HWND)aParent->GetNativeData(NS_NATIVE_WINDOW) :
HWND_DESKTOP;
}
DoCreate( hwndP, (nsWindow*) aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
// We need to find the nsWindow that goes with the native window, or controls
// all get the ID of 0, and a zillion toolkits get created.
nsWindow *pParent = (nsWindow*)aParent;
if (!pParent && hwndP && hwndP != HWND_DESKTOP) {
pParent = GetNSWindowPtr(hwndP);
}
return NS_OK;
}
DoCreate(hwndP, pParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
//-------------------------------------------------------------------------
//
// create with a native parent
//
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// We need to find the nsWindow that goes with the native window, or controls
// all get the ID of 0, and a zillion toolkits get created.
//
nsWindow *pParent = nsnull;
HWND hwndP = (HWND) aParent;
if( hwndP && hwndP != HWND_DESKTOP)
pParent = GetNSWindowPtr(hwndP);
// XXX WC_MOZILLA will probably need a change here
//
if( !hwndP)
hwndP = HWND_DESKTOP;
DoCreate( hwndP, pParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
return NS_OK;
return NS_OK;
}
//-------------------------------------------------------------------------

Просмотреть файл

@ -105,15 +105,9 @@ class nsWindow : public nsBaseWidget
// nsIWidget
// Creation from native (eh?) or widget parent, destroy
// Creation from native widget parent or nsIWidget parent, destroy
NS_IMETHOD Create( nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create( nsNativeWidget aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,

Просмотреть файл

@ -591,13 +591,13 @@ NS_IMETHODIMP nsWidget::InvalidateRegion( const nsIRegion *aRegion, PRBool aIsSy
}
nsresult nsWidget::CreateWidget(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
nsWidgetInitData *aInitData)
{
PtWidget_t *parentWidget = nsnull;

Просмотреть файл

@ -70,29 +70,14 @@ public:
// nsIWidget
// create with nsIWidget parent
inline NS_IMETHOD Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull)
{
return(CreateWidget(aParent, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData, nsnull));
}
// create with a native parent
inline NS_IMETHOD Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull)
{
return(CreateWidget(nsnull, aRect, aHandleEventFunction, aContext, aAppShell, aToolkit, aInitData,aParent));
}
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Destroy(void);
inline nsIWidget* GetParent(void)
@ -229,15 +214,6 @@ public:
protected:
NS_IMETHOD CreateNative(PtWidget_t *parentWindow) { return NS_OK; }
nsresult CreateWidget(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
inline PRBool DispatchWindowEvent(nsGUIEvent* event)
{
nsEventStatus status;

Просмотреть файл

@ -235,38 +235,6 @@ nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>& aConfigura
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
LOG(("%s [%p]\n", __PRETTY_FUNCTION__, (void *)this));
nsresult rv = NativeCreate(aParent, nsnull, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
return rv;
}
NS_IMETHODIMP
nsWindow::Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
LOG(("%s [%p]\n", __PRETTY_FUNCTION__, (void *)this));
nsresult rv = NativeCreate(nsnull, aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData);
return rv;
}
NS_IMETHODIMP
nsWindow::Destroy(void)
{
@ -1594,14 +1562,14 @@ GetBrandName(nsXPIDLString& brandName)
nsresult
nsWindow::NativeCreate(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
nsWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
// only set the base parent if we're going to be a dialog or a
// toplevel

Просмотреть файл

@ -116,14 +116,8 @@ public:
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
NS_IMETHOD Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
NS_IMETHOD Create(nsNativeWidget aParent,
const nsIntRect &aRect,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
@ -276,15 +270,6 @@ protected:
nsEventStatus OnWindowStateEvent(QEvent *aEvent);
nsresult NativeCreate(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData);
void NativeResize(PRInt32 aWidth,
PRInt32 aHeight,
PRBool aRepaint);

Просмотреть файл

@ -460,39 +460,6 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
*
**************************************************************/
// Create the proper widget
NS_METHOD nsWindow::Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
if (aInitData)
mUnicodeWidget = aInitData->mUnicode;
return(StandardWindowCreate(aParent, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData,
nsnull));
}
// Create with a native parent
NS_METHOD nsWindow::Create(nsNativeWidget aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
if (aInitData)
mUnicodeWidget = aInitData->mUnicode;
return(StandardWindowCreate(nsnull, aRect, aHandleEventFunction,
aContext, aAppShell, aToolkit, aInitData,
aParent));
}
// Allow Derived classes to modify the height that is passed
// when the window is created or resized. Also add extra height
// if needed (on Windows CE)
@ -510,17 +477,20 @@ PRInt32 nsWindow::GetHeight(PRInt32 aProposedHeight)
return aProposedHeight + extra;
}
// Utility methods for creating windows.
// Create the proper widget
nsresult
nsWindow::StandardWindowCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent)
nsWindow::Create(nsIWidget *aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData)
{
if (aInitData)
mUnicodeWidget = aInitData->mUnicode;
nsIWidget *baseParent = aInitData &&
(aInitData->mWindowType == eWindowType_dialog ||
aInitData->mWindowType == eWindowType_toplevel ||

Просмотреть файл

@ -101,13 +101,7 @@ public:
* nsIWidget interface
*/
NS_IMETHOD Create(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsNativeWidget aParent,
nsNativeWidget aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
@ -332,14 +326,6 @@ protected:
virtual LPCWSTR WindowPopupClass();
virtual DWORD WindowStyle();
virtual DWORD WindowExStyle();
virtual nsresult StandardWindowCreate(nsIWidget *aParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
/**
* XP and Vista theming support for windows with rounded edges

Просмотреть файл

@ -190,6 +190,7 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
mWindow->SetClientData(this);
mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget
nsnull, // Native parent widget
r, // Widget dimensions
nsWebShellWindow::HandleEvent, // Event handler function
nsnull, // Device context