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

Side by Side Diff: ios/web/web_state/ui/crw_context_menu_controller.mm

Issue 2639793002: Stop triggering context menu while scrolling (Closed)
Patch Set: Adressed feedback Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ios/web/web_state/ui/crw_context_menu_controller.h" 5 #import "ios/web/web_state/ui/crw_context_menu_controller.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 [self fetchDOMElementAtPoint:[touch locationInView:_webView] 296 [self fetchDOMElementAtPoint:[touch locationInView:_webView]
297 completionHandler:^(NSDictionary* element) { 297 completionHandler:^(NSDictionary* element) {
298 [weakSelf setDOMElementForLastTouch:element]; 298 [weakSelf setDOMElementForLastTouch:element];
299 }]; 299 }];
300 return YES; 300 return YES;
301 } 301 }
302 302
303 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer { 303 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
304 // Expect only _contextMenuRecognizer. 304 // Expect only _contextMenuRecognizer.
305 DCHECK([gestureRecognizer isEqual:_contextMenuRecognizer]); 305 DCHECK([gestureRecognizer isEqual:_contextMenuRecognizer]);
306
307 // Context menu should not be triggered while scrolling, as some users tend to
308 // stop scrolling by resting the finger on the screen instead of touching the
309 // screen. For more info, please refer to crbug.com/642375.
310 if ([self webScrollView].dragging) {
311 return NO;
312 }
313
306 // Fetching is considered as successful even if |_DOMElementForLastTouch| is 314 // Fetching is considered as successful even if |_DOMElementForLastTouch| is
307 // empty. However if |_DOMElementForLastTouch| is empty then custom context 315 // empty. However if |_DOMElementForLastTouch| is empty then custom context
308 // menu should not be shown. 316 // menu should not be shown.
309 UMA_HISTOGRAM_BOOLEAN("WebController.FetchContextMenuInfoAsyncSucceeded", 317 UMA_HISTOGRAM_BOOLEAN("WebController.FetchContextMenuInfoAsyncSucceeded",
310 !!_DOMElementForLastTouch); 318 !!_DOMElementForLastTouch);
311 return [_DOMElementForLastTouch count]; 319 return [_DOMElementForLastTouch count];
312 } 320 }
313 321
314 #pragma mark - 322 #pragma mark -
315 #pragma mark Web Page Features 323 #pragma mark Web Page Features
(...skipping 21 matching lines...) Expand all
337 [NSString stringWithFormat:@"__gCrWeb.getElementFromPoint(%g, %g);", 345 [NSString stringWithFormat:@"__gCrWeb.getElementFromPoint(%g, %g);",
338 localPoint.x, localPoint.y]; 346 localPoint.x, localPoint.y];
339 [self executeJavaScript:kGetElementScript 347 [self executeJavaScript:kGetElementScript
340 completionHandler:^(id element, NSError*) { 348 completionHandler:^(id element, NSError*) {
341 handler(base::mac::ObjCCastStrict<NSDictionary>(element)); 349 handler(base::mac::ObjCCastStrict<NSDictionary>(element));
342 }]; 350 }];
343 }]; 351 }];
344 } 352 }
345 353
346 @end 354 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698