#ifndef PageOverlay_h
#define PageOverlay_h
#include "APIObject.h"
#include "WKBase.h"
#include <WebCore/RunLoop.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class GraphicsContext;
class IntPoint;
class IntRect;
}
namespace WebKit {
class WebMouseEvent;
class WebPage;
class PageOverlay : public TypedAPIObject<APIObject::TypeBundlePageOverlay> {
public:
class Client {
protected:
virtual ~Client() { }
public:
virtual void pageOverlayDestroyed(PageOverlay*) = 0;
virtual void willMoveToWebPage(PageOverlay*, WebPage*) = 0;
virtual void didMoveToWebPage(PageOverlay*, WebPage*) = 0;
virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect) = 0;
virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&) = 0;
virtual WKTypeRef copyAccessibilityAttributeValue(PageOverlay*, WKStringRef attribute, WKTypeRef parameter) { return 0; }
virtual WKArrayRef copyAccessibilityAttributeNames(PageOverlay*, bool parameterizedNames) { return 0; }
};
static PassRefPtr<PageOverlay> create(Client*);
virtual ~PageOverlay();
void setPage(WebPage*);
void setNeedsDisplay(const WebCore::IntRect& dirtyRect);
void setNeedsDisplay();
void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
bool mouseEvent(const WebMouseEvent&);
WKTypeRef copyAccessibilityAttributeValue(WKStringRef attribute, WKTypeRef parameter);
WKArrayRef copyAccessibilityAttributeNames(bool parameterizedNames);
void startFadeInAnimation();
void startFadeOutAnimation();
void stopFadeOutAnimation();
float fractionFadedIn() const { return m_fractionFadedIn; }
Client* client() const { return m_client; }
protected:
explicit PageOverlay(Client*);
private:
WebCore::IntRect bounds() const;
void startFadeAnimation();
void fadeAnimationTimerFired();
Client* m_client;
WebPage* m_webPage;
WebCore::RunLoop::Timer<PageOverlay> m_fadeAnimationTimer;
double m_fadeAnimationStartTime;
double m_fadeAnimationDuration;
enum FadeAnimationType {
NoAnimation,
FadeInAnimation,
FadeOutAnimation,
};
FadeAnimationType m_fadeAnimationType;
float m_fractionFadedIn;
bool m_pageOverlayShouldApplyFadeWhenPainting;
};
}
#endif // PageOverlay_h