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

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: comments 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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 // If "forward" is inactive and the user rubber-bands to the right, 1581 // If "forward" is inactive and the user rubber-bands to the right,
1581 // "isPinnedLeft" will be false. When the user then rubber-bands to 1582 // "isPinnedLeft" will be false. When the user then rubber-bands to
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.
1591 // FIXME: Is this true with the UI up?
1590 (isPinnedLeft_ && !isRightScroll) || 1592 (isPinnedLeft_ && !isRightScroll) ||
1591 (isPinnedRight_ && isRightScroll))) { 1593 (isPinnedRight_ && isRightScroll))) {
1592 // The way this api works: gestureAmount is between -1 and 1 (float). If 1594
1595 // Released by the tracking handler once the gesture is complete.
1596 HistoryOverlayController* historyOverlay =
Alexei Svitkine (slow) 2011/08/16 14:10:04 I was going to ask you about this - but Mark beat
1597 [[HistoryOverlayController alloc]
1598 initForMode:goForward ? kHistoryOverlayModeForward :
1599 kHistoryOverlayModeBack];
1600
1601 // 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 > 1602 // 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, 1603 // 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 1604 // 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 1605 // (or -1, depending on the direction). If the user lets go below that
1597 // threshold, we get NSEventPhaseCancelled, and the amount animates 1606 // threshold, we get NSEventPhaseCancelled, and the amount animates
1598 // toward 0. 1607 // toward 0. When gestureAmount has reaches its final value, i.e. the
1608 // track animation is done, the handler is called with |isComplete| set
1609 // to |YES|.
1599 [theEvent trackSwipeEventWithOptions:0 1610 [theEvent trackSwipeEventWithOptions:0
1600 dampenAmountThresholdMin:-1 1611 dampenAmountThresholdMin:-50
Mark Mentovai 2011/08/16 05:47:22 Why the change to ±50 here? Learn anything you’re
Nico 2011/08/16 15:55:43 Hah, no. I played with this and couldn't really se
1601 max:1 1612 max:50
1602 usingHandler:^(CGFloat gestureAmount, 1613 usingHandler:^(CGFloat gestureAmount,
1603 NSEventPhase phase, 1614 NSEventPhase phase,
1604 BOOL isComplete, 1615 BOOL isComplete,
1605 BOOL *stop) { 1616 BOOL *stop) {
1617 if (phase == NSEventPhaseBegan) {
1618 [historyOverlay showPanelForWindow:[self window]];
1619 return;
1620 }
1621
1606 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice] 1622 // |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice]
1607 // automatically. 1623 // automatically.
1608 // TODO(thakis): UI.
1609 Browser* browser = BrowserList::GetLastActive(); 1624 Browser* browser = BrowserList::GetLastActive();
1610 if (phase == NSEventPhaseEnded && browser) { 1625 if (phase == NSEventPhaseEnded && browser) {
1611 if (goForward) 1626 if (goForward)
1612 browser->GoForward(CURRENT_TAB); 1627 browser->GoForward(CURRENT_TAB);
1613 else 1628 else
1614 browser->GoBack(CURRENT_TAB); 1629 browser->GoBack(CURRENT_TAB);
1615 } 1630 }
1631
1632 [historyOverlay setProgress:gestureAmount];
1633 if (isComplete) {
1634 [historyOverlay dismiss];
1635 [historyOverlay release];
1636 }
1616 }]; 1637 }];
1617 return YES; 1638 return YES;
1618 } 1639 }
1619 } 1640 }
1620 return NO; 1641 return NO;
1621 } 1642 }
1622 1643
1623 - (void)scrollWheel:(NSEvent*)theEvent { 1644 - (void)scrollWheel:(NSEvent*)theEvent {
1624 [self cancelChildPopups]; 1645 [self cancelChildPopups];
1625 1646
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 if (!string) return NO; 2908 if (!string) return NO;
2888 2909
2889 // If the user is currently using an IME, confirm the IME input, 2910 // 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. 2911 // and then insert the text from the service, the same as TextEdit and Safari.
2891 [self confirmComposition]; 2912 [self confirmComposition];
2892 [self insertText:string]; 2913 [self insertText:string];
2893 return YES; 2914 return YES;
2894 } 2915 }
2895 2916
2896 @end 2917 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698