#ifndef VTTRegion_h
#define VTTRegion_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/html/track/TextTrack.h"
#include "platform/Timer.h"
#include "platform/geometry/FloatPoint.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExceptionState;
class HTMLDivElement;
class VTTCueBox;
class VTTScanner;
class VTTRegion : public RefCounted<VTTRegion> {
public:
static PassRefPtr<VTTRegion> create()
{
return adoptRef(new VTTRegion());
}
virtual ~VTTRegion();
TextTrack* track() const { return m_track; }
void setTrack(TextTrack*);
const String& id() const { return m_id; }
void setId(const String&);
double width() const { return m_width; }
void setWidth(double, ExceptionState&);
long height() const { return m_heightInLines; }
void setHeight(long, ExceptionState&);
double regionAnchorX() const { return m_regionAnchor.x(); }
void setRegionAnchorX(double, ExceptionState&);
double regionAnchorY() const { return m_regionAnchor.y(); }
void setRegionAnchorY(double, ExceptionState&);
double viewportAnchorX() const { return m_viewportAnchor.x(); }
void setViewportAnchorX(double, ExceptionState&);
double viewportAnchorY() const { return m_viewportAnchor.y(); }
void setViewportAnchorY(double, ExceptionState&);
const AtomicString scroll() const;
void setScroll(const AtomicString&, ExceptionState&);
void updateParametersFromRegion(VTTRegion*);
const String& regionSettings() const { return m_settings; }
void setRegionSettings(const String&);
bool isScrollingRegion() { return m_scroll; }
PassRefPtr<HTMLDivElement> getDisplayTree(Document&);
void appendVTTCueBox(PassRefPtr<VTTCueBox>);
void displayLastVTTCueBox();
void willRemoveVTTCueBox(VTTCueBox*);
private:
VTTRegion();
void prepareRegionDisplayTree();
void startTimer();
void stopTimer();
void scrollTimerFired(Timer<VTTRegion>*);
enum RegionSetting {
None,
Id,
Width,
Height,
RegionAnchor,
ViewportAnchor,
Scroll
};
RegionSetting scanSettingName(VTTScanner&);
void parseSettingValue(RegionSetting, VTTScanner&);
static const AtomicString& textTrackCueContainerShadowPseudoId();
static const AtomicString& textTrackCueContainerScrollingClass();
static const AtomicString& textTrackRegionShadowPseudoId();
String m_id;
String m_settings;
double m_width;
unsigned m_heightInLines;
FloatPoint m_regionAnchor;
FloatPoint m_viewportAnchor;
bool m_scroll;
RefPtr<HTMLDivElement> m_cueContainer;
RefPtr<HTMLDivElement> m_regionDisplayTree;
TextTrack* m_track;
double m_currentTop;
Timer<VTTRegion> m_scrollTimer;
};
}
#endif