mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 848895 part 1. Always hold an on-stack strong reference to mRules when calling into it. r=ehsan
This commit is contained in:
parent
9150701b0b
commit
d1287439d0
@ -72,6 +72,8 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
|
||||
nsTextRulesInfo ruleInfo(aEnabled ? EditAction::setAbsolutePosition :
|
||||
EditAction::removeAbsolutePosition);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (NS_FAILED(res) || cancel)
|
||||
return res;
|
||||
@ -184,6 +186,8 @@ nsHTMLEditor::RelativeChangeZIndex(int32_t aChange)
|
||||
nsTextRulesInfo ruleInfo(aChange < 0 ? EditAction::decreaseZIndex :
|
||||
EditAction::increaseZIndex);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || NS_FAILED(res))
|
||||
return res;
|
||||
@ -560,7 +564,7 @@ nsHTMLEditor::AbsolutelyPositionElement(nsIDOMElement * aElement,
|
||||
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(aElement);
|
||||
if (element && element->IsHTML(nsGkAtoms::div) && !HasStyleOrIdOrClass(element)) {
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsresult res = htmlRules->MakeSureElemStartsOrEndsOnCR(aElement);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
@ -152,6 +152,8 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
|
||||
|
||||
nsTextRulesInfo ruleInfo(EditAction::loadHTML);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel) {
|
||||
@ -1702,6 +1704,8 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
|
||||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(EditAction::insertElement);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
@ -1906,6 +1910,8 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
||||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(EditAction::insertElement);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
@ -1999,6 +2005,8 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
||||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(EditAction::insertElement);
|
||||
bool cancel, handled;
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
|
@ -1721,8 +1721,7 @@ nsHTMLEditor::GetParagraphState(bool *aMixed, nsAString &outFormat)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
return htmlRules->GetParagraphState(aMixed, outFormat);
|
||||
}
|
||||
@ -1912,8 +1911,7 @@ nsHTMLEditor::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aOL && aUL && aDL, NS_ERROR_NULL_POINTER);
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
return htmlRules->GetListState(aMixed, aOL, aUL, aDL);
|
||||
}
|
||||
@ -1924,8 +1922,7 @@ nsHTMLEditor::GetListItemState(bool *aMixed, bool *aLI, bool *aDT, bool *aDD)
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aLI && aDT && aDD, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
return htmlRules->GetListItemState(aMixed, aLI, aDT, aDD);
|
||||
}
|
||||
@ -1935,8 +1932,7 @@ nsHTMLEditor::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
|
||||
{
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aMixed && aAlign, NS_ERROR_NULL_POINTER);
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
return htmlRules->GetAlignment(aMixed, aAlign);
|
||||
}
|
||||
@ -1948,8 +1944,7 @@ nsHTMLEditor::GetIndentState(bool *aCanIndent, bool *aCanOutdent)
|
||||
if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }
|
||||
NS_ENSURE_TRUE(aCanIndent && aCanOutdent, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsHTMLEditRules* htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
NS_ENSURE_TRUE(htmlRules, NS_ERROR_FAILURE);
|
||||
nsRefPtr<nsHTMLEditRules> htmlRules = static_cast<nsHTMLEditRules*>(mRules.get());
|
||||
|
||||
return htmlRules->GetIndentState(aCanIndent, aCanOutdent);
|
||||
}
|
||||
@ -3249,6 +3244,8 @@ nsHTMLEditor::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
// Ignore insertion of the bogus node
|
||||
return;
|
||||
}
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
mRules->DocumentModified();
|
||||
|
||||
// Update spellcheck for only the newly-inserted node (bug 743819)
|
||||
@ -3280,6 +3277,8 @@ nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
|
||||
// Ignore removal of the bogus node
|
||||
return;
|
||||
}
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
mRules->DocumentModified();
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,8 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
||||
|
||||
bool cancel, handled;
|
||||
nsTextRulesInfo ruleInfo(EditAction::setTextProperty);
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled) {
|
||||
@ -1354,6 +1356,8 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
||||
|
||||
bool cancel, handled;
|
||||
nsTextRulesInfo ruleInfo(EditAction::removeTextProperty);
|
||||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled)
|
||||
|
Loading…
Reference in New Issue
Block a user