Diff
Modified: trunk/Source/WebCore/ChangeLog (155810 => 155811)
--- trunk/Source/WebCore/ChangeLog 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/ChangeLog 2013-09-15 14:13:55 UTC (rev 155811)
@@ -1,5 +1,20 @@
2013-09-15 Andreas Kling <akl...@apple.com>
+ CTTE: RenderMedia and RenderVideo are never anonymous.
+ <https://webkit.org/b/121388>
+
+ Reviewed by Sam Weinig.
+
+ Codify the following:
+
+ - RenderMedia always has an HTMLMediaElement.
+ - RenderVideo always has an HTMLVideoElement.
+
+ None of these renderers are ever anonymous, so delete element() and provide
+ strongly typed reference getters instead.
+
+2013-09-15 Andreas Kling <akl...@apple.com>
+
Unreviewed, rolling out r155809.
http://trac.webkit.org/changeset/155809
https://bugs.webkit.org/show_bug.cgi?id=121388
Modified: trunk/Source/WebCore/bindings/js/JSHTMLMediaElementCustom.cpp (155810 => 155811)
--- trunk/Source/WebCore/bindings/js/JSHTMLMediaElementCustom.cpp 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/bindings/js/JSHTMLMediaElementCustom.cpp 2013-09-15 14:13:55 UTC (rev 155811)
@@ -36,12 +36,11 @@
void JSHTMLMediaElement::setController(ExecState*, JSValue value)
{
- HTMLMediaElement* imp = toHTMLMediaElement(impl());
// 4.8.10.11.2 Media controllers: controller attribute.
// On setting, it must first remove the element's mediagroup attribute, if any,
- imp->setMediaGroup(String());
+ impl()->setMediaGroup(String());
// and then set the current media controller to the given value.
- imp->setController(toMediaController(value));
+ impl()->setController(toMediaController(value));
}
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (155810 => 155811)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-09-15 14:13:55 UTC (rev 155811)
@@ -560,7 +560,7 @@
{
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
// Setup the renderer if we already have a proxy widget.
- RenderEmbeddedObject* mediaRenderer = new (arena) RenderEmbeddedObject(this);
+ RenderEmbeddedObject* mediaRenderer = new (arena) RenderEmbeddedObject(*this);
if (m_proxyWidget) {
mediaRenderer->setWidget(m_proxyWidget);
@@ -569,7 +569,7 @@
}
return mediaRenderer;
#else
- return new (arena) RenderMedia(this);
+ return new (arena) RenderMedia(*this);
#endif
}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (155810 => 155811)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2013-09-15 14:13:55 UTC (rev 155811)
@@ -802,12 +802,21 @@
return node && node->isElementNode() && toElement(node)->isMediaElement();
}
+inline HTMLMediaElement& toHTMLMediaElement(Node& node)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(isMediaElement(&node));
+ return static_cast<HTMLMediaElement&>(node);
+}
+
inline HTMLMediaElement* toHTMLMediaElement(Node* node)
{
ASSERT_WITH_SECURITY_IMPLICATION(!node || isMediaElement(node));
return static_cast<HTMLMediaElement*>(node);
}
+void toHTMLMediaElement(const HTMLMediaElement&);
+void toHTMLMediaElement(const HTMLMediaElement*);
+
} //namespace
#endif
Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (155810 => 155811)
--- trunk/Source/WebCore/html/HTMLVideoElement.cpp 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp 2013-09-15 14:13:55 UTC (rev 155811)
@@ -71,7 +71,7 @@
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
RenderObject* HTMLVideoElement::createRenderer(RenderArena* arena, RenderStyle*)
{
- return new (arena) RenderVideo(this);
+ return new (arena) RenderVideo(*this);
}
#endif
Modified: trunk/Source/WebCore/rendering/RenderMedia.cpp (155810 => 155811)
--- trunk/Source/WebCore/rendering/RenderMedia.cpp 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/rendering/RenderMedia.cpp 2013-09-15 14:13:55 UTC (rev 155811)
@@ -28,21 +28,20 @@
#if ENABLE(VIDEO)
#include "RenderMedia.h"
-#include "HTMLMediaElement.h"
#include "RenderFlowThread.h"
#include "RenderView.h"
#include <wtf/StackStats.h>
namespace WebCore {
-RenderMedia::RenderMedia(HTMLMediaElement* video)
- : RenderImage(video)
+RenderMedia::RenderMedia(HTMLMediaElement& element)
+ : RenderImage(&element)
{
setImageResource(RenderImageResource::create());
}
-RenderMedia::RenderMedia(HTMLMediaElement* video, const IntSize& intrinsicSize)
- : RenderImage(video)
+RenderMedia::RenderMedia(HTMLMediaElement& element, const IntSize& intrinsicSize)
+ : RenderImage(&element)
{
setImageResource(RenderImageResource::create());
setIntrinsicSize(intrinsicSize);
@@ -52,11 +51,6 @@
{
}
-HTMLMediaElement* RenderMedia::mediaElement() const
-{
- return toHTMLMediaElement(element());
-}
-
void RenderMedia::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;
Modified: trunk/Source/WebCore/rendering/RenderMedia.h (155810 => 155811)
--- trunk/Source/WebCore/rendering/RenderMedia.h 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/rendering/RenderMedia.h 2013-09-15 14:13:55 UTC (rev 155811)
@@ -28,30 +28,31 @@
#if ENABLE(VIDEO)
+#include "HTMLMediaElement.h"
#include "RenderImage.h"
namespace WebCore {
-class HTMLMediaElement;
-
class RenderMedia : public RenderImage {
public:
- explicit RenderMedia(HTMLMediaElement*);
- RenderMedia(HTMLMediaElement*, const IntSize& intrinsicSize);
+ explicit RenderMedia(HTMLMediaElement&);
+ RenderMedia(HTMLMediaElement&, const IntSize& intrinsicSize);
virtual ~RenderMedia();
+ HTMLMediaElement& mediaElement() const { return *toHTMLMediaElement(RenderImage::element()); }
+
RenderObject* firstChild() const { return m_children.firstChild(); }
RenderObject* lastChild() const { return m_children.lastChild(); }
virtual const RenderObjectChildList* children() const OVERRIDE FINAL { return &m_children; }
virtual RenderObjectChildList* children() OVERRIDE FINAL { return &m_children; }
- HTMLMediaElement* mediaElement() const;
-
protected:
virtual void layout();
private:
+ void element() const WTF_DELETED_FUNCTION;
+
virtual bool canHaveChildren() const OVERRIDE FINAL { return true; }
virtual const char* renderName() const OVERRIDE { return "RenderMedia"; }
Modified: trunk/Source/WebCore/rendering/RenderVideo.cpp (155810 => 155811)
--- trunk/Source/WebCore/rendering/RenderVideo.cpp 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/rendering/RenderVideo.cpp 2013-09-15 14:13:55 UTC (rev 155811)
@@ -48,17 +48,17 @@
using namespace HTMLNames;
-RenderVideo::RenderVideo(HTMLVideoElement* video)
- : RenderMedia(video)
+RenderVideo::RenderVideo(HTMLVideoElement& element)
+ : RenderMedia(element)
{
setIntrinsicSize(calculateIntrinsicSize());
}
RenderVideo::~RenderVideo()
{
- if (MediaPlayer* p = mediaElement()->player()) {
- p->setVisible(false);
- p->setFrameView(0);
+ if (MediaPlayer* player = videoElement().player()) {
+ player->setVisible(false);
+ player->setFrameView(0);
}
}
@@ -73,7 +73,7 @@
void RenderVideo::intrinsicSizeChanged()
{
- if (videoElement()->shouldDisplayPosterImage())
+ if (videoElement().shouldDisplayPosterImage())
RenderMedia::intrinsicSizeChanged();
updateIntrinsicSize();
}
@@ -84,7 +84,7 @@
size.scale(style()->effectiveZoom());
// Never set the element size to zero when in a media document.
- if (size.isEmpty() && element()->document().isMediaDocument())
+ if (size.isEmpty() && document().isMediaDocument())
return;
if (size == intrinsicSize())
@@ -97,8 +97,6 @@
LayoutSize RenderVideo::calculateIntrinsicSize()
{
- HTMLVideoElement* video = videoElement();
-
// Spec text from 4.8.6
//
// The intrinsic width of a video element's playback area is the intrinsic width
@@ -108,27 +106,27 @@
// 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) {
+ MediaPlayer* player = videoElement().player();
+ if (player && videoElement().readyState() >= HTMLVideoElement::HAVE_METADATA) {
LayoutSize size = player->naturalSize();
if (!size.isEmpty())
return size;
}
- if (video->shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !imageResource()->errorOccurred())
+ if (videoElement().shouldDisplayPosterImage() && !m_cachedImageSize.isEmpty() && !imageResource()->errorOccurred())
return m_cachedImageSize;
// When the natural size of the video is unavailable, we use the provided
// width and height attributes of the video element as the intrinsic size until
- // better values become available.
- if (video->hasAttribute(widthAttr) && video->hasAttribute(heightAttr))
- return LayoutSize(video->width(), video->height());
+ // better values become available.
+ if (videoElement().hasAttribute(widthAttr) && videoElement().hasAttribute(heightAttr))
+ return LayoutSize(videoElement().width(), videoElement().height());
// <video> in standalone media documents should not use the default 300x150
// size since they also have audio-only files. By setting the intrinsic
// size to 300x1 the video will resize itself in these cases, and audio will
// have the correct height (it needs to be > 0 for controls to render properly).
- if (video->document().isMediaDocument())
+ if (videoElement().document().isMediaDocument())
return LayoutSize(defaultSize().width(), 1);
return defaultSize();
@@ -141,7 +139,7 @@
// Cache the image intrinsic size so we can continue to use it to draw the image correctly
// even if we know the video intrinsic size but aren't able to draw video frames yet
// (we don't want to scale the poster to the video size without keeping aspect ratio).
- if (videoElement()->shouldDisplayPosterImage())
+ if (videoElement().shouldDisplayPosterImage())
m_cachedImageSize = intrinsicSize();
// The intrinsic size is now that of the image, but in case we already had the
@@ -153,7 +151,7 @@
{
LayoutSize intrinsicSize = this->intrinsicSize();
- if (videoElement()->shouldDisplayPosterImage())
+ if (videoElement().shouldDisplayPosterImage())
intrinsicSize = m_cachedImageSize;
return pixelSnappedIntRect(replacedContentRect(intrinsicSize));
@@ -161,13 +159,13 @@
bool RenderVideo::shouldDisplayVideo() const
{
- return !videoElement()->shouldDisplayPosterImage();
+ return !videoElement().shouldDisplayPosterImage();
}
void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- MediaPlayer* mediaPlayer = mediaElement()->player();
- bool displayingPoster = videoElement()->shouldDisplayPosterImage();
+ MediaPlayer* mediaPlayer = videoElement().player();
+ bool displayingPoster = videoElement().shouldDisplayPosterImage();
Page* page = frame().page();
@@ -211,9 +209,9 @@
updatePlayer();
}
-HTMLVideoElement* RenderVideo::videoElement() const
+HTMLVideoElement& RenderVideo::videoElement() const
{
- return toHTMLVideoElement(element());
+ return toHTMLVideoElement(RenderMedia::mediaElement());
}
void RenderVideo::updateFromElement()
@@ -229,11 +227,11 @@
updateIntrinsicSize();
- MediaPlayer* mediaPlayer = mediaElement()->player();
+ MediaPlayer* mediaPlayer = videoElement().player();
if (!mediaPlayer)
return;
- if (!videoElement()->inActiveDocument()) {
+ if (!videoElement().inActiveDocument()) {
mediaPlayer->setVisible(false);
return;
}
@@ -267,24 +265,21 @@
#if USE(ACCELERATED_COMPOSITING)
bool RenderVideo::supportsAcceleratedRendering() const
{
- MediaPlayer* p = mediaElement()->player();
- if (p)
- return p->supportsAcceleratedRendering();
-
+ if (MediaPlayer* player = videoElement().player())
+ return player->supportsAcceleratedRendering();
return false;
}
void RenderVideo::acceleratedRenderingStateChanged()
{
- MediaPlayer* p = mediaElement()->player();
- if (p)
- p->acceleratedRenderingStateChanged();
+ if (MediaPlayer* player = videoElement().player())
+ player->acceleratedRenderingStateChanged();
}
#endif // USE(ACCELERATED_COMPOSITING)
bool RenderVideo::requiresImmediateCompositing() const
{
- MediaPlayer* player = mediaElement()->player();
+ MediaPlayer* player = videoElement().player();
return player && player->requiresImmediateCompositing();
}
@@ -333,13 +328,13 @@
bool RenderVideo::foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const
{
- if (videoElement()->shouldDisplayPosterImage())
+ if (videoElement().shouldDisplayPosterImage())
return RenderImage::foregroundIsKnownToBeOpaqueInRect(localRect, maxDepthToTest);
if (!videoBox().contains(enclosingIntRect(localRect)))
return false;
- if (MediaPlayer* player = mediaElement()->player())
+ if (MediaPlayer* player = videoElement().player())
return player->hasAvailableVideoFrame();
return false;
Modified: trunk/Source/WebCore/rendering/RenderVideo.h (155810 => 155811)
--- trunk/Source/WebCore/rendering/RenderVideo.h 2013-09-15 14:12:11 UTC (rev 155810)
+++ trunk/Source/WebCore/rendering/RenderVideo.h 2013-09-15 14:13:55 UTC (rev 155811)
@@ -31,15 +31,16 @@
#include "RenderMedia.h"
namespace WebCore {
-
-class HTMLMediaElement;
+
class HTMLVideoElement;
class RenderVideo FINAL : public RenderMedia {
public:
- RenderVideo(HTMLVideoElement*);
+ explicit RenderVideo(HTMLVideoElement&);
virtual ~RenderVideo();
+ HTMLVideoElement& videoElement() const;
+
IntRect videoBox() const;
static IntSize defaultSize();
@@ -54,8 +55,9 @@
virtual bool shouldDisplayVideo() const;
private:
+ void mediaElement() const WTF_DELETED_FUNCTION;
+
virtual void updateFromElement();
- inline HTMLVideoElement* videoElement() const;
virtual void intrinsicSizeChanged();
LayoutSize calculateIntrinsicSize();