Example #1
0
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;
}
Example #2
0
PassRefPtr<TextTrackCueBox> TextTrackCue::getDisplayTree()
{
    if (!m_displayTreeShouldChange)
        return m_displayTree;

    // 10.1 - 10.10
    calculateDisplayParameters();

    // 10.11. Apply the terms of the CSS specifications to nodes within the
    // following constraints, thus obtaining a set of CSS boxes positioned
    // relative to an initial containing block:
    m_displayTree->removeChildren();

    // The document tree is the tree of WebVTT Node Objects rooted at nodes.

    // The children of the nodes must be wrapped in an anonymous box whose
    // 'display' property has the value 'inline'. This is the WebVTT cue
    // background box.

    // Note: This is contained by default in m_pastDocumentNodes.
    m_displayTree->appendChild(m_pastDocumentNodes, ASSERT_NO_EXCEPTION, true);
    m_displayTree->appendChild(m_futureDocumentNodes, ASSERT_NO_EXCEPTION, true);

    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
    // 'display' property has the value 'ruby-base'.

    // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
    // line-wrapping rules, except that additionally, regardless of the value of
    // the 'white-space' property, lines must be wrapped at the edge of their
    // containing blocks, even if doing so requires splitting a word where there
    // is no line breaking opportunity. (Thus, normally text wraps as needed,
    // but if there is a particularly long word, it does not overflow as it
    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
    m_displayTree->applyCSSProperties();

    if (m_hasInnerTimestamps)
        updateDisplayTree(track()->mediaElement()->currentTime());

    m_displayTreeShouldChange = false;

    // 10.15. Let cue's text track cue display state have the CSS boxes in
    // boxes.
    return m_displayTree;
}
Example #3
0
PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree(const IntSize& videoSize)
{
    RefPtrWillBeRawPtr<VTTCueBox> displayTree(ensureDisplayTree());
    if (!m_displayTreeShouldChange || !track()->isRendered())
        return displayTree.release();

    // 10.1 - 10.10
    calculateDisplayParameters();

    // 10.11. Apply the terms of the CSS specifications to nodes within the
    // following constraints, thus obtaining a set of CSS boxes positioned
    // relative to an initial containing block:
    displayTree->removeChildren();

    // The document tree is the tree of WebVTT Node Objects rooted at nodes.

    // The children of the nodes must be wrapped in an anonymous box whose
    // 'display' property has the value 'inline'. This is the WebVTT cue
    // background box.

    // Note: This is contained by default in m_cueBackgroundBox.
    m_cueBackgroundBox->setShadowPseudoId(cueShadowPseudoId());
    displayTree->appendChild(m_cueBackgroundBox);

    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
    // 'display' property has the value 'ruby-base'.

    // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
    // line-wrapping rules, except that additionally, regardless of the value of
    // the 'white-space' property, lines must be wrapped at the edge of their
    // containing blocks, even if doing so requires splitting a word where there
    // is no line breaking opportunity. (Thus, normally text wraps as needed,
    // but if there is a particularly long word, it does not overflow as it
    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
    displayTree->applyCSSProperties(videoSize);

    m_displayTreeShouldChange = false;

    // 10.15. Let cue's text track cue display state have the CSS boxes in
    // boxes.
    return displayTree.release();
}
Example #4
0
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;
}
Example #5
0
VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
{
    RefPtr<VTTCueBox> displayTree = displayTreeInternal();
    if (!m_displayTreeShouldChange || !track()->isRendered())
        return displayTree.get();

    // 10.1 - 10.10
    calculateDisplayParameters();

    // 10.11. Apply the terms of the CSS specifications to nodes within the
    // following constraints, thus obtaining a set of CSS boxes positioned
    // relative to an initial containing block:
    displayTree->removeChildren();

    // The document tree is the tree of WebVTT Node Objects rooted at nodes.

    // The children of the nodes must be wrapped in an anonymous box whose
    // 'display' property has the value 'inline'. This is the WebVTT cue
    // background box.

    // Note: This is contained by default in m_cueHighlightBox.
    m_cueHighlightBox->setPseudo(cueShadowPseudoId());

    m_cueBackdropBox->setPseudo(cueBackdropShadowPseudoId());
    m_cueBackdropBox->appendChild(m_cueHighlightBox, ASSERT_NO_EXCEPTION);
    displayTree->appendChild(m_cueBackdropBox, ASSERT_NO_EXCEPTION);

    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
    // 'display' property has the value 'ruby-base'.

    displayTree->setFontSizeFromCaptionUserPrefs(fontSize);
    displayTree->applyCSSProperties(videoSize);

    m_displayTreeShouldChange = false;

    // 10.15. Let cue's text track cue display state have the CSS boxes in
    // boxes.
    return displayTree.get();
}
Example #6
0
PassRefPtr<HTMLDivElement> TextTrackCue::getDisplayTree()
{
    DEFINE_STATIC_LOCAL(const AtomicString, trackBackgroundShadowPseudoId, ("-webkit-media-text-track-background"));
    DEFINE_STATIC_LOCAL(const AtomicString, trackDisplayBoxShadowPseudoId, ("-webkit-media-text-track-display"));

    if (!m_displayTreeShouldChange)
        return m_displayTree;

    // 10.1 - 10.10
    calculateDisplayParameters();

    // 10.11. Apply the terms of the CSS specifications to nodes within the
    // following constraints, thus obtaining a set of CSS boxes positioned
    // relative to an initial containing block:
    m_displayTree->removeChildren();

    // The document tree is the tree of WebVTT Node Objects rooted at nodes.

    // The children of the nodes must be wrapped in an anonymous box whose
    // 'display' property has the value 'inline'. This is the WebVTT cue
    // background box.
    RefPtr<HTMLDivElement> cueBackgroundBox = HTMLDivElement::create(static_cast<Document*>(m_scriptExecutionContext));

    cueBackgroundBox->setShadowPseudoId(trackBackgroundShadowPseudoId);
    cueBackgroundBox->appendChild(getCueAsHTML(), ASSERT_NO_EXCEPTION, true);

    m_displayTree->setShadowPseudoId(trackDisplayBoxShadowPseudoId, ASSERT_NO_EXCEPTION);
    m_displayTree->appendChild(cueBackgroundBox, ASSERT_NO_EXCEPTION, true);

    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
    // WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
    // 'display' property has the value 'ruby-base'.

    // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
    // line-wrapping rules, except that additionally, regardless of the value of
    // the 'white-space' property, lines must be wrapped at the edge of their
    // containing blocks, even if doing so requires splitting a word where there
    // is no line breaking opportunity. (Thus, normally text wraps as needed,
    // but if there is a particularly long word, it does not overflow as it
    // normally would in CSS, it is instead forcibly wrapped at the box's edge.)

    // FIXME(BUG 79916): CSS width property should be set to 'size vw', when the
    // maximum cue size computation is corrected in the specification.
    if (m_snapToLines)
        m_displayTree->setInlineStyleProperty(CSSPropertyWidth, (double) m_cueSize, CSSPrimitiveValue::CSS_PERCENTAGE);

    // FIXME(BUG 79750, 79751): Steps 10.12 - 10.14

    if (!m_snapToLines) {
        std::pair<double, double> position = getPositionCoordinates();

        // 10.13.1 Set up x and y:
        m_displayTree->setInlineStyleProperty(CSSPropertyLeft, position.first, CSSPrimitiveValue::CSS_PERCENTAGE);
        m_displayTree->setInlineStyleProperty(CSSPropertyTop, position.second, CSSPrimitiveValue::CSS_PERCENTAGE);

        // 10.13.2 Position the boxes in boxes such that the point x% along the
        // width of the bounding box of the boxes in boxes is x% of the way
        // across the width of the video's rendering area, and the point y%
        // along the height of the bounding box of the boxes in boxes is y%
        // of the way across the height of the video's rendering area, while
        // maintaining the relative positions of the boxes in boxes to each
        // other.
        String translateX = "-" + String::number(position.first) + "%";
        String translateY = "-" + String::number(position.second) + "%";
        String webkitTransformTranslateValue = "translate(" + translateX + "," + translateY + ")";

        m_displayTree->setInlineStyleProperty(CSSPropertyWebkitTransform,
                                              webkitTransformTranslateValue);

        m_displayTree->setInlineStyleProperty(CSSPropertyWhiteSpace,
                                              CSSValuePre);
    }

    m_displayTreeShouldChange = false;

    // 10.15. Let cue's text track cue display state have the CSS boxes in
    // boxes.
    return m_displayTree;
}