summaryrefslogtreecommitdiff
path: root/dom/events/EventStateManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/events/EventStateManager.cpp')
-rw-r--r--dom/events/EventStateManager.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp
index 86201bdc30..9f06deb2ba 100644
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -93,6 +93,10 @@
#include "Units.h"
#include "mozilla/layers/APZCTreeManager.h"
+#ifdef XP_MACOSX
+#import <ApplicationServices/ApplicationServices.h>
+#endif
+
namespace mozilla {
using namespace dom;
@@ -1511,6 +1515,14 @@ EventStateManager::FireContextClick()
return;
}
+#ifdef XP_MACOSX
+ // Hack to ensure that we don't show a context menu when the user
+ // let go of the mouse after a long cpu-hogging operation prevented
+ // us from handling any OS events. See bug 117589.
+ if (!CGEventSourceButtonState(kCGEventSourceStateCombinedSessionState, kCGMouseButtonLeft))
+ return;
+#endif
+
nsEventStatus status = nsEventStatus_eIgnore;
// Dispatch to the DOM. We have to fake out the ESM and tell it that the
@@ -2823,6 +2835,29 @@ EventStateManager::DecideGestureEvent(WidgetGestureNotifyEvent* aEvent,
aEvent->mPanDirection = panDirection;
}
+#ifdef XP_MACOSX
+static bool
+NodeAllowsClickThrough(nsINode* aNode)
+{
+ while (aNode) {
+ if (aNode->IsXULElement()) {
+ mozilla::dom::Element* element = aNode->AsElement();
+ static nsIContent::AttrValuesArray strings[] =
+ {&nsGkAtoms::always, &nsGkAtoms::never, nullptr};
+ switch (element->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::clickthrough,
+ strings, eCaseMatters)) {
+ case 0:
+ return true;
+ case 1:
+ return false;
+ }
+ }
+ aNode = nsContentUtils::GetCrossDocParentNode(aNode);
+ }
+ return true;
+}
+#endif
+
void
EventStateManager::PostHandleKeyboardEvent(WidgetKeyboardEvent* aKeyboardEvent,
nsEventStatus& aStatus,
@@ -3055,7 +3090,10 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// focused frame
EnsureDocument(mPresContext);
if (mDocument) {
- fm->ClearFocus(mDocument->GetWindow());
+#ifdef XP_MACOSX
+ if (!activeContent || !activeContent->IsXULElement())
+#endif
+ fm->ClearFocus(mDocument->GetWindow());
fm->SetFocusedWindow(mDocument->GetWindow());
}
}
@@ -3467,6 +3505,18 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
+#ifdef XP_MACOSX
+ case eMouseActivate:
+ if (mCurrentTarget) {
+ nsCOMPtr<nsIContent> targetContent;
+ mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(targetContent));
+ if (!NodeAllowsClickThrough(targetContent)) {
+ *aStatus = nsEventStatus_eConsumeNoDefault;
+ }
+ }
+ break;
+#endif
+
default:
break;
}