-
rdar://problem/8650085mitz@apple.com authored
JavaScriptCore: WTF support for <rdar://problem/8650085> adding word-prefix search options to the text search API. https://bugs.webkit.org/show_bug.cgi?id=50038 Reviewed by Darin Adler. * wtf/unicode/UnicodeMacrosFromICU.h: Copied additional macros from icu/unicode/utf16.h. WebCore: WebCore part of <rdar://problem/8650085> adding word-prefix search options to the text search API. https://bugs.webkit.org/show_bug.cgi?id=50038 Reviewed by Darin Adler. Test: editing/text-iterator/findString.html * GNUmakefile.am: Added FindOptions.h. * WebCore.exp.in: Export the new methods that take FindOptions. * WebCore.gypi: Added FindOptions.h. * WebCore.pro: Added FindOptions.h and TextBoundaries.{cpp,h}. * WebCore.vcproj/WebCore.vcproj: Added FindOptions.h. * WebCore.xcodeproj/project.pbxproj: Added FindOptions.h and TextBoundaries.cpp. * editing/Editor.cpp: (WebCore::Editor::firstVisibleRange): Changed to use FindOptions. (WebCore::Editor::lastVisibleRange): Ditto. (WebCore::Editor::nextVisibleRange): Ditto. (WebCore::Editor::findString): Ditto. (WebCore::Editor::countMatchesForText): Ditto. * editing/Editor.h: Added a version of findString() that takes FindOptions. Changed countMatchesForText() to take FindOptions. Made nextVisibleRange() private and changed it and firstVisibleRange() and lastVisibleRange() to take FindOptions. * editing/FindOptions.h: Added. * editing/TextIterator.cpp: Augmented SearchBuffer with an optional prefix, which is not searched, but provides context for determining word boundaries. (WebCore::isSeparator): Added. Identifies a class of characters used to determine where “words” are embedded in a word. (WebCore::SearchBuffer::SearchBuffer): Changed to take FindOptions. Added initialization of m_options, m_prefixLength and m_needsMoreContext. (WebCore::SearchBuffer::append): Adjust m_prefixLength as part of the prefix gets pushed out of the buffer. (WebCore::SearchBuffer::needsMoreContext): Added. (WebCore::SearchBuffer::prependContext): Added. (WebCore::SearchBuffer::isWordStartMatch): Added. (WebCore::SearchBuffer::search): Changed to account for the context prefix. When searching only for word prefix matches, maintains enough context before a tentative match when moving it to the beginning of the buffer. Reject matches that are not at word starts if requested. Adjust m_prefixLength when pushing characters out of the buffer. (WebCore::findPlainText): Changed to work with FindOptions. Feed the search buffer with context if and as long as it requires more of it. * editing/TextIterator.h: Added a version of findPlainText() that takes FindOptions. * editing/visible_units.cpp: Moved {end,start}Of{First,Last}WordBoundary to TextBoundaries.cpp. * page/Page.cpp: (WebCore::Page::findString): Changed to work with FindOptions. (WebCore::Page::markAllMatchesForText): Ditto. * page/Page.h: Added FindOptions-based findString() and markAllMatchesForText(). * platform/text/TextBoundaries.cpp: (WebCore::endOfFirstWordBoundaryContext): Moved here from visible_units.cpp. (WebCore::startOfLastWordBoundaryContext): Ditto. * platform/text/TextBoundaries.h: WebKit/mac: WebKit Mac part of <rdar://problem/8650085> adding word-prefix search options to the text search API. https://bugs.webkit.org/show_bug.cgi?id=50038 Based on a patch from Darin Adler. Reviewed by Darin Adler. * WebView/WebDocumentInternal.h: Removed -markAllMatchesForText:caseSensitive:limit: and replaced -countMatchesForText:caseSensitive:limit:markMatches: with a WebFindOptions-based method. Declared a WebDocumentOptionsSearching protocol with a new -findString:options: method. Made WebHTMLView conform to the new protocol. * WebView/WebHTMLView.mm: (coreOptions): Added. Converts WebFindOptions to WebCore FindOptions. (-[WebHTMLView searchFor:direction:caseSensitive:wrap:startInSelection:]): Changed to use -findString:options:. (-[WebHTMLView countMatchesForText:options:limit:markMatches:]): Changed to use WebFindOptions. (-[WebHTMLView findString:options:]): Added. Calls through to WebCore::Editor::findString(). * WebView/WebPDFView.mm: (-[WebPDFView countMatchesForText:options:limit:markMatches:]): Changed to use WebFindOptions. * WebView/WebView.mm: (-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]): Now calls through to -countMatchesForText:options:highlight:limit:markMatches. (-[WebView countMatchesForText:caseSensitive:highlight:limit:markMatches:]): Ditto. (-[WebView searchFor:direction:caseSensitive:wrap:startInSelection:]): Now calls through to -findString:options:. (incrementFrame): Changed to use WebFindOptions. (findString): Added this helper method that performs the search using the best supported method for the document view. (-[WebView findString:options:]): Changed -searchFor::::: into this. (-[WebView canMarkAllTextMatches]): (-[WebView countMatchesForText:options:highlight:limit:markMatches:]): Updated to use WebFindOptions. (-[WebView unmarkAllTextMatches]): Updated for change to incrementFrame. (-[WebView rectsForTextMatches]): Ditto. * WebView/WebViewPrivate.h: Added WebFindOptions, -findString:options:, and WebFindOptions version of countMatchesForText:. WebKit2: WebKit2 part of <rdar://problem/8650085> adding word-prefix search options to the text search API. https://bugs.webkit.org/show_bug.cgi?id=50038 Based on a patch from Darin Adler. Reviewed by Darin Adler. * Shared/WebFindOptions.h: Renamed FindOptions.h to this to account for WebCore’s new private FindOptions.h. Added and reordered FindOptions and rolled FindDirection into FindOptions. * UIProcess/API/C/WKAPICast.h: Removed toFindDirection(). (WebKit::toFindOptions): Updated for new values. * UIProcess/API/C/WKPage.cpp: (WKPageFindString): Removed separate WKFindDirection. (WKPageCountStringMatches): Replaces caseInsensitive boolean with WKFindOptions. * UIProcess/API/C/WKPage.h: Removed WKFindDirection and updated WKFindOptions. * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::findString): Removed separate FindDirection. (WebKit::WebPageProxy::countStringMatches): Replaced caseInsensitive boolean with FindOptions. * UIProcess/WebPageProxy.h: * WebKit2.xcodeproj/project.pbxproj: Updated for the header rename. * WebProcess/WebPage/FindController.cpp: (WebKit::core): Added. Converts WebKit2 FindOptions to WebCore FindOptions. (WebKit::FindController::countStringMatches): Changed to use FindOptions. (WebKit::FindController::findString): Ditto. * WebProcess/WebPage/FindController.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::findString): Ditto. (WebKit::WebPage::countStringMatches): Ditto. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Ditto. WebKitTools: DumpRenderTree changes for testing the text search API. https://bugs.webkit.org/show_bug.cgi?id=50038 Reviewed by Darin Adler. * DumpRenderTree/LayoutTestController.cpp: (findStringCallback): (LayoutTestController::staticFunctions): * DumpRenderTree/LayoutTestController.h: * DumpRenderTree/mac/LayoutTestControllerMac.mm: (LayoutTestController::findString): * MiniBrowser/mac/BrowserWindowController.m: (-[BrowserWindowController find:]): LayoutTests: Added text search tests, in particular testing word-prefix search. https://bugs.webkit.org/show_bug.cgi?id=50038 Reviewed by Darin Adler. * editing/text-iterator/findString-expected.txt: Added. * editing/text-iterator/findString.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72887 268f45cc-cd09-0410-ab3c-d52691b4dbfc
7258a696