diff --git a/docshell/base/nsIDocShellTreeItem.idl b/docshell/base/nsIDocShellTreeItem.idl index 0d6adb86718e..c1bd7b0be3a1 100644 --- a/docshell/base/nsIDocShellTreeItem.idl +++ b/docshell/base/nsIDocShellTreeItem.idl @@ -51,10 +51,10 @@ interface nsIDocShellTreeItem : nsISupports /* Definitions for the item types. */ - const long typeChrome=0; - const long typeContent=1; - const long typeContentWrapper=2; - const long typeChromeWrapper=3; + const long typeChrome=0; // typeChrome must equal 0 + const long typeContent=1; // typeContent must equal 1 + const long typeContentWrapper=2; // typeContentWrapper must equal 2 + const long typeChromeWrapper=3; // typeChromeWrapper must equal 3 const long typeAll=0x7FFFFFFF; diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index 00242fd1a9b7..79a9e714b64a 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -1035,6 +1035,7 @@ NS_IMETHODIMP nsWebBrowser::Create() nsWidgetInitData widgetInit; widgetInit.clipChildren = PR_TRUE; + widgetInit.mContentType = mContentType; widgetInit.mWindowType = eWindowType_child; nsRect bounds(mInitInfo->x, mInitInfo->y, mInitInfo->cx, mInitInfo->cy); diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 296d1786f99b..d992ea76d051 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -69,6 +69,7 @@ #include "nsIFrameManager.h" #include "nsGUIEvent.h" #include "nsIRootBox.h" +#include "nsIDocShellTreeItem.h" #ifdef XP_WIN #include "nsISound.h" #endif @@ -218,6 +219,7 @@ 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; diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index dd0db2a34ed0..984373ce8a43 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -105,7 +105,7 @@ typedef void* nsNativeWidget; * Border styles */ -enum nsWindowType { +enum nsWindowType { // Don't alter previously encoded enum values - 3rd party apps may look at these // default top level window eWindowType_toplevel, // top level window but usually handled differently by the OS @@ -119,10 +119,9 @@ enum nsWindowType { // plugin window eWindowType_plugin, // java plugin window - eWindowType_java + eWindowType_java, }; - enum nsBorderStyle { // no border, titlebar, etc.. opposite of all @@ -218,7 +217,8 @@ struct nsWidgetInitData { mDropShadow(PR_FALSE), mListenForResizes(PR_FALSE), mWindowType(eWindowType_child), - mBorderStyle(eBorderStyle_default) + mBorderStyle(eBorderStyle_default), + mContentType(1) // nsIDocShellTreeItem::typeContent { } @@ -227,6 +227,7 @@ struct nsWidgetInitData { PRPackedBool mListenForResizes; nsWindowType mWindowType; nsBorderStyle mBorderStyle; + PRUint32 mContentType; // from nsIDocShellTreeItem.idl content types - typeChrome, typeContent, etc. }; /** diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 9270270303ff..fa9cb2ae6d71 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -1506,6 +1506,16 @@ 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) + LONG contentType = aInitData? aInitData->mContentType: (parent? ::GetWindowLong(parent, GWL_ID): -1); + LONG isContent = (contentType == 1 || contentType == 2); +#ifdef MOZ_UNICODE + ::SetWindowLongW(mWnd, GWL_ID, contentType); +#else + ::SetWindowLong(mWnd, GWL_ID, contentType); +#endif + // call the event callback to notify about creation DispatchStandardEvent(NS_CREATE); @@ -2921,31 +2931,41 @@ BOOL nsWindow::OnKeyDown( UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData) else if (mIsControlDown && aVirtualKeyCode == VK_BACK) { DispatchKeyEvent(NS_KEY_PRESS, 0, VK_BACK, aKeyData); } - else if (mIsControlDown && !mIsShiftDown && aVirtualKeyCode == NS_VK_SUBTRACT) { - DispatchKeyEvent(NS_KEY_PRESS, '-', 0, aKeyData); - } - else if (mIsControlDown && !mIsShiftDown && aVirtualKeyCode == NS_VK_ADD) { - DispatchKeyEvent(NS_KEY_PRESS, '+', 0, aKeyData); - } else if ((mIsControlDown && !mIsShiftDown) && ((( NS_VK_0 <= aVirtualKeyCode) && (aVirtualKeyCode <= NS_VK_9)) || + (aVirtualKeyCode == NS_VK_ADD) || + (aVirtualKeyCode == NS_VK_SUBTRACT) || (aVirtualKeyCode == NS_VK_SEMICOLON) || (aVirtualKeyCode == NS_VK_EQUALS) || (aVirtualKeyCode == NS_VK_COMMA) || (aVirtualKeyCode == NS_VK_PERIOD) || + (aVirtualKeyCode == NS_VK_QUOTE) || + (aVirtualKeyCode == NS_VK_BACK_QUOTE) || (aVirtualKeyCode == NS_VK_SLASH) ) ) { - // put the 0 - 9 in charcode instead of keycode. - DispatchKeyEvent(NS_KEY_PRESS, aVirtualKeyCode, 0, aKeyData); + switch (aVirtualKeyCode) { + case NS_VK_ADD : asciiKey = '+'; break; + case NS_VK_SUBTRACT : asciiKey = '-'; break; + case NS_VK_SEMICOLON : asciiKey = ';'; break; + case NS_VK_EQUALS : asciiKey = '='; break; + case NS_VK_COMMA : asciiKey = ','; break; + case NS_VK_PERIOD : asciiKey = '.'; break; + case NS_VK_QUOTE : asciiKey = '\''; break; + case NS_VK_BACK_QUOTE: asciiKey = '`'; break; + case NS_VK_SLASH : asciiKey = '/'; break; + // NS_VK_0 - NS_VK9 line up exactly with ascii '0' - '9' + default : asciiKey = aVirtualKeyCode; break; + } + // put the ascii character in charcode instead of using keycode. + DispatchKeyEvent(NS_KEY_PRESS, asciiKey, 0, aKeyData); } - else if (NO_WM_CHAR_LATER(aVirtualKeyCode) && + else if (NO_WM_CHAR_LATER(aVirtualKeyCode) && (aVirtualKeyCode != NS_VK_SEMICOLON) && - (aVirtualKeyCode != NS_VK_EQUALS) && - (aVirtualKeyCode != NS_VK_COMMA) && - (aVirtualKeyCode != NS_VK_PERIOD) && - (aVirtualKeyCode != NS_VK_SLASH)) + (aVirtualKeyCode != NS_VK_EQUALS) && + (aVirtualKeyCode != NS_VK_COMMA) && + (aVirtualKeyCode != NS_VK_PERIOD)) { DispatchKeyEvent(NS_KEY_PRESS, 0, aVirtualKeyCode, aKeyData); } diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 9cc8a0000fb2..73b62585750a 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -632,7 +632,8 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent, if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP) widgetInitData.mWindowType = eWindowType_popup; - + widgetInitData.mContentType = nsIDocShellTreeItem::typeChrome; + // note default chrome overrides other OS chrome settings, but // not internal chrome if (aChromeMask & nsIWebBrowserChrome::CHROME_DEFAULT) diff --git a/xpfe/components/xremote/src/XRemoteService.cpp b/xpfe/components/xremote/src/XRemoteService.cpp index d74e03bcae22..01681c5b1e3c 100644 --- a/xpfe/components/xremote/src/XRemoteService.cpp +++ b/xpfe/components/xremote/src/XRemoteService.cpp @@ -439,6 +439,7 @@ XRemoteService::CreateProxyWindow(void) nsWidgetInitData initData; initData.mWindowType = eWindowType_toplevel; + initData.mContentType = nsIDocShellTreeItem::typeChrome; // create the window as a new toplevel nsRect rect(0,0,100,100);