diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp
index 7690b1163fe5..d24bb1ba4f34 100644
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -455,8 +455,17 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
break;
+ case NS_MOUSE_MIDDLE_BUTTON_DOWN: // cancel all of these events for buttons
+ case NS_MOUSE_MIDDLE_BUTTON_UP:
+ case NS_MOUSE_MIDDLE_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_DOUBLECLICK:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
- // XXX Bring up a contextual menu provided by the application
+ case NS_MOUSE_RIGHT_BUTTON_UP:
+ if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
+ (*aDOMEvent)->PreventBubble();
+ } else {
+ ret = NS_ERROR_FAILURE;
+ }
break;
case NS_MOUSE_ENTER_SYNTH:
diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index 3996c577cb25..0caef5d7cc5e 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -56,6 +56,7 @@
#include "nsDOMError.h"
#include "nsIPresState.h"
+#include "nsIDOMEvent.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMHTMLCollection.h"
@@ -789,9 +790,28 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
} break;// NS_KEY_PRESS
+ case NS_MOUSE_MIDDLE_BUTTON_DOWN: // cancel all of these events for buttons
+ case NS_MOUSE_MIDDLE_BUTTON_UP:
+ case NS_MOUSE_MIDDLE_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_BUTTON_DOWN:
+ case NS_MOUSE_RIGHT_BUTTON_UP: {
+ PRInt32 type;
+ GetType(&type);
+ if (type == NS_FORM_INPUT_BUTTON ||
+ type == NS_FORM_INPUT_RESET ||
+ type == NS_FORM_INPUT_SUBMIT ) {
+ if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
+ (*aDOMEvent)->PreventBubble();
+ } else {
+ ret = NS_ERROR_FAILURE;
+ }
+ }
+ } break;
+
case NS_MOUSE_LEFT_BUTTON_DOWN:
mDidMouseDown = PR_TRUE;
- break;// NS_KEY_PRESS
+ break;
case NS_MOUSE_LEFT_BUTTON_UP:
{
diff --git a/layout/html/content/src/nsHTMLButtonElement.cpp b/layout/html/content/src/nsHTMLButtonElement.cpp
index 7690b1163fe5..d24bb1ba4f34 100644
--- a/layout/html/content/src/nsHTMLButtonElement.cpp
+++ b/layout/html/content/src/nsHTMLButtonElement.cpp
@@ -455,8 +455,17 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
break;
+ case NS_MOUSE_MIDDLE_BUTTON_DOWN: // cancel all of these events for buttons
+ case NS_MOUSE_MIDDLE_BUTTON_UP:
+ case NS_MOUSE_MIDDLE_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_DOUBLECLICK:
case NS_MOUSE_RIGHT_BUTTON_DOWN:
- // XXX Bring up a contextual menu provided by the application
+ case NS_MOUSE_RIGHT_BUTTON_UP:
+ if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
+ (*aDOMEvent)->PreventBubble();
+ } else {
+ ret = NS_ERROR_FAILURE;
+ }
break;
case NS_MOUSE_ENTER_SYNTH:
diff --git a/layout/html/content/src/nsHTMLInputElement.cpp b/layout/html/content/src/nsHTMLInputElement.cpp
index 3996c577cb25..0caef5d7cc5e 100644
--- a/layout/html/content/src/nsHTMLInputElement.cpp
+++ b/layout/html/content/src/nsHTMLInputElement.cpp
@@ -56,6 +56,7 @@
#include "nsDOMError.h"
#include "nsIPresState.h"
+#include "nsIDOMEvent.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMHTMLCollection.h"
@@ -789,9 +790,28 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
} break;// NS_KEY_PRESS
+ case NS_MOUSE_MIDDLE_BUTTON_DOWN: // cancel all of these events for buttons
+ case NS_MOUSE_MIDDLE_BUTTON_UP:
+ case NS_MOUSE_MIDDLE_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_DOUBLECLICK:
+ case NS_MOUSE_RIGHT_BUTTON_DOWN:
+ case NS_MOUSE_RIGHT_BUTTON_UP: {
+ PRInt32 type;
+ GetType(&type);
+ if (type == NS_FORM_INPUT_BUTTON ||
+ type == NS_FORM_INPUT_RESET ||
+ type == NS_FORM_INPUT_SUBMIT ) {
+ if (aDOMEvent != nsnull && *aDOMEvent != nsnull) {
+ (*aDOMEvent)->PreventBubble();
+ } else {
+ ret = NS_ERROR_FAILURE;
+ }
+ }
+ } break;
+
case NS_MOUSE_LEFT_BUTTON_DOWN:
mDidMouseDown = PR_TRUE;
- break;// NS_KEY_PRESS
+ break;
case NS_MOUSE_LEFT_BUTTON_UP:
{