Commit Graph

8235 Commits

Author SHA1 Message Date
MacDue
38855de829 LibWeb: Use 'now' from EventLoop for animation frame callbacks
Previously, 'now' was set to the time `requestAnimationFrame()` was
called, and the EventLoop's 'now' was ignored. This was a little odd and
meant the time was always in the past.
2024-02-11 08:10:45 +01:00
Tim Ledbetter
0577a664dd LibWeb: Use correct offset value when replacing character data
Previously, the range's end offset was being set using it's previous
value.
2024-02-10 11:18:51 +01:00
Aliaksandr Kalenik
40246adfb9 LibWeb: Add internals.wheel() to simulate mouse wheel events
This function allows us to write tests for scrolling scenarios where
the events are processed by the EventHandler.
2024-02-10 11:18:40 +01:00
Aliaksandr Kalenik
76d1536307 LibWeb: Optimize scroll offset and clip state recalculation
In this commit we have optimized the handling of scroll offsets and
clip rectangles to improve performance. Previously, the process
involved multiple full traversals of the paintable tree before each
repaint, which was highly inefficient, especially on pages with a
large number of paintables. The steps were:

1. Traverse the paintable tree to identify all boxes with scrollable or
   clipped overflow.
2. Gather the accumulated scroll offset or clip rectangle for each box.
3. Perform another traversal to apply the corresponding scroll offset
   and clip rectangle to each paintable.

To address this, we've adopted a new strategy that separates the
assignment of the scroll/clip frame from the refresh of accumulated
scroll offsets and clip rectangles, thus reducing the workload:

1. Post-relayout: Identify all boxes with overflow and link each
   paintable to the state of its containing scroll/clip frame.
2. Pre-repaint: Update the clip rectangle and scroll offset only in the
   previously identified boxes.

This adjustment ensures that the costly tree traversals are only
necessary after a relayout, substantially decreasing the amount of work
required before each repaint.
2024-02-09 16:45:44 +01:00
Aliaksandr Kalenik
fc40d35012 LibWeb: Move paint properties invalidation flag into Document
Move paint-only properties invalidation flag to Document for
consistency, as style and layout invalidation flags are already
managed there.
2024-02-09 16:45:44 +01:00
ronak69
05e53b5fd3 LibWeb: Use file's URL as document's URL when loading markdown files
A markdown file gets loaded as an inline content document by
`create_document_for_inline_content()`, for which the default document
URL is "about:error". That breaks the fragment links.

