Closed Bug 1573823 Opened 7 years ago Closed 5 years ago

nsTypeAheadFind can hold on to a shell pointing to a document which already has another shell, somehow

Categories

(Core :: Find Backend, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1667209

People

(Reporter: emilio, Unassigned)

References

(Blocks 1 open bug)

Details

So nsTypeAheadFind has mPresShell as a weakptr. So if it grabs the presshell and then the document gets a new one (e.g. via reframing of the <iframe>) but the old one hasn't been destroyed yet, we could end up working with it.

We could change nsTypeAheadFind::GetPresShell to do a sanity check and return null if that fails, I guess (like it already does when checking for a prescontext, etc). But fundamentally it seems like it would be slightly better if we held a weakptr to a document and then got a presshell from that. Or even simpler, just removed the mPresShell cache altogether (modulo maybe the use in nsTypeAheadFind::GetSearchContainers that compares it to the selection's presshell) and just reget it from the docshell as needed, which is what we do anyway if GetPresShell() returns null.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #1)

So nsTypeAheadFind has mPresShell as a weakptr. So if it grabs the presshell and then the document gets a new one (e.g. via reframing of the <iframe>) but the old one hasn't been destroyed yet, we could end up working with it.

We could change nsTypeAheadFind::GetPresShell to do a sanity check and return null if that fails, I guess (like it already does when checking for a prescontext, etc). But fundamentally it seems like it would be slightly better if we held a weakptr to a document and then got a presshell from that. Or even simpler, just removed the mPresShell cache altogether (modulo maybe the use in nsTypeAheadFind::GetSearchContainers that compares it to the selection's presshell) and just reget it from the docshell as needed, which is what we do anyway if GetPresShell() returns null.

The issue as far as I understand it is that mDocShell points to the top-level document, while mPresShell may point to that or a subdocument.

But yeah keeping the document pointer as a weak ptr would work I suspect.

Ah, because we can change mPresShell in the GetSearchContainers callers. OK. The other thing we could do is hold a weakref to the docshell that we are currently targeting, since that's where that presshell came from to start with.

The priority flag is not set for this bug.
:mikedeboer, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(mdeboer)

Emilio, does there remain anything left actionable in this bug? Please also note that bug 1553384 landed on autoland just now, which may include changes in the area you're looking at here.

Component: Find Toolbar → Find Backend
Flags: needinfo?(mdeboer) → needinfo?(emilio)
Priority: -- → P3
Product: Toolkit → Core

I think there is, yeah. https://searchfox.org/mozilla-central/search?q=nsTypeAheadFind%3A%3AmPresShell&case=false&regexp=false&path=

I don't know if that stuff is less reachable these days because of that bug though.

Flags: needinfo?(emilio)

I fixed this in bug 1667209.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.