mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 949642 - Implement VTTCue::LineAlign. r=rillian
This commit is contained in:
parent
1486f7e3ec
commit
47bef1e163
@ -41,6 +41,7 @@ TextTrackCue::SetDefaultCueSettings()
|
||||
mSnapToLines = true;
|
||||
mLine = WEBVTT_AUTO;
|
||||
mAlign = AlignSetting::Middle;
|
||||
mLineAlign = AlignSetting::Start;
|
||||
mVertical = DirectionSetting::_empty;
|
||||
}
|
||||
|
||||
|
@ -174,6 +174,26 @@ public:
|
||||
mLine = aLine;
|
||||
}
|
||||
|
||||
AlignSetting LineAlign() const
|
||||
{
|
||||
return mLineAlign;
|
||||
}
|
||||
|
||||
void SetLineAlign(AlignSetting& aLineAlign, ErrorResult& aRv)
|
||||
{
|
||||
if (mLineAlign == aLineAlign)
|
||||
return;
|
||||
|
||||
if (aLineAlign == AlignSetting::Left ||
|
||||
aLineAlign == AlignSetting::Right) {
|
||||
return aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
}
|
||||
|
||||
mReset = true;
|
||||
mLineAlign = aLineAlign;
|
||||
CueChanged();
|
||||
}
|
||||
|
||||
int32_t Position() const
|
||||
{
|
||||
return mPosition;
|
||||
@ -324,6 +344,7 @@ private:
|
||||
DirectionSetting mVertical;
|
||||
int mLine;
|
||||
AlignSetting mAlign;
|
||||
AlignSetting mLineAlign;
|
||||
|
||||
// Holds the computed DOM elements that represent the parsed cue text.
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#text-track-cue-display-state
|
||||
|
@ -72,6 +72,34 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
cue.pauseOnExit = true;
|
||||
is(cue.pauseOnExit, true, "Cue's pause on exit flag should be true.");
|
||||
|
||||
// Check that cue line align works properly
|
||||
is(cue.lineAlign, "start", "Cue's default line alignment should be start.");
|
||||
|
||||
var exceptionHappened = false;
|
||||
try {
|
||||
cue.lineAlign = "left";
|
||||
} catch(e) {
|
||||
exceptionHappened = true;
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError.");
|
||||
}
|
||||
ok(exceptionHappened, "Exception should have happened.");
|
||||
|
||||
exceptionHappened = false;
|
||||
try {
|
||||
cue.lineAlign = "right";
|
||||
} catch(e) {
|
||||
exceptionHappened = true;
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError.");
|
||||
}
|
||||
ok(exceptionHappened, "Exception should have happened.");
|
||||
|
||||
cue.lineAlign = "middle";
|
||||
is(cue.lineAlign, "middle", "Cue's line align should be middle.");
|
||||
cue.lineAlign = "START";
|
||||
is(cue.lineAlign, "middle", "Cue's line align should be middle.");
|
||||
cue.lineAlign = "end";
|
||||
is(cue.lineAlign, "end", "Cue's line align should be end.");
|
||||
|
||||
// Check that we can create and add new VTTCues
|
||||
var vttCue = new VTTCue(3.999, 4, "foo");
|
||||
trackElement.track.addCue(vttCue);
|
||||
@ -91,7 +119,7 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
||||
trackElement.track.removeCue(cue);
|
||||
is(cueList.length, 4, "Cue list length should be 4.");
|
||||
|
||||
var exceptionHappened = false;
|
||||
exceptionHappened = false;
|
||||
try {
|
||||
// We should not be able to remove a cue that is not in the list.
|
||||
cue = new VTTCue(1, 2, "foo");
|
||||
|
@ -38,6 +38,8 @@ interface VTTCue : EventTarget {
|
||||
// XXXhumph: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20651
|
||||
// attribute (long or AutoKeyword) line;
|
||||
[SetterThrows]
|
||||
attribute AlignSetting lineAlign;
|
||||
[SetterThrows]
|
||||
attribute long position;
|
||||
[SetterThrows]
|
||||
attribute long size;
|
||||
|
Loading…
Reference in New Issue
Block a user