PassRefPtrWillBeRawPtr<DocumentFragment> VTTCue::createCueRenderingTree() { createVTTNodeTree(); RefPtrWillBeRawPtr<DocumentFragment> clonedFragment = DocumentFragment::create(document()); m_vttNodeTree->cloneChildNodes(clonedFragment.get()); return clonedFragment.release(); }
PassRefPtrWillBeRawPtr<DocumentFragment> VTTCue::getCueAsHTML() { createVTTNodeTree(); RefPtrWillBeRawPtr<DocumentFragment> clonedFragment = DocumentFragment::create(document()); copyVTTNodeToDOMTree(m_vttNodeTree.get(), clonedFragment.get()); return clonedFragment.release(); }
DocumentFragment* VTTCue::getCueAsHTML() { createVTTNodeTree(); DocumentFragment* clonedFragment = DocumentFragment::create(document()); copyVTTNodeToDOMTree(m_vttNodeTree.get(), clonedFragment); return clonedFragment; }
PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree() { ASSERT(track() && track()->isRendered() && isActive()); if (!m_displayTree) { m_displayTree = VTTCueBox::create(document(), this); 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()); VTTDisplayParameters displayParameters = calculateDisplayParameters(); m_displayTree->applyCSSProperties(displayParameters); // Apply user override settings for text tracks applyUserOverrideCSSProperties(); m_displayTreeShouldChange = false; return m_displayTree; }
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; }
void VTTCue::calculateDisplayParameters() { createVTTNodeTree(); // Steps 10.2, 10.3 m_displayDirection = determineTextDirection(m_vttNodeTree.get()); if (m_displayDirection == CSSValueRtl) UseCounter::count(document(), UseCounter::VTTCueRenderRtl); // 10.4 If the text track cue writing direction is horizontal, then let // block-flow be 'tb'. Otherwise, if the text track cue writing direction is // vertical growing left, then let block-flow be 'lr'. Otherwise, the text // track cue writing direction is vertical growing right; let block-flow be // 'rl'. // The above step is done through the writing direction static map. // 10.5 Determine the value of maximum size for cue as per the appropriate // rules from the following list: int maximumSize = m_textPosition; if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueLtr) || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueRtl) || (m_writingDirection == Horizontal && m_cueAlignment == Left) || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == Start || m_cueAlignment == Left)) || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == Start || m_cueAlignment == Left))) { maximumSize = 100 - m_textPosition; } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_displayDirection == CSSValueLtr) || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_displayDirection == CSSValueRtl) || (m_writingDirection == Horizontal && m_cueAlignment == Right) || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == End || m_cueAlignment == Right)) || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == End || m_cueAlignment == Right))) { maximumSize = m_textPosition; } else if (m_cueAlignment == Middle) { maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosition); maximumSize = maximumSize * 2; } else { ASSERT_NOT_REACHED(); } // 10.6 If the text track cue size is less than maximum size, then let size // be text track cue size. Otherwise, let size be maximum size. m_displaySize = std::min(m_cueSize, maximumSize); // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) // Could be done within a spec implementation check - http://crbug.com/301580 // 10.8 Determine the value of x-position or y-position for cue as per the // appropriate rules from the following list: if (m_writingDirection == Horizontal) { switch (m_cueAlignment) { case Start: if (m_displayDirection == CSSValueLtr) m_displayPosition.first = m_textPosition; else m_displayPosition.first = 100 - m_textPosition - m_displaySize; break; case End: if (m_displayDirection == CSSValueRtl) m_displayPosition.first = 100 - m_textPosition; else m_displayPosition.first = m_textPosition - m_displaySize; break; case Left: if (m_displayDirection == CSSValueLtr) m_displayPosition.first = m_textPosition; else m_displayPosition.first = 100 - m_textPosition; break; case Right: if (m_displayDirection == CSSValueLtr) m_displayPosition.first = m_textPosition - m_displaySize; else m_displayPosition.first = 100 - m_textPosition - m_displaySize; break; case Middle: if (m_displayDirection == CSSValueLtr) m_displayPosition.first = m_textPosition - m_displaySize / 2; else m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2; break; default: ASSERT_NOT_REACHED(); } } else { // Cases for m_writingDirection being VerticalGrowing{Left|Right} switch (m_cueAlignment) { case Start: case Left: m_displayPosition.second = m_textPosition; break; case End: case Right: m_displayPosition.second = m_textPosition - m_displaySize; break; case Middle: m_displayPosition.second = m_textPosition - m_displaySize / 2; break; default: ASSERT_NOT_REACHED(); } } // A text track cue has a text track cue computed line position whose value // is defined in terms of the other aspects of the cue. m_computedLinePosition = calculateComputedLinePosition(); // 10.9 Determine the value of whichever of x-position or y-position is not // yet calculated for cue as per the appropriate rules from the following // list: if (m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal) m_displayPosition.second = 0; if (!m_snapToLines && m_displayPosition.second == undefinedPosition && m_writingDirection == Horizontal) m_displayPosition.second = m_computedLinePosition; if (m_snapToLines && m_displayPosition.first == undefinedPosition && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight)) m_displayPosition.first = 0; if (!m_snapToLines && (m_writingDirection == VerticalGrowingLeft || m_writingDirection == VerticalGrowingRight)) m_displayPosition.first = m_computedLinePosition; }