Changeset 166658 in webkit
- Timestamp:
- Apr 2, 2014 12:51:43 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r166656 r166658 1 2014-04-02 Alice Barraclough <alice.liu@apple.com> 2 3 Adding Objective-C SPI for Find in Page. 4 https://bugs.webkit.org/show_bug.cgi?id=131000 Need an Objective-C API or SPI for Find in Page 5 6 Reviewed by Dan Bernstein. 7 8 Find-on-page SPI added to WKWebView, which funnels the messages through the WebPageProxy. 9 Returning messages are designated by _WKFindDelegate protocol. 10 Also provide FindDelegate access on WKWebView. 11 WebPageProxy gets a new-style API::FindClient. 12 Also had to replicate WKFindOptions as _WKFindOptions in Cocoa SPI. This is unfortunate, but it 13 does follow the pattern of other options & enums related to classes that are SPI-for-now. 14 15 PageClientImplIOS handles setFindIndicator function by forwarding to its WKContentView, 16 but WKContentView _setFindIndicator remains unimplemented for now. 17 18 * UIProcess/API/APIFindClient.h: Added. 19 (API::FindClient::~FindClient): 20 (API::FindClient::didCountStringMatches): 21 (API::FindClient::didFindString): 22 (API::FindClient::didFailToFindString): 23 * UIProcess/API/C/WKPage.cpp: 24 (WKPageSetPageFindClient): 25 * UIProcess/API/Cocoa/WKWebView.mm: 26 (-[WKWebView initWithFrame:configuration:]): 27 (-[WKWebView _findDelegate]): 28 (-[WKWebView _setFindDelegate:]): 29 (toFindOptions): 30 (-[WKWebView _countStringMatches:options:maxCount:]): 31 (-[WKWebView _findString:options:maxCount:]): 32 (-[WKWebView _hideFindUI]): 33 (-[WKWebView _hostForFindUI]): 34 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 35 (NS_OPTIONS): 36 * UIProcess/API/Cocoa/_WKFindDelegate.h: Added. 37 * UIProcess/Cocoa/FindClient.h: Added. 38 * UIProcess/Cocoa/FindClient.mm: Added. 39 (WebKit::FindClient::FindClient): 40 (WebKit::FindClient::delegate): 41 (WebKit::FindClient::setDelegate): 42 (WebKit::FindClient::didCountStringMatches): 43 (WebKit::FindClient::didFindString): 44 (WebKit::FindClient::didFailToFindString): 45 * UIProcess/WebPageProxy.cpp: 46 (WebKit::WebPageProxy::WebPageProxy): 47 (WebKit::WebPageProxy::setFindClient): 48 (WebKit::WebPageProxy::close): 49 (WebKit::WebPageProxy::didCountStringMatches): 50 (WebKit::WebPageProxy::didFindString): 51 (WebKit::WebPageProxy::didFailToFindString): 52 (WebKit::WebPageProxy::initializeFindClient): Deleted. 53 * UIProcess/WebPageProxy.h: 54 (WebKit::WebPageProxy::findClient): 55 * UIProcess/ios/PageClientImplIOS.mm: 56 (WebKit::PageClientImpl::setFindIndicator): 57 * UIProcess/ios/WKContentView.h: 58 * UIProcess/ios/WKContentView.mm: 59 (-[WKContentView _setFindIndicator:WebKit::fadeOut:animate:]): 60 * WebKit2.xcodeproj/project.pbxproj: 61 1 62 2014-04-02 Anders Carlsson <andersca@apple.com> 2 63 -
trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp
r166265 r166658 30 30 #include "APIArray.h" 31 31 #include "APIData.h" 32 #include "APIFindClient.h" 32 33 #include "APILoaderClient.h" 33 34 #include "APIPolicyClient.h" … … 677 678 void WKPageSetPageFindClient(WKPageRef pageRef, const WKPageFindClientBase* wkClient) 678 679 { 679 toImpl(pageRef)->initializeFindClient(wkClient); 680 class FindClient : public API::Client<WKPageFindClientBase>, public API::FindClient { 681 public: 682 explicit FindClient(const WKPageFindClientBase* client) 683 { 684 initialize(client); 685 } 686 687 private: 688 virtual void didFindString(WebPageProxy* page, const String& string, uint32_t matchCount) override 689 { 690 if (!m_client.didFindString) 691 return; 692 693 m_client.didFindString(toAPI(page), toAPI(string.impl()), matchCount, m_client.base.clientInfo); 694 } 695 696 virtual void didFailToFindString(WebPageProxy* page, const String& string) override 697 { 698 if (!m_client.didFailToFindString) 699 return; 700 701 m_client.didFailToFindString(toAPI(page), toAPI(string.impl()), m_client.base.clientInfo); 702 } 703 704 virtual void didCountStringMatches(WebPageProxy* page, const String& string, uint32_t matchCount) override 705 { 706 if (m_client.didCountStringMatches) 707 return; 708 709 m_client.didCountStringMatches(toAPI(page), toAPI(string.impl()), matchCount, m_client.base.clientInfo); 710 } 711 }; 712 713 toImpl(pageRef)->setFindClient(std::make_unique<FindClient>(wkClient)); 680 714 } 681 715 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r166651 r166658 29 29 #if WK_API_ENABLED 30 30 31 #import "FindClient.h" 31 32 #import "NavigationState.h" 32 33 #import "RemoteLayerTreeTransaction.h" … … 54 55 #import "WebPageProxy.h" 55 56 #import "WebProcessProxy.h" 57 #import "_WKFindDelegate.h" 56 58 #import "_WKRemoteObjectRegistryInternal.h" 57 59 #import "_WKUserContentController.h" … … 198 200 _page->setPolicyClient(_navigationState->createPolicyClient()); 199 201 _page->setLoaderClient(_navigationState->createLoaderClient()); 200 201 202 _page->setUIClient(std::make_unique<WebKit::UIClient>(self)); 202 203 _page->setFindClient(std::make_unique<WebKit::FindClient>(self)); 203 204 return self; 204 205 } … … 1083 1084 } 1084 1085 1086 - (id <_WKFindDelegate>)_findDelegate 1087 { 1088 return [static_cast<WebKit::FindClient&>(_page->findClient()).delegate().leakRef() autorelease]; 1089 } 1090 1091 - (void)_setFindDelegate:(id<_WKFindDelegate>)findDelegate 1092 { 1093 static_cast<WebKit::FindClient&>(_page->findClient()).setDelegate(findDelegate); 1094 } 1095 1096 static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions) 1097 { 1098 unsigned findOptions = 0; 1099 1100 if (wkFindOptions & _WKFindOptionsCaseInsensitive) 1101 findOptions |= WebKit::FindOptionsCaseInsensitive; 1102 if (wkFindOptions & _WKFindOptionsAtWordStarts) 1103 findOptions |= WebKit::FindOptionsAtWordStarts; 1104 if (wkFindOptions & _WKFindOptionsTreatMedialCapitalAsWordStart) 1105 findOptions |= WebKit::FindOptionsTreatMedialCapitalAsWordStart; 1106 if (wkFindOptions & _WKFindOptionsBackwards) 1107 findOptions |= WebKit::FindOptionsBackwards; 1108 if (wkFindOptions & _WKFindOptionsWrapAround) 1109 findOptions |= WebKit::FindOptionsWrapAround; 1110 if (wkFindOptions & _WKFindOptionsShowOverlay) 1111 findOptions |= WebKit::FindOptionsShowOverlay; 1112 if (wkFindOptions & _WKFindOptionsShowFindIndicator) 1113 findOptions |= WebKit::FindOptionsShowFindIndicator; 1114 if (wkFindOptions & _WKFindOptionsShowHighlight) 1115 findOptions |= WebKit::FindOptionsShowHighlight; 1116 1117 return static_cast<WebKit::FindOptions>(findOptions); 1118 } 1119 1120 - (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount 1121 { 1122 _page->countStringMatches(string, toFindOptions(options), maxCount); 1123 } 1124 1125 - (void)_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount 1126 { 1127 _page->findString(string, toFindOptions(options), maxCount); 1128 } 1129 1130 - (void)_hideFindUI 1131 { 1132 _page->hideFindUI(); 1133 } 1134 1085 1135 #pragma mark iOS-specific methods 1086 1136 … … 1177 1227 } 1178 1228 1229 - (UIView *)_viewForFindUI 1230 { 1231 return [self viewForZoomingInScrollView:[self scrollView]]; 1232 } 1233 1179 1234 - (BOOL)_isDisplayingPDF 1180 1235 { -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r166629 r166658 41 41 }; 42 42 43 typedef NS_OPTIONS(NSUInteger, _WKFindOptions) { 44 _WKFindOptionsCaseInsensitive = 1 << 0, 45 _WKFindOptionsAtWordStarts = 1 << 1, 46 _WKFindOptionsTreatMedialCapitalAsWordStart = 1 << 2, 47 _WKFindOptionsBackwards = 1 << 3, 48 _WKFindOptionsWrapAround = 1 << 4, 49 _WKFindOptionsShowOverlay = 1 << 5, 50 _WKFindOptionsShowFindIndicator = 1 << 6, 51 _WKFindOptionsShowHighlight = 1 << 7, 52 }; 53 43 54 @class WKBrowsingContextHandle; 44 55 @class _WKRemoteObjectRegistry; 45 56 46 57 @protocol WKHistoryDelegatePrivate; 58 @protocol _WKFindDelegate; 47 59 @protocol _WKScriptMessageHandler; 48 60 … … 98 110 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler; 99 111 112 - (UIView *)_viewForFindUI; 113 100 114 // FIXME: Remove this once nobody uses it. 101 115 @property (nonatomic, readonly) NSURL *activeURL; … … 122 136 @property (nonatomic, setter=_setPageZoomFactor:) double _pageZoomFactor; 123 137 138 @property (nonatomic, weak, setter=_setFindDelegate:) id <_WKFindDelegate> _findDelegate; 139 - (void)_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount; 140 - (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount; 141 - (void)_hideFindUI; 142 124 143 @end 125 144 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r166518 r166658 29 29 30 30 #include "APIArray.h" 31 #include "APIFindClient.h" 31 32 #include "APILoaderClient.h" 32 33 #include "APIPolicyClient.h" … … 258 259 , m_policyClient(std::make_unique<API::PolicyClient>()) 259 260 , m_uiClient(std::make_unique<API::UIClient>()) 261 , m_findClient(std::make_unique<API::FindClient>()) 260 262 , m_process(process) 261 263 , m_pageGroup(*configuration.pageGroup) … … 474 476 } 475 477 476 void WebPageProxy::initializeFindClient(const WKPageFindClientBase* client) 477 { 478 m_findClient.initialize(client); 478 void WebPageProxy::setFindClient(std::unique_ptr<API::FindClient> findClient) 479 { 480 if (!findClient) { 481 m_findClient = std::make_unique<API::FindClient>(); 482 return; 483 } 484 485 m_findClient = std::move(findClient); 479 486 } 480 487 … … 607 614 m_uiPopupMenuClient.initialize(0); 608 615 #endif 609 m_findClient .initialize(0);616 m_findClient = std::make_unique<API::FindClient>(); 610 617 m_findMatchesClient.initialize(0); 611 618 #if ENABLE(CONTEXT_MENUS) … … 3192 3199 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount) 3193 3200 { 3194 m_findClient .didCountStringMatches(this, string, matchCount);3201 m_findClient->didCountStringMatches(this, string, matchCount); 3195 3202 } 3196 3203 … … 3208 3215 void WebPageProxy::didFindString(const String& string, uint32_t matchCount) 3209 3216 { 3210 m_findClient .didFindString(this, string, matchCount);3217 m_findClient->didFindString(this, string, matchCount); 3211 3218 } 3212 3219 … … 3231 3238 void WebPageProxy::didFailToFindString(const String& string) 3232 3239 { 3233 m_findClient .didFailToFindString(this, string);3240 m_findClient->didFailToFindString(this, string); 3234 3241 } 3235 3242 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r166466 r166658 105 105 106 106 namespace API { 107 class FindClient; 107 108 class LoaderClient; 108 109 class PolicyClient; … … 477 478 void initializeContextMenuClient(const WKPageContextMenuClientBase*); 478 479 #endif 479 void initializeFindClient(const WKPageFindClientBase*); 480 API::FindClient& findClient() { return *m_findClient; } 481 void setFindClient(std::unique_ptr<API::FindClient>); 480 482 void initializeFindMatchesClient(const WKPageFindMatchesClientBase*); 481 483 void initializeFormClient(const WKPageFormClientBase*); … … 1374 1376 WebUIPopupMenuClient m_uiPopupMenuClient; 1375 1377 #endif 1376 WebFindClientm_findClient;1378 std::unique_ptr<API::FindClient> m_findClient; 1377 1379 WebFindMatchesClient m_findMatchesClient; 1378 1380 #if ENABLE(CONTEXT_MENUS) -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r166466 r166658 32 32 #import "DataReference.h" 33 33 #import "DownloadProxy.h" 34 #import "FindIndicator.h" 34 35 #import "NativeWebKeyboardEvent.h" 35 36 #import "InteractionInformationAtPosition.h" … … 304 305 } 305 306 306 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> , bool, bool)307 { 308 notImplemented();307 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate) 308 { 309 [m_contentView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate]; 309 310 } 310 311 -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.h
r166257 r166658 36 36 namespace WebKit { 37 37 class DrawingAreaProxy; 38 class FindIndicator; 38 39 class GeolocationPermissionRequestProxy; 39 40 class RemoteLayerTreeTransaction; … … 85 86 - (void)_zoomOutWithOrigin:(CGPoint)origin; 86 87 88 - (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate; 89 87 90 @end -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm
r166380 r166658 48 48 #import "WebKitSystemInterfaceIOS.h" 49 49 #import <WebCore/FrameView.h> 50 #import <WebCore/NotImplemented.h> 50 51 #import <UIKit/UIWindow_Private.h> 51 52 #import <wtf/CurrentTime.h> … … 485 486 } 486 487 488 - (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate 489 { 490 notImplemented(); 491 } 492 487 493 @end 488 494 -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r166617 r166658 48 48 49 49 /* Begin PBXBuildFile section */ 50 005D158F18E4C4EB00734619 /* _WKFindDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 005D158E18E4C4EB00734619 /* _WKFindDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 51 00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661518E24CBA00CE1F88 /* APIFindClient.h */; }; 52 00B9661918E25AE100CE1F88 /* FindClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 00B9661718E25AE100CE1F88 /* FindClient.mm */; }; 53 00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661818E25AE100CE1F88 /* FindClient.h */; }; 50 54 0F0C365818C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F0C365718C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm */; }; 51 55 0F0C365A18C0555800F607D7 /* LayerRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F0C365918C0555800F607D7 /* LayerRepresentation.h */; }; … … 1789 1793 1790 1794 /* Begin PBXFileReference section */ 1795 005D158E18E4C4EB00734619 /* _WKFindDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFindDelegate.h; sourceTree = "<group>"; }; 1796 00B9661518E24CBA00CE1F88 /* APIFindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFindClient.h; sourceTree = "<group>"; }; 1797 00B9661718E25AE100CE1F88 /* FindClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindClient.mm; sourceTree = "<group>"; }; 1798 00B9661818E25AE100CE1F88 /* FindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindClient.h; sourceTree = "<group>"; }; 1791 1799 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; 1792 1800 089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; … … 4247 4255 A1DF631118E0B7C8003A3E2A /* DownloadClient.h */, 4248 4256 A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */, 4257 00B9661818E25AE100CE1F88 /* FindClient.h */, 4258 00B9661718E25AE100CE1F88 /* FindClient.mm */, 4249 4259 1A422F8D18B29C6400D8CD96 /* HistoryClient.h */, 4250 4260 1A422F8C18B29C6400D8CD96 /* HistoryClient.mm */, … … 4631 4641 A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */, 4632 4642 A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */, 4643 005D158E18E4C4EB00734619 /* _WKFindDelegate.h */, 4633 4644 A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */, 4634 4645 379A873818BBFE0F00588AF2 /* _WKElementAction.h */, … … 5495 5506 BC111B47112F616900337BAB /* mac */, 5496 5507 1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */, 5508 00B9661518E24CBA00CE1F88 /* APIFindClient.h */, 5497 5509 1A6637D618B2831F00C0BCF3 /* APIHistoryClient.h */, 5498 5510 1A2464F21891E45100234C5B /* APILoaderClient.h */, … … 6913 6925 370F34A71829CFF3009027C8 /* WKBrowsingContextHistoryDelegate.h in Headers */, 6914 6926 1AF05D8714688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h in Headers */, 6927 00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */, 6915 6928 1A64245E12DE29A100CAAE2C /* UpdateInfo.h in Headers */, 6916 6929 BCB0B0E012305AB100B1341E /* UserMessageCoders.h in Headers */, … … 6956 6969 75E749EC180DBB9800088BA6 /* WebOriginDataManagerProxyMessages.h in Headers */, 6957 6970 512935D81288D19400A4B695 /* WebContextMenuItem.h in Headers */, 6971 00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */, 6958 6972 510FBB9B1288C95E00AFFDF4 /* WebContextMenuItemData.h in Headers */, 6959 6973 51ACBB82127A8BAD00D203B9 /* WebContextMenuProxy.h in Headers */, … … 7254 7268 378E1A40181EDA010031007A /* WKObject.h in Headers */, 7255 7269 BC857FE612B843D800EDEB2E /* WKOpenPanelParameters.h in Headers */, 7270 005D158F18E4C4EB00734619 /* _WKFindDelegate.h in Headers */, 7256 7271 BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */, 7257 7272 BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */, … … 8193 8208 1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */, 8194 8209 1A6FBD2911E69BC200DB1371 /* NetscapePlugin.cpp in Sources */, 8210 00B9661918E25AE100CE1F88 /* FindClient.mm in Sources */, 8195 8211 1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */, 8196 8212 1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.