Make TextTrackCue more mutable

https://bugs.webkit.org/show_bug.cgi?id=72555

Reviewed by Anders Carlsson.

Source/WebCore: 

Test: media/track/track-cue-mutable.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Do nothing if the "ignore cue updates"
    flag is set
(WebCore::HTMLMediaElement::textTrackAddCues): Block cue updates until all of the new cues have
    been added, then call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackRemoveCues): Block cue updates until all of the new cues have
    been removed, then call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackAddCue): Call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackRemoveCue): Ditto.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::ignoreTrackDisplayUpdateRequests):
(WebCore::HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests):
(WebCore::HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests):

* html/TextTrack.cpp:
(WebCore::TextTrack::cueWillChange): New, remove the cue from the media element because its
    position in the interval tree is based on start and end times.
(WebCore::TextTrack::cueDidChange): Add the cue to the media element.
* html/TextTrack.h:

* html/TextTrackCue.cpp:
(WebCore::startKeyword): New, use a static String for the constant.
(WebCore::middleKeyword): Ditto.
(WebCore::endKeyword): Ditto.
(WebCore::horizontalKeyword): Ditto.
(WebCore::verticalKeyword): Ditto.
(WebCore::verticallrKeyword): Ditto.
(WebCore::TextTrackCue::cueWillChange): New, tell the track the cue is about to change.
(WebCore::TextTrackCue::cueDidChange): New, tell the track the cue has changed.
(WebCore::TextTrackCue::setId): New, attribute is mutable.
(WebCore::TextTrackCue::setStartTime): Ditto.
(WebCore::TextTrackCue::setEndTime): Ditto.
(WebCore::TextTrackCue::setPauseOnExit): Ditto.
(WebCore::TextTrackCue::direction): Ditto.
(WebCore::TextTrackCue::setDirection): Ditto.
(WebCore::TextTrackCue::setSnapToLines): Ditto.
(WebCore::TextTrackCue::setLinePosition): Ditto.
(WebCore::TextTrackCue::setTextPosition): Ditto.
(WebCore::TextTrackCue::setSize): Ditto.
(WebCore::TextTrackCue::alignment): Ditto.
(WebCore::TextTrackCue::setAlignment): Ditto.
(WebCore::TextTrackCue::parseSettings): Use the static strings.
* html/TextTrackCue.h:
(WebCore::TextTrackCue::id):
(WebCore::TextTrackCue::startTime):
(WebCore::TextTrackCue::endTime):
(WebCore::TextTrackCue::pauseOnExit):
* html/TextTrackCue.idl:

LayoutTests: 

