зеркало из https://github.com/mozilla/pjs.git
fix bug 19358. r=erik,pierre,pinkerton. Move the support of nsIKBStateControl from nsMacWindow to nsWindow. Remove unnecessary ResetInputState in mouse click. That is already been replaced by xp code. Clean up casting compilation error after change the class hier.
This commit is contained in:
Родитель
cb98c50b32
Коммит
36e9a8378c
|
@ -371,19 +371,19 @@ PRBool nsMacEventHandler::HandleMenuCommand(
|
||||||
// the event is supposed to not have been handled)
|
// the event is supposed to not have been handled)
|
||||||
if (focusedWidget == gEventDispatchHandler.GetActive())
|
if (focusedWidget == gEventDispatchHandler.GetActive())
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsWindow> grandParent;
|
nsCOMPtr<nsIWidget> grandParent;
|
||||||
nsCOMPtr<nsWindow> parent ( dont_AddRef((nsWindow*)focusedWidget->GetParent()) );
|
nsCOMPtr<nsIWidget> parent ( dont_AddRef(focusedWidget->GetParent()) );
|
||||||
while (parent)
|
while (parent)
|
||||||
{
|
{
|
||||||
menuEvent.widget = parent;
|
menuEvent.widget = parent;
|
||||||
eventHandled = parent->DispatchWindowEvent(menuEvent);
|
eventHandled = (static_cast<nsWindow*>(static_cast<nsIWidget*>(parent)))->DispatchWindowEvent(menuEvent);
|
||||||
if (eventHandled)
|
if (eventHandled)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grandParent = dont_AddRef((nsWindow*)parent->GetParent());
|
grandParent = dont_AddRef(parent->GetParent());
|
||||||
parent = grandParent;
|
parent = grandParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1099,6 @@ PRBool nsMacEventHandler::HandleMouseDownEvent(
|
||||||
nsWindow* widgetHit = (nsWindow*)mouseEvent.widget;
|
nsWindow* widgetHit = (nsWindow*)mouseEvent.widget;
|
||||||
if (widgetHit)
|
if (widgetHit)
|
||||||
{
|
{
|
||||||
ResetInputState();
|
|
||||||
#ifdef NOTNOW
|
#ifdef NOTNOW
|
||||||
if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) {
|
if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) {
|
||||||
nsRect widgetRect,newrect;
|
nsRect widgetRect,newrect;
|
||||||
|
|
|
@ -98,25 +98,6 @@ SetDragActionBasedOnModifiers ( nsIDragService* inDragService, short inModifiers
|
||||||
|
|
||||||
#pragma mark -
|
#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
|
//¥¥¥ this should probably go into the drag session as a static
|
||||||
pascal OSErr
|
pascal OSErr
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#define MacWindow_h__
|
#define MacWindow_h__
|
||||||
|
|
||||||
#include <memory> // for auto_ptr
|
#include <memory> // for auto_ptr
|
||||||
#include "nsIKBStateControl.h"
|
|
||||||
|
|
||||||
#include "nsWindow.h"
|
#include "nsWindow.h"
|
||||||
#include "nsMacEventHandler.h"
|
#include "nsMacEventHandler.h"
|
||||||
|
@ -37,7 +36,7 @@ class nsMacEventHandler;
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// MacOS native window
|
// MacOS native window
|
||||||
|
|
||||||
class nsMacWindow : public nsChildWindow, public nsIKBStateControl
|
class nsMacWindow : public nsChildWindow
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef nsChildWindow Inherited;
|
typedef nsChildWindow Inherited;
|
||||||
|
@ -45,10 +44,6 @@ private:
|
||||||
public:
|
public:
|
||||||
nsMacWindow();
|
nsMacWindow();
|
||||||
virtual ~nsMacWindow();
|
virtual ~nsMacWindow();
|
||||||
// nsISupports
|
|
||||||
NS_IMETHOD_(nsrefcnt) AddRef();
|
|
||||||
NS_IMETHOD_(nsrefcnt) Release();
|
|
||||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// nsIWidget interface
|
// nsIWidget interface
|
||||||
|
|
|
@ -193,37 +193,37 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
||||||
inst = (nsISupports*)(nsBaseWidget*)new nsMacWindow();
|
inst = (nsISupports*)(nsBaseWidget*)new nsMacWindow();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCChild)) {
|
else if (mClassID.Equals(kCChild)) {
|
||||||
inst = (nsISupports*)new ChildWindow();
|
inst = (nsISupports*)(nsBaseWidget*)new ChildWindow();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCButton)) {
|
else if (mClassID.Equals(kCButton)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsButton();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsButton();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCCheckButton)) {
|
else if (mClassID.Equals(kCCheckButton)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsCheckButton();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCCombobox)) {
|
else if (mClassID.Equals(kCCombobox)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsComboBox();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsComboBox();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCRadioButton)) {
|
else if (mClassID.Equals(kCRadioButton)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsRadioButton();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsRadioButton();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCFileOpen)) {
|
else if (mClassID.Equals(kCFileOpen)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsFileWidget();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsFileWidget();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCListbox)) {
|
else if (mClassID.Equals(kCListbox)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsListBox();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsListBox();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCHorzScrollbar)) {
|
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)) {
|
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)) {
|
else if (mClassID.Equals(kCTextArea)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsTextAreaWidget();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextAreaWidget();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCTextField)) {
|
else if (mClassID.Equals(kCTextField)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsTextWidget();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextWidget();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCAppShell)) {
|
else if (mClassID.Equals(kCAppShell)) {
|
||||||
inst = (nsISupports*)new nsAppShell();
|
inst = (nsISupports*)new nsAppShell();
|
||||||
|
@ -235,7 +235,7 @@ nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter,
|
||||||
inst = (nsISupports*)new nsLookAndFeel();
|
inst = (nsISupports*)new nsLookAndFeel();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCLabel)) {
|
else if (mClassID.Equals(kCLabel)) {
|
||||||
inst = (nsISupports*)(nsWindow*)new nsLabel();
|
inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsLabel();
|
||||||
}
|
}
|
||||||
else if (mClassID.Equals(kCMenuBar)) {
|
else if (mClassID.Equals(kCMenuBar)) {
|
||||||
inst = (nsISupports*)(nsIMenuBar*) new nsMenuBar();
|
inst = (nsISupports*)(nsIMenuBar*) new nsMenuBar();
|
||||||
|
|
|
@ -93,7 +93,7 @@ inline void GetPortVisibleRegion(GrafPtr port, RgnHandle visRgn)
|
||||||
// nsWindow constructor
|
// nsWindow constructor
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsWindow::nsWindow() : nsBaseWidget() , nsDeleteObserved(this)
|
nsWindow::nsWindow() : nsBaseWidget() , nsDeleteObserved(this), nsIKBStateControl()
|
||||||
{
|
{
|
||||||
gInstanceClassName = "nsWindow";
|
gInstanceClassName = "nsWindow";
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ nsWindow::~nsWindow()
|
||||||
nsISupports* child;
|
nsISupports* child;
|
||||||
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
||||||
{
|
{
|
||||||
nsWindow* childWindow = static_cast<nsWindow*>(child);
|
nsWindow* childWindow = static_cast<nsWindow*>(static_cast<nsIWidget*>(child));
|
||||||
NS_RELEASE(child);
|
NS_RELEASE(child);
|
||||||
|
|
||||||
childWindow->mParent = nsnull;
|
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 {
|
do {
|
||||||
nsISupports* child;
|
nsISupports* child;
|
||||||
if (NS_SUCCEEDED(children->CurrentItem(&child))) {
|
if (NS_SUCCEEDED(children->CurrentItem(&child))) {
|
||||||
nsWindow* childWindow = static_cast<nsWindow*>(child);
|
nsWindow* childWindow = static_cast<nsWindow*>(static_cast<nsIWidget*>(child));
|
||||||
|
|
||||||
nsRect childBounds;
|
nsRect childBounds;
|
||||||
childWindow->GetBounds(childBounds);
|
childWindow->GetBounds(childBounds);
|
||||||
|
@ -1394,7 +1410,7 @@ scrollChildren:
|
||||||
nsISupports* child;
|
nsISupports* child;
|
||||||
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
||||||
{
|
{
|
||||||
nsWindow* childWindow = static_cast<nsWindow*>(child);
|
nsWindow* childWindow = static_cast<nsWindow*>(static_cast<nsIWidget*>(child));
|
||||||
NS_RELEASE(child);
|
NS_RELEASE(child);
|
||||||
|
|
||||||
nsRect bounds;
|
nsRect bounds;
|
||||||
|
@ -1664,7 +1680,7 @@ void nsWindow::CalcWindowRegions()
|
||||||
nsISupports* child;
|
nsISupports* child;
|
||||||
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
||||||
{
|
{
|
||||||
nsWindow* childWindow = static_cast<nsWindow*>(child);
|
nsWindow* childWindow = static_cast<nsWindow*>(static_cast<nsIWidget*>(child));
|
||||||
NS_RELEASE(child);
|
NS_RELEASE(child);
|
||||||
|
|
||||||
PRBool visible;
|
PRBool visible;
|
||||||
|
@ -1773,7 +1789,7 @@ nsWindow* nsWindow::FindWidgetHit(Point aThePoint)
|
||||||
nsISupports* child;
|
nsISupports* child;
|
||||||
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
if (NS_SUCCEEDED(children->CurrentItem(&child)))
|
||||||
{
|
{
|
||||||
nsWindow* childWindow = static_cast<nsWindow*>(child);
|
nsWindow* childWindow = static_cast<nsWindow*>(static_cast<nsIWidget*>(child));
|
||||||
NS_RELEASE(child);
|
NS_RELEASE(child);
|
||||||
|
|
||||||
nsWindow* deeperHit = childWindow->FindWidgetHit(aThePoint);
|
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.");
|
NS_ASSERTION(0, "Would some Mac person please implement me? Thanks.");
|
||||||
return NS_OK;
|
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<nsIWidget> parent = getter_AddRefs(GetParent());
|
||||||
|
NS_ASSERTION(parent, "cannot get parent");
|
||||||
|
if(parent)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIKBStateControl> 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<nsIWidget> parent = getter_AddRefs(GetParent());
|
||||||
|
NS_ASSERTION(parent, "cannot get parent");
|
||||||
|
if(parent)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIKBStateControl> kb = do_QueryInterface(parent);
|
||||||
|
NS_ASSERTION(kb, "cannot get parent");
|
||||||
|
if(kb) {
|
||||||
|
return kb->PasswordFieldInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_ERROR_ABORT;
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "nsDeleteObserver.h"
|
#include "nsDeleteObserver.h"
|
||||||
|
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
|
#include "nsIKBStateControl.h"
|
||||||
#include "nsIAppShell.h"
|
#include "nsIAppShell.h"
|
||||||
|
|
||||||
#include "nsIMouseListener.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:
|
public:
|
||||||
nsWindow();
|
nsWindow();
|
||||||
virtual ~nsWindow();
|
virtual ~nsWindow();
|
||||||
|
// nsISupports
|
||||||
|
NS_IMETHOD_(nsrefcnt) AddRef();
|
||||||
|
NS_IMETHOD_(nsrefcnt) Release();
|
||||||
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||||
|
|
||||||
// nsIWidget interface
|
// nsIWidget interface
|
||||||
NS_IMETHOD Create(nsIWidget *aParent,
|
NS_IMETHOD Create(nsIWidget *aParent,
|
||||||
|
@ -180,6 +187,11 @@ public:
|
||||||
PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;};
|
PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;};
|
||||||
void Flash(nsPaintEvent &aEvent);
|
void Flash(nsPaintEvent &aEvent);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// nsIKBStateControl interface
|
||||||
|
NS_IMETHOD ResetInputState();
|
||||||
|
NS_IMETHOD PasswordFieldInit();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
PRBool ReportDestroyEvent();
|
PRBool ReportDestroyEvent();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче