diff --git a/widget/src/mac/nsMacEventHandler.cpp b/widget/src/mac/nsMacEventHandler.cpp index 2bd59d80285..363837d114f 100644 --- a/widget/src/mac/nsMacEventHandler.cpp +++ b/widget/src/mac/nsMacEventHandler.cpp @@ -371,19 +371,19 @@ PRBool nsMacEventHandler::HandleMenuCommand( // the event is supposed to not have been handled) if (focusedWidget == gEventDispatchHandler.GetActive()) { - nsCOMPtr grandParent; - nsCOMPtr parent ( dont_AddRef((nsWindow*)focusedWidget->GetParent()) ); + nsCOMPtr grandParent; + nsCOMPtr parent ( dont_AddRef(focusedWidget->GetParent()) ); while (parent) { menuEvent.widget = parent; - eventHandled = parent->DispatchWindowEvent(menuEvent); + eventHandled = (static_cast(static_cast(parent)))->DispatchWindowEvent(menuEvent); if (eventHandled) { break; } else { - grandParent = dont_AddRef((nsWindow*)parent->GetParent()); + grandParent = dont_AddRef(parent->GetParent()); parent = grandParent; } } @@ -1099,7 +1099,6 @@ PRBool nsMacEventHandler::HandleMouseDownEvent( nsWindow* widgetHit = (nsWindow*)mouseEvent.widget; if (widgetHit) { - ResetInputState(); #ifdef NOTNOW if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) { nsRect widgetRect,newrect; diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index 4c473969948..996033993e1 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -98,25 +98,6 @@ SetDragActionBasedOnModifiers ( nsIDragService* inDragService, short inModifiers #pragma mark - -NS_IMPL_ADDREF(nsMacWindow); -NS_IMPL_RELEASE(nsMacWindow); -nsresult nsMacWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - if (NULL == aInstancePtr) { - return NS_ERROR_NULL_POINTER; - } - - if (aIID.Equals(nsIKBStateControl::GetIID())) { - *aInstancePtr = (void*) ((nsIKBStateControl*)this); - AddRef(); - return NS_OK; - } - - return nsChildWindow::QueryInterface(aIID,aInstancePtr); -} - -#pragma mark - - //еее this should probably go into the drag session as a static pascal OSErr diff --git a/widget/src/mac/nsMacWindow.h b/widget/src/mac/nsMacWindow.h index cf27fb44464..a7cab109ac8 100644 --- a/widget/src/mac/nsMacWindow.h +++ b/widget/src/mac/nsMacWindow.h @@ -23,7 +23,6 @@ #define MacWindow_h__ #include // for auto_ptr -#include "nsIKBStateControl.h" #include "nsWindow.h" #include "nsMacEventHandler.h" @@ -37,7 +36,7 @@ class nsMacEventHandler; //------------------------------------------------------------------------- // MacOS native window -class nsMacWindow : public nsChildWindow, public nsIKBStateControl +class nsMacWindow : public nsChildWindow { private: typedef nsChildWindow Inherited; @@ -45,10 +44,6 @@ private: public: nsMacWindow(); virtual ~nsMacWindow(); - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(); - NS_IMETHOD_(nsrefcnt) Release(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); /* // nsIWidget interface diff --git a/widget/src/mac/nsWidgetFactory.cpp b/widget/src/mac/nsWidgetFactory.cpp index 43a6aadd7cb..6d3ef18c97b 100644 --- a/widget/src/mac/nsWidgetFactory.cpp +++ b/widget/src/mac/nsWidgetFactory.cpp @@ -193,37 +193,37 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, inst = (nsISupports*)(nsBaseWidget*)new nsMacWindow(); } else if (mClassID.Equals(kCChild)) { - inst = (nsISupports*)new ChildWindow(); + inst = (nsISupports*)(nsBaseWidget*)new ChildWindow(); } else if (mClassID.Equals(kCButton)) { - inst = (nsISupports*)(nsWindow*)new nsButton(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsButton(); } else if (mClassID.Equals(kCCheckButton)) { - inst = (nsISupports*)(nsWindow*)new nsCheckButton(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton(); } else if (mClassID.Equals(kCCombobox)) { - inst = (nsISupports*)(nsWindow*)new nsComboBox(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsComboBox(); } else if (mClassID.Equals(kCRadioButton)) { - inst = (nsISupports*)(nsWindow*)new nsRadioButton(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsRadioButton(); } else if (mClassID.Equals(kCFileOpen)) { - inst = (nsISupports*)(nsWindow*)new nsFileWidget(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsFileWidget(); } else if (mClassID.Equals(kCListbox)) { - inst = (nsISupports*)(nsWindow*)new nsListBox(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsListBox(); } else if (mClassID.Equals(kCHorzScrollbar)) { - inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_FALSE); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_FALSE); } else if (mClassID.Equals(kCVertScrollbar)) { - inst = (nsISupports*)(nsWindow*)new nsScrollbar(PR_TRUE); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_TRUE); } else if (mClassID.Equals(kCTextArea)) { - inst = (nsISupports*)(nsWindow*)new nsTextAreaWidget(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextAreaWidget(); } else if (mClassID.Equals(kCTextField)) { - inst = (nsISupports*)(nsWindow*)new nsTextWidget(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextWidget(); } else if (mClassID.Equals(kCAppShell)) { inst = (nsISupports*)new nsAppShell(); @@ -235,7 +235,7 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, inst = (nsISupports*)new nsLookAndFeel(); } else if (mClassID.Equals(kCLabel)) { - inst = (nsISupports*)(nsWindow*)new nsLabel(); + inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsLabel(); } else if (mClassID.Equals(kCMenuBar)) { inst = (nsISupports*)(nsIMenuBar*) new nsMenuBar(); diff --git a/widget/src/mac/nsWindow.cpp b/widget/src/mac/nsWindow.cpp index 561ece7aef7..a9e8b507c37 100644 --- a/widget/src/mac/nsWindow.cpp +++ b/widget/src/mac/nsWindow.cpp @@ -93,7 +93,7 @@ inline void GetPortVisibleRegion(GrafPtr port, RgnHandle visRgn) // nsWindow constructor // //------------------------------------------------------------------------- -nsWindow::nsWindow() : nsBaseWidget() , nsDeleteObserved(this) +nsWindow::nsWindow() : nsBaseWidget() , nsDeleteObserved(this), nsIKBStateControl() { gInstanceClassName = "nsWindow"; @@ -142,7 +142,7 @@ nsWindow::~nsWindow() nsISupports* child; if (NS_SUCCEEDED(children->CurrentItem(&child))) { - nsWindow* childWindow = static_cast(child); + nsWindow* childWindow = static_cast(static_cast(child)); NS_RELEASE(child); childWindow->mParent = nsnull; @@ -177,6 +177,22 @@ nsWindow::~nsWindow() } } +NS_IMPL_ADDREF(nsWindow); +NS_IMPL_RELEASE(nsWindow); +nsresult nsWindow::QueryInterface(const nsIID& aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + + if (aIID.Equals(nsIKBStateControl::GetIID())) { + *aInstancePtr = (void*) ((nsIKBStateControl*)this); + AddRef(); + return NS_OK; + } + + return nsBaseWidget::QueryInterface(aIID,aInstancePtr); +} //------------------------------------------------------------------------- // @@ -1210,7 +1226,7 @@ void nsWindow::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) do { nsISupports* child; if (NS_SUCCEEDED(children->CurrentItem(&child))) { - nsWindow* childWindow = static_cast(child); + nsWindow* childWindow = static_cast(static_cast(child)); nsRect childBounds; childWindow->GetBounds(childBounds); @@ -1394,7 +1410,7 @@ scrollChildren: nsISupports* child; if (NS_SUCCEEDED(children->CurrentItem(&child))) { - nsWindow* childWindow = static_cast(child); + nsWindow* childWindow = static_cast(static_cast(child)); NS_RELEASE(child); nsRect bounds; @@ -1664,7 +1680,7 @@ void nsWindow::CalcWindowRegions() nsISupports* child; if (NS_SUCCEEDED(children->CurrentItem(&child))) { - nsWindow* childWindow = static_cast(child); + nsWindow* childWindow = static_cast(static_cast(child)); NS_RELEASE(child); PRBool visible; @@ -1773,7 +1789,7 @@ nsWindow* nsWindow::FindWidgetHit(Point aThePoint) nsISupports* child; if (NS_SUCCEEDED(children->CurrentItem(&child))) { - nsWindow* childWindow = static_cast(child); + nsWindow* childWindow = static_cast(static_cast(child)); NS_RELEASE(child); nsWindow* deeperHit = childWindow->FindWidgetHit(aThePoint); @@ -1933,3 +1949,39 @@ NS_IMETHODIMP nsWindow::SetTitle(const nsString& title) NS_ASSERTION(0, "Would some Mac person please implement me? Thanks."); return NS_OK; } + +#pragma mark - + + +NS_IMETHODIMP nsWindow::ResetInputState() +{ + // currently, the nsMacEventHandler is owned by nsMacWindow, which is the top level window + // we deletgate this call to it's parent + nsCOMPtr parent = getter_AddRefs(GetParent()); + NS_ASSERTION(parent, "cannot get parent"); + if(parent) + { + nsCOMPtr kb = do_QueryInterface(parent); + NS_ASSERTION(kb, "cannot get parent"); + if(kb) { + return kb->ResetInputState(); + } + } + return NS_ERROR_ABORT; +} +NS_IMETHODIMP nsWindow::PasswordFieldInit() +{ + // currently, the nsMacEventHandler is owned by nsMacWindow, which is the top level window + // we deletgate this call to it's parent + nsCOMPtr parent = getter_AddRefs(GetParent()); + NS_ASSERTION(parent, "cannot get parent"); + if(parent) + { + nsCOMPtr kb = do_QueryInterface(parent); + NS_ASSERTION(kb, "cannot get parent"); + if(kb) { + return kb->PasswordFieldInit(); + } + } + return NS_ERROR_ABORT; +} diff --git a/widget/src/mac/nsWindow.h b/widget/src/mac/nsWindow.h index bd90c3f38ad..9960724a57a 100644 --- a/widget/src/mac/nsWindow.h +++ b/widget/src/mac/nsWindow.h @@ -27,6 +27,7 @@ #include "nsDeleteObserver.h" #include "nsIWidget.h" +#include "nsIKBStateControl.h" #include "nsIAppShell.h" #include "nsIMouseListener.h" @@ -73,12 +74,18 @@ protected: // //------------------------------------------------------------------------- -class nsWindow : public nsBaseWidget, public nsDeleteObserved +class nsWindow : public nsBaseWidget, public nsDeleteObserved, public nsIKBStateControl { +private: + typedef nsBaseWidget Inherited; public: nsWindow(); virtual ~nsWindow(); + // nsISupports + NS_IMETHOD_(nsrefcnt) AddRef(); + NS_IMETHOD_(nsrefcnt) Release(); + NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, @@ -180,6 +187,11 @@ public: PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;}; void Flash(nsPaintEvent &aEvent); +public: + // nsIKBStateControl interface + NS_IMETHOD ResetInputState(); + NS_IMETHOD PasswordFieldInit(); + protected: PRBool ReportDestroyEvent();