From 5c4be41f42c239d9977993674f66fc032b719221 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 14 May 2018 23:20:28 +0900 Subject: [PATCH] Bug 1460509 - part 31: Make HTMLEditRules::GetInlineStyles() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r=m_kato MozReview-Commit-ID: 3Nk1gBttuwM --HG-- extra : rebase_source : b9e0d63683407d9e5440157309cb61d213524223 --- editor/libeditor/HTMLEditRules.cpp | 5 ++++- editor/libeditor/HTMLEditRules.h | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 7e82889268f2..8dd108493bf4 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -8516,6 +8516,9 @@ HTMLEditRules::GetInlineStyles(nsINode* aNode, isSet = CSSEditUtils::IsCSSEquivalentToHTMLInlineStyleSet( aNode, aStyleCache[j].tag, aStyleCache[j].attr, outValue, CSSEditUtils::eComputed); + if (NS_WARN_IF(!CanHandleEditAction())) { + return NS_ERROR_EDITOR_DESTROYED; + } } if (isSet) { aStyleCache[j].mPresent = true; @@ -8556,7 +8559,7 @@ HTMLEditRules::ReapplyCachedStyles() InitStyleCacheArray(styleAtInsertionPoint); nsresult rv = GetInlineStyles(selNode, styleAtInsertionPoint); if (NS_WARN_IF(NS_FAILED(rv))) { - return NS_OK; + return rv == NS_ERROR_EDITOR_DESTROYED ? NS_ERROR_EDITOR_DESTROYED : NS_OK; } for (size_t i = 0; i < SIZE_STYLE_TABLE; ++i) { diff --git a/editor/libeditor/HTMLEditRules.h b/editor/libeditor/HTMLEditRules.h index f508d687d81d..c5f26e75e5cd 100644 --- a/editor/libeditor/HTMLEditRules.h +++ b/editor/libeditor/HTMLEditRules.h @@ -778,10 +778,11 @@ protected: /** * GetInlineStyles() retrieves the style of aNode and modifies each item of - * aStyleCache. + * aStyleCache. This might cause flushing layout at retrieving computed + * values of CSS properties. */ - nsresult GetInlineStyles(nsINode* aNode, - StyleCache aStyleCache[SIZE_STYLE_TABLE]); + MOZ_MUST_USE nsresult + GetInlineStyles(nsINode* aNode, StyleCache aStyleCache[SIZE_STYLE_TABLE]); protected: HTMLEditor* mHTMLEditor;