forked from mirrors/gecko-dev
Bug 1884631 - Remove macOS native sheet support. r=mac-reviewers,aleca,kaie,bradwerth
Firefox never uses this. TB could use the same approach Firefox uses, but for now on macOS the sheets become regular modal dialogs, which is the same as on Windows and Linux. See bug 1755330 and bug 1737489 for more context. Differential Revision: https://phabricator.services.mozilla.com/D204209
This commit is contained in:
parent
78c4019273
commit
6bfd255000
12 changed files with 194 additions and 576 deletions
|
|
@ -11708,8 +11708,7 @@ static bool IsTopLevelWidget(nsIWidget* aWidget) {
|
|||
|
||||
auto windowType = aWidget->GetWindowType();
|
||||
return windowType == WindowType::TopLevel ||
|
||||
windowType == WindowType::Dialog || windowType == WindowType::Popup ||
|
||||
windowType == WindowType::Sheet;
|
||||
windowType == WindowType::Dialog || windowType == WindowType::Popup;
|
||||
}
|
||||
|
||||
PresShell::WindowSizeConstraints PresShell::GetWindowSizeConstraints() {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ enum class WindowType : uint8_t {
|
|||
TopLevel, // default top level window
|
||||
Dialog, // top level window but usually handled differently
|
||||
// by the OS
|
||||
Sheet, // MacOSX sheet (special dialog class)
|
||||
Popup, // used for combo boxes, etc
|
||||
Child, // child windows (contained inside a window on the
|
||||
// desktop (has no border))
|
||||
|
|
|
|||
|
|
@ -11,12 +11,6 @@ with Files("**"):
|
|||
with Files("*TextInput*"):
|
||||
BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling")
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
"nsPIWidgetCocoa.idl",
|
||||
]
|
||||
|
||||
XPIDL_MODULE = "widget_cocoa"
|
||||
|
||||
EXPORTS += [
|
||||
"DesktopBackgroundImage.h",
|
||||
"MediaHardwareKeysEventSourceMac.h",
|
||||
|
|
|
|||
|
|
@ -1730,19 +1730,21 @@ static LayoutDeviceIntRect FindFirstRectOfType(
|
|||
|
||||
void nsChildView::UpdateThemeGeometries(
|
||||
const nsTArray<ThemeGeometry>& aThemeGeometries) {
|
||||
if (![mView window]) return;
|
||||
if (!mView.window) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateVibrancy(aThemeGeometries);
|
||||
|
||||
if (![[mView window] isKindOfClass:[ToolbarWindow class]]) return;
|
||||
if (![mView.window isKindOfClass:[ToolbarWindow class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update unified toolbar height and sheet attachment position.
|
||||
int32_t windowWidth = mBounds.width;
|
||||
int32_t titlebarBottom = FindTitlebarBottom(aThemeGeometries, windowWidth);
|
||||
int32_t unifiedToolbarBottom =
|
||||
FindUnifiedToolbarBottom(aThemeGeometries, windowWidth, titlebarBottom);
|
||||
int32_t toolboxBottom =
|
||||
FindFirstRectOfType(aThemeGeometries, eThemeGeometryTypeToolbox).YMost();
|
||||
|
||||
ToolbarWindow* win = (ToolbarWindow*)[mView window];
|
||||
int32_t titlebarHeight = [win drawsContentsIntoWindowFrame]
|
||||
|
|
@ -1751,12 +1753,6 @@ void nsChildView::UpdateThemeGeometries(
|
|||
int32_t devUnifiedHeight = titlebarHeight + unifiedToolbarBottom;
|
||||
[win setUnifiedToolbarHeight:DevPixelsToCocoaPoints(devUnifiedHeight)];
|
||||
|
||||
int32_t sheetPositionDevPx = std::max(toolboxBottom, unifiedToolbarBottom);
|
||||
NSPoint sheetPositionView = {0, DevPixelsToCocoaPoints(sheetPositionDevPx)};
|
||||
NSPoint sheetPositionWindow = [mView convertPoint:sheetPositionView
|
||||
toView:nil];
|
||||
[win setSheetAttachmentPosition:sheetPositionWindow.y];
|
||||
|
||||
// Update titlebar control offsets.
|
||||
LayoutDeviceIntRect windowButtonRect =
|
||||
FindFirstRectOfType(aThemeGeometries, eThemeGeometryTypeWindowButtons);
|
||||
|
|
@ -5129,18 +5125,12 @@ BOOL ChildViewMouseTracker::WindowAcceptsEvent(NSWindow* aWindow,
|
|||
|
||||
case WindowType::TopLevel:
|
||||
case WindowType::Dialog:
|
||||
if ([aWindow attachedSheet]) return NO;
|
||||
if (aWindow.attachedSheet) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
topLevelWindow = aWindow;
|
||||
break;
|
||||
case WindowType::Sheet: {
|
||||
nsIWidget* parentWidget = windowWidget->GetSheetWindowParent();
|
||||
if (!parentWidget) return YES;
|
||||
|
||||
topLevelWindow = (NSWindow*)parentWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return YES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsBaseWidget.h"
|
||||
#include "nsPIWidgetCocoa.h"
|
||||
#include "nsCocoaUtils.h"
|
||||
#include "nsTouchBar.h"
|
||||
#include <dlfcn.h>
|
||||
|
|
@ -189,7 +188,6 @@ typedef struct _nsCocoaWindowList {
|
|||
FullscreenTitlebarTracker* mFullscreenTitlebarTracker;
|
||||
|
||||
CGFloat mUnifiedToolbarHeight;
|
||||
CGFloat mSheetAttachmentPosition;
|
||||
CGFloat mMenuBarHeight;
|
||||
/* Store the height of the titlebar when this window is initialized. The
|
||||
titlebarHeight getter returns 0 when in fullscreen, which is not useful in
|
||||
|
|
@ -203,68 +201,61 @@ typedef struct _nsCocoaWindowList {
|
|||
- (NSRect)titlebarRect;
|
||||
- (void)setTitlebarNeedsDisplay;
|
||||
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
|
||||
- (void)setSheetAttachmentPosition:(CGFloat)aY;
|
||||
- (CGFloat)sheetAttachmentPosition;
|
||||
- (void)placeWindowButtons:(NSRect)aRect;
|
||||
- (NSRect)windowButtonsRect;
|
||||
- (void)windowMainStateChanged;
|
||||
@end
|
||||
|
||||
class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
||||
class nsCocoaWindow final : public nsBaseWidget {
|
||||
private:
|
||||
typedef nsBaseWidget Inherited;
|
||||
|
||||
public:
|
||||
nsCocoaWindow();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSPIWIDGETCOCOA; // semicolon for clang-format bug 1629756
|
||||
[[nodiscard]] nsresult Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const DesktopIntRect& aRect,
|
||||
InitData* = nullptr) override;
|
||||
|
||||
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const DesktopIntRect& aRect,
|
||||
InitData* = nullptr) override;
|
||||
[[nodiscard]] nsresult Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
InitData* = nullptr) override;
|
||||
|
||||
[[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
|
||||
nsNativeWidget aNativeParent,
|
||||
const LayoutDeviceIntRect& aRect,
|
||||
InitData* = nullptr) override;
|
||||
void Destroy() override;
|
||||
|
||||
virtual void Destroy() override;
|
||||
void Show(bool aState) override;
|
||||
bool NeedsRecreateToReshow() override;
|
||||
|
||||
virtual void Show(bool aState) override;
|
||||
virtual bool NeedsRecreateToReshow() override;
|
||||
void Enable(bool aState) override;
|
||||
bool IsEnabled() const override;
|
||||
void SetModal(bool aState) override;
|
||||
void SetFakeModal(bool aState) override;
|
||||
bool IsRunningAppModal() override;
|
||||
bool IsVisible() const override;
|
||||
void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
LayoutDeviceIntPoint GetClientOffset() override;
|
||||
LayoutDeviceIntMargin ClientToWindowMargin() override;
|
||||
|
||||
virtual nsIWidget* GetSheetWindowParent(void) override;
|
||||
virtual void Enable(bool aState) override;
|
||||
virtual bool IsEnabled() const override;
|
||||
virtual void SetModal(bool aState) override;
|
||||
virtual void SetFakeModal(bool aState) override;
|
||||
virtual bool IsRunningAppModal() override;
|
||||
virtual bool IsVisible() const override;
|
||||
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
|
||||
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
||||
virtual LayoutDeviceIntPoint GetClientOffset() override;
|
||||
virtual LayoutDeviceIntMargin ClientToWindowMargin() override;
|
||||
void* GetNativeData(uint32_t aDataType) override;
|
||||
|
||||
virtual void* GetNativeData(uint32_t aDataType) override;
|
||||
void ConstrainPosition(DesktopIntPoint&) override;
|
||||
void SetSizeConstraints(const SizeConstraints& aConstraints) override;
|
||||
void Move(double aX, double aY) override;
|
||||
nsSizeMode SizeMode() override { return mSizeMode; }
|
||||
void SetSizeMode(nsSizeMode aMode) override;
|
||||
void GetWorkspaceID(nsAString& workspaceID) override;
|
||||
void MoveToWorkspace(const nsAString& workspaceID) override;
|
||||
void SuppressAnimation(bool aSuppress) override;
|
||||
void HideWindowChrome(bool aShouldHide) override;
|
||||
|
||||
virtual void ConstrainPosition(DesktopIntPoint&) override;
|
||||
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
|
||||
virtual void Move(double aX, double aY) override;
|
||||
virtual nsSizeMode SizeMode() override { return mSizeMode; }
|
||||
virtual void SetSizeMode(nsSizeMode aMode) override;
|
||||
virtual void GetWorkspaceID(nsAString& workspaceID) override;
|
||||
virtual void MoveToWorkspace(const nsAString& workspaceID) override;
|
||||
virtual void SuppressAnimation(bool aSuppress) override;
|
||||
virtual void HideWindowChrome(bool aShouldHide) override;
|
||||
|
||||
virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
|
||||
virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
|
||||
uint16_t aDuration,
|
||||
nsISupports* aData,
|
||||
nsIRunnable* aCallback) override;
|
||||
virtual void CleanupFullscreenTransition() override;
|
||||
bool PrepareForFullscreenTransition(nsISupports** aData) override;
|
||||
void PerformFullscreenTransition(FullscreenTransitionStage aStage,
|
||||
uint16_t aDuration, nsISupports* aData,
|
||||
nsIRunnable* aCallback) override;
|
||||
void CleanupFullscreenTransition() override;
|
||||
nsresult MakeFullScreen(bool aFullScreen) final;
|
||||
nsresult MakeFullScreenWithNativeTransition(bool aFullScreen) final;
|
||||
NSAnimation* FullscreenTransitionAnimation() const {
|
||||
|
|
@ -277,68 +268,66 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
mFullscreenTransitionAnimation = nil;
|
||||
}
|
||||
|
||||
virtual void Resize(double aWidth, double aHeight, bool aRepaint) override;
|
||||
virtual void Resize(double aX, double aY, double aWidth, double aHeight,
|
||||
bool aRepaint) override;
|
||||
void Resize(double aWidth, double aHeight, bool aRepaint) override;
|
||||
void Resize(double aX, double aY, double aWidth, double aHeight,
|
||||
bool aRepaint) override;
|
||||
NSRect GetClientCocoaRect();
|
||||
virtual LayoutDeviceIntRect GetClientBounds() override;
|
||||
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
||||
LayoutDeviceIntRect GetClientBounds() override;
|
||||
LayoutDeviceIntRect GetScreenBounds() override;
|
||||
void ReportMoveEvent();
|
||||
void ReportSizeEvent();
|
||||
virtual void SetCursor(const Cursor&) override;
|
||||
void SetCursor(const Cursor&) override;
|
||||
|
||||
CGFloat BackingScaleFactor();
|
||||
void BackingScaleFactorChanged();
|
||||
virtual double GetDefaultScaleInternal() override;
|
||||
virtual int32_t RoundsWidgetCoordinatesTo() override;
|
||||
double GetDefaultScaleInternal() override;
|
||||
int32_t RoundsWidgetCoordinatesTo() override;
|
||||
|
||||
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() final {
|
||||
return mozilla::DesktopToLayoutDeviceScale(BackingScaleFactor());
|
||||
}
|
||||
|
||||
virtual nsresult SetTitle(const nsAString& aTitle) override;
|
||||
nsresult SetTitle(const nsAString& aTitle) override;
|
||||
|
||||
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
||||
virtual WindowRenderer* GetWindowRenderer() override;
|
||||
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
nsEventStatus& aStatus) override;
|
||||
virtual void CaptureRollupEvents(bool aDoCapture) override;
|
||||
[[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) override;
|
||||
virtual bool HasPendingInputEvent() override;
|
||||
virtual TransparencyMode GetTransparencyMode() override;
|
||||
virtual void SetTransparencyMode(TransparencyMode aMode) override;
|
||||
virtual void SetWindowShadowStyle(mozilla::WindowShadow aStyle) override;
|
||||
virtual void SetWindowOpacity(float aOpacity) override;
|
||||
virtual void SetWindowTransform(
|
||||
const mozilla::gfx::Matrix& aTransform) override;
|
||||
virtual void SetInputRegion(const InputRegion&) override;
|
||||
virtual void SetColorScheme(
|
||||
const mozilla::Maybe<mozilla::ColorScheme>&) override;
|
||||
virtual void SetShowsToolbarButton(bool aShow) override;
|
||||
virtual void SetSupportsNativeFullscreen(bool aShow) override;
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType) override;
|
||||
virtual void SetDrawsTitle(bool aDrawTitle) override;
|
||||
virtual nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) override;
|
||||
void Invalidate(const LayoutDeviceIntRect& aRect) override;
|
||||
WindowRenderer* GetWindowRenderer() override;
|
||||
nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
||||
nsEventStatus& aStatus) override;
|
||||
void CaptureRollupEvents(bool aDoCapture) override;
|
||||
[[nodiscard]] nsresult GetAttention(int32_t aCycleCount) override;
|
||||
bool HasPendingInputEvent() override;
|
||||
TransparencyMode GetTransparencyMode() override;
|
||||
void SetTransparencyMode(TransparencyMode aMode) override;
|
||||
void SetWindowShadowStyle(mozilla::WindowShadow aStyle) override;
|
||||
void SetWindowOpacity(float aOpacity) override;
|
||||
void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) override;
|
||||
void SetInputRegion(const InputRegion&) override;
|
||||
void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) override;
|
||||
void SetShowsToolbarButton(bool aShow) override;
|
||||
void SetSupportsNativeFullscreen(bool aShow) override;
|
||||
void SetWindowAnimationType(WindowAnimationType aType) override;
|
||||
void SetDrawsTitle(bool aDrawTitle) override;
|
||||
nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) override;
|
||||
void SetDrawsInTitlebar(bool aState);
|
||||
virtual void UpdateThemeGeometries(
|
||||
void UpdateThemeGeometries(
|
||||
const nsTArray<ThemeGeometry>& aThemeGeometries) override;
|
||||
virtual nsresult SynthesizeNativeMouseEvent(
|
||||
LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
|
||||
mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
|
||||
nsIObserver* aObserver) override;
|
||||
virtual nsresult SynthesizeNativeMouseScrollEvent(
|
||||
nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
|
||||
NativeMouseMessage aNativeMessage,
|
||||
mozilla::MouseButton aButton,
|
||||
nsIWidget::Modifiers aModifierFlags,
|
||||
nsIObserver* aObserver) override;
|
||||
nsresult SynthesizeNativeMouseScrollEvent(
|
||||
LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
|
||||
double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
|
||||
uint32_t aAdditionalFlags, nsIObserver* aObserver) override;
|
||||
virtual void LockAspectRatio(bool aShouldLock) override;
|
||||
void LockAspectRatio(bool aShouldLock) override;
|
||||
|
||||
void DispatchSizeModeEvent();
|
||||
void DispatchOcclusionEvent();
|
||||
|
||||
// be notified that a some form of drag event needs to go into Gecko
|
||||
virtual bool DragEvent(unsigned int aMessage,
|
||||
mozilla::gfx::Point aMouseGlobal,
|
||||
UInt16 aKeyModifiers);
|
||||
bool DragEvent(unsigned int aMessage, mozilla::gfx::Point aMouseGlobal,
|
||||
UInt16 aKeyModifiers);
|
||||
|
||||
bool HasModalDescendents() { return mNumModalDescendents > 0; }
|
||||
NSWindow* GetCocoaWindow() { return mWindow; }
|
||||
|
|
@ -346,10 +335,10 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
void SetMenuBar(RefPtr<nsMenuBarX>&& aMenuBar);
|
||||
nsMenuBarX* GetMenuBar();
|
||||
|
||||
virtual void SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) override;
|
||||
virtual InputContext GetInputContext() override { return mInputContext; }
|
||||
MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
|
||||
void SetInputContext(const InputContext& aContext,
|
||||
const InputContextAction& aAction) override;
|
||||
InputContext GetInputContext() override { return mInputContext; }
|
||||
MOZ_CAN_RUN_SCRIPT bool GetEditCommands(
|
||||
mozilla::NativeKeyBindingsType aType,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
nsTArray<mozilla::CommandInt>& aCommands) override;
|
||||
|
|
@ -400,6 +389,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
void DestroyNativeWindow();
|
||||
void UpdateBounds();
|
||||
int32_t GetWorkspaceID();
|
||||
void SendSetZLevelEvent();
|
||||
|
||||
void DoResize(double aX, double aY, double aWidth, double aHeight,
|
||||
bool aRepaint, bool aConstrainToCurrentScreen);
|
||||
|
|
@ -407,7 +397,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
void UpdateFullscreenState(bool aFullScreen, bool aNativeMode);
|
||||
nsresult DoMakeFullScreen(bool aFullScreen, bool aUseSystemTransition);
|
||||
|
||||
virtual already_AddRefed<nsIWidget> AllocateChildPopupWidget() override {
|
||||
already_AddRefed<nsIWidget> AllocateChildPopupWidget() override {
|
||||
return nsIWidget::CreateTopLevelWindow();
|
||||
}
|
||||
|
||||
|
|
@ -417,8 +407,6 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
WindowDelegate*
|
||||
mDelegate; // our delegate for processing window msgs [STRONG]
|
||||
RefPtr<nsMenuBarX> mMenuBar;
|
||||
NSWindow* mSheetWindowParent; // if this is a sheet, this is the NSWindow
|
||||
// it's attached to
|
||||
nsChildView*
|
||||
mPopupContentView; // if this is a popup, this is its content widget
|
||||
// if this is a toplevel window, and there is any ongoing fullscreen
|
||||
|
|
@ -432,8 +420,6 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
|
|||
WindowAnimationType mAnimationType;
|
||||
|
||||
bool mWindowMadeHere; // true if we created the window, false for embedding
|
||||
bool mSheetNeedsShow; // if this is a sheet, are we waiting to be shown?
|
||||
// this is used for sibling sheet contention only
|
||||
nsSizeMode mSizeMode;
|
||||
bool mInFullScreenMode;
|
||||
// Whether we are currently using native fullscreen. It could be false because
|
||||
|
|
|
|||
|
|
@ -105,13 +105,6 @@ extern CGError CGSSetWindowTransform(CGSConnection cid, CGSWindow wid,
|
|||
|
||||
#define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
|
||||
|
||||
// A note on testing to see if your object is a sheet...
|
||||
// |mWindowType == WindowType::Sheet| is true if your gecko nsIWidget is a sheet
|
||||
// widget - whether or not the sheet is showing. |[mWindow isSheet]| will return
|
||||
// true *only when the sheet is actually showing*. Choose your test wisely.
|
||||
|
||||
static void RollUpPopups(nsIRollupListener::AllowAnimations aAllowAnimations =
|
||||
nsIRollupListener::AllowAnimations::Yes) {
|
||||
if (RefPtr pm = nsXULPopupManager::GetInstance()) {
|
||||
|
|
@ -139,14 +132,12 @@ nsCocoaWindow::nsCocoaWindow()
|
|||
mAncestorLink(nullptr),
|
||||
mWindow(nil),
|
||||
mDelegate(nil),
|
||||
mSheetWindowParent(nil),
|
||||
mPopupContentView(nil),
|
||||
mFullscreenTransitionAnimation(nil),
|
||||
mShadowStyle(WindowShadow::None),
|
||||
mBackingScaleFactor(0.0),
|
||||
mAnimationType(nsIWidget::eGenericWindowAnimation),
|
||||
mWindowMadeHere(false),
|
||||
mSheetNeedsShow(false),
|
||||
mSizeMode(nsSizeMode_Normal),
|
||||
mInFullScreenMode(false),
|
||||
mInNativeFullScreenMode(false),
|
||||
|
|
@ -432,15 +423,6 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect,
|
|||
case WindowType::Dialog:
|
||||
features = WindowMaskForBorderStyle(aBorderStyle);
|
||||
break;
|
||||
case WindowType::Sheet:
|
||||
if (mParent->GetWindowType() != WindowType::Invisible &&
|
||||
aBorderStyle & BorderStyle::ResizeH) {
|
||||
features = NSWindowStyleMaskResizable;
|
||||
} else {
|
||||
features = NSWindowStyleMaskMiniaturizable;
|
||||
}
|
||||
features |= NSWindowStyleMaskTitled;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unhandled window type!");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
@ -651,14 +633,6 @@ void nsCocoaWindow::Destroy() {
|
|||
}
|
||||
}
|
||||
|
||||
nsIWidget* nsCocoaWindow::GetSheetWindowParent(void) {
|
||||
if (mWindowType != WindowType::Sheet) return nullptr;
|
||||
nsCocoaWindow* parent = static_cast<nsCocoaWindow*>(mParent);
|
||||
while (parent && (parent->mWindowType == WindowType::Sheet))
|
||||
parent = static_cast<nsCocoaWindow*>(parent->mParent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
void* nsCocoaWindow::GetNativeData(uint32_t aDataType) {
|
||||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
|
|
@ -708,7 +682,7 @@ void* nsCocoaWindow::GetNativeData(uint32_t aDataType) {
|
|||
bool nsCocoaWindow::IsVisible() const {
|
||||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
return (mWindow && ([mWindow isVisibleOrBeingShown] || mSheetNeedsShow));
|
||||
return mWindow && mWindow.isVisibleOrBeingShown;
|
||||
|
||||
NS_OBJC_END_TRY_BLOCK_RETURN(false);
|
||||
}
|
||||
|
|
@ -733,7 +707,7 @@ void nsCocoaWindow::SetModal(bool aState) {
|
|||
nsAutoreleasePool localPool;
|
||||
|
||||
mModal = aState;
|
||||
nsCocoaWindow* ancestor = static_cast<nsCocoaWindow*>(mAncestorLink);
|
||||
auto* ancestor = static_cast<nsCocoaWindow*>(mAncestorLink);
|
||||
if (aState) {
|
||||
++gXULModalLevel;
|
||||
// When a non-sheet window gets "set modal", make the window(s) that it
|
||||
|
|
@ -743,58 +717,54 @@ void nsCocoaWindow::SetModal(bool aState) {
|
|||
// methods) that's incompatible with the modal event loop in AppWindow::
|
||||
// ShowModal() (each of these event loops is "exclusive", and can't run at
|
||||
// the same time as other (similar) event loops).
|
||||
if (mWindowType != WindowType::Sheet) {
|
||||
while (ancestor) {
|
||||
if (ancestor->mNumModalDescendents++ == 0) {
|
||||
NSWindow* aWindow = ancestor->GetCocoaWindow();
|
||||
if (ancestor->mWindowType != WindowType::Invisible) {
|
||||
[[aWindow standardWindowButton:NSWindowCloseButton] setEnabled:NO];
|
||||
[[aWindow standardWindowButton:NSWindowMiniaturizeButton]
|
||||
setEnabled:NO];
|
||||
[[aWindow standardWindowButton:NSWindowZoomButton] setEnabled:NO];
|
||||
}
|
||||
while (ancestor) {
|
||||
if (ancestor->mNumModalDescendents++ == 0) {
|
||||
NSWindow* aWindow = ancestor->GetCocoaWindow();
|
||||
if (ancestor->mWindowType != WindowType::Invisible) {
|
||||
[[aWindow standardWindowButton:NSWindowCloseButton] setEnabled:NO];
|
||||
[[aWindow standardWindowButton:NSWindowMiniaturizeButton]
|
||||
setEnabled:NO];
|
||||
[[aWindow standardWindowButton:NSWindowZoomButton] setEnabled:NO];
|
||||
}
|
||||
ancestor = static_cast<nsCocoaWindow*>(ancestor->mParent);
|
||||
}
|
||||
[mWindow setLevel:NSModalPanelWindowLevel];
|
||||
nsCocoaWindowList* windowList = new nsCocoaWindowList;
|
||||
if (windowList) {
|
||||
windowList->window = this; // Don't ADDREF
|
||||
windowList->prev = gGeckoAppModalWindowList;
|
||||
gGeckoAppModalWindowList = windowList;
|
||||
}
|
||||
ancestor = static_cast<nsCocoaWindow*>(ancestor->mParent);
|
||||
}
|
||||
[mWindow setLevel:NSModalPanelWindowLevel];
|
||||
nsCocoaWindowList* windowList = new nsCocoaWindowList;
|
||||
if (windowList) {
|
||||
windowList->window = this; // Don't ADDREF
|
||||
windowList->prev = gGeckoAppModalWindowList;
|
||||
gGeckoAppModalWindowList = windowList;
|
||||
}
|
||||
} else {
|
||||
--gXULModalLevel;
|
||||
NS_ASSERTION(gXULModalLevel >= 0,
|
||||
"Mismatched call to nsCocoaWindow::SetModal(false)!");
|
||||
if (mWindowType != WindowType::Sheet) {
|
||||
while (ancestor) {
|
||||
if (--ancestor->mNumModalDescendents == 0) {
|
||||
NSWindow* aWindow = ancestor->GetCocoaWindow();
|
||||
if (ancestor->mWindowType != WindowType::Invisible) {
|
||||
[[aWindow standardWindowButton:NSWindowCloseButton] setEnabled:YES];
|
||||
[[aWindow standardWindowButton:NSWindowMiniaturizeButton]
|
||||
setEnabled:YES];
|
||||
[[aWindow standardWindowButton:NSWindowZoomButton] setEnabled:YES];
|
||||
}
|
||||
while (ancestor) {
|
||||
if (--ancestor->mNumModalDescendents == 0) {
|
||||
NSWindow* aWindow = ancestor->GetCocoaWindow();
|
||||
if (ancestor->mWindowType != WindowType::Invisible) {
|
||||
[[aWindow standardWindowButton:NSWindowCloseButton] setEnabled:YES];
|
||||
[[aWindow standardWindowButton:NSWindowMiniaturizeButton]
|
||||
setEnabled:YES];
|
||||
[[aWindow standardWindowButton:NSWindowZoomButton] setEnabled:YES];
|
||||
}
|
||||
NS_ASSERTION(ancestor->mNumModalDescendents >= 0,
|
||||
"Widget hierarchy changed while modal!");
|
||||
ancestor = static_cast<nsCocoaWindow*>(ancestor->mParent);
|
||||
}
|
||||
if (gGeckoAppModalWindowList) {
|
||||
NS_ASSERTION(gGeckoAppModalWindowList->window == this,
|
||||
"Widget hierarchy changed while modal!");
|
||||
nsCocoaWindowList* saved = gGeckoAppModalWindowList;
|
||||
gGeckoAppModalWindowList = gGeckoAppModalWindowList->prev;
|
||||
delete saved; // "window" not ADDREFed
|
||||
}
|
||||
if (mWindowType == WindowType::Popup) {
|
||||
SetPopupWindowLevel();
|
||||
} else {
|
||||
mWindow.level = NSNormalWindowLevel;
|
||||
}
|
||||
NS_ASSERTION(ancestor->mNumModalDescendents >= 0,
|
||||
"Widget hierarchy changed while modal!");
|
||||
ancestor = static_cast<nsCocoaWindow*>(ancestor->mParent);
|
||||
}
|
||||
if (gGeckoAppModalWindowList) {
|
||||
NS_ASSERTION(gGeckoAppModalWindowList->window == this,
|
||||
"Widget hierarchy changed while modal!");
|
||||
nsCocoaWindowList* saved = gGeckoAppModalWindowList;
|
||||
gGeckoAppModalWindowList = gGeckoAppModalWindowList->prev;
|
||||
delete saved; // "window" not ADDREFed
|
||||
}
|
||||
if (mWindowType == WindowType::Popup) {
|
||||
SetPopupWindowLevel();
|
||||
} else {
|
||||
mWindow.level = NSNormalWindowLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -816,12 +786,10 @@ void nsCocoaWindow::Show(bool aState) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!mSheetNeedsShow) {
|
||||
// Early exit if our current visibility state is already the requested
|
||||
// state.
|
||||
if (aState == mWindow.isVisibleOrBeingShown) {
|
||||
return;
|
||||
}
|
||||
// Early exit if our current visibility state is already the requested
|
||||
// state.
|
||||
if (aState == mWindow.isVisibleOrBeingShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
[mWindow setBeingShown:aState];
|
||||
|
|
@ -829,11 +797,8 @@ void nsCocoaWindow::Show(bool aState) {
|
|||
mWasShown = true;
|
||||
}
|
||||
|
||||
nsIWidget* parentWidget = mParent;
|
||||
nsCOMPtr<nsPIWidgetCocoa> piParentWidget(do_QueryInterface(parentWidget));
|
||||
NSWindow* nativeParentWindow =
|
||||
parentWidget ? (NSWindow*)parentWidget->GetNativeData(NS_NATIVE_WINDOW)
|
||||
: nil;
|
||||
mParent ? (NSWindow*)mParent->GetNativeData(NS_NATIVE_WINDOW) : nil;
|
||||
|
||||
if (aState && !mBounds.IsEmpty()) {
|
||||
// If we had set the activationPolicy to accessory, then right now we won't
|
||||
|
|
@ -856,82 +821,7 @@ void nsCocoaWindow::Show(bool aState) {
|
|||
mPopupContentView->Show(true);
|
||||
}
|
||||
|
||||
if (mWindowType == WindowType::Sheet) {
|
||||
// bail if no parent window (its basically what we do in Carbon)
|
||||
if (!nativeParentWindow || !piParentWidget) return;
|
||||
|
||||
NSWindow* topNonSheetWindow = nativeParentWindow;
|
||||
|
||||
// If this sheet is the child of another sheet, hide the parent so that
|
||||
// this sheet can be displayed. Leave the parent mSheetNeedsShow alone,
|
||||
// that is only used to handle sibling sheet contention. The parent will
|
||||
// return once there are no more child sheets.
|
||||
bool parentIsSheet = false;
|
||||
if (NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
|
||||
parentIsSheet) {
|
||||
piParentWidget->GetSheetWindowParent(&topNonSheetWindow);
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
[NSApp endSheet:nativeParentWindow];
|
||||
#else
|
||||
[nativeParentWindow.sheetParent endSheet:nativeParentWindow];
|
||||
#endif
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> sheetShown;
|
||||
if (NS_SUCCEEDED(piParentWidget->GetChildSheet(
|
||||
true, getter_AddRefs(sheetShown))) &&
|
||||
(!sheetShown || sheetShown == this)) {
|
||||
// If this sheet is already the sheet actually being shown, don't
|
||||
// tell it to show again. Otherwise the number of calls to
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
// [NSApp beginSheet...] won't match up with [NSApp endSheet...].
|
||||
#else
|
||||
// [NSWindow beginSheet...] won't match up with [NSWindow endSheet...].
|
||||
#endif
|
||||
if (![mWindow isVisible]) {
|
||||
mSheetNeedsShow = false;
|
||||
mSheetWindowParent = topNonSheetWindow;
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
// Only set contextInfo if our parent isn't a sheet.
|
||||
NSWindow* contextInfo = parentIsSheet ? nil : mSheetWindowParent;
|
||||
[TopLevelWindowData deactivateInWindow:mSheetWindowParent];
|
||||
[NSApp beginSheet:mWindow
|
||||
modalForWindow:mSheetWindowParent
|
||||
modalDelegate:mDelegate
|
||||
didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
|
||||
contextInfo:contextInfo];
|
||||
#else
|
||||
NSWindow* sheet = mWindow;
|
||||
NSWindow* nonSheetParent = parentIsSheet ? nil : mSheetWindowParent;
|
||||
[TopLevelWindowData deactivateInWindow:mSheetWindowParent];
|
||||
[mSheetWindowParent beginSheet:sheet
|
||||
completionHandler:^(NSModalResponse returnCode) {
|
||||
// Note: 'nonSheetParent' (if it is set) is the window
|
||||
// that is the parent of the sheet. If it's set,
|
||||
// 'nonSheetParent' is always the top- level window,
|
||||
// not another sheet itself. But 'nonSheetParent' is
|
||||
// nil if our parent window is also a sheet -- in that
|
||||
// case we shouldn't send the top-level window any
|
||||
// activate events (because it's our parent window that
|
||||
// needs to get these events, not the top-level
|
||||
// window).
|
||||
[TopLevelWindowData deactivateInWindow:sheet];
|
||||
[sheet orderOut:nil];
|
||||
if (nonSheetParent) {
|
||||
[TopLevelWindowData activateInWindow:nonSheetParent];
|
||||
}
|
||||
}];
|
||||
#endif
|
||||
[TopLevelWindowData activateInWindow:mWindow];
|
||||
SendSetZLevelEvent();
|
||||
}
|
||||
} else {
|
||||
// A sibling of this sheet is active, don't show this sheet yet.
|
||||
// When the active sheet hides, its brothers and sisters that have
|
||||
// mSheetNeedsShow set will have their opportunities to display.
|
||||
mSheetNeedsShow = true;
|
||||
}
|
||||
} else if (mWindowType == WindowType::Popup) {
|
||||
if (mWindowType == WindowType::Popup) {
|
||||
// For reasons that aren't yet clear, calls to [NSWindow orderFront:] or
|
||||
// [NSWindow makeKeyAndOrderFront:] can sometimes trigger "Error (1000)
|
||||
// creating CGSWindow", which in turn triggers an internal inconsistency
|
||||
|
|
@ -1001,120 +891,22 @@ void nsCocoaWindow::Show(bool aState) {
|
|||
RollUpPopups();
|
||||
}
|
||||
|
||||
// now get rid of the window/sheet
|
||||
if (mWindowType == WindowType::Sheet) {
|
||||
if (mSheetNeedsShow) {
|
||||
// This is an attempt to hide a sheet that never had a chance to
|
||||
// be shown. There's nothing to do other than make sure that it
|
||||
// won't show.
|
||||
mSheetNeedsShow = false;
|
||||
} else {
|
||||
// get sheet's parent *before* hiding the sheet (which breaks the
|
||||
// linkage)
|
||||
NSWindow* sheetParent = mSheetWindowParent;
|
||||
// If the window is a popup window with a parent window we need to
|
||||
// unhook it here before ordering it out. When you order out the child
|
||||
// of a window it hides the parent window.
|
||||
if (mWindowType == WindowType::Popup && nativeParentWindow) {
|
||||
[nativeParentWindow removeChildWindow:mWindow];
|
||||
}
|
||||
|
||||
// hide the sheet
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
[NSApp endSheet:mWindow];
|
||||
#else
|
||||
[mSheetWindowParent endSheet:mWindow];
|
||||
#endif
|
||||
[TopLevelWindowData deactivateInWindow:mWindow];
|
||||
|
||||
nsCOMPtr<nsIWidget> siblingSheetToShow;
|
||||
bool parentIsSheet = false;
|
||||
|
||||
if (nativeParentWindow && piParentWidget &&
|
||||
NS_SUCCEEDED(piParentWidget->GetChildSheet(
|
||||
false, getter_AddRefs(siblingSheetToShow))) &&
|
||||
siblingSheetToShow) {
|
||||
// First, give sibling sheets an opportunity to show.
|
||||
siblingSheetToShow->Show(true);
|
||||
} else if (nativeParentWindow && piParentWidget &&
|
||||
NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
|
||||
parentIsSheet) {
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
// Only set contextInfo if the parent of the parent sheet we're about
|
||||
// to restore isn't itself a sheet.
|
||||
NSWindow* contextInfo = sheetParent;
|
||||
#else
|
||||
// Only set nonSheetGrandparent if the parent of the parent sheet
|
||||
// we're about to restore isn't itself a sheet.
|
||||
NSWindow* nonSheetGrandparent = sheetParent;
|
||||
#endif
|
||||
nsIWidget* grandparentWidget = nil;
|
||||
if (NS_SUCCEEDED(piParentWidget->GetRealParent(&grandparentWidget)) &&
|
||||
grandparentWidget) {
|
||||
nsCOMPtr<nsPIWidgetCocoa> piGrandparentWidget(
|
||||
do_QueryInterface(grandparentWidget));
|
||||
bool grandparentIsSheet = false;
|
||||
if (piGrandparentWidget &&
|
||||
NS_SUCCEEDED(
|
||||
piGrandparentWidget->GetIsSheet(&grandparentIsSheet)) &&
|
||||
grandparentIsSheet) {
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
contextInfo = nil;
|
||||
#else
|
||||
nonSheetGrandparent = nil;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// If there are no sibling sheets, but the parent is a sheet, restore
|
||||
// it. It wasn't sent any deactivate events when it was hidden, so
|
||||
// don't call through Show, just let the OS put it back up.
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
[NSApp beginSheet:nativeParentWindow
|
||||
modalForWindow:sheetParent
|
||||
modalDelegate:[nativeParentWindow delegate]
|
||||
didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
|
||||
contextInfo:contextInfo];
|
||||
#else
|
||||
[nativeParentWindow
|
||||
beginSheet:sheetParent
|
||||
completionHandler:^(NSModalResponse returnCode) {
|
||||
// Note: 'nonSheetGrandparent' (if it is set) is the window that
|
||||
// is the parent of sheetParent. If it's set,
|
||||
// 'nonSheetGrandparent' is always the top-level window, not
|
||||
// another sheet itself. But 'nonSheetGrandparent' is nil if
|
||||
// our parent window is also a sheet -- in that case we
|
||||
// shouldn't send the top-level window any activate events
|
||||
// (because it's our parent window that needs to get these
|
||||
// events, not the top-level window).
|
||||
[TopLevelWindowData deactivateInWindow:sheetParent];
|
||||
[sheetParent orderOut:nil];
|
||||
if (nonSheetGrandparent) {
|
||||
[TopLevelWindowData activateInWindow:nonSheetGrandparent];
|
||||
}
|
||||
}];
|
||||
#endif
|
||||
} else {
|
||||
// Sheet, that was hard. No more siblings or parents, going back
|
||||
// to a real window.
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
[sheetParent makeKeyAndOrderFront:nil];
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
}
|
||||
SendSetZLevelEvent();
|
||||
}
|
||||
} else {
|
||||
// If the window is a popup window with a parent window we need to
|
||||
// unhook it here before ordering it out. When you order out the child
|
||||
// of a window it hides the parent window.
|
||||
if (mWindowType == WindowType::Popup && nativeParentWindow) {
|
||||
[nativeParentWindow removeChildWindow:mWindow];
|
||||
}
|
||||
|
||||
[mWindow orderOut:nil];
|
||||
|
||||
// If our popup window is a non-native context menu, tell the OS (and
|
||||
// other programs) that a menu has closed.
|
||||
if ([mWindow isKindOfClass:[PopupWindow class]] &&
|
||||
[(PopupWindow*)mWindow isContextMenu]) {
|
||||
[[NSDistributedNotificationCenter defaultCenter]
|
||||
postNotificationName:
|
||||
@"com.apple.HIToolbox.endMenuTrackingNotification"
|
||||
object:@"org.mozilla.gecko.PopupWindow"];
|
||||
}
|
||||
[mWindow orderOut:nil];
|
||||
// If our popup window is a non-native context menu, tell the OS (and
|
||||
// other programs) that a menu has closed.
|
||||
if ([mWindow isKindOfClass:[PopupWindow class]] &&
|
||||
[(PopupWindow*)mWindow isContextMenu]) {
|
||||
[NSDistributedNotificationCenter.defaultCenter
|
||||
postNotificationName:
|
||||
@"com.apple.HIToolbox.endMenuTrackingNotification"
|
||||
object:@"org.mozilla.gecko.PopupWindow"];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2287,53 +2079,13 @@ bool nsCocoaWindow::DragEvent(unsigned int aMessage,
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::SendSetZLevelEvent() {
|
||||
nsWindowZ placement = nsWindowZTop;
|
||||
nsCOMPtr<nsIWidget> actualBelow;
|
||||
void nsCocoaWindow::SendSetZLevelEvent() {
|
||||
if (mWidgetListener) {
|
||||
nsWindowZ placement = nsWindowZTop;
|
||||
nsCOMPtr<nsIWidget> actualBelow;
|
||||
mWidgetListener->ZLevelChanged(true, &placement, nullptr,
|
||||
getter_AddRefs(actualBelow));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsIWidget** _retval) {
|
||||
nsIWidget* child = GetFirstChild();
|
||||
|
||||
while (child) {
|
||||
if (child->GetWindowType() == WindowType::Sheet) {
|
||||
// if it's a sheet, it must be an nsCocoaWindow
|
||||
nsCocoaWindow* cocoaWindow = static_cast<nsCocoaWindow*>(child);
|
||||
if (cocoaWindow->mWindow &&
|
||||
((aShown && [cocoaWindow->mWindow isVisible]) ||
|
||||
(!aShown && cocoaWindow->mSheetNeedsShow))) {
|
||||
nsCOMPtr<nsIWidget> widget = cocoaWindow;
|
||||
widget.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
child = child->GetNextSibling();
|
||||
}
|
||||
|
||||
*_retval = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::GetRealParent(nsIWidget** parent) {
|
||||
*parent = mParent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::GetIsSheet(bool* isSheet) {
|
||||
mWindowType == WindowType::Sheet ? * isSheet = true : * isSheet = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::GetSheetWindowParent(
|
||||
NSWindow** sheetWindowParent) {
|
||||
*sheetWindowParent = mSheetWindowParent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Invokes callback and ProcessEvent methods on Event Listener object
|
||||
|
|
@ -3184,9 +2936,7 @@ void nsCocoaWindow::CocoaWindowDidResize() {
|
|||
ChildViewMouseTracker::ReEvaluateMouseEnterState();
|
||||
|
||||
NSWindow* window = [aNotification object];
|
||||
if ([window isSheet]) [WindowDelegate paintMenubarForWindow:window];
|
||||
|
||||
nsChildView* mainChildView =
|
||||
auto* mainChildView =
|
||||
static_cast<nsChildView*>([[(BaseWindow*)window mainChildView] widget]);
|
||||
if (mainChildView) {
|
||||
if (mainChildView->GetInputContext().IsPasswordEditor()) {
|
||||
|
|
@ -3205,13 +2955,6 @@ void nsCocoaWindow::CocoaWindowDidResize() {
|
|||
RollUpPopups(nsIRollupListener::AllowAnimations::No);
|
||||
|
||||
ChildViewMouseTracker::ReEvaluateMouseEnterState();
|
||||
|
||||
// If a sheet just resigned key then we should paint the menu bar
|
||||
// for whatever window is now main.
|
||||
NSWindow* window = [aNotification object];
|
||||
if ([window isSheet])
|
||||
[WindowDelegate paintMenubarForWindow:[NSApp mainWindow]];
|
||||
|
||||
TextInputHandler::EnsureSecureEventInputDisabled();
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
|
|
@ -3264,36 +3007,6 @@ void nsCocoaWindow::CocoaWindowDidResize() {
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (NSRect)window:(NSWindow*)window
|
||||
willPositionSheet:(NSWindow*)sheet
|
||||
usingRect:(NSRect)rect {
|
||||
if ([window isKindOfClass:[ToolbarWindow class]]) {
|
||||
rect.origin.y = [(ToolbarWindow*)window sheetAttachmentPosition];
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
- (void)didEndSheet:(NSWindow*)sheet
|
||||
returnCode:(int)returnCode
|
||||
contextInfo:(void*)contextInfo {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
// Note: 'contextInfo' (if it is set) is the window that is the parent of
|
||||
// the sheet. The value of contextInfo is determined in
|
||||
// nsCocoaWindow::Show(). If it's set, 'contextInfo' is always the top-
|
||||
// level window, not another sheet itself. But 'contextInfo' is nil if
|
||||
// our parent window is also a sheet -- in that case we shouldn't send
|
||||
// the top-level window any activate events (because it's our parent
|
||||
// window that needs to get these events, not the top-level window).
|
||||
[TopLevelWindowData deactivateInWindow:sheet];
|
||||
[sheet orderOut:self];
|
||||
if (contextInfo) [TopLevelWindowData activateInWindow:(NSWindow*)contextInfo];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)windowDidChangeBackingProperties:(NSNotification*)aNotification {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
|
|
@ -3974,7 +3687,6 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
|
|||
defer:aFlag])) {
|
||||
mTitlebarView = nil;
|
||||
mUnifiedToolbarHeight = 22.0f;
|
||||
mSheetAttachmentPosition = aChildViewRect.size.height;
|
||||
mWindowButtonsRect = NSZeroRect;
|
||||
mInitialTitlebarHeight = [self titlebarHeight];
|
||||
|
||||
|
|
@ -4206,14 +3918,6 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
|
|||
[self setTitlebarNeedsDisplay];
|
||||
}
|
||||
|
||||
- (void)setSheetAttachmentPosition:(CGFloat)aY {
|
||||
mSheetAttachmentPosition = aY;
|
||||
}
|
||||
|
||||
- (CGFloat)sheetAttachmentPosition {
|
||||
return mSheetAttachmentPosition;
|
||||
}
|
||||
|
||||
- (void)placeWindowButtons:(NSRect)aRect {
|
||||
if (!NSEqualRects(mWindowButtonsRect, aRect)) {
|
||||
mWindowButtonsRect = aRect;
|
||||
|
|
|
|||
|
|
@ -399,9 +399,8 @@ static BOOL FrameIsInActiveWindow(nsIFrame* aFrame) {
|
|||
|
||||
// Toolbar controls and content controls respond to different window
|
||||
// activeness states.
|
||||
static BOOL IsActive(nsIFrame* aFrame, BOOL aIsToolbarControl) {
|
||||
if (aIsToolbarControl) return [NativeWindowForFrame(aFrame) isMainWindow];
|
||||
return FrameIsInActiveWindow(aFrame);
|
||||
static BOOL IsActiveToolbarControl(nsIFrame* aFrame) {
|
||||
return NativeWindowForFrame(aFrame).isMainWindow;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsNativeThemeCocoa, nsNativeTheme, nsITheme)
|
||||
|
|
@ -2347,7 +2346,7 @@ Maybe<nsNativeThemeCocoa::WidgetInfo> nsNativeThemeCocoa::ComputeWidgetInfo(
|
|||
}
|
||||
|
||||
case StyleAppearance::Statusbar:
|
||||
return Some(WidgetInfo::StatusBar(IsActive(aFrame, YES)));
|
||||
return Some(WidgetInfo::StatusBar(IsActiveToolbarControl(aFrame)));
|
||||
|
||||
case StyleAppearance::MenulistButton:
|
||||
case StyleAppearance::Menulist: {
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
/* -*- 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
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIWidget;
|
||||
|
||||
[ptr] native NSWindowPtr(NSWindow);
|
||||
|
||||
//
|
||||
// nsPIWidgetCocoa
|
||||
//
|
||||
// A private interface (unfrozen, private to the widget implementation) that
|
||||
// gives us access to some extra features on a widget/window.
|
||||
//
|
||||
[uuid(f75ff69e-3a51-419e-bd29-042f804bc2ed)]
|
||||
interface nsPIWidgetCocoa : nsISupports
|
||||
{
|
||||
void SendSetZLevelEvent();
|
||||
|
||||
// Find the displayed child sheet (if aShown) or a child sheet that
|
||||
// wants to be displayed (if !aShown)
|
||||
nsIWidget GetChildSheet(in boolean aShown);
|
||||
|
||||
// Get the parent widget (if any) StandardCreate() was called with.
|
||||
nsIWidget GetRealParent();
|
||||
|
||||
// If the object implementing this interface is a sheet, this will return the
|
||||
// native NSWindow it is attached to
|
||||
readonly attribute NSWindowPtr sheetWindowParent;
|
||||
|
||||
// True if window is a sheet
|
||||
readonly attribute boolean isSheet;
|
||||
|
||||
}; // nsPIWidgetCocoa
|
||||
|
|
@ -115,31 +115,31 @@
|
|||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
if ((self = [super init])) {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
[NSNotificationCenter.defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(windowBecameKey:)
|
||||
name:NSWindowDidBecomeKeyNotification
|
||||
object:inWindow];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
[NSNotificationCenter.defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(windowResignedKey:)
|
||||
name:NSWindowDidResignKeyNotification
|
||||
object:inWindow];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
[NSNotificationCenter.defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(windowBecameMain:)
|
||||
name:NSWindowDidBecomeMainNotification
|
||||
object:inWindow];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
[NSNotificationCenter.defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(windowResignedMain:)
|
||||
name:NSWindowDidResignMainNotification
|
||||
object:inWindow];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
[NSNotificationCenter.defaultCenter
|
||||
addObserver:self
|
||||
selector:@selector(windowWillClose:)
|
||||
name:NSWindowWillCloseNotification
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
- (void)dealloc {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self];
|
||||
[super dealloc];
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
|
|
@ -171,7 +171,7 @@
|
|||
+ (void)activateInWindow:(NSWindow*)aWindow {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
WindowDelegate* delegate = (WindowDelegate*)[aWindow delegate];
|
||||
WindowDelegate* delegate = (WindowDelegate*)aWindow.delegate;
|
||||
if (!delegate || ![delegate isKindOfClass:[WindowDelegate class]]) return;
|
||||
|
||||
if ([delegate toplevelActiveState]) return;
|
||||
|
|
@ -191,7 +191,7 @@
|
|||
+ (void)deactivateInWindow:(NSWindow*)aWindow {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
WindowDelegate* delegate = (WindowDelegate*)[aWindow delegate];
|
||||
WindowDelegate* delegate = (WindowDelegate*)aWindow.delegate;
|
||||
if (!delegate || ![delegate isKindOfClass:[WindowDelegate class]]) return;
|
||||
|
||||
if (![delegate toplevelActiveState]) return;
|
||||
|
|
@ -205,9 +205,10 @@
|
|||
+ (void)activateInWindowViews:(NSWindow*)aWindow {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
id firstResponder = [aWindow firstResponder];
|
||||
if ([firstResponder isKindOfClass:[ChildView class]])
|
||||
id firstResponder = aWindow.firstResponder;
|
||||
if ([firstResponder isKindOfClass:[ChildView class]]) {
|
||||
[firstResponder viewsWindowDidBecomeKey];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
}
|
||||
|
|
@ -217,9 +218,10 @@
|
|||
+ (void)deactivateInWindowViews:(NSWindow*)aWindow {
|
||||
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
|
||||
|
||||
id firstResponder = [aWindow firstResponder];
|
||||
if ([firstResponder isKindOfClass:[ChildView class]])
|
||||
id firstResponder = aWindow.firstResponder;
|
||||
if ([firstResponder isKindOfClass:[ChildView class]]) {
|
||||
[firstResponder viewsWindowDidResignKey];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_IGNORE_BLOCK;
|
||||
}
|
||||
|
|
@ -230,23 +232,23 @@
|
|||
// should be sent when a native window becomes key, and the NS_DEACTIVATE
|
||||
// event should be sent when it resignes key.
|
||||
- (void)windowBecameKey:(NSNotification*)inNotification {
|
||||
NSWindow* window = (NSWindow*)[inNotification object];
|
||||
NSWindow* window = inNotification.object;
|
||||
|
||||
id delegate = [window delegate];
|
||||
id delegate = window.delegate;
|
||||
if (!delegate || ![delegate isKindOfClass:[WindowDelegate class]]) {
|
||||
[TopLevelWindowData activateInWindowViews:window];
|
||||
} else if ([window isSheet] || [NSApp modalWindow]) {
|
||||
} else if (window.isSheet || NSApp.modalWindow) {
|
||||
[TopLevelWindowData activateInWindow:window];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowResignedKey:(NSNotification*)inNotification {
|
||||
NSWindow* window = (NSWindow*)[inNotification object];
|
||||
NSWindow* window = inNotification.object;
|
||||
|
||||
id delegate = [window delegate];
|
||||
id delegate = window.delegate;
|
||||
if (!delegate || ![delegate isKindOfClass:[WindowDelegate class]]) {
|
||||
[TopLevelWindowData deactivateInWindowViews:window];
|
||||
} else if ([window isSheet] || [NSApp modalWindow]) {
|
||||
} else if (window.isSheet || NSApp.modalWindow) {
|
||||
[TopLevelWindowData deactivateInWindow:window];
|
||||
}
|
||||
}
|
||||
|
|
@ -255,24 +257,24 @@
|
|||
// state). So (for non-embedders) we need to ensure that a top-level window
|
||||
// is main when an NS_ACTIVATE event is sent to Gecko for it.
|
||||
- (void)windowBecameMain:(NSNotification*)inNotification {
|
||||
NSWindow* window = (NSWindow*)[inNotification object];
|
||||
|
||||
id delegate = [window delegate];
|
||||
NSWindow* window = inNotification.object;
|
||||
id delegate = window.delegate;
|
||||
// Don't send events to a top-level window that has a sheet/modal-window open
|
||||
// above it -- as far as Gecko is concerned, it's inactive, and stays so until
|
||||
// the sheet/modal-window closes.
|
||||
if (delegate && [delegate isKindOfClass:[WindowDelegate class]] &&
|
||||
![window attachedSheet] && ![NSApp modalWindow])
|
||||
!window.attachedSheet && !NSApp.modalWindow) {
|
||||
[TopLevelWindowData activateInWindow:window];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowResignedMain:(NSNotification*)inNotification {
|
||||
NSWindow* window = (NSWindow*)[inNotification object];
|
||||
|
||||
id delegate = [window delegate];
|
||||
NSWindow* window = inNotification.object;
|
||||
id delegate = window.delegate;
|
||||
if (delegate && [delegate isKindOfClass:[WindowDelegate class]] &&
|
||||
![window attachedSheet] && ![NSApp modalWindow])
|
||||
![window attachedSheet] && ![NSApp modalWindow]) {
|
||||
[TopLevelWindowData deactivateInWindow:window];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification*)inNotification {
|
||||
|
|
|
|||
|
|
@ -160,10 +160,9 @@ void HeadlessWidget::GetCompositorWidgetInitData(
|
|||
nsIWidget* HeadlessWidget::GetTopLevelWidget() { return mTopLevel; }
|
||||
|
||||
void HeadlessWidget::RaiseWindow() {
|
||||
MOZ_ASSERT(mWindowType == WindowType::TopLevel ||
|
||||
mWindowType == WindowType::Dialog ||
|
||||
mWindowType == WindowType::Sheet,
|
||||
"Raising a non-toplevel window.");
|
||||
MOZ_ASSERT(
|
||||
mWindowType == WindowType::TopLevel || mWindowType == WindowType::Dialog,
|
||||
"Raising a non-toplevel window.");
|
||||
|
||||
// Do nothing if this is the currently active window.
|
||||
RefPtr<HeadlessWidget> activeWindow = GetActiveWindow();
|
||||
|
|
@ -204,7 +203,7 @@ void HeadlessWidget::Show(bool aState) {
|
|||
// so we don't focus them by default.
|
||||
if (aState && !mAlwaysOnTop &&
|
||||
(mWindowType == WindowType::TopLevel ||
|
||||
mWindowType == WindowType::Dialog || mWindowType == WindowType::Sheet)) {
|
||||
mWindowType == WindowType::Dialog)) {
|
||||
RaiseWindow();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1335,8 +1335,6 @@ DWORD nsWindow::WindowExStyle() {
|
|||
}
|
||||
return extendedStyle;
|
||||
}
|
||||
case WindowType::Sheet:
|
||||
MOZ_FALLTHROUGH_ASSERT("Sheets are macOS specific");
|
||||
case WindowType::Dialog:
|
||||
case WindowType::TopLevel:
|
||||
case WindowType::Invisible:
|
||||
|
|
|
|||
|
|
@ -579,26 +579,11 @@ nsresult nsAppShellService::JustCreateTopWindow(
|
|||
!!(aChromeMask & nsIWebBrowserChrome::CHROME_ALERT) &&
|
||||
widgetInitData.mWindowType == widget::WindowType::Dialog;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Mac OS X sheet support
|
||||
// Adding CHROME_OPENAS_CHROME to sheetMask makes modal windows opened from
|
||||
// nsGlobalWindow::ShowModalDialog() be dialogs (not sheets), while modal
|
||||
// windows opened from nsPromptService::DoDialog() still are sheets. This
|
||||
// fixes bmo bug 395465 (see nsCocoaWindow::StandardCreate() and
|
||||
// nsCocoaWindow::SetModal()).
|
||||
uint32_t sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
||||
nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
|
||||
if (parent && (parent != mHiddenWindow) &&
|
||||
((aChromeMask & sheetMask) == sheetMask)) {
|
||||
widgetInitData.mWindowType = widget::WindowType::Sheet;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN)
|
||||
if (widgetInitData.mWindowType == widget::WindowType::TopLevel ||
|
||||
widgetInitData.mWindowType == widget::WindowType::Dialog)
|
||||
widgetInitData.mWindowType == widget::WindowType::Dialog) {
|
||||
widgetInitData.mClipChildren = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// note default chrome overrides other OS chrome settings, but
|
||||
|
|
|
|||
Loading…
Reference in a new issue