mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Implement CloseWatcher API
This implements most of the CloseWatcher API from the html spec. AbortSignal support is unimplemented. Integration with dialogs and popovers is also unimplemented.
This commit is contained in:
parent
527632f416
commit
b216046234
Notes:
sideshowbarker
2024-07-17 07:31:31 +09:00
Author: https://github.com/lukewarlow
Commit: b216046234
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/240
Reviewed-by: https://github.com/awesomekling
15 changed files with 432 additions and 3 deletions
40
Userland/Libraries/LibWeb/HTML/CloseWatcherManager.h
Normal file
40
Userland/Libraries/LibWeb/HTML/CloseWatcherManager.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2024, the Ladybird developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#close-watcher-manager
|
||||
class CloseWatcherManager final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(CloseWatcherManager, Bindings::PlatformObject);
|
||||
JS_DECLARE_ALLOCATOR(CloseWatcherManager);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static JS::NonnullGCPtr<CloseWatcherManager> create(JS::Realm&);
|
||||
|
||||
void add(JS::NonnullGCPtr<CloseWatcher>);
|
||||
void remove(CloseWatcher const&);
|
||||
|
||||
bool process_close_watchers();
|
||||
|
||||
void notify_about_user_activation();
|
||||
bool can_prevent_close();
|
||||
|
||||
private:
|
||||
explicit CloseWatcherManager(JS::Realm&);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
Vector<Vector<JS::NonnullGCPtr<CloseWatcher>>> m_groups;
|
||||
uint32_t m_allowed_number_of_groups { 1 };
|
||||
bool m_next_user_interaction_allows_a_new_group { true };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue