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

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

Issue 1018593004: Implement <video controls> dodging for text track layout (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/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.h » ('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 8b960ab7c012b658458db01c46fe972445023594..2078e21c7484d273ee76690c66822e95e6939753 100644
--- a/Source/core/layout/LayoutMedia.cpp
+++ b/Source/core/layout/LayoutMedia.cpp
@@ -28,6 +28,8 @@
#include "core/layout/LayoutMedia.h"
#include "core/html/HTMLMediaElement.h"
+#include "core/html/shadow/MediaControls.h"
+#include "core/layout/LayoutTextTrackContainer.h"
#include "core/layout/LayoutView.h"
namespace blink {
@@ -55,19 +57,40 @@ void LayoutMedia::layout()
LayoutSize newSize = contentBoxRect().size();
- LayoutState state(*this, locationOffset());
-
- for (LayoutObject* child = m_children.firstChild(); child; child = child->nextSibling()) {
- ASSERT(child->node()->isMediaControls() || child->node()->isTextTrackContainer());
+ bool sizeChanged = newSize != oldSize;
- if (newSize == oldSize && !child->needsLayout())
- continue;
+ LayoutState state(*this, locationOffset());
- LayoutBox* layoutBox = toLayoutBox(child);
- layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
- layoutBox->style()->setHeight(Length(newSize.height(), Fixed));
- layoutBox->style()->setWidth(Length(newSize.width(), Fixed));
- layoutBox->forceLayout();
+ // Iterate the children in reverse order so that the media controls are laid
+ // out before the text track container.
+ IntRect controlsRect;
+#if ENABLE(ASSERT)
+ bool didLayoutTextTrackContainer = false;
+#endif
+ for (LayoutObject* child = m_children.lastChild(); child; child = child->previousSibling()) {
fs 2015/03/17 10:27:56 I think you could also just drop the for-loop enti
+ bool isMediaControls = child->node()->isMediaControls();
+ bool isTextTrackContainer = child->node()->isTextTrackContainer();
+ ASSERT(isMediaControls || isTextTrackContainer);
+
+ if (isTextTrackContainer) {
+#if ENABLE(ASSERT)
+ didLayoutTextTrackContainer = true;
+#endif
+ static_cast<LayoutTextTrackContainer*>(child)->setControlsRect(controlsRect);
+ }
+
+ if (sizeChanged || child->needsLayout()) {
+ LayoutBox* layoutBox = toLayoutBox(child);
+ layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
+ layoutBox->style()->setHeight(Length(newSize.height(), Fixed));
+ layoutBox->style()->setWidth(Length(newSize.width(), Fixed));
+ layoutBox->forceLayout();
+ }
+
+ if (isMediaControls) {
+ ASSERT(!didLayoutTextTrackContainer);
+ controlsRect = toMediaControls(child->node())->absoluteRectForTextTracks();
+ }
}
clearNeedsLayout();
« no previous file with comments | « Source/core/html/track/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698