1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 01:51:03 +09:00
Commit graph

469 commits

Author SHA1 Message Date
stasoid
2abc792938 LibCore: Implement System::set_close_on_exec 2025-03-19 20:25:24 -06:00
stasoid
2e200489c8 LibCore: Implement StandardPaths::user_data_directory on Windows 2025-03-19 20:25:24 -06:00
stasoid
10db20a537 LibCore: Implement System::current_executable_path on Windows 2025-03-19 20:25:24 -06:00
Andrew Kaster
89ecc75ed8 LibCore+Meta: Un-break Swift build on Linux
LibCore's list of ignored header files for Swift was missing the Apple
only files on non-Apple platforms. Additionally, any generic glue code
cannot use -fobjc-arc, so we need to rely on -fblocks only.
2025-03-18 17:15:08 -06:00
Andrew Kaster
c8787e6a9f LibCore: Add swift bindings for EventLoop as an Executor and Actor 2025-03-15 21:51:22 -06:00
Timothy Flynn
0f05aac290 LibCore: Mark the lambda in Promise::when_resolved as mutable
This allows the handler passed into this function to also be mutable.
2025-03-09 11:14:20 -04:00
Luke Wilde
08246bfa8c LibCore: Don't discard subsequent results in Socket::resolve_host
Previously, we only returned the first result that looked like an IPv6
or IPv4 address.

This cropped up when attempting to connect to https://cxbyte.me/ whilst
IPv6 on the server wasn't working. Since we only returned the first
result, which happened to be the IPv6 address, we wasn't able to
connect.

Returning all results allows curl to attempt to connect to a different
IP if one of them isn't working, and potentially make a successful
connection.
2025-02-28 15:14:35 +01:00
Timothy Flynn
fe2dff4944 AK+Everywhere: Convert JSON value serialization to String
This removes the use of StringBuilder::OutputType (which was ByteString,
and only used by the JSON classes). And it removes the StringBuilder
template parameter from the serialization methods; this was only ever
used with StringBuilder, so a template is pretty overkill here.
2025-02-20 19:27:51 -05:00
Timothy Flynn
2c03de60da AK+Everywhere: Remove now-unecessary use of ByteString with JSON types
This removes JsonObject::get_byte_string and JsonObject::to_byte_string.
2025-02-20 19:27:51 -05:00
Timothy Flynn
bc54c0cdfb AK+Everywhere: Store JSON strings as String 2025-02-20 19:27:51 -05:00
Timothy Flynn
e591636419 AK+Everywhere: Store JSON object keys as String 2025-02-20 19:27:51 -05:00
Timothy Flynn
70eb0ba1cd AK+Everywhere: Remove the char const* JSON value constructor 2025-02-20 19:27:51 -05:00
Shannon Booth
d62cf0a807 Everywhere: Remove some use of the URL constructors
These make it too easy to construct an invalid URL, which makes it
difficult to remove the valid state of URL - which this API relies
on.
2025-02-19 08:01:35 -05:00
devgianlu
d6e9d2cdbb LibCore: Expose TCPSocket file descriptor 2025-02-17 19:52:43 +01:00
stasoid
4ae3522b10 LibCore: Implement System::socketpair on Windows 2025-02-14 09:38:59 -07:00
Timothy Flynn
9a4bb958ac LibCore: Remove ErrorOr return type from read_long_version_string
Nothing in this function is fallible.
2025-02-13 08:27:02 -05:00
stasoid
fe43712e72 LibCore: Add S_ISDIR, S_ISREG to System.h on Windows
Before this commit, LibCore/System.h exposed only part of
System::stat API on Windows. Namely, users of Core::System::stat
had to #include <dirent.h> in order to check the return value of stat.
It is OK for low-level libs like LibCore/LibFileSystem, but
S_ISDIR is also used in LibWeb\Loader\GeneratedPagesLoader.cpp.
We want to avoid platform #ifdefs in LibWeb.
2025-02-12 18:42:05 -07:00
stasoid
6b86d8a44d LibCore: Implement System::physical_memory_bytes on Windows 2025-02-12 18:42:05 -07:00
stasoid
f143a9b971 LibCore: Implement System::hardware_concurrency on Windows 2025-02-11 04:07:24 -07:00
Andrew Kaster
0dd23e43e3 LibCore: Add helper to convert Bytes/ReadonlyBytes to WSABUF 2025-02-11 01:41:46 -07:00
Andrew Kaster
25f00b2486 LibCore: Add missing HashMap include to Windows EventLoop 2025-02-11 01:41:46 -07:00
Andrew Kaster
6ebba0d847 LibCore: Skip Command, UDPServer and TCPServer on Windows 2025-02-11 01:41:46 -07:00
stasoid
26825b5865 LibCore: Properly shutdown a socket on Windows
It fixes a bug in which ImageDecoder and RequestServer
do not exit because their connections don't close.

This makes the shutdown behavior match the Linux version,
which receives FD_READ | FD_HANGUP on socket close, and
TransportSocket::read_as_much_as_possible_without_blocking calls
schedule_shutdown when read from a socket returns 0 bytes.

On Windows, we have to explicitly call WIN32 shutdown to receive
notification FD_CLOSE.
2025-02-10 12:46:25 -07:00
stasoid
e1f70d532c LibCore: Implement LocalSocket on Windows
Windows flavor of non-blocking IO, overlapped IO, differs from that on
Linux. On Windows, the OS handles writing to overlapped buffer, while
on Linux user must do it manually.

Additionally, we can only have overlapped sockets because it is the
requirement to be able to wait on them - WSAEventSelect automatically
sets socket to nonblocking mode.

So we end up emulating Linux-nonblocking sockets with
Windows-nonblocking sockets.

Pending IO state (ERROR_IO_PENDING) must not escape read/write
functions. If that happens, all synchronization like WSAPoll and
WaitForMultipleObjects stops working (WaitForMultipleObjects stops
working because with overlapped IO you are supposed to wait on an event
in OVERLAPPED structure, while we are waiting on WSA Event, see
EventLoopImplementationWindows.cpp).
2025-02-10 12:46:25 -07:00
stasoid
f696f20cd8 LibCore: Port SystemServerTakeover.cpp to Windows 2025-02-06 15:25:14 -07:00
stasoid
a291a7f770 LibCore: Add System::sleep_ms 2025-02-06 15:16:50 -07:00
stasoid
e6e233fd64 LibCore: Correctly pass arguments with spaces to Process on Windows 2025-02-06 15:15:16 -07:00
stasoid
1173b14c43 LibCore: Pass correct number of arguments to the Process on Windows
Incorrect behavior of CreateProcess:
CreateProcess("a.exe", "b c", ...) ->
    a.exe::main::argv == ["b", "c"] (wrong)
CreateProcess(0, "a.exe b c", ...) ->
    a.exe::main::argv == ["a.exe", "b", "c"] (right)

https://learn.microsoft.com/en-us/cpp/cpp/main-function-command-line-args
"If you use both the first and second arguments (lpApplicationName and
lpCommandLine), argv[0] may not be the executable name."

This means first argument of CreateProcess should never be used.
-----------------------------------------------------------------------

Searching for executable in path is suppressed now by prepending "./"

Additional bonus of the new code: .exe extension does not need to be
specified.
2025-02-06 15:15:16 -07:00
stasoid
b77016cc34 LibCore: Consistently treat file descriptors as handles on Windows
Also:
 * implement dup and is_socket
 * implement and call init_crt_and_wsa
2025-02-05 19:27:47 -07:00
stasoid
259cd70c1b LibCore: Simplify System::open
_O_OBTAIN_DIR flag makes _open use FILE_FLAG_BACKUP_SEMANTICS in
CreateFile call.

FILE_FLAG_BACKUP_SEMANTICS is required to open directory handles.

For ordinary files FILE_FLAG_BACKUP_SEMANTICS overrides file security
checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME
privileges, see https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea
2025-02-05 19:27:47 -07:00
stasoid
870cce9d11 AK: Add Error::from_windows_error(void)
Also slightly improve Error::from_windows_error(int)
2025-02-05 19:27:47 -07:00
stasoid
e0576f4790 LibCore: Add definitions for socketpair in SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
a274a50bb3 LibCore: Add declarations for getaddrinfo in SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
170f056805 LibCore: Allow winsock2.h to be included after SocketAddressWindows.h 2025-02-05 16:07:39 -07:00
stasoid
eb650798d0 LibCore: Fix SocketAddress.h compilation errors on Windows 2025-02-05 16:07:39 -07:00
Tim Ledbetter
c67035b9c1 LibCore/ArgsParser: Treat multi-use arguments as required 2025-02-05 06:58:52 -05:00
Lucas CHOLLET
e015a43b51 LibCore: Remove unused methods from EventLoop 2025-01-30 15:34:02 -07:00
stasoid
c580763743 LibCore: Don't search fonts in system_data_directories() on Windows
Fonts on Windows are stored only in %WINDIR%\Fonts and
%LOCALAPPDATA%\Microsoft\Windows\Fonts, see https://stackoverflow.com/a/67078786

And system_data_directories() is not implemented on Windows yet.
2025-01-27 09:25:17 +00:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Arhcout
aa82ff8044 LibWeb: Add documentation to the date parser format
So we don't have to dig in the parser's code
2025-01-03 11:26:01 +00:00
stasoid
49bdda1475 AK: Simplify usage of windows.h and winsock2.h
Use <AK/Windows.h> instead of windows.h/winsock2.h
to avoid timeval-related errors.

Note: winsock2.h includes windows.h
2025-01-02 10:17:51 -07:00
Timothy Flynn
27478ec7d4 Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-19 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.mm" -o -name "*.h")
2024-12-28 05:39:32 -08:00
Andreas Kling
4eda7b5646 LibCore: Make EventReceiver ref counting use atomics
This removes a race in ImageDecoder's make_decode_image_job(), where the
ref count of `this` is mutated from separate threads in the callbacks.
2024-12-26 13:45:10 +01:00
Tim Ledbetter
a450d64ffa LibCore: Return correct error code from Process::wait_for_termination 2024-12-20 14:59:56 +01:00
R-Goc
579484e065 LibCore: Fix compilation of EventLoopImplementationWindows.cpp 2024-12-20 13:57:43 +01:00
stasoid
15a96e841b Meta: Make pthread and mman available for all libraries on Windows
by default
2024-12-18 05:55:58 +01:00
stasoid
212cea4535 LibCore: Add System::getpid 2024-12-17 11:07:53 +01:00
Pavel Shliak
6f81b80114 Everywhere: Include HashMap only where it's actually used 2024-12-09 12:31:16 +01:00
R-Goc
c66eb5db11 LibCore: Add includes for S_ISDIR on Windows 2024-12-08 17:29:22 -07:00
stasoid
777dcdf6d0 LibCore: Port SharedCircularQueue to Windows 2024-12-08 17:25:40 -07:00