void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) { RefPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); VTTRegion* region = 0; if (track()->regions()) region = track()->regions()->getRegionById(regionId()); if (!region) { // If cue has an empty text track cue region identifier or there is no // WebVTT region whose region identifier is identical to cue's text // track cue region identifier, run the following substeps: if (displayBox->hasChildNodes() && !container.contains(displayBox.get())) { // Note: the display tree of a cue is removed when the active flag of the cue is unset. container.appendChild(displayBox); } } else { // Let region be the WebVTT region whose region identifier // matches the text track cue region identifier of cue. RefPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); // Append the region to the viewport, if it was not already. if (!container.contains(regionNode.get())) container.appendChild(regionNode); region->appendVTTCueBox(displayBox); } }
void VTTCue::updateDisplay(HTMLDivElement& container) { ASSERT(track() && track()->isRendered() && isActive()); UseCounter::count(document(), UseCounter::VTTCueRender); if (m_writingDirection != Horizontal) UseCounter::count(document(), UseCounter::VTTCueRenderVertical); if (!m_snapToLines) UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); if (!lineIsAuto()) UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto); if (textPositionIsAuto()) UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50); if (m_cueSize != 100) UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100); if (m_cueAlignment != Middle) UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); VTTCueBox* displayBox = getDisplayTree(); VTTRegion* region = 0; if (track()->regions()) region = track()->regions()->getRegionById(regionId()); if (!region) { // If cue has an empty region identifier or there is no WebVTT region // whose region identifier is identical to cue's region identifier, run // the following substeps: if (displayBox->hasChildren() && !container.contains(displayBox)) { // Note: the display tree of a cue is removed when the active flag of the cue is unset. container.appendChild(displayBox); } } else { // Let region be the WebVTT region whose region identifier matches the // region identifier of cue. HTMLDivElement* regionNode = region->getDisplayTree(document()); // Append the region to the viewport, if it was not already. if (!container.contains(regionNode)) container.appendChild(regionNode); region->appendVTTCueBox(displayBox); } }
void VTTCue::updateDisplay(const IntSize& videoSize, HTMLDivElement& container) { UseCounter::count(document(), UseCounter::VTTCueRender); if (m_writingDirection != Horizontal) UseCounter::count(document(), UseCounter::VTTCueRenderVertical); if (!m_snapToLines) UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); if (m_linePosition != undefinedPosition) UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto); if (m_textPosition != 50) UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50); if (m_cueSize != 100) UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100); if (m_cueAlignment != Middle) UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); VTTRegion* region = 0; if (track()->regions()) region = track()->regions()->getRegionById(regionId()); if (!region) { // If cue has an empty text track cue region identifier or there is no // WebVTT region whose region identifier is identical to cue's text // track cue region identifier, run the following substeps: if (displayBox->hasChildren() && !container.contains(displayBox.get())) { // Note: the display tree of a cue is removed when the active flag of the cue is unset. container.appendChild(displayBox); } } else { // Let region be the WebVTT region whose region identifier // matches the text track cue region identifier of cue. RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(document()); // Append the region to the viewport, if it was not already. if (!container.contains(regionNode.get())) container.appendChild(regionNode); region->appendVTTCueBox(displayBox); } }
VTTCueBox* VTTCue::getDisplayTree() { ASSERT(track() && track()->isRendered() && isActive()); if (!m_displayTree) { m_displayTree = VTTCueBox::create(document()); m_displayTree->appendChild(m_cueBackgroundBox); } ASSERT(m_displayTree->firstChild() == m_cueBackgroundBox); if (!m_displayTreeShouldChange) { // Apply updated user style overrides for text tracks when display tree doesn't change. // This ensures that the track settings are refreshed when the video is // replayed or when the user slides back to an already rendered track. applyUserOverrideCSSProperties(); return m_displayTree; } createVTTNodeTree(); m_cueBackgroundBox->removeChildren(); m_vttNodeTree->cloneChildNodes(m_cueBackgroundBox.get()); // TODO(philipj): The region identifier may be non-empty without there being // a corresponding region, in which case this VTTCueBox will be added // directly to the text track container in updateDisplay(). if (regionId().isEmpty()) { VTTDisplayParameters displayParameters = calculateDisplayParameters(); m_displayTree->applyCSSProperties(displayParameters); } else { m_displayTree->setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); } // Apply user override settings for text tracks applyUserOverrideCSSProperties(); m_displayTreeShouldChange = false; return m_displayTree; }