Bug 194968. Use content id properly to expose whether window is content vs. UI. r/sr=roc+moz

This commit is contained in:
aaronl%netscape.com 2003-03-06 23:07:00 +00:00
Родитель 316990e8f9
Коммит c616086a0c
17 изменённых файлов: 133 добавлений и 43 удалений

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

@ -1848,12 +1848,25 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDocShellTreeItem> 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<nsIXULDocument> 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;

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

@ -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);
}

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

@ -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);

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

@ -1848,12 +1848,25 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDocShellTreeItem> 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<nsIXULDocument> 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;

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

@ -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<nsIDOMXULDocument> 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");
}

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

@ -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<nsIDOMXULElement> 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);

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

@ -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<nsIDOMXULDocument> 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");
}

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

@ -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<nsIDOMXULElement> 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);

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

@ -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);
}

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

@ -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();

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

@ -41,11 +41,9 @@
#include "nsISupports.h"
#include "nsCoord.h"
#include <stdio.h>
#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.

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

@ -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);

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

@ -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;

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

@ -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;
};

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

@ -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");

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

@ -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;

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

@ -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