Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: Source/core/html/track/vtt/VTTCue.cpp

Issue 1022523002: Clean up around text track display state updates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/vtt/VTTCue.cpp
diff --git a/Source/core/html/track/vtt/VTTCue.cpp b/Source/core/html/track/vtt/VTTCue.cpp
index 462c88d5c6d7bc472900d3049fb06252a5ec9cf3..92f0990b2c1c00dacbd9b35948d0565e71cda1e8 100644
--- a/Source/core/html/track/vtt/VTTCue.cpp
+++ b/Source/core/html/track/vtt/VTTCue.cpp
@@ -231,6 +231,7 @@ VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin
, m_displayTreeShouldChange(true)
{
UseCounter::count(document, UseCounter::VTTCue);
+ m_cueBackgroundBox->setShadowPseudoId(cueShadowPseudoId());
}
VTTCue::~VTTCue()
@@ -253,13 +254,6 @@ String VTTCue::toString() const
}
#endif
-VTTCueBox& VTTCue::ensureDisplayTree()
-{
- if (!m_displayTree)
- m_displayTree = VTTCueBox::create(document(), this);
- return *m_displayTree;
-}
-
void VTTCue::cueDidChange()
{
TextTrackCue::cueDidChange();
@@ -799,48 +793,28 @@ void VTTCue::updateDisplayTree(double movieTime)
PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree()
{
- RefPtrWillBeRawPtr<VTTCueBox> displayTree(ensureDisplayTree());
- if (!m_displayTreeShouldChange || !track()->isRendered())
- return displayTree.release();
-
- createVTTNodeTree();
-
- // 10.1 - 10.10
- VTTDisplayParameters displayParameters = 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();
+ ASSERT(track() && track()->isRendered() && isActive());
- // The document tree is the tree of WebVTT Node Objects rooted at nodes.
+ if (!m_displayTree) {
+ m_displayTree = VTTCueBox::create(document(), this);
+ m_displayTree->appendChild(m_cueBackgroundBox);
+ }
- // 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.
+ ASSERT(m_displayTree->firstChild() == m_cueBackgroundBox);
- // Note: This is contained by default in m_cueBackgroundBox.
- m_cueBackgroundBox->setShadowPseudoId(cueShadowPseudoId());
- displayTree->appendChild(m_cueBackgroundBox);
+ // Note: It is updateDisplayTree() which actually adds the child
+ // nodes to 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'.
+ if (!m_displayTreeShouldChange)
+ return m_displayTree;
- // 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(displayParameters);
+ createVTTNodeTree();
+ VTTDisplayParameters displayParameters = calculateDisplayParameters();
+ m_displayTree->applyCSSProperties(displayParameters);
m_displayTreeShouldChange = false;
- // 10.15. Let cue's text track cue display state have the CSS boxes in
- // boxes.
- return displayTree.release();
+ return m_displayTree;
}
void VTTCue::removeDisplayTree(RemovalNotification removalNotification)
@@ -858,6 +832,8 @@ void VTTCue::removeDisplayTree(RemovalNotification removalNotification)
void VTTCue::updateDisplay(HTMLDivElement& container)
{
+ ASSERT(track() && track()->isRendered() && isActive());
+
UseCounter::count(document(), UseCounter::VTTCueRender);
if (m_writingDirection != Horizontal)
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698