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

50 commits

Author SHA1 Message Date
Lucien Fiorini
0fcb574041 LibGfx+LibWeb: Turn Gfx::Filter into a SkImageFilter wrapper 2025-06-01 23:22:10 +02:00
Psychpsyo
85883ee5ce LibWeb: Deduplicate clipping code
This makes it so that PaintableWithLines no longer has its own
bespoke clipping logic, using the same code as regular scroll/
overflow clipping.
2025-05-13 15:30:14 +03:00
Timothy Flynn
c846616d51 LibWeb: Adjust positions by the scroll offset for scrollbar hit testing
This ensures we scroll to the correct position when dragging a scrollbar
or clicking its gutter.
2025-05-08 10:40:58 +01:00
Timothy Flynn
22532c769c LibWeb: Be less lenient in scrollbar hit testing
A scrollbar contains a mouse position only if its gutter rect contains
that position. We were incorrectly deciding a position was contained if
it fell to the right of a vertical scrollbar, or below a horizontal
scrollbar.
2025-05-08 10:40:58 +01:00
Psychpsyo
dbece92637 LibWeb: Make elements with 'opacity: 0' respond to hit-testing 2025-05-07 01:45:07 +03:00
Jonne Ransijn
e5d89c72a6 LibWeb: Remove unuses variable in PaintableBox.cpp 2025-04-22 21:19:31 -06:00
Timothy Flynn
4cd186f3f5 LibWeb: Adjust the scroll offset when the scrollbar gutter is clicked
This allows clicking on the scrollbar gutter to scroll to the offset
indicated by the mouse position.
2025-04-22 11:29:06 -04:00
Timothy Flynn
a135ce528e LibWeb: Move adjustmust of scrollbar offset into compute_scrollbar_data
Currently, compute_scrollbar_data does not adjust the position of the
scrollbar thumb based on the actual scroll offset. This is because we
perform this offset in most cases inside the display list executor, in
order to allow us to avoid recomputing the display list.

However, there are cases where we do want the thumb rect with an offset
inside PaintableBox. We currently use scroll_thumb_rect to perform that
computation.

In an upcoming patch, we will need both this offset thumb rect and the
scrollbar gutter rect. So this patch moves the computation of the offset
to compute_scrollbar_data, performed behind an optional parameter.
2025-04-22 11:29:06 -04:00
Timothy Flynn
66e422b4f1 LibWeb: Draw a scrollbar gutter when the scrollbar is enlarged 2025-04-22 11:29:06 -04:00
Timothy Flynn
843468dbf8 LibWeb: Enlarge scrollbars that are interacting with the mouse
When a scrollbar is not interacting with the mouse, we now draw the
scrollbar slightly slimmer. When the mouse enters the space occupied
by the scrollbar, we enlarge it for easier mouse interactivity.
2025-04-22 11:29:06 -04:00
Andreas Kling
c394344e7d LibWeb: Put PaintableWithLines in dedicated GC allocator 2025-04-22 12:09:42 +02:00
Aliaksandr Kalenik
8e2d1559ec LibGfx: Join ScaledFont into Font
Since ScaledFont is the only class inherited from Font we could simply
merge them.
2025-04-21 09:51:16 +02:00
Aliaksandr Kalenik
2e256d2eac LibWeb: Invalidate text-decoration-thickness as paint-only property
Fixes underinvalidation caused by resolving text-decoration-thickness
during layout commit, while this property can be invalidated
independently of layout.
2025-03-16 22:25:26 +01:00
Aliaksandr Kalenik
9e287465b9 LibWeb: Fix CSS transform invalidation when transitioning to none
Fixes https://github.com/LadybirdBrowser/ladybird/issues/2707
2025-03-15 13:30:45 +01:00
Tim Ledbetter
88d35c547c LibWeb/CSS: Implement the caret-color property 2025-03-09 19:36:29 +01:00
Vaxry
c5d0af54d0 LibWeb: Don't handle scroll if no axes are accepted
In some cases, we might be hovering directly on an element
scrollable e.g. horizontally, but we are scrolling vertically.
In these cases, we need to delegate the scroll to the parent
instead of stalling the user's scroll.
2025-03-01 23:54:48 +01:00
Sam Atkins
532c01c388 LibWeb: Implement text-decoration: spelling-error and grammar-error 2025-02-28 16:34:08 +00:00
Sam Atkins
bfd7ac1204 LibWeb+WebContent+UI: Support image cursors
The `cursor` property accepts a list of possible cursors, which behave
as a fallback: We use whichever cursor is the first available one. This
is a little complicated because initially, any remote images have not
loaded, so we need to use the fallback standard cursor, and then switch
to another when it loads.

So, ComputedValues stores a Vector of cursors, and then in EventHandler
we scan down that list until we find a cursor that's ready for use.

The spec defines cursors as being `<url>`, but allows for `<image>`
instead. That includes functions like `linear-gradient()`.