Overriding "about:error" URL by passing the URL of the just loaded
markdown file as an argument to `HTMLParser::run()` ensures that the URL
of the document is as expected.
2024-02-08 07:58:07 -07:00
Andrew Kaster
53273e2037 LibWeb: Don't navigate() to about:blank when making a fresh Traversable
This matches the behavior of the window open steps, and should probably
be a spec issue :yakplus:
2024-02-08 15:53:46 +01:00
Andrew Kaster
889b903e40 LibWeb: Call the_end() on Documents from window.open("about:blank") 2024-02-08 15:53:46 +01:00
Andrew Kaster
bc9c710904 LibWeb: Hide WebDriver::match_route debug behind its own flag
When enabling WEBDRIVER_DEBUG globally, this function's debug spam
overpowers the rest of the useful logs.
2024-02-08 15:53:46 +01:00
Aliaksandr Kalenik
ff3e454565 LibWeb: Invalidate paint-only property after relayout
Before this change, `set_needs_to_resolve_paint_only_properties()` was
only called after style invalidation. However, since relayout can be
triggered independently from style invalidation, we need to ensure that
paint-only properties are updated in that case too.
2024-02-08 13:08:10 +01:00
Aliaksandr Kalenik
4a41a65ec5 LibWeb: Shift button paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Aliaksandr Kalenik
d43dbe2842 LibWeb: Shift SVG paintable clip rectangle by scroll offset
Rectangles should be recorded using absolute coordinates, including
the scroll offset.
2024-02-06 13:06:16 +01:00
Tim Ledbetter
69df94ec5c LibWeb: Implement document.elementFromPoint()
This function uses our existing hit testing code to determine the
topmost element at the given coordinates relative to the viewport.
2024-02-06 08:43:03 +01:00
Matthew Olsson
c732e03ea0 LibWeb: Add missing implementation of method in AnimationTimeline 2024-02-06 08:42:07 +01:00
Matthew Olsson
df4be9a479 LibWeb: Add missing virtual destructor in AnimationEffect 2024-02-06 08:42:07 +01:00
Matthew Olsson
154b4d4196 LibWeb: Invalidate style of animation targets in update_finished_state 2024-02-06 08:42:07 +01:00
Matthew Olsson
a7727215a6 LibWeb: Implement missing members of AnimationEffect.getComputedTiming() 2024-02-06 08:42:07 +01:00
Matthew Olsson
360082544c LibWeb: Fix incorrect Animation active_time in the after phase 2024-02-06 08:42:07 +01:00
Matthew Olsson
16a21a503d LibWeb: Fix incorrect comparison in Animation::update_finished_state 2024-02-06 08:42:07 +01:00
Matthew Olsson
2e29b0d700 LibWeb: Rename confusing parameter in AnimationPlaybackEvent 2024-02-06 08:42:07 +01:00
Matthew Olsson
8c80d0ee02 LibWeb: Fix typo (original_relative_time -> origin_relative_time) 2024-02-06 08:42:07 +01:00
Matthew Olsson
a27dd03dcc LibWeb: Avoid slicing struct in KeyframeEffect::construct_impl 2024-02-06 08:42:07 +01:00
Aliaksandr Kalenik
7411f66fcf LibWeb/CSS: Resolve value of "height" in special way according to spec
Per spec value of height should be resolved to used value if "display"
property is not "none" or "contents".
2024-02-06 08:41:21 +01:00
Timothy Flynn
747fd86f26 LibWeb: Make WebDriver check if the BC's navigable has been destroyed
The spec steps to check if a browsing context is open have been updated
for navigables.
2024-02-06 08:40:27 +01:00
Aliaksandr Kalenik
623ad94582 LibWeb: Resolve effective overflow-x and overflow-y according to spec
Implements following rule from CSS Overflow Module Level 3:
"The visible/clip values of overflow compute to auto/hidden
(respectively) if one of overflow-x or overflow-y is neither visible
nor clip."
2024-02-06 08:39:06 +01:00
Shannon Booth
b6292a2d7d LibWeb: Use WebIDL integer typedefs in ProgressEvent 2024-02-06 08:35:53 +01:00
Shannon Booth
3e756da564 LibWeb: Use unsigned long long for ProgressEventInit
The IDL generator now supports this :^)
2024-02-06 08:35:53 +01:00
Andrew Kaster
813c66403d LibWeb: Catch null browsing context in destroy_top_level_traversable
When WebDriver asks to destroy a window, we can hit this case with no
active browsing context. This seems odd, but perhaps is a spec issue as
well. Just log to dbgln for now.
2024-02-05 08:05:48 -07:00
Andrew Kaster
d508a02f25 LibWeb: Ensure that load events are fired for window.open('about:blank') 2024-02-05 08:05:48 -07:00
Andrew Kaster
888e67992a LibWeb: Remove unused BrowsingContext functions and data members
This aligns it better with the current state of the spec.

There's still some functions and data members that need moved into
Navigable or TraversableNavigable, but we can leave those for the next
cleanup PR.
2024-02-05 08:05:48 -07:00
Andrew Kaster
9645daaf6c LibWeb: Remove RemoteBrowsingContext and AbstractBrowsingContext
With the transition to Navigables, and a working implementation of
window.open(), we no longer need this abstraction layer.
2024-02-05 08:05:48 -07:00
Andrew Kaster
6e75440d5a LibWeb: Bring Document::fallback_base_url closer to the spec 2024-02-05 08:05:48 -07:00
Andrew Kaster
5d9d0aa267 LibWeb: Replace check for BrowsingContext's about blank state with false
This check has been if (false && stuff) for quite a while, since the
transition to Navigables. No one updates the BrowsingContext's session
history, so the check for it having an about blank document and only an
about blank document is always false.
2024-02-05 08:05:48 -07:00
Andrew Kaster
b6fc29ca21 LibWeb: Always use Navigable to translate CSS positions to top-level 2024-02-05 08:05:48 -07:00
Andrew Kaster
3aee787539 LibWeb+WebContent: Convert WebDriver to choose a navigable AO
Also use the TraversableNavigable's window_handle instead of the
BrowsingContext's.
2024-02-05 08:05:48 -07:00
Andrew Kaster
36cd2fb7c5 Ladybird+WebContent: Update IPC calls to handle multiple traversables
The IPC layer between chromes and LibWeb now understands that multiple
top level traversables can live in each WebContent process.

