Bug 1850645 - Make TextControlState use nsAutoString r=smaug
Currently, the type of `AutoTextControlHandlingState::mSettingValue` is `nsString`, but it's a stack only class, and if the string buffer is refcountable, `nsTAutoStringN(const substring_type&)` avoid copying the memory anyway. https://searchfox.org/mozilla-central/rev/fccd8c0ac998c4c624b6c255e621d36f72cabe01/xpcom/string/nsTString.h#295 https://searchfox.org/mozilla-central/rev/fccd8c0ac998c4c624b6c255e621d36f72cabe01/xpcom/string/nsTSubstring.cpp#504,513-514,517 So, it should be `nsAutoString` in any cases. Therefore, this patch changes the type and fix similar points in `TextControlState.cpp`. Differential Revision: https://phabricator.services.mozilla.com/D188682
This commit is contained in:
@@ -1372,7 +1372,7 @@ class MOZ_STACK_CLASS AutoTextControlHandlingState {
|
||||
// mTextInputListener grabs TextControlState::mTextListener because if
|
||||
// TextControlState is unbind from the frame, it's released.
|
||||
RefPtr<TextInputListener> const mTextInputListener;
|
||||
nsString mSettingValue;
|
||||
nsAutoString mSettingValue;
|
||||
const nsAString* mOldValue = nullptr;
|
||||
ValueSetterOptions mValueSetterOptions;
|
||||
TextControlAction const mTextControlAction;
|
||||
@@ -2544,9 +2544,7 @@ void TextControlState::GetValue(nsAString& aValue, bool aIgnoreWrap,
|
||||
}
|
||||
|
||||
bool TextControlState::ValueEquals(const nsAString& aValue) const {
|
||||
// We can avoid copying string buffer in many cases. Therefore, we should
|
||||
// use nsString rather than nsAutoString here.
|
||||
nsString value;
|
||||
nsAutoString value;
|
||||
GetValue(value, true, /* aForDisplay = */ true);
|
||||
return aValue.Equals(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user