LibURL+LibWeb+LibWebView: Move internal URLs to their own header
This nearly eliminates the compilation impact of adding a new WebUI URL.
This commit is contained in:
parent
19dd5bef60
commit
409e5edbf1
8 changed files with 52 additions and 14 deletions
42
Libraries/LibURL/InternalURLs.h
Normal file
42
Libraries/LibURL/InternalURLs.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2026, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NeverDestroyed.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibURL/URL.h>
|
||||
|
||||
namespace URL {
|
||||
|
||||
#define ENUMERATE_INTERNAL_URLS \
|
||||
__URL_ENUMERATE(bookmarks) \
|
||||
__URL_ENUMERATE(newtab) \
|
||||
__URL_ENUMERATE(processes) \
|
||||
__URL_ENUMERATE(settings) \
|
||||
__URL_ENUMERATE(version)
|
||||
|
||||
#define __URL_ENUMERATE(url) \
|
||||
inline URL const& about_##url() \
|
||||
{ \
|
||||
static NeverDestroyed<URL> url = URL::about(#url##_string); \
|
||||
return *url; \
|
||||
}
|
||||
ENUMERATE_INTERNAL_URLS
|
||||
#undef __URL_ENUMERATE
|
||||
|
||||
inline bool is_webui_url(URL const& url)
|
||||
{
|
||||
#define __URL_ENUMERATE(internal_url) \
|
||||
if (url == about_##internal_url()) \
|
||||
return true;
|
||||
ENUMERATE_INTERNAL_URLS
|
||||
#undef __URL_ENUMERATE
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -212,18 +212,7 @@ URL create_with_data(StringView mime_type, StringView payload, bool is_base64 =
|
|||
|
||||
inline URL about_blank() { return URL::about("blank"_string); }
|
||||
inline URL about_srcdoc() { return URL::about("srcdoc"_string); }
|
||||
|
||||
inline URL about_error() { return URL::about("error"_string); }
|
||||
inline URL about_newtab() { return URL::about("newtab"_string); }
|
||||
inline URL about_bookmarks() { return URL::about("bookmarks"_string); }
|
||||
inline URL about_processes() { return URL::about("processes"_string); }
|
||||
inline URL about_settings() { return URL::about("settings"_string); }
|
||||
inline URL about_version() { return URL::about("version"_string); }
|
||||
|
||||
inline bool is_webui_url(URL const& url)
|
||||
{
|
||||
return first_is_one_of(url, about_bookmarks(), about_processes(), about_settings(), about_version());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Bindings/PrincipalHostDefined.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/IPv6Address.h>
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibURL/Origin.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <LibDevTools/DevToolsServer.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibImageDecoderClient/Client.h>
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/Loader/UserAgent.h>
|
||||
#include <LibWeb/Page/InputEvent.h>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibUnicode/Locale.h>
|
||||
#include <LibWebView/Application.h>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWebView/Menu.h>
|
||||
#include <LibWebView/URL.h>
|
||||
|
|
|
|||
|
|
@ -5,17 +5,19 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibURL/InternalURLs.h>
|
||||
#include <LibWebView/URL.h>
|
||||
#include <UI/Qt/Application.h>
|
||||
#include <UI/Qt/ChromeStyle.h>
|
||||
#include <UI/Qt/EventLoopImplementationQt.h>
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <UI/Qt/MacWindow.h>
|
||||
#endif
|
||||
#include <UI/Qt/Settings.h>
|
||||
#include <UI/Qt/StringUtils.h>
|
||||
#include <UI/Qt/WebContentView.h>
|
||||
|
||||
#if defined(AK_OS_MACOS)
|
||||
# include <UI/Qt/MacWindow.h>
|
||||
#endif
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDesktopServices>
|
||||
#include <QDialog>
|
||||
|
|
|
|||
Loading…
Reference in a new issue