Changeset 295299 in webkit
- Timestamp:
- Jun 6, 2022, 3:08:33 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
-
LayoutTests/fast/forms/ios/show-file-upload-context-menu-above-keyboard-expected.txt (added)
-
LayoutTests/fast/forms/ios/show-file-upload-context-menu-above-keyboard.html (added)
-
LayoutTests/resources/ui-helper.js (modified) (2 diffs)
-
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h (modified) (1 diff)
-
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (modified) (7 diffs)
-
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (modified) (1 diff)
-
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (modified) (1 diff)
-
Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (modified) (1 diff)
-
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h (modified) (3 diffs)
-
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/resources/ui-helper.js
r292812 r295299 779 779 } 780 780 781 static dismissMenu() 782 { 783 if (!this.isWebKit2()) 784 return Promise.resolve(); 785 786 return new Promise(resolve => { 787 testRunner.runUIScript("uiController.dismissMenu()", resolve); 788 }); 789 } 790 781 791 static waitForKeyboardToHide() 782 792 { … … 1353 1363 return new Promise(resolve => { 1354 1364 testRunner.runUIScript("JSON.stringify(uiController.menuRect)", result => resolve(JSON.parse(result))); 1365 }); 1366 } 1367 1368 static contextMenuRect() 1369 { 1370 return new Promise(resolve => { 1371 testRunner.runUIScript("JSON.stringify(uiController.contextMenuRect)", result => resolve(JSON.parse(result))); 1355 1372 }); 1356 1373 } -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r295289 r295299 2378 2378 - (void)_keyboardDidShow 2379 2379 { 2380 [self _zoomToFocusRectAfterShowingKeyboardIfNeeded]; 2381 2382 #if USE(UICONTEXTMENU) 2383 [_fileUploadPanel repositionContextMenuIfNeeded]; 2384 #endif 2385 } 2386 2387 - (void)_zoomToFocusRectAfterShowingKeyboardIfNeeded 2388 { 2380 2389 if (!_shouldZoomToFocusRectAfterShowingKeyboard) 2381 2390 return; -
trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h
r284558 r295299 45 45 - (void)dismiss; 46 46 47 #if USE(UICONTEXTMENU) 48 - (void)repositionContextMenuIfNeeded; 49 #endif 50 47 51 - (NSArray<NSString *> *)currentAvailableActionTitles; 48 52 - (NSArray<NSString *> *)acceptedTypeIdentifiers; -
trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm
r294882 r295299 40 40 #import "WKStringCF.h" 41 41 #import "WKURLCF.h" 42 #import "WKWebViewInternal.h" 42 43 #import "WebIconUtilities.h" 43 44 #import "WebOpenPanelResultListenerProxy.h" … … 50 51 #import <wtf/OptionSet.h> 51 52 #import <wtf/RetainPtr.h> 53 #import <wtf/SetForScope.h> 52 54 #import <wtf/WeakObjCPtr.h> 53 55 #import <wtf/text/StringView.h> … … 357 359 ALLOW_DEPRECATED_DECLARATIONS_END 358 360 #if USE(UICONTEXTMENU) 361 BOOL _isRepositioningContextMenu; 359 362 RetainPtr<UIContextMenuInteraction> _documentContextMenuInteraction; 360 363 #endif … … 683 686 - (void)contextMenuInteraction:(UIContextMenuInteraction *)interaction willEndForConfiguration:(UIContextMenuConfiguration *)configuration animator:(id<UIContextMenuInteractionAnimating>)animator 684 687 { 688 if (_isRepositioningContextMenu) 689 return; 690 685 691 [animator addCompletion:^{ 686 692 [self removeContextMenuInteraction]; … … 699 705 } 700 706 701 - ( void)ensureContextMenuInteraction707 - (UIContextMenuInteraction *)ensureContextMenuInteraction 702 708 { 703 709 if (!_documentContextMenuInteraction) { … … 706 712 self->_isPresentingSubMenu = NO; 707 713 } 708 } 709 710 #endif 714 return _documentContextMenuInteraction.get(); 715 } 716 717 - (void)repositionContextMenuIfNeeded 718 { 719 if (!_documentContextMenuInteraction) 720 return; 721 722 auto *webView = [_view webView]; 723 if (!webView) 724 return; 725 726 auto inputViewBoundsInWindow = webView->_inputViewBoundsInWindow; 727 if (CGRectIsEmpty(inputViewBoundsInWindow)) 728 return; 729 730 // The exact bounds of the context menu container itself isn't exposed through any UIKit API or SPI, 731 // and would require traversing the view hierarchy in search of internal UIKit views. For now, just 732 // reposition the context menu if its presentation location is covered by the input view. 733 if (!CGRectContainsPoint(inputViewBoundsInWindow, [_view convertPoint:_interactionPoint toView:webView.window])) 734 return; 735 736 SetForScope repositioningContextMenuScope { _isRepositioningContextMenu, YES }; 737 [UIView performWithoutAnimation:^{ 738 [_documentContextMenuInteraction dismissMenu]; 739 [_view presentContextMenu:_documentContextMenuInteraction.get() atLocation:_interactionPoint]; 740 }]; 741 } 742 743 #endif // USE(UICONTEXTMENU) 711 744 712 745 - (void)showFilePickerMenu … … 728 761 // FIXME 49961589: Support picking media with UIImagePickerController 729 762 #if HAVE(UICONTEXTMENU_LOCATION) 730 if (_allowedImagePickerTypes.containsAny({ WKFileUploadPanelImagePickerType::Image, WKFileUploadPanelImagePickerType::Video })) { 731 [self ensureContextMenuInteraction]; 732 [_view presentContextMenu:_documentContextMenuInteraction.get() atLocation:_interactionPoint]; 733 } else // Image and Video types are not accepted so bypass the menu and open the file picker directly. 763 if (_allowedImagePickerTypes.containsAny({ WKFileUploadPanelImagePickerType::Image, WKFileUploadPanelImagePickerType::Video })) 764 [_view presentContextMenu:self.ensureContextMenuInteraction atLocation:_interactionPoint]; 765 else // Image and Video types are not accepted so bypass the menu and open the file picker directly. 734 766 #endif 735 767 [self showFilePickerMenu]; -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r290098 r295299 267 267 readonly attribute boolean isShowingMenu; 268 268 readonly attribute object menuRect; 269 readonly attribute object contextMenuRect; 269 270 object rectForMenuAction(DOMString action); 270 271 undefined chooseMenuAction(DOMString action, object callback); -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r290098 r295299 286 286 virtual JSObjectRef rectForMenuAction(JSStringRef) const { notImplemented(); return nullptr; } 287 287 virtual JSObjectRef menuRect() const { notImplemented(); return nullptr; } 288 virtual JSObjectRef contextMenuRect() const { notImplemented(); return nullptr; } 288 289 virtual bool isShowingContextMenu() const { notImplemented(); return false; } 289 290 -
trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm
r293117 r295299 262 262 - (void)_dismissAllContextMenuInteractions 263 263 { 264 #if PLATFORM(IOS)264 #if USE(UICONTEXTMENU) 265 265 for (id <UIInteraction> interaction in self.contentView.interactions) { 266 if ([interaction isKindOfClass:UIContextMenuInteraction.class]) 267 [(UIContextMenuInteraction *)interaction dismissMenu]; 266 if (auto contextMenuInteraction = dynamic_objc_cast<UIContextMenuInteraction>(interaction)) { 267 [UIView performWithoutAnimation:^{ 268 [contextMenuInteraction dismissMenu]; 269 }]; 270 } 268 271 } 269 272 #endif -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
r288178 r295299 30 30 #import "UIScriptControllerCocoa.h" 31 31 #import <wtf/BlockPtr.h> 32 33 typedef struct CGRect CGRect; 32 34 33 35 namespace WebCore { … … 124 126 bool isShowingPopover() const override; 125 127 JSObjectRef rectForMenuAction(JSStringRef) const override; 128 JSObjectRef contextMenuRect() const override; 126 129 JSObjectRef menuRect() const override; 127 130 bool isDismissingMenu() const override; … … 171 174 void singleTapAtPointWithModifiers(WebCore::FloatPoint location, Vector<String>&& modifierFlags, BlockPtr<void()>&&); 172 175 176 JSObjectRef toObject(CGRect) const; 177 173 178 bool isWebContentFirstResponder() const override; 174 179 }; -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r288178 r295299 1106 1106 return nullptr; 1107 1107 1108 CGRect rectInRootViewCoordinates = [calloutBar convertRect:calloutBar.bounds toView:platformContentView()]; 1109 return m_context->objectFromRect(WebCore::FloatRect(rectInRootViewCoordinates.origin.x, rectInRootViewCoordinates.origin.y, rectInRootViewCoordinates.size.width, rectInRootViewCoordinates.size.height)); 1108 return toObject([calloutBar convertRect:calloutBar.bounds toView:platformContentView()]); 1109 } 1110 1111 JSObjectRef UIScriptControllerIOS::contextMenuRect() const 1112 { 1113 auto *window = webView().window; 1114 auto *contextMenuView = [findAllViewsInHierarchyOfType(window, NSClassFromString(@"_UIContextMenuView")) firstObject]; 1115 if (!contextMenuView) 1116 return nullptr; 1117 1118 return toObject([contextMenuView convertRect:contextMenuView.bounds toView:nil]); 1119 } 1120 1121 JSObjectRef UIScriptControllerIOS::toObject(CGRect rect) const 1122 { 1123 return m_context->objectFromRect(WebCore::FloatRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)); 1110 1124 } 1111 1125
Note:
See TracChangeset
for help on using the changeset viewer.