Add a new set of WebKit2 APIs for text search and
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 23:00:59 +0000 (23:00 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 23:00:59 +0000 (23:00 +0000)
commit4dbe36aeca3cf55bc9f62c0335a642ec9a71a1b2
tree3104ceb2cf0dabb243fb6b4739282dbf5f341265
parent7c025e91c2a22735c466225c6a533e41a0f1ca16
Add a new set of WebKit2 APIs for text search and
search results management.
https://bugs.webkit.org/show_bug.cgi?id=106834.
<rdar://problem/12597159>

Source/WebCore:

Reviewed by Simon Fraser.

Adding new API to perform text search in WebKit2 without using
the stock UI. The new interface provides all the information
necessary to write a custom UI for search.

Added new TextWebKitAPI test.

* WebCore.exp.in: Added new exported methods.
* editing/Editor.cpp:
(WebCore::Editor::countMatchesForText): Added new parameter to store
all the ranges relative to the matches found.
* editing/Editor.h: Modified the interface of countMatchesForText and removed
the other definition of countMatchesForText with a different signature.
* page/Page.cpp:
(WebCore::Page::findStringMatchingRanges): Added.
(WebCore::Page::markAllMatchesForText): Changed to use the new unified
countMatchesForText.
* page/Page.h:

Source/WebKit/mac:

Reviewed by Simon Fraser.

Adding new API to perform text search in WebKit2 without using
the stock UI. The new interface provides all the information
necessary to write a custom UI for search.

Added new TextWebKitAPI test.

* WebView/WebHTMLView.mm:
(-[WebHTMLView countMatchesForText:inDOMRange:options:limit:markMatches:]):
Modified to reflect the changes to Editor::countMatchesForText interface.

Source/WebKit2:

Reviewed by Simon Fraser.

Adding new API to perform text search in WebKit2 without using
the stock UI. The new interface provides all the information
necessary to write a custom UI for search. The main logic is
implemented in the new functions added to FindController.

Added new TextWebKitAPI test.

* UIProcess/API/C/WKPage.cpp:
(WKPageFindStringMatches): Added.
(WKPageGetImageForFindMatch): Added.
(WKPageSelectFindMatch): Added.
(WKPageSetPageFindMatchesClient): Added.
* UIProcess/API/C/WKPage.h: Added the new API definitions.
* UIProcess/WebFindClient.cpp: Added new client callbacks.
(WebKit::WebFindMatchesClient::didFindStringMatches):
(WebKit::WebFindMatchesClient::didGetImageForMatchResult):
* UIProcess/WebFindClient.h:
(WebFindMatchesClient): Added.
* UIProcess/WebPageProxy.cpp: Added proxy methods.
(WebKit::WebPageProxy::initializeFindMatchesClient):
(WebKit::WebPageProxy::findStringMatches):
(WebKit::WebPageProxy::getImageForFindMatch):
(WebKit::WebPageProxy::selectFindMatch):
(WebKit::WebPageProxy::didGetImageForFindMatch):
(WebKit::WebPageProxy::didFindStringMatches):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::findStringMatches): Finds all the matching
text according to the find options. All the matching text ranges are
stored in a vector until the next call to findStringMatches or until
hideFindUI is called. The message that is sent back to the UI process
contains a vector containing an entry for each find match (i.e. for each
range) and each entry is represented by a vector of the corresponding
text rects. It also returns the index in the vector of matches corresponding
to the first match after the user selection.
If there is no selection the index is always 0 and if there are no
matches after the user selection, the index returned is -1.
(WebKit::FindController::getFindIndicatorBitmapAndRect): Helper function
to share code between updateFindIndicator and getImageForFindMatch.
(WebKit::FindController::getImageForFindMatch): Creates the image corresponding
to the text matched at the given match index.
(WebKit::FindController::selectFindMatch): creates a selection for the range
corresponding to the given match index.
(WebKit::FindController::hideFindUI): Added logic to clear the vector
of matched ranges.
(WebKit::FindController::updateFindIndicator): Updated to use the
new helper function getFindIndicatorBitmapAndRect.
* WebProcess/WebPage/FindController.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::findStringMatches):
(WebKit::WebPage::getImageForFindMatch):
(WebKit::WebPage::selectFindMatch):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Tools:

Added new test for the new WebKit2 API for
text search.

Reviewed by Simon Fraser.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/FindMatches.mm: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/WebFindClient.cpp
Source/WebKit2/UIProcess/WebFindClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/FindController.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/FindMatches.mm [new file with mode: 0644]