WebCore:
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2007 05:25:25 +0000 (05:25 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2007 05:25:25 +0000 (05:25 +0000)
        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

LayoutTests/ChangeLog
LayoutTests/media/video-aspect-ratio.html [new file with mode: 0644]
LayoutTests/platform/mac/media/video-aspect-ratio-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/media/video-aspect-ratio-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/media/video-aspect-ratio-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/RenderBox.cpp
WebCore/rendering/RenderBox.h
WebCore/rendering/RenderMedia.h

index 8829270b566d7d56ae6ca74488172036b87168cb..abb28dca999a976cc8483d25ebeffa4a9df56d48 100644 (file)
@@ -1,3 +1,15 @@
+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.
diff --git a/LayoutTests/media/video-aspect-ratio.html b/LayoutTests/media/video-aspect-ratio.html
new file mode 100644 (file)
index 0000000..f43330a
--- /dev/null
@@ -0,0 +1,36 @@
+<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>
diff --git a/LayoutTests/platform/mac/media/video-aspect-ratio-expected.checksum b/LayoutTests/platform/mac/media/video-aspect-ratio-expected.checksum
new file mode 100644 (file)
index 0000000..4898c07
--- /dev/null
@@ -0,0 +1 @@
+cc3d95a58d95f0e0310077c086fad46c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/media/video-aspect-ratio-expected.png b/LayoutTests/platform/mac/media/video-aspect-ratio-expected.png
new file mode 100644 (file)
index 0000000..defe3b5
Binary files /dev/null and b/LayoutTests/platform/mac/media/video-aspect-ratio-expected.png differ
diff --git a/LayoutTests/platform/mac/media/video-aspect-ratio-expected.txt b/LayoutTests/platform/mac/media/video-aspect-ratio-expected.txt
new file mode 100644 (file)
index 0000000..bec3afd
--- /dev/null
@@ -0,0 +1,28 @@
+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
index 8a13a03d974c2e3aa30fab862692b63008780e96..7c27d30a2d750cde04cbbbfdfb416df09de1945f 100644 (file)
@@ -1,3 +1,21 @@
+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.
index c04ee1d3812226418ab3e630394ed9cc5785a660..8070624ddc74bc4a2872ce7e0b5398447a5c8972 100644 (file)
@@ -1094,7 +1094,7 @@ void RenderBox::calcWidth()
 
     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();
 
@@ -1266,7 +1266,7 @@ void RenderBox::calcHeight()
         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
index d61b8c6a1b7e7801e266e82ce926d5542f3e81e3..3e6668d0c121c011ae44853c12c9c1017fcab1fb 100644 (file)
@@ -162,6 +162,8 @@ protected:
 #endif
 
     void calcAbsoluteHorizontal();
+    
+    virtual bool shouldCalculateSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
 
 private:
     void paintRootBoxDecorations(PaintInfo&, int tx, int ty);
index 2ed3cad9bc02841e9b3c35b3738a8e7ebe404c41..e232a0acadf49b258466a5218587cd35b296bb8f 100644 (file)
@@ -47,6 +47,8 @@ public:
     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; }