From 6d76ab9b6c19d0829c343e1bc3cd7865221d64ba Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:43:03 -0400 Subject: 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 --- dom/html/nsTextEditorState.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dom/html/nsTextEditorState.cpp') diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 25be6016c..812a8d0b6 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -2214,6 +2214,23 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags) return true; } +bool +nsTextEditorState::HasNonEmptyValue() +{ + if (mEditor && mBoundFrame && mEditorInitialized && + !mIsCommittingComposition) { + bool empty; + nsresult rv = mEditor->GetDocumentIsEmpty(&empty); + if (NS_SUCCEEDED(rv)) { + return !empty; + } + } + + nsAutoString value; + GetValue(value, true); + return !value.IsEmpty(); +} + void nsTextEditorState::InitializeKeyboardEventListeners() { -- cgit v1.2.3