[Cherry-pick] Add a new set of WebKit2 APIs for text search and search results manage...
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Jan 2013 23:00:59 +0000 (23:00 +0000)
committerJinwoo Song <jinwoo7.song@samsung.com>
Mon, 25 Mar 2013 05:32:55 +0000 (14:32 +0900)
commitf43a44e5534aafd34b240905fd21ec22c79775b7
tree03f979450aaefa3a61ac7abf75ea031e237480ac
parentb08a0089c3896abfbb4c014e2951ce6e234b536e
[Cherry-pick] Add a new set of WebKit2 APIs for text search and search results management.

[Title] [Cherry-pick] Add a new set of WebKit2 APIs for text search and search results management.
[Issue] https://tizendev.org/bugs/browse/N_SE-25811
[Problem] Find string is not working in the page with the CSS style, '--webkit-user-select: none'.
[Solution] We need to expand the text search implementation with the new WebKit2 APIs in the open source.
           So I cherry-pick this patch in the open source.
[Cherry-Picker] Jinwoo Song <jinwoo7.song@samsung.com>

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: http://svn.webkit.org/repository/webkit/trunk@139796 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:
Source/WebCore/ChangeLog
Source/WebKit/mac/ChangeLog
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

Change-Id: I50c151a32ebbc2cbaa1ce2c973afb25d7e99db78
20 files changed:
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/WebView/WebHTMLView.mm
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/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/FindMatches.mm [new file with mode: 0644]