Bug 1386582, create element state objects only if needed, r=ehsan
This commit is contained in:
@@ -6410,18 +6410,30 @@ HTMLInputElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission)
|
||||
NS_IMETHODIMP
|
||||
HTMLInputElement::SaveState()
|
||||
{
|
||||
RefPtr<HTMLInputElementState> inputState;
|
||||
nsPresState* state = nullptr;
|
||||
switch (GetValueMode()) {
|
||||
case VALUE_MODE_DEFAULT_ON:
|
||||
if (mCheckedChanged) {
|
||||
inputState = new HTMLInputElementState();
|
||||
state = GetPrimaryPresState();
|
||||
if (!state) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<HTMLInputElementState> inputState = new HTMLInputElementState();
|
||||
inputState->SetChecked(mChecked);
|
||||
state->SetStateProperty(inputState);
|
||||
}
|
||||
break;
|
||||
case VALUE_MODE_FILENAME:
|
||||
if (!mFileData->mFilesOrDirectories.IsEmpty()) {
|
||||
inputState = new HTMLInputElementState();
|
||||
state = GetPrimaryPresState();
|
||||
if (!state) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<HTMLInputElementState> inputState = new HTMLInputElementState();
|
||||
inputState->SetFilesOrDirectories(mFileData->mFilesOrDirectories);
|
||||
state->SetStateProperty(inputState);
|
||||
}
|
||||
break;
|
||||
case VALUE_MODE_VALUE:
|
||||
@@ -6434,7 +6446,12 @@ HTMLInputElement::SaveState()
|
||||
break;
|
||||
}
|
||||
|
||||
inputState = new HTMLInputElementState();
|
||||
state = GetPrimaryPresState();
|
||||
if (!state) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<HTMLInputElementState> inputState = new HTMLInputElementState();
|
||||
nsAutoString value;
|
||||
GetValue(value, CallerType::System);
|
||||
|
||||
@@ -6451,18 +6468,14 @@ HTMLInputElement::SaveState()
|
||||
}
|
||||
|
||||
inputState->SetValue(value);
|
||||
state->SetStateProperty(inputState);
|
||||
break;
|
||||
}
|
||||
|
||||
if (inputState) {
|
||||
nsPresState* state = GetPrimaryPresState();
|
||||
if (state) {
|
||||
state->SetStateProperty(inputState);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDisabledChanged) {
|
||||
nsPresState* state = GetPrimaryPresState();
|
||||
if (!state) {
|
||||
state = GetPrimaryPresState();
|
||||
}
|
||||
if (state) {
|
||||
// We do not want to save the real disabled state but the disabled
|
||||
// attribute.
|
||||
|
||||
Reference in New Issue
Block a user