#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 didInvalidateDocumentMarkerRects();
void redraw();
private:
void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
void didMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;
bool mouseEvent(WebCore::PageOverlay&, const WebCore::PlatformMouseEvent&) override;
void drawRect(WebCore::PageOverlay&, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) override;
Vector<WebCore::IntRect> rectsForTextMatchesInRect(WebCore::IntRect clipRect);
bool updateFindIndicator(WebCore::Frame& selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
void updateFindUIAfterPageScroll(bool found, const String&, FindOptions, unsigned maxMatchCount);
void willFindString();
void didFindString();
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