This commit implements image cursors in the Qt UI, but not AppKit.
2025-02-28 13:50:13 +01:00
Sam Atkins
fd2414ba35 LibWeb/Painting: Call Base::resolve_paint_properties() from children 2025-02-28 13:50:13 +01:00
Timothy Flynn
72905c84d5 LibWeb+LibWebView+WebContent: Support both inspecting/highlighting nodes
Our own Inspector differs from most other DevTools implementations with
regard to highlighting DOM nodes as you hover elements in the inspected
DOM tree. In other implementations, as you change the hovered node, the
browser will render a box model overlay onto the page for that node. We
currently don't do this; we wait until you click the node, at which
point we both paint the overlay and inspect the node's properties.

This patch does not change that behavior, but separates the IPCs and
internal tracking of inspected nodes to support the standard DevTools
behavior. So the DOM document now stores an inspected node and a
highlighted node. The former is used for features such as "$0" in the
JavaScript console, and the latter is used for the box model overlay.
Our Inspector continues to set these to the same node.
2025-02-24 12:05:29 -05:00
InvalidUsernameException
be47f95180 LibWeb: Reduce number of recompiled files for display list headers
This reduces the number of `.cpp` files that need to be recompiled when
one of the below header files changes as follows:

Painting/Command.h: 1030 -> 61
Painting/DisplayList.h: 1030 -> 60
Painting/DisplayListRecorder.h: 557 -> 59
2025-02-23 10:14:39 -05:00
Jelle Raaijmakers
f204970052 LibWeb: Ignore fragments with pointer-events: none in hit-testing 2025-01-31 13:37:15 +01:00
Aliaksandr Kalenik
a4c331c199 LibWeb: Fix unnecessary wheel event consumption with overflow: scroll
Allow wheel event to be consumed by a `overflow: scroll` box only if it
has content that overflows a scrollport.

This fixes the timing issue in the
`Text/input/scroll-window-using-wheel-event.html` test, where a `<body>`
element with `overflow: scroll` was incorrectly consuming wheel events
that should have propagated to the window.
2025-01-31 00:11:34 +01:00
Aliaksandr Kalenik
74dde4dc0f LibWeb: Rename is_scrollable() to could_be_scrolled_by_wheel_event()
Previous name for misleading because it checks if box could be scrolled
by user input event which is diffent from checking if box is scrollable.
For example box with `overflow: hidden` is scrollable but it can't be
scrolled by user input event.
2025-01-31 00:11:34 +01:00
Jelle Raaijmakers
84c4702b10 LibWeb: Handle continuation chain during hit-testing instead of after it
My previous attempt at resolving the continuation chain tried to deal
with `pointer-events: none` by repeatedly falling back to the parent
paintable until one was found that _would_ want to handle pointer
events. But since we were no longer performing hit-tests on those
paintables, false positives could pop up. This could happen for
out-of-flow block elements that did not overlap with their parent rects,
for example.

This approach works much better since it only handles the continuation
case that's relevant (the "middle" anonymous box) and it does so during
hit-testing instead of after, allowing all the other relevant logic to
come into play.
2025-01-26 17:30:00 +01:00
Jelle Raaijmakers
b7a554d1f2 LibWeb: Reorder paintable hit-testing to account for pointer-events
Instead of ignoring any paintable immediately when they're invisible to
hit-testing, consider every candidate and while the most specific
candidate is invisible to hit-testing, traverse up to its parent
paintable.

This more closely reflects the behavior expected when wrapping block
elements inside inline elements, where although the block element might
have `pointer-events: none`, it still becomes part of the hit-test body
of the inline parent.

This makes the following link work as expected:

  <a href="https://ladybird.org">
    <div style="pointer-events: none">Ladybird</div>
  </a>
2025-01-23 09:33:10 +01:00
Jelle Raaijmakers
e076cb9b0e LibWeb: Simplify hit testing coordinate calculations
There are many simpler APIs that we can use here. No functional changes.
2025-01-23 09:33:10 +01:00
Jelle Raaijmakers
336684bc5c LibWeb: Support inserting non-inline elements into inline elements
Our layout tree requires that all containers either have inline or
non-inline children. In order to support the layout of non-inline
elements inside inline elements, we need to do a bit of tree
restructuring. It effectively simulates temporarily closing all inline
nodes, appending the block element, and resumes appending to the last
open inline node.

The acid1.txt expectation needed to be updated to reflect the fact that
we now hoist its <p> elements out of the inline <form> they were in.
Visually, the before and after situations for acid1.html are identical.
2025-01-23 09:33:10 +01:00
Jelle Raaijmakers
7eb4f3da37 LibGfx: Add Rect::unite()
The existing `::unite_horizontally()` and `::unite_vertically()` tests
did not properly test the edge cases where left/top in the Rect were
updated, so they get re-arranged a bit.
2025-01-23 09:33:10 +01:00
Tim Ledbetter
639ed5a052 WebContent+LibWeb: Add an option to disable painting viewport scrollbars 2025-01-15 12:33:53 +00:00
Gingeh
ce5cd012b9 LibWeb/CSS: Implement the color-scheme CSS property 2025-01-08 11:18:13 +00:00
Aliaksandr Kalenik
0b8b690f92 LibWeb+LibWebView: Allow to specify default font size in FontPlugin
Instead of always assuming 12pt size for default font, explicitly pass
it as a parameter.
2025-01-02 10:47:21 +01:00
Andreas Kling
4324439006 LibWeb: Reorder some checks in PaintableWithLines::hit_test for speed
In particular:

- Don't compute DOM node editability if we don't need it. This was 22%
  of CPU time when scrolling on Wikipedia.

- Defer inversion of transformed coordinates until we actually need
  them, after we've performed early returns.
2024-12-30 21:25:20 +01:00
Jelle Raaijmakers
4d9f17eddf LibGfx+LibWeb: Draw glyph runs with subpixel accuracy
This improves the quality of our font rendering, especially when
animations are involved. Relevant changes:

  * Skia fonts have their subpixel flag set, which means that individual
    glyphs are rendered at subpixel offsets causing glyph runs as a
    whole to look better.

  * Fragment offsets are no longer rounded to whole device pixels, and
    instead the floating point offset is kept. This allows us to pass
    through the floating point baseline position all the way to the Skia
    calls, which already expected that to be a float position.

The `scrollable-contains-table.html` ref test needed different table
headings since they would slightly inflate the column size in the test
file, but not the reference.
2024-12-21 23:09:52 +01:00
Lucien Fiorini
9fd1223992 LibWeb+LibGfx: Refactor CSS filters into LibGfx
CSS filters work similarly to canvas filters, so it makes sense to have
Gfx::Filter that can be used by both libraries in an analogous way
as Gfx::Color.
2024-12-18 18:54:20 +01:00
Jelle Raaijmakers
1c55153d43 LibWeb: Refactor "editable" and "editing host" concepts
The DOM spec defines what it means for an element to be an "editing
host", and the Editing spec does the same for the "editable" concept.
Replace our `Node::is_editable()` implementation with these
spec-compliant algorithms.

An editing host is an element that has the properties to make its
contents effectively editable. Editable elements are descendants of an
editing host. Concepts like the inheritable contenteditable attribute
are propagated through the editable algorithm.
2024-12-10 14:54:19 +01:00
Sam Atkins
00302b5b1e LibWeb/Painting: Place text cursor using GlyphRun font
This makes the cursor appear in the correct place when the text makes
use of multiple different fonts.
2024-12-06 02:57:34 +01:00
Sam Atkins
e457252c97 LibWeb/Painting: Use GlyphRun font for measuring selection rectangle
We incorrectly used the first available font to measure this before,
which may or may not be the correct font for this text.
2024-12-06 02:57:34 +01:00
Jonne Ransijn
acaf01bf7b LibWeb: Do not normalize border radii containing their initial values
Most computed border-radii contain their initial values, and since the
normalized initial border radii are always zero, there is no need to do
expensive floating point math to normalize them.
2024-12-04 08:30:22 +00:00
Pavel Shliak
dbfe5be9ff LibGfx: Delete DeprecatedPainter 2024-11-25 21:13:53 +01:00
Jonne Ransijn
a0fb092d94 LibWeb: Transform PaintableBox::hit_test positions
Elements with transforms were tested on their pre-transformed
positions, causing incorrect hits.

Copy the position transformation done in `StackingContext::hit_test`
to ensure that hit tests are done on the _actual_ position.
2024-11-23 22:06:32 +01:00
Jonne Ransijn
d2ca522540 LibWeb: Use is_viewport helper
This method exists precicely to simplify the check being done here,
so lets use it!
2024-11-23 22:06:32 +01:00
Andreas Kling
9a7c9286c4 LibWeb: Support individual scale CSS property 2024-11-22 20:06:44 +01:00
Andreas Kling
66a821e731 LibWeb: Support individual translate CSS property 2024-11-22 20:06:44 +01:00
Andreas Kling
6836d4edb1 LibWeb: Fix incomplete plumbing for individual rotate CSS property 2024-11-22 20:06:44 +01:00
Aliaksandr Kalenik
96a35767b6 LibWeb: Implement mask-image CSS property support
Implemented by reusing AddMask display list item that was initially
added for `background-clip` property.

Progress on flashlight effect on https://null.com/games/athena-crisis
2024-11-18 22:58:58 +01:00
Aliaksandr Kalenik
9f541c363d LibWeb: Allow stacking context to only be created by PaintableBox
For a while we used the wider Paintable type for stacking context,
because it was allowed to be created by InlinePaintable and
PaintableBox. Now, when InlinePaintable type is gone, we can use more
specific PaintableBox type for a stacking context.
2024-11-18 20:07:30 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Shannon Booth
1e54003cb1 LibJS+LibWeb: Rename Heap::allocate_without_realm to Heap::allocate
Now that the heap has no knowledge about a JavaScript realm and is
purely for managing the memory of the heap, it does not make sense
to name this function to say that it is a non-realm variant.
2024-11-13 16:51:44 -05:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibWeb/Painting/PaintableBox.cpp (Browse further)