Upstream version 11.39.250.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderMedia.cpp
index aacc6ae..9be9622 100644 (file)
 #include "core/rendering/RenderMedia.h"
 
 #include "core/html/HTMLMediaElement.h"
-#include "core/rendering/LayoutRectRecorder.h"
-#include "core/rendering/RenderFlowThread.h"
 #include "core/rendering/RenderView.h"
 
-namespace WebCore {
+namespace blink {
 
 RenderMedia::RenderMedia(HTMLMediaElement* video)
     : RenderImage(video)
@@ -44,6 +42,12 @@ RenderMedia::~RenderMedia()
 {
 }
 
+void RenderMedia::trace(Visitor* visitor)
+{
+    visitor->trace(m_children);
+    RenderImage::trace(visitor);
+}
+
 HTMLMediaElement* RenderMedia::mediaElement() const
 {
     return toHTMLMediaElement(node());
@@ -51,7 +55,6 @@ HTMLMediaElement* RenderMedia::mediaElement() const
 
 void RenderMedia::layout()
 {
-    LayoutRectRecorder recorder(*this);
     LayoutSize oldSize = contentBoxRect().size();
 
     RenderImage::layout();
@@ -61,34 +64,31 @@ void RenderMedia::layout()
         return;
 
     bool controlsNeedLayout = controlsRenderer->needsLayout();
-    // If the region chain has changed we also need to relayout the controls to update the region box info.
-    // FIXME: We can do better once we compute region box info for RenderReplaced, not only for RenderBlock.
-    const RenderFlowThread* flowThread = flowThreadContainingBlock();
-    if (flowThread && !controlsNeedLayout) {
-        if (flowThread->pageLogicalSizeChanged())
-            controlsNeedLayout = true;
-    }
-
     LayoutSize newSize = contentBoxRect().size();
     if (newSize == oldSize && !controlsNeedLayout)
         return;
 
-    // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or
-    // instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient,
-    // and this method will be called many times per second during playback, use a LayoutStateMaintainer:
-    LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
+    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();
     clearNeedsLayout();
+}
 
-    statePusher.pop();
+bool RenderMedia::isChildAllowed(RenderObject* child, RenderStyle*) 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();
 }
 
 void RenderMedia::paintReplaced(PaintInfo&, const LayoutPoint&)
 {
 }
 
-} // namespace WebCore
+} // namespace blink