summaryrefslogtreecommitdiff
path: root/widget
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2022-04-26 10:13:11 -0500
committerBrian Smith <brian@dbsoft.org>2022-04-26 10:19:04 -0500
commit3daf711085889bad1bd68651bc4e8790412ae105 (patch)
treef5b0e4c1befb320cdf158e1839ac5e273373087f /widget
parent7fe702603066e7f122d5dd66a3a1892ac7e06215 (diff)
downloaduxp-3daf711085889bad1bd68651bc4e8790412ae105.tar.gz
Issue #1829 - Revert “Issue #1751 -- Remove XP_MACOSX conditionals from the rest of the tree.”
This also removes some PP abuse and takes file entries out of PP when no longer needed without XP_MACOSX conditionals. This reverts commit 6f707bde95dab6998ac204f9ee6c925ee230c740.
Diffstat (limited to 'widget')
-rw-r--r--widget/CompositorWidget.h6
-rw-r--r--widget/GfxInfoBase.cpp8
-rw-r--r--widget/NativeKeyToDOMCodeName.h6
-rw-r--r--widget/NativeKeyToDOMKeyName.h4
-rw-r--r--widget/TextEvents.h31
-rw-r--r--widget/WidgetEventImpl.cpp4
-rw-r--r--widget/nsBaseWidget.cpp23
-rw-r--r--widget/nsBaseWidget.h2
-rw-r--r--widget/nsGUIEventIPC.h14
-rw-r--r--widget/nsIWidget.h4
-rw-r--r--widget/nsNativeTheme.cpp14
11 files changed, 109 insertions, 7 deletions
diff --git a/widget/CompositorWidget.h b/widget/CompositorWidget.h
index 829255b62d..eb657ba7f3 100644
--- a/widget/CompositorWidget.h
+++ b/widget/CompositorWidget.h
@@ -54,7 +54,11 @@ class CompositorWidgetChild;
class WidgetRenderingContext
{
-/** Mac Stub **/
+public:
+#ifdef XP_MACOSX
+ WidgetRenderingContext() : mLayerManager(nullptr) {}
+ layers::LayerManagerComposite* mLayerManager;
+#endif
};
/**
diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp
index ae0878c757..ed47355367 100644
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -1,3 +1,4 @@
+/* vim: se cin sw=2 ts=2 et : */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
@@ -645,6 +646,13 @@ MatchingOperatingSystems(OperatingSystem aBlockedOS, OperatingSystem aSystemOS)
}
#endif
+#if defined (XP_MACOSX)
+ if (aBlockedOS == OperatingSystem::OSX) {
+ // We do want even "unknown" aSystemOS to fall under "all OS X"
+ return true;
+ }
+#endif
+
return aSystemOS == aBlockedOS;
}
diff --git a/widget/NativeKeyToDOMCodeName.h b/widget/NativeKeyToDOMCodeName.h
index 05bcd3babb..74f2ed1f47 100644
--- a/widget/NativeKeyToDOMCodeName.h
+++ b/widget/NativeKeyToDOMCodeName.h
@@ -27,6 +27,12 @@
#define CODE_MAP_WIN(aCPPCodeName, aNativeKey) \
NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \
CODE_NAME_INDEX_##aCPPCodeName)
+#elif defined(XP_MACOSX)
+#undef CODE_MAP_MAC
+// aNativeKey is key code starting with kVK_.
+#define CODE_MAP_MAC(aCPPCodeName, aNativeKey) \
+ NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \
+ CODE_NAME_INDEX_##aCPPCodeName)
#elif defined(MOZ_WIDGET_GTK)
#undef CODE_MAP_X11
// aNativeKey is hardware_keycode of GDKEvent or nativeScanCode of QKeyEvent.
diff --git a/widget/NativeKeyToDOMKeyName.h b/widget/NativeKeyToDOMKeyName.h
index 45400e9564..25dafff6f3 100644
--- a/widget/NativeKeyToDOMKeyName.h
+++ b/widget/NativeKeyToDOMKeyName.h
@@ -61,6 +61,10 @@
#else
#error Any NS_*_TO_DOM_KEY_NAME_INDEX() is not defined.
#endif // #if defined(NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX) ...
+#elif defined(XP_MACOSX)
+#undef KEY_MAP_COCOA
+#define KEY_MAP_COCOA(aCPPKeyName, aNativeKey) \
+ NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName)
#elif defined(MOZ_WIDGET_GTK)
#undef KEY_MAP_GTK
#define KEY_MAP_GTK(aCPPKeyName, aNativeKey) \
diff --git a/widget/TextEvents.h b/widget/TextEvents.h
index 736effeeab..6c29341144 100644
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -111,6 +111,10 @@ protected:
, mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
, mAccessKeyForwardedToChild(false)
, mUniqueId(0)
+#ifdef XP_MACOSX
+ , mNativeModifierFlags(0)
+ , mNativeKeyCode(0)
+#endif // #ifdef XP_MACOSX
, mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
, mInputMethodAppState(eNotHandled)
@@ -136,6 +140,10 @@ public:
, mLocation(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
, mAccessKeyForwardedToChild(false)
, mUniqueId(0)
+#ifdef XP_MACOSX
+ , mNativeModifierFlags(0)
+ , mNativeKeyCode(0)
+#endif // #ifdef XP_MACOSX
, mKeyNameIndex(mozilla::KEY_NAME_INDEX_Unidentified)
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
, mInputMethodAppState(eNotHandled)
@@ -196,6 +204,15 @@ public:
// CODE_NAME_INDEX_USE_STRING.
nsString mCodeValue;
+#ifdef XP_MACOSX
+ // Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
+ nsString mNativeCharacters;
+ nsString mNativeCharactersIgnoringModifiers;
+ // If this is non-empty, create a text event for plugins instead of a
+ // keyboard event.
+ nsString mPluginTextEventString;
+#endif // #ifdef XP_MACOSX
+
// OS-specific native event can optionally be preserved
void* mNativeKeyEvent;
// A DOM keyCode value or 0. If a keypress event whose mCharCode is 0, this
@@ -223,6 +240,12 @@ public:
// over long periods.
uint32_t mUniqueId;
+#ifdef XP_MACOSX
+ // Values given by a native NSEvent, for use with Cocoa NPAPI plugins.
+ uint32_t mNativeModifierFlags;
+ uint16_t mNativeKeyCode;
+#endif // #ifdef XP_MACOSX
+
// DOM KeyboardEvent.key
KeyNameIndex mKeyNameIndex;
// DOM KeyboardEvent.code
@@ -374,6 +397,14 @@ public:
// is destroyed.
mNativeKeyEvent = nullptr;
mUniqueId = aEvent.mUniqueId;
+#ifdef XP_MACOSX
+ mNativeKeyCode = aEvent.mNativeKeyCode;
+ mNativeModifierFlags = aEvent.mNativeModifierFlags;
+ mNativeCharacters.Assign(aEvent.mNativeCharacters);
+ mNativeCharactersIgnoringModifiers.
+ Assign(aEvent.mNativeCharactersIgnoringModifiers);
+ mPluginTextEventString.Assign(aEvent.mPluginTextEventString);
+#endif
mInputMethodAppState = aEvent.mInputMethodAppState;
mIsSynthesizedByTIP = aEvent.mIsSynthesizedByTIP;
}
diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp
index 1302c3e948..59c80672b1 100644
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -479,7 +479,11 @@ WidgetInputEvent::AccelModifier()
sAccelModifier = MODIFIER_CONTROL;
break;
default:
+#ifdef XP_MACOSX
+ sAccelModifier = MODIFIER_META;
+#else
sAccelModifier = MODIFIER_CONTROL;
+#endif
break;
}
}
diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp
index 23859383c2..d3cdf72cfc 100644
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -84,6 +84,10 @@ static void debug_RegisterPrefCallbacks();
static int32_t gNumWidgets;
#endif
+#ifdef XP_MACOSX
+#include "nsCocoaFeatures.h"
+#endif
+
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
static nsRefPtrHashtable<nsVoidPtrHashKey, nsIWidget>* sPluginWidgetList;
#endif
@@ -171,7 +175,7 @@ nsBaseWidget::nsBaseWidget()
, mUpdateCursor(true)
, mUseAttachedEvents(false)
, mIMEHasFocus(false)
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
, mAccessibilityInUseFlag(false)
#endif
{
@@ -641,8 +645,15 @@ void nsBaseWidget::AddChild(nsIWidget* aChild)
void nsBaseWidget::RemoveChild(nsIWidget* aChild)
{
#ifdef DEBUG
+#ifdef XP_MACOSX
+ // nsCocoaWindow doesn't implement GetParent, so in that case parent will be
+ // null and we'll just have to do without this assertion.
+ nsIWidget* parent = aChild->GetParent();
+ NS_ASSERTION(!parent || parent == this, "Not one of our kids!");
+#else
MOZ_RELEASE_ASSERT(aChild->GetParent() == this, "Not one of our kids!");
#endif
+#endif
if (mLastChild == aChild) {
mLastChild = mLastChild->GetPrevSibling();
@@ -1371,8 +1382,12 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight)
mLayerManager = lm.forget();
// Only track compositors for top-level windows, since other window types
- // may use the basic compositor.
+ // may use the basic compositor. Except on the OS X - see bug 1306383
+#if defined(XP_MACOSX)
+ bool getCompositorFromThisWindow = true;
+#else
bool getCompositorFromThisWindow = (mWindowType == eWindowType_toplevel);
+#endif
if (getCompositorFromThisWindow) {
gfxPlatform::GetPlatform()->NotifyCompositorCreated(mLayerManager->GetCompositorBackendType());
@@ -1870,7 +1885,7 @@ nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId,
#ifdef ACCESSIBILITY
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
// defined in nsAppRunner.cpp
extern const char* kAccessibilityLastRunDatePref;
@@ -1899,7 +1914,7 @@ nsBaseWidget::GetRootAccessible()
// make sure it's not created at unsafe times.
nsAccessibilityService* accService = GetOrCreateAccService();
if (accService) {
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
if (!mAccessibilityInUseFlag) {
mAccessibilityInUseFlag = true;
uint32_t now = PRTimeToSeconds(PR_Now());
diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h
index 4065a7f1e8..bbc6b72383 100644
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -677,7 +677,7 @@ protected:
bool mUpdateCursor;
bool mUseAttachedEvents;
bool mIMEHasFocus;
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
bool mAccessibilityInUseFlag;
#endif
static nsIRollupListener* gRollupListener;
diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h
index bf03652440..e45189bb10 100644
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -431,6 +431,13 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
WriteParam(aMsg,
static_cast<paramType::InputMethodAppStateType>
(aParam.mInputMethodAppState));
+#ifdef XP_MACOSX
+ WriteParam(aMsg, aParam.mNativeKeyCode);
+ WriteParam(aMsg, aParam.mNativeModifierFlags);
+ WriteParam(aMsg, aParam.mNativeCharacters);
+ WriteParam(aMsg, aParam.mNativeCharactersIgnoringModifiers);
+ WriteParam(aMsg, aParam.mPluginTextEventString);
+#endif
// An OS-specific native event might be attached in |mNativeKeyEvent|, but
// that cannot be copied across process boundaries.
}
@@ -458,6 +465,13 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
ReadParam(aMsg, aIter, &aResult->mUniqueId) &&
ReadParam(aMsg, aIter, &aResult->mIsSynthesizedByTIP) &&
ReadParam(aMsg, aIter, &inputMethodAppState)
+#ifdef XP_MACOSX
+ && ReadParam(aMsg, aIter, &aResult->mNativeKeyCode)
+ && ReadParam(aMsg, aIter, &aResult->mNativeModifierFlags)
+ && ReadParam(aMsg, aIter, &aResult->mNativeCharacters)
+ && ReadParam(aMsg, aIter, &aResult->mNativeCharactersIgnoringModifiers)
+ && ReadParam(aMsg, aIter, &aResult->mPluginTextEventString)
+#endif
)
{
aResult->mKeyNameIndex = static_cast<mozilla::KeyNameIndex>(keyNameIndex);
diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h
index 716ed85c45..8e28c24da5 100644
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -115,6 +115,10 @@ typedef void* nsNativeWidget;
// IME context. Note that the result is only valid in the process. So,
// XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
#define NS_RAW_NATIVE_IME_CONTEXT 14
+#ifdef XP_MACOSX
+#define NS_NATIVE_PLUGIN_PORT_QD 100
+#define NS_NATIVE_PLUGIN_PORT_CG 101
+#endif
#ifdef XP_WIN
#define NS_NATIVE_TSF_THREAD_MGR 100
#define NS_NATIVE_TSF_CATEGORY_MGR 101
diff --git a/widget/nsNativeTheme.cpp b/widget/nsNativeTheme.cpp
index 35c5a84f75..a5bd85fafa 100644
--- a/widget/nsNativeTheme.cpp
+++ b/widget/nsNativeTheme.cpp
@@ -99,13 +99,25 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame, uint8_t aWidgetType)
flags |= NS_EVENT_STATE_FOCUS;
}
- // On Windows, only draw focus rings if they should be shown. This
+ // On Windows and Mac, only draw focus rings if they should be shown. This
// means that focus rings are only shown once the keyboard has been used to
// focus something in the window.
+#if defined(XP_MACOSX)
+ // Mac always draws focus rings for textboxes and lists.
+ if (aWidgetType == NS_THEME_NUMBER_INPUT ||
+ aWidgetType == NS_THEME_TEXTFIELD ||
+ aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
+ aWidgetType == NS_THEME_SEARCHFIELD ||
+ aWidgetType == NS_THEME_LISTBOX) {
+ return flags;
+ }
+#endif
#if defined(XP_WIN)
// On Windows, focused buttons are always drawn as such by the native theme.
if (aWidgetType == NS_THEME_BUTTON)
return flags;
+#endif
+#if defined(XP_MACOSX) || defined(XP_WIN)
nsIDocument* doc = aFrame->GetContent()->OwnerDoc();
nsPIDOMWindowOuter* window = doc->GetWindow();
if (window && !window->ShouldShowFocusRing())