Chromium Code Reviews| 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(); |