This source file includes following definitions.
- isInfiniteOrNonNumber
- m_pauseOnExit
- cueWillChange
- cueDidChange
- track
- setTrack
- setId
- setStartTime
- setEndTime
- setPauseOnExit
- cueIndex
- invalidateCueIndex
- dispatchEvent
- isActive
- setIsActive
- interfaceName
#include "config.h"
#include "core/html/track/TextTrackCue.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/events/Event.h"
#include "core/html/track/TextTrack.h"
#include "core/html/track/TextTrackCueList.h"
namespace WebCore {
static const int invalidCueIndex = -1;
bool TextTrackCue::isInfiniteOrNonNumber(double value, ExceptionState& exceptionState)
{
if (!std::isfinite(value)) {
exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value));
return true;
}
return false;
}
TextTrackCue::TextTrackCue(double start, double end)
: m_startTime(start)
, m_endTime(end)
, m_cueIndex(invalidCueIndex)
, m_track(0)
, m_isActive(false)
, m_pauseOnExit(false)
{
}
void TextTrackCue::cueWillChange()
{
if (m_track)
m_track->cueWillChange(this);
}
void TextTrackCue::cueDidChange()
{
if (m_track)
m_track->cueDidChange(this);
}
TextTrack* TextTrackCue::track() const
{
return m_track;
}
void TextTrackCue::setTrack(TextTrack* track)
{
m_track = track;
}
void TextTrackCue::setId(const AtomicString& id)
{
if (m_id == id)
return;
cueWillChange();
m_id = id;
cueDidChange();
}
void TextTrackCue::setStartTime(double value, ExceptionState& exceptionState)
{
if (isInfiniteOrNonNumber(value, exceptionState))
return;
if (m_startTime == value || value < 0)
return;
cueWillChange();
m_startTime = value;
cueDidChange();
}
void TextTrackCue::setEndTime(double value, ExceptionState& exceptionState)
{
if (isInfiniteOrNonNumber(value, exceptionState))
return;
if (m_endTime == value || value < 0)
return;
cueWillChange();
m_endTime = value;
cueDidChange();
}
void TextTrackCue::setPauseOnExit(bool value)
{
if (m_pauseOnExit == value)
return;
cueWillChange();
m_pauseOnExit = value;
cueDidChange();
}
int TextTrackCue::cueIndex()
{
if (m_cueIndex == invalidCueIndex)
m_cueIndex = track()->cues()->getCueIndex(this);
return m_cueIndex;
}
void TextTrackCue::invalidateCueIndex()
{
m_cueIndex = invalidCueIndex;
}
bool TextTrackCue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
{
if (!track() || track()->mode() == TextTrack::disabledKeyword())
return false;
return EventTarget::dispatchEvent(event);
}
bool TextTrackCue::isActive()
{
return m_isActive && track() && track()->mode() != TextTrack::disabledKeyword();
}
void TextTrackCue::setIsActive(bool active)
{
m_isActive = active;
if (!active)
removeDisplayTree();
}
const AtomicString& TextTrackCue::interfaceName() const
{
return EventTargetNames::TextTrackCue;
}
}