#include "core/rendering/RenderVideo.h"
-#include "HTMLNames.h"
+#include "core/HTMLNames.h"
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLVideoElement.h"
-#include "core/rendering/LayoutRectRecorder.h"
+#include "core/paint/VideoPainter.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderFullScreen.h"
#include "platform/graphics/media/MediaPlayer.h"
#include "public/platform/WebLayer.h"
-namespace WebCore {
+namespace blink {
using namespace HTMLNames;
IntSize RenderVideo::defaultSize()
{
- // These values are specified in the spec.
- static const int cDefaultWidth = 300;
- static const int cDefaultHeight = 150;
-
- return IntSize(cDefaultWidth, cDefaultHeight);
+ return IntSize(defaultWidth, defaultHeight);
}
void RenderVideo::intrinsicSizeChanged()
setIntrinsicSize(size);
setPreferredLogicalWidthsDirty();
- setNeedsLayout();
+ setNeedsLayoutAndFullPaintInvalidation();
}
LayoutSize RenderVideo::calculateIntrinsicSize()
// The intrinsic height of a video element's playback area is the intrinsic height
// of the video resource, if that is available; otherwise it is the intrinsic
// height of the poster frame, if that is available; otherwise it is 150 CSS pixels.
- MediaPlayer* player = mediaElement()->player();
- if (player && video->readyState() >= HTMLVideoElement::HAVE_METADATA) {
- LayoutSize size = player->naturalSize();
+ WebMediaPlayer* webMediaPlayer = mediaElement()->webMediaPlayer();
+ if (webMediaPlayer && video->readyState() >= HTMLVideoElement::HAVE_METADATA) {
+ IntSize size = webMediaPlayer->naturalSize();
if (!size.isEmpty())
return size;
}
void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- MediaPlayer* mediaPlayer = mediaElement()->player();
- bool displayingPoster = videoElement()->shouldDisplayPosterImage();
- if (!displayingPoster && !mediaPlayer)
- return;
-
- LayoutRect rect = videoBox();
- if (rect.isEmpty())
- return;
- rect.moveBy(paintOffset);
-
- LayoutRect contentRect = contentBoxRect();
- contentRect.moveBy(paintOffset);
- GraphicsContext* context = paintInfo.context;
- bool clip = !contentRect.contains(rect);
- if (clip) {
- context->save();
- context->clip(contentRect);
- }
-
- if (displayingPoster)
- paintIntoRect(context, rect);
- else if ((document().view() && document().view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) || !acceleratedRenderingInUse())
- mediaPlayer->paint(context, pixelSnappedIntRect(rect));
-
- if (clip)
- context->restore();
+ VideoPainter(*this).paintReplaced(paintInfo, paintOffset);
}
bool RenderVideo::acceleratedRenderingInUse()
{
- blink::WebLayer* webLayer = mediaElement()->platformLayer();
+ WebLayer* webLayer = mediaElement()->platformLayer();
return webLayer && !webLayer->isOrphan();
}
void RenderVideo::layout()
{
- LayoutRectRecorder recorder(*this);
updatePlayer();
RenderMedia::layout();
}
{
updateIntrinsicSize();
- MediaPlayer* mediaPlayer = mediaElement()->player();
+ WebMediaPlayer* mediaPlayer = mediaElement()->webMediaPlayer();
if (!mediaPlayer)
return;
if (!videoElement()->isActive())
return;
- contentChanged(VideoChanged);
+ videoElement()->setNeedsCompositingUpdate();
}
LayoutUnit RenderVideo::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
return RenderMedia::offsetHeight();
}
-CompositingReasons RenderVideo::additionalCompositingReasons(CompositingTriggerFlags triggers) const
+CompositingReasons RenderVideo::additionalCompositingReasons() const
{
if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled()) {
HTMLMediaElement* media = toHTMLMediaElement(node());
return CompositingReasonVideo;
}
- if ((triggers & VideoTrigger) && shouldDisplayVideo() && supportsAcceleratedRendering())
+ if (shouldDisplayVideo() && supportsAcceleratedRendering())
return CompositingReasonVideo;
return CompositingReasonNone;
}
-} // namespace WebCore
+} // namespace blink