RESOLVED FIXED 155198
IFrame is resized incorrectly on orientation change
https://bugs.webkit.org/show_bug.cgi?id=155198
Summary IFrame is resized incorrectly on orientation change
Dima Voytenko
Reported Tuesday, March 8, 2016 11:00:12 PM UTC
Device: iPhone 6 The demo: - parent document: http://jsbin.com/panoke/edit?html,css,output - iframe document: http://jsbin.com/somuhix/edit?html,css,js,output To reproduce: 1. Open http://output.jsbin.com/panoke/quiet in the portrait mode 2. Switch to landscape mode. Observe the reported resize event with the viewport width 667 (window.innerWidth = 667) 3. Switch back to portrait mode. Observe the reported resize event with the viewport width 667 (window.innerWidth = 667) again, which is incorrect. Expected: When rotating back to portrait mode, the expected viewport width should be 375. The child iframe document sets the width on one of its elements based on the viewport width. This, however, should only affect scrollWidth and not viewport width. Workaround: Instead of `iframe {width: 100%}` CSS, use `iframe {min-width: 100%}` (or even `iframe {min-width: 100%; max-width: 100%}`) - that fixes the problem. It appears that `width: 100%` explicitly triggers some different mode on the iframe.
Attachments
testcase (1.59 KB, text/html)
2017-01-31 06:17 PST, Frédéric Wang (:fredw)
no flags
testcase (1.80 KB, text/html)
2017-01-31 06:17 PST, Frédéric Wang (:fredw)
no flags
Patch (5.74 KB, patch)
2018-02-16 07:48 PST, Frédéric Wang (:fredw)
tonikitoo: review+
Radar WebKit Bug Importer
Comment 1 Thursday, October 6, 2016 11:16:27 PM UTC
Frédéric Wang (:fredw)
Comment 2 Tuesday, January 31, 2017 2:17:15 PM UTC
Created attachment 300208 [details] testcase
Frédéric Wang (:fredw)
Comment 3 Tuesday, January 31, 2017 2:17:42 PM UTC
Created attachment 300209 [details] testcase
Frédéric Wang (:fredw)
Comment 4 Monday, February 12, 2018 3:11:34 PM UTC
Testing with the simulator, the bug seems to be fixed on trunk (I can reproduce it with iOS 10.0 though).
Frédéric Wang (:fredw)
Comment 5 Friday, February 16, 2018 3:48:24 PM UTC
Antonio Gomes
Comment 6 Monday, February 19, 2018 4:15:35 PM UTC
Comment on attachment 334041 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=334041&action=review r+ w/ nits > LayoutTests/fast/events/ios/rotation/resize-iframe-after-orientation-change.html:26 > + uiController.simulateRotation('${orientation}', function() { let use either single or double quote throughout the test. > LayoutTests/fast/events/ios/rotation/resize-iframe-after-orientation-change.html:43 > + await rotateDevice('portrait'); > + var output = document.getElementById("output"); > + var outer = document.getElementById("outer"); > + shouldBe('document.getElementById("frame").scrollWidth', 'outer.scrollWidth'); > + shouldBe('document.getElementById("frame").contentDocument.getElementById("inner").scrollWidth', 'outer.scrollWidth'); ditto, unless where the difference makes sense.
Frédéric Wang (:fredw)
Comment 7 Monday, February 19, 2018 4:57:47 PM UTC
Note You need to log in before you can comment on or make changes to this bug.