From c7ce2f4da02737396b143c827c135242ed3716ad Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Thu, 20 May 2004 03:14:41 +0000 Subject: [PATCH] Bug 242799. Fix touchpad scrolling but keep support for screen reader behavior based on class names. r=ere, sr=roc git-svn-id: svn://10.0.0.236/trunk@156625 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 16 +-------------- mozilla/layout/base/nsDocumentViewer.cpp | 16 +-------------- mozilla/layout/generic/nsFrameFrame.cpp | 17 +++++++++++----- .../layout/html/document/src/nsFrameFrame.cpp | 17 +++++++++++----- .../layout/xul/base/src/nsMenuPopupFrame.cpp | 3 +-- mozilla/widget/src/windows/nsWindow.cpp | 20 ++++++++++++------- mozilla/widget/src/windows/nsWindow.h | 8 +++++++- .../xpfe/appshell/src/nsAppShellService.cpp | 1 + 8 files changed, 48 insertions(+), 50 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 243b8195441..f561e2c3c39 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -1912,26 +1912,12 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, if (NS_FAILED(rv)) return rv; - nsCOMPtr treeItem(do_QueryInterface(mContainer)); - NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE); - PRInt32 itemType; - nsContentType contentType = eContentTypeUI; - treeItem->GetItemType(&itemType); - if (itemType == nsIDocShellTreeItem::typeContent || - itemType == nsIDocShellTreeItem::typeContentWrapper) { -#ifdef MOZ_XUL - nsCOMPtr xulDoc(do_QueryInterface(mDocument)); - if (!xulDoc) -#endif - contentType = eContentTypeContent; - } - // pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone. // otherwise the view will find its own parent widget and "do the right thing" to // establish a parent/child widget relationship rv = view->CreateWidget(kWidgetCID, nsnull, containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), - PR_TRUE, PR_FALSE, contentType); + PR_TRUE, PR_FALSE); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 243b8195441..f561e2c3c39 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -1912,26 +1912,12 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, if (NS_FAILED(rv)) return rv; - nsCOMPtr treeItem(do_QueryInterface(mContainer)); - NS_ENSURE_TRUE(treeItem, NS_ERROR_FAILURE); - PRInt32 itemType; - nsContentType contentType = eContentTypeUI; - treeItem->GetItemType(&itemType); - if (itemType == nsIDocShellTreeItem::typeContent || - itemType == nsIDocShellTreeItem::typeContentWrapper) { -#ifdef MOZ_XUL - nsCOMPtr xulDoc(do_QueryInterface(mDocument)); - if (!xulDoc) -#endif - contentType = eContentTypeContent; - } - // pass in a native widget to be the parent widget ONLY if the view hierarchy will stand alone. // otherwise the view will find its own parent widget and "do the right thing" to // establish a parent/child widget relationship rv = view->CreateWidget(kWidgetCID, nsnull, containerView != nsnull ? nsnull : aParentWidget->GetNativeData(NS_NATIVE_WIDGET), - PR_TRUE, PR_FALSE, contentType); + PR_TRUE, PR_FALSE); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 19ace54bf6a..a028b81008a 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -154,7 +154,7 @@ protected: PRBool IsInline() { return mIsInline; } nsresult ReloadURL(); nsresult ShowDocShell(); - nsresult CreateViewAndWidget(); + nsresult CreateViewAndWidget(nsContentType aContentType); virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, @@ -275,7 +275,7 @@ nsSubDocumentFrame::Init(nsIPresContext* aPresContext, do_QueryInterface(aPresContext); if (thePrintPreviewContext) { - rv = CreateViewAndWidget(); + rv = CreateViewAndWidget(eContentTypeContent); NS_ENSURE_SUCCESS(rv,rv); // we are in PrintPreview @@ -682,7 +682,13 @@ nsSubDocumentFrame::ShowDocShell() scrollY); } - rv = CreateViewAndWidget(); + PRInt32 itemType = nsIDocShellTreeItem::typeContent; + nsCOMPtr treeItem(do_QueryInterface(docShell)); + if (treeItem) { + treeItem->GetItemType(&itemType); + } + rv = CreateViewAndWidget(itemType == nsIDocShellTreeItem::typeChrome ? + eContentTypeUI : eContentTypeContent); if (NS_FAILED(rv)) { return rv; } @@ -705,7 +711,7 @@ nsSubDocumentFrame::ShowDocShell() } nsresult -nsSubDocumentFrame::CreateViewAndWidget() +nsSubDocumentFrame::CreateViewAndWidget(nsContentType aContentType) { // create, init, set the parent of the view nsIView* innerView; @@ -730,7 +736,8 @@ nsSubDocumentFrame::CreateViewAndWidget() initData.clipChildren = PR_TRUE; initData.clipSiblings = PR_TRUE; - return innerView->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE); + return innerView->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE, + aContentType); } // load a new url diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 19ace54bf6a..a028b81008a 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -154,7 +154,7 @@ protected: PRBool IsInline() { return mIsInline; } nsresult ReloadURL(); nsresult ShowDocShell(); - nsresult CreateViewAndWidget(); + nsresult CreateViewAndWidget(nsContentType aContentType); virtual void GetDesiredSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, @@ -275,7 +275,7 @@ nsSubDocumentFrame::Init(nsIPresContext* aPresContext, do_QueryInterface(aPresContext); if (thePrintPreviewContext) { - rv = CreateViewAndWidget(); + rv = CreateViewAndWidget(eContentTypeContent); NS_ENSURE_SUCCESS(rv,rv); // we are in PrintPreview @@ -682,7 +682,13 @@ nsSubDocumentFrame::ShowDocShell() scrollY); } - rv = CreateViewAndWidget(); + PRInt32 itemType = nsIDocShellTreeItem::typeContent; + nsCOMPtr treeItem(do_QueryInterface(docShell)); + if (treeItem) { + treeItem->GetItemType(&itemType); + } + rv = CreateViewAndWidget(itemType == nsIDocShellTreeItem::typeChrome ? + eContentTypeUI : eContentTypeContent); if (NS_FAILED(rv)) { return rv; } @@ -705,7 +711,7 @@ nsSubDocumentFrame::ShowDocShell() } nsresult -nsSubDocumentFrame::CreateViewAndWidget() +nsSubDocumentFrame::CreateViewAndWidget(nsContentType aContentType) { // create, init, set the parent of the view nsIView* innerView; @@ -730,7 +736,8 @@ nsSubDocumentFrame::CreateViewAndWidget() initData.clipChildren = PR_TRUE; initData.clipSiblings = PR_TRUE; - return innerView->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE); + return innerView->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE, + aContentType); } // load a new url diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 04dce98ae0d..b1d1b83ae7f 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -228,8 +228,7 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext, eContentTypeUI); #else static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID); - ourView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE, - eContentTypeUI); + ourView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE); #endif MoveToAttributePosition(); diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index f0fb4c550ed..d2c2f97c115 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -4115,10 +4115,13 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; case WM_KILLFOCUS: - WCHAR className[19]; - nsToolkit::mGetClassName((HWND)wParam, className, 19); - if(wcscmp(className, WindowClassW())) + WCHAR className[kMaxClassNameLength]; + nsToolkit::mGetClassName((HWND)wParam, className, kMaxClassNameLength); + if(wcscmp(className, kWClassNameUI) && + wcscmp(className, kWClassNameContent) && + wcscmp(className, kWClassNameGeneral)) { isMozWindowTakingFocus = PR_FALSE; + } if(gJustGotDeactivate) { gJustGotDeactivate = PR_FALSE; result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus); @@ -4218,10 +4221,13 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT if (pl.showCmd == SW_SHOWMINIMIZED) { // Deactivate - WCHAR className[19]; - nsToolkit::mGetClassName((HWND)wParam, className, 19); - if(wcscmp(className, WindowClassW())) - isMozWindowTakingFocus = PR_FALSE; + WCHAR className[kMaxClassNameLength]; + nsToolkit::mGetClassName((HWND)wParam, className, kMaxClassNameLength); + if (wcscmp(className, kWClassNameUI) && + wcscmp(className, kWClassNameContent) && + wcscmp(className, kWClassNameGeneral)) { + isMozWindowTakingFocus = PR_FALSE; + } gJustGotDeactivate = PR_FALSE; result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus); } else if (pl.showCmd == SW_SHOWNORMAL){ diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 91eb47129ab..572fc10772a 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -74,11 +74,17 @@ class nsIMenuBar; #define COLOREF_2_NSRGB(color) \ NS_RGB(GetRValue(color), GetGValue(color), GetBValue(color)) +/* + * ::: IMPORTANT ::: + * External apps and drivers depend on window class names. + * For example, changing the window classes + * could break touchpad scrolling or screen readers. + */ +const PRUint32 kMaxClassNameLength = 40; const LPCWSTR kWClassNameHidden = L"MozillaHiddenWindowClass"; const LPCWSTR kWClassNameUI = L"MozillaUIWindowClass"; const LPCWSTR kWClassNameContent = L"MozillaContentWindowClass"; const LPCWSTR kWClassNameGeneral = L"MozillaWindowClass"; - const LPCSTR kClassNameHidden = "MozillaHiddenWindowClass"; const LPCSTR kClassNameUI = "MozillaUIWindowClass"; const LPCSTR kClassNameContent = "MozillaContentWindowClass"; diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 2c125e47326..1f8dc01096e 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -833,6 +833,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP) widgetInitData.mWindowType = eWindowType_popup; + widgetInitData.mContentType = eContentTypeUI; // note default chrome overrides other OS chrome settings, but // not internal chrome if (aChromeMask & nsIWebBrowserChrome::CHROME_DEFAULT)