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

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

Issue 9296040: mac: Always do history swiping on the NTP on lion devices with touchpad. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable swipes to the left as well Created 8 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | chrome/browser/ui/browser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h" 5 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/debugger/devtools_window.h" 10 #include "chrome/browser/debugger/devtools_window.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 gotUnhandledWheelEvent_ = false; 163 gotUnhandledWheelEvent_ = false;
164 } 164 }
165 165
166 if (!render_widget_host_ || !render_widget_host_->IsRenderView()) 166 if (!render_widget_host_ || !render_widget_host_->IsRenderView())
167 return NO; 167 return NO;
168 bool isDevtoolsRwhv = DevToolsWindow::IsDevToolsWindow( 168 bool isDevtoolsRwhv = DevToolsWindow::IsDevToolsWindow(
169 static_cast<RenderViewHost*>(render_widget_host_)); 169 static_cast<RenderViewHost*>(render_widget_host_));
170 if (isDevtoolsRwhv) 170 if (isDevtoolsRwhv)
171 return NO; 171 return NO;
172 172
173 // TODO(thakis): This is wrong, as it will navigate the frontmost browser
174 // for swipe events on background windows. It also navigates the frontmost
175 // browser for swipes on extensions popups. And it's a dependency problem,
176 // too. http://crbug.com/102541
Robert Sesek 2012/01/30 17:13:18 I think I have a fix for this either today or tomo
Nico 2012/01/30 17:59:22 Heh, I've been looking at this, too. I guess I'll
177 Browser* browser = BrowserList::GetLastActive();
178
179 if (browser && browser->IsOnNtp() &&
180 [NSEvent isSwipeTrackingFromScrollEventsEnabled]) {
181 // Always do history navigation on the NTP if it's enabled.
182 gotUnhandledWheelEvent_ = true;
183 }
184
173 if (gotUnhandledWheelEvent_ && 185 if (gotUnhandledWheelEvent_ &&
174 [NSEvent isSwipeTrackingFromScrollEventsEnabled] && 186 [NSEvent isSwipeTrackingFromScrollEventsEnabled] &&
175 [theEvent phase] == NSEventPhaseChanged) { 187 [theEvent phase] == NSEventPhaseChanged) {
176 totalScrollDelta_.width += [theEvent scrollingDeltaX]; 188 totalScrollDelta_.width += [theEvent scrollingDeltaX];
177 totalScrollDelta_.height += [theEvent scrollingDeltaY]; 189 totalScrollDelta_.height += [theEvent scrollingDeltaY];
178 190
179 bool isHorizontalGesture = 191 bool isHorizontalGesture =
180 std::abs(totalScrollDelta_.width) > std::abs(totalScrollDelta_.height); 192 std::abs(totalScrollDelta_.width) > std::abs(totalScrollDelta_.height);
181 193
182 bool isRightScroll = [theEvent scrollingDeltaX] < 0; 194 bool isRightScroll = [theEvent scrollingDeltaX] < 0;
183 bool goForward = isRightScroll; 195 bool goForward = isRightScroll;
184 bool canGoBack = false, canGoForward = false; 196 bool canGoBack = false, canGoForward = false;
185 if (Browser* browser = BrowserList::GetLastActive()) { 197 if (browser) {
186 canGoBack = browser->CanGoBack(); 198 canGoBack = browser->CanGoBack();
187 canGoForward = browser->CanGoForward(); 199 canGoForward = browser->CanGoForward();
188 } 200 }
189 201
190 // If "forward" is inactive and the user rubber-bands to the right, 202 // If "forward" is inactive and the user rubber-bands to the right,
191 // "isPinnedLeft" will be false. When the user then rubber-bands to the 203 // "isPinnedLeft" will be false. When the user then rubber-bands to the
192 // left in the same gesture, that should trigger history immediately if 204 // left in the same gesture, that should trigger history immediately if
193 // there's no scrollbar, hence the check for hasHorizontalScrollbar_. 205 // there's no scrollbar, hence the check for hasHorizontalScrollbar_.
194 bool shouldGoBack = isPinnedLeft_ || !hasHorizontalScrollbar_; 206 bool shouldGoBack = isPinnedLeft_ || !hasHorizontalScrollbar_;
195 bool shouldGoForward = isPinnedRight_ || !hasHorizontalScrollbar_; 207 bool shouldGoForward = isPinnedRight_ || !hasHorizontalScrollbar_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 268
257 [historyOverlay setProgress:gestureAmount]; 269 [historyOverlay setProgress:gestureAmount];
258 if (isComplete) { 270 if (isComplete) {
259 [historyOverlay dismiss]; 271 [historyOverlay dismiss];
260 [historyOverlay release]; 272 [historyOverlay release];
261 } 273 }
262 }]; 274 }];
263 return YES; 275 return YES;
264 } 276 }
265 } 277 }
266 return NO; 278 return gotUnhandledWheelEvent_;
267 } 279 }
268 280
269 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item 281 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item
270 isValidItem:(BOOL*)valid { 282 isValidItem:(BOOL*)valid {
271 SEL action = [item action]; 283 SEL action = [item action];
272 284
273 // For now, this action is always enabled for render view; 285 // For now, this action is always enabled for render view;
274 // this is sub-optimal. 286 // this is sub-optimal.
275 // TODO(suzhe): Plumb the "can*" methods up from WebCore. 287 // TODO(suzhe): Plumb the "can*" methods up from WebCore.
276 if (action == @selector(checkSpelling:)) { 288 if (action == @selector(checkSpelling:)) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 353 }
342 354
343 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { 355 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked {
344 spellcheck_enabled_ = enabled; 356 spellcheck_enabled_ = enabled;
345 spellcheck_checked_ = checked; 357 spellcheck_checked_ = checked;
346 } 358 }
347 359
348 // END Spellchecking methods 360 // END Spellchecking methods
349 361
350 @end 362 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/browser.h » ('j') | chrome/browser/ui/browser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698