-
Notifications
You must be signed in to change notification settings - Fork 20.6k
CSS: dimensions workaround for IE11 fullscreen quirk #2401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b9513bb
to
25c134d
Compare
25c134d
to
a6d1fa4
Compare
This fix will not work if IE/Edge fixes this bug so I don't think it'll work. We'd need to have a way to feature detect this bug but this would require going to fullscreen which is impossible (and we wouldn't want to do such an invasive test anyway). Is there any non-intrusive way to detect the issue? |
I guess it would work if we could get a confirmation from the MS Edge team that this will not get fixed in IE11 as Edge has unprefixed the fullscreen API - so it's enough to test if the API works only with the prefix. We'd workaround it only for IE11 and just hope Edge fixes it soon. Thoughts, @dmethvin? |
@mzgol Valid point. Do you have any info regarding this bug for Edge? There actually is one other possibility as pointed out by http://christophercurrie.github.io/technology/2014/03/20/internet-explorer-11-fullscreen-bug.html which is checking if clientWidth / clientHeight are smaller than offsetWidth / offsetHeight. Should I try that approach instead? |
a6d1fa4
to
f9f2891
Compare
@mzgol I have now narrowed down the fix to only kick in if dimensions are obviously wrong (clientrect > offset) |
@AVGP A minor difference in output of these two methods may happen because of fractional values etc. I'd feel safer if you checked that it's much larger, e.g. 99 larger (that's the bug, isn't it?) - maybe not 100x to account for minor differences. Ideally we'd do it via a support test (see https://github.com/jquery/jquery/blob/master/src/css/support.js and how We could cache the result on its first failure but I'm not sure if it's worth it as most people will use the non-fullscreen mode and we couldn't cache the result there. Unfortunately, we have no way of automatically testing it so it will have to stay without a test for now. It's starting to look good! 👍 |
@@ -113,6 +113,14 @@ function getWidthOrHeight( elem, name, extra ) { | |||
styles = getStyles( elem ), | |||
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; | |||
|
|||
// Fix for edge case in IE 11. See https://github.com/jquery/jquery/issues/1764 | |||
if ( window.top !== window.self && document.msFullscreenElement && | |||
elem.getBoundingClientRect().width > elem.offsetWidth ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be the other way round?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, wait a moment. From the description at https://connect.microsoft.com/IE/feedback/details/838286/ie-11-incorrectly-reports-dom-element-sizes-in-fullscreen-mode-when-fullscreened-element-is-within-an-iframe it seems that both values, elem.getBoundingClientRect().width
& elem.offsetWidth
are 100 times too small. Is this test correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I have tested against IE 11 on Windows 7 using the VM that Microsoft provides and found getBoundingClientRect to return correct values, while offsetWidth/offsetHeight returned values 100x smaller (but rounded, so I couldn't just multiply those with 100).
I observed this behaviour consistently throughout my tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a Windows 10 VM around, I'll check if the problem exists in IE11 & Edge and to what extent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I'll be working soon on fixing #1724 so there will be more getBoundingClientRect
around. It would be cool if it was correct in IE11 because this whole workaround wouldn't be needed then. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind! I'm an idiot. I mixed up clientWidth / clientHeight with the bounding rect. Dang! So that check is not going to work :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that's not a big problem. So I'll check if the ratio clientWidth / offsetWidth is larger than 90. But that's a bit of a danger, as somebody might use a giant border...
f9f2891
to
266fd38
Compare
@mzgol Alright, I fixed the detection to use the ratio of clientWidth and offsetWidth and the workaround only becomes effective if that's larger than 90 (as there is some rounding error involved). I don't think using the support.* method and its caching is useful here, it might rather introduce issues me thinks (especially as it's such a nasty edge case). The code works reliably in my IE 11 / Win7 VM, what does your IE 11 / Edge / Win 10 VM say? |
@AVGP I see the issue in IE11 with both |
@mzgol Yup, as I said: I mixed up clientWidth vs. getBoundingRect().width - I fixed that in my latest change. And hooray for Edge! \o/ :rainbow: |
Fortunately, Edge not only supports the unprefixed fullscreen API but it also doesn't support the prefixed one. So if I think comparing with So, judging that we cannot test it reliably I think we could construct a support test like: support.widthReliableInFullscreenMode = 'msFullscreenElement' in document; with a comment about why we don't have a "true" test and then in the code if this value is I'll reach out to MS to make sure they don't intend to fix it in IE11, if that's true I think we're good to go. |
@mzgol Coool! Alright, that makes things much more predictable! Now one last question: shouldn't it be support.widthUnreliableInFullscreenMode = 'msFullscreenElement' in document; so the inverse (check name) as the width is unreliable in fullscreen if we're having the IE 11? |
@mzgol by the way: Thanks for onboarding me so patiently, really appreciate your support 🙇 |
266fd38
to
fc69b37
Compare
I'd prefer to not introduce a negation in the name, it's harder to comprehend what
It's great to have dedicated contributors. :) Pure pleasure. |
fc69b37
to
adcdab0
Compare
@mzgol I went with |
Sounds good. 👍 |
}, | ||
// Support: IE 11 | ||
// IE 11 has a bug with offsetWidth / offsetHeight / getClientBoundingRect() | ||
// in fullscreen mode inside an iframe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd describe what exactly the bug is about and link to the MS Connect bug about it.
adcdab0
to
c8dde6e
Compare
Right; I just having a test in |
@@ -113,6 +113,18 @@ function getWidthOrHeight( elem, name, extra ) { | |||
styles = getStyles( elem ), | |||
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; | |||
|
|||
// Support: IE11+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Support: IE11 only
as there is no IE12 and it's fixed in Edge.
Well, that is two different issues, one is to follow XP covenants and other is to have test for the specific bug. For our predecessors, from the seventies, second, was only one thing that mattered, provided that they tested their software before shipping. |
That was a hint btw :-) |
Right, in summary: I'm lost. I need a short, actionable summary of what I have to do to make this land. @mzgol is going to put one together for me, so stay tuned. P.S.: Data roaming su-ucks! |
1034428
to
fcb4b3f
Compare
@christophercurrie Thanks for the nice, isolated test case :-) |
@AVGP OK, there's one thing needed to finish this PR: remove One other thing is the integration test page but there are a couple of things needed to remember there so I can do it myself in a separate commit and not bother you about it if you want. :) But I'll describe: one should create an HTML page similar to https://github.com/jquery/jquery/blob/compat/test/integration/gh-1684-ajax.html (note that this one is present only in the |
fcb4b3f
to
be824b9
Compare
@mzgol Alright. I reverted the changes and adjusted the condition as desired. I'm not sure if I will give the integration test a shot. It does sound interesting, but I simply don't know if I come around doing it. If you take that upon you, that'd be great - if I have some time, I may give it a go (and will push here for you to see)... whatever gets us this fix landed :-) |
OK, I'll add the test. The rest looks ready. Thanks @AVGP! |
@mzgol Well thanks to you, @markelog, @christophercurrie and @gibson042 for helping me making it this far :) |
@mzgol Thanks for making it so! I'm looking forward to the next release then :-) |
IE 11 used to have an issue where if an element inside an iframe was put in fullscreen mode, the element dimensions started being 100 times too small; we've added a workaround that would multiply them by 100. However, the IE 11 issue has been unexpectedly fixed and since our detection was really detecting the browser and not a bug, we've started breaking the browser instead of fixing it. Since there's no good way to detect if the bug exists, we have to back the workaround out completely. Fixes gh-3041 Refs gh-1764 Refs gh-2401 Refs 90d828b
IE 11 used to have an issue where if an element inside an iframe was put in fullscreen mode, the element dimensions started being 100 times too small; we've added a workaround that would multiply them by 100. However, the IE 11 issue has been unexpectedly fixed and since our detection was really detecting the browser and not a bug, we've started breaking the browser instead of fixing it. Since there's no good way to detect if the bug exists, we have to back the workaround out completely. Refs ff1a082 Fixes gh-3041 Refs gh-1764 Refs gh-2401 Refs 90d828b
IE 11 used to have an issue where if an element inside an iframe was put in fullscreen mode, the element dimensions started being 100 times too small; we've added a workaround that would multiply them by 100. However, the IE 11 issue has been unexpectedly fixed and since our detection was really detecting the browser and not a bug, we've started breaking the browser instead of fixing it. Since there's no good way to detect if the bug exists, we have to back the workaround out completely. Refs ff1a082 Refs fb9adb9 Fixes gh-3041 Refs gh-1764 Refs gh-2401 Refs 90d828b
Fixes #1764