mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
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:
parent
6856634ebc
commit
daa9c4a650
Notes:
sideshowbarker
2024-07-16 20:44:03 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/daa9c4a650 Pull-request: https://github.com/SerenityOS/serenity/pull/20720 Reviewed-by: https://github.com/kalenikaliaksandr Reviewed-by: https://github.com/shannonbooth ✅
2 changed files with 43 additions and 0 deletions
36
Userland/Libraries/LibWeb/HTML/NavigationType.h
Normal file
36
Userland/Libraries/LibWeb/HTML/NavigationType.h
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
7
Userland/Libraries/LibWeb/HTML/NavigationType.idl
Normal file
7
Userland/Libraries/LibWeb/HTML/NavigationType.idl
Normal file
|
@ -0,0 +1,7 @@
|
|||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtype
|
||||
enum NavigationType {
|
||||
"push",
|
||||
"replace",
|
||||
"reload",
|
||||
"traverse"
|
||||
};
|
Loading…
Reference in a new issue