Commit 4c172144 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

Run "tools/mac/rewrite_modern_objc.py out/gn ../../ui/views"

Bug: 324079
Change-Id: I06c556660ab05975b5a0726cf7e3e72afa9ed070
Reviewed-on: https://chromium-review.googlesource.com/c/1296675Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602057}
parent d7d6e62a
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
// OSExchangeData into the pasteboard. // OSExchangeData into the pasteboard.
VIEWS_EXPORT VIEWS_EXPORT
@interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider> @interface CocoaDragDropDataProvider : NSObject<NSPasteboardItemDataProvider>
- (id)initWithData:(const ui::OSExchangeData&)data; - (instancetype)initWithData:(const ui::OSExchangeData&)data;
@end @end
namespace gfx { namespace gfx {
......
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
#import "ui/views_bridge_mac/bridged_native_widget_impl.h" #import "ui/views_bridge_mac/bridged_native_widget_impl.h"
@interface CocoaDragDropDataProvider () @interface CocoaDragDropDataProvider ()
- (id)initWithData:(const ui::OSExchangeData&)data; - (instancetype)initWithData:(const ui::OSExchangeData&)data;
- (id)initWithPasteboard:(NSPasteboard*)pasteboard; - (instancetype)initWithPasteboard:(NSPasteboard*)pasteboard;
@end @end
@implementation CocoaDragDropDataProvider { @implementation CocoaDragDropDataProvider {
std::unique_ptr<ui::OSExchangeData> data_; std::unique_ptr<ui::OSExchangeData> data_;
} }
- (id)initWithData:(const ui::OSExchangeData&)data { - (instancetype)initWithData:(const ui::OSExchangeData&)data {
if ((self = [super init])) { if ((self = [super init])) {
data_.reset(new OSExchangeData( data_.reset(new OSExchangeData(
std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone()))); std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone())));
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
return self; return self;
} }
- (id)initWithPasteboard:(NSPasteboard*)pasteboard { - (instancetype)initWithPasteboard:(NSPasteboard*)pasteboard {
if ((self = [super init])) { if ((self = [super init])) {
data_ = ui::OSExchangeDataProviderMac::CreateDataFromPasteboard(pasteboard); data_ = ui::OSExchangeDataProviderMac::CreateDataFromPasteboard(pasteboard);
} }
......
...@@ -56,7 +56,7 @@ using base::ASCIIToUTF16; ...@@ -56,7 +56,7 @@ using base::ASCIIToUTF16;
@synthesize draggingFormation; @synthesize draggingFormation;
@synthesize springLoadingHighlight; @synthesize springLoadingHighlight;
- (id)initWithPasteboard:(NSPasteboard*)pasteboard { - (instancetype)initWithPasteboard:(NSPasteboard*)pasteboard {
if ((self = [super init])) { if ((self = [super init])) {
pasteboard_ = pasteboard; pasteboard_ = pasteboard;
} }
......
...@@ -257,8 +257,7 @@ class MenuRunnerCocoaTest : public ViewsTestBase, ...@@ -257,8 +257,7 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
// An anchor view should only be added for Native menus. // An anchor view should only be added for Native menus.
if (GetParam() == MenuType::NATIVE) { if (GetParam() == MenuType::NATIVE) {
ASSERT_EQ(native_view_subview_count_ + 1, [subviews count]); ASSERT_EQ(native_view_subview_count_ + 1, [subviews count]);
last_anchor_frame_ = last_anchor_frame_ = [subviews[native_view_subview_count_] frame];
[[subviews objectAtIndex:native_view_subview_count_] frame];
} else { } else {
EXPECT_EQ(native_view_subview_count_, [subviews count]); EXPECT_EQ(native_view_subview_count_, [subviews count]);
} }
......
...@@ -304,10 +304,10 @@ TEST_F(AXNativeWidgetMacTest, FocusableElementsAreLeafNodes) { ...@@ -304,10 +304,10 @@ TEST_F(AXNativeWidgetMacTest, FocusableElementsAreLeafNodes) {
1u, 1u,
[[button->GetNativeViewAccessible() [[button->GetNativeViewAccessible()
accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count]); accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count]);
EXPECT_EQ(button->label()->GetNativeViewAccessible(), EXPECT_EQ(
[[button->GetNativeViewAccessible() button->label()->GetNativeViewAccessible(),
accessibilityAttributeValue:NSAccessibilityChildrenAttribute] [button->GetNativeViewAccessible()
objectAtIndex:0]); accessibilityAttributeValue:NSAccessibilityChildrenAttribute][0]);
// If the child is disabled, it should still be traversable. // If the child is disabled, it should still be traversable.
button->label()->SetEnabled(false); button->label()->SetEnabled(false);
...@@ -315,10 +315,10 @@ TEST_F(AXNativeWidgetMacTest, FocusableElementsAreLeafNodes) { ...@@ -315,10 +315,10 @@ TEST_F(AXNativeWidgetMacTest, FocusableElementsAreLeafNodes) {
1u, 1u,
[[button->GetNativeViewAccessible() [[button->GetNativeViewAccessible()
accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count]); accessibilityAttributeValue:NSAccessibilityChildrenAttribute] count]);
EXPECT_EQ(button->label()->GetNativeViewAccessible(), EXPECT_EQ(
[[button->GetNativeViewAccessible() button->label()->GetNativeViewAccessible(),
accessibilityAttributeValue:NSAccessibilityChildrenAttribute] [button->GetNativeViewAccessible()
objectAtIndex:0]); accessibilityAttributeValue:NSAccessibilityChildrenAttribute][0]);
} }
// Test for NSAccessibilityChildrenAttribute, and ensure it excludes ignored // Test for NSAccessibilityChildrenAttribute, and ensure it excludes ignored
...@@ -558,7 +558,7 @@ TEST_F(AXNativeWidgetMacTest, ViewWritableAttributes) { ...@@ -558,7 +558,7 @@ TEST_F(AXNativeWidgetMacTest, ViewWritableAttributes) {
[AttributeValueAtMidpoint(NSAccessibilityFocusedAttribute) boolValue]); [AttributeValueAtMidpoint(NSAccessibilityFocusedAttribute) boolValue]);
EXPECT_TRUE([ax_node EXPECT_TRUE([ax_node
accessibilityIsAttributeSettable:NSAccessibilityFocusedAttribute]); accessibilityIsAttributeSettable:NSAccessibilityFocusedAttribute]);
[ax_node accessibilitySetValue:[NSNumber numberWithBool:YES] [ax_node accessibilitySetValue:@YES
forAttribute:NSAccessibilityFocusedAttribute]; forAttribute:NSAccessibilityFocusedAttribute];
EXPECT_TRUE( EXPECT_TRUE(
[AttributeValueAtMidpoint(NSAccessibilityFocusedAttribute) boolValue]); [AttributeValueAtMidpoint(NSAccessibilityFocusedAttribute) boolValue]);
......
...@@ -774,8 +774,7 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) { ...@@ -774,8 +774,7 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
child->Show(); child->Show();
EXPECT_TRUE(child->IsVisible()); EXPECT_TRUE(child->IsVisible());
EXPECT_EQ(1u, [[native_parent childWindows] count]); EXPECT_EQ(1u, [[native_parent childWindows] count]);
EXPECT_EQ(child->GetNativeWindow(), EXPECT_EQ(child->GetNativeWindow(), [native_parent childWindows][0]);
[[native_parent childWindows] objectAtIndex:0]);
EXPECT_EQ(native_parent, EXPECT_EQ(native_parent,
[child->GetNativeWindow().GetNativeNSWindow() parentWindow]); [child->GetNativeWindow().GetNativeNSWindow() parentWindow]);
......
...@@ -66,8 +66,8 @@ VIEWS_EXPORT ...@@ -66,8 +66,8 @@ VIEWS_EXPORT
@property(assign, nonatomic) BOOL drawMenuBackgroundForBlur; @property(assign, nonatomic) BOOL drawMenuBackgroundForBlur;
// Initialize the NSView -> views::View bridge. |viewToHost| must be non-NULL. // Initialize the NSView -> views::View bridge. |viewToHost| must be non-NULL.
- (id)initWithBridge:(views::BridgedNativeWidgetImpl*)bridge - (instancetype)initWithBridge:(views::BridgedNativeWidgetImpl*)bridge
bounds:(gfx::Rect)rect; bounds:(gfx::Rect)rect;
// Clear the hosted view. For example, if it is about to be destroyed. // Clear the hosted view. For example, if it is about to be destroyed.
- (void)clearView; - (void)clearView;
......
...@@ -254,7 +254,7 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { ...@@ -254,7 +254,7 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
- (void)insertTextInternal:(id)text; - (void)insertTextInternal:(id)text;
// Returns the native Widget's drag drop client. Possibly null. // Returns the native Widget's drag drop client. Possibly null.
- (views_bridge_mac::DragDropClient*)dragDropClient; - (views_bridge_mac::DragDropClient*)dragDropClient NS_RETURNS_INNER_POINTER;
// Menu action handlers. // Menu action handlers.
- (void)undo:(id)sender; - (void)undo:(id)sender;
...@@ -273,8 +273,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) { ...@@ -273,8 +273,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
@synthesize textInputClient = textInputClient_; @synthesize textInputClient = textInputClient_;
@synthesize drawMenuBackgroundForBlur = drawMenuBackgroundForBlur_; @synthesize drawMenuBackgroundForBlur = drawMenuBackgroundForBlur_;
- (id)initWithBridge:(views::BridgedNativeWidgetImpl*)bridge - (instancetype)initWithBridge:(views::BridgedNativeWidgetImpl*)bridge
bounds:(gfx::Rect)bounds { bounds:(gfx::Rect)bounds {
// To keep things simple, assume the origin is (0, 0) until there exists a use // To keep things simple, assume the origin is (0, 0) until there exists a use
// case for something other than that. // case for something other than that.
DCHECK(bounds.origin().IsOrigin()); DCHECK(bounds.origin().IsOrigin());
......
...@@ -54,7 +54,7 @@ constexpr auto kUIPaintTimeout = base::TimeDelta::FromSeconds(5); ...@@ -54,7 +54,7 @@ constexpr auto kUIPaintTimeout = base::TimeDelta::FromSeconds(5);
@implementation ViewsNSWindowCloseAnimator @implementation ViewsNSWindowCloseAnimator
- (id)initWithWindow:(NSWindow*)window { - (instancetype)initWithWindow:(NSWindow*)window {
if ((self = [super init])) { if ((self = [super init])) {
window_.reset([window retain]); window_.reset([window retain]);
animation_.reset( animation_.reset(
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
@end @end
@implementation WeakCocoaWindowMoveLoop @implementation WeakCocoaWindowMoveLoop
- (id)initWithWeakPtr:(const base::WeakPtr<views::CocoaWindowMoveLoop>&)weak { - (instancetype)initWithWeakPtr:
(const base::WeakPtr<views::CocoaWindowMoveLoop>&)weak {
if ((self = [super init])) { if ((self = [super init])) {
weak_ = weak; weak_ = weak;
} }
......
...@@ -28,7 +28,8 @@ VIEWS_EXPORT ...@@ -28,7 +28,8 @@ VIEWS_EXPORT
@property(retain, nonatomic) NSCursor* cursor; @property(retain, nonatomic) NSCursor* cursor;
// Initialize with the given |parent|. // Initialize with the given |parent|.
- (id)initWithBridgedNativeWidget:(views::BridgedNativeWidgetImpl*)parent; - (instancetype)initWithBridgedNativeWidget:
(views::BridgedNativeWidgetImpl*)parent;
// Notify that the window has been reordered in (or removed from) the window // Notify that the window has been reordered in (or removed from) the window
// server's screen list. This is a substitute for -[NSWindowDelegate // server's screen list. This is a substitute for -[NSWindowDelegate
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
@implementation ViewsNSWindowDelegate @implementation ViewsNSWindowDelegate
- (id)initWithBridgedNativeWidget:(views::BridgedNativeWidgetImpl*)parent { - (instancetype)initWithBridgedNativeWidget:
(views::BridgedNativeWidgetImpl*)parent {
DCHECK(parent); DCHECK(parent);
if ((self = [super init])) { if ((self = [super init])) {
parent_ = parent; parent_ = parent;
......
...@@ -27,7 +27,7 @@ class ViewsScrollbarBridgeDelegate { ...@@ -27,7 +27,7 @@ class ViewsScrollbarBridgeDelegate {
// Initializes with the given delegate and registers for notifications on // Initializes with the given delegate and registers for notifications on
// scroller style changes. // scroller style changes.
- (id)initWithDelegate:(ViewsScrollbarBridgeDelegate*)delegate; - (instancetype)initWithDelegate:(ViewsScrollbarBridgeDelegate*)delegate;
// Sets |delegate_| to nullptr. // Sets |delegate_| to nullptr.
- (void)clearDelegate; - (void)clearDelegate;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
@implementation ViewsScrollbarBridge @implementation ViewsScrollbarBridge
- (id)initWithDelegate:(ViewsScrollbarBridgeDelegate*)delegate { - (instancetype)initWithDelegate:(ViewsScrollbarBridgeDelegate*)delegate {
if ((self = [super init])) { if ((self = [super init])) {
delegate_ = delegate; delegate_ = delegate;
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment