mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1132499 - part 2 - convert nsTextEditorState::mValue to be an nsString; r=ehsan
I don't know the full history here; roc asked about this exact thing in bug 534785 when reviewing the creation of nsTextEditorState. The answer then was "historical reasons" (the original code is hg@1)...maybe to try and save some space? Regardless, since the only thing we do here is convert from/to incoming/outgoing nsStrings, which at least sometimes appear to be causing OOMs, we might as well hold it as an nsString all the time. This change will ideally eliminate allocations, as we'll be able to use nsString's buffer sharing underneath the hood.
This commit is contained in:
parent
f0c8d767c9
commit
64fe772d2f
@ -1918,7 +1918,7 @@ nsTextEditorState::GetValue(nsAString& aValue, bool aIgnoreWrap) const
|
||||
if (!mTextCtrlElement->ValueChanged() || !mValue) {
|
||||
mTextCtrlElement->GetDefaultValueFromContent(aValue);
|
||||
} else {
|
||||
aValue = NS_ConvertUTF8toUTF16(*mValue);
|
||||
aValue = *mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2148,7 +2148,7 @@ nsTextEditorState::SetValue(const nsAString& aValue, uint32_t aFlags)
|
||||
if (!nsContentUtils::PlatformToDOMLineBreaks(value, fallible)) {
|
||||
return false;
|
||||
}
|
||||
if (!CopyUTF16toUTF8(value, *mValue, fallible)) {
|
||||
if (!mValue->Assign(value, fallible)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ private:
|
||||
nsCOMPtr<mozilla::dom::Element> mPlaceholderDiv;
|
||||
nsTextControlFrame* mBoundFrame;
|
||||
RefPtr<nsTextInputListener> mTextListener;
|
||||
mozilla::Maybe<nsCString> mValue;
|
||||
mozilla::Maybe<nsString> mValue;
|
||||
RefPtr<nsAnonDivObserver> mMutationObserver;
|
||||
mutable nsString mCachedValue; // Caches non-hard-wrapped value on a multiline control.
|
||||
// mValueBeingSet is available only while SetValue() is requesting to commit
|
||||
|
Loading…
Reference in New Issue
Block a user