summaryrefslogtreecommitdiff
path: root/chromium/ui/base/cocoa
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-03-08 10:28:10 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-03-20 13:40:30 +0000
commite733310db58160074f574c429d48f8308c0afe17 (patch)
treef8aef4b7e62a69928dbcf880620eece20f98c6df /chromium/ui/base/cocoa
parent2f583e4aec1ae3a86fa047829c96b310dc12ecdf (diff)
downloadqtwebengine-chromium-e733310db58160074f574c429d48f8308c0afe17.tar.gz
BASELINE: Update Chromium to 56.0.2924.122
Change-Id: I4e04de8f47e47e501c46ed934c76a431c6337ced Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ui/base/cocoa')
-rw-r--r--chromium/ui/base/cocoa/appkit_utils.h3
-rw-r--r--chromium/ui/base/cocoa/appkit_utils.mm6
-rw-r--r--chromium/ui/base/cocoa/nscolor_additions.h17
-rw-r--r--chromium/ui/base/cocoa/nscolor_additions.mm29
-rw-r--r--chromium/ui/base/cocoa/nscolor_additions_unittest.mm24
-rw-r--r--chromium/ui/base/cocoa/nsgraphics_context_additions_unittest.mm3
-rw-r--r--chromium/ui/base/cocoa/touch_bar_forward_declarations.h59
-rw-r--r--chromium/ui/base/cocoa/tracking_area.h4
-rw-r--r--chromium/ui/base/cocoa/tracking_area.mm7
9 files changed, 80 insertions, 72 deletions
diff --git a/chromium/ui/base/cocoa/appkit_utils.h b/chromium/ui/base/cocoa/appkit_utils.h
index bb11e078804..8f900e9326b 100644
--- a/chromium/ui/base/cocoa/appkit_utils.h
+++ b/chromium/ui/base/cocoa/appkit_utils.h
@@ -45,6 +45,9 @@ UI_BASE_EXPORT void WindowTitlebarReceivedDoubleClick(NSWindow* window,
// Whether a force-click event on the touchpad should invoke Quick Look.
UI_BASE_EXPORT bool ForceClickInvokesQuickLook();
+// Returns true if both CGFloat values are equal.
+UI_BASE_EXPORT bool IsCGFloatEqual(CGFloat a, CGFloat b);
+
} // namespace ui
#endif // UI_BASE_COCOA_APPKIT_UTILS_H
diff --git a/chromium/ui/base/cocoa/appkit_utils.mm b/chromium/ui/base/cocoa/appkit_utils.mm
index 95483cfd284..6c3e7e2d9cb 100644
--- a/chromium/ui/base/cocoa/appkit_utils.mm
+++ b/chromium/ui/base/cocoa/appkit_utils.mm
@@ -4,6 +4,8 @@
#import "ui/base/cocoa/appkit_utils.h"
+#include <cmath>
+
#include "base/mac/mac_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -109,4 +111,8 @@ bool ForceClickInvokesQuickLook() {
static_cast<NSInteger>(ForceTouchAction::QUICK_LOOK);
}
+bool IsCGFloatEqual(CGFloat a, CGFloat b) {
+ return std::fabs(a - b) <= std::numeric_limits<CGFloat>::epsilon();
+}
+
} // namespace ui
diff --git a/chromium/ui/base/cocoa/nscolor_additions.h b/chromium/ui/base/cocoa/nscolor_additions.h
deleted file mode 100644
index eaeb63a683f..00000000000
--- a/chromium/ui/base/cocoa/nscolor_additions.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_BASE_COCOA_NSCOLOR_ADDITIONS_H_
-#define UI_BASE_COCOA_NSCOLOR_ADDITIONS_H_
-
-#import <Cocoa/Cocoa.h>
-
-@interface NSColor (ChromeAdditions)
-
-// Returns an autoreleased CGColor, just like -[NSColor CGColor] in 10.8 SDK.
-- (CGColorRef)cr_CGColor;
-
-@end
-
-#endif // UI_BASE_COCOA_NSCOLOR_ADDITIONS_H_
diff --git a/chromium/ui/base/cocoa/nscolor_additions.mm b/chromium/ui/base/cocoa/nscolor_additions.mm
deleted file mode 100644
index 84502d6d33b..00000000000
--- a/chromium/ui/base/cocoa/nscolor_additions.mm
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ui/base/cocoa/nscolor_additions.h"
-
-#include "base/mac/foundation_util.h"
-#import "base/mac/sdk_forward_declarations.h"
-#include "base/macros.h"
-
-@implementation NSColor (ChromeAdditions)
-
-- (CGColorRef)cr_CGColor {
- // Redirect to -[NSColor CGColor] if available because it caches.
- static BOOL redirect =
- [NSColor instancesRespondToSelector:@selector(CGColor)];
- if (redirect)
- return [self CGColor];
-
- const NSInteger numberOfComponents = [self numberOfComponents];
- std::vector<CGFloat> components(numberOfComponents, 0.0);
- [self getComponents:components.data()];
- auto* color =
- CGColorCreate([[self colorSpace] CGColorSpace], components.data());
- base::mac::CFTypeRefToNSObjectAutorelease(color);
- return color;
-}
-
-@end
diff --git a/chromium/ui/base/cocoa/nscolor_additions_unittest.mm b/chromium/ui/base/cocoa/nscolor_additions_unittest.mm
deleted file mode 100644
index 0096714b7cb..00000000000
--- a/chromium/ui/base/cocoa/nscolor_additions_unittest.mm
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ui/base/cocoa/nscolor_additions.h"
-
-#include "base/mac/scoped_cftyperef.h"
-#include "testing/platform_test.h"
-
-typedef PlatformTest NSColorChromeAdditionsTest;
-
-TEST_F(NSColorChromeAdditionsTest, ConvertColorWithTwoComponents) {
- NSColor* nsColor = [NSColor colorWithCalibratedWhite:0.5 alpha:0.5];
- base::ScopedCFTypeRef<CGColorRef> cgColor(CGColorCreateGenericGray(0.5, 0.5));
- EXPECT_TRUE(CFEqual(cgColor, [nsColor cr_CGColor]));
-}
-
-TEST_F(NSColorChromeAdditionsTest, ConvertColorWithFourComponents) {
- NSColor* nsColor =
- [NSColor colorWithCalibratedRed:0.1 green:0.2 blue:0.3 alpha:0.4];
- base::ScopedCFTypeRef<CGColorRef> cgColor(
- CGColorCreateGenericRGB(0.1, 0.2, 0.3, 0.4));
- EXPECT_TRUE(CFEqual(cgColor, [nsColor cr_CGColor]));
-}
diff --git a/chromium/ui/base/cocoa/nsgraphics_context_additions_unittest.mm b/chromium/ui/base/cocoa/nsgraphics_context_additions_unittest.mm
index bfa17611d3d..d63f8f349df 100644
--- a/chromium/ui/base/cocoa/nsgraphics_context_additions_unittest.mm
+++ b/chromium/ui/base/cocoa/nsgraphics_context_additions_unittest.mm
@@ -9,8 +9,7 @@
typedef ui::CocoaTest NSGraphicsContextCrAdditionsTest;
-// Test fails, see http://crbug.com/249241
-TEST_F(NSGraphicsContextCrAdditionsTest, DISABLED_PatternPhase) {
+TEST_F(NSGraphicsContextCrAdditionsTest, PatternPhase) {
NSRect frame = NSMakeRect(50, 50, 100, 100);
base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:frame]);
[[test_window() contentView] addSubview:view];
diff --git a/chromium/ui/base/cocoa/touch_bar_forward_declarations.h b/chromium/ui/base/cocoa/touch_bar_forward_declarations.h
new file mode 100644
index 00000000000..54c68ae534b
--- /dev/null
+++ b/chromium/ui/base/cocoa/touch_bar_forward_declarations.h
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
+#define UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
+
+// Once Chrome no longer supports OSX 10.12.0, this file can be deleted.
+
+#import <Foundation/Foundation.h>
+
+#if !defined(MAC_OS_X_VERSION_10_12_1)
+
+// The TouchBar classes do not exist at all without the 10.12.1 SDK. When
+// compiling with older SDKs, pretend they are NSObject and add categories to
+// NSObject to expose the methods.
+// To alloc one of these classes, use -[NSClassFromString(@"..") alloc].
+
+// Incomplete. Add more as necessary.
+
+typedef NSObject NSCustomTouchBarItem;
+typedef NSObject NSGroupTouchBarItem;
+typedef NSObject NSTouchBar;
+typedef NSObject NSTouchBarItem;
+typedef NSString* NSTouchBarItemIdentifier;
+
+@protocol NSTouchBarDelegate<NSObject>
+@end
+
+@interface NSObject (FakeNSCustomTouchBarItem)
+@property(readwrite, strong) NSView* view;
+@end
+
+@interface NSObject (FakeNSGroupTouchBarItem)
++ (NSGroupTouchBarItem*)groupItemWithIdentifier:
+ (NSTouchBarItemIdentifier)identifier
+ items:(NSArray*)items;
+@end
+
+@interface NSObject (FakeNSTouchBar)
+@property(copy) NSArray* defaultItemIdentifiers;
+@property(copy) NSTouchBarItemIdentifier principalItemIdentifier;
+@property(weak) id<NSTouchBarDelegate> delegate;
+@end
+
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1
+
+// When compiling against the 10.12.1 SDK or later, just provide forward
+// declarations to suppress the partial availability warnings.
+
+@class NSCustomTouchBarItem;
+@class NSGroupTouchBarItem;
+@class NSTouchBar;
+@protocol NSTouchBarDelegate;
+@class NSTouchBarItem;
+
+#endif // MAC_OS_X_VERSION_10_12_1
+
+#endif // UI_BASE_COCOA_TOUCH_BAR_FORWARD_DECLARATIONS_H_
diff --git a/chromium/ui/base/cocoa/tracking_area.h b/chromium/ui/base/cocoa/tracking_area.h
index 07eb70b5f3d..0f67d6ca636 100644
--- a/chromium/ui/base/cocoa/tracking_area.h
+++ b/chromium/ui/base/cocoa/tracking_area.h
@@ -35,6 +35,10 @@ UI_BASE_EXPORT
// |-clearOwner| when the notification is observed.
- (void)clearOwnerWhenWindowWillClose:(NSWindow*)window;
+// Returns YES if the mouse is inside the tracking area's rect. |view| is the
+// NSView the tracking area is attached to.
+- (BOOL)mouseInsideTrackingAreaForView:(NSView*)view;
+
@end
// Scoper //////////////////////////////////////////////////////////////////////
diff --git a/chromium/ui/base/cocoa/tracking_area.mm b/chromium/ui/base/cocoa/tracking_area.mm
index e68fb5beae2..f310514d69b 100644
--- a/chromium/ui/base/cocoa/tracking_area.mm
+++ b/chromium/ui/base/cocoa/tracking_area.mm
@@ -101,6 +101,13 @@
object:window];
}
+- (BOOL)mouseInsideTrackingAreaForView:(NSView*)view {
+ DCHECK(view);
+ NSPoint mouseLoc = [[view window] mouseLocationOutsideOfEventStream];
+ NSPoint mousePos = [view convertPoint:mouseLoc fromView:nil];
+ return NSMouseInRect(mousePos, [self rect], [view isFlipped]);
+}
+
- (void)windowWillClose:(NSNotification*)notif {
[self clearOwner];
}