Index: xpfe/global/resources/content/commonDialog.xul
===================================================================
RCS file: /cvsroot/mozilla/xpfe/global/resources/content/commonDialog.xul,v
retrieving revision 1.41
diff -u -r1.41 commonDialog.xul
--- xpfe/global/resources/content/commonDialog.xul 1 Feb 2002 22:18:57 -0000 1.41
+++ xpfe/global/resources/content/commonDialog.xul 25 Nov 2002 05:31:42 -0000
@@ -10,9 +10,13 @@
ondialogaccept="return commonDialogOnAccept();"
ondialogextra1="return commonDialogOnExtra1();"
ondialogextra2="return commonDialogOnExtra2();"
+ onmouseup="SetCollapsedOnCommonDialog(false, event);"
+ onmousedown="SetCollapsedOnCommonDialog(true, event);"
buttonpack="center"
style="min-width: 29em; min-height: 8.5em; -moz-user-focus: ignore;">
+
Index: xpfe/global/resources/content/commonDialog.js
===================================================================
RCS file: /cvsroot/mozilla/xpfe/global/resources/content/commonDialog.js,v
retrieving revision 1.49
diff -u -r1.49 commonDialog.js
--- xpfe/global/resources/content/commonDialog.js 3 Oct 2002 00:46:24 -0000 1.49
+++ xpfe/global/resources/content/commonDialog.js 25 Nov 2002 05:31:44 -0000
@@ -41,7 +41,58 @@
// parameters to gCommonDialogParam.Get() are defined in nsPIPromptService.idl
var gCommonDialogParam =
window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
+
+var gJavaScriptApplication = null;
+var gLeftContext, gRightContext;
+
+var leftDown = false;
+var rightDown = false;
+var collapsed = false;
+
+
+function SetCollapsedOnCommonDialog(value, e) {
+ if (e.which == 1) {
+ leftDown = value;
+ } else if (e.which == 3) {
+ rightDown = value;
+ }
+
+ if ((leftDown && rightDown && !collapsed) || (!leftDown && !rightDown && collapsed)) {
+
+ // Determine if we are being called from content by checking the window title.
+ // That title is contained in a .properties file and contains a %S.
+ // For English, the title is "[JavaScript Application] %S"
+
+ // First get the string from the properties file if it is not already cached
+ if (!gJavaScriptApplication) {
+ // Get the title string from the properties file
+ var commonDialogBundle = document.getElementById("commonDialogBundle");
+ gJavaScriptApplication = commonDialogBundle.getString('ScriptDlgTitle');
+ // Find strings that precede and follow the %S
+ var re = /\%S/;
+ if (gJavaScriptApplication.match(re)) {
+ gLeftContext = RegExp.leftContext;
+ gRightContext = RegExp.rightContext;
+ }
+ }
+
+ // Now test if current window title matches the string from the properties file
+ if (window.title.slice(0,gLeftContext.length) == gLeftContext &&
+ window.title.slice(gRightContext.length,-0) == gRightContext) {
+ // it matches -- time to collapse or uncollapse the window
+
+ if (leftDown && rightDown && !collapsed) {
+ collapsed = true;
+ document.getElementById('commonDialog').setAttribute("collapsed", "true");
+ } else if (!leftDown && !rightDown && collapsed) {
+ collapsed = false;
+ document.getElementById('commonDialog').setAttribute("collapsed", "false");
+ }
+ }
+ }
+}
+
function showControls()
{
// This is called before onload fires, so we can't be certain that any elements
Index: xpfe/browser/resources/content/navigator.xul
===================================================================
RCS file: /cvsroot/mozilla/xpfe/browser/resources/content/navigator.xul,v
retrieving revision 1.394
diff -u -r1.394 navigator.xul
--- xpfe/browser/resources/content/navigator.xul 5 Oct 2002 08:11:25 -0000 1.394
+++ xpfe/browser/resources/content/navigator.xul 25 Nov 2002 05:31:50 -0000
@@ -54,6 +54,8 @@
windowtype="navigator:browser"
width="610" height="450"
screenX="4" screenY="4"
+ onmouseup="SetCollapsedOnBrowserWindow(false, event);"
+ onmousedown="SetCollapsedOnBrowserWindow(true, event);"
persist="screenX screenY width height sizemode">
Index: xpfe/browser/resources/content/navigator.js
===================================================================
RCS file: /cvsroot/mozilla/xpfe/browser/resources/content/navigator.js,v
retrieving revision 1.481
diff -u -r1.481 navigator.js
--- xpfe/browser/resources/content/navigator.js 22 Oct 2002 19:48:59 -0000 1.481
+++ xpfe/browser/resources/content/navigator.js 25 Nov 2002 05:31:57 -0000
@@ -1367,6 +1367,28 @@
BrowserViewSourceOfURL(webNav.currentURI.spec, docCharset, pageCookie);
}
+var leftDown = false;
+var rightDown = false;
+var collapsed = false;
+
+function SetCollapsedOnBrowserWindow(value, e) {
+ if (e.which == 1) {
+ leftDown = value;
+ } else if (e.which == 3) {
+ rightDown = value;
+ }
+ if (leftDown && rightDown && !collapsed) {
+ collapsed = true;
+ document.getElementById('browser').setAttribute("collapsed", "true");
+ document.getElementById('sidebar-box').setAttribute("collapsed", "true");
+ } else if (!leftDown && !rightDown && collapsed) {
+ collapsed = false;
+ document.getElementById('browser').setAttribute("collapsed", "false");
+ document.getElementById('sidebar-box').setAttribute("collapsed", "false");
+ }
+
+}
+
function BrowserViewSourceOfURL(url, charset, pageCookie)
{
// try to open a view-source window while inheriting the charset (if any)
Index: mailnews/base/resources/content/mail3PaneWindowVertLayout.xul
===================================================================
RCS file: /cvsroot/mozilla/mailnews/base/resources/content/mail3PaneWindowVertLayout.xul,v
retrieving revision 1.91
diff -u -r1.91 mail3PaneWindowVertLayout.xul
--- mailnews/base/resources/content/mail3PaneWindowVertLayout.xul 17 Sep 2002 07:21:34 -0000 1.91
+++ mailnews/base/resources/content/mail3PaneWindowVertLayout.xul 25 Nov 2002 05:31:58 -0000
@@ -50,6 +50,8 @@
width="750"
height="500"
screenX="10" screenY="10"
+ onmouseup="SetCollapsedOnMailWindow(false, event);"
+ onmousedown="SetCollapsedOnMailWindow(true, event);"
persist="width height screenX screenY sizemode"
windowtype="mail:3pane">
Index: mailnews/base/resources/content/messenger.xul
===================================================================
RCS file: /cvsroot/mozilla/mailnews/base/resources/content/messenger.xul,v
retrieving revision 1.242
diff -u -r1.242 messenger.xul
--- mailnews/base/resources/content/messenger.xul 17 Sep 2002 21:03:39 -0000 1.242
+++ mailnews/base/resources/content/messenger.xul 25 Nov 2002 05:32:01 -0000
@@ -51,6 +51,8 @@
height="500"
screenX="10" screenY="10"
persist="width height screenX screenY sizemode"
+ onmouseup="SetCollapsedOnMailWindow(false, event);"
+ onmousedown="SetCollapsedOnMailWindow(true, event);"
windowtype="mail:3pane">
Index: mailnews/base/resources/content/mail3PaneWindowCommands.js
===================================================================
RCS file: /cvsroot/mozilla/mailnews/base/resources/content/mail3PaneWindowCommands.js,v
retrieving revision 1.107
diff -u -r1.107 mail3PaneWindowCommands.js
--- mailnews/base/resources/content/mail3PaneWindowCommands.js 3 Oct 2002 11:08:18 -0000 1.107
+++ mailnews/base/resources/content/mail3PaneWindowCommands.js 25 Nov 2002 05:32:05 -0000
@@ -1153,3 +1153,22 @@
SetFocusThreadPane();
}
+var leftDown = false;
+var rightDown = false;
+var collapsed = false;
+
+function SetCollapsedOnMailWindow(value, e) {
+ if (e.which == 1) {
+ leftDown = value;
+ } else if (e.which == 3) {
+ rightDown = value;
+ }
+
+ if (leftDown && rightDown && !collapsed) {
+ collapsed = true;
+ document.getElementById('messagepanebox').setAttribute("collapsed", "true");
+ } else if (!leftDown && !rightDown && collapsed) {
+ collapsed = false;
+ document.getElementById('messagepanebox').setAttribute("collapsed", "false");
+ }
+}
Index: content/events/src/nsEventListenerManager.cpp
===================================================================
RCS file: /cvsroot/mozilla/content/events/src/nsEventListenerManager.cpp,v
retrieving revision 1.133
diff -u -r1.133 nsEventListenerManager.cpp
--- content/events/src/nsEventListenerManager.cpp 8 Oct 2002 10:43:38 -0000 1.133
+++ content/events/src/nsEventListenerManager.cpp 25 Nov 2002 05:32:14 -0000
@@ -36,6 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
+// define either ElementInChromeTest or ElementInScriptTest but not both
+//#define ElementInChromeTest
+//#define ScriptInChromeTest
+
#include "nsISupports.h"
#include "nsGUIEvent.h"
#include "nsDOMEvent.h"
@@ -82,7 +86,7 @@
#include "nsIDOMScriptObjectFactory.h"
#include "nsDOMCID.h"
#include "nsIScriptObjectOwner.h" // for nsIScriptEventHandlerOwner
-#include "nsIClassInfo.h"
+#include "nsIClassInfo.h" // ??? is this needed ???
#include "nsIFocusController.h"
#include "nsIDOMElement.h"
#include "nsIBoxObject.h"
@@ -90,6 +94,9 @@
#include "nsIWidget.h"
#include "nsContentUtils.h"
+#ifdef ElementInChromeTest
+#include "nsIDocShellTreeItem.h"
+#endif
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
@@ -306,6 +313,11 @@
return nsnull;
}
+PRBool gLeftMouseDown = PR_FALSE;
+PRBool gRightMouseDown = PR_FALSE;
+PRBool gTestInProgress = PR_FALSE;
+PRBool gAfterTest = PR_FALSE;
+
EventArrayType nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
{
if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener)))
@@ -315,7 +327,7 @@
return eEventArrayType_MouseMotion;
if (aIID.Equals(NS_GET_IID(nsIDOMContextMenuListener)))
- return eEventArrayType_ContextMenu;
+ return (gTestInProgress || gAfterTest) ? eEventArrayType_None : eEventArrayType_ContextMenu;
if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener)))
return eEventArrayType_Key;
@@ -396,6 +408,22 @@
{
NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
+#ifdef ScriptInChromeTest
+ PRBool isChrome = PR_FALSE;
+ nsresult rv2;
+ nsCOMPtr stack = do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv2);
+ if (NS_SUCCEEDED(rv2) && stack) {
+ JSContext *cx;
+ if (NS_SUCCEEDED(stack->Peek(&cx))) {
+ nsCOMPtr securityManager =
+ do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv2);
+ if (NS_SUCCEEDED(rv2) && securityManager) {
+ securityManager->SubjectPrincipalIsSystem(&isChrome);
+ }
+ }
+ }
+#endif
+
nsVoidArray* listeners = GetListenersByType(aType, aKey, PR_TRUE);
//We asked the GetListenersByType to create the array if it had to. If it didn't
@@ -460,6 +488,35 @@
ls->mSubType = aSubType;
ls->mSubTypeCapture = NS_EVENT_BITS_NONE;
ls->mHandlerIsString = 0;
+#ifdef ScriptInChromeTest
+ if (isChrome) {
+ ls->mIsChrome = isChrome;
+ }
+#else
+ ls->mIsChrome = PR_TRUE;
+#endif
+
+#ifdef ElementInChromeTest
+ nsCOMPtr document;
+ nsCOMPtr content(do_QueryInterface(mTarget));
+ if (content) {
+ if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(document))) && document) {
+ nsCOMPtr container;
+ if (NS_SUCCEEDED(document->GetContainer(getter_AddRefs(container))) && container) {
+ nsCOMPtr docshellTreeItem(do_QueryInterface(container));
+ if (docshellTreeItem) {
+ PRInt32 itemType = nsIDocShellTreeItem::typeContent;
+ if (NS_SUCCEEDED(docshellTreeItem->GetItemType(&itemType))) {
+ if (itemType != nsIDocShellTreeItem::typeChrome) {
+ ls->mIsChrome = PR_FALSE;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+
listeners->AppendElement((void*)ls);
NS_ADDREF(aListener);
}
@@ -1006,6 +1063,7 @@
return rv;
nsCOMPtr classInfo = do_QueryInterface(aObject);
+// ??? why is above line needed ???
if (sAddListenerID == JSVAL_VOID) {
sAddListenerID = STRING_TO_JSVAL(::JS_InternString(cx, "addEventListener"));
@@ -1252,6 +1310,28 @@
case NS_MOUSE_RIGHT_DOUBLECLICK:
case NS_MOUSE_ENTER_SYNTH:
case NS_MOUSE_EXIT_SYNTH:
+
+ switch(aEvent->message) {
+ case NS_MOUSE_LEFT_BUTTON_DOWN:
+ gLeftMouseDown = PR_TRUE;
+ break;
+ case NS_MOUSE_RIGHT_BUTTON_DOWN:
+ gAfterTest = PR_FALSE;
+ gRightMouseDown = PR_TRUE;
+ break;
+ case NS_MOUSE_LEFT_BUTTON_UP:
+ gLeftMouseDown = PR_FALSE;
+ break;
+ case NS_MOUSE_RIGHT_BUTTON_UP:
+ gRightMouseDown = PR_FALSE;
+ break;
+ default:
+ break;
+ }
+ if (gRightMouseDown && gLeftMouseDown && !gTestInProgress) {
+ gTestInProgress = PR_TRUE;
+ }
+
listeners = GetListenersByType(eEventArrayType_Mouse, nsnull, PR_FALSE);
if (listeners) {
if (nsnull == *aDOMEvent) {
@@ -1268,6 +1348,9 @@
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
+ if (!ls->mIsChrome) {
+ continue;
+ }
ret = mouseListener->MouseDown(*aDOMEvent);
break;
case NS_MOUSE_LEFT_BUTTON_UP:
@@ -1302,6 +1385,9 @@
case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
+ if (!ls->mIsChrome) {
+ continue;
+ }
subType = NS_EVENT_BITS_MOUSE_MOUSEDOWN;
if (ls->mSubType & NS_EVENT_BITS_MOUSE_MOUSEDOWN) {
correctSubType = PR_TRUE;
@@ -1354,6 +1440,11 @@
}
}
}
+
+ if (!gRightMouseDown && !gLeftMouseDown && gTestInProgress) {
+ gAfterTest = PR_TRUE;
+ gTestInProgress = PR_FALSE;
+ }
break;
case NS_MOUSE_MOVE:
@@ -1402,6 +1493,7 @@
case NS_CONTEXTMENU:
case NS_CONTEXTMENU_KEY:
+ if (gTestInProgress || gAfterTest) break;
listeners = GetListenersByType(eEventArrayType_ContextMenu, nsnull, PR_FALSE);
if (listeners) {
Index: content/events/src/nsEventListenerManager.h
===================================================================
RCS file: /cvsroot/mozilla/content/events/src/nsEventListenerManager.h,v
retrieving revision 1.57
diff -u -r1.57 nsEventListenerManager.h
--- content/events/src/nsEventListenerManager.h 3 Oct 2002 00:47:53 -0000 1.57
+++ content/events/src/nsEventListenerManager.h 25 Nov 2002 05:32:17 -0000
@@ -56,6 +56,7 @@
PRUint8 mSubType;
PRUint8 mHandlerIsString;
PRUint8 mSubTypeCapture;
+ PRBool mIsChrome;
} nsListenerStruct;
//These define the internal type of the EventListenerManager