Changeset 69616 in webkit


Ignore:
Timestamp:
Oct 12, 2010 4:10:36 PM (13 years ago)
Author:
andersca@apple.com
Message:

Start fleshing out find page overlays
https://bugs.webkit.org/show_bug.cgi?id=47559

Reviewed by Sam Weinig.

WebKit2:

  • UIProcess/API/C/WKAPICast.h:

(WebKit::toFindOptions):
Handle the kWKFindOptionsShowFindIndicator flag.

  • WebKit2.pro:
  • WebKit2.xcodeproj/project.pbxproj:

Add new files.

  • WebProcess/WebPage/FindController.cpp:

(WebKit::FindController::FindController):
Initialize the find page overlay.

(WebKit::FindController::findString):
Hide or show the find page overlay.

(WebKit::FindController::findPageOverlayDestroyed):
Null out the find page overlay.

  • WebProcess/WebPage/FindPageOverlay.cpp: Added.
  • WebProcess/WebPage/FindPageOverlay.h: Added.

Add stubbed out FindPageOverlay class.

  • WebProcess/WebPage/PageOverlay.cpp: Added.

(WebKit::PageOverlay::setPage):
Set the parent web page.

(WebKit::PageOverlay::setNeedsDisplay):
Invalidate the parent web page.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::drawRect):
If there's a page overlay, ask it to draw on top of the page contents.

(WebKit::WebPage::installPageOverlay):
Set the page overlay.

(WebKit::WebPage::uninstallPageOverlay):
Clear the page overlay.

  • win/WebKit2.vcproj:

Add new files.

WebKitTools:

  • MiniBrowser/mac/BrowserWindowController.m:

(-[BrowserWindowController find:]):
Pass kWKFindOptionsShowOverlay to WKPageFindString.

Location:
trunk
Files:
11 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r69614 r69616  
     12010-10-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Start fleshing out find page overlays
     6        https://bugs.webkit.org/show_bug.cgi?id=47559
     7
     8        * UIProcess/API/C/WKAPICast.h:
     9        (WebKit::toFindOptions):
     10        Handle the kWKFindOptionsShowFindIndicator flag.
     11
     12        * WebKit2.pro:
     13        * WebKit2.xcodeproj/project.pbxproj:
     14        Add new files.
     15       
     16        * WebProcess/WebPage/FindController.cpp:
     17        (WebKit::FindController::FindController):
     18        Initialize the find page overlay.
     19
     20        (WebKit::FindController::findString):
     21        Hide or show the find page overlay.
     22
     23        (WebKit::FindController::findPageOverlayDestroyed):
     24        Null out the find page overlay.
     25
     26        * WebProcess/WebPage/FindPageOverlay.cpp: Added.
     27        * WebProcess/WebPage/FindPageOverlay.h: Added.
     28        Add stubbed out FindPageOverlay class.
     29
     30        * WebProcess/WebPage/PageOverlay.cpp: Added.
     31        (WebKit::PageOverlay::setPage):
     32        Set the parent web page.
     33
     34        (WebKit::PageOverlay::setNeedsDisplay):
     35        Invalidate the parent web page.
     36
     37        * WebProcess/WebPage/WebPage.cpp:
     38        (WebKit::WebPage::drawRect):
     39        If there's a page overlay, ask it to draw on top of the page contents.
     40
     41        (WebKit::WebPage::installPageOverlay):
     42        Set the page overlay.
     43
     44        (WebKit::WebPage::uninstallPageOverlay):
     45        Clear the page overlay.
     46
     47        * win/WebKit2.vcproj:
     48        Add new files.
     49
    1502010-10-12  Jessie Berlin  <jberlin@apple.com>
    251
  • trunk/WebKit2/UIProcess/API/C/WKAPICast.h

    r69325 r69616  
    140140    if (wkFindOptions & kWKFindOptionsShowOverlay)
    141141        findOptions |= FindOptionsShowOverlay;
     142    if (wkFindOptions & kWKFindOptionsShowFindIndicator)
     143        findOptions |= FindOptionsShowFindIndicator;
    142144
    143145    return static_cast<FindOptions>(findOptions);
  • trunk/WebKit2/WebKit2.pro

    r69598 r69616  
    297297    WebProcess/WebPage/DrawingArea.h \
    298298    WebProcess/WebPage/FindController.h \
     299    WebProcess/WebPage/FindPageOverlay.h \
     300    WebProcess/WebPage/PageOverlay.h \
    299301    WebProcess/WebPage/WebEditCommand.h \
    300302    WebProcess/WebPage/WebFrame.h \
     
    434436    WebProcess/WebPage/DrawingArea.cpp \
    435437    WebProcess/WebPage/FindController.cpp \
     438    WebProcess/WebPage/FindPageOverlay.cpp \
     439    WebProcess/WebPage/PageOverlay.cpp \
    436440    WebProcess/WebPage/WebEditCommand.cpp \
    437441    WebProcess/WebPage/WebFrame.cpp \
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r69604 r69616  
    124124                1A90C1F41264FD71003E44D4 /* FindController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A90C1F21264FD71003E44D4 /* FindController.h */; };
    125125                1A90C1F51264FD71003E44D4 /* FindController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A90C1F31264FD71003E44D4 /* FindController.cpp */; };
     126                1A90C23712650717003E44D4 /* PageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A90C23512650717003E44D4 /* PageOverlay.h */; };
     127                1A90C23812650717003E44D4 /* PageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A90C23612650717003E44D4 /* PageOverlay.cpp */; };
     128                1A90C2A312650C60003E44D4 /* FindPageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A90C2A112650C60003E44D4 /* FindPageOverlay.h */; };
     129                1A90C2A412650C60003E44D4 /* FindPageOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A90C2A212650C60003E44D4 /* FindPageOverlay.cpp */; };
    126130                1AA1CC5D100FA1A10078DEBC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CC5C100FA1A10078DEBC /* QuartzCore.framework */; };
    127131                1AA1CD07100FA1BA0078DEBC /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1CD06100FA1BA0078DEBC /* Carbon.framework */; };
     
    585589                1A90C1F21264FD71003E44D4 /* FindController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindController.h; sourceTree = "<group>"; };
    586590                1A90C1F31264FD71003E44D4 /* FindController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FindController.cpp; sourceTree = "<group>"; };
     591                1A90C23512650717003E44D4 /* PageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageOverlay.h; sourceTree = "<group>"; };
     592                1A90C23612650717003E44D4 /* PageOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageOverlay.cpp; sourceTree = "<group>"; };
     593                1A90C2A112650C60003E44D4 /* FindPageOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindPageOverlay.h; sourceTree = "<group>"; };
     594                1A90C2A212650C60003E44D4 /* FindPageOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FindPageOverlay.cpp; sourceTree = "<group>"; };
    587595                1AA1C79A100E7FC50078DEBC /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    588596                1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
     
    13141322                                1A90C1F31264FD71003E44D4 /* FindController.cpp */,
    13151323                                1A90C1F21264FD71003E44D4 /* FindController.h */,
     1324                                1A90C2A212650C60003E44D4 /* FindPageOverlay.cpp */,
     1325                                1A90C2A112650C60003E44D4 /* FindPageOverlay.h */,
    13161326                                0F5265B111DD37680006D33C /* LayerBackedDrawingArea.cpp */,
    13171327                                0F5265B211DD37680006D33C /* LayerBackedDrawingArea.h */,
     1328                                1A90C23612650717003E44D4 /* PageOverlay.cpp */,
     1329                                1A90C23512650717003E44D4 /* PageOverlay.h */,
    13181330                                BC72B9F811E6476B001EB4EA /* WebBackForwardListProxy.cpp */,
    13191331                                BC72B9F911E6476B001EB4EA /* WebBackForwardListProxy.h */,
     
    20062018                                1A90C1EE1264FD50003E44D4 /* FindOptions.h in Headers */,
    20072019                                1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
     2020                                1A90C23712650717003E44D4 /* PageOverlay.h in Headers */,
     2021                                1A90C2A312650C60003E44D4 /* FindPageOverlay.h in Headers */,
    20082022                        );
    20092023                        runOnlyForDeploymentPostprocessing = 0;
     
    23102324                                1AC41AC81263C88300054E94 /* BinarySemaphore.cpp in Sources */,
    23112325                                1A90C1F51264FD71003E44D4 /* FindController.cpp in Sources */,
     2326                                1A90C23812650717003E44D4 /* PageOverlay.cpp in Sources */,
     2327                                1A90C2A412650C60003E44D4 /* FindPageOverlay.cpp in Sources */,
    23122328                        );
    23132329                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit2/WebProcess/WebPage/FindController.cpp

    r69598 r69616  
    2626#include "FindController.h"
    2727
     28#include "FindPageOverlay.h"
    2829#include "WebPage.h"
    2930#include <WebCore/Frame.h>
     
    3637FindController::FindController(WebPage* webPage)
    3738    : m_webPage(webPage)
     39    , m_findPageOverlay(0)
    3840{
    3941}
     
    5759    Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
    5860
     61    bool shouldShowOverlay = false;
     62
    5963    if (!found) {
    6064        // We didn't find the string, clear all text matches.
     
    6468        if (selectedFrame)
    6569            selectedFrame->selection()->clear();
     70    } else {
     71        // FIXME: We need to show the find indicator here.
    6672
     73        shouldShowOverlay = findOptions & FindOptionsShowOverlay;
     74    }
     75
     76    if (!shouldShowOverlay) {
     77        if (m_findPageOverlay) {
     78            // Get rid of the overlay.
     79            m_webPage->uninstallPageOverlay();
     80        }
     81       
     82        ASSERT(!m_findPageOverlay);
    6783        return;
     84    }
     85
     86    if (!m_findPageOverlay) {
     87        OwnPtr<FindPageOverlay> findPageOverlay = FindPageOverlay::create(this);
     88        m_findPageOverlay = findPageOverlay.get();
     89        m_webPage->installPageOverlay(findPageOverlay.release());
     90    } else {
     91        // The page overlay needs to be repainted.
     92        m_findPageOverlay->setNeedsDisplay();
    6893    }
    6994}
     
    7499}
    75100
     101void FindController::findPageOverlayDestroyed()
     102{
     103    ASSERT(m_findPageOverlay);
     104    m_findPageOverlay = 0;
     105}
     106
    76107} // namespace WebKit
  • trunk/WebKit2/WebProcess/WebPage/FindController.h

    r69598 r69616  
    3737namespace WebKit {
    3838
     39class FindPageOverlay;
    3940class WebPage;
    4041
     
    4849    void hideFindUI();
    4950
     51    void findPageOverlayDestroyed();
     52
    5053private:
    5154    WebPage* m_webPage;
     55    FindPageOverlay* m_findPageOverlay;
    5256};
    5357
  • trunk/WebKit2/WebProcess/WebPage/FindPageOverlay.cpp

    r69614 r69616  
    2424 */
    2525
    26 #ifndef FindController_h
    27 #define FindController_h
     26#include "FindPageOverlay.h"
    2827
    29 #include "FindOptions.h"
    30 #include <wtf/Forward.h>
    31 #include <wtf/Noncopyable.h>
     28#include "FindController.h"
     29#include <WebCore/GraphicsContext.h>
    3230
    33 namespace WebCore {
    34     class Frame;
    35 }
     31using namespace WebCore;
    3632
    3733namespace WebKit {
    3834
    39 class WebPage;
     35PassOwnPtr<FindPageOverlay> FindPageOverlay::create(FindController* findController)
     36{
     37    return adoptPtr(new FindPageOverlay(findController));
     38}
    4039
    41 class FindController {
    42     WTF_MAKE_NONCOPYABLE(FindController);
     40FindPageOverlay::FindPageOverlay(FindController* findController)
     41    : m_findController(findController)
     42{
     43}
    4344
    44 public:
    45     explicit FindController(WebPage*);
     45FindPageOverlay::~FindPageOverlay()
     46{
     47    m_findController->findPageOverlayDestroyed();
     48}
    4649
    47     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
    48     void hideFindUI();
     50void FindPageOverlay::drawRect(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
     51{
     52    // FIXME: Draw something.
     53}
    4954
    50 private:
    51     WebPage* m_webPage;
    52 };
    5355
    5456} // namespace WebKit
    55 
    56 #endif // FindController_h
  • trunk/WebKit2/WebProcess/WebPage/FindPageOverlay.h

    r69614 r69616  
    2424 */
    2525
    26 #ifndef FindController_h
    27 #define FindController_h
     26#ifndef FindPageOverlay_h
     27#define FindPageOverlay_h
    2828
    29 #include "FindOptions.h"
    30 #include <wtf/Forward.h>
    31 #include <wtf/Noncopyable.h>
    32 
    33 namespace WebCore {
    34     class Frame;
    35 }
     29#include "PageOverlay.h"
     30#include <wtf/PassOwnPtr.h>
    3631
    3732namespace WebKit {
    3833
    39 class WebPage;
     34class FindController;
    4035
    41 class FindController {
    42     WTF_MAKE_NONCOPYABLE(FindController);
    43 
     36class FindPageOverlay : public PageOverlay {
    4437public:
    45     explicit FindController(WebPage*);
    46 
    47     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
    48     void hideFindUI();
     38    static PassOwnPtr<FindPageOverlay> create(FindController*);
     39    virtual ~FindPageOverlay();
    4940
    5041private:
    51     WebPage* m_webPage;
     42    explicit FindPageOverlay(FindController*);
     43
     44    // PageOverlay.
     45    virtual void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
     46
     47    FindController* m_findController;
    5248};
    5349
    5450} // namespace WebKit
    5551
    56 #endif // FindController_h
     52#endif // FindPageOverlay_h
  • trunk/WebKit2/WebProcess/WebPage/PageOverlay.cpp

    r69614 r69616  
    2424 */
    2525
    26 #ifndef FindController_h
    27 #define FindController_h
     26#include "PageOverlay.h"
    2827
    29 #include "FindOptions.h"
    30 #include <wtf/Forward.h>
    31 #include <wtf/Noncopyable.h>
     28#include "WebPage.h"
    3229
    33 namespace WebCore {
    34     class Frame;
    35 }
     30using namespace WebCore;
    3631
    3732namespace WebKit {
    3833
    39 class WebPage;
     34PageOverlay::PageOverlay()
     35    : m_webPage(0)
     36{
     37}
    4038
    41 class FindController {
    42     WTF_MAKE_NONCOPYABLE(FindController);
     39PageOverlay::~PageOverlay()
     40{
     41}
    4342
    44 public:
    45     explicit FindController(WebPage*);
     43void PageOverlay::setPage(WebPage* webPage)
     44{
     45    ASSERT(!m_webPage);
    4646
    47     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
    48     void hideFindUI();
     47    m_webPage = webPage;
     48    setNeedsDisplay();
     49}
    4950
    50 private:
    51     WebPage* m_webPage;
    52 };
     51void PageOverlay::setNeedsDisplay()
     52{
     53    m_webPage->drawingArea()->setNeedsDisplay(IntRect(IntPoint(), m_webPage->size()));
     54}
    5355
    5456} // namespace WebKit
    55 
    56 #endif // FindController_h
  • trunk/WebKit2/WebProcess/WebPage/PageOverlay.h

    r69614 r69616  
    2424 */
    2525
    26 #ifndef FindController_h
    27 #define FindController_h
     26#ifndef PageOverlay_h
     27#define PageOverlay_h
    2828
    29 #include "FindOptions.h"
    30 #include <wtf/Forward.h>
    3129#include <wtf/Noncopyable.h>
    3230
    3331namespace WebCore {
    34     class Frame;
     32    class GraphicsContext;
     33    class IntRect;
    3534}
    3635
     
    3938class WebPage;
    4039
    41 class FindController {
    42     WTF_MAKE_NONCOPYABLE(FindController);
     40class PageOverlay {
     41    WTF_MAKE_NONCOPYABLE(PageOverlay);
    4342
    4443public:
    45     explicit FindController(WebPage*);
     44    virtual ~PageOverlay();
     45    virtual void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) = 0;
     46   
     47    void setPage(WebPage*);
     48    void setNeedsDisplay();
    4649
    47     void findString(const String&, FindDirection, FindOptions, unsigned maxNumMatches);
    48     void hideFindUI();
     50protected:
     51    PageOverlay();
    4952
    5053private:
     
    5457} // namespace WebKit
    5558
    56 #endif // FindController_h
     59#endif // PageOverlay_h
  • trunk/WebKit2/WebProcess/WebPage/WebPage.cpp

    r69598 r69616  
    3131#include "MessageID.h"
    3232#include "NetscapePlugin.h"
     33#include "PageOverlay.h"
    3334#include "PluginProcessConnection.h"
    3435#include "PluginProcessConnectionManager.h"
     
    383384    m_mainFrame->coreFrame()->view()->paint(&graphicsContext, rect);
    384385    graphicsContext.restore();
     386
     387    if (m_pageOverlay) {
     388        graphicsContext.save();
     389        graphicsContext.clip(rect);
     390        m_pageOverlay->drawRect(graphicsContext, rect);
     391        graphicsContext.restore();
     392    }
    385393}
    386394
     
    423431        return;
    424432    return frame->setPageAndTextZoomFactors(static_cast<float>(pageZoomFactor), static_cast<float>(textZoomFactor));
     433}
     434
     435void WebPage::installPageOverlay(PassOwnPtr<PageOverlay> pageOverlay)
     436{
     437    m_pageOverlay = pageOverlay;
     438    m_pageOverlay->setPage(this);
     439}
     440
     441void WebPage::uninstallPageOverlay()
     442{
     443    m_pageOverlay = 0;
    425444}
    426445
  • trunk/WebKit2/WebProcess/WebPage/WebPage.h

    r69598 r69616  
    6565
    6666class DrawingArea;
     67class PageOverlay;
    6768class PluginView;
    6869class WebEvent;
     
    157158    HWND nativeWindow() const { return m_nativeWindow; }
    158159#endif
     160
     161    void installPageOverlay(PassOwnPtr<PageOverlay>);
     162    void uninstallPageOverlay();
    159163
    160164    static const WebEvent* currentEvent();
     
    253257
    254258    FindController m_findController;
     259    OwnPtr<PageOverlay> m_pageOverlay;
    255260
    256261    uint64_t m_pageID;
  • trunk/WebKit2/win/WebKit2.vcproj

    r69598 r69616  
    10451045                                </File>
    10461046                                <File
     1047                                        RelativePath="..\WebProcess\WebPage\FindPageOverlay.cpp"
     1048                                        >
     1049                                </File>
     1050                                <File
     1051                                        RelativePath="..\WebProcess\WebPage\FindPageOverlay.h"
     1052                                        >
     1053                                </File>
     1054                                <File
     1055                                        RelativePath="..\WebProcess\WebPage\PageOverlay.cpp"
     1056                                        >
     1057                                </File>
     1058                                <File
     1059                                        RelativePath="..\WebProcess\WebPage\PageOverlay.h"
     1060                                        >
     1061                                </File>
     1062                                <File
    10471063                                        RelativePath="..\WebProcess\WebPage\WebBackForwardListProxy.cpp"
    10481064                                        >
  • trunk/WebKitTools/ChangeLog

    r69597 r69616  
     12010-10-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Start fleshing out find page overlays
     6        https://bugs.webkit.org/show_bug.cgi?id=47559
     7
     8        * MiniBrowser/mac/BrowserWindowController.m:
     9        (-[BrowserWindowController find:]):
     10        Pass kWKFindOptionsShowOverlay to WKPageFindString.
     11
    1122010-10-12  Robert Hogan  <robert@webkit.org>
    213
  • trunk/WebKitTools/MiniBrowser/mac/BrowserWindowController.m

    r69595 r69616  
    670670
    671671    WKPageFindString(_webView.pageRef, string, kWKFindDirectionForward,
    672                      kWKFindOptionsCaseInsensitive | kWKFindOptionsWrapAround | kWKFindOptionsShowFindIndicator, 100);
     672                     kWKFindOptionsCaseInsensitive | kWKFindOptionsWrapAround | kWKFindOptionsShowFindIndicator | kWKFindOptionsShowOverlay, 100);
    673673}
    674674
Note: See TracChangeset for help on using the changeset viewer.