summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:43:03 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:43:03 -0400
commiteb1e5950cdbb235b117a3b1e21596072a86d579d (patch)
treef664dfac761bd71fdccf73d4d3d76abb87b2adef /editor
parentbea6ef77ad25e5fd1b2f30210f22ecdb1ebd2e0d (diff)
downloadaura-central-eb1e5950cdbb235b117a3b1e21596072a86d579d.tar.gz
Bug 1360154 - nsIPlaintextEditor might have to have hasText property for UpdateOverlayTextVisibility
* DocumentIsBody should return bool, not nsresult * Add fast path to check whether valus is emtpy Tag mcp-graveyard/UXP%1375
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/HTMLEditor.cpp10
-rw-r--r--editor/libeditor/TextEditRules.cpp9
-rw-r--r--editor/libeditor/TextEditRules.h2
-rw-r--r--editor/libeditor/TextEditor.cpp6
-rw-r--r--editor/libeditor/nsIEditRules.h2
5 files changed, 11 insertions, 18 deletions
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 04a710cde..c2f0bdc6d 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3530,15 +3530,11 @@ HTMLEditor::SelectEntireDocument(Selection* aSelection)
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> rules(mRules);
- // get editor root node
- nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
-
// is doc empty?
- bool bDocIsEmpty;
- nsresult rv = rules->DocumentIsEmpty(&bDocIsEmpty);
- NS_ENSURE_SUCCESS(rv, rv);
+ if (rules->DocumentIsEmpty()) {
+ // get editor root node
+ Element* rootElement = GetRoot();
- if (bDocIsEmpty) {
// if its empty dont select entire doc - that would select the bogus node
return aSelection->Collapse(rootElement, 0);
}
diff --git a/editor/libeditor/TextEditRules.cpp b/editor/libeditor/TextEditRules.cpp
index 8f8f34e8b..35d4a2f3d 100644
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -329,13 +329,10 @@ TextEditRules::DidDoAction(Selection* aSelection,
}
}
-NS_IMETHODIMP
-TextEditRules::DocumentIsEmpty(bool* aDocumentIsEmpty)
+NS_IMETHODIMP_(bool)
+TextEditRules::DocumentIsEmpty()
{
- NS_ENSURE_TRUE(aDocumentIsEmpty, NS_ERROR_NULL_POINTER);
-
- *aDocumentIsEmpty = (mBogusNode != nullptr);
- return NS_OK;
+ return (mBogusNode != nullptr);
}
void
diff --git a/editor/libeditor/TextEditRules.h b/editor/libeditor/TextEditRules.h
index 6d4915f15..208e14d23 100644
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -66,7 +66,7 @@ public:
bool* aCancel, bool* aHandled) override;
NS_IMETHOD DidDoAction(Selection* aSelection, RulesInfo* aInfo,
nsresult aResult) override;
- NS_IMETHOD DocumentIsEmpty(bool* aDocumentIsEmpty) override;
+ NS_IMETHOD_(bool) DocumentIsEmpty() override;
NS_IMETHOD DocumentModified() override;
protected:
diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp
index 9d07c198b..c3cfa4a72 100644
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -913,7 +913,8 @@ TextEditor::GetDocumentIsEmpty(bool* aDocumentIsEmpty)
// Protect the edit rules object from dying
nsCOMPtr<nsIEditRules> rules(mRules);
- return rules->DocumentIsEmpty(aDocumentIsEmpty);
+ *aDocumentIsEmpty = rules->DocumentIsEmpty();
+ return NS_OK;
}
NS_IMETHODIMP
@@ -1580,8 +1581,7 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
nsCOMPtr<nsIEditRules> rules(mRules);
// is doc empty?
- bool bDocIsEmpty;
- if (NS_SUCCEEDED(rules->DocumentIsEmpty(&bDocIsEmpty)) && bDocIsEmpty) {
+ if (rules->DocumentIsEmpty()) {
// get root node
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
diff --git a/editor/libeditor/nsIEditRules.h b/editor/libeditor/nsIEditRules.h
index b186895ae..a493145cc 100644
--- a/editor/libeditor/nsIEditRules.h
+++ b/editor/libeditor/nsIEditRules.h
@@ -59,7 +59,7 @@ public:
bool* aHandled) = 0;
NS_IMETHOD DidDoAction(mozilla::dom::Selection* aSelection,
mozilla::RulesInfo* aInfo, nsresult aResult) = 0;
- NS_IMETHOD DocumentIsEmpty(bool* aDocumentIsEmpty) = 0;
+ NS_IMETHOD_(bool) DocumentIsEmpty() = 0;
NS_IMETHOD DocumentModified() = 0;
};