#ifndef PageOverlay_h
#define PageOverlay_h
#include "Color.h"
#include "FloatPoint.h"
#include "IntRect.h"
#include "Timer.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class Frame;
class GraphicsContext;
class GraphicsLayer;
class Page;
class PageOverlayController;
class PlatformMouseEvent;
class PageOverlay final : public RefCounted<PageOverlay> {
WTF_MAKE_NONCOPYABLE(PageOverlay);
WTF_MAKE_FAST_ALLOCATED;
public:
class Client {
protected:
virtual ~Client() { }
public:
virtual void pageOverlayDestroyed(PageOverlay&) = 0;
virtual void willMoveToPage(PageOverlay&, Page*) = 0;
virtual void didMoveToPage(PageOverlay&, Page*) = 0;
virtual void drawRect(PageOverlay&, GraphicsContext&, const IntRect& dirtyRect) = 0;
virtual bool mouseEvent(PageOverlay&, const PlatformMouseEvent&) = 0;
virtual void didScrollFrame(PageOverlay&, Frame&) { }
virtual bool copyAccessibilityAttributeStringValueForPoint(PageOverlay&, String , FloatPoint, String&) { return false; }
virtual bool copyAccessibilityAttributeBoolValueForPoint(PageOverlay&, String , FloatPoint, bool&) { return false; }
virtual Vector<String> copyAccessibilityAttributeNames(PageOverlay&, bool ) { return { }; }
};
enum class OverlayType {
View, Document, };
WEBCORE_EXPORT static Ref<PageOverlay> create(Client&, OverlayType = OverlayType::View);
WEBCORE_EXPORT virtual ~PageOverlay();
WEBCORE_EXPORT PageOverlayController* controller() const;
typedef uint64_t PageOverlayID;
virtual PageOverlayID pageOverlayID() const { return m_pageOverlayID; }
void setPage(Page*);
WEBCORE_EXPORT void setNeedsDisplay(const IntRect& dirtyRect);
WEBCORE_EXPORT void setNeedsDisplay();
void drawRect(GraphicsContext&, const IntRect& dirtyRect);
bool mouseEvent(const PlatformMouseEvent&);
void didScrollFrame(Frame&);
bool copyAccessibilityAttributeStringValueForPoint(String attribute, FloatPoint parameter, String& value);
bool copyAccessibilityAttributeBoolValueForPoint(String attribute, FloatPoint parameter, bool& value);
Vector<String> copyAccessibilityAttributeNames(bool parameterizedNames);
void startFadeInAnimation();
void startFadeOutAnimation();
WEBCORE_EXPORT void stopFadeOutAnimation();
WEBCORE_EXPORT void clear();
Client& client() const { return m_client; }
enum class FadeMode { DoNotFade, Fade };
OverlayType overlayType() { return m_overlayType; }
WEBCORE_EXPORT IntRect bounds() const;
WEBCORE_EXPORT IntRect frame() const;
WEBCORE_EXPORT void setFrame(IntRect);
WEBCORE_EXPORT IntSize viewToOverlayOffset() const;
RGBA32 backgroundColor() const { return m_backgroundColor; }
void setBackgroundColor(RGBA32);
WEBCORE_EXPORT GraphicsLayer& layer();
private:
explicit PageOverlay(Client&, OverlayType);
void startFadeAnimation();
void fadeAnimationTimerFired();
Client& m_client;
Page* m_page;
Timer m_fadeAnimationTimer;
double m_fadeAnimationStartTime;
double m_fadeAnimationDuration;
enum FadeAnimationType {
NoAnimation,
FadeInAnimation,
FadeOutAnimation,
};
FadeAnimationType m_fadeAnimationType;
float m_fractionFadedIn;
OverlayType m_overlayType;
IntRect m_overrideFrame;
RGBA32 m_backgroundColor;
PageOverlayID m_pageOverlayID;
};
}
#endif // PageOverlay_h