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

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

Issue 7645041: mac: Makeshift UI for scroll feedback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #include "base/mac/scoped_cftyperef.h" 14 #include "base/mac/scoped_cftyperef.h"
15 #import "base/mac/scoped_nsautorelease_pool.h" 15 #import "base/mac/scoped_nsautorelease_pool.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #import "base/memory/scoped_nsobject.h" 17 #import "base/memory/scoped_nsobject.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/sys_info.h" 19 #include "base/sys_info.h"
20 #include "base/sys_string_conversions.h" 20 #include "base/sys_string_conversions.h"
21 #include "chrome/browser/browser_trial.h" 21 #include "chrome/browser/browser_trial.h"
22 #include "chrome/browser/mac/closure_blocks_leopard_compat.h" 22 #include "chrome/browser/mac/closure_blocks_leopard_compat.h"
23 #import "chrome/browser/renderer_host/accelerated_plugin_view_mac.h" 23 #import "chrome/browser/renderer_host/accelerated_plugin_view_mac.h"
24 #import "chrome/browser/renderer_host/text_input_client_mac.h" 24 #import "chrome/browser/renderer_host/text_input_client_mac.h"
25 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h" 25 #include "chrome/browser/spellchecker/spellchecker_platform_engine.h"
26 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
27 #include "chrome/browser/ui/browser_list.h" 27 #include "chrome/browser/ui/browser_list.h"
28 #import "chrome/browser/ui/cocoa/history_overlay_controller.h"
28 #import "chrome/browser/ui/cocoa/rwhvm_editcommand_helper.h" 29 #import "chrome/browser/ui/cocoa/rwhvm_editcommand_helper.h"
29 #import "chrome/browser/ui/cocoa/view_id_util.h" 30 #import "chrome/browser/ui/cocoa/view_id_util.h"
30 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
31 #include "chrome/common/spellcheck_messages.h" 32 #include "chrome/common/spellcheck_messages.h"
32 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 33 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
33 #include "content/browser/browser_thread.h" 34 #include "content/browser/browser_thread.h"
34 #include "content/browser/gpu/gpu_process_host.h" 35 #include "content/browser/gpu/gpu_process_host.h"
35 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 36 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
36 #include "content/browser/plugin_process_host.h" 37 #include "content/browser/plugin_process_host.h"
37 #include "content/browser/renderer_host/backing_store_mac.h" 38 #include "content/browser/renderer_host/backing_store_mac.h"
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 // the left in the same gesture, that should trigger history 1583 // the left in the same gesture, that should trigger history
1583 // immediately if there's no scrollbar, hence the check for 1584 // immediately if there's no scrollbar, hence the check for
1584 // hasHorizontalScrollbar_. 1585 // hasHorizontalScrollbar_.
1585 (!hasHorizontalScrollbar_ || 1586 (!hasHorizontalScrollbar_ ||
1586 // One would think we have to check canGoBack / canGoForward here, but 1587 // One would think we have to check canGoBack / canGoForward here, but
1587 // that's actually done in the renderer 1588 // that's actually done in the renderer
1588 // (ChromeClientImpl::shouldRubberBand()), when it decides if it should 1589 // (ChromeClientImpl::shouldRubberBand()), when it decides if it should
1589 // rubberband or send back an event unhandled. 1590 // rubberband or send back an event unhandled.
1590 (isPinnedLeft_ && !isRightScroll) || 1591 (isPinnedLeft_ && !isRightScroll) ||
1591 (isPinnedRight_ && isRightScroll))) { 1592 (isPinnedRight_ && isRightScroll))) {
1593
1594 // Released by the tracking handler once the gesture is complete.
1595 HistoryOverlayController* historyOverlay =
1596 [[HistoryOverlayController alloc]
1597 initForMode:goForward ? kHistoryOverlayModeForward :
1598 kHistoryOverlayModeBack];
1599
1592 // The way this api works: gestureAmount is between -1 and 1 (float). If 1600 // The way this api works: gestureAmount is between -1 and 1 (float). If
1593 // the user does the gesture for more than about 25% (i.e. < -0.25 or > 1601 // the user does the gesture for more than about 25% (i.e. < -0.25 or >
1594 // 0.25) and then lets go, it is accepted, we get a NSEventPhaseEnded, 1602 // 0.25) and then lets go, it is accepted, we get a NSEventPhaseEnded,
1595 // and after that the block is called with amounts animating towards 1 1603 // and after that the block is called with amounts animating towards 1
1596 // (or -1, depending on the direction). If the user lets go below that 1604 // (or -1, depending on the direction). If the user lets go below that
1597 // threshold, we get NSEventPhaseCancelled, and the amount animates 1605 // threshold, we get NSEventPhaseCancelled, and the amount animates
1598 // toward 0. 1606 // toward 0.
Mark Mentovai 2011/08/16 01:01:20 Since you describe the API here and isComplete is
Nico 2011/08/16 04:56:17 Done.
1599 [theEvent trackSwipeEventWithOptions:0 1607 [theEvent trackSwipeEventWithOptions:0
1600 dampenAmountThresholdMin:-1 1608 dampenAmountThresholdMin:-1
1601 max:1 1609 max:1
1602 usingHandler:^(CGFloat gestureAmount, 1610 usingHandler:^(CGFloat gestureAmount,
1603 NSEventPhase phase, 1611 NSEventPhase phase,
1604 BOOL isComplete, 1612 BOOL isComplete,
1605 BOOL *stop) { 1613 BOOL *stop) {
1614 if (phase == NSEventPhaseBegan) {
1615 [historyOverlay showPanelForWindow:[self window]];
1616 return;
1617 }
1618
1606 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] 1619 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice]
1607 // automatically. 1620 // automatically.
1608 // TODO(thakis): UI.
1609 Browser* browser = BrowserList::GetLastActive(); 1621 Browser* browser = BrowserList::GetLastActive();
1610 if (phase == NSEventPhaseEnded && browser) { 1622 if (phase == NSEventPhaseEnded && browser) {
1611 if (goForward) 1623 if (goForward)
1612 browser->GoForward(CURRENT_TAB); 1624 browser->GoForward(CURRENT_TAB);
1613 else 1625 else
1614 browser->GoBack(CURRENT_TAB); 1626 browser->GoBack(CURRENT_TAB);
1615 } 1627 }
1628
1629 [historyOverlay setProgress:gestureAmount];
1630 if (isComplete) {
1631 [historyOverlay dismiss];
1632 [historyOverlay release];
1633 }
1616 }]; 1634 }];
1617 return YES; 1635 return YES;
1618 } 1636 }
1619 } 1637 }
1620 return NO; 1638 return NO;
1621 } 1639 }
1622 1640
1623 - (void)scrollWheel:(NSEvent*)theEvent { 1641 - (void)scrollWheel:(NSEvent*)theEvent {
1624 [self cancelChildPopups]; 1642 [self cancelChildPopups];
1625 1643
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 if (!string) return NO; 2905 if (!string) return NO;
2888 2906
2889 // If the user is currently using an IME, confirm the IME input, 2907 // If the user is currently using an IME, confirm the IME input,
2890 // and then insert the text from the service, the same as TextEdit and Safari. 2908 // and then insert the text from the service, the same as TextEdit and Safari.
2891 [self confirmComposition]; 2909 [self confirmComposition];
2892 [self insertText:string]; 2910 [self insertText:string];
2893 return YES; 2911 return YES;
2894 } 2912 }
2895 2913
2896 @end 2914 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698