Bug 1460509 - part 28: Make HTMLEditRules::AdjustWhitespace() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r?m_kato
MozReview-Commit-ID: 6dFP6BYDXMg
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -8632,16 +8632,19 @@ HTMLEditRules::AdjustWhitespace()
EditorBase::GetStartPoint(&SelectionRef()));
if (NS_WARN_IF(!selectionStartPoint.IsSet())) {
return NS_ERROR_FAILURE;
}
// Ask whitespace object to tweak nbsp's
nsresult rv =
WSRunObject(&HTMLEditorRef(), selectionStartPoint).AdjustWhitespace();
+ if (NS_WARN_IF(!CanHandleEditAction())) {
+ return NS_ERROR_EDITOR_DESTROYED;
+ }
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
nsresult
HTMLEditRules::PinSelectionToNewBlock()
--- a/editor/libeditor/HTMLEditRules.h
+++ b/editor/libeditor/HTMLEditRules.h
@@ -589,17 +589,22 @@ protected:
* @param aListElement A <ul>, <ol> or <dl> element.
*/
MOZ_MUST_USE nsresult RemoveListStructure(Element& aListElement);
nsresult CacheInlineStyles(nsINode* aNode);
nsresult ReapplyCachedStyles();
void ClearCachedStyles();
void AdjustSpecialBreaks();
- nsresult AdjustWhitespace();
+
+ /**
+ * AdjustWhitespace() may replace whitespaces with NBSP or something.
+ * See WSRunObject::AdjustWhitespace() for the detail.
+ */
+ MOZ_MUST_USE nsresult AdjustWhitespace();
/**
* PinSelectionToNewBlock() may collapse Selection around mNewNode if it's
* necessary,
*/
MOZ_MUST_USE nsresult PinSelectionToNewBlock();
void CheckInterlinePosition();