mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibWeb: Flesh out "document visibility" state a bit more
We can now "update the visibility state", which also causes `visibilitychange` events to fire on the document. This still needs GUI integration work at the BrowsingContext level.
This commit is contained in:
parent
5a500827b8
commit
42b8656db3
3 changed files with 28 additions and 3 deletions
|
@ -1578,13 +1578,31 @@ Bindings::LocationObject* Document::location()
|
|||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-document-hidden
|
||||
bool Document::hidden() const
|
||||
{
|
||||
return false;
|
||||
return visibility_state() == "hidden";
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-document-visibilitystate
|
||||
String Document::visibility_state() const
|
||||
{
|
||||
return hidden() ? "hidden" : "visible";
|
||||
return m_visibility_state;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#update-the-visibility-state
|
||||
void Document::update_the_visibility_state(String visibility_state)
|
||||
{
|
||||
// 1. If document's visibility state equals visibilityState, then return.
|
||||
if (m_visibility_state == visibility_state)
|
||||
return;
|
||||
|
||||
// 2. Set document's visibility state to visibilityState.
|
||||
m_visibility_state = visibility_state;
|
||||
|
||||
// FIXME: 3. Run any page visibility change steps which may be defined in other specifications, with visibility state and document.
|
||||
|
||||
// 4. Fire an event named visibilitychange at document, with its bubbles attribute initialized to true.
|
||||
auto event = DOM::Event::create(window(), HTML::EventNames::visibilitychange);
|
||||
event->set_bubbles(true);
|
||||
dispatch_event(event);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#run-the-resize-steps
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue