mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 15:32:51 +00:00
UI event handlers currently return a boolean where false means the event was cancelled by a script on the page, or otherwise dropped. It has been a point of confusion for some time now, as it's not particularly clear what should be returned in some special cases, or how the UI process should handle the response. This adds an enumeration with a few states that indicate exactly how the WebContent process handled the event. This should remove all ambiguity, and let us properly handle these states going forward. There should be no behavior change with this patch. It's meant to only introduce the enum, not change any of our decisions based on the result.
28 lines
791 B
C++
28 lines
791 B
C++
/*
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
namespace Web {
|
|
|
|
enum class EventResult {
|
|
// The event is allowed to continue. It was not cancelled by the page, nor handled explicitly by the WebContent
|
|
// process. The UI process is allowed to further process the event.
|
|
Accepted,
|
|
|
|
// The event was accepted, and was handled explicitly by the WebContent process. The UI process should not further
|
|
// process the event.
|
|
Handled,
|
|
|
|
// The event was not accepted by the WebContent process (e.g. because the document is no longer active, or a
|
|
// drag-and-drop is active).
|
|
Dropped,
|
|
|
|
// The event was cancelled by the page (e.g. by way of e.preventDefault()).
|
|
Cancelled,
|
|
};
|
|
|
|
}
|