summaryrefslogtreecommitdiffstats
path: root/widget/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'widget/cocoa')
-rw-r--r--widget/cocoa/CFTypeRefPtr.h194
-rw-r--r--widget/cocoa/GfxInfo.mm18
-rw-r--r--widget/cocoa/MOZIconHelper.mm8
-rw-r--r--widget/cocoa/OSXNotificationCenter.mm6
-rw-r--r--widget/cocoa/TextRecognition.mm4
-rw-r--r--widget/cocoa/moz.build1
-rw-r--r--widget/cocoa/nsCocoaUtils.h21
-rw-r--r--widget/cocoa/nsCocoaUtils.mm84
-rw-r--r--widget/cocoa/nsCocoaWindow.h1
-rw-r--r--widget/cocoa/nsCocoaWindow.mm410
-rw-r--r--widget/cocoa/nsCursorManager.mm10
-rw-r--r--widget/cocoa/nsLookAndFeel.mm3
-rw-r--r--widget/cocoa/nsMacSharingService.mm2
13 files changed, 277 insertions, 485 deletions
diff --git a/widget/cocoa/CFTypeRefPtr.h b/widget/cocoa/CFTypeRefPtr.h
deleted file mode 100644
index 185355777e..0000000000
--- a/widget/cocoa/CFTypeRefPtr.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef CFTypeRefPtr_h
-#define CFTypeRefPtr_h
-
-#include "mozilla/Assertions.h"
-#include "mozilla/Attributes.h"
-#include "mozilla/DbgMacro.h"
-#include "mozilla/HashFunctions.h"
-
-// A smart pointer for CoreFoundation classes which does reference counting.
-//
-// Manual reference counting:
-//
-// UInt32 someNumber = 10;
-// CFNumberRef numberObject =
-// CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &someNumber);
-// // do something with numberObject
-// CFRelease(numberObject);
-//
-// Automatic reference counting using CFTypeRefPtr:
-//
-// UInt32 someNumber = 10;
-// auto numberObject =
-// CFTypeRefPtr<CFNumberRef>::WrapUnderCreateRule(
-// CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &someNumber));
-// // do something with numberObject
-// // no CFRelease
-
-template <class PtrT>
-class CFTypeRefPtr {
- private:
- void assign_with_CFRetain(PtrT aRawPtr) {
- CFRetain(aRawPtr);
- assign_assuming_CFRetain(aRawPtr);
- }
-
- void assign_assuming_CFRetain(PtrT aNewPtr) {
- PtrT oldPtr = mRawPtr;
- mRawPtr = aNewPtr;
- if (oldPtr) {
- CFRelease(oldPtr);
- }
- }
-
- private:
- PtrT mRawPtr;
-
- public:
- ~CFTypeRefPtr() {
- if (mRawPtr) {
- CFRelease(mRawPtr);
- }
- }
-
- // Constructors
-
- CFTypeRefPtr() : mRawPtr(nullptr) {}
-
- CFTypeRefPtr(const CFTypeRefPtr<PtrT>& aSmartPtr)
- : mRawPtr(aSmartPtr.mRawPtr) {
- if (mRawPtr) {
- CFRetain(mRawPtr);
- }
- }
-
- CFTypeRefPtr(CFTypeRefPtr<PtrT>&& aRefPtr) : mRawPtr(aRefPtr.mRawPtr) {
- aRefPtr.mRawPtr = nullptr;
- }
-
- MOZ_IMPLICIT CFTypeRefPtr(decltype(nullptr)) : mRawPtr(nullptr) {}
-
- // There is no constructor from a raw pointer value.
- // Use one of the static WrapUnder*Rule methods below instead.
-
- static CFTypeRefPtr<PtrT> WrapUnderCreateRule(PtrT aRawPtr) {
- CFTypeRefPtr<PtrT> ptr;
- ptr.AssignUnderCreateRule(aRawPtr);
- return ptr;
- }
-
- static CFTypeRefPtr<PtrT> WrapUnderGetRule(PtrT aRawPtr) {
- CFTypeRefPtr<PtrT> ptr;
- ptr.AssignUnderGetRule(aRawPtr);
- return ptr;
- }
-
- // Assignment operators
-
- CFTypeRefPtr<PtrT>& operator=(decltype(nullptr)) {
- assign_assuming_CFRetain(nullptr);
- return *this;
- }
-
- CFTypeRefPtr<PtrT>& operator=(const CFTypeRefPtr<PtrT>& aRhs) {
- assign_with_CFRetain(aRhs.mRawPtr);
- return *this;
- }
-
- CFTypeRefPtr<PtrT>& operator=(CFTypeRefPtr<PtrT>&& aRefPtr) {
- assign_assuming_CFRetain(aRefPtr.mRawPtr);
- aRefPtr.mRawPtr = nullptr;
- return *this;
- }
-
- // There is no operator= for a raw pointer value.
- // Use one of the AssignUnder*Rule methods below instead.
-
- CFTypeRefPtr<PtrT>& AssignUnderCreateRule(PtrT aRawPtr) {
- // Freshly-created objects come with a retain count of 1.
- assign_assuming_CFRetain(aRawPtr);
- return *this;
- }
-
- CFTypeRefPtr<PtrT>& AssignUnderGetRule(PtrT aRawPtr) {
- assign_with_CFRetain(aRawPtr);
- return *this;
- }
-
- // Other pointer operators
-
- // This is the only way to get the raw pointer out of the smart pointer.
- // There is no implicit conversion to a raw pointer.
- PtrT get() const { return mRawPtr; }
-
- // Don't allow implicit conversion of temporary CFTypeRefPtr to raw pointer,
- // because the refcount might be one and the pointer will immediately become
- // invalid.
- operator PtrT() const&& = delete;
- // Also don't allow implicit conversion of non-temporary CFTypeRefPtr.
- operator PtrT() const& = delete;
-
- // These let you null-check a pointer without calling get().
- explicit operator bool() const { return !!mRawPtr; }
-};
-
-template <class PtrT>
-inline bool operator==(const CFTypeRefPtr<PtrT>& aLhs,
- const CFTypeRefPtr<PtrT>& aRhs) {
- return aLhs.get() == aRhs.get();
-}
-
-template <class PtrT>
-inline bool operator!=(const CFTypeRefPtr<PtrT>& aLhs,
- const CFTypeRefPtr<PtrT>& aRhs) {
- return !(aLhs == aRhs);
-}
-
-// Comparing an |CFTypeRefPtr| to |nullptr|
-
-template <class PtrT>
-inline bool operator==(const CFTypeRefPtr<PtrT>& aLhs, decltype(nullptr)) {
- return aLhs.get() == nullptr;
-}
-
-template <class PtrT>
-inline bool operator==(decltype(nullptr), const CFTypeRefPtr<PtrT>& aRhs) {
- return nullptr == aRhs.get();
-}
-
-template <class PtrT>
-inline bool operator!=(const CFTypeRefPtr<PtrT>& aLhs, decltype(nullptr)) {
- return aLhs.get() != nullptr;
-}
-
-template <class PtrT>
-inline bool operator!=(decltype(nullptr), const CFTypeRefPtr<PtrT>& aRhs) {
- return nullptr != aRhs.get();
-}
-
-// MOZ_DBG support
-
-template <class PtrT>
-std::ostream& operator<<(std::ostream& aOut, const CFTypeRefPtr<PtrT>& aObj) {
- return mozilla::DebugValue(aOut, aObj.get());
-}
-
-// std::hash support (e.g. for unordered_map)
-namespace std {
-template <class PtrT>
-struct hash<CFTypeRefPtr<PtrT>> {
- typedef CFTypeRefPtr<PtrT> argument_type;
- typedef std::size_t result_type;
- result_type operator()(argument_type const& aPtr) const {
- return mozilla::HashGeneric(reinterpret_cast<uintptr_t>(aPtr.get()));
- }
-};
-} // namespace std
-
-#endif /* CFTypeRefPtr_h */
diff --git a/widget/cocoa/GfxInfo.mm b/widget/cocoa/GfxInfo.mm
index 1476cc27db..f4477cef4a 100644
--- a/widget/cocoa/GfxInfo.mm
+++ b/widget/cocoa/GfxInfo.mm
@@ -419,21 +419,17 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { return NS_ERROR_FAILURE; }
void GfxInfo::AddCrashReportAnnotations() {
nsString deviceID, vendorID, driverVersion;
- nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion;
GetAdapterDeviceID(deviceID);
- CopyUTF16toUTF8(deviceID, narrowDeviceID);
GetAdapterVendorID(vendorID);
- CopyUTF16toUTF8(vendorID, narrowVendorID);
GetAdapterDriverVersion(driverVersion);
- CopyUTF16toUTF8(driverVersion, narrowDriverVersion);
-
- CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterVendorID,
- narrowVendorID);
- CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterDeviceID,
- narrowDeviceID);
- CrashReporter::AnnotateCrashReport(
- CrashReporter::Annotation::AdapterDriverVersion, narrowDriverVersion);
+
+ CrashReporter::RecordAnnotationNSString(
+ CrashReporter::Annotation::AdapterVendorID, vendorID);
+ CrashReporter::RecordAnnotationNSString(
+ CrashReporter::Annotation::AdapterDeviceID, deviceID);
+ CrashReporter::RecordAnnotationNSString(
+ CrashReporter::Annotation::AdapterDriverVersion, driverVersion);
}
// We don't support checking driver versions on Mac.
diff --git a/widget/cocoa/MOZIconHelper.mm b/widget/cocoa/MOZIconHelper.mm
index e15407b797..f9c8f02406 100644
--- a/widget/cocoa/MOZIconHelper.mm
+++ b/widget/cocoa/MOZIconHelper.mm
@@ -32,11 +32,11 @@
if (aScaleFactor != 0.0f) {
rv = nsCocoaUtils::CreateNSImageFromImageContainer(
aImage, imgIContainer::FRAME_CURRENT, aPresContext, aComputedStyle,
- &retainedImage, aScaleFactor, &isEntirelyBlack);
+ aSize, &retainedImage, aScaleFactor, &isEntirelyBlack);
} else {
rv = nsCocoaUtils::CreateDualRepresentationNSImageFromImageContainer(
aImage, imgIContainer::FRAME_CURRENT, aPresContext, aComputedStyle,
- &retainedImage, &isEntirelyBlack);
+ aSize, &retainedImage, &isEntirelyBlack);
}
NSImage* image = [retainedImage autorelease];
@@ -45,10 +45,6 @@
return nil;
}
- int32_t origWidth = 0, origHeight = 0;
- aImage->GetWidth(&origWidth);
- aImage->GetHeight(&origHeight);
-
// If all the color channels in the image are black, treat the image as a
// template. This will cause macOS to use the image's alpha channel as a mask
// and it will fill it with a color that looks good in the context that it's
diff --git a/widget/cocoa/OSXNotificationCenter.mm b/widget/cocoa/OSXNotificationCenter.mm
index 07cb026f1f..f7d507a947 100644
--- a/widget/cocoa/OSXNotificationCenter.mm
+++ b/widget/cocoa/OSXNotificationCenter.mm
@@ -544,9 +544,11 @@ OSXNotificationCenter::OnImageReady(nsISupports* aUserData,
NSImage* cocoaImage = nil;
// TODO: Pass pres context / ComputedStyle here to support context paint
- // properties
+ // properties.
+ // TODO: Do we have a reasonable size to pass around here?
nsCocoaUtils::CreateDualRepresentationNSImageFromImageContainer(
- image, imgIContainer::FRAME_FIRST, nullptr, nullptr, &cocoaImage);
+ image, imgIContainer::FRAME_FIRST, nullptr, nullptr, NSMakeSize(0, 0),
+ &cocoaImage);
(osxni->mPendingNotification).contentImage = cocoaImage;
[cocoaImage release];
ShowPendingNotification(osxni);
diff --git a/widget/cocoa/TextRecognition.mm b/widget/cocoa/TextRecognition.mm
index c365f51982..31a170466a 100644
--- a/widget/cocoa/TextRecognition.mm
+++ b/widget/cocoa/TextRecognition.mm
@@ -70,8 +70,8 @@ auto TextRecognition::DoFindText(gfx::DataSourceSurface& aSurface,
// https://developer.apple.com/documentation/vision/vnrecognizedtext?language=objc
auto& quad = *pResult->quads().AppendElement();
- CopyCocoaStringToXPCOMString(recognizedText.string,
- quad.string());
+ CopyNSStringToXPCOMString(recognizedText.string,
+ quad.string());
quad.confidence() = recognizedText.confidence;
auto ToImagePoint = [](CGPoint aPoint) -> ImagePoint {
diff --git a/widget/cocoa/moz.build b/widget/cocoa/moz.build
index ebee9439e0..ddb402e2cc 100644
--- a/widget/cocoa/moz.build
+++ b/widget/cocoa/moz.build
@@ -18,7 +18,6 @@ XPIDL_SOURCES += [
XPIDL_MODULE = "widget_cocoa"
EXPORTS += [
- "CFTypeRefPtr.h",
"DesktopBackgroundImage.h",
"MediaHardwareKeysEventSourceMac.h",
"MediaHardwareKeysEventSourceMacMediaCenter.h",
diff --git a/widget/cocoa/nsCocoaUtils.h b/widget/cocoa/nsCocoaUtils.h
index 9e3b76a920..9b36c1192d 100644
--- a/widget/cocoa/nsCocoaUtils.h
+++ b/widget/cocoa/nsCocoaUtils.h
@@ -18,6 +18,7 @@
#include "nsObjCExceptions.h"
#include "mozilla/EventForwards.h"
+#include "mozilla/MacStringHelpers.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPtr.h"
#include "nsIWidget.h"
@@ -298,8 +299,9 @@ class nsCocoaUtils {
static nsresult CreateNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext,
- const mozilla::ComputedStyle* aComputedStyle, NSImage** aResult,
- CGFloat scaleFactor, bool* aIsEntirelyBlack = nullptr);
+ const mozilla::ComputedStyle* aComputedStyle,
+ const NSSize& aPreferredSize, NSImage** aResult, CGFloat scaleFactor,
+ bool* aIsEntirelyBlack = nullptr);
/** Creates a Cocoa <code>NSImage</code> from a frame of an
<code>imgIContainer</code>. The new <code>NSImage</code> will have both a
@@ -317,18 +319,23 @@ class nsCocoaUtils {
static nsresult CreateDualRepresentationNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext,
- const mozilla::ComputedStyle* aComputedStyle, NSImage** aResult,
+ const mozilla::ComputedStyle* aComputedStyle,
+ const NSSize& aPreferredSize, NSImage** aResult,
bool* aIsEntirelyBlack = nullptr);
/**
* Returns nsAString for aSrc.
*/
- static void GetStringForNSString(const NSString* aSrc, nsAString& aDist);
+ static void GetStringForNSString(const NSString* aSrc, nsAString& aDist) {
+ mozilla::CopyNSStringToXPCOMString(aSrc, aDist);
+ }
/**
* Makes NSString instance for aString.
*/
- static NSString* ToNSString(const nsAString& aString);
+ static NSString* ToNSString(const nsAString& aString) {
+ return mozilla::XPCOMStringToNSString(aString);
+ }
/**
* Returns an NSURL instance for the provided string.
@@ -338,7 +345,9 @@ class nsCocoaUtils {
/**
* Makes NSString instance for aCString.
*/
- static NSString* ToNSString(const nsACString& aCString);
+ static NSString* ToNSString(const nsACString& aCString) {
+ return mozilla::XPCOMStringToNSString(aCString);
+ }
/**
* Returns NSRect for aGeckoRect.
diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm
index f3a7604762..769eb05a85 100644
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -515,11 +515,27 @@ nsresult nsCocoaUtils::CreateNSImageFromCGImage(CGImageRef aInputImage,
nsresult nsCocoaUtils::CreateNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext, const ComputedStyle* aComputedStyle,
- NSImage** aResult, CGFloat scaleFactor, bool* aIsEntirelyBlack) {
+ const NSSize& aPreferredSize, NSImage** aResult, CGFloat scaleFactor,
+ bool* aIsEntirelyBlack) {
RefPtr<SourceSurface> surface;
- int32_t width = 0, height = 0;
- aImage->GetWidth(&width);
- aImage->GetHeight(&height);
+ int32_t width = 0;
+ int32_t height = 0;
+ {
+ const bool gotWidth = NS_SUCCEEDED(aImage->GetWidth(&width));
+ const bool gotHeight = NS_SUCCEEDED(aImage->GetHeight(&height));
+ if (auto ratio = aImage->GetIntrinsicRatio()) {
+ if (gotWidth != gotHeight) {
+ if (gotWidth) {
+ height = ratio->Inverted().ApplyTo(width);
+ } else {
+ width = ratio->ApplyTo(height);
+ }
+ } else if (!gotWidth) {
+ height = std::ceil(aPreferredSize.height);
+ width = ratio->ApplyTo(height);
+ }
+ }
+ }
// Render a vector image at the correct resolution on a retina display
if (aImage->GetType() == imgIContainer::TYPE_VECTOR) {
@@ -582,31 +598,28 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(
nsresult nsCocoaUtils::CreateDualRepresentationNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext, const ComputedStyle* aComputedStyle,
- NSImage** aResult, bool* aIsEntirelyBlack) {
- int32_t width = 0, height = 0;
- aImage->GetWidth(&width);
- aImage->GetHeight(&height);
- NSSize size = NSMakeSize(width, height);
- *aResult = [[NSImage alloc] init];
- [*aResult setSize:size];
-
+ const NSSize& aPreferredSize, NSImage** aResult, bool* aIsEntirelyBlack) {
NSImage* newRepresentation = nil;
nsresult rv = CreateNSImageFromImageContainer(
- aImage, aWhichFrame, aPresContext, aComputedStyle, &newRepresentation,
- 1.0f, aIsEntirelyBlack);
+ aImage, aWhichFrame, aPresContext, aComputedStyle, aPreferredSize,
+ &newRepresentation, 1.0f, aIsEntirelyBlack);
if (NS_FAILED(rv) || !newRepresentation) {
return NS_ERROR_FAILURE;
}
+ NSSize size = newRepresentation.size;
+ *aResult = [[NSImage alloc] init];
+ [*aResult setSize:size];
+
[[[newRepresentation representations] objectAtIndex:0] setSize:size];
[*aResult
addRepresentation:[[newRepresentation representations] objectAtIndex:0]];
[newRepresentation release];
newRepresentation = nil;
- rv = CreateNSImageFromImageContainer(aImage, aWhichFrame, aPresContext,
- aComputedStyle, &newRepresentation, 2.0f,
- aIsEntirelyBlack);
+ rv = CreateNSImageFromImageContainer(
+ aImage, aWhichFrame, aPresContext, aComputedStyle, aPreferredSize,
+ &newRepresentation, 2.0f, aIsEntirelyBlack);
if (NS_FAILED(rv) || !newRepresentation) {
return NS_ERROR_FAILURE;
}
@@ -619,43 +632,6 @@ nsresult nsCocoaUtils::CreateDualRepresentationNSImageFromImageContainer(
}
// static
-void nsCocoaUtils::GetStringForNSString(const NSString* aSrc,
- nsAString& aDist) {
- NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
-
- if (!aSrc) {
- aDist.Truncate();
- return;
- }
-
- aDist.SetLength([aSrc length]);
- [aSrc getCharacters:reinterpret_cast<unichar*>(aDist.BeginWriting())
- range:NSMakeRange(0, [aSrc length])];
-
- NS_OBJC_END_TRY_IGNORE_BLOCK;
-}
-
-// static
-NSString* nsCocoaUtils::ToNSString(const nsAString& aString) {
- if (aString.IsEmpty()) {
- return [NSString string];
- }
- return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(
- aString.BeginReading())
- length:aString.Length()];
-}
-
-// static
-NSString* nsCocoaUtils::ToNSString(const nsACString& aCString) {
- if (aCString.IsEmpty()) {
- return [NSString string];
- }
- return [[[NSString alloc] initWithBytes:aCString.BeginReading()
- length:aCString.Length()
- encoding:NSUTF8StringEncoding] autorelease];
-}
-
-// static
NSURL* nsCocoaUtils::ToNSURL(const nsAString& aURLString) {
nsAutoCString encodedURLString;
nsresult rv = NS_GetSpecWithNSURLEncoding(encodedURLString,
diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h
index c2e595677f..621c32eb44 100644
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -492,6 +492,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
bool mWindowTransformIsIdentity;
bool mAlwaysOnTop;
bool mAspectRatioLocked;
+ bool mIsAlert = false; // True if this is an non-native alert window.
int32_t mNumModalDescendents;
InputContext mInputContext;
diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
index e5abaa5a87..4b135e7565 100644
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -187,7 +187,7 @@ void nsCocoaWindow::DestroyNativeWindow() {
[mWindow releaseJSObjects];
// We want to unhook the delegate here because we don't want events
// sent to it after this object has been destroyed.
- [mWindow setDelegate:nil];
+ mWindow.delegate = nil;
[mWindow close];
mWindow = nil;
[mDelegate autorelease];
@@ -260,7 +260,7 @@ DesktopToLayoutDeviceScale ParentBackingScaleFactor(nsIWidget* aParent,
}
NSWindow* parentWindow = [aParentView window];
if (parentWindow) {
- return DesktopToLayoutDeviceScale([parentWindow backingScaleFactor]);
+ return DesktopToLayoutDeviceScale(parentWindow.backingScaleFactor);
}
return DesktopToLayoutDeviceScale(1.0);
}
@@ -322,6 +322,7 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
mParent = aParent;
mAncestorLink = aParent;
mAlwaysOnTop = aInitData->mAlwaysOnTop;
+ mIsAlert = aInitData->mIsAlert;
// If we have a parent widget, the new widget will be offset from the
// parent widget by aRect.{x,y}. Otherwise, we'll use aRect for the
@@ -477,29 +478,31 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect,
contentRect = aRect;
contentRect.origin.y -= (newWindowFrame.size.height - aRect.size.height);
- if (mWindowType != WindowType::Popup)
- contentRect.origin.y -= [[NSApp mainMenu] menuBarHeight];
+ if (mWindowType != WindowType::Popup) {
+ contentRect.origin.y -= NSApp.mainMenu.menuBarHeight;
+ }
}
// NSLog(@"Top-level window being created at Cocoa rect: %f, %f, %f, %f\n",
// rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
Class windowClass = [BaseWindow class];
- // If we have a titlebar on a top-level window, we want to be able to control
- // the titlebar color (for unified windows), so use the special ToolbarWindow
- // class. Note that we need to check the window type because we mark sheets as
- // having titlebars.
if ((mWindowType == WindowType::TopLevel ||
mWindowType == WindowType::Dialog) &&
- (features & NSWindowStyleMaskTitled))
+ (features & NSWindowStyleMaskTitled)) {
+ // If we have a titlebar on a top-level window, we want to be able to
+ // control the titlebar color (for unified windows), so use the special
+ // ToolbarWindow class. Note that we need to check the window type because
+ // we mark sheets as having titlebars.
windowClass = [ToolbarWindow class];
- // If we're a popup window we need to use the PopupWindow class.
- else if (mWindowType == WindowType::Popup)
+ } else if (mWindowType == WindowType::Popup) {
windowClass = [PopupWindow class];
- // If we're a non-popup borderless window we need to use the
- // BorderlessWindow class.
- else if (features == NSWindowStyleMaskBorderless)
+ // If we're a popup window we need to use the PopupWindow class.
+ } else if (features == NSWindowStyleMaskBorderless) {
+ // If we're a non-popup borderless window we need to use the
+ // BorderlessWindow class.
windowClass = [BorderlessWindow class];
+ }
// Create the window
mWindow = [[windowClass alloc] initWithContentRect:contentRect
@@ -509,65 +512,60 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect,
// Make sure that window titles don't leak to disk in private browsing mode
// due to macOS' resume feature.
- [mWindow setRestorable:!aIsPrivateBrowsing];
+ mWindow.restorable = !aIsPrivateBrowsing;
if (aIsPrivateBrowsing) {
[mWindow disableSnapshotRestoration];
}
// setup our notification delegate. Note that setDelegate: does NOT retain.
mDelegate = [[WindowDelegate alloc] initWithGeckoWindow:this];
- [mWindow setDelegate:mDelegate];
+ mWindow.delegate = mDelegate;
// Make sure that the content rect we gave has been honored.
NSRect wantedFrame = [mWindow frameRectForChildViewRect:contentRect];
- if (!NSEqualRects([mWindow frame], wantedFrame)) {
+ if (!NSEqualRects(mWindow.frame, wantedFrame)) {
// This can happen when the window is not on the primary screen.
[mWindow setFrame:wantedFrame display:NO];
}
UpdateBounds();
if (mWindowType == WindowType::Invisible) {
- [mWindow setLevel:kCGDesktopWindowLevelKey];
+ mWindow.level = kCGDesktopWindowLevelKey;
}
if (mWindowType == WindowType::Popup) {
SetPopupWindowLevel();
- [mWindow setBackgroundColor:NSColor.clearColor];
- [mWindow setOpaque:NO];
+ mWindow.backgroundColor = NSColor.clearColor;
+ mWindow.opaque = NO;
// When multiple spaces are in use and the browser is assigned to a
// particular space, override the "Assign To" space and display popups on
// the active space. Does not work with multiple displays. See
// NeedsRecreateToReshow() for multi-display with multi-space workaround.
- if (!mAlwaysOnTop) {
- NSWindowCollectionBehavior behavior = [mWindow collectionBehavior];
- behavior |= NSWindowCollectionBehaviorMoveToActiveSpace;
- [mWindow setCollectionBehavior:behavior];
- }
+ mWindow.collectionBehavior = mWindow.collectionBehavior |
+ NSWindowCollectionBehaviorMoveToActiveSpace;
} else {
// Non-popup windows are always opaque.
- [mWindow setOpaque:YES];
+ mWindow.opaque = YES;
}
- NSWindowCollectionBehavior newBehavior = [mWindow collectionBehavior];
- if (mAlwaysOnTop) {
- [mWindow setLevel:NSFloatingWindowLevel];
- newBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
+ if (mAlwaysOnTop || mIsAlert) {
+ mWindow.level = NSFloatingWindowLevel;
+ mWindow.collectionBehavior =
+ mWindow.collectionBehavior | NSWindowCollectionBehaviorCanJoinAllSpaces;
}
- [mWindow setCollectionBehavior:newBehavior];
-
- [mWindow setContentMinSize:NSMakeSize(60, 60)];
+ mWindow.contentMinSize = NSMakeSize(60, 60);
[mWindow disableCursorRects];
// Make the window use CoreAnimation from the start, so that we don't
// switch from a non-CA window to a CA-window in the middle.
- [[mWindow contentView] setWantsLayer:YES];
+ mWindow.contentView.wantsLayer = YES;
// Make sure the window starts out not draggable by the background.
// We will turn it on as necessary.
- [mWindow setMovableByWindowBackground:NO];
+ mWindow.movableByWindowBackground = NO;
- [[WindowDataMap sharedWindowDataMap] ensureDataForWindow:mWindow];
+ [WindowDataMap.sharedWindowDataMap ensureDataForWindow:mWindow];
mWindowMadeHere = true;
// Make the window respect the global appearance, which follows the
@@ -596,11 +594,11 @@ nsresult nsCocoaWindow::CreatePopupContentView(const LayoutDeviceIntRect& aRect,
return rv;
}
- NSView* contentView = [mWindow contentView];
- ChildView* childView =
- (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
- [childView setFrame:[contentView bounds]];
- [childView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ NSView* contentView = mWindow.contentView;
+ auto* childView = static_cast<ChildView*>(
+ mPopupContentView->GetNativeData(NS_NATIVE_WIDGET));
+ childView.frame = contentView.bounds;
+ childView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[contentView addSubview:childView];
return NS_OK;
@@ -670,7 +668,7 @@ void* nsCocoaWindow::GetNativeData(uint32_t aDataType) {
// to emulate how windows works, we always have to return a NSView
// for NS_NATIVE_WIDGET
case NS_NATIVE_WIDGET:
- retVal = [mWindow contentView];
+ retVal = mWindow.contentView;
break;
case NS_NATIVE_WINDOW:
@@ -687,9 +685,9 @@ void* nsCocoaWindow::GetNativeData(uint32_t aDataType) {
if (retVal) {
break;
}
- NSView* view = mWindow ? [mWindow contentView] : nil;
+ NSView* view = mWindow ? mWindow.contentView : nil;
if (view) {
- retVal = [view inputContext];
+ retVal = view.inputContext;
}
// If inputContext isn't available on this window, return this window's
// pointer instead of nullptr since if this returns nullptr,
@@ -792,10 +790,11 @@ void nsCocoaWindow::SetModal(bool aState) {
gGeckoAppModalWindowList = gGeckoAppModalWindowList->prev;
delete saved; // "window" not ADDREFed
}
- if (mWindowType == WindowType::Popup)
+ if (mWindowType == WindowType::Popup) {
SetPopupWindowLevel();
- else
- [mWindow setLevel:NSNormalWindowLevel];
+ } else {
+ mWindow.level = NSNormalWindowLevel;
+ }
}
}
@@ -810,43 +809,44 @@ void nsCocoaWindow::SetFakeModal(bool aState) {
bool nsCocoaWindow::IsRunningAppModal() { return [NSApp _isRunningAppModal]; }
// Hide or show this window
-void nsCocoaWindow::Show(bool bState) {
+void nsCocoaWindow::Show(bool aState) {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
- if (!mWindow) return;
+ if (!mWindow) {
+ return;
+ }
if (!mSheetNeedsShow) {
// Early exit if our current visibility state is already the requested
// state.
- if (bState == ([mWindow isVisible] || [mWindow isBeingShown])) {
+ if (aState == mWindow.isVisibleOrBeingShown) {
return;
}
}
- [mWindow setBeingShown:bState];
- if (bState && !mWasShown) {
+ [mWindow setBeingShown:aState];
+ if (aState && !mWasShown) {
mWasShown = true;
}
nsIWidget* parentWidget = mParent;
nsCOMPtr<nsPIWidgetCocoa> piParentWidget(do_QueryInterface(parentWidget));
NSWindow* nativeParentWindow =
- (parentWidget) ? (NSWindow*)parentWidget->GetNativeData(NS_NATIVE_WINDOW)
- : nil;
+ parentWidget ? (NSWindow*)parentWidget->GetNativeData(NS_NATIVE_WINDOW)
+ : nil;
- if (bState && !mBounds.IsEmpty()) {
+ if (aState && !mBounds.IsEmpty()) {
// If we had set the activationPolicy to accessory, then right now we won't
// have a dock icon. Make sure that we undo that and show a dock icon now
// that we're going to show a window.
- if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) {
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+ if (NSApp.activationPolicy != NSApplicationActivationPolicyRegular) {
+ NSApp.activationPolicy = NSApplicationActivationPolicyRegular;
PR_SetEnv("MOZ_APP_NO_DOCK=");
}
// Don't try to show a popup when the parent isn't visible or is minimized.
if (mWindowType == WindowType::Popup && nativeParentWindow) {
- if (![nativeParentWindow isVisible] ||
- [nativeParentWindow isMiniaturized]) {
+ if (!nativeParentWindow.isVisible || nativeParentWindow.isMiniaturized) {
return;
}
}
@@ -947,7 +947,7 @@ void nsCocoaWindow::Show(bool bState) {
// close other programs' context menus when ours open.
if ([mWindow isKindOfClass:[PopupWindow class]] &&
[(PopupWindow*)mWindow isContextMenu]) {
- [[NSDistributedNotificationCenter defaultCenter]
+ [NSDistributedNotificationCenter.defaultCenter
postNotificationName:
@"com.apple.HIToolbox.beginMenuTrackingNotification"
object:@"org.mozilla.gecko.PopupWindow"];
@@ -958,8 +958,9 @@ void nsCocoaWindow::Show(bool bState) {
// appear above the parent and move when the parent does. Setting this
// needs to happen after the _setWindowNumber calls above, otherwise the
// window doesn't focus properly.
- if (nativeParentWindow && mPopupLevel == PopupLevel::Parent)
+ if (nativeParentWindow && mPopupLevel == PopupLevel::Parent) {
[nativeParentWindow addChildWindow:mWindow ordered:NSWindowAbove];
+ }
} else {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
if (mWindowType == WindowType::TopLevel &&
@@ -983,9 +984,9 @@ void nsCocoaWindow::Show(bool bState) {
mWindowAnimationBehavior = behavior;
}
- // We don't want alwaysontop windows to pull focus when they're opened,
- // as these tend to be for peripheral indicators and displays.
- if (mAlwaysOnTop) {
+ // We don't want alwaysontop / alert windows to pull focus when they're
+ // opened, as these tend to be for peripheral indicators and displays.
+ if (mAlwaysOnTop || mIsAlert) {
[mWindow orderFront:nil];
} else {
[mWindow makeKeyAndOrderFront:nil];
@@ -1099,8 +1100,9 @@ void nsCocoaWindow::Show(bool bState) {
// 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)
+ if (mWindowType == WindowType::Popup && nativeParentWindow) {
[nativeParentWindow removeChildWindow:mWindow];
+ }
[mWindow orderOut:nil];
@@ -1129,8 +1131,8 @@ void nsCocoaWindow::Show(bool bState) {
bool nsCocoaWindow::NeedsRecreateToReshow() {
// Limit the workaround to popup windows because only they need to override
// the "Assign To" setting. i.e., to display where the parent window is.
- return (mWindowType == WindowType::Popup) && mWasShown &&
- ([[NSScreen screens] count] > 1);
+ return mWindowType == WindowType::Popup && mWasShown &&
+ NSScreen.screens.count > 1;
}
WindowRenderer* nsCocoaWindow::GetWindowRenderer() {
@@ -1143,8 +1145,8 @@ WindowRenderer* nsCocoaWindow::GetWindowRenderer() {
TransparencyMode nsCocoaWindow::GetTransparencyMode() {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
- return (!mWindow || [mWindow isOpaque]) ? TransparencyMode::Opaque
- : TransparencyMode::Transparent;
+ return !mWindow || mWindow.isOpaque ? TransparencyMode::Opaque
+ : TransparencyMode::Transparent;
NS_OBJC_END_TRY_BLOCK_RETURN(TransparencyMode::Opaque);
}
@@ -1162,9 +1164,9 @@ void nsCocoaWindow::SetTransparencyMode(TransparencyMode aMode) {
if (isTransparent == currentTransparency) {
return;
}
- [mWindow setOpaque:!isTransparent];
- [mWindow setBackgroundColor:(isTransparent ? NSColor.clearColor
- : NSColor.whiteColor)];
+ mWindow.opaque = !isTransparent;
+ mWindow.backgroundColor =
+ isTransparent ? NSColor.clearColor : NSColor.whiteColor;
NS_OBJC_END_TRY_IGNORE_BLOCK;
}
@@ -1184,7 +1186,7 @@ void nsCocoaWindow::ConstrainPosition(DesktopIntPoint& aPoint) {
int32_t width, height;
- NSRect frame = [mWindow frame];
+ NSRect frame = mWindow.frame;
// zero size rects confuse the screen manager
width = std::max<int32_t>(frame.size.width, 1);
@@ -1243,7 +1245,7 @@ void nsCocoaWindow::SetSizeConstraints(const SizeConstraints& aConstraints) {
NSSize minSize = {
nsCocoaUtils::DevPixelsToCocoaPoints(c.mMinSize.width, c.mScale.scale),
nsCocoaUtils::DevPixelsToCocoaPoints(c.mMinSize.height, c.mScale.scale)};
- [mWindow setMinSize:minSize];
+ mWindow.minSize = minSize;
c.mMaxSize.width = std::max(
nsCocoaUtils::CocoaPointsToDevPixels(c.mMaxSize.width, c.mScale.scale),
@@ -1259,8 +1261,7 @@ void nsCocoaWindow::SetSizeConstraints(const SizeConstraints& aConstraints) {
c.mMaxSize.height == NS_MAXSIZE ? FLT_MAX
: nsCocoaUtils::DevPixelsToCocoaPoints(
c.mMaxSize.height, c.mScale.scale)};
- [mWindow setMaxSize:maxSize];
-
+ mWindow.maxSize = maxSize;
nsBaseWidget::SetSizeConstraints(c);
NS_OBJC_END_TRY_IGNORE_BLOCK;
@@ -1280,7 +1281,7 @@ void nsCocoaWindow::Move(double aX, double aY) {
static_cast<float>(aX),
static_cast<float>(nsCocoaUtils::FlippedScreenY(NSToIntRound(aY)))};
- NSRect frame = [mWindow frame];
+ NSRect frame = mWindow.frame;
if (frame.origin.x != coord.x ||
frame.origin.y + frame.size.height != coord.y) {
[mWindow setFrameTopLeftPoint:coord];
@@ -1488,13 +1489,9 @@ void nsCocoaWindow::MoveToWorkspace(const nsAString& workspaceIDStr) {
void nsCocoaWindow::SuppressAnimation(bool aSuppress) {
if ([mWindow respondsToSelector:@selector(setAnimationBehavior:)]) {
- if (aSuppress) {
- [mWindow setIsAnimationSuppressed:YES];
- [mWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];
- } else {
- [mWindow setIsAnimationSuppressed:NO];
- [mWindow setAnimationBehavior:mWindowAnimationBehavior];
- }
+ mWindow.isAnimationSuppressed = aSuppress;
+ mWindow.animationBehavior =
+ aSuppress ? NSWindowAnimationBehaviorNone : mWindowAnimationBehavior;
}
}
@@ -1506,10 +1503,11 @@ void nsCocoaWindow::HideWindowChrome(bool aShouldHide) {
if (!mWindow || !mWindowMadeHere ||
(mWindowType != WindowType::TopLevel &&
- mWindowType != WindowType::Dialog))
+ mWindowType != WindowType::Dialog)) {
return;
+ }
- BOOL isVisible = [mWindow isVisible];
+ const BOOL isVisible = mWindow.isVisible;
// Remove child windows.
NSArray* childWindows = [mWindow childWindows];
@@ -1530,7 +1528,7 @@ void nsCocoaWindow::HideWindowChrome(bool aShouldHide) {
NSMutableDictionary* state = [mWindow exportState];
// Recreate the window with the right border style.
- NSRect frameRect = [mWindow frame];
+ NSRect frameRect = mWindow.frame;
DestroyNativeWindow();
nsresult rv = CreateNativeWindow(
frameRect, aShouldHide ? BorderStyle::None : mBorderStyle, true,
@@ -1629,7 +1627,7 @@ static bool AlwaysUsesNativeFullScreen() {
NSScreen* cocoaScreen = ScreenHelperCocoa::CocoaScreenForScreen(widgetScreen);
NSWindow* win =
- [[NSWindow alloc] initWithContentRect:[cocoaScreen frame]
+ [[NSWindow alloc] initWithContentRect:cocoaScreen.frame
styleMask:NSWindowStyleMaskBorderless
backing:NSBackingStoreBuffered
defer:YES];
@@ -2075,7 +2073,7 @@ void nsCocoaWindow::DoResize(double aX, double aY, double aWidth,
// convert requested bounds into Cocoa coordinate system
NSRect newFrame = nsCocoaUtils::GeckoRectToCocoaRect(newBounds);
- NSRect frame = [mWindow frame];
+ NSRect frame = mWindow.frame;
BOOL isMoving = newFrame.origin.x != frame.origin.x ||
newFrame.origin.y != frame.origin.y;
BOOL isResizing = newFrame.size.width != frame.size.width ||
@@ -2114,7 +2112,7 @@ NSRect nsCocoaWindow::GetClientCocoaRect() {
return NSZeroRect;
}
- return [mWindow childViewRectForFrameRect:[mWindow frame]];
+ return [mWindow childViewRectForFrameRect:mWindow.frame];
}
LayoutDeviceIntRect nsCocoaWindow::GetClientBounds() {
@@ -2130,7 +2128,7 @@ LayoutDeviceIntRect nsCocoaWindow::GetClientBounds() {
void nsCocoaWindow::UpdateBounds() {
NSRect frame = NSZeroRect;
if (mWindow) {
- frame = [mWindow frame];
+ frame = mWindow.frame;
}
mBounds =
nsCocoaUtils::CocoaRectToGeckoRectDevPix(frame, BackingScaleFactor());
@@ -2145,7 +2143,7 @@ LayoutDeviceIntRect nsCocoaWindow::GetScreenBounds() {
#ifdef DEBUG
LayoutDeviceIntRect r = nsCocoaUtils::CocoaRectToGeckoRectDevPix(
- [mWindow frame], BackingScaleFactor());
+ mWindow.frame, BackingScaleFactor());
NS_ASSERTION(mWindow && mBounds == r, "mBounds out of sync!");
#endif
@@ -2157,7 +2155,7 @@ LayoutDeviceIntRect nsCocoaWindow::GetScreenBounds() {
double nsCocoaWindow::GetDefaultScaleInternal() { return BackingScaleFactor(); }
static CGFloat GetBackingScaleFactor(NSWindow* aWindow) {
- NSRect frame = [aWindow frame];
+ NSRect frame = aWindow.frame;
if (frame.size.width > 0 && frame.size.height > 0) {
return nsCocoaUtils::GetBackingScaleFactor(aWindow);
}
@@ -2220,6 +2218,7 @@ void nsCocoaWindow::BackingScaleFactorChanged() {
}
mBackingScaleFactor = newScale;
+ NotifyAPZOfDPIChange();
if (!mWidgetListener || mWidgetListener->GetAppWindow()) {
return;
@@ -2255,7 +2254,7 @@ nsresult nsCocoaWindow::SetTitle(const nsAString& aTitle) {
const unichar* uniTitle = reinterpret_cast<const unichar*>(strTitle.get());
NSString* title = [NSString stringWithCharacters:uniTitle
length:strTitle.Length()];
- if ([mWindow drawsContentsIntoWindowFrame] && ![mWindow wantsTitleDrawn]) {
+ if (mWindow.drawsContentsIntoWindowFrame && !mWindow.wantsTitleDrawn) {
// Don't cause invalidations when the title isn't displayed.
[mWindow disableSetNeedsDisplay];
[mWindow setTitle:title];
@@ -2291,9 +2290,10 @@ bool nsCocoaWindow::DragEvent(unsigned int aMessage,
NS_IMETHODIMP nsCocoaWindow::SendSetZLevelEvent() {
nsWindowZ placement = nsWindowZTop;
nsCOMPtr<nsIWidget> actualBelow;
- if (mWidgetListener)
+ if (mWidgetListener) {
mWidgetListener->ZLevelChanged(true, &placement, nullptr,
getter_AddRefs(actualBelow));
+ }
return NS_OK;
}
@@ -2344,8 +2344,9 @@ nsresult nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event,
nsCOMPtr<nsIWidget> kungFuDeathGrip(event->mWidget);
mozilla::Unused << kungFuDeathGrip; // Not used within this function
- if (mWidgetListener)
+ if (mWidgetListener) {
aStatus = mWidgetListener->HandleEvent(event, mUseAttachedEvents);
+ }
return NS_OK;
}
@@ -2355,10 +2356,15 @@ nsresult nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event,
// canonical indicator that a window is currently full screen and it makes sense
// to keep all sizemode logic here.
static nsSizeMode GetWindowSizeMode(NSWindow* aWindow, bool aFullScreen) {
- if (aFullScreen) return nsSizeMode_Fullscreen;
- if ([aWindow isMiniaturized]) return nsSizeMode_Minimized;
- if (([aWindow styleMask] & NSWindowStyleMaskResizable) && [aWindow isZoomed])
+ if (aFullScreen) {
+ return nsSizeMode_Fullscreen;
+ }
+ if (aWindow.isMiniaturized) {
+ return nsSizeMode_Minimized;
+ }
+ if ((aWindow.styleMask & NSWindowStyleMaskResizable) && aWindow.isZoomed) {
return nsSizeMode_Maximized;
+ }
return nsSizeMode_Normal;
}
@@ -2379,7 +2385,7 @@ void nsCocoaWindow::ReportMoveEvent() {
// The zoomed state can change when we're moving, in which case we need to
// update our internal mSizeMode. This can happen either if we're maximized
// and then moved, or if we're not maximized and moved back to zoomed state.
- if (mWindow && ((mSizeMode == nsSizeMode_Maximized) ^ [mWindow isZoomed])) {
+ if (mWindow && (mSizeMode == nsSizeMode_Maximized) ^ mWindow.isZoomed) {
DispatchSizeModeEvent();
}
@@ -2462,8 +2468,9 @@ void nsCocoaWindow::SetMenuBar(RefPtr<nsMenuBarX>&& aMenuBar) {
// displayed when the app starts up.
if (mMenuBar && ((!gSomeMenuBarPainted &&
nsMenuUtilsX::GetHiddenWindowMenuBar() == mMenuBar) ||
- [mWindow isMainWindow]))
+ mWindow.isMainWindow)) {
mMenuBar->Paint();
+ }
}
void nsCocoaWindow::SetFocus(Raise aRaise,
@@ -2474,12 +2481,10 @@ void nsCocoaWindow::SetFocus(Raise aRaise,
return mPopupContentView->SetFocus(aRaise, aCallerType);
}
- if (aRaise == Raise::Yes &&
- ([mWindow isVisible] || [mWindow isMiniaturized])) {
- if ([mWindow isMiniaturized]) {
+ if (aRaise == Raise::Yes && (mWindow.isVisible || mWindow.isMiniaturized)) {
+ if (mWindow.isMiniaturized) {
[mWindow deminiaturize:nil];
}
-
[mWindow makeKeyAndOrderFront:nil];
SendSetZLevelEvent();
}
@@ -2533,7 +2538,7 @@ void nsCocoaWindow::CaptureRollupEvents(bool aDoCapture) {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
if (aDoCapture) {
- if (![NSApp isActive]) {
+ if (!NSApp.isActive) {
// We need to capture mouse event if we aren't
// the active application. We only set this up when needed
// because they cause spurious mouse event after crash
@@ -2553,14 +2558,17 @@ void nsCocoaWindow::CaptureRollupEvents(bool aDoCapture) {
// So here we fiddle with a non-native popup window's level to make sure the
// "active" one is always above any other non-native popup windows that
// may be visible.
- if (mWindow && (mWindowType == WindowType::Popup)) SetPopupWindowLevel();
+ if (mWindowType == WindowType::Popup) {
+ SetPopupWindowLevel();
+ }
} else {
nsToolkit::GetToolkit()->StopMonitoringAllProcessMouseEvents();
// XXXndeakin this doesn't make sense.
// Why is the new window assumed to be a modal panel?
- if (mWindow && (mWindowType == WindowType::Popup))
- [mWindow setLevel:NSModalPanelWindowLevel];
+ if (mWindow && mWindowType == WindowType::Popup) {
+ mWindow.level = NSModalPanelWindowLevel;
+ }
}
NS_OBJC_END_TRY_IGNORE_BLOCK;
@@ -2644,7 +2652,7 @@ void nsCocoaWindow::SetWindowTransform(const gfx::Matrix& aTransform) {
// Calling CGSSetWindowTransform when the window is not visible results in
// misplacing the window into doubled x,y coordinates (see bug 1448132).
- if (![mWindow isVisible] || NSIsEmptyRect([mWindow frame])) {
+ if (!mWindow.isVisible || NSIsEmptyRect(mWindow.frame)) {
return;
}
@@ -2753,13 +2761,9 @@ void nsCocoaWindow::SetWindowAnimationType(
void nsCocoaWindow::SetDrawsTitle(bool aDrawTitle) {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
- if (![mWindow drawsContentsIntoWindowFrame]) {
- // If we don't draw into the window frame, we always want to display window
- // titles.
- [mWindow setWantsTitleDrawn:YES];
- } else {
- [mWindow setWantsTitleDrawn:aDrawTitle];
- }
+ // If we don't draw into the window frame, we always want to display window
+ // titles.
+ mWindow.wantsTitleDrawn = aDrawTitle || !mWindow.drawsContentsIntoWindowFrame;
NS_OBJC_END_TRY_IGNORE_BLOCK;
}
@@ -2853,19 +2857,13 @@ void nsCocoaWindow::UpdateThemeGeometries(
}
void nsCocoaWindow::SetPopupWindowLevel() {
- if (!mWindow) return;
-
- // Floating popups are at the floating level and hide when the window is
- // deactivated.
- if (mPopupLevel == PopupLevel::Floating) {
- [mWindow setLevel:NSFloatingWindowLevel];
- [mWindow setHidesOnDeactivate:YES];
- } else {
- // Otherwise, this is a top-level or parent popup. Parent popups always
- // appear just above their parent and essentially ignore the level.
- [mWindow setLevel:NSPopUpMenuWindowLevel];
- [mWindow setHidesOnDeactivate:NO];
+ if (!mWindow) {
+ return;
}
+ // Otherwise, this is a top-level or parent popup. Parent popups always
+ // appear just above their parent and essentially ignore the level.
+ mWindow.level = NSPopUpMenuWindowLevel;
+ mWindow.hidesOnDeactivate = NO;
}
void nsCocoaWindow::SetInputContext(const InputContext& aContext,
@@ -2897,7 +2895,7 @@ bool nsCocoaWindow::GetEditCommands(NativeKeyBindingsType aType,
void nsCocoaWindow::PauseOrResumeCompositor(bool aPause) {
if (auto* mainChildView =
- static_cast<nsIWidget*>([[mWindow mainChildView] widget])) {
+ static_cast<nsIWidget*>(mWindow.mainChildView.widget)) {
mainChildView->PauseOrResumeCompositor(aPause);
}
}
@@ -2951,16 +2949,17 @@ already_AddRefed<nsIWidget> nsIWidget::CreateChildWindow() {
nsCocoaWindow* geckoWidget = [windowDelegate geckoWidget];
NS_ASSERTION(geckoWidget, "Window delegate not returning a gecko widget!");
- nsMenuBarX* geckoMenuBar = geckoWidget->GetMenuBar();
- if (geckoMenuBar) {
+ if (nsMenuBarX* geckoMenuBar = geckoWidget->GetMenuBar()) {
geckoMenuBar->Paint();
} else {
// sometimes we don't have a native application menu early in launching
- if (!sApplicationMenu) return;
+ if (!sApplicationMenu) {
+ return;
+ }
- NSMenu* mainMenu = [NSApp mainMenu];
+ NSMenu* mainMenu = NSApp.mainMenu;
NS_ASSERTION(
- [mainMenu numberOfItems] > 0,
+ mainMenu.numberOfItems > 0,
"Main menu does not have any items, something is terribly wrong!");
// Create a new menu bar.
@@ -2976,7 +2975,7 @@ already_AddRefed<nsIWidget> nsIWidget::CreateChildWindow() {
[firstMenuItem release];
// set our new menu bar as the main menu
- [NSApp setMainMenu:newMenuBar];
+ NSApp.mainMenu = newMenuBar;
[newMenuBar release];
}
@@ -3097,8 +3096,8 @@ void nsCocoaWindow::CocoaWindowDidResize() {
// in fullscreen mode. In Safari they're not transparent. But in Firefox
// for some reason they are, which causes bug 1069658. The following code
// works around this Apple bug or design flaw.
- NSWindow* window = (NSWindow*)[notification object];
- NSView* frameView = [[window contentView] superview];
+ NSWindow* window = notification.object;
+ NSView* frameView = window.contentView.superview;
NSView* titlebarView = nil;
NSView* titlebarContainerView = nil;
if ([frameView respondsToSelector:@selector(titlebarView)]) {
@@ -3142,9 +3141,13 @@ void nsCocoaWindow::CocoaWindowDidResize() {
// [NSApp _isRunningAppModal] will return true if we're running an OS dialog
// app modally. If one of those is up then we want it to retain its menu bar.
- if ([NSApp _isRunningAppModal]) return;
- NSWindow* window = [aNotification object];
- if (window) [WindowDelegate paintMenubarForWindow:window];
+ if (NSApp._isRunningAppModal) {
+ return;
+ }
+ NSWindow* window = aNotification.object;
+ if (window) {
+ [WindowDelegate paintMenubarForWindow:window];
+ }
if ([window isKindOfClass:[ToolbarWindow class]]) {
[(ToolbarWindow*)window windowMainStateChanged];
@@ -3254,8 +3257,9 @@ void nsCocoaWindow::CocoaWindowDidResize() {
}
- (BOOL)windowShouldZoom:(NSWindow*)window toFrame:(NSRect)proposedFrame {
- if (!mHasEverBeenZoomed && [window isZoomed]) return NO; // See bug 429954.
-
+ if (!mHasEverBeenZoomed && window.isZoomed) {
+ return NO; // See bug 429954.
+ }
mHasEverBeenZoomed = YES;
return YES;
}
@@ -3298,7 +3302,7 @@ void nsCocoaWindow::CocoaWindowDidResize() {
if ([window respondsToSelector:@selector(backingScaleFactor)]) {
CGFloat oldFactor = [[[aNotification userInfo]
objectForKey:@"NSBackingPropertyOldScaleFactorKey"] doubleValue];
- if ([window backingScaleFactor] != oldFactor) {
+ if (window.backingScaleFactor != oldFactor) {
mGeckoWindow->BackingScaleFactorChanged();
}
}
@@ -3349,7 +3353,7 @@ void nsCocoaWindow::CocoaWindowDidResize() {
if (![self.window isKindOfClass:[ToolbarWindow class]]) {
return self.FrameView__closeButtonOrigin;
}
- ToolbarWindow* win = (ToolbarWindow*)[self window];
+ auto* win = static_cast<ToolbarWindow*>(self.window);
if (win.drawsContentsIntoWindowFrame &&
!(win.styleMask & NSWindowStyleMaskFullScreen) &&
(win.styleMask & NSWindowStyleMaskTitled)) {
@@ -3360,8 +3364,9 @@ void nsCocoaWindow::CocoaWindowDidResize() {
// for the vertical coordinate will move the buttons above the window,
// making them invisible.
return NSMakePoint(buttonsRect.origin.x, win.frame.size.height);
- } else if (win.windowTitlebarLayoutDirection ==
- NSUserInterfaceLayoutDirectionRightToLeft) {
+ }
+ if (win.windowTitlebarLayoutDirection ==
+ NSUserInterfaceLayoutDirectionRightToLeft) {
// We're in RTL mode, which means that the close button is the rightmost
// button of the three window buttons. and buttonsRect.origin is the
// bottom left corner of the green (zoom) button. The close button is 40px
@@ -3375,13 +3380,14 @@ void nsCocoaWindow::CocoaWindowDidResize() {
}
- (CGFloat)FrameView__titlebarHeight {
+ // XXX: Shouldn't this be [super FrameView__titlebarHeight]?
CGFloat height = [self FrameView__titlebarHeight];
- if ([[self window] isKindOfClass:[ToolbarWindow class]]) {
+ if ([self.window isKindOfClass:[ToolbarWindow class]]) {
// Make sure that the titlebar height includes our shifted buttons.
// The following coordinates are in window space, with the origin being at
// the bottom left corner of the window.
- ToolbarWindow* win = (ToolbarWindow*)[self window];
- CGFloat frameHeight = [self frame].size.height;
+ auto* win = static_cast<ToolbarWindow*>(self.window);
+ CGFloat frameHeight = self.frame.size.height;
CGFloat windowButtonY = frameHeight;
if (!NSIsEmptyRect(win.windowButtonsRect) &&
win.drawsContentsIntoWindowFrame &&
@@ -3506,8 +3512,8 @@ static NSImage* GetMenuMaskImage() {
}
- (void)swapOutChildViewWrapper:(NSView*)aNewWrapper {
- [aNewWrapper setFrame:[[self contentView] frame]];
- NSView* childView = [[self mainChildView] retain];
+ aNewWrapper.frame = self.contentView.frame;
+ NSView* childView = [self.mainChildView retain];
[childView removeFromSuperview];
[aNewWrapper addSubview:childView];
[childView release];
@@ -3603,16 +3609,16 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
- (NSMutableDictionary*)exportState {
NSMutableDictionary* state = [NSMutableDictionary dictionaryWithCapacity:10];
- if (NSString* title = [self title]) {
+ if (NSString* title = self.title) {
[state setObject:title forKey:kStateTitleKey];
}
- [state setObject:[NSNumber numberWithBool:[self drawsContentsIntoWindowFrame]]
+ [state setObject:[NSNumber numberWithBool:self.drawsContentsIntoWindowFrame]
forKey:kStateDrawsContentsIntoWindowFrameKey];
- [state setObject:[NSNumber numberWithBool:[self showsToolbarButton]]
+ [state setObject:[NSNumber numberWithBool:self.showsToolbarButton]
forKey:kStateShowsToolbarButton];
- [state setObject:[NSNumber numberWithUnsignedInt:[self collectionBehavior]]
+ [state setObject:[NSNumber numberWithUnsignedInt:self.collectionBehavior]
forKey:kStateCollectionBehavior];
- [state setObject:[NSNumber numberWithBool:[self wantsTitleDrawn]]
+ [state setObject:[NSNumber numberWithBool:self.wantsTitleDrawn]
forKey:kStateWantsTitleDrawn];
return state;
}
@@ -3667,17 +3673,17 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
}
- (NSView*)trackingAreaView {
- NSView* contentView = [self contentView];
- return [contentView superview] ? [contentView superview] : contentView;
+ NSView* contentView = self.contentView;
+ return contentView.superview ? contentView.superview : contentView;
}
- (NSArray<NSView*>*)contentViewContents {
- return [[[[self contentView] subviews] copy] autorelease];
+ return [[self.contentView.subviews copy] autorelease];
}
- (ChildView*)mainChildView {
- NSView* contentView = [self contentView];
- NSView* lastView = [[contentView subviews] lastObject];
+ NSView* contentView = self.contentView;
+ NSView* lastView = contentView.subviews.lastObject;
if ([lastView isKindOfClass:[ChildView class]]) {
return (ChildView*)lastView;
}
@@ -3686,7 +3692,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
- (void)removeTrackingArea {
if (mTrackingArea) {
- [[self trackingAreaView] removeTrackingArea:mTrackingArea];
+ [self.trackingAreaView removeTrackingArea:mTrackingArea];
[mTrackingArea release];
mTrackingArea = nil;
}
@@ -3695,7 +3701,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
- (void)updateTrackingArea {
[self removeTrackingArea];
- NSView* view = [self trackingAreaView];
+ NSView* view = self.trackingAreaView;
const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved |
NSTrackingActiveAlways;
@@ -3741,7 +3747,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
// Possibly move the titlebar buttons.
- (void)reflowTitlebarElements {
- NSView* frameView = [[self contentView] superview];
+ NSView* frameView = self.contentView.superview;
if ([frameView respondsToSelector:@selector(_tileTitlebarAndRedisplay:)]) {
[frameView _tileTitlebarAndRedisplay:NO];
}
@@ -3852,15 +3858,15 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
}
- (void)mouseUp:(NSEvent*)event {
- if ([event clickCount] == 2) {
+ if (event.clickCount == 2) {
// Handle titlebar double click. We don't get the window's default behavior
// here because the window uses NSWindowStyleMaskFullSizeContentView, and
// this view (the titlebar gradient view) is technically part of the window
// "contents" (it's a subview of the content view).
if (nsCocoaUtils::ShouldZoomOnTitlebarDoubleClick()) {
- [[self window] performZoom:nil];
+ [self.window performZoom:nil];
} else if (nsCocoaUtils::ShouldMinimizeOnTitlebarDoubleClick()) {
- [[self window] performMiniaturize:nil];
+ [self.window performMiniaturize:nil];
}
}
}
@@ -4094,8 +4100,7 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
}
- (NSArray<NSView*>*)contentViewContents {
- NSMutableArray<NSView*>* contents =
- [[[self contentView] subviews] mutableCopy];
+ NSMutableArray<NSView*>* contents = [[self.contentView subviews] mutableCopy];
if (mTitlebarView) {
// Do not include the titlebar gradient view in the returned array.
[contents removeObject:mTitlebarView];
@@ -4105,16 +4110,16 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
- (void)updateTitlebarView {
BOOL needTitlebarView =
- ![self drawsContentsIntoWindowFrame] || mUnifiedToolbarHeight > 0;
+ !self.drawsContentsIntoWindowFrame || mUnifiedToolbarHeight > 0;
if (needTitlebarView && !mTitlebarView) {
mTitlebarView =
- [[MOZTitlebarView alloc] initWithFrame:[self unifiedToolbarRect]];
+ [[MOZTitlebarView alloc] initWithFrame:self.unifiedToolbarRect];
mTitlebarView.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
[self.contentView addSubview:mTitlebarView
positioned:NSWindowBelow
relativeTo:nil];
} else if (needTitlebarView && mTitlebarView) {
- mTitlebarView.frame = [self unifiedToolbarRect];
+ mTitlebarView.frame = self.unifiedToolbarRect;
} else if (!needTitlebarView && mTitlebarView) {
[mTitlebarView removeFromSuperview];
[mTitlebarView release];
@@ -4132,15 +4137,15 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
}
- (NSRect)titlebarRect {
- CGFloat titlebarHeight = [self titlebarHeight];
- return NSMakeRect(0, [self frame].size.height - titlebarHeight,
- [self frame].size.width, titlebarHeight);
+ CGFloat titlebarHeight = self.titlebarHeight;
+ return NSMakeRect(0, self.frame.size.height - titlebarHeight,
+ self.frame.size.width, titlebarHeight);
}
// In window contentView coordinates (origin bottom left)
- (NSRect)unifiedToolbarRect {
- return NSMakeRect(0, [self frame].size.height - mUnifiedToolbarHeight,
- [self frame].size.width, mUnifiedToolbarHeight);
+ return NSMakeRect(0, self.frame.size.height - mUnifiedToolbarHeight,
+ self.frame.size.width, mUnifiedToolbarHeight);
}
// Returns the unified height of titlebar + toolbar.
@@ -4152,8 +4157,8 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
// We use the original content rect here, not what we return from
// [self contentRectForFrameRect:], because that would give us a
// titlebarHeight of zero.
- NSRect frameRect = [self frame];
- NSUInteger styleMask = [self styleMask];
+ NSRect frameRect = self.frame;
+ NSUInteger styleMask = self.styleMask;
styleMask &= ~NSWindowStyleMaskFullSizeContentView;
NSRect originalContentRect = [NSWindow contentRectForFrameRect:frameRect
styleMask:styleMask];
@@ -4172,16 +4177,15 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
// Extending the content area into the title bar works by resizing the
// mainChildView so that it covers the titlebar.
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState {
- BOOL stateChanged = ([self drawsContentsIntoWindowFrame] != aState);
+ BOOL stateChanged = self.drawsContentsIntoWindowFrame != aState;
[super setDrawsContentsIntoWindowFrame:aState];
- if (stateChanged && [[self delegate] isKindOfClass:[WindowDelegate class]]) {
+ if (stateChanged && [self.delegate isKindOfClass:[WindowDelegate class]]) {
// Here we extend / shrink our mainChildView. We do that by firing a resize
// event which will cause the ChildView to be resized to the rect returned
// by nsCocoaWindow::GetClientBounds. GetClientBounds bases its return
// value on what we return from drawsContentsIntoWindowFrame.
- WindowDelegate* windowDelegate = (WindowDelegate*)[self delegate];
- nsCocoaWindow* geckoWindow = [windowDelegate geckoWidget];
- if (geckoWindow) {
+ auto* windowDelegate = static_cast<WindowDelegate*>(self.delegate);
+ if (nsCocoaWindow* geckoWindow = windowDelegate.geckoWidget) {
// Re-layout our contents.
geckoWindow->ReportSizeEvent();
}
@@ -4233,13 +4237,16 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
RollUpPopups();
- if ([[self delegate] isKindOfClass:[WindowDelegate class]]) {
- WindowDelegate* windowDelegate = (WindowDelegate*)[self delegate];
- nsCocoaWindow* geckoWindow = [windowDelegate geckoWidget];
- if (!geckoWindow) return;
+ if ([self.delegate isKindOfClass:[WindowDelegate class]]) {
+ auto* windowDelegate = static_cast<WindowDelegate*>(self.delegate);
+ nsCocoaWindow* geckoWindow = windowDelegate.geckoWidget;
+ if (!geckoWindow) {
+ return;
+ }
- nsIWidgetListener* listener = geckoWindow->GetWidgetListener();
- if (listener) listener->OSToolbarButtonPressed();
+ if (nsIWidgetListener* listener = geckoWindow->GetWidgetListener()) {
+ listener->OSToolbarButtonPressed();
+ }
}
NS_OBJC_END_TRY_IGNORE_BLOCK;
@@ -4278,14 +4285,17 @@ static bool ShouldShiftByMenubarHeightInFullscreen(nsCocoaWindow* aWindow) {
// Drop all mouse events if a modal window has appeared above us.
// This helps make us behave as if the OS were running a "real" modal
// event loop.
- id delegate = [self delegate];
+ id delegate = self.delegate;
if (delegate && [delegate isKindOfClass:[WindowDelegate class]]) {
nsCocoaWindow* widget = [(WindowDelegate*)delegate geckoWidget];
if (widget) {
if (gGeckoAppModalWindowList &&
- (widget != gGeckoAppModalWindowList->window))
+ widget != gGeckoAppModalWindowList->window) {
+ return;
+ }
+ if (widget->HasModalDescendents()) {
return;
- if (widget->HasModalDescendents()) return;
+ }
}
}
break;
@@ -4410,14 +4420,17 @@ static const NSUInteger kWindowShadowOptionsTooltip = 4;
// Drop all mouse events if a modal window has appeared above us.
// This helps make us behave as if the OS were running a "real" modal
// event loop.
- id delegate = [self delegate];
+ id delegate = self.delegate;
if (delegate && [delegate isKindOfClass:[WindowDelegate class]]) {
nsCocoaWindow* widget = [(WindowDelegate*)delegate geckoWidget];
if (widget) {
if (gGeckoAppModalWindowList &&
- (widget != gGeckoAppModalWindowList->window))
+ widget != gGeckoAppModalWindowList->window) {
return;
- if (widget->HasModalDescendents()) return;
+ }
+ if (widget->HasModalDescendents()) {
+ return;
+ }
}
}
break;
@@ -4436,8 +4449,7 @@ static const NSUInteger kWindowShadowOptionsTooltip = 4;
- (BOOL)canBecomeMainWindow {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
- if (![self isVisible]) return NO;
- return YES;
+ return self.isVisible;
NS_OBJC_END_TRY_BLOCK_RETURN(NO);
}
diff --git a/widget/cocoa/nsCursorManager.mm b/widget/cocoa/nsCursorManager.mm
index 2db20681ad..11a37f59b7 100644
--- a/widget/cocoa/nsCursorManager.mm
+++ b/widget/cocoa/nsCursorManager.mm
@@ -304,19 +304,17 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
return NS_ERROR_FAILURE;
}
+ const NSSize cocoaSize = NSMakeSize(size.width, size.height);
NSImage* cursorImage;
nsresult rv = nsCocoaUtils::CreateNSImageFromImageContainer(
aCursor.mContainer, imgIContainer::FRAME_FIRST, nullptr, nullptr,
- &cursorImage, scaleFactor);
+ cocoaSize, &cursorImage, scaleFactor);
if (NS_FAILED(rv) || !cursorImage) {
return NS_ERROR_FAILURE;
}
- {
- NSSize cocoaSize = NSMakeSize(size.width, size.height);
- [cursorImage setSize:cocoaSize];
- [[[cursorImage representations] objectAtIndex:0] setSize:cocoaSize];
- }
+ [cursorImage setSize:cocoaSize];
+ [[[cursorImage representations] objectAtIndex:0] setSize:cocoaSize];
// if the hotspot is nonsensical, make it 0,0
uint32_t hotspotX =
diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm
index 73fd6b689c..5675198ff2 100644
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -366,9 +366,6 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
case IntID::SubmenuDelay:
aResult = 200;
break;
- case IntID::TooltipDelay:
- aResult = 500;
- break;
case IntID::MenusCanOverlapOSBar:
// xul popups are not allowed to overlap the menubar.
aResult = 0;
diff --git a/widget/cocoa/nsMacSharingService.mm b/widget/cocoa/nsMacSharingService.mm
index 694617ba65..c8509af00f 100644
--- a/widget/cocoa/nsMacSharingService.mm
+++ b/widget/cocoa/nsMacSharingService.mm
@@ -98,7 +98,7 @@ static NSString* NSImageToBase64(const NSImage* aImage) {
static void SetStrAttribute(JSContext* aCx, JS::Rooted<JSObject*>& aObj,
const char* aKey, NSString* aVal) {
nsAutoString strVal;
- mozilla::CopyCocoaStringToXPCOMString(aVal, strVal);
+ mozilla::CopyNSStringToXPCOMString(aVal, strVal);
JS::Rooted<JSString*> title(aCx, JS_NewUCStringCopyZ(aCx, strVal.get()));
JS::Rooted<JS::Value> attVal(aCx, JS::StringValue(title));
JS_SetProperty(aCx, aObj, aKey, attVal);