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

@@ -250,6 +250,13 @@ class HTMLInputElement final : public TextControlElement,
const nsAString& aValue) override;
virtual bool HasCachedSelection() override;
/**
* TextEditorValueEquals() is designed for internal use so that aValue
* shouldn't include \r character. It should be handled before calling this
* with nsContentUtils::PlatformToDOMLineBreaks().
*/
bool TextEditorValueEquals(const nsAString& aValue) const;
// Methods for nsFormFillController so it can do selection operations on input
// types the HTML spec doesn't support them on, like "email".
uint32_t GetSelectionStartIgnoringType(ErrorResult& aRv);