Reviewed by Mitz.
Fix aspect ratio calculation of video.
Video should always be treated as a replaced element in size calculation.
Test: media/video-aspect-ratio.html
* rendering/RenderBox.cpp:
(WebCore::RenderBox::calcWidth):
(WebCore::RenderBox::calcHeight):
* rendering/RenderBox.h:
(WebCore::RenderBox::shouldCalculateSizeAsReplaced):
* rendering/RenderMedia.h:
(WebCore::RenderMedia::shouldCalculateSizeAsReplaced):
LayoutTests:
Reviewed by Mitz.
Test for video aspect ratio calculation.
* media/video-aspect-ratio.html: Added.
* platform/mac/media: Added.
* platform/mac/media/video-aspect-ratio-expected.checksum: Added.
* platform/mac/media/video-aspect-ratio-expected.png: Added.
* platform/mac/media/video-aspect-ratio-expected.txt: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28226
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-11-29 Antti Koivisto <antti@apple.com>
+
+ Reviewed by Mitz.
+
+ Test for video aspect ratio calculation.
+
+ * media/video-aspect-ratio.html: Added.
+ * platform/mac/media: Added.
+ * platform/mac/media/video-aspect-ratio-expected.checksum: Added.
+ * platform/mac/media/video-aspect-ratio-expected.png: Added.
+ * platform/mac/media/video-aspect-ratio-expected.txt: Added.
+
2007-11-29 Anders Carlsson <andersca@apple.com>
Reviewed by Sam.
--- /dev/null
+<p>Test video sizing. You should see one bigger image (paused video) and 7 small ones of 1/4 its size. </p>
+<video src="content/test.mp4"></video><br>
+<video src="content/test.mp4" style="width: 160px; height:120px">
+
+</video><div style="display:inline-block">
+<video src="content/test.mp4" style="width: 160px;">
+</video><video src="content/test.mp4" style="height: 120px;">
+</video>
+
+</div><div style="width: 320px; height:120px; display:inline-block; margin: 0">
+<video src="content/test.mp4" style="height: 100%;">
+</video><video src="content/test.mp4" style="width: 50%;"></video>
+
+</div><div style="width: 320px; height:120px;position:relative; display:inline-block; margin: 0">
+<video src="content/test.mp4" style="height: 120px; position: absolute;"></video>
+<video src="content/test.mp4" style="left: 160px; width: 160px; position: absolute;">
+</video>
+</div>
+<script>
+if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ setTimeout(function() {
+ document.body.appendChild(document.createTextNode('FAIL'));
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ } , 8000);
+}
+var count = document.getElementsByTagName('video').length;
+document.addEventListener("load", function () {
+ if (!--count) {
+ document.body.offsetLeft;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
+}, true);
+</script>
--- /dev/null
+cc3d95a58d95f0e0310077c086fad46c
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 623x18
+ text run at (0,0) width 623: "Test video sizing. You should see one bigger image (paused video) and 7 small ones of 1/4 its size."
+ RenderBlock (anonymous) at (0,34) size 784x480
+ RenderVideo {VIDEO} at (0,0) size 320x240
+ RenderBR {BR} at (320,240) size 0x0
+ RenderVideo {VIDEO} at (0,240) size 160x120
+ RenderBlock {DIV} at (160,240) size 320x120
+ RenderVideo {VIDEO} at (0,0) size 160x120
+ RenderVideo {VIDEO} at (160,0) size 160x120
+ RenderText {#text} at (0,0) size 0x0
+ RenderBlock {DIV} at (0,360) size 320x120
+ RenderVideo {VIDEO} at (0,0) size 160x120
+ RenderVideo {VIDEO} at (160,0) size 160x120
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+ RenderText {#text} at (0,0) size 0x0
+layer at (328,402) size 320x120
+ RenderBlock (relative positioned) {DIV} at (320,360) size 320x120
+layer at (328,402) size 160x120
+ RenderVideo {VIDEO} at (0,0) size 160x120
+layer at (488,402) size 160x120
+ RenderVideo {VIDEO} at (160,0) size 160x120
+2007-11-29 Antti Koivisto <antti@apple.com>
+
+ Reviewed by Mitz.
+
+ Fix aspect ratio calculation of video.
+
+ Video should always be treated as a replaced element in size calculation.
+
+ Test: media/video-aspect-ratio.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::calcWidth):
+ (WebCore::RenderBox::calcHeight):
+ * rendering/RenderBox.h:
+ (WebCore::RenderBox::shouldCalculateSizeAsReplaced):
+ * rendering/RenderMedia.h:
+ (WebCore::RenderMedia::shouldCalculateSizeAsReplaced):
+
2007-11-29 Sam Weinig <sam@webkit.org>
Reviewed by Oliver.
bool inVerticalBox = parent()->isFlexibleBox() && (parent()->style()->boxOrient() == VERTICAL);
bool stretching = (parent()->style()->boxAlign() == BSTRETCH);
- bool treatAsReplaced = isReplaced() && !isInlineBlockOrInlineTable() && (!inVerticalBox || !stretching);
+ bool treatAsReplaced = shouldCalculateSizeAsReplaced() && (!inVerticalBox || !stretching);
Length width = (treatAsReplaced) ? Length(calcReplacedWidth(), Fixed) : style()->width();
Length h;
bool inHorizontalBox = parent()->isFlexibleBox() && parent()->style()->boxOrient() == HORIZONTAL;
bool stretching = parent()->style()->boxAlign() == BSTRETCH;
- bool treatAsReplaced = isReplaced() && !isInlineBlockOrInlineTable() && (!inHorizontalBox || !stretching);
+ bool treatAsReplaced = shouldCalculateSizeAsReplaced() && (!inHorizontalBox || !stretching);
bool checkMinMaxHeight = false;
// The parent box is flexing us, so it has increased or decreased our height. We have to
#endif
void calcAbsoluteHorizontal();
+
+ virtual bool shouldCalculateSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
private:
void paintRootBoxDecorations(PaintInfo&, int tx, int ty);
virtual void setStyle(RenderStyle* newStyle);
virtual bool canHaveChildren() const { return false; }
+
+ virtual bool shouldCalculateSizeAsReplaced() const { return true; }
virtual const char* renderName() const { return "RenderMedia"; }
virtual bool isMedia() const { return true; }