| OLD | NEW |
| 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/mac/closure_blocks_leopard_compat.h" | 9 #include "base/mac/closure_blocks_leopard_compat.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 gotUnhandledWheelEvent_ = NO; | 167 gotUnhandledWheelEvent_ = NO; |
| 168 } | 168 } |
| 169 | 169 |
| 170 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) | 170 if (!renderWidgetHost_ || !renderWidgetHost_->IsRenderView()) |
| 171 return NO; | 171 return NO; |
| 172 if (DevToolsWindow::IsDevToolsWindow( | 172 if (DevToolsWindow::IsDevToolsWindow( |
| 173 RenderViewHost::From(renderWidgetHost_))) { | 173 RenderViewHost::From(renderWidgetHost_))) { |
| 174 return NO; | 174 return NO; |
| 175 } | 175 } |
| 176 | 176 |
| 177 BOOL suppressWheelEvent = NO; | |
| 178 Browser* browser = BrowserList::FindBrowserWithWindow([theEvent window]); | |
| 179 if (browser && [NSEvent isSwipeTrackingFromScrollEventsEnabled]) { | |
| 180 content::WebContents* contents = browser->GetSelectedWebContents(); | |
| 181 if (contents && contents->GetURL() == GURL(chrome::kChromeUINewTabURL)) { | |
| 182 // Always do history navigation on the NTP if it's enabled. | |
| 183 gotUnhandledWheelEvent_ = YES; | |
| 184 suppressWheelEvent = YES; | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 if (gotUnhandledWheelEvent_ && | 177 if (gotUnhandledWheelEvent_ && |
| 189 [NSEvent isSwipeTrackingFromScrollEventsEnabled] && | 178 [NSEvent isSwipeTrackingFromScrollEventsEnabled] && |
| 190 [theEvent phase] == NSEventPhaseChanged) { | 179 [theEvent phase] == NSEventPhaseChanged) { |
| 180 Browser* browser = BrowserList::FindBrowserWithWindow([theEvent window]); |
| 191 totalScrollDelta_.width += [theEvent scrollingDeltaX]; | 181 totalScrollDelta_.width += [theEvent scrollingDeltaX]; |
| 192 totalScrollDelta_.height += [theEvent scrollingDeltaY]; | 182 totalScrollDelta_.height += [theEvent scrollingDeltaY]; |
| 193 | 183 |
| 194 bool isHorizontalGesture = | 184 bool isHorizontalGesture = |
| 195 std::abs(totalScrollDelta_.width) > std::abs(totalScrollDelta_.height); | 185 std::abs(totalScrollDelta_.width) > std::abs(totalScrollDelta_.height); |
| 196 | 186 |
| 197 bool isRightScroll = [theEvent scrollingDeltaX] < 0; | 187 bool isRightScroll = [theEvent scrollingDeltaX] < 0; |
| 198 bool goForward = isRightScroll; | 188 bool goForward = isRightScroll; |
| 199 bool canGoBack = false, canGoForward = false; | 189 bool canGoBack = false, canGoForward = false; |
| 200 if (browser) { | 190 if (browser) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 else | 266 else |
| 277 browser->GoBack(CURRENT_TAB); | 267 browser->GoBack(CURRENT_TAB); |
| 278 } | 268 } |
| 279 | 269 |
| 280 if (isComplete) | 270 if (isComplete) |
| 281 [historyOverlay release]; | 271 [historyOverlay release]; |
| 282 }]; | 272 }]; |
| 283 return YES; | 273 return YES; |
| 284 } | 274 } |
| 285 } | 275 } |
| 286 return suppressWheelEvent; | 276 return NO; |
| 287 } | 277 } |
| 288 | 278 |
| 289 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item | 279 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item |
| 290 isValidItem:(BOOL*)valid { | 280 isValidItem:(BOOL*)valid { |
| 291 SEL action = [item action]; | 281 SEL action = [item action]; |
| 292 | 282 |
| 293 // For now, this action is always enabled for render view; | 283 // For now, this action is always enabled for render view; |
| 294 // this is sub-optimal. | 284 // this is sub-optimal. |
| 295 // TODO(suzhe): Plumb the "can*" methods up from WebCore. | 285 // TODO(suzhe): Plumb the "can*" methods up from WebCore. |
| 296 if (action == @selector(checkSpelling:)) { | 286 if (action == @selector(checkSpelling:)) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 351 } |
| 362 | 352 |
| 363 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { | 353 - (void)spellCheckEnabled:(BOOL)enabled checked:(BOOL)checked { |
| 364 spellcheckEnabled_ = enabled; | 354 spellcheckEnabled_ = enabled; |
| 365 spellcheckChecked_ = checked; | 355 spellcheckChecked_ = checked; |
| 366 } | 356 } |
| 367 | 357 |
| 368 // END Spellchecking methods | 358 // END Spellchecking methods |
| 369 | 359 |
| 370 @end | 360 @end |
| OLD | NEW |