seamless iframes don't take border into account properly and make the iframe too...
authormkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2013 20:50:43 +0000 (20:50 +0000)
committermkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2013 20:50:43 +0000 (20:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90827

Reviewed by Ojan Vafai.

Source/WebCore:

Seamless IFrames were incorrectly calculating their width; borders and
padding of the child document were accidentally left out of the end
result. This tiny patch adds the border/padding width to the calculated
width for the seamless IFrame, bringing things back into line with
expectations.

Test: fast/frames/seamless/seamless-border-padding.html

* rendering/RenderIFrame.cpp:
(WebCore::RenderIFrame::minPreferredLogicalWidth):
(WebCore::RenderIFrame::maxPreferredLogicalWidth):
    Add borderAndPaddingLogicalWidth() to the result of both methods.

LayoutTests:

* fast/frames/seamless/seamless-border-padding-expected.txt: Added.
* fast/frames/seamless/seamless-border-padding.html: Added.
    This test checks the IFrame's handling of borders and padding.
    Things work correctly for width after this patch, but there are
    still issues with padding and height, which will be fixed in
    http://wkbug.com/106167

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/frames/seamless/seamless-border-padding-expected.txt [new file with mode: 0644]
LayoutTests/fast/frames/seamless/seamless-border-padding.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderIFrame.cpp

index fdfe8ab..cf67bf8 100644 (file)
@@ -1,3 +1,17 @@
+2013-01-05  Mike West  <mkwst@chromium.org>
+
+        seamless iframes don't take border into account properly and make the iframe too small.
+        https://bugs.webkit.org/show_bug.cgi?id=90827
+
+        Reviewed by Ojan Vafai.
+
+        * fast/frames/seamless/seamless-border-padding-expected.txt: Added.
+        * fast/frames/seamless/seamless-border-padding.html: Added.
+            This test checks the IFrame's handling of borders and padding.
+            Things work correctly for width after this patch, but there are
+            still issues with padding and height, which will be fixed in
+            http://wkbug.com/106167
+
 2013-01-05  Min Qin  <qinmin@chromium.org>
 
         MediaControls::show() should make controls opaque
diff --git a/LayoutTests/fast/frames/seamless/seamless-border-padding-expected.txt b/LayoutTests/fast/frames/seamless/seamless-border-padding-expected.txt
new file mode 100644 (file)
index 0000000..7802a0f
--- /dev/null
@@ -0,0 +1,10 @@
+Test that seamless IFrames correctly size themselves when a border is present.
+PASS nothing.getBoundingClientRect().width is 100
+PASS nothing.getBoundingClientRect().height is 100
+PASS hasborder.getBoundingClientRect().width is 102
+PASS hasborder.getBoundingClientRect().height is 102
+PASS haspadding.getBoundingClientRect().width is 104
+FAIL haspadding.getBoundingClientRect().height should be 104. Was 100.
+PASS hasboth.getBoundingClientRect().width is 106
+FAIL hasboth.getBoundingClientRect().height should be 106. Was 102.
+      
diff --git a/LayoutTests/fast/frames/seamless/seamless-border-padding.html b/LayoutTests/fast/frames/seamless/seamless-border-padding.html
new file mode 100644 (file)
index 0000000..f4d021c
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../js/resources/js-test-pre.js"></script>
+    <style>
+        iframe { display: inline-block; }
+        .border { border: 1px solid black; }
+        .padding { padding: 2px;
+    </style>
+    <script>
+        debug("Test that seamless IFrames correctly size themselves when a border is present.");
+        window.onload = function () {
+            window.nothing = document.getElementById("nothing");
+            shouldBe("nothing.getBoundingClientRect().width", "100");
+            shouldBe("nothing.getBoundingClientRect().height", "100");
+
+            window.hasborder = document.getElementById("hasborder");
+            shouldBe("hasborder.getBoundingClientRect().width", "102");
+            shouldBe("hasborder.getBoundingClientRect().height", "102");
+
+            window.haspadding = document.getElementById("haspadding");
+            shouldBe("haspadding.getBoundingClientRect().width", "104");
+            shouldBe("haspadding.getBoundingClientRect().height", "104");
+
+            window.hasboth = document.getElementById("hasboth");
+            shouldBe("hasboth.getBoundingClientRect().width", "106");
+            shouldBe("hasboth.getBoundingClientRect().height", "106");
+        };
+    </script>
+</head>
+<body>
+    <iframe id="nothing" seamless srcdoc="<style>body { overflow:hidden; }</style><div style='width:100px;height:100px;'>TEST</div>"></iframe>
+    <iframe id="hasborder" class="border" seamless srcdoc="<style>body { overflow:hidden; }</style><div style='width:100px;height:100px;'>TEST</div>"></iframe>
+    <iframe id="haspadding" class="padding" seamless srcdoc="<style>body { overflow:hidden; }</style><div style='width:100px;height:100px;'>TEST</div>"></iframe>
+    <iframe id="hasboth" class="border padding" seamless srcdoc="<style>body { overflow:hidden; }</style><div style='width:100px;height:100px;'>TEST</div>"></iframe>
+</body>
index 806017a..8a8df8d 100644 (file)
@@ -1,3 +1,23 @@
+2013-01-05  Mike West  <mkwst@chromium.org>
+
+        seamless iframes don't take border into account properly and make the iframe too small.
+        https://bugs.webkit.org/show_bug.cgi?id=90827
+
+        Reviewed by Ojan Vafai.
+
+        Seamless IFrames were incorrectly calculating their width; borders and
+        padding of the child document were accidentally left out of the end
+        result. This tiny patch adds the border/padding width to the calculated
+        width for the seamless IFrame, bringing things back into line with
+        expectations.
+
+        Test: fast/frames/seamless/seamless-border-padding.html
+
+        * rendering/RenderIFrame.cpp:
+        (WebCore::RenderIFrame::minPreferredLogicalWidth):
+        (WebCore::RenderIFrame::maxPreferredLogicalWidth):
+            Add borderAndPaddingLogicalWidth() to the result of both methods.
+
 2013-01-05  Min Qin  <qinmin@chromium.org>
 
         MediaControls::show() should make controls opaque
index 2fcd58a..d47a208 100644 (file)
@@ -63,7 +63,7 @@ LayoutUnit RenderIFrame::minPreferredLogicalWidth() const
     if (!childRoot)
         return 0;
 
-    return childRoot->minPreferredLogicalWidth();
+    return childRoot->minPreferredLogicalWidth() + borderAndPaddingLogicalWidth();
 }
 
 LayoutUnit RenderIFrame::maxPreferredLogicalWidth() const
@@ -75,7 +75,7 @@ LayoutUnit RenderIFrame::maxPreferredLogicalWidth() const
     if (!childRoot)
         return 0;
 
-    return childRoot->maxPreferredLogicalWidth();
+    return childRoot->maxPreferredLogicalWidth() + borderAndPaddingLogicalWidth();
 }
 
 bool RenderIFrame::isSeamless() const