Re: getComputedStyle - Why window member function?

Martin Honnen <[email protected]> Fri, 11 Feb 2011 14:45:50 +0100
Newsgroups gmane.comp.mozilla.devel.dom
Organization Liberty Development
Message-ID <[email protected]>
Neil Deakin wrote:
> On 11/02/11 5:37 AM, Axel Dahmen wrote:
>> Because styles are not a window's property but a document's property. It
>> wouldn't come up my mind to search in the cupboard for motor oil,
>> either. That's why.
> 
> I think the original intent was that a document might be presented in
> multiple ways. For instance, Firefox used to (theoretically) support
> displaying the same document in both regular and print preview mode at
> the same time. One document, but different styles used for each mode.
> 
> Some implementation might also want to replicate that, which is why
> getComputedStyle is defined on a 'view' rather than on a document.

And you can have a pure in memory DOM document that is not rendered
anywhere, like an responseXML document or one created from DOMParser or
one created with document.implementation.createDocument. As computing
styles on such documents does not make much sense I think the
document.defaultView
(http://www.w3.org/TR/DOM-Level-2-Views/views.html#Views-AbstractView)
was introduced and that is null for documents like I listed above. For
rendered documents implementors mapped document.defaultView to the
window object. I don't know whether that was the intention of the
authors of the "Document Object Model Views" spec. But it certainly make
sense not to have getComputedStyle exposed on all kind of documents.

-- 

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

_______________________________________________
dev-tech-dom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-dom