#ifndef FindController_h
#define FindController_h
#include "ShareableBitmap.h"
#include "WebFindOptions.h"
#include <WebCore/IntRect.h>
#include <WebCore/PageOverlay.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#if PLATFORM(IOS)
#include "FindIndicatorOverlayClientIOS.h"
#endif
namespace WebCore {
class Frame;
class Range;
}
namespace WebKit {
class WebPage;
class FindController : private WebCore::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();
void redraw();
private:
virtual void pageOverlayDestroyed(WebCore::PageOverlay&);
virtual void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*);
virtual void didMoveToPage(WebCore::PageOverlay&, WebCore::Page*);
virtual bool mouseEvent(WebCore::PageOverlay&, const WebCore::PlatformMouseEvent&);
virtual void drawRect(WebCore::PageOverlay&, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
Vector<WebCore::IntRect> rectsForTextMatches();
bool updateFindIndicator(WebCore::Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount);
void willFindString();
void didFailToFindString();
void didHideFindIndicator();
WebPage* m_webPage;
WebCore::PageOverlay* m_findPageOverlay;
bool m_isShowingFindIndicator;
WebCore::IntRect m_findIndicatorRect;
Vector<RefPtr<WebCore::Range>> m_findMatches;
int m_foundStringMatchIndex;
#if PLATFORM(IOS)
RefPtr<WebCore::PageOverlay> m_findIndicatorOverlay;
std::unique_ptr<FindIndicatorOverlayClientIOS> m_findIndicatorOverlayClient;
#endif
};
}
#endif // FindController_h