Re: [cssom] What should happen with getComputedStyle on a node in another document when used values are involved?

On 12/10/14, 1:49 AM, 段垚 wrote:
> My test results of getComputedStyle() on a foreign element in 3 desktop
> browsers is as follows:

I think we need to add a few things to the test matrix.  Specifically, 
these may be of interest:

1)  Node is display:none and in an iframe.
2)  Node has a display:none parent and is in an iframe.
3)  Node is in an iframe and the <iframe> element is display:none.
4)  Node's ownerDocument is in an iframe but the node is not "in the
     document" (in that its parentNode chain does not terminate at the
     document node).

I think calling the createHTMLDocument() case "invisible doc" is a bit 
misleading, because it actually has a much stronger constraint on it: 
it's a document which is not in a browsing context at all.  There are 
various cases of "invisible" documents which are in browsing contexts, 
and in fact may well have CSS layout happening in them.

> * Browsers are consistent for visible subdoc (i.e. in a frame). That is,
> parent doc's CSS rules are never considered, and
> getComputedStyle(el_in_frame)
> is equivalent to
> el_in_frame.ownerDocument.defaultView.getComputedStyle(el_in_frame).
> However this behavior conflicts with current CSSOM spec.

Yep.

> * Browsers are inconsistent for invisible subdoc. Firefox's behavior
> seems similar to the one defined spec, but layout is not performed to
> compute used values,

There can't be any layout because there is no browsing context, fwiw. 
Also, per HTML spec style sheets in such a document must not be loaded 
(an <style> elements must not be parsed).  So what IE is doing here just 
doesn't match the HTML spec at all.

>    and inline rules are dropped.

Yeah, the data structure we use for CSS-anything in Gecko just doesn't 
exist in document's without a browsing context.

> Chrome doesn't support getComputedStyle() on invisible subdoc at all.

Here's a question.  If you make that getComputedStyle call, then adopt 
the element into a document that _is_ in a browsing context, what 
happens?  Does it matter whether you insert the element so it's "in the 
document" in the document it was adopted into?

-Boris

Received on Friday, 12 December 2014 03:44:07 UTC