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

Unified Diff: chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm

Issue 248383002: Revert of mac: History swiping doesn't work right with iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm
diff --git a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm
index 8cf35cdf9a4a828002a8d9f3126f82719567fef8..47f795edf3d55dcf6cecc0e88c1599affdcd062e 100644
--- a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm
+++ b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm
@@ -43,12 +43,17 @@
return NO;
}
-- (void)gotWheelEventConsumed:(BOOL)consumed {
- if (consumed) {
- gestureHandledState_ = history_swiper::kHandled;
- } else if (gestureHandledState_ == history_swiper::kPending) {
- gestureHandledState_ = history_swiper::kUnhandled;
- }
+- (void)gotUnhandledWheelEvent {
+ gotUnhandledWheelEvent_ = YES;
+}
+
+- (void)scrollOffsetPinnedToLeft:(BOOL)left toRight:(BOOL)right {
+ isPinnedLeft_ = left;
+ isPinnedRight_ = right;
+}
+
+- (void)setHasHorizontalScrollbar:(BOOL)hasHorizontalScrollbar {
+ hasHorizontalScrollbar_ = hasHorizontalScrollbar;
}
- (BOOL)canRubberbandLeft:(NSView*)view {
@@ -88,7 +93,7 @@
// Reset state pertaining to previous gestures.
historySwipeCancelled_ = NO;
gestureStartPointValid_ = NO;
- gestureHandledState_ = history_swiper::kPending;
+ gotUnhandledWheelEvent_ = NO;
receivedTouch_ = NO;
mouseScrollDelta_ = NSZeroSize;
}
@@ -337,6 +342,14 @@
[self browserCanNavigateInDirection:direction event:theEvent];
if (!browserCanMove)
return NO;
+
+ if (isRightScroll) {
+ if (hasHorizontalScrollbar_ && !isPinnedRight_)
+ return NO;
+ } else {
+ if (hasHorizontalScrollbar_ && !isPinnedLeft_)
+ return NO;
+ }
[self initiateMagicMouseHistorySwipe:isRightScroll event:theEvent];
return YES;
@@ -474,9 +487,9 @@
if (![delegate_ shouldAllowHistorySwiping])
return NO;
- // Only enable history swiping if blink has never handled any of the events in
- // the gesture.
- if (gestureHandledState_ != history_swiper::kUnhandled)
+ // Don't even consider enabling history swiping until blink has decided it is
+ // not going to handle the event.
+ if (!gotUnhandledWheelEvent_)
return NO;
// If the window has a horizontal scroll bar, sometimes Cocoa gets confused
@@ -512,6 +525,14 @@
if (inverted)
isRightScroll = !isRightScroll;
+ if (isRightScroll) {
+ if (hasHorizontalScrollbar_ && !isPinnedRight_)
+ return NO;
+ } else {
+ if (hasHorizontalScrollbar_ && !isPinnedLeft_)
+ return NO;
+ }
+
history_swiper::NavigationDirection direction =
isRightScroll ? history_swiper::kForwards : history_swiper::kBackwards;
BOOL browserCanMove =

Powered by Google App Engine
This is Rietveld 408576698