зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1276832 - part1 : modify VTTCue's line to double. r=rillian,smaug
MozReview-Commit-ID: 7P79SO5TI0K --HG-- extra : rebase_source : 2f05ccdfccaabf02474f087cf6561c132d412a2b
This commit is contained in:
Родитель
70613457d1
Коммит
c388caa29d
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "mozilla/dom/HTMLTrackElement.h"
|
||||
#include "mozilla/dom/TextTrackCue.h"
|
||||
#include "mozilla/dom/TextTrackList.h"
|
||||
#include "mozilla/dom/TextTrackRegion.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
@ -169,6 +170,40 @@ TextTrackCue::SetRegion(TextTrackRegion* aRegion)
|
|||
mReset = true;
|
||||
}
|
||||
|
||||
double
|
||||
TextTrackCue::ComputedLine()
|
||||
{
|
||||
// See spec https://w3c.github.io/webvtt/#cue-computed-line
|
||||
if (!mLineIsAutoKeyword && !mSnapToLines &&
|
||||
(mLine < 0.0 || mLine > 100.0)) {
|
||||
return 100.0;
|
||||
} else if (!mLineIsAutoKeyword) {
|
||||
return mLine;
|
||||
} else if (mLineIsAutoKeyword && !mSnapToLines) {
|
||||
return 100.0;
|
||||
} else if (!mTrack ||
|
||||
!mTrack->GetTextTrackList() ||
|
||||
!mTrack->GetTextTrackList()->GetMediaElement()) {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
RefPtr<TextTrackList> trackList = mTrack->GetTextTrackList();
|
||||
bool dummy;
|
||||
uint32_t showingTracksNum = 0;
|
||||
for (uint32_t idx = 0; idx < trackList->Length(); idx++) {
|
||||
RefPtr<TextTrack> track = trackList->IndexedGetter(idx, dummy);
|
||||
if (track->Mode() == TextTrackMode::Showing) {
|
||||
showingTracksNum++;
|
||||
}
|
||||
|
||||
if (mTrack == track) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (-1.0) * showingTracksNum;
|
||||
}
|
||||
|
||||
PositionAlignSetting
|
||||
TextTrackCue::ComputedPositionAlign()
|
||||
{
|
||||
|
|
|
@ -151,21 +151,21 @@ public:
|
|||
mSnapToLines = aSnapToLines;
|
||||
}
|
||||
|
||||
void GetLine(OwningLongOrAutoKeyword& aLine) const
|
||||
void GetLine(OwningDoubleOrAutoKeyword& aLine) const
|
||||
{
|
||||
if (mLineIsAutoKeyword) {
|
||||
aLine.SetAsAutoKeyword() = AutoKeyword::Auto;
|
||||
return;
|
||||
}
|
||||
aLine.SetAsLong() = mLineLong;
|
||||
aLine.SetAsDouble() = mLine;
|
||||
}
|
||||
|
||||
void SetLine(const LongOrAutoKeyword& aLine)
|
||||
void SetLine(const DoubleOrAutoKeyword& aLine)
|
||||
{
|
||||
if (aLine.IsLong() &&
|
||||
(mLineIsAutoKeyword || (aLine.GetAsLong() != mLineLong))) {
|
||||
if (aLine.IsDouble() &&
|
||||
(mLineIsAutoKeyword || (aLine.GetAsDouble() != mLine))) {
|
||||
mLineIsAutoKeyword = false;
|
||||
mLineLong = aLine.GetAsLong();
|
||||
mLine = aLine.GetAsDouble();
|
||||
mReset = true;
|
||||
return;
|
||||
}
|
||||
|
@ -299,6 +299,7 @@ public:
|
|||
return mReset;
|
||||
}
|
||||
|
||||
double ComputedLine();
|
||||
PositionAlignSetting ComputedPositionAlign();
|
||||
|
||||
// Helper functions for implementation.
|
||||
|
@ -367,7 +368,7 @@ private:
|
|||
RefPtr<TextTrackRegion> mRegion;
|
||||
DirectionSetting mVertical;
|
||||
bool mLineIsAutoKeyword;
|
||||
long mLineLong;
|
||||
double mLine;
|
||||
AlignSetting mAlign;
|
||||
LineAlignSetting mLineAlign;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ interface VTTCue : TextTrackCue {
|
|||
attribute VTTRegion? region;
|
||||
attribute DirectionSetting vertical;
|
||||
attribute boolean snapToLines;
|
||||
attribute (long or AutoKeyword) line;
|
||||
attribute (double or AutoKeyword) line;
|
||||
[SetterThrows]
|
||||
attribute LineAlignSetting lineAlign;
|
||||
[SetterThrows]
|
||||
|
@ -64,5 +64,7 @@ partial interface VTTCue {
|
|||
[ChromeOnly]
|
||||
readonly attribute boolean hasBeenReset;
|
||||
[ChromeOnly]
|
||||
readonly attribute double computedLine;
|
||||
[ChromeOnly]
|
||||
readonly attribute PositionAlignSetting computedPositionAlign;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче