Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e390a911b3480dd8d019bbcf46412885d4ec5ed7
      
https://github.com/WebKit/WebKit/commit/e390a911b3480dd8d019bbcf46412885d4ec5ed7
  Author: David Kilzer <[email protected]>
  Date:   2026-10-02 (Fri, 02 Oct 2026)

  Changed paths:
    M Source/WebCore/css/MediaList.cpp
    M Source/WebCore/css/query/MediaQueryParser.cpp
    M Tools/TestWebKitAPI/CMakeLists.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WebCore/MediaQueryListCapacity.cpp

  Log Message:
  -----------
  Media query lists retain a sixteen-element buffer for a single query
<https://bugs.webkit.org/show_bug.cgi?id=324051>
<rdar://184884868>

Reviewed by Darin Adler.

`MQ::MediaQueryList` grows its buffer to WTF's sixteen-element minimum
on the first `append()` and then keeps it for the lifetime of the
stylesheet, even though the overwhelmingly common list holds a single
query.

Size the buffer to the exact query count up front, since every
top-level comma-separated component value yields exactly one query.
`MediaList::appendMedium()` and `MediaList::deleteMedium()` hit the
same floor on the same retained storage, so size their buffers to what
they store as well.

Tests: Tools/TestWebKitAPI/Tests/WebCore/MediaQueryListCapacity.cpp

* Source/WebCore/css/MediaList.cpp:
(WebCore::MediaList::deleteMedium):
(WebCore::MediaList::appendMedium):
* Source/WebCore/css/query/MediaQueryParser.cpp:
(WebCore::MQ::mediaQueryCount): Add.
(WebCore::MQ::MediaQueryParser::consumeMediaQueryList):
* Tools/TestWebKitAPI/CMakeLists.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/MediaQueryListCapacity.cpp: Add.

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



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

Reply via email to