Ejemplo n.º 1
0
void VTTRegion::displayLastVTTCueBox()
{
    WTF_LOG(Media, "VTTRegion::displayLastVTTCueBox");
    ASSERT(m_cueContainer);

    // FIXME: This should not be causing recalc styles in a loop to set the "top" css
    // property to move elements. We should just scroll the text track cues on the
    // compositor with an animation.

    if (m_scrollTimer.isActive())
        return;

    // If it's a scrolling region, add the scrolling class.
    if (isScrollingRegion())
        m_cueContainer->classList()->add(textTrackCueContainerScrollingClass(), ASSERT_NO_EXCEPTION);

    float regionBottom = m_regionDisplayTree->getBoundingClientRect()->bottom();

    // Find first cue that is not entirely displayed and scroll it upwards.
    for (size_t i = 0; i < m_cueContainer->childNodeCount() && !m_scrollTimer.isActive(); ++i) {
        float childTop = toHTMLDivElement(m_cueContainer->childNode(i))->getBoundingClientRect()->top();
        float childBottom = toHTMLDivElement(m_cueContainer->childNode(i))->getBoundingClientRect()->bottom();

        if (regionBottom >= childBottom)
            continue;

        float height = childBottom - childTop;

        m_currentTop -= std::min(height, childBottom - regionBottom);
        m_cueContainer->setInlineStyleProperty(CSSPropertyTop, m_currentTop, CSSPrimitiveValue::CSS_PX);

        startTimer();
    }
}
Ejemplo n.º 2
0
bool isPlainTextMarkup(Node* node) {
  DCHECK(node);
  if (!isHTMLDivElement(*node))
    return false;

  HTMLDivElement& element = toHTMLDivElement(*node);
  if (!element.hasAttributes())
    return false;

  if (element.hasOneChild())
    return element.firstChild()->isTextNode() ||
           element.firstChild()->hasChildren();

  return element.hasChildCount(2) &&
         isTabHTMLSpanElementTextNode(element.firstChild()->firstChild()) &&
         element.lastChild()->isTextNode();
}