mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LibWeb/IDB: Implement create_a_sorted_name_list
This commit is contained in:
parent
3879391fa6
commit
1ad9b3ee6e
Notes:
github-actions[bot]
2025-03-27 15:49:03 +00:00
Author: https://github.com/stelar7
Commit: 1ad9b3ee6e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
2 changed files with 16 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/ArrayBuffer.h>
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
|
||||
#include <LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Database.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
@ -621,4 +623,16 @@ bool is_valid_key_path(KeyPath const& path)
|
|||
});
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#create-a-sorted-name-list
|
||||
GC::Ref<HTML::DOMStringList> create_a_sorted_name_list(JS::Realm& realm, Vector<String> names)
|
||||
{
|
||||
// 1. Let sorted be names sorted in ascending order with the code unit less than algorithm.
|
||||
quick_sort(names, [](auto const& a, auto const& b) {
|
||||
return Infra::code_unit_less_than(a, b);
|
||||
});
|
||||
|
||||
// 2. Return a new DOMStringList associated with sorted.
|
||||
return HTML::DOMStringList::create(realm, names);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Variant.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/HTML/DOMStringList.h>
|
||||
#include <LibWeb/IndexedDB/IDBRequest.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Key.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
|
@ -25,5 +26,6 @@ WebIDL::ExceptionOr<u64> delete_a_database(JS::Realm&, StorageAPI::StorageKey, S
|
|||
void abort_a_transaction(IDBTransaction&, GC::Ptr<WebIDL::DOMException>);
|
||||
JS::Value convert_a_key_to_a_value(JS::Realm&, GC::Ref<Key>);
|
||||
bool is_valid_key_path(KeyPath const&);
|
||||
GC::Ref<HTML::DOMStringList> create_a_sorted_name_list(JS::Realm&, Vector<String>);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue