Closed
Bug 795520
Opened 12 years ago
Closed 12 years ago
getComputedStyle returns null inside IFRAME that has no CSS box yet due to lazy restyle processing
Categories
(Core :: DOM: CSS Object Model, defect)
Tracking
()
RESOLVED
FIXED
mozilla19
People
(Reporter: aochider, Assigned: bzbarsky)
Details
Attachments
(3 files, 2 obsolete files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1 Build ID: 20120905151427 Steps to reproduce: The src of an IFRAME has a script that uses the "getComputedStyle" method on an element inside itself. The IFRAME element is itself surrounded by an element that renders it display:none. Actual results: The "getComputedStyle" method returns null. Expected results: The "getComputedStyle" method returns a hashtable of computed styles.
Reporter | ||
Comment 2•12 years ago
|
||
Reporter | ||
Comment 3•12 years ago
|
||
Reporter | ||
Comment 4•12 years ago
|
||
Attachment #666239 -
Attachment is obsolete: true
Reporter | ||
Comment 5•12 years ago
|
||
Attachment #666240 -
Attachment is obsolete: true
Attachment #666241 -
Attachment mime type: text/plain → text/html
Attachment #666242 -
Attachment mime type: text/plain → text/html
Reporter | ||
Comment 6•12 years ago
|
||
This is still an issue in 16
Assignee | ||
Comment 7•12 years ago
|
||
There is no sane way to compute style in a display:none iframe, because styles depend on the size of the frame due to media queries and the frame has no defines size. So anything we actually returned would be a lie that would have no bearing on reality. There are existing reports about this, for what it's worth....
Whiteboard: DUPEME
Assignee | ||
Updated•12 years ago
|
Summary: getComputedStyle inside IFRAME → getComputedStyle returns null inside IFRAME that has no CSS box
Reporter | ||
Comment 8•12 years ago
|
||
Thank you for the explanation. But why does Chrome not have this same issue?
Assignee | ||
Comment 9•12 years ago
|
||
Because it just makes up something that has no bearing on reality and returns it. That happened to be easy to do in their implementation, so they did.
Reporter | ||
Comment 10•12 years ago
|
||
Haha, okay, thanks. I understand the logical problem, but I wanted to file a bug because it can break jQuery's animation methods (which I happen to have to work with at work :( ).
Assignee | ||
Comment 11•12 years ago
|
||
Is this the case when you set display:none on the body and then jQuery's determination of default styles breaks?
Reporter | ||
Comment 12•12 years ago
|
||
Yes, kind of. It is more like this: 1)IFRAME hidden via parent element's class 2)User triggers event somehow 3)IFRAME parent's class removed 4)jQuery animation starts 5)jQuery tries to getComputedStyle but fails 6)Bug is filed at work :( I did some tests and found that getComputedStyle does not take effect until a little bit after the parent's class has been removed.
Assignee | ||
Comment 13•12 years ago
|
||
>3)IFRAME parent's class removed ... >5)jQuery tries to getComputedStyle but fails Ah. _That_ is eminently fixable! That part of the testcase was sadly commented out...
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: CSS Object Model
Ever confirmed: true
Product: Firefox → Core
Summary: getComputedStyle returns null inside IFRAME that has no CSS box → getComputedStyle returns null inside IFRAME that has no CSS box yet due to lazy restyle processing
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → bzbarsky
Whiteboard: DUPEME
Reporter | ||
Comment 14•12 years ago
|
||
Cool, thanks!
Assignee | ||
Comment 15•12 years ago
|
||
from getComputedStyle, even if we have no presshell, then just throw (after flushing, as needed) if people try to get style info for it just like we already do for declarations whose document loses a presshell. This might cause compat issues on sites that can deal with null but not exceptions, though. :(
Attachment #670841 -
Flags: review?(dbaron)
Assignee | ||
Updated•12 years ago
|
Whiteboard: [need review]
Comment on attachment 670841 [details] [diff] [review] Don't fail to return a computed CSS declaration just because the style change that will give us a presshell has not been processed yet. more risky, option would be to always return a declaration r=dbaron
Attachment #670841 -
Flags: review?(dbaron) → review+
Assignee | ||
Comment 17•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/e711e4cdb4d5
Flags: in-testsuite+
Whiteboard: [need review]
Target Milestone: --- → mozilla19
Comment 18•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e711e4cdb4d5
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Comment 19•9 years ago
|
||
I don't believe this is fixed. I'm still able to replicate this (Running 43.0a1 (2015-09-07)). It also looks like this bug was referenced and implied that it wasn't fixed back in 2013 https://www.sencha.com/forum/showthread.php?276869-RightMargin-test-fails-in-Ext.supports&s=86665e3075360b34b20f01d183f38d61
Assignee | ||
Comment 20•9 years ago
|
||
The bug as described in the summary is fixed. The link you mention is talking about a situation in which an iframe is actually display:none all along, not just transiently missing a CSS box. That's a different issue.
Assignee | ||
Comment 21•9 years ago
|
||
And in particular is covered by bug 548397 and bug 1012413.
Comment 22•9 years ago
|
||
That is quite possibly correct. It looks like they were linking the wrong bug in that discussion. I've CC'd myself to the other ones you've mentioned. Thanks.
You need to log in
before you can comment on or make changes to this bug.
Description
•