This largely mechanical change adds a billion page_id/page_index
arguments to make sure that pages that end up opening new WebViews
through mechanisms like window.open() still work properly with those
extra windows.
2024-02-03 20:51:37 -05:00
Andrew Kaster
adb5c27331 LibWeb: Create a new WebView for window.open()'d top level traversables 2024-02-03 20:51:37 -05:00
Andrew Kaster
677bdc2a4f Ladybird: Add IPC call for creating a new child tab
This will be used for choosing a navigable that requires opening a new
tab or new window. Such as calls to window.open(), or specific WebDriver
calls.
2024-02-03 20:51:37 -05:00
Timothy Flynn
5d1657f57f LibWeb: Implement implicit submission of HTMLFormElement 2024-02-03 15:30:16 -07:00
Timothy Flynn
a17074422e LibWeb: Reset form association when any element with an ID changes
When an element with an ID is added to or removed from the DOM, or if
an ID is added, removed, or changed, then we must reset the form owner
of all form-associated elements who have a form attribute.

We do this in 2 steps, using the DOM document as the messenger to handle
these changes:

1. All form-associated elements with a form attribute are stored on the
   document. If the form attribute is removed, the element is removed
   from that list as well.

2. When a DOM element with an ID undergoes any of the aforementioned
   changes, it notifies the document of the change. The document then
   forwards that change to the stored form-associated elements.
2024-02-03 15:30:16 -07:00
Timothy Flynn
960dcf0e56 LibWeb: Reset form association when the element's form attribute changes 2024-02-03 15:30:16 -07:00
Timothy Flynn
23fb1209af LibWeb: Add FormAssociatedElement to the forwarding header 2024-02-03 15:30:16 -07:00
Timothy Flynn
fb270289a4 LibWeb: Store HTMLFormElement associated elements as nonnull GC pointers
We never store null elements in this list, so let's avoid confusion and
store the elements as NonnullGCPtr.
2024-02-03 15:30:16 -07:00
Timothy Flynn
c5f8f940f0 LibWeb: Convert some tabs to spaces in an HTMLFormElement comment block 2024-02-03 15:30:16 -07:00
Tim Ledbetter
d73979e0a8 LibWeb: Don't update input text if Ctrl or Alt are pressed
With this change, input elements ignore keypresses while Ctrl or Alt
are pressed. This matches the behavior of Chrome and Firefox
2024-02-03 14:07:37 -05:00
Aliaksandr Kalenik
36553d4566 LibWeb: Do not add CSS transforms into clip rect in PaintableWithLines
Painting command executor already accounts for CSS transforms so clip
rect only needs to be adjusted by scroll offset.
2024-02-03 20:05:09 +01:00
Aliaksandr Kalenik
7ad0767aa0 LibWeb: Remove BrowsingContext::scroll_to()
Let's use navigable directly instead of going through browsing context
to request a scroll.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
0c92c80544 LibWeb: Redirect wheel events to iframe if needed in EventHandler 2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
bf14de4118 LibWeb: Remove direct calls of page_did_request_scroll_to()
By replacing the `page_did_request_scroll_to()` calls with a request
to perform scrolling in the corresponding navigable, we ensure that
the scrolling of iframes will scroll within them instead of triggering
scroll of top level document.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
607e4cab0a LibWeb: Use associated navigable in scrollX and scrollY in Window
If these functions are invoked from inside an iframe, we should use
the navigable associated with the iframe to get the viewport.
2024-02-03 19:00:26 +01:00