Bug 1366218 - Use fast path to check empty value. r=smaug
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 23 May 2017 12:27:23 +0900
changeset 360320 ffaa07672466b06cd748b07a34cf95377afdde41
parent 360319 78ca9145472c444090b94e2cb6cf1d92ee6857ab
child 360344 291a11111bdd05c5cd55dd552da4b1285ceba9b2
child 360355 9c23bf9c0eff3730ba39c8b1cda053886b86beb1
push id31873
push userarchaeopteryx@coole-files.de
push dateWed, 24 May 2017 09:23:57 +0000
treeherdermozilla-central@ffaa07672466 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1366218
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/html/HTMLInputElement.cpp
--- 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)