Index: Source/core/layout/LayoutMedia.cpp |
diff --git a/Source/core/layout/LayoutMedia.cpp b/Source/core/layout/LayoutMedia.cpp |
index 905cee26c646822ed0b51f24b53b81e70532a937..54401ef2878c5524302bb834580d64c2d41b3047 100644 |
--- a/Source/core/layout/LayoutMedia.cpp |
+++ b/Source/core/layout/LayoutMedia.cpp |
@@ -57,8 +57,22 @@ void LayoutMedia::layout() |
LayoutState state(*this, locationOffset()); |
- for (LayoutObject* child = m_children.firstChild(); child; child = child->nextSibling()) { |
- ASSERT(child->node()->isMediaControls() || child->node()->isTextTrackContainer()); |
+ // Iterate the children in reverse order so that the media controls are laid |
+ // out before the text track container. This is to ensure that the text |
+ // track rendering has an up-to-date position of the media controls for |
+ // overlap checking, see LayoutVTTCue. |
+#if ENABLE(ASSERT) |
+ bool seenTextTrackContainer = false; |
+#endif |
+ for (LayoutObject* child = m_children.lastChild(); child; child = child->previousSibling()) { |
+#if ENABLE(ASSERT) |
+ if (child->node()->isMediaControls()) |
+ ASSERT(!seenTextTrackContainer); |
+ else if (child->node()->isTextTrackContainer()) |
+ seenTextTrackContainer = true; |
+ else |
+ ASSERT_NOT_REACHED(); |
+#endif |
if (newSize == oldSize && !child->needsLayout()) |
continue; |