mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 05:14:24 +00:00
Bug 1338030 - region : integrate the RegionNodeBox and RegionCueStyleBox. r=rillian
MozReview-Commit-ID: 8M9x31q2dSK --HG-- extra : rebase_source : 93d49147d626cf2b5add5d81b5476b5efb696262
This commit is contained in:
parent
25491eae61
commit
4a945299ed
@ -1049,29 +1049,66 @@ const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
};
|
||||
|
||||
(function() {
|
||||
var styleBox, cue;
|
||||
var styleBox, cue, controlBarBox;
|
||||
|
||||
if (controlBarShown) {
|
||||
controlBarBox = BoxPosition.getSimpleBoxPosition(controlBar);
|
||||
// Add an empty output box that cover the same region as video control bar.
|
||||
boxPositions.push(BoxPosition.getSimpleBoxPosition(controlBar));
|
||||
boxPositions.push(controlBarBox);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webvtt/#processing-model 6.1.12.1
|
||||
// Create regionNode
|
||||
var regionNodeBoxes = {};
|
||||
var regionNodeBox;
|
||||
|
||||
for (var i = 0; i < cues.length; i++) {
|
||||
cue = cues[i];
|
||||
if (cue.region != null) {
|
||||
// 6.1.14.1
|
||||
styleBox = new RegionCueStyleBox(window, cue);
|
||||
|
||||
// Compute the intial position and styles of the cue div.
|
||||
styleBox = new CueStyleBox(window, cue, styleOptions);
|
||||
styleBox.cueDiv.style.setProperty("--cue-font-size", fontSize + "px");
|
||||
rootOfCues.appendChild(styleBox.div);
|
||||
if (!regionNodeBoxes[cue.region.id]) {
|
||||
// create regionNode
|
||||
// Adjust the container hieght to exclude the controlBar
|
||||
var adjustContainerBox = BoxPosition.getSimpleBoxPosition(rootOfCues);
|
||||
if (controlBarShown) {
|
||||
adjustContainerBox.height -= controlBarBox.height;
|
||||
adjustContainerBox.bottom += controlBarBox.height;
|
||||
}
|
||||
regionNodeBox = new RegionNodeBox(window, cue.region, adjustContainerBox);
|
||||
regionNodeBoxes[cue.region.id] = regionNodeBox;
|
||||
}
|
||||
// 6.1.14.3
|
||||
var currentRegionBox = regionNodeBoxes[cue.region.id];
|
||||
var currentRegionNodeDiv = currentRegionBox.div;
|
||||
// 6.1.14.3.2
|
||||
// TODO: fix me, it looks like the we need to set/change "top" attribute at the styleBox.div
|
||||
// to do the "scroll up", however, we do not implement it yet?
|
||||
if (cue.region.scroll == "up" && currentRegionNodeDiv.childElementCount > 0) {
|
||||
styleBox.div.style.transitionProperty = "top";
|
||||
styleBox.div.style.transitionDuration = "0.433s";
|
||||
}
|
||||
|
||||
// Move the cue div to it's correct line position.
|
||||
moveBoxToLinePosition(window, styleBox, containerBox, boxPositions);
|
||||
currentRegionNodeDiv.appendChild(styleBox.div);
|
||||
rootOfCues.appendChild(currentRegionNodeDiv);
|
||||
cue.displayState = styleBox.div;
|
||||
boxPositions.push(BoxPosition.getSimpleBoxPosition(currentRegionBox));
|
||||
} else {
|
||||
// Compute the intial position and styles of the cue div.
|
||||
styleBox = new CueStyleBox(window, cue, styleOptions);
|
||||
styleBox.cueDiv.style.setProperty("--cue-font-size", fontSize + "px");
|
||||
rootOfCues.appendChild(styleBox.div);
|
||||
|
||||
// Remember the computed div so that we don't have to recompute it later
|
||||
// if we don't have too.
|
||||
cue.displayState = styleBox.div;
|
||||
// Move the cue div to it's correct line position.
|
||||
moveBoxToLinePosition(window, styleBox, containerBox, boxPositions);
|
||||
|
||||
boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox));
|
||||
// Remember the computed div so that we don't have to recompute it later
|
||||
// if we don't have too.
|
||||
cue.displayState = styleBox.div;
|
||||
|
||||
boxPositions.push(BoxPosition.getSimpleBoxPosition(styleBox));
|
||||
}
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user