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

Unified Diff: Source/core/layout/LayoutMedia.cpp

Issue 949203002: Separate the text track container from the media controls (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address nits 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/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutMedia.cpp
diff --git a/Source/core/layout/LayoutMedia.cpp b/Source/core/layout/LayoutMedia.cpp
index 67702a12b9747973a211a4802eb9f49ab2b8ecab..905cee26c646822ed0b51f24b53b81e70532a937 100644
--- a/Source/core/layout/LayoutMedia.cpp
+++ b/Source/core/layout/LayoutMedia.cpp
@@ -53,32 +53,47 @@ void LayoutMedia::layout()
LayoutImage::layout();
- LayoutBox* controlsRenderer = toLayoutBox(m_children.firstChild());
- if (!controlsRenderer)
- return;
-
- bool controlsNeedLayout = controlsRenderer->needsLayout();
LayoutSize newSize = contentBoxRect().size();
- if (newSize == oldSize && !controlsNeedLayout)
- return;
LayoutState state(*this, locationOffset());
- controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
- controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed));
- controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed));
- controlsRenderer->forceLayout();
+ for (LayoutObject* child = m_children.firstChild(); child; child = child->nextSibling()) {
+ ASSERT(child->node()->isMediaControls() || child->node()->isTextTrackContainer());
+
+ if (newSize == oldSize && !child->needsLayout())
+ continue;
+
+ LayoutBox* layoutBox = toLayoutBox(child);
+ layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
+ // TODO(philipj): Remove the mutableStyleRef() and depend on CSS
+ // width/height: inherit to match the media element size.
+ layoutBox->mutableStyleRef().setHeight(Length(newSize.height(), Fixed));
+ layoutBox->mutableStyleRef().setWidth(Length(newSize.width(), Fixed));
+ layoutBox->forceLayout();
+ }
+
clearNeedsLayout();
}
bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const
{
- // The only allowed child is the media controls. The user agent stylesheet
- // (mediaControls.css) has ::-webkit-media-controls { display: flex; }. If
- // author style sets display: inline we would get an inline renderer as a
- // child of replaced content, which is not supposed to be possible. This
- // check can be removed if ::-webkit-media-controls is made internal.
- return child->isFlexibleBox();
+ // Two types of child layout objects are allowed: media controls
+ // and the text track container. Filter children by node type.
+ ASSERT(child->node());
+
+ // The user agent stylesheet (mediaControls.css) has
+ // ::-webkit-media-controls { display: flex; }. If author style
+ // sets display: inline we would get an inline renderer as a child
+ // of replaced content, which is not supposed to be possible. This
+ // check can be removed if ::-webkit-media-controls is made
+ // internal.
+ if (child->node()->isMediaControls())
+ return child->isFlexibleBox();
+
+ if (child->node()->isTextTrackContainer())
+ return true;
+
+ return false;
}
void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&)
« no previous file with comments | « Source/core/html/track/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698