Bug 1541452 - update cue display when window is resized. r=heycam

When window is resized, the cue would usually be zoomed in or out automatically with the video and keep its relative position to video.

However, if video is being applied the explicit percentage value on its 'width' or 'height', we have to recompute cue's position in this situation, because the width or height of the video would be scaled again after applied the first size scaled which is caused by resizing.

Differential Revision: https://phabricator.services.mozilla.com/D36138
This commit is contained in:
alwu
2019-07-06 00:53:20 +00:00
parent eaa1b53894
commit 788999bc24
2 changed files with 25 additions and 14 deletions

View File

@@ -311,6 +311,8 @@ void TextTrackManager::PopulatePendingList() {
void TextTrackManager::AddListeners() {
if (mMediaElement) {
mMediaElement->AddEventListener(NS_LITERAL_STRING("resizecaption"), this,
false, false);
mMediaElement->AddEventListener(NS_LITERAL_STRING("resizevideocontrols"),
this, false, false);
mMediaElement->AddEventListener(NS_LITERAL_STRING("seeked"), this, false,
@@ -416,14 +418,20 @@ TextTrackManager::HandleEvent(Event* aEvent) {
nsAutoString type;
aEvent->GetType(type);
if (type.EqualsLiteral("resizevideocontrols") ||
type.EqualsLiteral("seeked")) {
WEBVTT_LOG("Handle event %s", NS_ConvertUTF16toUTF8(type).get());
const bool setDirty = type.EqualsLiteral("seeked") ||
type.EqualsLiteral("resizecaption") ||
type.EqualsLiteral("resizevideocontrols");
const bool updateDisplay = type.EqualsLiteral("controlbarchange") ||
type.EqualsLiteral("resizecaption");
if (setDirty) {
for (uint32_t i = 0; i < mTextTracks->Length(); i++) {
((*mTextTracks)[i])->SetCuesDirty();
}
}
if (type.EqualsLiteral("controlbarchange")) {
if (updateDisplay) {
UpdateCueDisplay();
}