mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
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:
parent
b8260c664a
commit
a6f048fc42
7 changed files with 33 additions and 18 deletions
|
|
@ -2214,6 +2214,23 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
|
||||||
return true;
|
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
|
void
|
||||||
nsTextEditorState::InitializeKeyboardEventListeners()
|
nsTextEditorState::InitializeKeyboardEventListeners()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,11 @@ public:
|
||||||
};
|
};
|
||||||
MOZ_MUST_USE bool SetValue(const nsAString& aValue, uint32_t aFlags);
|
MOZ_MUST_USE bool SetValue(const nsAString& aValue, uint32_t aFlags);
|
||||||
void GetValue(nsAString& aValue, bool aIgnoreWrap) const;
|
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(); }
|
void EmptyValue() { if (mValue) mValue->Truncate(); }
|
||||||
bool IsEmpty() const { return mValue ? mValue->IsEmpty() : true; }
|
bool IsEmpty() const { return mValue ? mValue->IsEmpty() : true; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3530,15 +3530,11 @@ HTMLEditor::SelectEntireDocument(Selection* aSelection)
|
||||||
// Protect the edit rules object from dying
|
// Protect the edit rules object from dying
|
||||||
nsCOMPtr<nsIEditRules> rules(mRules);
|
nsCOMPtr<nsIEditRules> rules(mRules);
|
||||||
|
|
||||||
// get editor root node
|
|
||||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
|
||||||
|
|
||||||
// is doc empty?
|
// is doc empty?
|
||||||
bool bDocIsEmpty;
|
if (rules->DocumentIsEmpty()) {
|
||||||
nsresult rv = rules->DocumentIsEmpty(&bDocIsEmpty);
|
// get editor root node
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
Element* rootElement = GetRoot();
|
||||||
|
|
||||||
if (bDocIsEmpty) {
|
|
||||||
// if its empty dont select entire doc - that would select the bogus node
|
// if its empty dont select entire doc - that would select the bogus node
|
||||||
return aSelection->Collapse(rootElement, 0);
|
return aSelection->Collapse(rootElement, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,13 +329,10 @@ TextEditRules::DidDoAction(Selection* aSelection,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP_(bool)
|
||||||
TextEditRules::DocumentIsEmpty(bool* aDocumentIsEmpty)
|
TextEditRules::DocumentIsEmpty()
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(aDocumentIsEmpty, NS_ERROR_NULL_POINTER);
|
return (mBogusNode != nullptr);
|
||||||
|
|
||||||
*aDocumentIsEmpty = (mBogusNode != nullptr);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
bool* aCancel, bool* aHandled) override;
|
bool* aCancel, bool* aHandled) override;
|
||||||
NS_IMETHOD DidDoAction(Selection* aSelection, RulesInfo* aInfo,
|
NS_IMETHOD DidDoAction(Selection* aSelection, RulesInfo* aInfo,
|
||||||
nsresult aResult) override;
|
nsresult aResult) override;
|
||||||
NS_IMETHOD DocumentIsEmpty(bool* aDocumentIsEmpty) override;
|
NS_IMETHOD_(bool) DocumentIsEmpty() override;
|
||||||
NS_IMETHOD DocumentModified() override;
|
NS_IMETHOD DocumentModified() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -913,7 +913,8 @@ TextEditor::GetDocumentIsEmpty(bool* aDocumentIsEmpty)
|
||||||
// Protect the edit rules object from dying
|
// Protect the edit rules object from dying
|
||||||
nsCOMPtr<nsIEditRules> rules(mRules);
|
nsCOMPtr<nsIEditRules> rules(mRules);
|
||||||
|
|
||||||
return rules->DocumentIsEmpty(aDocumentIsEmpty);
|
*aDocumentIsEmpty = rules->DocumentIsEmpty();
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -1580,8 +1581,7 @@ TextEditor::SelectEntireDocument(Selection* aSelection)
|
||||||
nsCOMPtr<nsIEditRules> rules(mRules);
|
nsCOMPtr<nsIEditRules> rules(mRules);
|
||||||
|
|
||||||
// is doc empty?
|
// is doc empty?
|
||||||
bool bDocIsEmpty;
|
if (rules->DocumentIsEmpty()) {
|
||||||
if (NS_SUCCEEDED(rules->DocumentIsEmpty(&bDocIsEmpty)) && bDocIsEmpty) {
|
|
||||||
// get root node
|
// get root node
|
||||||
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
|
||||||
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
bool* aHandled) = 0;
|
bool* aHandled) = 0;
|
||||||
NS_IMETHOD DidDoAction(mozilla::dom::Selection* aSelection,
|
NS_IMETHOD DidDoAction(mozilla::dom::Selection* aSelection,
|
||||||
mozilla::RulesInfo* aInfo, nsresult aResult) = 0;
|
mozilla::RulesInfo* aInfo, nsresult aResult) = 0;
|
||||||
NS_IMETHOD DocumentIsEmpty(bool* aDocumentIsEmpty) = 0;
|
NS_IMETHOD_(bool) DocumentIsEmpty() = 0;
|
||||||
NS_IMETHOD DocumentModified() = 0;
|
NS_IMETHOD DocumentModified() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue