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

This commit is contained in:
Rick Eyre 2014-01-15 08:04:00 -08:00
Родитель 1997436909
Коммит 194c47dcd0
5 изменённых файлов: 35 добавлений и 14 удалений

Просмотреть файл

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

Просмотреть файл

@ -15,6 +15,7 @@
#include "mozilla/StaticPtr.h" #include "mozilla/StaticPtr.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "mozilla/dom/HTMLDivElement.h" #include "mozilla/dom/HTMLDivElement.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -168,16 +169,30 @@ public:
CueChanged(); 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 if (aLine.IsLong() &&
mReset = true; (mLineIsAutoKeyword || (aLine.GetAsLong() != mLineLong))) {
mLine = aLine; mLineIsAutoKeyword = false;
mLineLong = aLine.GetAsLong();
CueChanged();
mReset = true;
return;
}
if (aLine.IsAutoKeyword() && !mLineIsAutoKeyword) {
mLineIsAutoKeyword = true;
CueChanged();
mReset = true;
}
} }
AlignSetting LineAlign() const AlignSetting LineAlign() const
@ -355,7 +370,8 @@ private:
bool mSnapToLines; bool mSnapToLines;
nsString mRegionId; nsString mRegionId;
DirectionSetting mVertical; DirectionSetting mVertical;
int mLine; bool mLineIsAutoKeyword;
long mLineLong;
AlignSetting mAlign; AlignSetting mAlign;
AlignSetting mLineAlign; AlignSetting mLineAlign;

Просмотреть файл

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

Просмотреть файл

@ -840,7 +840,9 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
if typeNeedsRooting(f): if typeNeedsRooting(f):
headers.add("mozilla/dom/RootedDictionary.h") headers.add("mozilla/dom/RootedDictionary.h")
elif f.isEnum(): 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)) map(addInfoForType, getAllTypes(descriptors, dictionaries, callbacks))

Просмотреть файл

@ -35,8 +35,7 @@ interface VTTCue : EventTarget {
attribute DOMString regionId; attribute DOMString regionId;
attribute DirectionSetting vertical; attribute DirectionSetting vertical;
attribute boolean snapToLines; 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] [SetterThrows]
attribute AlignSetting lineAlign; attribute AlignSetting lineAlign;
[SetterThrows] [SetterThrows]