diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index a0390454bfd..a7ca81cae11 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -1848,12 +1848,25 @@ 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) { + nsCOMPtr xulDoc(do_QueryInterface(mDocument)); + if (!xulDoc) { + 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); + PR_TRUE, PR_FALSE, contentType); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 5b9aba6888a..3aab73eb849 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -2741,7 +2741,10 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink) } else { canCreateScrollbars = PR_TRUE; } - rv = aPO->mRootView->CreateWidget(kWidgetCID, nsnull, widget->GetNativeData(NS_NATIVE_WIDGET)); + rv = aPO->mRootView->CreateWidget(kWidgetCID, nsnull, + widget->GetNativeData(NS_NATIVE_WIDGET), + PR_TRUE, PR_TRUE, + eContentTypeContent); aPO->mRootView->GetWidget(*getter_AddRefs(aPO->mWindow)); aPO->mPresContext->SetPaginatedScrolling(canCreateScrollbars); } diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 42a521eb54e..a035fe2ec0a 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -32,6 +32,7 @@ #include "nsIComponentManager.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" +#include "nsIDOMXULDocument.h" #include "nsIDOMWindow.h" #include "nsIDOMElement.h" #include "nsIInterfaceRequestor.h" @@ -1042,7 +1043,9 @@ NS_IMETHODIMP nsWebBrowser::Create() nsWidgetInitData widgetInit; widgetInit.clipChildren = PR_TRUE; - widgetInit.mContentType = mContentType; + widgetInit.mContentType = (mContentType == typeChrome || + mContentType == typeChromeWrapper)? eContentTypeUI: eContentTypeContent; + widgetInit.mWindowType = eWindowType_child; nsRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index a0390454bfd..a7ca81cae11 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -1848,12 +1848,25 @@ 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) { + nsCOMPtr xulDoc(do_QueryInterface(mDocument)); + if (!xulDoc) { + 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); + PR_TRUE, PR_FALSE, contentType); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 9c4d323bcc1..9345fbe57ce 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -42,6 +42,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIDocument.h" +#include "nsIDOMXULDocument.h" #include "nsIDocumentObserver.h" #include "nsIStyleSet.h" #include "nsICSSStyleSheet.h" // XXX for UA sheet loading hack, can this go away please? @@ -7251,7 +7252,9 @@ PresShell::VerifyIncrementalReflow() } //now create the widget for the view - rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget); + nsCOMPtr xulDoc(do_QueryInterface(mDocument)); + rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE, + PR_TRUE, xulDoc? eContentTypeUI: eContentTypeContent); if (NS_OK != rv) { NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget"); } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 29b227f1d21..ada9090fbf6 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -71,6 +71,7 @@ #include "nsFrameSetFrame.h" #include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLIFrameElement.h" +#include "nsIDOMXULElement.h" #include "nsIFrameLoader.h" #include "nsLayoutAtoms.h" #include "nsIChromeEventHandler.h" @@ -1166,8 +1167,10 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext, nsWidgetInitData initData; initData.clipChildren = PR_TRUE; initData.clipSiblings = PR_TRUE; + nsCOMPtr xulElement(do_QueryInterface(mContent)); - rv = view->CreateWidget(kCChildCID, &initData); + rv = view->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE, + xulElement? eContentTypeUI: eContentTypeContent); SetView(aPresContext, view); nsContainerFrame::SyncFrameViewProperties(aPresContext, this, nsnull, view); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 9c4d323bcc1..9345fbe57ce 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -42,6 +42,7 @@ #include "nsIPresContext.h" #include "nsIContent.h" #include "nsIDocument.h" +#include "nsIDOMXULDocument.h" #include "nsIDocumentObserver.h" #include "nsIStyleSet.h" #include "nsICSSStyleSheet.h" // XXX for UA sheet loading hack, can this go away please? @@ -7251,7 +7252,9 @@ PresShell::VerifyIncrementalReflow() } //now create the widget for the view - rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget); + nsCOMPtr xulDoc(do_QueryInterface(mDocument)); + rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget, PR_TRUE, + PR_TRUE, xulDoc? eContentTypeUI: eContentTypeContent); if (NS_OK != rv) { NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget"); } diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 29b227f1d21..ada9090fbf6 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -71,6 +71,7 @@ #include "nsFrameSetFrame.h" #include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLIFrameElement.h" +#include "nsIDOMXULElement.h" #include "nsIFrameLoader.h" #include "nsLayoutAtoms.h" #include "nsIChromeEventHandler.h" @@ -1166,8 +1167,10 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext, nsWidgetInitData initData; initData.clipChildren = PR_TRUE; initData.clipSiblings = PR_TRUE; + nsCOMPtr xulElement(do_QueryInterface(mContent)); - rv = view->CreateWidget(kCChildCID, &initData); + rv = view->CreateWidget(kCChildCID, nsnull, nsnull, PR_TRUE, PR_TRUE, + xulElement? eContentTypeUI: eContentTypeContent); SetView(aPresContext, view); nsContainerFrame::SyncFrameViewProperties(aPresContext, this, nsnull, view); diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 5b9aba6888a..3aab73eb849 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -2741,7 +2741,10 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink) } else { canCreateScrollbars = PR_TRUE; } - rv = aPO->mRootView->CreateWidget(kWidgetCID, nsnull, widget->GetNativeData(NS_NATIVE_WIDGET)); + rv = aPO->mRootView->CreateWidget(kWidgetCID, nsnull, + widget->GetNativeData(NS_NATIVE_WIDGET), + PR_TRUE, PR_TRUE, + eContentTypeContent); aPO->mRootView->GetWidget(*getter_AddRefs(aPO->mWindow)); aPO->mPresContext->SetPaginatedScrolling(canCreateScrollbars); } diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index fab24c50e4b..23a7a7d85dd 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -220,7 +220,6 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext, // Create a widget for ourselves. nsWidgetInitData widgetData; widgetData.mWindowType = eWindowType_popup; - widgetData.mContentType = nsIDocShellTreeItem::typeChrome; widgetData.mBorderStyle = eBorderStyle_default; widgetData.clipSiblings = PR_TRUE; @@ -238,10 +237,12 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext, printf("XP Popups: This is a nag to indicate that an inconsistent hack is being done on the Mac for popups.\n"); #endif static NS_DEFINE_IID(kCPopupCID, NS_POPUP_CID); - ourView->CreateWidget(kCPopupCID, &widgetData, nsnull); + ourView->CreateWidget(kCPopupCID, &widgetData, nsnull, PR_TRUE, PR_TRUE, + eContentTypeUI); #else static NS_DEFINE_IID(kCChildCID, NS_CHILD_CID); - ourView->CreateWidget(kCChildCID, &widgetData, nsnull); + ourView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE, + eContentTypeUI); #endif MoveToAttributePosition(); diff --git a/mozilla/view/public/nsIView.h b/mozilla/view/public/nsIView.h index 46e1b2e7daa..e50d0611e30 100644 --- a/mozilla/view/public/nsIView.h +++ b/mozilla/view/public/nsIView.h @@ -41,11 +41,9 @@ #include "nsISupports.h" #include "nsCoord.h" #include +#include "nsIWidget.h" class nsIViewManager; -class nsIWidget; -struct nsWidgetInitData; -typedef void* nsNativeWidget; struct nsRect; // Enumerated type to indicate the visibility of a layer. @@ -229,13 +227,17 @@ public: * @param aNative native window that will be used as parent of * aWindowIID. if nsnull, then parent will be derived from * parent view and it's ancestors + * @param aWindowType is either content, UI or inherit from parent window. + * This is used to expose what type of window this is to + * assistive technology like screen readers. * @return error status */ NS_IMETHOD CreateWidget(const nsIID &aWindowIID, nsWidgetInitData *aWidgetInitData = nsnull, nsNativeWidget aNative = nsnull, PRBool aEnableDragDrop = PR_TRUE, - PRBool aResetVisibility = PR_TRUE) = 0; + PRBool aResetVisibility = PR_TRUE, + nsContentType aWindowType = eContentTypeInherit) = 0; /** * In 4.0, the "cutout" nature of a view is queryable. diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp index b35bc112224..b1a9dfc390a 100644 --- a/mozilla/view/src/nsView.cpp +++ b/mozilla/view/src/nsView.cpp @@ -727,10 +727,11 @@ NS_IMETHODIMP nsView::GetClientData(void *&aData) const } NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID, - nsWidgetInitData *aWidgetInitData, - nsNativeWidget aNative, - PRBool aEnableDragDrop, - PRBool aResetVisibility) + nsWidgetInitData *aWidgetInitData, + nsNativeWidget aNative, + PRBool aEnableDragDrop, + PRBool aResetVisibility, + nsContentType aContentType) { nsIDeviceContext *dx; nsRect trect = mDimBounds; @@ -751,17 +752,21 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID, if (PR_TRUE == usewidgets) { + PRBool initDataPassedIn = PR_TRUE; + nsWidgetInitData initData; + if (!aWidgetInitData) { + initDataPassedIn = PR_FALSE; + aWidgetInitData = &initData; + } + aWidgetInitData->mContentType = aContentType; + if (aNative) mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData); else { - nsWidgetInitData initData; - if (nsnull == aWidgetInitData && nsnull != GetParent()) { - if (GetParent()->GetViewManager() != mViewManager) { - initData.mListenForResizes = PR_TRUE; - aWidgetInitData = &initData; - } - } + if (!initDataPassedIn && GetParent() && + GetParent()->GetViewManager() != mViewManager) + initData.mListenForResizes = PR_TRUE; nsIWidget *parent; GetOffsetFromWidget(nsnull, nsnull, parent); diff --git a/mozilla/view/src/nsView.h b/mozilla/view/src/nsView.h index 17480466b38..47942de9ba3 100644 --- a/mozilla/view/src/nsView.h +++ b/mozilla/view/src/nsView.h @@ -39,9 +39,9 @@ #define nsView_h___ #include "nsIView.h" +#include "nsIWidget.h" #include "nsRect.h" #include "nsCRT.h" -#include "nsIWidget.h" #include "nsIFactory.h" #include "nsIViewObserver.h" #include "nsEvent.h" @@ -133,7 +133,8 @@ public: nsWidgetInitData *aWidgetInitData = nsnull, nsNativeWidget aNative = nsnull, PRBool aEnableDragDrop = PR_TRUE, - PRBool aResetVisibility = PR_TRUE); + PRBool aResetVisibility = PR_TRUE, + nsContentType aContentType = eContentTypeInherit); NS_IMETHOD GetWidget(nsIWidget *&aWidget) const; NS_IMETHOD HasWidget(PRBool *aHasWidget) const; NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; diff --git a/mozilla/widget/public/nsIWidget.h b/mozilla/widget/public/nsIWidget.h index 97cffb6168f..5489d5d206b 100644 --- a/mozilla/widget/public/nsIWidget.h +++ b/mozilla/widget/public/nsIWidget.h @@ -204,6 +204,11 @@ enum nsCursor { ///(normal cursor, usually rendered as an arrow) eCursor_count_up_down }; +enum nsContentType { + eContentTypeInherit = -1, + eContentTypeUI = 0, // eContentTypeUI must equal 0 + eContentTypeContent = 1 // eContentTypeUI must equal 1 +}; /** * Basic struct for widget initialization data. @@ -218,7 +223,7 @@ struct nsWidgetInitData { mListenForResizes(PR_FALSE), mWindowType(eWindowType_child), mBorderStyle(eBorderStyle_default), - mContentType(1), // nsIDocShellTreeItem::typeContent + mContentType(eContentTypeInherit), mUnicode(PR_TRUE) { } @@ -228,7 +233,7 @@ struct nsWidgetInitData { PRPackedBool mListenForResizes; nsWindowType mWindowType; nsBorderStyle mBorderStyle; - PRUint32 mContentType; // from nsIDocShellTreeItem.idl content types - typeChrome, typeContent, etc. + nsContentType mContentType; // Exposed so screen readers know what's UI PRPackedBool mUnicode; }; diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 2e742debec4..45ec1cc2db4 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -1637,17 +1637,8 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, } }*/ - // Show nsIDocShellTreeItem::contentType in GWL_ID - // This way 3rd part apps can check if a window is chrome (0) or content (1) -#ifdef MOZ_UNICODE - LONG contentType = aInitData? aInitData->mContentType: (parent? nsToolkit::mGetWindowLong(parent, GWL_ID): -1); - LONG isContent = (contentType == 1 || contentType == 2); - nsToolkit::mSetWindowLong(mWnd, GWL_ID, isContent); -#else - LONG contentType = aInitData? aInitData->mContentType: (parent? ::GetWindowLong(parent, GWL_ID): -1); - LONG isContent = (contentType == 1 || contentType == 2); - ::SetWindowLong(mWnd, GWL_ID, isContent); -#endif + mContentType = aInitData? aInitData->mContentType: eContentTypeInherit; + SetWin32ContentType(); // call the event callback to notify about creation @@ -1657,6 +1648,39 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, return(NS_OK); } +PRBool nsWindow::SetWin32ContentType() +{ + // Show mContentType in GWL_ID + // This way 3rd part apps can check if a window is UI (0) or content (1) + // Return true if control id changed + + nsContentType newContentType = mContentType; + +#ifdef MOZ_UNICODE + if (newContentType == eContentTypeInherit) { + HWND parentWnd = mWnd; + newContentType = eContentTypeUI; // default if we're the root + if ((parentWnd = ::GetParent(parentWnd)) != 0) { + newContentType = (nsContentType)nsToolkit::mGetWindowLong(parentWnd, GWL_ID); + } + } + nsContentType oldContentType = (nsContentType)nsToolkit::mGetWindowLong(mWnd, GWL_ID); + nsToolkit::mSetWindowLong(mWnd, GWL_ID, (PRInt32)newContentType); +#else + if (newContentType == eContentTypeInherit) { + HWND parentWnd = mWnd; + newContentType = eContentTypeUI; // default if we're the root + if ((parentWnd = ::GetParent(parentWnd)) != 0) { + newContentType = (nsContentType)nsToolkit::GetWindowLong(parentWnd, GWL_ID); + } + } + nsContentType oldContentType = (nsContentType)nsToolkit::GetWindowLong(mWnd, GWL_ID); + nsToolkit::SetWindowLong(mWnd, GWL_ID, (PRInt32)newContentType); +#endif + + return oldContentType != newContentType; +} + //------------------------------------------------------------------------- // // Create the proper widget @@ -1759,6 +1783,9 @@ NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent) HWND newParent = (HWND)aNewParent->GetNativeData(NS_NATIVE_WINDOW); NS_ASSERTION(newParent, "Parent widget has a null native window handle"); ::SetParent(mWnd, newParent); + PRBool isChanged = mContentType == eContentTypeInherit && SetWin32ContentType(); + NS_ASSERTION(!isChanged, "SetParent won't expose a new content type when decendents use eContentTypeInherit."); + return NS_OK; } NS_WARNING("Null aNewParent passed to SetParent"); diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 40dec9f093d..b29ed248d68 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -493,6 +493,7 @@ protected: void MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthResult, nsTextRangeArray* textRangeListResult); void ConstrainZLevel(HWND *aAfter); + PRBool SetWin32ContentType(); private: @@ -529,6 +530,7 @@ protected: char mLeadByte; PRUint32 mBlurEventSuppressionLevel; + nsContentType mContentType; // XXX Temporary, should not be caching the font nsFont * mFont; diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 7c859c8c2d4..81d4c9c7798 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -739,7 +739,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP) widgetInitData.mWindowType = eWindowType_popup; - widgetInitData.mContentType = nsIDocShellTreeItem::typeChrome; + widgetInitData.mContentType = eContentTypeUI; // note default chrome overrides other OS chrome settings, but // not internal chrome