On Wed Nov 8 23:24:59 2023 +0000, Jacek Caban wrote:
On second thought, what should I do about the document's
get_parentWindow? It's not the same doc (unlike with iframe test), but it still returns the outer window. It already returns outer window AFAICS, so you may just leave it alone. Depending on future of window object, we may forward it to `IHTMLWindow2::get_window` or something along those lines, but I don't see why you want to touch it in this context.
Should I keep a strong ref from the document to the outer window in
doc->outer_window and use it there? Although it won't make much difference than holding it from inner windows, though. No, that would just hide the problem. Ultimately, I think we will want to get rid of it and have only inner window reference in document node (which may be used to get outer window when really needed).
Alternatively, I could keep some sort of weak ref to the outer_window
from the doc, but it would probably require it to be added to a list of detached docs on the outer window (so it knows to detach them when it gets killed). Is that better? If we really need such reference, I think that a weak reference from inner to outer window would be better than document to outer (and yes, it would need a list of orphaned inner windows). But to decide that we really need it, a much deeper look at those problems is needed. So far it seems like it would be just hiding other problems, but I can't be sure. Even if we decide that it's needed, NULL checks would be still needed as well, so it defeats your motivation for the change.
So essentially I add a test that shows get_parentWindow returns the same outer window even after the document (and inner window) is detached, which means we'll need at least a weak ref either from the inner window or the document, or a strong ref but that's a bad idea as you said.
Storing the weak ref in the inner window sounds like a much better idea, thanks. Then I can get rid of `outer_window` from the doc again. I've been doing it with the document and need to clean it up a bit but seems to be mostly fine.
Perhaps I can re-use the base window's outer_window for this? It's already a "weak" ref of sorts (since it can point to itself if it's the outer window), I can just delay NULLing it until it's actually killed, rather than detached. I'll see.