| Summary: | Use Ref and RefPtr pattern when handling document close calls | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Gabriel Nava Marino <gnavamarino> | ||||
| Component: | DOM | Assignee: | Gabriel Nava Marino <gnavamarino> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | cdumez, ews-watchlist, hi, japhet, joepeck, pangle, sam, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Gabriel Nava Marino
2022-04-04 11:12:21 PDT
Created attachment 456594 [details]
Patch
Comment on attachment 456594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=456594&action=review > Source/WebCore/ChangeLog:8 > + Ensure document object remains for the scope of the call. I wonder ifs we should come up with some convention (naming or otherwise) to indicate that a caller is responsible for maintaining an external ref. Like, Document::close_mayDestroy(), or perhaps even take it a step further and require a separate type to call close()? Ref closer = document.closer() closer.close() /* can safely use document as long as closer is in scope */ (In reply to Sam Weinig from comment #2) > Comment on attachment 456594 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=456594&action=review > > > Source/WebCore/ChangeLog:8 > > + Ensure document object remains for the scope of the call. > > I wonder ifs we should come up with some convention (naming or otherwise) to > indicate that a caller is responsible for maintaining an external ref. Like, > Document::close_mayDestroy(), or perhaps even take it a step further and > require a separate type to call close()? > > Ref closer = document.closer() > closer.close() > > /* can safely use document as long as closer is in scope */ I agree this could be executed by explicit calls such above, which themselves could be enforced for example via assertions. I can create a follow-up bug to track this suggestion. (In reply to Gabriel Nava Marino from comment #3) > (In reply to Sam Weinig from comment #2) > > Comment on attachment 456594 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=456594&action=review > > > > > Source/WebCore/ChangeLog:8 > > > + Ensure document object remains for the scope of the call. > > > > I wonder ifs we should come up with some convention (naming or otherwise) to > > indicate that a caller is responsible for maintaining an external ref. Like, > > Document::close_mayDestroy(), or perhaps even take it a step further and > > require a separate type to call close()? > > > > Ref closer = document.closer() > > closer.close() > > > > /* can safely use document as long as closer is in scope */ > > I agree this could be executed by explicit calls such above, which > themselves could be enforced for example via assertions. > > I can create a follow-up bug to track this suggestion. https://bugs.webkit.org/show_bug.cgi?id=238780 Committed r292361 (249226@main): <https://commits.webkit.org/249226@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 456594 [details]. |