ListAttributeTargetObserver is needlessly created even when there is no list attribute
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jul 2021 22:48:18 +0000 (22:48 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Jul 2021 22:48:18 +0000 (22:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=228541

Reviewed by Yusuke Suzuki.

No new tests because no behavior change.

This is possibly a small improvement (~0.5%) on Speedometer subtests that do innerHTML, but not statistically significant.

Ported from a Chromium change by Adithya Srinivasan

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::resetListAttributeTargetObserver): check if there's a list attribute before making an observer.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280521 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLInputElement.cpp

index cab5e1571093e231448688ddaf53238a7ccdbcab..df5daa74b3479a14bf813d7d7b9889cf9a9806ab 100644 (file)
@@ -1,3 +1,19 @@
+2021-07-31  Maciej Stachowiak  <mjs@apple.com>
+
+        ListAttributeTargetObserver is needlessly created even when there is no list attribute
+        https://bugs.webkit.org/show_bug.cgi?id=228541
+
+        Reviewed by Yusuke Suzuki.
+
+        No new tests because no behavior change.
+
+        This is possibly a small improvement (~0.5%) on Speedometer subtests that do innerHTML, but not statistically significant.
+
+        Ported from a Chromium change by Adithya Srinivasan
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::resetListAttributeTargetObserver): check if there's a list attribute before making an observer.
+
 2021-07-31  Youenn Fablet  <youenn@apple.com>
 
         Improve LocalSampleBufferDisplayLayer logging
index f52f92f0c030c1b73f670229f6c2bff7fcb6edb6..9312d9b76b9fd2e6a9bb977c73dcbfab6a6a13ce 100644 (file)
@@ -1682,10 +1682,14 @@ RefPtr<HTMLDataListElement> HTMLInputElement::dataList() const
 
 void HTMLInputElement::resetListAttributeTargetObserver()
 {
-    if (isConnected())
-        m_listAttributeTargetObserver = makeUnique<ListAttributeTargetObserver>(attributeWithoutSynchronization(listAttr), this);
-    else
-        m_listAttributeTargetObserver = nullptr;
+    if (isConnected()) {
+        if (auto& listAttrValue = attributeWithoutSynchronization(listAttr); !listAttrValue.isNull()) {
+            m_listAttributeTargetObserver = makeUnique<ListAttributeTargetObserver>(listAttrValue, this);
+            return;
+        }
+    }
+
+    m_listAttributeTargetObserver = nullptr;
 }
 
 void HTMLInputElement::dataListMayHaveChanged()