1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibWeb: Keep CSS sheets sorted in document tree order

This ensures that style is applied consistently, even if the document
has external CSS resources that don't always arrive in the same order.
This commit is contained in:
Andreas Kling 2022-09-09 11:08:56 +02:00
parent 32c99313a6
commit 524ec95bcd
4 changed files with 24 additions and 10 deletions

View file

@ -20,14 +20,14 @@ public:
void add_sheet(CSSStyleSheet&);
void remove_sheet(CSSStyleSheet&);
Vector<CSSStyleSheet&> const& sheets() const { return m_sheets; }
Vector<CSSStyleSheet&>& sheets() { return m_sheets; }
Vector<JS::NonnullGCPtr<CSSStyleSheet>> const& sheets() const { return m_sheets; }
Vector<JS::NonnullGCPtr<CSSStyleSheet>>& sheets() { return m_sheets; }
CSSStyleSheet* item(size_t index) const
{
if (index >= m_sheets.size())
return {};
return &const_cast<CSSStyleSheet&>(m_sheets[index]);
return const_cast<CSSStyleSheet*>(m_sheets[index].ptr());
}
size_t length() const { return m_sheets.size(); }
@ -43,8 +43,10 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
void sort_sheets();
DOM::Document& m_document;
Vector<CSSStyleSheet&> m_sheets;
Vector<JS::NonnullGCPtr<CSSStyleSheet>> m_sheets;
};
}