#ifndef FindController_h
#define FindController_h
#include "PageOverlay.h"
#include "ShareableBitmap.h"
#include "WebFindOptions.h"
#include <WebCore/IntRect.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
namespace WebCore {
class Frame;
class Range;
}
namespace WebKit {
class WebPage;
class FindController : private PageOverlay::Client {
WTF_MAKE_NONCOPYABLE(FindController);
public:
explicit FindController(WebPage*);
virtual ~FindController();
void findString(const String&, FindOptions, unsigned maxMatchCount);
void findStringMatches(const String&, FindOptions, unsigned maxMatchCount);
void getImageForFindMatch(uint32_t matchIndex);
void selectFindMatch(uint32_t matchIndex);
void hideFindUI();
void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
void hideFindIndicator();
void showFindIndicatorInSelection();
bool isShowingOverlay() const { return m_isShowingFindIndicator && m_findPageOverlay; }
void deviceScaleFactorDidChange();
private:
virtual void pageOverlayDestroyed(PageOverlay*);
virtual void willMoveToWebPage(PageOverlay*, WebPage*);
virtual void didMoveToWebPage(PageOverlay*, WebPage*);
virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&);
virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
Vector<WebCore::IntRect> rectsForTextMatches();
bool getFindIndicatorBitmapAndRect(WebCore::Frame*, ShareableBitmap::Handle&, WebCore::IntRect& selectionRect);
bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount);
WebPage* m_webPage;
PageOverlay* m_findPageOverlay;
bool m_isShowingFindIndicator;
WebCore::IntRect m_findIndicatorRect;
Vector<RefPtr<WebCore::Range>> m_findMatches;
};
}
#endif // FindController_h