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 #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 07:43:03 -04:00 committed by Roy Tam
commit a6f048fc42
7 changed files with 33 additions and 18 deletions

View file

@ -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);
}