summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron <ccameron@chromium.org>2015-10-07 12:42:18 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-07 19:43:34 +0000
commit741debced2db082f4921d7a46f79d81e47caaada (patch)
tree703e1ce03ab4eaf41e695385624939fa354f24d3
parentfe29294ef4a3045ab4d92dace8d6d9b20690d121 (diff)
downloadchromium_src-741debced2db082f4921d7a46f79d81e47caaada.zip
chromium_src-741debced2db082f4921d7a46f79d81e47caaada.tar.gz
chromium_src-741debced2db082f4921d7a46f79d81e47caaada.tar.bz2
Mac: Use [NSArray firstObject] for [NSScreen screens]
Crash reports indicate that the array is at times empty. Use firstObject instead of objectAtIndex:0, because firstObject will return nil instead of raising an exception. BUG=529723 Review URL: https://codereview.chromium.org/1380083005 Cr-Commit-Position: refs/heads/master@{#352915}
-rw-r--r--chrome/browser/ui/app_list/app_list_service_mac.mm2
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm8
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm2
-rw-r--r--chrome/browser/ui/cocoa/autofill/autofill_section_container.mm2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm6
-rw-r--r--chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm2
-rw-r--r--chrome/browser/ui/cocoa/panels/panel_utils_cocoa.mm8
-rw-r--r--chrome/browser/ui/cocoa/presentation_mode_controller.mm2
-rw-r--r--chrome/browser/ui/window_sizer/window_sizer_mac.mm2
-rw-r--r--content/browser/renderer_host/input/web_input_event_builders_mac.mm2
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm2
-rw-r--r--content/browser/web_contents/web_contents_view_mac.mm2
-rw-r--r--content/public/test/content_browser_test_utils_mac.mm2
-rw-r--r--ui/base/test/ui_controls_mac.mm2
-rw-r--r--ui/events/cocoa/events_mac_unittest.mm2
-rw-r--r--ui/gfx/color_profile_mac_unittest.mm2
-rw-r--r--ui/gfx/mac/coordinate_conversion.mm2
-rw-r--r--ui/gfx/mac/coordinate_conversion_unittest.mm4
-rw-r--r--ui/gfx/screen_mac.mm8
-rw-r--r--ui/message_center/cocoa/popup_collection.mm2
-rw-r--r--ui/snapshot/snapshot_mac.mm2
-rw-r--r--ui/views/event_monitor_mac.mm2
-rw-r--r--ui/views/widget/native_widget_mac_unittest.mm2
24 files changed, 37 insertions, 37 deletions
diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm
index b6673cd..b5c6d95 100644
--- a/chrome/browser/ui/app_list/app_list_service_mac.mm
+++ b/chrome/browser/ui/app_list/app_list_service_mac.mm
@@ -250,7 +250,7 @@ void GetAppListWindowOrigins(
const NSSize ns_window_size = [window frame].size;
gfx::Size window_size(ns_window_size.width, ns_window_size.height);
int primary_display_height =
- NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]);
+ NSMaxY([[[NSScreen screens] firstObject] frame]);
AppListServiceMac::FindAnchorPoint(window_size,
display,
primary_display_height,
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 337fe2e..bad78a5 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -57,7 +57,7 @@ const int kActivateThrottlePeriodSeconds = 2;
NSRect GfxToCocoaBounds(gfx::Rect bounds) {
typedef AppWindow::BoundsSpecification BoundsSpecification;
- NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
+ NSRect main_screen_rect = [[[NSScreen screens] firstObject] frame];
// If coordinates are unspecified, center window on primary screen.
if (bounds.x() == BoundsSpecification::kUnspecifiedPosition)
@@ -452,7 +452,7 @@ gfx::NativeWindow NativeAppWindowCocoa::GetNativeWindow() const {
gfx::Rect NativeAppWindowCocoa::GetRestoredBounds() const {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
NSRect frame = restored_bounds_;
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
@@ -469,7 +469,7 @@ ui::WindowShowState NativeAppWindowCocoa::GetRestoredState() const {
gfx::Rect NativeAppWindowCocoa::GetBounds() const {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
NSRect frame = [window() frame];
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
@@ -687,7 +687,7 @@ gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const {
// Flip the coordinates based on the main screen.
NSInteger screen_height =
- NSHeight([[[NSScreen screens] objectAtIndex:0] frame]);
+ NSHeight([[[NSScreen screens] firstObject] frame]);
NSRect frame_nsrect = [window() frame];
gfx::Rect frame_rect(NSRectToCGRect(frame_nsrect));
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm
index 8d54aac..73e2f32 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_popup_base_view_cocoa.mm
@@ -139,7 +139,7 @@
// coordinate space places the origin at the top-left of the first screen,
// whereas Cocoa's coordinate space expects the origin to be at the
// bottom-left of this same screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
frame.origin.y = NSMaxY([screen frame]) - NSMaxY(frame);
// TODO(isherman): The view should support scrolling if the popup gets too
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
index c4945fd..40584c3 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm
@@ -406,7 +406,7 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section,
[[field window] convertBaseToScreen:textFrameInScreen.origin];
// And adjust for gfx::Rect being flipped compared to OSX coordinates.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
textFrameInScreen.origin.y =
NSMaxY([screen frame]) - NSMaxY(textFrameInScreen);
gfx::Rect textFrameRect(NSRectToCGRect(textFrameInScreen));
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 028c744..a3716da 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -210,7 +210,7 @@ void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
real_bounds.width(),
real_bounds.height());
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
cocoa_bounds.origin.y =
NSHeight([screen frame]) - real_bounds.height() - real_bounds.y();
@@ -348,7 +348,7 @@ void BrowserWindowCocoa::ZoomChangedForActiveTab(bool can_show_bubble) {
gfx::Rect BrowserWindowCocoa::GetRestoredBounds() const {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
NSRect frame = [controller_ regularWindowFrame];
gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 99ef304..876f3dc 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -122,7 +122,7 @@ void RecordFullscreenStyle(FullscreenStyle style) {
[self isInAnyFullscreenMode] ? savedRegularWindow_ : [self window];
// Window positions are stored relative to the origin of the primary monitor.
- NSRect monitorFrame = [[[NSScreen screens] objectAtIndex:0] frame];
+ NSRect monitorFrame = [[[NSScreen screens] firstObject] frame];
NSScreen* windowScreen = [window screen];
// Start with the window's frame, which is in virtual coordinates.
@@ -682,7 +682,7 @@ willPositionSheet:(NSWindow*)sheet
enteringAppKitFullscreen_ = YES;
enteringAppKitFullscreenOnPrimaryScreen_ =
- [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]];
+ [[[self window] screen] isEqual:[[NSScreen screens] firstObject]];
fullscreen_mac::SlidingStyle style;
if (browser_->exclusive_access_manager()
@@ -1098,7 +1098,7 @@ willPositionSheet:(NSWindow*)sheet
// transition from working well. See http://crbug.com/396980 for more
// details.
if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] &&
- ![[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
+ ![[[self window] screen] isEqual:[[NSScreen screens] firstObject]]) {
return NO;
}
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
index 9786b9b..0620ce5 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm
@@ -114,7 +114,7 @@ void OmniboxPopupViewMac::UpdatePopupAppearance() {
gfx::Rect OmniboxPopupViewMac::GetTargetBounds() {
// Flip the coordinate system before returning.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
NSRect monitor_frame = [screen frame];
gfx::Rect bounds(NSRectToCGRect(target_popup_frame_));
bounds.set_y(monitor_frame.size.height - bounds.y() - bounds.height());
diff --git a/chrome/browser/ui/cocoa/panels/panel_utils_cocoa.mm b/chrome/browser/ui/cocoa/panels/panel_utils_cocoa.mm
index a5f1739..2fe8a56 100644
--- a/chrome/browser/ui/cocoa/panels/panel_utils_cocoa.mm
+++ b/chrome/browser/ui/cocoa/panels/panel_utils_cocoa.mm
@@ -8,7 +8,7 @@ namespace cocoa_utils {
NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
return NSMakeRect(
bounds.x(), NSHeight([screen frame]) - bounds.height() - bounds.y(),
@@ -17,7 +17,7 @@ NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) {
gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
return gfx::Rect(
NSMinX(bounds), NSHeight([screen frame]) - NSMaxY(bounds),
@@ -26,14 +26,14 @@ gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) {
NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point) {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
return NSMakePoint(point.x(), NSHeight([screen frame]) - point.y());
}
gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point) {
// Flip coordinates based on the primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
return gfx::Point(point.x, NSHeight([screen frame]) - point.y);
}
diff --git a/chrome/browser/ui/cocoa/presentation_mode_controller.mm b/chrome/browser/ui/cocoa/presentation_mode_controller.mm
index 8f7c688..0998ad7 100644
--- a/chrome/browser/ui/cocoa/presentation_mode_controller.mm
+++ b/chrome/browser/ui/cocoa/presentation_mode_controller.mm
@@ -535,7 +535,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
- (BOOL)isWindowOnPrimaryScreen {
NSScreen* screen = [[browserController_ window] screen];
- NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* primaryScreen = [[NSScreen screens] firstObject];
return (screen == primaryScreen);
}
diff --git a/chrome/browser/ui/window_sizer/window_sizer_mac.mm b/chrome/browser/ui/window_sizer/window_sizer_mac.mm
index b73c2db..64d049f 100644
--- a/chrome/browser/ui/window_sizer/window_sizer_mac.mm
+++ b/chrome/browser/ui/window_sizer/window_sizer_mac.mm
@@ -19,7 +19,7 @@ const int WindowSizer::kWindowTilePixels = 22;
gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size,
chrome::HostDesktopType type) {
NSRect work_area = [[NSScreen mainScreen] visibleFrame];
- NSRect main_area = [[[NSScreen screens] objectAtIndex:0] frame];
+ NSRect main_area = [[[NSScreen screens] firstObject] frame];
NSPoint corner = NSMakePoint(NSMinX(work_area), NSMaxY(work_area));
if (Browser* browser = chrome::FindLastActiveWithHostDesktopType(type)) {
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac.mm b/content/browser/renderer_host/input/web_input_event_builders_mac.mm
index 00d34f8..1e116e8 100644
--- a/content/browser/renderer_host/input/web_input_event_builders_mac.mm
+++ b/content/browser/renderer_host/input/web_input_event_builders_mac.mm
@@ -502,7 +502,7 @@ void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result,
result->globalX = screen_local.x;
// Flip y.
NSScreen* primary_screen = ([[NSScreen screens] count] > 0)
- ? [[NSScreen screens] objectAtIndex:0]
+ ? [[NSScreen screens] firstObject]
: nil;
if (primary_screen)
result->globalY = [primary_screen frame].size.height - screen_local.y;
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 8db1f59..00c46f2 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -354,7 +354,7 @@ float FlipYFromRectToScreen(float y, float rect_height) {
if (!g_screen_info_up_to_date) {
if ([[NSScreen screens] count] > 0) {
screen_zero_height =
- [[[NSScreen screens] objectAtIndex:0] frame].size.height;
+ [[[NSScreen screens] firstObject] frame].size.height;
g_screen_info_up_to_date = true;
} else {
return y;
diff --git a/content/browser/web_contents/web_contents_view_mac.mm b/content/browser/web_contents/web_contents_view_mac.mm
index 9e1f792..5588f1f 100644
--- a/content/browser/web_contents/web_contents_view_mac.mm
+++ b/content/browser/web_contents/web_contents_view_mac.mm
@@ -122,7 +122,7 @@ void WebContentsViewMac::GetContainerBounds(gfx::Rect* out) const {
bounds.origin = [window convertBaseToScreen:bounds.origin];
// Flip y to account for screen flip.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
bounds.origin.y = [screen frame].size.height - bounds.origin.y
- bounds.size.height;
*out = gfx::Rect(NSRectToCGRect(bounds));
diff --git a/content/public/test/content_browser_test_utils_mac.mm b/content/public/test/content_browser_test_utils_mac.mm
index 165a177..d2e879c 100644
--- a/content/public/test/content_browser_test_utils_mac.mm
+++ b/content/public/test/content_browser_test_utils_mac.mm
@@ -15,7 +15,7 @@ void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds) {
NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect());
if ([[NSScreen screens] count] > 0) {
new_bounds.origin.y =
- [[[NSScreen screens] objectAtIndex:0] frame].size.height -
+ [[[NSScreen screens] firstObject] frame].size.height -
new_bounds.origin.y - new_bounds.size.height;
}
diff --git a/ui/base/test/ui_controls_mac.mm b/ui/base/test/ui_controls_mac.mm
index 002cb03..15cdb79 100644
--- a/ui/base/test/ui_controls_mac.mm
+++ b/ui/base/test/ui_controls_mac.mm
@@ -235,7 +235,7 @@ bool SendMouseMove(long x, long y) {
bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) {
CHECK(g_ui_controls_enabled);
CGFloat screenHeight =
- [[[NSScreen screens] objectAtIndex:0] frame].size.height;
+ [[[NSScreen screens] firstObject] frame].size.height;
g_mouse_location = NSMakePoint(x, screenHeight - y); // flip!
NSWindow* window = WindowAtCurrentMouseLocation();
diff --git a/ui/events/cocoa/events_mac_unittest.mm b/ui/events/cocoa/events_mac_unittest.mm
index c4169bf..ff943b9 100644
--- a/ui/events/cocoa/events_mac_unittest.mm
+++ b/ui/events/cocoa/events_mac_unittest.mm
@@ -109,7 +109,7 @@ class EventsMacTest : public CocoaTest {
NSPointFromCGPoint(Flip(window_location).ToCGPoint());
NSPoint screen_point = [test_window() convertBaseToScreen:window_point];
CGFloat primary_screen_height =
- NSHeight([[[NSScreen screens] objectAtIndex:0] frame]);
+ NSHeight([[[NSScreen screens] firstObject] frame]);
screen_point.y = primary_screen_height - screen_point.y;
CGEventSetLocation(scroll, NSPointToCGPoint(screen_point));
return [NSEvent eventWithCGEvent:scroll];
diff --git a/ui/gfx/color_profile_mac_unittest.mm b/ui/gfx/color_profile_mac_unittest.mm
index 26dd290..3910a9d 100644
--- a/ui/gfx/color_profile_mac_unittest.mm
+++ b/ui/gfx/color_profile_mac_unittest.mm
@@ -51,7 +51,7 @@ class ColorProfileTest : public ui::CocoaTest {
}
NSRect PrimaryScreenFrame() {
- return [[[NSScreen screens] objectAtIndex:0] frame];
+ return [[[NSScreen screens] firstObject] frame];
}
};
diff --git a/ui/gfx/mac/coordinate_conversion.mm b/ui/gfx/mac/coordinate_conversion.mm
index 54b16e9..b31ce9e 100644
--- a/ui/gfx/mac/coordinate_conversion.mm
+++ b/ui/gfx/mac/coordinate_conversion.mm
@@ -16,7 +16,7 @@ namespace {
// The height of the primary display, which OSX defines as the monitor with the
// menubar. This is always at index 0.
CGFloat PrimaryDisplayHeight() {
- return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]);
+ return NSMaxY([[[NSScreen screens] firstObject] frame]);
}
} // namespace
diff --git a/ui/gfx/mac/coordinate_conversion_unittest.mm b/ui/gfx/mac/coordinate_conversion_unittest.mm
index ac882fa..ccddbe8 100644
--- a/ui/gfx/mac/coordinate_conversion_unittest.mm
+++ b/ui/gfx/mac/coordinate_conversion_unittest.mm
@@ -48,7 +48,7 @@ class MacCoordinateConversionTest : public PlatformTest {
void MacCoordinateConversionTest::SetUp() {
// Before swizzling, do a sanity check that the primary screen's origin is
// (0, 0). This should always be true.
- NSRect primary_screen_frame = [[[NSScreen screens] objectAtIndex:0] frame];
+ NSRect primary_screen_frame = [[[NSScreen screens] firstObject] frame];
EXPECT_EQ(0, primary_screen_frame.origin.x);
EXPECT_EQ(0, primary_screen_frame.origin.y);
@@ -57,7 +57,7 @@ void MacCoordinateConversionTest::SetUp() {
[MacCoordinateConversionTestScreenDonor class],
@selector(frame)));
- primary_screen_frame = [[[NSScreen screens] objectAtIndex:0] frame];
+ primary_screen_frame = [[[NSScreen screens] firstObject] frame];
EXPECT_EQ(kTestWidth, primary_screen_frame.size.width);
EXPECT_EQ(kTestHeight, primary_screen_frame.size.height);
}
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm
index abd8549..e23feed 100644
--- a/ui/gfx/screen_mac.mm
+++ b/ui/gfx/screen_mac.mm
@@ -24,7 +24,7 @@ const int64 kConfigureDelayMs = 500;
gfx::Rect ConvertCoordinateSystem(NSRect ns_rect) {
// Primary monitor is defined as the monitor with the menubar,
// which is always at index 0.
- NSScreen* primary_screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* primary_screen = [[NSScreen screens] firstObject];
float primary_screen_height = [primary_screen frame].size.height;
gfx::Rect rect(NSRectToCGRect(ns_rect));
rect.set_y(primary_screen_height - rect.y() - rect.height());
@@ -58,7 +58,7 @@ gfx::Display GetDisplayForScreen(NSScreen* screen) {
gfx::Display display(display_id, gfx::Rect(NSRectToCGRect(frame)));
NSRect visible_frame = [screen visibleFrame];
- NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* primary = [[NSScreen screens] firstObject];
// Convert work area's coordinate systems.
if ([screen isEqual:primary]) {
@@ -103,7 +103,7 @@ class ScreenMac : public gfx::Screen {
gfx::Point GetCursorScreenPoint() override {
NSPoint mouseLocation = [NSEvent mouseLocation];
// Flip coordinates to gfx (0,0 in top-left corner) using primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y;
return gfx::Point(mouseLocation.x, mouseLocation.y);
}
@@ -161,7 +161,7 @@ class ScreenMac : public gfx::Screen {
gfx::Display GetPrimaryDisplay() const override {
// Primary display is defined as the display with the menubar,
// which is always at index 0.
- NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* primary = [[NSScreen screens] firstObject];
gfx::Display display = GetDisplayForScreen(primary);
return display;
}
diff --git a/ui/message_center/cocoa/popup_collection.mm b/ui/message_center/cocoa/popup_collection.mm
index 5961e614..05a6bdd 100644
--- a/ui/message_center/cocoa/popup_collection.mm
+++ b/ui/message_center/cocoa/popup_collection.mm
@@ -150,7 +150,7 @@ class PopupCollectionObserver : public message_center::MessageCenterObserver {
- (NSRect)screenFrame {
if (!NSIsEmptyRect(testingScreenFrame_))
return testingScreenFrame_;
- return [[[NSScreen screens] objectAtIndex:0] visibleFrame];
+ return [[[NSScreen screens] firstObject] visibleFrame];
}
- (BOOL)addNotification:(const message_center::Notification*)notification {
diff --git a/ui/snapshot/snapshot_mac.mm b/ui/snapshot/snapshot_mac.mm
index aa4048e..d1eb698 100644
--- a/ui/snapshot/snapshot_mac.mm
+++ b/ui/snapshot/snapshot_mac.mm
@@ -20,7 +20,7 @@ bool GrabViewSnapshot(gfx::NativeView view,
std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds) {
NSWindow* window = [view window];
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
gfx::Rect screen_bounds = gfx::Rect(NSRectToCGRect([screen frame]));
diff --git a/ui/views/event_monitor_mac.mm b/ui/views/event_monitor_mac.mm
index cb3e54e..45578c9 100644
--- a/ui/views/event_monitor_mac.mm
+++ b/ui/views/event_monitor_mac.mm
@@ -30,7 +30,7 @@ scoped_ptr<EventMonitor> EventMonitor::CreateWindowMonitor(
gfx::Point EventMonitor::GetLastMouseLocation() {
NSPoint mouseLocation = [NSEvent mouseLocation];
// Flip coordinates to gfx (0,0 in top-left corner) using primary screen.
- NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+ NSScreen* screen = [[NSScreen screens] firstObject];
mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y;
return gfx::Point(mouseLocation.x, mouseLocation.y);
}
diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm
index 0ff4fbf..2670ed6 100644
--- a/ui/views/widget/native_widget_mac_unittest.mm
+++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -1081,7 +1081,7 @@ TEST_F(NativeWidgetMacTest, GetWorkAreaBoundsInScreen) {
params.bounds = gfx::Rect(100, 100, 300, 200);
widget.Init(params);
widget.Show();
- NSRect expected = [[[NSScreen screens] objectAtIndex:0] visibleFrame];
+ NSRect expected = [[[NSScreen screens] firstObject] visibleFrame];
NSRect actual = gfx::ScreenRectToNSRect(widget.GetWorkAreaBoundsInScreen());
EXPECT_FALSE(NSIsEmptyRect(actual));
EXPECT_NSEQ(expected, actual);