summaryrefslogtreecommitdiffstats
path: root/dom/html
diff options
context:
space:
mode:
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; }