* media/track/track-cue-mutable-expected.txt: Added.
* media/track/track-cue-mutable.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ecf6e222
2012-01-06 Eric Carlson <eric.carlson@apple.com>
Make TextTrackCue more mutable
https://bugs.webkit.org/show_bug.cgi?id=72555
Reviewed by Anders Carlsson.
* media/track/track-cue-mutable-expected.txt: Added.
* media/track/track-cue-mutable.html: Added.
2012-01-06 Ken Buchanan <kenrb@chromium.org>
ASSERT failure due to combine-text with preceding spaces
Tests modifying attributes of a TextTrackCue
** Test initial values.
RUN(textCue = cues.getCueById('1'))
EXPECTED (textCue.startTime == '0') OK
EXPECTED (textCue.endTime == '1') OK
EXPECTED (textCue.pauseOnExit == 'false') OK
EXPECTED (textCue.direction == 'horizontal') OK
EXPECTED (textCue.snapToLines == 'true') OK
EXPECTED (textCue.linePosition == '-1') OK
EXPECTED (textCue.textPosition == '50') OK
EXPECTED (textCue.size == '100') OK
EXPECTED (textCue.alignment == 'middle') OK
** Modify cue values.
RUN(textCue.startTime = 1.1)
EXPECTED (textCue.startTime == '1.1') OK
RUN(textCue.endTime = 3.9)
EXPECTED (textCue.endTime == '3.9') OK
RUN(textCue.pauseOnExit = true)
EXPECTED (textCue.pauseOnExit == 'true') OK
On setting, the text track cue writing direction must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-direction
TEST(textCue.direction = 'VERTICAL') THROWS(DOMException.SYNTAX_ERR) OK
EXPECTED (textCue.direction == 'horizontal') OK
RUN(textCue.direction = 'vertical')
EXPECTED (textCue.direction == 'vertical') OK
RUN(textCue.snapToLines = false)
EXPECTED (textCue.snapToLines == 'false') OK
On setting, if the text track cue snap-to-lines flag is not set, and the new value is negative or greater than 100, then throw an IndexSizeError exception.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition
TEST(textCue.linePosition = -2) THROWS(DOMException.INDEX_SIZE_ERR) OK
TEST(textCue.linePosition = 102) THROWS(DOMException.INDEX_SIZE_ERR) OK
EXPECTED (textCue.linePosition == '-1') OK
RUN(textCue.linePosition = 42)
EXPECTED (textCue.linePosition == '42') OK
RUN(textCue.snapToLines = true)
RUN(textCue.linePosition = -2)
EXPECTED (textCue.linePosition == '-2') OK
RUN(textCue.linePosition = 102)
EXPECTED (textCue.linePosition == '102') OK
On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue text position to the new value.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition
TEST(textCue.textPosition = -200) THROWS(DOMException.INDEX_SIZE_ERR) OK
TEST(textCue.textPosition = 110) THROWS(DOMException.INDEX_SIZE_ERR) OK
RUN(textCue.textPosition = 11)
EXPECTED (textCue.textPosition == '11') OK
On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue size to the new value.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
TEST(textCue.size = -200) THROWS(DOMException.INDEX_SIZE_ERR) OK
TEST(textCue.size = 110) THROWS(DOMException.INDEX_SIZE_ERR) OK
RUN(textCue.size = 57)
EXPECTED (textCue.size == '57') OK
On setting, the text track cue alignment must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-alignment
TEST(textCue.alignment = 'End') THROWS(DOMException.SYNTAX_ERR) OK
EXPECTED (textCue.alignment == 'middle') OK
RUN(textCue.alignment = 'end')
EXPECTED (textCue.alignment == 'end') OK
END OF TEST
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=../media-file.js></script>
<script src=../video-test.js></script>
<script>
var cues;
function logSpecURL(url, description)
{
consoleWrite("<br><i>" + description + "</i>");
consoleWrite("<a href=" + url + ">" + url + "<" + "/a>");
}
function trackLoaded()
{
track = document.getElementById('captions');
cues = track.track.cues;
consoleWrite("** Test initial values.");
run("textCue = cues.getCueById('1')");
testExpected("textCue.startTime", 0);
testExpected("textCue.endTime", 1.0);
testExpected("textCue.pauseOnExit", false);
testExpected("textCue.direction", "horizontal");
testExpected("textCue.snapToLines", true);
testExpected("textCue.linePosition", -1);
testExpected("textCue.textPosition", 50);
testExpected("textCue.size", 100);
testExpected("textCue.alignment", "middle");
consoleWrite("<br>** Modify cue values.");
run("textCue.startTime = 1.1");
testExpected("textCue.startTime", 1.1);
consoleWrite("");
run("textCue.endTime = 3.9");
testExpected("textCue.endTime", 3.9);
consoleWrite("");
run("textCue.pauseOnExit = true");
testExpected("textCue.pauseOnExit", true);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-direction",
"On setting, the text track cue writing direction must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.");
testException("textCue.direction = 'VERTICAL'", "DOMException.SYNTAX_ERR");
testExpected("textCue.direction", "horizontal");
run("textCue.direction = 'vertical'");
testExpected("textCue.direction", "vertical");
consoleWrite("");
run("textCue.snapToLines = false");
testExpected("textCue.snapToLines", false);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition",
"On setting, if the text track cue snap-to-lines flag is not set, and the new value is negative or greater than 100, then throw an IndexSizeError exception.");
testException("textCue.linePosition = -2", "DOMException.INDEX_SIZE_ERR");
testException("textCue.linePosition = 102", "DOMException.INDEX_SIZE_ERR");
testExpected("textCue.linePosition", -1);
run("textCue.linePosition = 42");
testExpected("textCue.linePosition", 42);
run("textCue.snapToLines = true");
run("textCue.linePosition = -2");
testExpected("textCue.linePosition", -2);
run("textCue.linePosition = 102");
testExpected("textCue.linePosition", 102);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition",
"On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue text position to the new value.");
testException("textCue.textPosition = -200", "DOMException.INDEX_SIZE_ERR");
testException("textCue.textPosition = 110", "DOMException.INDEX_SIZE_ERR");
run("textCue.textPosition = 11");
testExpected("textCue.textPosition", 11);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size",
"On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue size to the new value.");
testException("textCue.size = -200", "DOMException.INDEX_SIZE_ERR");
testException("textCue.size = 110", "DOMException.INDEX_SIZE_ERR");
run("textCue.size = 57");
testExpected("textCue.size", 57);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-alignment",
"On setting, the text track cue alignment must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.");
testException("textCue.alignment = 'End'", "DOMException.SYNTAX_ERR");
testExpected("textCue.alignment", "middle");
run("textCue.alignment = 'end'");
testExpected("textCue.alignment", "end");
consoleWrite("");
endTest();
}
</script>
</head>
<body>
<p>Tests modifying attributes of a TextTrackCue</p>
<video controls>
<track id="captions" src="captions-webvtt/captions.vtt" kind="captions" onload="trackLoaded()" default>
</video>
</body>
</html>
2012-01-06 Eric Carlson <eric.carlson@apple.com>
Make TextTrackCue more mutable
https://bugs.webkit.org/show_bug.cgi?id=72555
Reviewed by Anders Carlsson.
Test: media/track/track-cue-mutable.html
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues): Do nothing if the "ignore cue updates"
flag is set
(WebCore::HTMLMediaElement::textTrackAddCues): Block cue updates until all of the new cues have
been added, then call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackRemoveCues): Block cue updates until all of the new cues have
been removed, then call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackAddCue): Call updateActiveTextTrackCues so update the display if necessary.
(WebCore::HTMLMediaElement::textTrackRemoveCue): Ditto.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::ignoreTrackDisplayUpdateRequests):
(WebCore::HTMLMediaElement::beginIgnoringTrackDisplayUpdateRequests):
(WebCore::HTMLMediaElement::endIgnoringTrackDisplayUpdateRequests):
* html/TextTrack.cpp:
(WebCore::TextTrack::cueWillChange): New, remove the cue from the media element because its
position in the interval tree is based on start and end times.
(WebCore::TextTrack::cueDidChange): Add the cue to the media element.
* html/TextTrack.h:
* html/TextTrackCue.cpp:
(WebCore::startKeyword): New, use a static String for the constant.
(WebCore::middleKeyword): Ditto.
(WebCore::endKeyword): Ditto.
(WebCore::horizontalKeyword): Ditto.
(WebCore::verticalKeyword): Ditto.
(WebCore::verticallrKeyword): Ditto.
(WebCore::TextTrackCue::cueWillChange): New, tell the track the cue is about to change.
(WebCore::TextTrackCue::cueDidChange): New, tell the track the cue has changed.
(WebCore::TextTrackCue::setId): New, attribute is mutable.
(WebCore::TextTrackCue::setStartTime): Ditto.
(WebCore::TextTrackCue::setEndTime): Ditto.
(WebCore::TextTrackCue::setPauseOnExit): Ditto.
(WebCore::TextTrackCue::direction): Ditto.
(WebCore::TextTrackCue::setDirection): Ditto.
(WebCore::TextTrackCue::setSnapToLines): Ditto.
(WebCore::TextTrackCue::setLinePosition): Ditto.
(WebCore::TextTrackCue::setTextPosition): Ditto.
(WebCore::TextTrackCue::setSize): Ditto.
(WebCore::TextTrackCue::alignment): Ditto.
(WebCore::TextTrackCue::setAlignment): Ditto.
(WebCore::TextTrackCue::parseSettings): Use the static strings.
* html/TextTrackCue.h:
(WebCore::TextTrackCue::id):
(WebCore::TextTrackCue::startTime):
(WebCore::TextTrackCue::endTime):
(WebCore::TextTrackCue::pauseOnExit):
* html/TextTrackCue.idl:
2012-01-06 Oliver Hunt <oliver@apple.com>
DFG no longer optimises CanvasPixelArray
......@@ -948,6 +948,9 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content
#if ENABLE(VIDEO_TRACK)
void HTMLMediaElement::updateActiveTextTrackCues(float movieTime)
{
if (ignoreTrackDisplayUpdateRequests())
return;
CueList previouslyActiveCues = m_currentlyActiveCues;
bool activeSetChanged = false;
......@@ -1030,24 +1033,32 @@ void HTMLMediaElement::textTrackKindChanged(TextTrack*)
void HTMLMediaElement::textTrackAddCues(TextTrack*, const TextTrackCueList* cues)
{
beginIgnoringTrackDisplayUpdateRequests();
for (size_t i = 0; i < cues->length(); ++i)
textTrackAddCue(cues->item(i)->track(), cues->item(i));
endIgnoringTrackDisplayUpdateRequests();
updateActiveTextTrackCues(currentTime());
}
void HTMLMediaElement::textTrackRemoveCues(TextTrack*, const TextTrackCueList* cues)
{
beginIgnoringTrackDisplayUpdateRequests();
for (size_t i = 0; i < cues->length(); ++i)
textTrackRemoveCue(cues->item(i)->track(), cues->item(i));
endIgnoringTrackDisplayUpdateRequests();
updateActiveTextTrackCues(currentTime());
}
void HTMLMediaElement::textTrackAddCue(TextTrack*, PassRefPtr<TextTrackCue> cue)
{
m_cueTree.add(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue.get()));
updateActiveTextTrackCues(currentTime());
}
void HTMLMediaElement::textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue> cue)
{
m_cueTree.remove(m_cueTree.createInterval(cue->startTime(), cue->endTime(), cue.get()));
updateActiveTextTrackCues(currentTime());
}
#endif
......
......@@ -400,6 +400,10 @@ private:
bool userIsInterestedInThisLanguage(const String&) const;
bool userIsInterestedInThisTrack(HTMLTrackElement*) const;
HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const;
bool ignoreTrackDisplayUpdateRequests() const { return m_ignoreTrackDisplayUpdate > 0; }
void beginIgnoringTrackDisplayUpdateRequests() { ++m_ignoreTrackDisplayUpdate; }
void endIgnoringTrackDisplayUpdateRequests() { ASSERT(m_ignoreTrackDisplayUpdate); --m_ignoreTrackDisplayUpdate; }
#endif
// These "internal" functions do not check user gesture restrictions.
......@@ -566,6 +570,7 @@ private:
Vector<RefPtr<TextTrack> > m_textTracksWhenResourceSelectionBegan;
CueIntervalTree m_cueTree;
CueList m_currentlyActiveCues;
int m_ignoreTrackDisplayUpdate;
#endif
#if ENABLE(WEB_AUDIO)
......
......@@ -251,6 +251,25 @@ void TextTrack::fireCueChangeEvent()
ExceptionCode ec = 0;
dispatchEvent(Event::create(eventNames().cuechangeEvent, false, false), ec);
}
void TextTrack::cueWillChange(TextTrackCue* cue)
{
if (!m_client)
return;
// The cue may need to be repositioned in the media element's interval tree, may need to
// be re-rendered, etc, so remove it before the modification...
m_client->textTrackRemoveCue(this, cue);
}
void TextTrack::cueDidChange(TextTrackCue* cue)
{
if (!m_client)
return;
// ... and add it back again.
m_client->textTrackAddCue(this, cue);
}
} // namespace WebCore
......
......@@ -98,6 +98,9 @@ public:
void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&);
void removeCue(TextTrackCue*, ExceptionCode&);
void cueWillChange(TextTrackCue*);
void cueDidChange(TextTrackCue*);
virtual void fireCueChangeEvent();
DEFINE_ATTRIBUTE_EVENT_LISTENER(cuechange);
......
......@@ -42,6 +42,41 @@
namespace WebCore {
static const AtomicString& startKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, start, ("start"));
return start;
}
static const AtomicString& middleKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, middle, ("middle"));
return middle;
}
static const AtomicString& endKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, end, ("end"));
return end;
}
static const AtomicString& horizontalKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, horizontal, ("horizontal"));
return horizontal;
}
static const AtomicString& verticalKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, vertical, ("vertical"));
return vertical;
}
static const AtomicString& verticallrKeyword()
{
DEFINE_STATIC_LOCAL(const AtomicString, verticallr, ("vertical-lr"));
return verticallr;
}
TextTrackCue::TextTrackCue(ScriptExecutionContext* context, const String& id, double start, double end, const String& content, const String& settings, bool pauseOnExit)
: m_id(id)
, m_startTime(start)
......@@ -64,6 +99,18 @@ TextTrackCue::~TextTrackCue()
{
}
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.get();
......@@ -74,54 +121,195 @@ void TextTrackCue::setTrack(PassRefPtr<TextTrack>track)
m_track = track;
}
String TextTrackCue::id() const
void TextTrackCue::setId(const String& id)
{
return m_id;
if (m_id == id)
return;
cueWillChange();
m_id = id;
cueDidChange();
}
double TextTrackCue::startTime() const
void TextTrackCue::setStartTime(double value)
{
return m_startTime;
if (m_startTime == value)
return;
cueWillChange();
m_startTime = value;
cueDidChange();
}
double TextTrackCue::endTime() const
void TextTrackCue::setEndTime(double value)
{
return m_endTime;
if (m_endTime == value)
return;
cueWillChange();
m_endTime = value;
cueDidChange();
}
bool TextTrackCue::pauseOnExit() const
void TextTrackCue::setPauseOnExit(bool value)
{
return m_pauseOnExit;
if (m_pauseOnExit == value)
return;
cueWillChange();
m_pauseOnExit = value;
cueDidChange();
}
String TextTrackCue::direction() const
{
switch (m_writingDirection) {
case Horizontal:
return "horizontal";
return horizontalKeyword();
case VerticalGrowingLeft:
return "vertical";
return verticalKeyword();
case VerticalGrowingRight:
return "vertical-lr";
return verticallrKeyword();
default:
ASSERT_NOT_REACHED();
return "";
}
}
void TextTrackCue::setDirection(const String& value, ExceptionCode& ec)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-direction
// On setting, the text track cue writing direction must be set to the value given
// in the first cell of the row in the table above whose second cell is a
// case-sensitive match for the new value, if any. If none of the values match, then
// the user agent must instead throw a SyntaxError exception.
Direction direction = m_writingDirection;
if (value == horizontalKeyword())
direction = Horizontal;
else if (value == verticalKeyword())
direction = VerticalGrowingLeft;
else if (value == verticallrKeyword())
direction = VerticalGrowingRight;
else
ec = SYNTAX_ERR;
if (direction == m_writingDirection)
return;
cueWillChange();
m_writingDirection = direction;
cueDidChange();
}
void TextTrackCue::setSnapToLines(bool value)
{
if (m_snapToLines == value)
return;
cueWillChange();
m_snapToLines = value;
cueDidChange();
}
void TextTrackCue::setLinePosition(int position, ExceptionCode& ec)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition
// On setting, if the text track cue snap-to-lines flag is not set, and the new
// value is negative or greater than 100, then throw an IndexSizeError exception.
if (!m_snapToLines && (position < 0 || position > 100)) {
ec = INDEX_SIZE_ERR;
return;
}
// Otherwise, set the text track cue line position to the new value.
if (m_linePosition == position)
return;
cueWillChange();
m_linePosition = position;
cueDidChange();
}
void TextTrackCue::setTextPosition(int position, ExceptionCode& ec)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-lineposition
// On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
// Otherwise, set the text track cue text position to the new value.
if (position < 0 || position > 100) {
ec = INDEX_SIZE_ERR;
return;
}
// Otherwise, set the text track cue line position to the new value.
if (m_textPosition == position)
return;
cueWillChange();
m_textPosition = position;
cueDidChange();
}
void TextTrackCue::setSize(int size, ExceptionCode& ec)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
// On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
// exception. Otherwise, set the text track cue size to the new value.
if (size < 0 || size > 100) {
ec = INDEX_SIZE_ERR;
return;
}
// Otherwise, set the text track cue line position to the new value.
if (m_cueSize == size)
return;
cueWillChange();
m_cueSize = size;
cueDidChange();
}
String TextTrackCue::alignment() const
{
switch (m_cueAlignment) {
case Start:
return "start";
case Start:
return startKeyword();
case Middle:
return "middle";
return middleKeyword();
case End:
return "end";
return endKeyword();
default:
ASSERT_NOT_REACHED();
return "";
}
}
void TextTrackCue::setAlignment(const String& value, ExceptionCode& ec)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-alignment
// On setting, the text track cue alignment must be set to the value given in the
// first cell of the row in the table above whose second cell is a case-sensitive
// match for the new value, if any. If none of the values match, then the user
// agent must instead throw a SyntaxError exception.
Alignment alignment = m_cueAlignment;
if (value == startKeyword())
alignment = Start;
else if (value == middleKeyword())
alignment = Middle;
else if (value == endKeyword())
alignment = End;
else
ec = SYNTAX_ERR;
if (alignment == m_cueAlignment)
return;
cueWillChange();
m_cueAlignment = alignment;
cueDidChange();
}
String TextTrackCue::getCueAsSource()
{
return m_content;
......@@ -187,9 +375,9 @@ void TextTrackCue::parseSettings(const String& input)
{
// 1-3 - Collect the next word and set the writing direction accordingly.
String writingDirection = WebVTTParser::collectWord(input, &position);
if (writingDirection == "vertical")
if (writingDirection == verticalKeyword())