LibWeb: Add NavigationType to prep for Navigation API platform objects

This enum is used in many Navigation API classes, so stick it in its own
IDL file. However, we have no way to ask the BindingsGenerator to create
just an enum class that's not defined in an IDL file without an
 ``interface`` class at the top level, so implement the expected enum
 and stringification method manually.
This commit is contained in:
Andrew Kaster 2023-08-23 10:27:37 -06:00 committed by Andrew Kaster
parent 6856634ebc
commit daa9c4a650
Notes: sideshowbarker 2024-07-16 20:44:03 +09:00
2 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
// FIXME: Generate this from the IDL file that just has an enum in it
namespace Web::Bindings {
enum class NavigationType {
Push,
Replace,
Reload,
Traverse,
};
inline String idl_enum_to_string(NavigationType value)
{
switch (value) {
case NavigationType::Push:
return "Push"_string;
case NavigationType::Replace:
return "Replace"_string;
case NavigationType::Reload:
return "Reload"_string;
case NavigationType::Traverse:
return "Traverse"_string;
default:
return "<unknown>"_string;
}
}
}

View file

@ -0,0 +1,7 @@
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtype
enum NavigationType {
"push",
"replace",
"reload",
"traverse"
};