Changeset 69978 in webkit


Ignore:
Timestamp:
Oct 18, 2010 11:46:51 AM (14 years ago)
Author:
andersca@apple.com
Message:

Add matchCountDidChange callback
https://bugs.webkit.org/show_bug.cgi?id=47840

Reviewed by Darin Adler.

  • UIProcess/API/C/WKPage.h:

Add matchCountDidChange WKPageFindClient callback.

  • UIProcess/WebFindClient.cpp:

(WebKit::WebFindClient::matchCountDidChange):
Call the WKPageFindClient callback.

  • UIProcess/WebPageProxy.messages.in:

Add MatchCountDidChange message.

  • WebProcess/WebPage/FindController.cpp:

(WebKit::FindController::countStringMatches):
Move code here from WebPage.

(WebKit::FindController::findString):
Send the MatchCountDidChange message.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::countStringMatches):
Move this code over to FindController.

Location:
trunk/WebKit2
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r69973 r69978  
     12010-10-18  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Add matchCountDidChange callback
     6        https://bugs.webkit.org/show_bug.cgi?id=47840
     7
     8        * UIProcess/API/C/WKPage.h:
     9        Add matchCountDidChange WKPageFindClient callback.
     10       
     11        * UIProcess/WebFindClient.cpp:
     12        (WebKit::WebFindClient::matchCountDidChange):
     13        Call the WKPageFindClient callback.
     14
     15        * UIProcess/WebPageProxy.messages.in:
     16        Add MatchCountDidChange message.
     17
     18        * WebProcess/WebPage/FindController.cpp:
     19        (WebKit::FindController::countStringMatches):
     20        Move code here from WebPage.
     21
     22        (WebKit::FindController::findString):
     23        Send the MatchCountDidChange message.
     24       
     25        * WebProcess/WebPage/WebPage.cpp:
     26        (WebKit::WebPage::countStringMatches):
     27        Move this code over to FindController.
     28
    1292010-10-18  Anders Carlsson  <andersca@apple.com>
    230
  • trunk/WebKit2/UIProcess/API/C/WKPage.cpp

    r69559 r69978  
    194194}
    195195
    196 void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindDirection findDirection, WKFindOptions findOptions, unsigned maxNumMatches)
    197 {
    198     toImpl(pageRef)->findString(toImpl(string)->string(), toFindDirection(findDirection), toFindOptions(findOptions), maxNumMatches);
     196void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindDirection findDirection, WKFindOptions findOptions, unsigned maxMatchCount)
     197{
     198    toImpl(pageRef)->findString(toImpl(string)->string(), toFindDirection(findDirection), toFindOptions(findOptions), maxMatchCount);
    199199}
    200200
     
    204204}
    205205
    206 void WKPageCountStringMatches(WKPageRef pageRef, WKStringRef string, bool caseInsensitive, unsigned maxNumMatches)
    207 {
    208     toImpl(pageRef)->countStringMatches(toImpl(string)->string(), caseInsensitive, maxNumMatches);
     206void WKPageCountStringMatches(WKPageRef pageRef, WKStringRef string, bool caseInsensitive, unsigned maxMatchCount)
     207{
     208    toImpl(pageRef)->countStringMatches(toImpl(string)->string(), caseInsensitive, maxMatchCount);
    209209}
    210210
  • trunk/WebKit2/UIProcess/API/C/WKPage.h

    r69892 r69978  
    166166
    167167// Find client.
    168 typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned numMatches, const void* clientInfo);
     168typedef void (*WKPageMatchCountDidChangeCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
     169typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
    169170
    170171struct WKPageFindClient {
    171172    int                                                                 version;
    172173    const void *                                                        clientInfo;
     174    WKPageMatchCountDidChangeCallback                                   matchCountDidChange;
    173175    WKPageDidCountStringMatchesCallback                                 didCountStringMatches;
    174176};
     
    235237typedef uint32_t WKFindOptions;
    236238
    237 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindDirection findDirection, WKFindOptions findOptions, unsigned maxNumMatches);
     239WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindDirection findDirection, WKFindOptions findOptions, unsigned maxMatchCount);
    238240WK_EXPORT void WKPageHideFindUI(WKPageRef page);
    239 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, bool caseInsensitive, unsigned maxNumMatches);
     241WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, bool caseInsensitive, unsigned maxMatchCount);
    240242
    241243WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client);
  • trunk/WebKit2/UIProcess/WebFindClient.cpp

    r69343 r69978  
    3030namespace WebKit {
    3131
    32 void WebFindClient::didCountStringMatches(WebPageProxy* page, const String& string, uint32_t numMatches)
     32void WebFindClient::matchCountDidChange(WebPageProxy* page, const String& string, uint32_t matchCount)
     33{
     34    if (!m_client.matchCountDidChange)
     35        return;
     36
     37    m_client.matchCountDidChange(toAPI(page), toAPI(string.impl()), matchCount, m_client.clientInfo);
     38}
     39
     40void WebFindClient::didCountStringMatches(WebPageProxy* page, const String& string, uint32_t matchCount)
    3341{
    3442    if (!m_client.didCountStringMatches)
    3543        return;
    3644
    37     m_client.didCountStringMatches(toAPI(page), toAPI(string.impl()), numMatches, m_client.clientInfo);
     45    m_client.didCountStringMatches(toAPI(page), toAPI(string.impl()), matchCount, m_client.clientInfo);
    3846}
    3947
  • trunk/WebKit2/UIProcess/WebFindClient.h

    r69343 r69978  
    3737class WebFindClient : public APIClient<WKPageFindClient> {
    3838public:
    39     void didCountStringMatches(WebPageProxy*, const String&, uint32_t numMatches);
     39    void matchCountDidChange(WebPageProxy*, const String&, uint32_t matchCount);
     40    void didCountStringMatches(WebPageProxy*, const String&, uint32_t matchCount);
    4041};
    4142
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r69899 r69978  
    506506}
    507507
    508 void WebPageProxy::findString(const String& string, FindDirection findDirection, FindOptions findOptions, unsigned maxNumMatches)
    509 {
    510     process()->send(Messages::WebPage::FindString(string, findDirection, findOptions, maxNumMatches), m_pageID);
     508void WebPageProxy::findString(const String& string, FindDirection findDirection, FindOptions findOptions, unsigned maxMatchCount)
     509{
     510    process()->send(Messages::WebPage::FindString(string, findDirection, findOptions, maxMatchCount), m_pageID);
    511511}
    512512
     
    516516}
    517517
    518 void WebPageProxy::countStringMatches(const String& string, bool caseInsensitive, unsigned maxNumMatches)
    519 {
    520     process()->send(Messages::WebPage::CountStringMatches(string, caseInsensitive, maxNumMatches), m_pageID);
     518void WebPageProxy::countStringMatches(const String& string, bool caseInsensitive, unsigned maxMatchCount)
     519{
     520    process()->send(Messages::WebPage::CountStringMatches(string, caseInsensitive, maxMatchCount), m_pageID);
    521521}
    522522   
     
    962962}
    963963
    964 void WebPageProxy::didCountStringMatches(const String& string, uint32_t numMatches)
    965 {
    966     m_findClient.didCountStringMatches(this, string, numMatches);
     964void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
     965{
     966    m_findClient.didCountStringMatches(this, string, matchCount);
    967967}
    968968
     
    971971    RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRect, textRects, contentImageHandle);
    972972    m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
     973}
     974
     975void WebPageProxy::matchCountDidChange(const String& string, uint32_t matchCount)
     976{
     977    m_findClient.matchCountDidChange(this, string, matchCount);
    973978}
    974979
  • trunk/WebKit2/UIProcess/WebPageProxy.h

    r69899 r69978  
    180180
    181181    // Find.
    182     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
     182    void findString(const String&, FindDirection, FindOptions, unsigned maxMatchCount);
    183183    void hideFindUI();
    184     void countStringMatches(const String&, bool caseInsensitive, unsigned maxNumMatches);
     184    void countStringMatches(const String&, bool caseInsensitive, unsigned maxMatchCount);
    185185
    186186    void runJavaScriptInMainFrame(const String&, PassRefPtr<ScriptReturnValueCallback>);
     
    286286
    287287    // Find.
    288     void didCountStringMatches(const String&, uint32_t numMatches);
     288    void didCountStringMatches(const String&, uint32_t matchCount);
    289289    void setFindIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle, bool fadeOut);
     290    void matchCountDidChange(const String&, uint32_t matchCount);
    290291
    291292    // Popup Menu.
  • trunk/WebKit2/UIProcess/WebPageProxy.messages.in

    r69899 r69978  
    9393
    9494    # Find.
    95     DidCountStringMatches(WTF::String string, uint32_t numMatches)
     95    DidCountStringMatches(WTF::String string, uint32_t matchCount)
    9696    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
     97    MatchCountDidChange(WTF::String string, uint32_t matchCount)
    9798
    9899    # PopupMenu.
  • trunk/WebKit2/WebProcess/WebPage/FindController.cpp

    r69877 r69978  
    4747}
    4848
     49void FindController::countStringMatches(const String& string, bool caseInsensitive, unsigned maxMatchCount)
     50{
     51    unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, caseInsensitive ? TextCaseInsensitive : TextCaseSensitive, false, maxMatchCount);
     52    m_webPage->corePage()->unmarkAllTextMatches();
     53
     54    WebProcess::shared().connection()->send(Messages::WebPageProxy::DidCountStringMatches(string, matchCount), m_webPage->pageID());
     55}
     56
    4957static Frame* frameWithSelection(Page* page)
    5058{
     
    5765}
    5866
    59 void FindController::findString(const String& string, FindDirection findDirection, FindOptions findOptions, unsigned maxNumMatches)
     67void FindController::findString(const String& string, FindDirection findDirection, FindOptions findOptions, unsigned maxMatchCount)
    6068{
    6169    m_webPage->corePage()->unmarkAllTextMatches();
     
    7684
    7785        hideFindIndicator();
     86
     87        WebProcess::shared().connection()->send(Messages::WebPageProxy::MatchCountDidChange(string, 0), m_webPage->pageID());
     88
    7889    } else {
    7990        shouldShowOverlay = findOptions & FindOptionsShowOverlay;
    8091
    8192        if (shouldShowOverlay) {
    82             unsigned numMatches = m_webPage->corePage()->markAllMatchesForText(string, caseSensitivity, false, maxNumMatches);
     93            unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, caseSensitivity, false, maxMatchCount);
    8394
    8495            // Check if we have more matches than allowed.
    85             if (numMatches > maxNumMatches)
     96            if (matchCount > maxMatchCount)
    8697                shouldShowOverlay = false;
     98
     99            WebProcess::shared().connection()->send(Messages::WebPageProxy::MatchCountDidChange(string, matchCount), m_webPage->pageID());
    87100        }
    88101
  • trunk/WebKit2/WebProcess/WebPage/FindController.h

    r69877 r69978  
    4646    explicit FindController(WebPage*);
    4747
    48     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
     48    void findString(const String&, FindDirection, FindOptions, unsigned maxMatchCount);
    4949    void hideFindUI();
    50 
     50    void countStringMatches(const String&, bool caseInsensitive, unsigned maxMatchCount);
     51   
    5152    void findPageOverlayDestroyed();
    5253
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r69899 r69978  
    788788}
    789789
    790 void WebPage::findString(const String& string, uint32_t findDirection, uint32_t findOptions, uint32_t maxNumMatches)
    791 {
    792     m_findController.findString(string, static_cast<FindDirection>(findDirection), static_cast<FindOptions>(findOptions), maxNumMatches);
     790void WebPage::findString(const String& string, uint32_t findDirection, uint32_t findOptions, uint32_t maxMatchCount)
     791{
     792    m_findController.findString(string, static_cast<FindDirection>(findDirection), static_cast<FindOptions>(findOptions), maxMatchCount);
    793793}
    794794
     
    798798}
    799799
    800 void WebPage::countStringMatches(const String& string, bool caseInsensitive, uint32_t maxNumMatches)
    801 {
    802     unsigned numMatches = m_page->markAllMatchesForText(string, caseInsensitive ? TextCaseInsensitive : TextCaseSensitive, false, maxNumMatches);
    803     m_page->unmarkAllTextMatches();
    804 
    805     WebProcess::shared().connection()->send(Messages::WebPageProxy::DidCountStringMatches(string, numMatches), m_pageID);
     800void WebPage::countStringMatches(const String& string, bool caseInsensitive, uint32_t maxMatchCount)
     801{
     802    m_findController.countStringMatches(string, caseInsensitive, maxMatchCount);
    806803}
    807804
     
    814811    m_activePopupMenu = 0;
    815812}
    816 
    817813
    818814#if PLATFORM(MAC)
  • trunk/WebKit2/WebProcess/WebPage/WebPage.h

    r69899 r69978  
    227227    void didRemoveEditCommand(uint64_t commandID);
    228228
    229     void findString(const String&, uint32_t findDirection, uint32_t findOptions, uint32_t maxNumMatches);
     229    void findString(const String&, uint32_t findDirection, uint32_t findOptions, uint32_t maxMatchCount);
    230230    void hideFindUI();
    231     void countStringMatches(const String&, bool caseInsensitive, uint32_t maxNumMatches);
     231    void countStringMatches(const String&, bool caseInsensitive, uint32_t maxMatchCount);
    232232
    233233    void didChangeSelectedIndexForActivePopupMenu(int32_t newIndex);
  • trunk/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r69899 r69978  
    7070
    7171    # Find.
    72     FindString(WTF::String string, uint32_t findDirection, uint32_t findOptions, unsigned maxNumMatches)
     72    FindString(WTF::String string, uint32_t findDirection, uint32_t findOptions, unsigned maxMatchCount)
    7373    HideFindUI()
    74     CountStringMatches(WTF::String string, bool caseInsensitive, unsigned maxNumMatches)
     74    CountStringMatches(WTF::String string, bool caseInsensitive, unsigned maxMatchCount)
    7575
    7676    # Popup menu.
Note: See TracChangeset for help on using the changeset viewer.