Bug 1597679 - part 3: Create methods to compare given string with values of TextControlState, nsTextControlFrame, HTMLInputElement and HTMLTextAreaElement r=smaug

For avoiding unnecessary copy of string buffer only for comparing setting
value and current value, especially with `nsAutoString`, this patch
creates `*Equals()` methods for every class.

And also this avoids to call `nsContentUtils::PlatformToDOMLineBreaks()` in
most paths.

Differential Revision: https://phabricator.services.mozilla.com/D54331
This commit is contained in:
Masayuki Nakano
2019-11-25 06:35:17 +00:00
parent 16fa2f8998
commit f93c719628
8 changed files with 125 additions and 40 deletions

View File

@@ -6756,6 +6756,11 @@ void HTMLInputElement::GetTextEditorValue(nsAString& aValue,
}
}
bool HTMLInputElement::TextEditorValueEquals(const nsAString& aValue) const {
TextControlState* state = GetEditorState();
return state ? state->ValueEquals(aValue) : aValue.IsEmpty();
}
void HTMLInputElement::InitializeKeyboardEventListeners() {
TextControlState* state = GetEditorState();
if (state) {