LibWeb: Turn is_platform_object() ifs into an Array

This commit is contained in:
Linus Groh 2022-09-21 17:44:33 +01:00
parent 464368f94a
commit 2cab2a8e8f
Notes: sideshowbarker 2024-07-17 06:44:32 +09:00

View File

@ -22,47 +22,32 @@ static bool is_platform_object(Type const& type)
// NOTE: This is a hand-curated subset of platform object types that are actually relevant
// in places where this function is used. If you add IDL code and get compile errors, you
// might simply need to add another type here.
if (type.name() == "EventTarget")
return true;
if (type.name() == "Node")
return true;
if (type.name() == "Document")
return true;
if (type.name() == "Text")
return true;
if (type.name() == "DocumentType")
return true;
static constexpr Array types = {
"AbortSignal"sv,
"Attr"sv,
"Blob"sv,
"CanvasRenderingContext2D"sv,
"Document"sv,
"DocumentType"sv,
"EventTarget"sv,
"ImageData"sv,
"MutationRecord"sv,
"NamedNodeMap"sv,
"Node"sv,
"Path2D"sv,
"Range"sv,
"Selection"sv,
"Text"sv,
"TextMetrics"sv,
"URLSearchParams"sv,
"WebGLRenderingContext"sv,
"Window"sv,
};
if (type.name().ends_with("Element"sv))
return true;
if (type.name().ends_with("Event"sv))
return true;
if (type.name() == "ImageData")
return true;
if (type.name() == "Window")
return true;
if (type.name() == "Range")
return true;
if (type.name() == "Selection")
return true;
if (type.name() == "Attr")
return true;
if (type.name() == "NamedNodeMap")
return true;
if (type.name() == "TextMetrics")
return true;
if (type.name() == "AbortSignal")
return true;
if (type.name() == "CanvasRenderingContext2D")
return true;
if (type.name() == "WebGLRenderingContext")
return true;
if (type.name() == "URLSearchParams")
return true;
if (type.name() == "Blob")
return true;
if (type.name() == "Path2D")
return true;
if (type.name() == "MutationRecord")
if (types.span().contains_slow(type.name()))
return true;
return false;
}