mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
Instead, take advantage of `ElementByIdMap` and `m_potentially_named_elements` to gather named elements more efficiently.
31 lines
651 B
C++
31 lines
651 B
C++
/*
|
|
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/DOM/Element.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::DOM {
|
|
|
|
class ElementByIdMap {
|
|
public:
|
|
void add(FlyString const& element_id, Element&);
|
|
void remove(FlyString const& element_id, Element&);
|
|
GC::Ptr<Element> get(FlyString const& element_id) const;
|
|
|
|
template<typename Callback>
|
|
void for_each_id(Callback callback)
|
|
{
|
|
for (auto const& id : m_map.keys())
|
|
callback(id);
|
|
}
|
|
|
|
private:
|
|
HashMap<FlyString, Vector<GC::Weak<Element>>> m_map;
|
|
};
|
|
|
|
}
|