LibWeb: Implement some viewport proximity features

This commit is contained in:
Psychpsyo 2024-11-26 23:58:07 +01:00 committed by Sam Atkins
commit 331b1b22f5
Notes: github-actions[bot] 2025-01-04 11:54:35 +00:00
3 changed files with 119 additions and 3 deletions

View file

@ -85,6 +85,17 @@ enum class CustomElementState {
Custom,
};
// https://drafts.csswg.org/css-contain/#proximity-to-the-viewport
// An element that has content-visibility: auto is in one of three states when it comes to its proximity to the viewport:
enum class ProximityToTheViewport {
// - The element is close to the viewport:
CloseToTheViewport,
// - The element is far away from the viewport:
FarAwayFromTheViewport,
// - The elements proximity to the viewport is not determined:
NotDetermined,
};
class Element
: public ParentNode
, public ChildNode<Element>
@ -377,6 +388,10 @@ public:
void resolve_counters(CSS::ComputedProperties&);
void inherit_counters();
ProximityToTheViewport proximity_to_the_viewport() const { return m_proximity_to_the_viewport; }
void determine_proximity_to_the_viewport();
bool is_relevant_to_the_user();
protected:
Element(Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
@ -469,6 +484,9 @@ private:
OwnPtr<CSS::CountersSet> m_counters_set;
GC::Ptr<DOM::Element> m_aria_active_descendant_element;
// https://drafts.csswg.org/css-contain/#proximity-to-the-viewport
ProximityToTheViewport m_proximity_to_the_viewport { ProximityToTheViewport::NotDetermined };
};
template<>