Bug 882299 - Implement VTTCue::Line r=smaug,rillian,bz

This commit is contained in:
Rick Eyre 2014-01-15 08:04:00 -08:00
parent 0b1976d65d
commit 1fe94a73b3
5 changed files with 35 additions and 14 deletions

View File

@ -8,9 +8,6 @@
#include "nsComponentManagerUtils.h"
#include "mozilla/ClearOnShutdown.h"
// Alternate value for the 'auto' keyword.
#define WEBVTT_AUTO -1
namespace mozilla {
namespace dom {
@ -38,7 +35,7 @@ TextTrackCue::SetDefaultCueSettings()
mSize = 100;
mPauseOnExit = false;
mSnapToLines = true;
mLine = WEBVTT_AUTO;
mLineIsAutoKeyword = true;
mAlign = AlignSetting::Middle;
mLineAlign = AlignSetting::Start;
mVertical = DirectionSetting::_empty;

View File

@ -15,6 +15,7 @@
#include "mozilla/StaticPtr.h"
#include "nsIDocument.h"
#include "mozilla/dom/HTMLDivElement.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
namespace dom {
@ -168,16 +169,30 @@ public:
CueChanged();
}
double Line() const
void GetLine(OwningLongOrAutoKeyword& aLine) const
{
return mLine;
if (mLineIsAutoKeyword) {
aLine.SetAsAutoKeyword() = AutoKeyword::Auto;
return;
}
aLine.SetAsLong() = mLineLong;
}
void SetLine(double aLine)
void SetLine(const LongOrAutoKeyword& aLine)
{
//XXX: TODO Line position can be a keyword auto. bug882299
mReset = true;
mLine = aLine;
if (aLine.IsLong() &&
(mLineIsAutoKeyword || (aLine.GetAsLong() != mLineLong))) {
mLineIsAutoKeyword = false;
mLineLong = aLine.GetAsLong();
CueChanged();
mReset = true;
return;
}
if (aLine.IsAutoKeyword() && !mLineIsAutoKeyword) {
mLineIsAutoKeyword = true;
CueChanged();
mReset = true;
}
}
AlignSetting LineAlign() const
@ -355,7 +370,8 @@ private:
bool mSnapToLines;
nsString mRegionId;
DirectionSetting mVertical;
int mLine;
bool mLineIsAutoKeyword;
long mLineLong;
AlignSetting mAlign;
AlignSetting mLineAlign;

View File

@ -130,6 +130,13 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
cue.positionAlign = "end";
is(cue.positionAlign, "end", "Cue's position align should be end.");
// Check cue.line
is(cue.line, "auto", "Cue's line value should initially be auto.");
cue.line = 12410
is(cue.line, 12410, "Cue's line value should now be 12410.");
cue.line = "auto";
is(cue.line, "auto", "Cue's line value should now be auto.");
// Check that we can create and add new VTTCues
var vttCue = new VTTCue(3.999, 4, "foo");
trackElement.track.addCue(vttCue);

View File

@ -840,7 +840,9 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
if typeNeedsRooting(f):
headers.add("mozilla/dom/RootedDictionary.h")
elif f.isEnum():
headers.add(CGHeaders.getDeclarationFilename(f))
# Need to see the actual definition of the enum,
# unfortunately.
headers.add(CGHeaders.getDeclarationFilename(f.inner))
map(addInfoForType, getAllTypes(descriptors, dictionaries, callbacks))

View File

@ -35,8 +35,7 @@ interface VTTCue : EventTarget {
attribute DOMString regionId;
attribute DirectionSetting vertical;
attribute boolean snapToLines;
// XXXhumph: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20651
// attribute (long or AutoKeyword) line;
attribute (long or AutoKeyword) line;
[SetterThrows]
attribute AlignSetting lineAlign;
[SetterThrows]