diff options
author | Brian Smith <brian@dbsoft.org> | 2022-04-26 11:24:42 -0500 |
---|---|---|
committer | Brian Smith <brian@dbsoft.org> | 2022-04-26 11:24:42 -0500 |
commit | c82b759d56454bcd3eac54c484569e1239f7d1cc (patch) | |
tree | 14b786bac9fd295d1fca6bd32683652b7ac9ef7e /dom/events | |
parent | 9e2a89c71ddf67975da35eb100673f6b5546f292 (diff) | |
download | uxp-c82b759d56454bcd3eac54c484569e1239f7d1cc.tar.gz |
Issue #1829 - Revert "Issue #1751 -- Remove XP_MACOSX conditionals from /dom"
This reverts commit 0dd3424f774954627d6f53df9fb47379d9b5c871.
Diffstat (limited to 'dom/events')
-rw-r--r-- | dom/events/EventStateManager.cpp | 52 | ||||
-rw-r--r-- | dom/events/TextComposition.cpp | 13 |
2 files changed, 64 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; } diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index 3b3dc6505b..bd7ebbc468 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -21,8 +21,21 @@ #include "mozilla/Unused.h" #include "mozilla/dom/TabParent.h" +#ifdef XP_MACOSX +// Some defiens will be conflict with OSX SDK +#define TextRange _TextRange +#define TextRangeArray _TextRangeArray +#define Comment _Comment +#endif + #include "nsPluginInstanceOwner.h" +#ifdef XP_MACOSX +#undef TextRange +#undef TextRangeArray +#undef Comment +#endif + using namespace mozilla::widget; namespace mozilla { |