Index: Source/core/layout/LayoutVTTCue.cpp |
diff --git a/Source/core/layout/LayoutVTTCue.cpp b/Source/core/layout/LayoutVTTCue.cpp |
index cd3007f1284658ad94209a1cd09278e134fb67c5..4f4440d98670fd5b02869f82f2ba24c068b3401a 100644 |
--- a/Source/core/layout/LayoutVTTCue.cpp |
+++ b/Source/core/layout/LayoutVTTCue.cpp |
@@ -29,6 +29,7 @@ |
#include "core/html/track/vtt/VTTCue.h" |
#include "core/layout/LayoutInline.h" |
#include "core/layout/LayoutState.h" |
+#include "core/layout/LayoutTextTrackContainer.h" |
namespace blink { |
@@ -41,8 +42,9 @@ LayoutVTTCue::LayoutVTTCue(VTTCueBox* element) |
class SnapToLinesLayouter { |
STACK_ALLOCATED(); |
public: |
- SnapToLinesLayouter(LayoutVTTCue& cueBox, float linePosition) |
+ SnapToLinesLayouter(LayoutVTTCue& cueBox, IntRect& controlsRect, float linePosition) |
: m_cueBox(cueBox) |
+ , m_controlsRect(controlsRect) |
, m_linePosition(linePosition) |
{ |
} |
@@ -64,6 +66,7 @@ private: |
LayoutPoint m_specifiedPosition; |
LayoutVTTCue& m_cueBox; |
+ IntRect m_controlsRect; |
float m_linePosition; |
}; |
@@ -116,13 +119,19 @@ bool SnapToLinesLayouter::isOutside() const |
bool SnapToLinesLayouter::isOverlapping() const |
{ |
+ IntRect cueBoxRect = m_cueBox.absoluteBoundingBoxRect(); |
for (LayoutObject* box = m_cueBox.previousSibling(); box; box = box->previousSibling()) { |
IntRect boxRect = box->absoluteBoundingBoxRect(); |
- if (m_cueBox.absoluteBoundingBoxRect().intersects(boxRect)) |
+ if (cueBoxRect.intersects(boxRect)) |
return true; |
} |
+ ASSERT(!m_cueBox.nextSibling()); |
+ |
+ if (cueBoxRect.intersects(m_controlsRect)) |
+ return true; |
+ |
return false; |
} |
@@ -317,9 +326,12 @@ void LayoutVTTCue::layout() |
LayoutState state(*this, locationOffset()); |
+ ASSERT(parent()->node()->isTextTrackContainer()); |
+ IntRect controlsRect = static_cast<LayoutTextTrackContainer*>(parent())->controlsRect(); |
+ |
// http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. |
if (m_cue->snapToLines()) { |
- SnapToLinesLayouter(*this, m_cue->calculateComputedLinePosition()).layout(); |
+ SnapToLinesLayouter(*this, controlsRect, m_cue->calculateComputedLinePosition()).layout(); |
adjustForTopAndBottomMarginBorderAndPadding(); |
} else { |