Something smells off with IsUnstyledDocument, IsLoadedAsData and IsLoadedAsInteractiveData




3 years ago
9 days ago


(Reporter: jwatt, Unassigned)


Firefox Tracking Flags

(Not tracked)




3 years ago
IsLoadedAsData and IsLoadedAsInteractiveData are undocumented, which makes their meaning unclear. When I added IsUnstyledDocument in bug 1008455 I made it return true if either of these methods return true since that seemed correct for "data" documents. I've since noticed that IsLoadedAsInteractiveData seems to be quite misleadingly named though, so I'm not sure IsUnstyledDocument is doing the right thing.

Digging into IsLoadedAsInteractiveData it seems like this is set for XBL bindings documents (it came into existance way back in bug 172372). For documents for which it returns true:

 * nsDocument::GetAnimationController() returns null

 * clone->SetFlags(NODE_FORCE_XBL_BINDINGS) will not be called in
   nsNodeUtils::CloneAndAdopt when cloning a XUL element to be a
   child of some other element

 * XMLDocument::StartDocumentLoad passes "loadAsData" to
   nsParser::SetCommand which prevents the parser loading <link>
   style sheets (nsXMLContentSink::ProcessStyleLink returns early)

 * XMLDocument::EndLoad sets mSynchronousDOMContentLoaded to true

Note that a document's nsScriptLoader and css::Loader are _not_ disabled, since XMLDocument::StartDocumentLoad passes "loadAsInteractiveData" to nsDocument::StartDocumentLoad _before_ changing |aCommand| to "loadAsData" for passing off to the parser. 

So I'm not sure to what extent documents that return true from IsLoadedAsInteractiveData are actually "data" documents. They seem much more like normal documents with a few XBL binding specific quirks. Even the bit where <link> style sheets are prevented seems suspect, since the XBL bindings document is still allowed and - according to bug 172372 - must be able to load style and script in other ways.
The idea is that IsLoadedAsInteractiveData should prevent anonymous content from doing random loads in the context of that document.  That is, if your binding template has an <img> in it, we should NOT load that <img> in the XBL document.  It should get loaded once the binding actually gets instantiated into the bound document.  This also applies to <script src>, <link href> etc.

I'm happy to rename IsLoadedAsInteractiveData as needed....
What are we going to do here, if anything?
Flags: needinfo?(jwatt)

Comment 3

9 months ago
(In reply to Andrew Overholt [:overholt] from comment #2)
> What are we going to do here, if anything?

I'd really like to see some documentation added to these two methods. Their meaning, finer details and how they differ are far from obvious to someone like me who sometimes has to deal with them, but not often enough to recall the details each time that happens.
Flags: needinfo?(jwatt)


9 months ago
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Product: Core → Core
You need to log in before you can comment on or make changes to this bug.