summaryrefslogtreecommitdiffstats
path: root/dom/html
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
commit6d76ab9b6c19d0829c343e1bc3cd7865221d64ba (patch)
treef664dfac761bd71fdccf73d4d3d76abb87b2adef /dom/html
parent9e5e58c0f6e1c65674cc688816f387532661d6f1 (diff)
downloadUXP-6d76ab9b6c19d0829c343e1bc3cd7865221d64ba.tar
UXP-6d76ab9b6c19d0829c343e1bc3cd7865221d64ba.tar.gz
UXP-6d76ab9b6c19d0829c343e1bc3cd7865221d64ba.tar.lz
UXP-6d76ab9b6c19d0829c343e1bc3cd7865221d64ba.tar.xz
UXP-6d76ab9b6c19d0829c343e1bc3cd7865221d64ba.zip
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
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/nsTextEditorState.cpp17
-rw-r--r--dom/html/nsTextEditorState.h5
2 files changed, 22 insertions, 0 deletions
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()
{
diff --git a/dom/html/nsTextEditorState.h b/dom/html/nsTextEditorState.h
index caf5e8eed..77d12e81a 100644
--- a/dom/html/nsTextEditorState.h
+++ b/dom/html/nsTextEditorState.h
@@ -157,6 +157,11 @@ public:
};
MOZ_MUST_USE bool SetValue(const nsAString& aValue, uint32_t aFlags);
void GetValue(nsAString& aValue, bool aIgnoreWrap) const;
+ bool HasNonEmptyValue();
+ // The following methods are for textarea element to use whether default
+ // value or not.
+ // XXX We might have to add assertion when it is into editable,
+ // or reconsider fixing bug 597525 to remove these.
void EmptyValue() { if (mValue) mValue->Truncate(); }
bool IsEmpty() const { return mValue ? mValue->IsEmpty() : true; }