Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3415adf7a9d658881a8246b91db3bc428069bc77
      
https://github.com/WebKit/WebKit/commit/3415adf7a9d658881a8246b91db3bc428069bc77
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-06 (Mon, 06 Apr 2026)

  Changed paths:
    M Source/WebCore/html/HTMLFormElement.cpp
    M Source/WebCore/html/HTMLFormElement.h

  Log Message:
  -----------
  HTMLFormElement::length() should use the cached HTMLFormControlsCollection
https://bugs.webkit.org/show_bug.cgi?id=311560

Reviewed by Ryosuke Niwa and Anne van Kesteren.

HTMLFormElement::length() was manually iterating m_listedElements and
calling virtual isEnumeratable() on each element on every call.
HTMLFormControlsCollection already caches element count via
CollectionIndexCache, but length() was bypassing it entirely. This made
JavaScript patterns like for (i = 0; i < form.length; i++) O(n^2).

Delegate to elements()->length() to benefit from the collection's
caching, matching how item() already delegates to elements()->item().

* Source/WebCore/html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::length):
(WebCore::HTMLFormElement::length const): Deleted.
* Source/WebCore/html/HTMLFormElement.h:

Canonical link: https://commits.webkit.org/310685@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to