Commit 354590c8 authored by eric@webkit.org's avatar eric@webkit.org

2010-01-28 Nicholas Young <nicholas.young@nokia.com>

        Reviewed by Eric Carlson.

        Prefer provided video element width/height properties to hard coded
        defaults for intrinsic size when natural video size is unavailable.
        https://bugs.webkit.org/show_bug.cgi?id=34302

        No new tests needed.

        * rendering/RenderVideo.cpp: Attempt to use width/height properties
        (WebCore::RenderVideo::RenderVideo):
        * rendering/RenderVideo.h: More appropriate constructor signature

git-svn-id: svn://svn.chromium.org/blink/trunk@54048 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 350a20a4
2010-01-28 Nicholas Young <nicholas.young@nokia.com>
Reviewed by Eric Carlson.
Prefer provided video element width/height properties to hard coded
defaults for intrinsic size when natural video size is unavailable.
https://bugs.webkit.org/show_bug.cgi?id=34302
No new tests needed.
* rendering/RenderVideo.cpp: Attempt to use width/height properties
(WebCore::RenderVideo::RenderVideo):
* rendering/RenderVideo.h: More appropriate constructor signature
2010-01-28 Oliver Hunt <oliver@apple.com> 2010-01-28 Oliver Hunt <oliver@apple.com>
Reviewed by Gavin Barraclough. Reviewed by Gavin Barraclough.
...@@ -50,18 +50,25 @@ using namespace HTMLNames; ...@@ -50,18 +50,25 @@ using namespace HTMLNames;
static const int cDefaultWidth = 300; static const int cDefaultWidth = 300;
static const int cDefaultHeight = 150; static const int cDefaultHeight = 150;
RenderVideo::RenderVideo(HTMLMediaElement* video) RenderVideo::RenderVideo(HTMLVideoElement* video)
: RenderMedia(video) : RenderMedia(video)
{ {
if (video->player()) if (video->player())
setIntrinsicSize(video->player()->naturalSize()); setIntrinsicSize(video->player()->naturalSize());
else { else {
// Video in standalone media documents should not use the default 300x150 // When the natural size of the video is unavailable, we use the provided
// size since they also have audio thrown at them. By setting the intrinsic // width and height attributes of the video element as the intrinsic size until
// size to 300x1 the video will resize itself in these cases, and audio will // better values become available. If these attributes are not set, we fall back
// have the correct height (it needs to be > 0 for controls to render properly). // to a default video size (300x150).
if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) if (video->hasAttribute(widthAttr) && video->hasAttribute(heightAttr))
setIntrinsicSize(IntSize(video->width(), video->height()));
else if (video->ownerDocument() && video->ownerDocument()->isMediaDocument()) {
// Video in standalone media documents should not use the default 300x150
// size since they also have audio thrown at them. 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).
setIntrinsicSize(IntSize(cDefaultWidth, 1)); setIntrinsicSize(IntSize(cDefaultWidth, 1));
}
else else
setIntrinsicSize(IntSize(cDefaultWidth, cDefaultHeight)); setIntrinsicSize(IntSize(cDefaultWidth, cDefaultHeight));
} }
......
...@@ -40,7 +40,7 @@ class GraphicsLayer; ...@@ -40,7 +40,7 @@ class GraphicsLayer;
class RenderVideo : public RenderMedia { class RenderVideo : public RenderMedia {
public: public:
RenderVideo(HTMLMediaElement*); RenderVideo(HTMLVideoElement*);
virtual ~RenderVideo(); virtual ~RenderVideo();
void videoSizeChanged(); void videoSizeChanged();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment