Commit graph

77078 commits

Author SHA1 Message Date
Johan Dahlin
6c99bf74ea Documentation: Add GTK UI build prerequisites and style guide
Add GTK4/libadwaita build instructions alongside Qt.
Add Documentation/GtkFrontend.md with GTK-specific coding style
rules and a manual test checklist.
2026-04-17 11:17:56 -04:00
Johan Dahlin
0a00a5d61a UI/Gtk: Add browser window, tabs, menus, and dialogs
Add the complete browser UI:
- BrowserWindow: AdwHeaderBar with navigation, tab management via
  AdwTabView/AdwTabBar, find-in-page, fullscreen, zoom, D-Bus
  single-instance with open/activate handlers
- Tab: WebContentView lifecycle, ViewImplementation callbacks for
  title, URL, favicon, cursor, tooltips, dialogs, window management
- LadybirdBrowserWindow: GtkBuilder template widget with toolbar,
  tab bar, find bar, devtools banner, and hamburger menu
- LadybirdLocationEntry: URL entry with autocomplete, domain
  highlighting, and security icon
- Menu: GAction-based context menus and application menu with
  keyboard accelerators
- Dialogs: JS alert/confirm/prompt (AdwAlertDialog), color picker,
  file picker, select dropdown, download save dialog, toast
- GtkBuilder .ui resources for browser window, location entry
  completions, and list popovers

Updates Application and main.cpp to create browser windows and
handle D-Bus activation from remote instances.
2026-04-17 11:17:56 -04:00
Johan Dahlin
2573aff090 UI/Gtk: Add input events and WebContentView
Add the web content rendering surface and input handling:
- Events: GDK keyboard, mouse, and scroll event
  translation to Web::KeyEvent/MouseEvent
- WebContentView: ViewImplementation backed by
  GdkMemoryTextureBuilder with incremental update hints,
  enqueue_native_event helpers for mouse/key events
- LadybirdWebView: Custom GtkWidget with focus, key,
  click, motion, and scroll controllers
- Builder.h: Typed GtkBuilder object lookup helper
2026-04-17 11:17:56 -04:00
Johan Dahlin
e8be4a88d9 UI/Gtk: Add GLib event loop integration and application entry point
Add the core infrastructure for the GTK frontend:
- EventLoopImplementationGtk: GLib main loop integration with
  Core::EventLoop, timers, notifiers, and signal handling
- GObjectPtr RAII wrapper for GObject lifecycle management
- Application subclass with AdwApplication and D-Bus registration
- Minimal main.cpp entry point

The application starts and runs the event loop but does not yet
open any windows.
2026-04-17 11:17:56 -04:00
Johan Dahlin
1bf03c21d1 CMake: Add GTK4 as a GUI framework option
Add GTK as a possible GUI framework alongside Qt on Linux. When the gtk
or qt vcpkg manifest feature is selected, the corresponding framework
dependencies are pulled in automatically.
2026-04-17 11:17:56 -04:00
Johan Dahlin
3b4449a7d5 Meta: Enable wayland in gtk overlay port
Enable the Wayland and Vulkan backends, add shaderc for GLSL
compilation, and drop the X11 backend to avoid requiring X11
development libraries on Wayland-only systems.
2026-04-17 11:17:56 -04:00
Johan Dahlin
1a61ca4b20 Meta: Add gtk overlay port
Copy the GTK 4.22.0 port from the vcpkg registry as an overlay port so
we can customize its build configuration.
2026-04-17 11:17:56 -04:00
Johan Dahlin
f9218e9e63 Meta: Add wayland and wayland-protocols overlay ports
These overlay ports allow vcpkg to build Wayland libraries from source
when the force-build feature is enabled along with the
X_VCPKG_FORCE_VCPKG_WAYLAND_LIBRARIES triplet variable.
2026-04-17 11:17:56 -04:00
Johan Dahlin
04a1c4310e Meta: Exclude GTK feature-gated vcpkg deps from flatpak check
The gtk, libadwaita, wayland, and wayland-protocols packages are behind
the vcpkg "gtk" manifest feature and not present in the Qt flatpak
manifest.
2026-04-17 11:17:56 -04:00
Johan Dahlin
43b68f6f76 Meta: Fix check-flatpak.py when GIT_DIR is set
pre-commit sets GIT_DIR to an absolute path pointing at the main
repository. When check-flatpak.py shells out to run git inside
Build/vcpkg, this causes git to look at the wrong repo, failing to find
packages in the vcpkg baseline. Clear GIT_DIR from the subprocess
environment so git operates on Build/vcpkg's own repo.
2026-04-17 11:17:56 -04:00
Shannon Booth
33725b494b LibWeb/Bindings: Factor generate_union_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
20b1fe22d1 LibWeb/Bindings: Factor generate_sequence_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
1532ac1551 LibWeb/Bindings: Factor generate_callback_function_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
6e5db85fac LibWeb/Bindings: Factor generate_enum_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
de472d3454 LibWeb/Bindings: Factor generate_record_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
6e21df0138 LibWeb/Bindings: Factor out generate_any_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
3b2df8eefb LibWeb/Bindings: Factor generate_array_buffer_view_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
d0e07d05f7 LibWeb/Bindings: Factor generate_callback_interface_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
2f184f00ec LibWeb/Bindings: Factor generate_buffer_source_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
241c5e182f LibWeb/Bindings: Name is_javascript_builtin in terms of BufferSource
While this does add some extra cases into the function, this is
effectively a rename to better match how we were effectively already
doing this. Rename the function and link it to the right location in
the specification. Doing this also allows us to drop the FIXME as it
makes it clear what this hardcoded list is meant to achieve.
2026-04-17 15:50:07 +01:00
Shannon Booth
3a6d4ec77a LibWeb/Bindings: Factor generate_floating_point_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
ca524a0a0c LibWeb/Bindings: Factor generate_platform_object_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
536052c3c8 LibWeb/Bindings: Factor generate_promise_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
69fb476e76 LibWeb/Bindings: Factor generate_object_to_cpp into function 2026-04-17 15:50:07 +01:00
Shannon Booth
431e8a7b81 LibWeb/Bindings: Remove uneeded File/MediaSource special cases
These are already covered by nature of being considered a platform
object.
2026-04-17 15:50:07 +01:00
Andreas Kling
bc01fc3280 LibWeb: Use pre-cached specificity when sorting matching CSS rules
sort_matching_rules() was calling Selector::specificity() inside the
sort comparator. MatchingRule already caches the specificity value
at rule insertion time, so use that directly instead.
2026-04-17 16:23:15 +02:00
Andreas Kling
0317007ee1 AK: Make short ASCII string literals compile-time constants
Make the _string, _fly_string, _utf16, and _utf16_fly_string UDL
operators constexpr, with a fast path for short (<= 7 byte) ASCII
literals that folds directly into an inline ShortString. Previously,
every "foo"_fly_string (and friends) involved an out-of-line call
into the string factory, even though the result is entirely known
at compile time.
2026-04-17 16:22:56 +02:00
Sam Atkins
7c1d359790 LibWeb: Clean-up more input state after running each test
The clean-up in 71c457c36e turns out to
not be enough for all cases. So be more thorough and clear up anything
that could affect the next test.

In particular this fixes flakiness in `Text/input/select-text.html` but
hopefully it solves the issue for good!
2026-04-17 14:13:18 +01:00
Andreas Kling
71d92c7298 UI/AppKit: Restore focus when activating a tab
Tabs opened from links on AppKit can be created before their URL is
loaded. That left background open-url tabs with the location field as
their stored responder, so switching to them later restored address-bar
focus instead of web content focus.

Track each tab's preferred responder, restore it when AppKit makes
the tab key, and mark page-backed open-url tabs to prefer the web view.
Blank new-tab pages still keep the location field focused.
2026-04-17 08:06:24 +02:00
Andreas Kling
1572429541 UI/Qt: Restore focus when activating a tab
Restore the active tab's remembered focus widget when switching tabs.
If the tab has no remembered focused child, fall back to the web
view so keyboard scrolling works immediately in tabs opened from
links.

This keeps the existing new-tab location bar behavior while making
background-opened pages respond to keyboard inputs as soon as they
are activated.
2026-04-17 08:06:24 +02:00
Tim Ledbetter
294a0efe2a LibWeb: Mark ellipsized fragments as hidden rather than removing them
Previously, when applying `text-overflow: ellipsis`, line box fragments
after the  ellipsis point were removed from the line box. This
invalidated fragment indices stored in `containing_line_box_fragment`,
causing an out-of-bounds access in `LayoutState::commit()` when
resolving atomic inline positions.

Instead of removing fragments, mark them as hidden. This preserves
index stability while preventing hidden fragments from being displayed.
2026-04-17 08:03:26 +02:00
Andreas Kling
8caca053a3 LibWeb: Avoid IntersectionObserver registration lookups
IntersectionObserver updates already iterate over each observer and its
observation targets. We then looked the same target and observer pair up
again through Element's registered observer list just to read and write
previousThresholdIndex and previousIsIntersecting.

Store that mutable state with the observer-side observation target
instead. The element-side list now only keeps strong observer
references for lifetime management and unobserve/disconnect.

This deviates from the spec's storage model, so document the difference
next to the preserved spec comments.
2026-04-17 08:02:30 +02:00
Andreas Kling
9694134f32 LibWeb: Stop emitting custom element reactions in attribute getters
In other engines, the [CEReactions] extended attribute on an attribute
only applies to the setter steps. Attribute getters never fire custom
element reactions, yet our bindings generator was still pushing a new
element queue onto the custom element reactions stack on entry and
popping + invoking it on return for every single getter call on a
[CEReactions] attribute.
2026-04-17 01:31:32 +02:00
Tim Ledbetter
caac0eea04 LibGfx: Map imported Linux dmabuf backing stores read-only
The UI process only reads these pixels to composite them - all writes
happen in WebContent via Vulkan. Some dmabuf exporters refuse writable
mappings on re-imported fds even when the Vulkan memory is
`HOST_VISIBLE`.
2026-04-17 00:39:04 +02:00
Tim Ledbetter
f168423c18 CI: Allow dependabot to update the Rust toolchain 2026-04-16 23:42:22 +02:00
Tim Ledbetter
e1a12bcbcb Meta: Pin Rust toolchain version
This should prevent CI failures on toolchain updates in the future.
2026-04-16 23:42:22 +02:00
Andreas Kling
530f6fb05c LibJS: Fold nested Rust match conditionals
Move several let/const checks and the `instanceof` keyword check into
match guards.
2026-04-16 22:44:41 +02:00
Andreas Kling
f5b78e700c LibRegex: Collapse named backreference guard
Fold the named-backreference validation into the match arm.
2026-04-16 22:44:41 +02:00
Andreas Kling
0755c7d180 LibUnicode: Remove redundant month casts
Remove three no-op `u8` casts from calendar date conversions.
2026-04-16 22:44:41 +02:00
Zaggy1024
3844edaaed AK: Avoid overflow in Duration::to_time_units() with fraction near 1
With numerators or denominators approaching NumericLimits<u32>::max(),
we could overflow in the sum of the remainder and the rounding
contribution. Instead, divide them separately and sum them afterward.
2026-04-16 15:08:27 -05:00
Zaggy1024
affbe61da0 AK: Simplify Duration::from_time_units and handle remainder overflow
Overflow could happen in the multiplication of the remainder seconds
back into time units. Instead, take a remainder of the time units from
the division and use that for the nanoseconds.
2026-04-16 15:08:27 -05:00
Andreas Kling
586da4e610 LibWebView: Add a "Search with <engine>" autocomplete row
Synthesize an extra AutocompleteSuggestion at the top of the Search
Suggestions section whenever there is a configured search engine and
the typed query is not URL-shaped.

Use the query as the row's primary text, carry a "Search with <engine>"
subtitle, and render that subtitle in the AppKit and Qt popups so the
explicit search fallback stays visible and readable even when history
fills the list.
2026-04-16 21:01:28 +02:00
Andreas Kling
bb9f789eae UI/Qt: Show rich, history-backed address bar autocomplete
Replace the old QCompleter-based popup with a custom list that renders
AutocompleteSuggestion rows with titles/URLs/section headers/favicons.

Parent the popup inside the window so it does not steal focus, route
keyboard and mouse activation through WebView::Autocomplete, and add
inline completion with backspace suppression and top-row selection.
2026-04-16 21:01:28 +02:00
Andreas Kling
ed34a4ba8a LibWebView: Ignore duplicate URL change notifications
Some navigations report the same URL more than once through
WebContentClient::did_change_url(). Forwarding those duplicate updates
into the frontend turned an internal no-op into visible UI churn,
including location bar resets and AppKit focus stealing.

Treat repeated URL notifications as a no-op inside LibWebView so
frontends only react to real URL changes.
2026-04-16 21:01:28 +02:00
Andreas Kling
c249f0324b LibWebView: Let Settings clear browsing history
Route the existing Clear Browsing Data dialog through HistoryStore's
time-range deletion path as well. That makes the Settings action
remove visited pages from persisted history and from history-backed
address bar suggestions instead of only touching cache and site data.

Add a history checkbox to the dialog, thread its state through the
Settings WebUI message, and cover remove_entries_accessed_since() for
both transient and persisted stores in TestHistoryStore.
2026-04-16 21:01:28 +02:00
Andreas Kling
1802a05bc2 UI/AppKit: Show rich autocomplete suggestion rows
Render AutocompleteSuggestion rows with section headers, favicons,
titles, and secondary text in the child-window popup instead of just
plain strings.

Move the AppKit popup and inline completion onto the shared suggestion
model, and share the base64 PNG decoding helper with the application
menu icon loading path.
2026-04-16 21:01:28 +02:00
Andreas Kling
4121b7c0d0 UI/AppKit: Show autocomplete in a child window
Replace the AppKit popover because it becomes key and steals focus from
the location field while suggestions are visible. Use a borderless
child window anchored to the toolbar item instead, and dismiss it on
resize or focus changes so the browser chrome stays predictable.
2026-04-16 21:01:28 +02:00
Andreas Kling
66e0035c9e LibWebView: Structure autocomplete suggestions
Replace the frontend-facing Vector<String> flow with structured
AutocompleteSuggestion objects carrying source, section, title,
and favicon metadata.

Build merged history and literal-URL rows in LibWebView, deduplicate
equivalent URL suggestions, move the autocomplete URL helpers out
of URL.h, and update the history and URL tests around the new model.
2026-04-16 21:01:28 +02:00
Andreas Kling
87b6703054 LibWebView: Persist page metadata in history
Record visits as soon as a page produces useful metadata such as a
title or favicon so pages that never finish loading still become
autocomplete candidates.

Store favicons in the history schema from the start instead of
introducing an upgrade path inside this series, and cover persisted
metadata behavior in TestHistoryStore.
2026-04-16 21:01:28 +02:00
Andreas Kling
fe2cab9270 LibWebView: Add history-backed location autocomplete
Teach LibWebView autocomplete to query HistoryStore before falling back
to remote engines and move the wiring out of the AppKit frontend.
Refine matching so scheme and www. boilerplate do not dominate results,
short title and substring queries stay quiet, and history tracing can
explain what the ranking code is doing.
2026-04-16 21:01:28 +02:00