Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1917973002: mac: Remove IsOSLion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 } // namespace 140 } // namespace
141 141
142 // These are not documented, so use only after checking -respondsToSelector:. 142 // These are not documented, so use only after checking -respondsToSelector:.
143 @interface NSApplication (UndocumentedSpeechMethods) 143 @interface NSApplication (UndocumentedSpeechMethods)
144 - (void)speakString:(NSString*)string; 144 - (void)speakString:(NSString*)string;
145 - (void)stopSpeaking:(id)sender; 145 - (void)stopSpeaking:(id)sender;
146 - (BOOL)isSpeaking; 146 - (BOOL)isSpeaking;
147 @end 147 @end
148 148
149 // This method will return YES for OS X versions 10.7.3 and later, and NO
150 // otherwise.
151 // Used to prevent a crash when building with the 10.7 SDK and accessing the
152 // notification below. See: http://crbug.com/260595.
153 static BOOL SupportsBackingPropertiesChangedNotification() {
154 // windowDidChangeBackingProperties: method has been added to the
155 // NSWindowDelegate protocol in 10.7.3, at the same time as the
156 // NSWindowDidChangeBackingPropertiesNotification notification was added.
157 // If the protocol contains this method description, the notification should
158 // be supported as well.
159 Protocol* windowDelegateProtocol = NSProtocolFromString(@"NSWindowDelegate");
160 struct objc_method_description methodDescription =
161 protocol_getMethodDescription(
162 windowDelegateProtocol,
163 @selector(windowDidChangeBackingProperties:),
164 NO,
165 YES);
166
167 // If the protocol does not contain the method, the returned method
168 // description is {NULL, NULL}
169 return methodDescription.name != NULL || methodDescription.types != NULL;
170 }
171
172 // Private methods: 149 // Private methods:
173 @interface RenderWidgetHostViewCocoa () 150 @interface RenderWidgetHostViewCocoa ()
174 @property(nonatomic, assign) NSRange selectedRange; 151 @property(nonatomic, assign) NSRange selectedRange;
175 @property(nonatomic, assign) NSRange markedRange; 152 @property(nonatomic, assign) NSRange markedRange;
176 153
177 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; 154 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event;
178 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; 155 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r;
179 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event 156 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event
180 consumed:(BOOL)consumed; 157 consumed:(BOOL)consumed;
181 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event 158 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent]) 2321 if ([RenderWidgetHostViewCocoa shouldAutohideCursorForEvent:theEvent])
2345 [NSCursor setHiddenUntilMouseMoves:YES]; 2322 [NSCursor setHiddenUntilMouseMoves:YES];
2346 } 2323 }
2347 2324
2348 - (void)forceTouchEvent:(NSEvent*)theEvent { 2325 - (void)forceTouchEvent:(NSEvent*)theEvent {
2349 if (ui::ForceClickInvokesQuickLook()) 2326 if (ui::ForceClickInvokesQuickLook())
2350 [self quickLookWithEvent:theEvent]; 2327 [self quickLookWithEvent:theEvent];
2351 } 2328 }
2352 2329
2353 - (void)shortCircuitScrollWheelEvent:(NSEvent*)event { 2330 - (void)shortCircuitScrollWheelEvent:(NSEvent*)event {
2354 DCHECK(base::mac::IsOSLionOrLater());
2355
2356 if ([event phase] != NSEventPhaseEnded && 2331 if ([event phase] != NSEventPhaseEnded &&
2357 [event phase] != NSEventPhaseCancelled) { 2332 [event phase] != NSEventPhaseCancelled) {
2358 return; 2333 return;
2359 } 2334 }
2360 2335
2361 if (renderWidgetHostView_->render_widget_host_) { 2336 if (renderWidgetHostView_->render_widget_host_) {
2362 // History-swiping is not possible if the logic reaches this point. 2337 // History-swiping is not possible if the logic reaches this point.
2363 // Allow rubber-banding in both directions. 2338 // Allow rubber-banding in both directions.
2364 bool canRubberbandLeft = true; 2339 bool canRubberbandLeft = true;
2365 bool canRubberbandRight = true; 2340 bool canRubberbandRight = true;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { 2486 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) {
2512 BOOL handled = [responderDelegate_ handleEvent:event]; 2487 BOOL handled = [responderDelegate_ handleEvent:event];
2513 if (handled) 2488 if (handled)
2514 return; 2489 return;
2515 } 2490 }
2516 2491
2517 // Use an NSEvent monitor to listen for the wheel-end end. This ensures that 2492 // Use an NSEvent monitor to listen for the wheel-end end. This ensures that
2518 // the event is received even when the mouse cursor is no longer over the view 2493 // the event is received even when the mouse cursor is no longer over the view
2519 // when the scrolling ends (e.g. if the tab was switched). This is necessary 2494 // when the scrolling ends (e.g. if the tab was switched). This is necessary
2520 // for ending rubber-banding in such cases. 2495 // for ending rubber-banding in such cases.
2521 if (base::mac::IsOSLionOrLater() && [event phase] == NSEventPhaseBegan && 2496 if ([event phase] == NSEventPhaseBegan && !endWheelMonitor_) {
2522 !endWheelMonitor_) {
2523 endWheelMonitor_ = 2497 endWheelMonitor_ =
2524 [NSEvent addLocalMonitorForEventsMatchingMask:NSScrollWheelMask 2498 [NSEvent addLocalMonitorForEventsMatchingMask:NSScrollWheelMask
2525 handler:^(NSEvent* blockEvent) { 2499 handler:^(NSEvent* blockEvent) {
2526 [self shortCircuitScrollWheelEvent:blockEvent]; 2500 [self shortCircuitScrollWheelEvent:blockEvent];
2527 return blockEvent; 2501 return blockEvent;
2528 }]; 2502 }];
2529 } 2503 }
2530 2504
2531 // This is responsible for content scrolling! 2505 // This is responsible for content scrolling!
2532 if (renderWidgetHostView_->render_widget_host_) { 2506 if (renderWidgetHostView_->render_widget_host_) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 updateEvent.data.pinchUpdate.zoomDisabled = !pinchHasReachedZoomThreshold_; 2549 updateEvent.data.pinchUpdate.zoomDisabled = !pinchHasReachedZoomThreshold_;
2576 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent); 2550 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(updateEvent);
2577 } 2551 }
2578 2552
2579 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { 2553 - (void)viewWillMoveToWindow:(NSWindow*)newWindow {
2580 NSWindow* oldWindow = [self window]; 2554 NSWindow* oldWindow = [self window];
2581 2555
2582 NSNotificationCenter* notificationCenter = 2556 NSNotificationCenter* notificationCenter =
2583 [NSNotificationCenter defaultCenter]; 2557 [NSNotificationCenter defaultCenter];
2584 2558
2585 // Backing property notifications crash on 10.6 when building with the 10.7
2586 // SDK, see http://crbug.com/260595.
2587 static BOOL supportsBackingPropertiesNotification =
2588 SupportsBackingPropertiesChangedNotification();
2589
2590 if (oldWindow) { 2559 if (oldWindow) {
2591 if (supportsBackingPropertiesNotification) { 2560 [notificationCenter
2592 [notificationCenter 2561 removeObserver:self
2593 removeObserver:self 2562 name:NSWindowDidChangeBackingPropertiesNotification
2594 name:NSWindowDidChangeBackingPropertiesNotification 2563 object:oldWindow];
2595 object:oldWindow];
2596 }
2597 [notificationCenter 2564 [notificationCenter
2598 removeObserver:self 2565 removeObserver:self
2599 name:NSWindowDidMoveNotification 2566 name:NSWindowDidMoveNotification
2600 object:oldWindow]; 2567 object:oldWindow];
2601 [notificationCenter 2568 [notificationCenter
2602 removeObserver:self 2569 removeObserver:self
2603 name:NSWindowDidEndLiveResizeNotification 2570 name:NSWindowDidEndLiveResizeNotification
2604 object:oldWindow]; 2571 object:oldWindow];
2605 [notificationCenter 2572 [notificationCenter
2606 removeObserver:self 2573 removeObserver:self
2607 name:NSWindowDidBecomeKeyNotification 2574 name:NSWindowDidBecomeKeyNotification
2608 object:oldWindow]; 2575 object:oldWindow];
2609 [notificationCenter 2576 [notificationCenter
2610 removeObserver:self 2577 removeObserver:self
2611 name:NSWindowDidResignKeyNotification 2578 name:NSWindowDidResignKeyNotification
2612 object:oldWindow]; 2579 object:oldWindow];
2613 } 2580 }
2614 if (newWindow) { 2581 if (newWindow) {
2615 if (supportsBackingPropertiesNotification) { 2582 [notificationCenter
2616 [notificationCenter 2583 addObserver:self
2617 addObserver:self 2584 selector:@selector(windowDidChangeBackingProperties:)
2618 selector:@selector(windowDidChangeBackingProperties:) 2585 name:NSWindowDidChangeBackingPropertiesNotification
2619 name:NSWindowDidChangeBackingPropertiesNotification 2586 object:newWindow];
2620 object:newWindow];
2621 }
2622 [notificationCenter 2587 [notificationCenter
2623 addObserver:self 2588 addObserver:self
2624 selector:@selector(windowChangedGlobalFrame:) 2589 selector:@selector(windowChangedGlobalFrame:)
2625 name:NSWindowDidMoveNotification 2590 name:NSWindowDidMoveNotification
2626 object:newWindow]; 2591 object:newWindow];
2627 [notificationCenter 2592 [notificationCenter
2628 addObserver:self 2593 addObserver:self
2629 selector:@selector(windowChangedGlobalFrame:) 2594 selector:@selector(windowChangedGlobalFrame:)
2630 name:NSWindowDidEndLiveResizeNotification 2595 name:NSWindowDidEndLiveResizeNotification
2631 object:newWindow]; 2596 object:newWindow];
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
3439 3404
3440 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3405 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3441 // regions that are not draggable. (See ControlRegionView in 3406 // regions that are not draggable. (See ControlRegionView in
3442 // native_app_window_cocoa.mm). This requires the render host view to be 3407 // native_app_window_cocoa.mm). This requires the render host view to be
3443 // draggable by default. 3408 // draggable by default.
3444 - (BOOL)mouseDownCanMoveWindow { 3409 - (BOOL)mouseDownCanMoveWindow {
3445 return YES; 3410 return YES;
3446 } 3411 }
3447 3412
3448 @end 3413 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698