1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

LibWeb: Implement the rest of the Adoption Agency Algorithm

This gets us 2 points on html5test.com :^)
- Before: https://html5te.st/4cf57659bc08272e (208)
- After: https://html5te.st/fb8a9259bda1c115 (210)
This commit is contained in:
Simon Wanner 2022-03-20 02:11:42 +01:00 committed by Andreas Kling
parent e165ae5b60
commit 1d95745901
6 changed files with 226 additions and 30 deletions

View file

@ -59,4 +59,26 @@ void ListOfActiveFormattingElements::clear_up_to_the_last_marker()
}
}
Optional<size_t> ListOfActiveFormattingElements::find_index(DOM::Element const& element) const
{
for (size_t i = 0; i < m_entries.size(); i++) {
if (m_entries[i].element == element)
return i;
}
return {};
}
void ListOfActiveFormattingElements::replace(DOM::Element& to_remove, DOM::Element& to_add)
{
for (size_t i = 0; i < m_entries.size(); i++) {
if (m_entries[i].element == to_remove)
m_entries[i].element = to_add;
}
}
void ListOfActiveFormattingElements::insert_at(size_t index, DOM::Element& element)
{
m_entries.insert(index, { element });
}
}