Bug 1368250 - Give the TextControlInitializer property a dtor to automatically call Revoke when the property is deleted. r=mats
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user