WebKit Bugzilla
Attachment 358242 Details for
Bug 193034
: Add support for using the current text selection as the find string on iOS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Rename FindInPage to Find
bug-193034-20190102190830.patch (text/plain), 45.92 KB, created by
Wenson Hsieh
on 2019-01-02 19:08:31 PST
(
hide
)
Description:
Rename FindInPage to Find
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-01-02 19:08:31 PST
Size:
45.92 KB
patch
obsolete
>Subversion Revision: 239574 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index df7dcc11902702f0755a0c93e4b84eb86d1eb95b..03ec5ce0240cf4941688ab89f591d58da00cbc00 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,40 @@ >+2018-12-29 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add support for using the current text selection as the find string on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=193034 >+ <rdar://problem/45138739> >+ >+ Reviewed by Tim Horton. >+ >+ Add support for "TakeFindStringFromSelection" on iOS. Unlike macOS, iOS does not have a notion of a "find >+ pasteboard" like macOS; instead, we handle this editing command by sending the selection string to the UI >+ process, where it is exposed via WebKit SPI so that clients that present find-in-page UI (i.e. MobileSafari) are >+ able to trigger find-in-page with this string. >+ >+ Test: WebKit.UseSelectionAsFindString >+ >+ * editing/Editor.cpp: >+ (WebCore::Editor::canCopyExcludingStandaloneImages const): >+ >+ Make this helper function cross-platform. >+ >+ * editing/Editor.h: >+ * editing/EditorCommand.cpp: >+ (WebCore::createCommandMap): >+ * editing/cocoa/EditorCocoa.mm: >+ (WebCore::Editor::takeFindStringFromSelection): >+ >+ Move this from EditorMac to EditorCocoa, and implement it on iOS by calling into the editor client to update the >+ find string (see WebKit/ChangeLog for more details). >+ >+ * editing/mac/EditorMac.mm: >+ (WebCore::Editor::canCopyExcludingStandaloneImages): Deleted. >+ (WebCore::Editor::takeFindStringFromSelection): Deleted. >+ * loader/EmptyClients.cpp: >+ * page/EditorClient.h: >+ >+ Add a new editor client method to send the string for find-in-page to the UI process. >+ > 2019-01-02 Simon Fraser <simon.fraser@apple.com> > > Support css-color-4 rgb functions >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 3207b95dd997da17c35baaddc73c1185ffd98b4f..4ad7660f634471aa496bfc1a4800a5cda658e3da 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,63 @@ >+2018-12-29 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add support for using the current text selection as the find string on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=193034 >+ <rdar://problem/45138739> >+ >+ Reviewed by Tim Horton. >+ >+ * SourcesCocoa.txt: >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView _takeFindStringFromSelection:]): >+ >+ Provides a way to set the find string on iOS and macOS (an aside: takeFindStringFromSelection: already exists on >+ macOS, but there is no equivalent protocol method on iOS, so this new SPI acts as a cross-platform way for >+ WebKit clients to take the find string from the selection across all Cocoa platforms). >+ >+ (+[WKWebView _stringForFind]): >+ (+[WKWebView _setStringForFind:]): >+ >+ Call into find-in-page helper functions. >+ >+ (-[WKWebView _findString:options:maxCount:]): >+ >+ On iOS, additionally update the find-in-page string when exercising the _findString:options:maxCount: SPI. This >+ mirrors macOS behavior of updating the find pasteboard every time the find string changes; however, on macOS, >+ this is implemented by the platform (in AppKit), whereas there's no platform find pasteboard on iOS, let alone >+ logic to update it in UIKit. As such, we directly drive updates to the find string within WebKit. >+ >+ * UIProcess/API/Cocoa/WKWebViewPrivate.h: >+ >+ Add some new cross-platform find-in-page SPI. See above for more details. >+ >+ * UIProcess/Cocoa/GlobalFindInPageState.h: Added. >+ * UIProcess/Cocoa/GlobalFindInPageState.mm: Added. >+ (WebKit::findPasteboard): >+ (WebKit::globalStringForFind): >+ >+ Fetch the string to use when finding text in the page. On macOS, this accesses the AppKit find pasteboard; on >+ iOS, this instead returns the current global find string. >+ >+ (WebKit::updateStringForFind): >+ >+ Sets the global find string. Uses the find pasteboard on macOS, and sets the global find string on iOS. >+ >+ (WebKit::stringForFind): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebPageProxy.messages.in: >+ >+ Add plumbing to allow WebEditorClient to deliver the update the global find string in the UI process. >+ >+ * UIProcess/ios/WebPageProxyIOS.mm: >+ (WebKit::WebPageProxy::updateStringForFind): >+ * WebKit.xcodeproj/project.pbxproj: >+ * WebProcess/WebCoreSupport/WebEditorClient.h: >+ * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm: >+ (WebKit::WebEditorClient::updateStringForFind): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::updateStringForFind): >+ > 2019-01-02 Wenson Hsieh <wenson_hsieh@apple.com> > > REGRESSION (r239441): [iOS] Selection UI sometimes doesn't change after tapping "select all" in the callout bar >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 3ebfcc8692b7ef922c548d1a5eaa49f95edd7dfc..78258fe3d56cccc7557dc848627cd14f5051959a 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,15 @@ >+2018-12-29 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add support for using the current text selection as the find string on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=193034 >+ <rdar://problem/45138739> >+ >+ Reviewed by Tim Horton. >+ >+ Add a method stub for WebKitLegacy. >+ >+ * WebCoreSupport/WebEditorClient.h: >+ > 2019-01-01 Jeff Miller <jeffm@apple.com> > > Update user-visible copyright strings to include 2019 >diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp >index a5e8584f4ae8772314f63f3417bc0cd6e46176fd..8d17137bfd5476bceb4e9bd72e370fa4f538160d 100644 >--- a/Source/WebCore/editing/Editor.cpp >+++ b/Source/WebCore/editing/Editor.cpp >@@ -4256,4 +4256,10 @@ RefPtr<HTMLImageElement> Editor::insertEditableImage() > return InsertEditableImageCommand::insertEditableImage(document()); > } > >+bool Editor::canCopyExcludingStandaloneImages() const >+{ >+ auto& selection = m_frame.selection().selection(); >+ return selection.isRange() && !selection.isInPasswordField(); >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/editing/Editor.h b/Source/WebCore/editing/Editor.h >index 7cad22098526006f9cc89c1ce0e279422ec7385f..05cc1b82aeac140b40930df6f37ea54955c63f46 100644 >--- a/Source/WebCore/editing/Editor.h >+++ b/Source/WebCore/editing/Editor.h >@@ -485,9 +485,8 @@ public: > #if PLATFORM(COCOA) > WEBCORE_EXPORT String stringSelectionForPasteboard(); > String stringSelectionForPasteboardWithImageAltText(); >-#if !PLATFORM(IOS_FAMILY) >- bool canCopyExcludingStandaloneImages(); > void takeFindStringFromSelection(); >+#if !PLATFORM(IOS_FAMILY) > WEBCORE_EXPORT void readSelectionFromPasteboard(const String& pasteboardName); > WEBCORE_EXPORT void replaceNodeFromPasteboard(Node*, const String& pasteboardName); > WEBCORE_EXPORT RefPtr<SharedBuffer> dataSelectionForPasteboard(const String& pasteboardName); >@@ -495,6 +494,8 @@ public: > WEBCORE_EXPORT void replaceSelectionWithAttributedString(NSAttributedString *, MailBlockquoteHandling = MailBlockquoteHandling::RespectBlockquote); > #endif > >+ bool canCopyExcludingStandaloneImages() const; >+ > String clientReplacementURLForResource(Ref<SharedBuffer>&& resourceData, const String& mimeType); > > #if !PLATFORM(WIN) >diff --git a/Source/WebCore/editing/EditorCommand.cpp b/Source/WebCore/editing/EditorCommand.cpp >index 9fdac1d6119538ace3d4bf8c0ee3179f47c8bd31..0b3bbb9be69569eb82cf054dc24c715e7e4ad438 100644 >--- a/Source/WebCore/editing/EditorCommand.cpp >+++ b/Source/WebCore/editing/EditorCommand.cpp >@@ -1102,13 +1102,15 @@ static bool executeSwapWithMark(Frame& frame, Event*, EditorCommandSource, const > return true; > } > >-#if PLATFORM(MAC) >+#if PLATFORM(COCOA) >+ > static bool executeTakeFindStringFromSelection(Frame& frame, Event*, EditorCommandSource, const String&) > { > frame.editor().takeFindStringFromSelection(); > return true; > } >-#endif >+ >+#endif // PLATFORM(COCOA) > > static bool executeToggleBold(Frame& frame, Event*, EditorCommandSource source, const String&) > { >@@ -1367,12 +1369,14 @@ static bool enabledRedo(Frame& frame, Event*, EditorCommandSource) > return frame.editor().canRedo(); > } > >-#if PLATFORM(MAC) >+#if PLATFORM(COCOA) >+ > static bool enabledTakeFindStringFromSelection(Frame& frame, Event*, EditorCommandSource) > { > return frame.editor().canCopyExcludingStandaloneImages(); > } >-#endif >+ >+#endif // PLATFORM(COCOA) > > static bool enabledUndo(Frame& frame, Event*, EditorCommandSource) > { >@@ -1718,7 +1722,7 @@ static const CommandMap& createCommandMap() > { "PasteGlobalSelection", { executePasteGlobalSelection, supportedFromMenuOrKeyBinding, enabledPaste, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } }, > #endif > >-#if PLATFORM(MAC) >+#if PLATFORM(COCOA) > { "TakeFindStringFromSelection", { executeTakeFindStringFromSelection, supportedFromMenuOrKeyBinding, enabledTakeFindStringFromSelection, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, > #endif > }; >diff --git a/Source/WebCore/editing/cocoa/EditorCocoa.mm b/Source/WebCore/editing/cocoa/EditorCocoa.mm >index 5de716fa1ac4a9b69c85f0966ba293bfabb26bfc..949b1a958772f68a17995bad444eaf080b05f24e 100644 >--- a/Source/WebCore/editing/cocoa/EditorCocoa.mm >+++ b/Source/WebCore/editing/cocoa/EditorCocoa.mm >@@ -45,8 +45,11 @@ > #import "HTMLConverter.h" > #import "HTMLImageElement.h" > #import "HTMLSpanElement.h" >+#import "LegacyNSPasteboardTypes.h" > #import "LegacyWebArchive.h" > #import "Pasteboard.h" >+#import "PasteboardStrategy.h" >+#import "PlatformStrategies.h" > #import "RenderElement.h" > #import "RenderStyle.h" > #import "Settings.h" >@@ -55,6 +58,7 @@ > #import "markup.h" > #import <pal/spi/cocoa/NSAttributedStringSPI.h> > #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> >+#import <pal/system/Sound.h> > #import <wtf/BlockObjCExceptions.h> > #import <wtf/cocoa/NSURLExtras.h> > >@@ -223,4 +227,28 @@ RefPtr<DocumentFragment> Editor::webContentFromPasteboard(Pasteboard& pasteboard > return WTFMove(reader.fragment); > } > >+void Editor::takeFindStringFromSelection() >+{ >+ if (!canCopyExcludingStandaloneImages()) { >+ PAL::systemBeep(); >+ return; >+ } >+ >+ auto stringFromSelection = m_frame.displayStringModifiedByEncoding(selectedTextForDataTransfer()); >+#if PLATFORM(MAC) >+ Vector<String> types; >+ types.append(String(legacyStringPasteboardType())); >+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN >+ platformStrategies()->pasteboardStrategy()->setTypes(types, NSFindPboard); >+ platformStrategies()->pasteboardStrategy()->setStringForType(WTFMove(stringFromSelection), legacyStringPasteboardType(), NSFindPboard); >+ ALLOW_DEPRECATED_DECLARATIONS_END >+#else >+ if (auto* client = this->client()) { >+ // Since the find pasteboard doesn't exist on iOS, WebKit maintains its own notion of the latest find string, >+ // which SPI clients may respect when presenting find-in-page UI. >+ client->updateStringForFind(stringFromSelection); >+ } >+#endif >+} >+ > } >diff --git a/Source/WebCore/editing/mac/EditorMac.mm b/Source/WebCore/editing/mac/EditorMac.mm >index 3fe6f4e7e452125b51fa1fc7d48061c2c46bb77d..6971f0097438beb4493cf210d255d071d2608b0d 100644 >--- a/Source/WebCore/editing/mac/EditorMac.mm >+++ b/Source/WebCore/editing/mac/EditorMac.mm >@@ -55,7 +55,6 @@ > #import "WebNSAttributedStringExtras.h" > #import "markup.h" > #import <AppKit/AppKit.h> >-#import <pal/system/Sound.h> > #import <wtf/cocoa/NSURLExtras.h> > > namespace WebCore { >@@ -98,27 +97,6 @@ void Editor::pasteWithPasteboard(Pasteboard* pasteboard, OptionSet<PasteOption> > client()->setInsertionPasteboard(String()); > } > >-bool Editor::canCopyExcludingStandaloneImages() >-{ >- const VisibleSelection& selection = m_frame.selection().selection(); >- return selection.isRange() && !selection.isInPasswordField(); >-} >- >-void Editor::takeFindStringFromSelection() >-{ >- if (!canCopyExcludingStandaloneImages()) { >- PAL::systemBeep(); >- return; >- } >- >- Vector<String> types; >- types.append(String(legacyStringPasteboardType())); >- ALLOW_DEPRECATED_DECLARATIONS_BEGIN >- platformStrategies()->pasteboardStrategy()->setTypes(types, NSFindPboard); >- platformStrategies()->pasteboardStrategy()->setStringForType(m_frame.displayStringModifiedByEncoding(selectedTextForDataTransfer()), legacyStringPasteboardType(), NSFindPboard); >- ALLOW_DEPRECATED_DECLARATIONS_END >-} >- > void Editor::readSelectionFromPasteboard(const String& pasteboardName) > { > Pasteboard pasteboard(pasteboardName); >diff --git a/Source/WebCore/loader/EmptyClients.cpp b/Source/WebCore/loader/EmptyClients.cpp >index a28ec68cd39d44514ce7266a8378bf133b6cabf2..492524b23eed81fedf68ed65b7ae8887b55ac364 100644 >--- a/Source/WebCore/loader/EmptyClients.cpp >+++ b/Source/WebCore/loader/EmptyClients.cpp >@@ -215,6 +215,7 @@ private: > int getPasteboardItemsCount() final { return 0; } > RefPtr<DocumentFragment> documentFragmentFromDelegate(int) final { return nullptr; } > bool performsTwoStepPaste(DocumentFragment*) final { return false; } >+ void updateStringForFind(const String&) final { } > #endif > > bool performTwoStepDrop(DocumentFragment&, Range&, bool) final { return false; } >diff --git a/Source/WebCore/page/EditorClient.h b/Source/WebCore/page/EditorClient.h >index a65d80cea0f27daf4bfd28a5ad08ea0a64c4648b..37bf1823a98c2d9e52f3d02cbf5bcffaee358c44 100644 >--- a/Source/WebCore/page/EditorClient.h >+++ b/Source/WebCore/page/EditorClient.h >@@ -134,6 +134,7 @@ public: > virtual int getPasteboardItemsCount() = 0; > virtual RefPtr<DocumentFragment> documentFragmentFromDelegate(int index) = 0; > virtual bool performsTwoStepPaste(DocumentFragment*) = 0; >+ virtual void updateStringForFind(const String&) = 0; > #endif > > #if PLATFORM(COCOA) >diff --git a/Source/WebKit/SourcesCocoa.txt b/Source/WebKit/SourcesCocoa.txt >index 8459750da34a6274adca8949015698909de55eb6..56f3c45c4119e7dcfc8db4b09e53d2b005801e7a 100644 >--- a/Source/WebKit/SourcesCocoa.txt >+++ b/Source/WebKit/SourcesCocoa.txt >@@ -317,6 +317,7 @@ UIProcess/Cocoa/DiagnosticLoggingClient.mm > UIProcess/Cocoa/DownloadClient.mm > UIProcess/Cocoa/FindClient.mm > UIProcess/Cocoa/FullscreenClient.mm >+UIProcess/Cocoa/GlobalFindInPageState.mm > UIProcess/Cocoa/IconLoadingDelegate.mm > UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm > UIProcess/Cocoa/NavigationState.mm >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index 6d893965eb345cb6813dfe7f0c64c4d321b6da6b..3c5bebf27b42fb9456fedd0e9ae133e75bda6dc9 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -37,6 +37,7 @@ > #import "FindClient.h" > #import "FrontBoardServicesSPI.h" > #import "FullscreenClient.h" >+#import "GlobalFindInPageState.h" > #import "IconLoadingDelegate.h" > #import "LegacySessionStateCoding.h" > #import "Logging.h" >@@ -4442,6 +4443,25 @@ - (void)_setEditable:(BOOL)editable > #endif > } > >+- (void)_takeFindStringFromSelection:(id)sender >+{ >+#if PLATFORM(MAC) >+ [self takeFindStringFromSelection:sender]; >+#else >+ _page->executeEditCommand("TakeFindStringFromSelection"_s); >+#endif >+} >+ >++ (NSString *)_stringForFind >+{ >+ return WebKit::stringForFind(); >+} >+ >++ (void)_setStringForFind:(NSString *)findString >+{ >+ WebKit::updateStringForFind(findString); >+} >+ > - (_WKRemoteObjectRegistry *)_remoteObjectRegistry > { > #if PLATFORM(MAC) >@@ -5177,6 +5197,11 @@ - (void)_countStringMatches:(NSString *)string options:(_WKFindOptions)options m > - (void)_findString:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount > { > #if PLATFORM(IOS_FAMILY) >+ // While AppKit contains logic in NSBarTextFinder to automatically update the find pasteboard >+ // when the find string changes, this (along with the find pasteboard itself) are both missing >+ // from iOS; thus, on iOS, we update the current find-in-page string here. >+ WebKit::updateStringForFind(string); >+ > if (_customContentView) { > [_customContentView web_findString:string options:options maxCount:maxCount]; > return; >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >index 88b5635be8fe6a0bb2e5d3cf62c7bf62f6c786bd..e709409fb4a66834f5cb2fa3967a393af5986050 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h >@@ -215,6 +215,9 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) { > - (IBAction)_changeListType:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (IBAction)_pasteAsQuotation:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > - (IBAction)_pasteAndMatchStyle:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+- (IBAction)_takeFindStringFromSelection:(id)sender WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); >+ >+@property (class, nonatomic, copy, setter=_setStringForFind:) NSString *_stringForFind WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > #if TARGET_OS_IPHONE > >diff --git a/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.h b/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.h >new file mode 100644 >index 0000000000000000000000000000000000000000..feaa58171deeac67f2f7f7ea83d75e6f652cf8b5 >--- /dev/null >+++ b/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.h >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if PLATFORM(COCOA) >+ >+namespace WTF { >+class String; >+} >+ >+namespace WebKit { >+ >+void updateStringForFind(const WTF::String&); >+WTF::String stringForFind(); >+ >+} // namespace WebKit >+ >+#endif // PLATFORM(COCOA) >diff --git a/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.mm b/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..3ff69eecdaacedb713f35bee8eaa2d9d860325f0 >--- /dev/null >+++ b/Source/WebKit/UIProcess/Cocoa/GlobalFindInPageState.mm >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "GlobalFindInPageState.h" >+ >+#import <wtf/text/WTFString.h> >+ >+#if PLATFORM(MAC) >+#import <AppKit/NSPasteboard.h> >+#import <WebCore/LegacyNSPasteboardTypes.h> >+#endif >+ >+namespace WebKit { >+ >+#if PLATFORM(MAC) >+ >+static NSPasteboard *findPasteboard() >+{ >+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN >+ return [NSPasteboard pasteboardWithName:NSFindPboard]; >+ ALLOW_DEPRECATED_DECLARATIONS_END >+} >+ >+#else >+ >+static String& globalStringForFind() >+{ >+ static NeverDestroyed<String> string; >+ return string.get(); >+} >+ >+#endif >+ >+void updateStringForFind(const String& string) >+{ >+#if PLATFORM(MAC) >+ [findPasteboard() setString:string forType:WebCore::legacyStringPasteboardType()]; >+#else >+ globalStringForFind() = string; >+#endif >+} >+ >+String stringForFind() >+{ >+#if PLATFORM(MAC) >+ return [findPasteboard() stringForType:WebCore::legacyStringPasteboardType()]; >+#else >+ return globalStringForFind(); >+#endif >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 01bea50d4f2f281903dd61f9cfe408dfcc02b3ad..52834e6d6ef8c5a4d41edb778bb3a16afeba9fa8 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1720,6 +1720,8 @@ private: > void interpretKeyEvent(const EditorState&, bool isCharEvent, bool& handled); > void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&); > void selectionRectsCallback(const Vector<WebCore::SelectionRect>&, CallbackID); >+ >+ void updateStringForFind(const String&); > #endif > #if PLATFORM(GTK) > void printFinishedCallback(const WebCore::ResourceError&, CallbackID); >diff --git a/Source/WebKit/UIProcess/WebPageProxy.messages.in b/Source/WebKit/UIProcess/WebPageProxy.messages.in >index 1e4518f71c41fd1e628886fc03e3512f018aa1c9..cf40fdcb0e5d1ed0e176db296c230313ecbdc9b7 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.messages.in >+++ b/Source/WebKit/UIProcess/WebPageProxy.messages.in >@@ -416,6 +416,8 @@ messages -> WebPageProxy { > > EnableInspectorNodeSearch() > DisableInspectorNodeSearch() >+ >+ UpdateStringForFind(String findString) > #endif > > DidChangeInspectorFrontendCount(uint64_t count) >diff --git a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >index f6d304b81061b5ad418806bd89d6b767af4dbbc2..d33263d547157aa5f3971be89cd99091fd002dea 100644 >--- a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >+++ b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >@@ -31,6 +31,7 @@ > #import "APIUIClient.h" > #import "DataReference.h" > #import "EditingRange.h" >+#import "GlobalFindInPageState.h" > #import "InteractionInformationAtPosition.h" > #import "Logging.h" > #import "NativeWebKeyboardEvent.h" >@@ -226,6 +227,14 @@ void WebPageProxy::resendLastVisibleContentRects() > m_process->send(Messages::ViewUpdateDispatcher::VisibleContentRectUpdate(m_pageID, m_lastVisibleContentRectUpdate), 0); > } > >+void WebPageProxy::updateStringForFind(const String& string) >+{ >+ if (!isValid()) >+ return; >+ >+ WebKit::updateStringForFind(string); >+} >+ > static inline float adjustedUnexposedEdge(float documentEdge, float exposedRectEdge, float factor) > { > if (exposedRectEdge < documentEdge) >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 223a7bf8fb6e034c6ab97fc5672bb1933f6cfb39..743d012853725c8ca9e7b5d00bcbd5d3f44da93b 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -75,9 +75,9 @@ > 005D158F18E4C4EB00734619 /* _WKFindDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 005D158E18E4C4EB00734619 /* _WKFindDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661518E24CBA00CE1F88 /* APIFindClient.h */; }; > 00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661818E25AE100CE1F88 /* FindClient.h */; }; >+ 07297F9F1C17AA1A015F0735 /* PersistencyUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 07321F9D1C17BBEA223F0735 /* PersistencyUtils.h */; }; > 07297F9F1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297F9D1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h */; }; > 07297F9F1C17BBEA015F0735 /* DeviceIdHashSaltStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */; }; >- 07297F9F1C17AA1A015F0735 /* PersistencyUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 07321F9D1C17BBEA223F0735 /* PersistencyUtils.h */; }; > 07297FA31C186ADB003F0735 /* WKUserMediaPermissionCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297FA11C186ADB003F0735 /* WKUserMediaPermissionCheck.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 074E75FE1DF2211900D318EC /* UserMediaProcessManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 074E75FB1DF1FD1300D318EC /* UserMediaProcessManager.h */; }; > 076E884E1A13CADF005E90FC /* APIContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */; }; >@@ -1039,8 +1039,8 @@ > 57DCEDC3214F114C0016B847 /* MockLocalService.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDC1214F114C0016B847 /* MockLocalService.h */; }; > 57DCEDC7214F18300016B847 /* MockLocalConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDC5214F18300016B847 /* MockLocalConnection.h */; }; > 57DCEDCB214F4E420016B847 /* MockAuthenticatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCEDC9214F4E420016B847 /* MockAuthenticatorManager.h */; }; >- 58E977DF21C49A00005D92A6 /* NetworkHTTPSUpgradeChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 58E977DD21C49A00005D92A6 /* NetworkHTTPSUpgradeChecker.h */; }; > 587743A621C30BBE00AE9084 /* HTTPSUpgradeList.db in Resources */ = {isa = PBXBuildFile; fileRef = 587743A421C30AD800AE9084 /* HTTPSUpgradeList.db */; }; >+ 58E977DF21C49A00005D92A6 /* NetworkHTTPSUpgradeChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 58E977DD21C49A00005D92A6 /* NetworkHTTPSUpgradeChecker.h */; }; > 5C0B17781E7C880E00E9123C /* NetworkSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */; }; > 5C0B17791E7C882100E9123C /* WebSocketStreamMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */; }; > 5C1426ED1C23F80900D41183 /* NetworkProcessCreationParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1426E31C23F80500D41183 /* NetworkProcessCreationParameters.h */; }; >@@ -1857,14 +1857,14 @@ > 00B9661518E24CBA00CE1F88 /* APIFindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFindClient.h; sourceTree = "<group>"; }; > 00B9661718E25AE100CE1F88 /* FindClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindClient.mm; sourceTree = "<group>"; }; > 00B9661818E25AE100CE1F88 /* FindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindClient.h; sourceTree = "<group>"; }; >+ 0729455C1C1711EA003F0735 /* PersistencyUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PersistencyUtils.cpp; sourceTree = "<group>"; }; > 07297F9C1C1711EA003F0735 /* DeviceIdHashSaltStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceIdHashSaltStorage.cpp; sourceTree = "<group>"; }; > 07297F9C1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionCheckProxy.cpp; sourceTree = "<group>"; }; > 07297F9D1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaPermissionCheckProxy.h; sourceTree = "<group>"; }; > 07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceIdHashSaltStorage.h; sourceTree = "<group>"; }; >- 0729455C1C1711EA003F0735 /* PersistencyUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PersistencyUtils.cpp; sourceTree = "<group>"; }; >- 07321F9D1C17BBEA223F0735 /* PersistencyUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistencyUtils.h; sourceTree = "<group>"; }; > 07297FA01C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionCheck.cpp; sourceTree = "<group>"; }; > 07297FA11C186ADB003F0735 /* WKUserMediaPermissionCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionCheck.h; sourceTree = "<group>"; }; >+ 07321F9D1C17BBEA223F0735 /* PersistencyUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PersistencyUtils.h; sourceTree = "<group>"; }; > 074E75FB1DF1FD1300D318EC /* UserMediaProcessManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaProcessManager.h; sourceTree = "<group>"; }; > 074E75FC1DF2002400D318EC /* UserMediaProcessManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaProcessManager.cpp; sourceTree = "<group>"; }; > 074E76001DF7075D00D318EC /* MediaDeviceSandboxExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaDeviceSandboxExtensions.cpp; sourceTree = "<group>"; }; >@@ -2808,6 +2808,8 @@ > 2DFF7B6E1DA4CFAF00814614 /* WKBackForwardListItemPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItemPrivate.h; sourceTree = "<group>"; }; > 2E16B6CC2017B7AB008996D6 /* WKFocusedFormControlView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFocusedFormControlView.mm; path = ios/forms/WKFocusedFormControlView.mm; sourceTree = "<group>"; }; > 2E16B6CD2017B7AC008996D6 /* WKFocusedFormControlView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFocusedFormControlView.h; path = ios/forms/WKFocusedFormControlView.h; sourceTree = "<group>"; }; >+ 2E2B3BA321D4879000538EDF /* GlobalFindInPageState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GlobalFindInPageState.mm; sourceTree = "<group>"; }; >+ 2E2B3BA421D4879000538EDF /* GlobalFindInPageState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlobalFindInPageState.h; sourceTree = "<group>"; }; > 2E5C770C1FA7D429005932C3 /* APIAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIAttachment.h; sourceTree = "<group>"; }; > 2E5C770D1FA7D429005932C3 /* APIAttachment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = APIAttachment.cpp; sourceTree = "<group>"; }; > 2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKFocusedElementInfo.h; sourceTree = "<group>"; }; >@@ -3409,9 +3411,9 @@ > 57DCEDC6214F18300016B847 /* MockLocalConnection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MockLocalConnection.mm; sourceTree = "<group>"; }; > 57DCEDC9214F4E420016B847 /* MockAuthenticatorManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockAuthenticatorManager.h; sourceTree = "<group>"; }; > 57DCEDCD214F51680016B847 /* MockAuthenticatorManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockAuthenticatorManager.cpp; sourceTree = "<group>"; }; >+ 587743A421C30AD800AE9084 /* HTTPSUpgradeList.db */ = {isa = PBXFileReference; lastKnownFileType = file; name = HTTPSUpgradeList.db; path = DerivedSources/WebKit2/HTTPSUpgradeList.db; sourceTree = BUILT_PRODUCTS_DIR; }; > 58E977DC21C499FE005D92A6 /* NetworkHTTPSUpgradeChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkHTTPSUpgradeChecker.cpp; sourceTree = "<group>"; }; > 58E977DD21C49A00005D92A6 /* NetworkHTTPSUpgradeChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkHTTPSUpgradeChecker.h; sourceTree = "<group>"; }; >- 587743A421C30AD800AE9084 /* HTTPSUpgradeList.db */ = {isa = PBXFileReference; lastKnownFileType = file; name = HTTPSUpgradeList.db; path = DerivedSources/WebKit2/HTTPSUpgradeList.db; sourceTree = BUILT_PRODUCTS_DIR; }; > 5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkSocketStreamMessageReceiver.cpp; path = DerivedSources/WebKit2/NetworkSocketStreamMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; > 5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSocketStreamMessages.h; path = DerivedSources/WebKit2/NetworkSocketStreamMessages.h; sourceTree = BUILT_PRODUCTS_DIR; }; > 5C0B17761E7C879C00E9123C /* WebSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketStreamMessageReceiver.cpp; path = DerivedSources/WebKit2/WebSocketStreamMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; >@@ -5306,6 +5308,8 @@ > 00B9661718E25AE100CE1F88 /* FindClient.mm */, > CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */, > CD78E1121DB7D7ED0014A2DE /* FullscreenClient.mm */, >+ 2E2B3BA421D4879000538EDF /* GlobalFindInPageState.h */, >+ 2E2B3BA321D4879000538EDF /* GlobalFindInPageState.mm */, > 51C0C9721DDD74F00032CAD3 /* IconLoadingDelegate.h */, > 51C0C9731DDD74F00032CAD3 /* IconLoadingDelegate.mm */, > 0F0C365918C0555800F607D7 /* LayerRepresentation.h */, >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h b/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h >index 4b5a6d3addb443e9800f0a5547bb979fc64d80ba..4720b71175412a59a229bc47106dab2da3c8756e 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.h >@@ -173,6 +173,7 @@ private: > int getPasteboardItemsCount() final; > RefPtr<WebCore::DocumentFragment> documentFragmentFromDelegate(int index) final; > bool performsTwoStepPaste(WebCore::DocumentFragment*) final; >+ void updateStringForFind(const String&) final; > #endif > > bool performTwoStepDrop(WebCore::DocumentFragment&, WebCore::Range&, bool isMove) final; >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm b/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm >index c60438c4e5bcbb4a43c83b85d441912ec4774627..00b871e9ddfc094548d2015b650a9c2d6fb144cf 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm >+++ b/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm >@@ -86,6 +86,11 @@ bool WebEditorClient::performsTwoStepPaste(WebCore::DocumentFragment*) > return false; > } > >+void WebEditorClient::updateStringForFind(const String& findString) >+{ >+ m_page->updateStringForFind(findString); >+} >+ > void WebEditorClient::overflowScrollPositionChanged() > { > m_page->didChangeSelection(); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 267a983e81800ccee57916c747354e24a7b26058..d8b8b30e57aa966b6eb6da5d9d7487823bdbf6f0 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -939,6 +939,8 @@ public: > const WebCore::ViewportConfiguration& viewportConfiguration() const { return m_viewportConfiguration; } > > void hardwareKeyboardAvailabilityChanged(); >+ >+ void updateStringForFind(const String&); > #endif > > #if ENABLE(IOS_TOUCH_EVENTS) >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index 90658056389737ef9caa5ffd61e8edaadf79cce9..b0f2d18c87a5515ec6ea1d353c2255d3791aee03 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -3125,6 +3125,11 @@ void WebPage::hardwareKeyboardAvailabilityChanged() > focusedFrame->eventHandler().capsLockStateMayHaveChanged(); > } > >+void WebPage::updateStringForFind(const String& findString) >+{ >+ send(Messages::WebPageProxy::UpdateStringForFind(findString)); >+} >+ > #if USE(QUICK_LOOK) > void WebPage::didReceivePasswordForQuickLookDocument(const String& password) > { >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >index 8464059c4952b96f614b7d5453a751585d8e4ab5..f0f968b7e2b66c891dc14b6c1faaf0b8bbe1d19e 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.h >@@ -144,6 +144,7 @@ private: > int getPasteboardItemsCount() final; > RefPtr<WebCore::DocumentFragment> documentFragmentFromDelegate(int index) final; > bool performsTwoStepPaste(WebCore::DocumentFragment*) final; >+ void updateStringForFind(const String&) final { } > #endif > > bool performTwoStepDrop(WebCore::DocumentFragment&, WebCore::Range& destination, bool isMove) final; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index cef356ebe085c69f88580798a1ab59702b2dae0a..c5470e262085e271c6c90f355911de07b3853e9e 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2018-12-29 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add support for using the current text selection as the find string on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=193034 >+ <rdar://problem/45138739> >+ >+ Reviewed by Tim Horton. >+ >+ Add a new API test to verify that the new WebKit SPI (_stringForFind, _takeFindStringFromSelection:, and >+ _setStringForFind) works as expected. >+ >+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: >+ * TestWebKitAPI/Tests/WebKitCocoa/UseSelectionAsFindString.mm: Added. >+ > 2019-01-02 Daniel Bates <dabates@apple.com> > > [lldb-webkit] Remove broken code to print WTF::OptionSet::m_storage >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index 2314328fed4ea1119fe35d1a59cf54dcaeee9227..bcdd2cf98974bd25f4689b692a2f7408e357cf0d 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -118,6 +118,7 @@ > 2E92B8F7216490D4005B64F0 /* rich-text-attributes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E92B8F6216490C3005B64F0 /* rich-text-attributes.html */; }; > 2E92B8FA2164A0C1005B64F0 /* FontAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E92B8F8216490EA005B64F0 /* FontAttributes.mm */; }; > 2E9896151D8F093800739892 /* text-and-password-inputs.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2E9896141D8F092B00739892 /* text-and-password-inputs.html */; }; >+ 2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E133B4F21D40AF000ED1CB2 /* UseSelectionAsFindString.mm */; }; > 2EB29D5E1F762DB90023A5F1 /* dump-datatransfer-types.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EB29D5D1F762DA50023A5F1 /* dump-datatransfer-types.html */; }; > 2EBD9D0A2134730D002DA758 /* video.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07CD32F72065B72A0064A4BE /* video.html */; }; > 2ECFF5551D9B12F800B55394 /* NowPlayingControlsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2ECFF5541D9B12F800B55394 /* NowPlayingControlsTests.mm */; }; >@@ -1395,6 +1396,7 @@ > 2DE71AFF1D49C2F000904094 /* blinking-div.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "blinking-div.html"; sourceTree = "<group>"; }; > 2DFF7B6C1DA487AF00814614 /* SnapshotStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SnapshotStore.mm; sourceTree = "<group>"; }; > 2E131C171D83A97E001BA36C /* wide-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "wide-autoplaying-video-with-audio.html"; sourceTree = "<group>"; }; >+ 2E133B4F21D40AF000ED1CB2 /* UseSelectionAsFindString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UseSelectionAsFindString.mm; sourceTree = "<group>"; }; > 2E14A5281D3FE8B80010F35B /* autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplaying-video-with-audio.html"; sourceTree = "<group>"; }; > 2E1B7AFF1D41A95F007558B4 /* large-video-seek-after-ending.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-seek-after-ending.html"; sourceTree = "<group>"; }; > 2E1B7B011D41B1B3007558B4 /* large-video-hides-controls-after-seek-to-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-hides-controls-after-seek-to-end.html"; sourceTree = "<group>"; }; >@@ -2537,6 +2539,7 @@ > 7CCB99201D3B41F6003922F6 /* UserInitiatedActionInNavigationAction.mm */, > 07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */, > 07F4E92D20AF58D3002E3803 /* UserMediaSimulateFailedSandbox.mm */, >+ 2E133B4F21D40AF000ED1CB2 /* UseSelectionAsFindString.mm */, > 93E943F11CD3E87E00AC08C2 /* VideoControlsManager.mm */, > CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */, > 6356FB211EC4E0BA0044BF18 /* VisibleContentRect.mm */, >@@ -4191,6 +4194,7 @@ > 0799C3491EBA2D7B003B7532 /* UserMediaDisabled.mm in Sources */, > 07F4E92E20AF59E2002E3803 /* UserMediaSimulateFailedSandbox.mm in Sources */, > 7CCE7F181A411AE600447C4C /* UserMessage.cpp in Sources */, >+ 2EB242B821D4140B0055C1C0 /* UseSelectionAsFindString.mm in Sources */, > 7C83E03A1D0A602700FEBCF3 /* UtilitiesCocoa.mm in Sources */, > 7C83E0C61D0A654E00FEBCF3 /* VideoControlsManager.mm in Sources */, > CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/UseSelectionAsFindString.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UseSelectionAsFindString.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..398ceca30e867b9d5e7e97840b9b0c33e370ea0d >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/UseSelectionAsFindString.mm >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+ >+#if WK_API_ENABLED >+ >+#import "PlatformUtilities.h" >+#import "TestWKWebView.h" >+#import <WebKit/WKWebViewPrivate.h> >+ >+namespace TestWebKitAPI { >+ >+TEST(WebKit, UseSelectionAsFindString) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView synchronouslyLoadHTMLString:@"<body>Hello <span id='text'>world</span></body>"]; >+ [webView evaluateJavaScript:@"getSelection().selectAllChildren(text)" completionHandler:nil]; >+ [webView _takeFindStringFromSelection:nil]; >+ [webView waitForNextPresentationUpdate]; >+ EXPECT_WK_STREQ("world", WKWebView._stringForFind); >+ [WKWebView _setStringForFind:@"testing"]; >+ EXPECT_WK_STREQ("testing", [WKWebView _stringForFind]); >+ >+#if PLATFORM(IOS_FAMILY) >+ [webView _findString:@"foo" options:0 maxCount:10]; >+ EXPECT_WK_STREQ("foo", [WKWebView _stringForFind]); >+#endif >+} >+ >+} // namespace TestWebKitAPI >+ >+#endif // WK_API_ENABLED
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193034
:
358074
|
358076
|
358082
|
358085
|
358097
|
358099
| 358242