Bug 1368250 - Give the TextControlInitializer property a dtor to automatically call Revoke when the property is deleted. r=mats

This commit is contained in:
Jonathan Kew
2017-05-28 11:22:29 +01:00
parent 8041f82d00
commit 3f425bcdc3
2 changed files with 11 additions and 14 deletions

View File

@@ -124,11 +124,7 @@ nsTextControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
mScrollEvent.Revoke();
EditorInitializer* initializer = GetProperty(TextControlInitializer());
if (initializer) {
initializer->Revoke();
DeleteProperty(TextControlInitializer());
}
DeleteProperty(TextControlInitializer());
// Unbind the text editor state object from the frame. The editor will live
// on, but things like controllers will be released.
@@ -394,12 +390,8 @@ nsTextControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
if (initEagerly) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Someone forgot a script blocker?");
EditorInitializer* initializer = GetProperty(TextControlInitializer());
if (initializer) {
initializer->Revoke();
}
initializer = new EditorInitializer(this);
SetProperty(TextControlInitializer(),initializer);
EditorInitializer* initializer = new EditorInitializer(this);
SetProperty(TextControlInitializer(), initializer);
nsContentUtils::AddScriptRunner(initializer);
}

View File

@@ -222,9 +222,14 @@ protected:
friend class nsTextEditorState; // needs access to UpdateValueDisplay
// Temp reference to scriptrunner
// We could make these auto-Revoking via the "delete" entry for safety
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(TextControlInitializer,
EditorInitializer)
NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(TextControlInitializer,
EditorInitializer,
nsTextControlFrame::RevokeInitializer)
static void
RevokeInitializer(EditorInitializer* aInitializer) {
aInitializer->Revoke();
};
class EditorInitializer : public mozilla::Runnable {
public: