Changeset 211770 in webkit
- Timestamp:
- Feb 6, 2017 8:23:52 PM (7 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r211767 r211770 1 2017-02-06 Dan Bernstein <mitz@apple.com> 2 3 [iOS] -[WKWebView becomeFirstResponder] and -[WKWebView resignFirstResponder] don’t get called when non-programmatic first responder changes happen 4 https://bugs.webkit.org/show_bug.cgi?id=167898 5 6 Reviewed by Tim Horton. 7 8 Made WKContentView’s -becomeFirstResponder and -resignFirstResponder forward to the 9 WKWebView, giving subclasses an opportunity to override these methods. Changed the WKWebView 10 implementations to call back into WKContentView methods that actually do the work. 11 12 * UIProcess/API/Cocoa/WKWebView.mm: 13 (-[WKWebView becomeFirstResponder]): If the current content view is a WKContentView, call 14 -becomeFirstResponderForWebView. Added a check that the content view has a superview to 15 get the right behavior when this is called during the transition from not having to having 16 a custom content view. 17 (-[WKWebView canBecomeFirstResponder]): If the current content view is a WKContentView, call 18 -canBecomeFirstResponderForWebView. 19 (-[WKWebView resignFirstResponder]): If the current content view is a WKContentView, call 20 -resignFirstResponderForWebView. 21 (-[WKWebView _setHasCustomContentView:loadedMIMEType:]): If the new content view is a 22 WKContentView, use -canBecomeFirstResponderForWebView. 23 24 * UIProcess/ios/WKContentViewInteraction.h: Added _becomingFirstResponder ivar. 25 * UIProcess/ios/WKContentViewInteraction.mm: 26 (-[WKContentView canBecomeFirstResponder]): Return _becomingFirstResponder. Normally this is 27 NO, so code that hit-tests then walks up the view hierarchy to select a first responder 28 will continue to the WKWebView. But we need to return YES around the call to super’s 29 -becomeFirstResponder in -becomeFirstResponderForWebView. 30 (-[WKContentView canBecomeFirstResponderForWebView]): Moved the old 31 -becomeFirstResponderForWebView implementation here. 32 (-[WKContentView becomeFirstResponder]): Forward to the WKWebView. 33 (-[WKContentView becomeFirstResponderForWebView]): Moved the old -becomeFirstResponder 34 implementation here, setting _becomingFirstResponder to YES around the call to super. 35 (-[WKContentView resignFirstResponder]): Forward to the WKWebView. 36 (-[WKContentView resignFirstResponderForWebView]): Moved the old -resignFirstResponder 37 implementation here. 38 1 39 2017-02-06 Simon Fraser <simon.fraser@apple.com> 2 40 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r211656 r211770 1 1 /* 2 * Copyright (C) 2014-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1014 1014 - (BOOL)becomeFirstResponder 1015 1015 { 1016 return [self._currentContentView becomeFirstResponder] || [super becomeFirstResponder]; 1016 UIView *currentContentView = self._currentContentView; 1017 if (currentContentView == _contentView && [_contentView superview]) 1018 return [_contentView becomeFirstResponderForWebView] || [super becomeFirstResponder]; 1019 1020 return [currentContentView becomeFirstResponder] || [super becomeFirstResponder]; 1017 1021 } 1018 1022 1019 1023 - (BOOL)canBecomeFirstResponder 1020 1024 { 1021 if (self._currentContentView == _contentView && [_contentView isResigningFirstResponder]) 1022 return NO; 1025 if (self._currentContentView == _contentView) 1026 return [_contentView canBecomeFirstResponderForWebView]; 1027 1023 1028 return YES; 1029 } 1030 1031 - (BOOL)resignFirstResponder 1032 { 1033 if ([_contentView isFirstResponder]) 1034 return [_contentView resignFirstResponderForWebView]; 1035 1036 return [super resignFirstResponder]; 1024 1037 } 1025 1038 … … 1090 1103 } 1091 1104 1092 if (self.isFirstResponder && self._currentContentView.canBecomeFirstResponder) 1093 [self._currentContentView becomeFirstResponder]; 1105 if (self.isFirstResponder) { 1106 UIView *currentContentView = self._currentContentView; 1107 if (currentContentView == _contentView ? [_contentView canBecomeFirstResponderForWebView] : currentContentView.canBecomeFirstResponder) 1108 [currentContentView becomeFirstResponder]; 1109 } 1094 1110 } 1095 1111 -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
r211679 r211770 1 1 /* 2 * Copyright (C) 2012-201 4Apple Inc. All rights reserved.2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 185 185 BOOL _showDebugTapHighlightsForFastClicking; 186 186 187 BOOL _becomingFirstResponder; 187 188 BOOL _resigningFirstResponder; 188 189 BOOL _needsDeferredEndScrollingSelectionUpdate; … … 213 214 214 215 - (void)scrollViewWillStartPanOrPinchGesture; 216 217 - (BOOL)canBecomeFirstResponderForWebView; 218 - (BOOL)becomeFirstResponderForWebView; 219 - (BOOL)resignFirstResponderForWebView; 215 220 216 221 #if ENABLE(TOUCH_EVENTS) -
trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
r211643 r211770 1 1 /* 2 * Copyright (C) 2012-201 4Apple Inc. All rights reserved.2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 81 81 #import <WebKit/WebSelectionRect.h> // FIXME: WK2 should not include WebKit headers! 82 82 #import <wtf/RetainPtr.h> 83 #import <wtf/SetForScope.h> 83 84 84 85 #if ENABLE(DATA_INTERACTION) … … 831 832 - (BOOL)canBecomeFirstResponder 832 833 { 834 return _becomingFirstResponder; 835 } 836 837 - (BOOL)canBecomeFirstResponderForWebView 838 { 833 839 if (_resigningFirstResponder) 834 840 return NO; … … 840 846 - (BOOL)becomeFirstResponder 841 847 { 848 return [_webView becomeFirstResponder]; 849 } 850 851 - (BOOL)becomeFirstResponderForWebView 852 { 842 853 if (_resigningFirstResponder) 843 854 return NO; 844 BOOL didBecomeFirstResponder = [super becomeFirstResponder]; 855 856 BOOL didBecomeFirstResponder; 857 { 858 SetForScope<BOOL> becomingFirstResponder { _becomingFirstResponder, YES }; 859 didBecomeFirstResponder = [super becomeFirstResponder]; 860 } 845 861 if (didBecomeFirstResponder) 846 862 [_textSelectionAssistant activateSelection]; … … 850 866 851 867 - (BOOL)resignFirstResponder 868 { 869 return [_webView resignFirstResponder]; 870 } 871 872 - (BOOL)resignFirstResponderForWebView 852 873 { 853 874 // FIXME: Maybe we should call resignFirstResponder on the superclass
Note: See TracChangeset
for help on using the changeset viewer.