Bug 1366218 - Use fast path to check empty value. r?smaug
HTMLInputElement::IsValueEmpty uses DocumentEncoder when input element has focus. DocumentEncoder is slow, so we should use fast path (nsTextEditorState::HasNonEmptyValue) to check whether value is empty.
MozReview-Commit-ID: 1JxAeZ6z5A4
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -1783,16 +1783,20 @@ HTMLInputElement::GetNonFileValueInterna
}
return;
}
}
bool
HTMLInputElement::IsValueEmpty() const
{
+ if (GetValueMode() == VALUE_MODE_VALUE && IsSingleLineTextControl(false)) {
+ return !mInputData.mState->HasNonEmptyValue();
+ }
+
nsAutoString value;
GetNonFileValueInternal(value);
return value.IsEmpty();
}
void
HTMLInputElement::ClearFiles(bool aSetValueChanged)