Commit Graph

9511 Commits

Author SHA1 Message Date
Jamie Mansfield
53d7aa53a2 LibWeb: Use Enumerated for HTMLScriptElement.referrerPolicy 2024-06-07 09:54:19 +02:00
Jamie Mansfield
7ce35b75aa LibWeb: Implement should block mixed content response to request 2024-06-07 09:50:30 +02:00
Jamie Mansfield
2159377296 LibWeb: Upgrade mixed requests to potentially trustworthy URLs
(if appropriate)
2024-06-07 09:50:30 +02:00
Jamie Mansfield
8f0d035145 LibWeb: Implement should block mixed content request 2024-06-07 09:50:30 +02:00
Andrew Kaster
d90a9ab70c LibWeb: Add Web::UIEvents::KeyCode and KeyModifier enums, drop Kernel
This was the last Kernel header we had. Move the definitions we need
into a UIEvents header similar to MouseButton.
2024-06-07 09:44:41 +02:00
Enver Balalic
862fc91b2c LibWeb: Implement HTMLImageElement::decode with a few FIXMEs
Implements enough of HTMLImageElement::decode for it to not break
websites and actually load an image :)
2024-06-06 08:20:02 +02:00
Andrew Kaster
7b67fa706f DOM: Check for navigable destruction in declarative refresh timer
If the Document's navigable has been destroyed since we started this
timer, or it's no longer the active document of its navigable, we
shouldn't navigate to it.
2024-06-06 08:13:34 +02:00
Tim Ledbetter
c79041344d LibWeb: Ensure anchor node is not null when extending selection
Previously, clicking while holding shift without having previously made
any text selection would cause a crash.
2024-06-05 13:57:01 -04:00
Tim Ledbetter
f721230456 LibWeb: Extend text selection when left clicking and holding shift 2024-06-05 11:51:41 -04:00
Andreas Kling
f42c18bc4c LibGfx: Make Painter::target() return a Bitmap&
Painter always has a target bitmap, so let's return a reference.
2024-06-05 15:37:05 +02:00
Andreas Kling
fe4cc32380 Everywhere: Include <LibGfx/Painter.h> in fewer places
Touching Painter.h now rebuilds ~40 files instead of ~300.
2024-06-05 15:37:05 +02:00
Andreas Kling
0e47e5e265 LibGfx: Move Gfx::Painter::LineStyle => Gfx::LineStyle 2024-06-05 15:37:05 +02:00
Andreas Kling
57906a4e1b LibGfx: Move Gfx::Painter::WindingRule => Gfx::WindingRule 2024-06-05 15:37:05 +02:00
Andreas Kling
254d040ff4 LibGfx: Move Gfx::Painter::ScalingMode => Gfx::ScalingMode
This will allow users to avoid including Painter.h
2024-06-05 15:37:05 +02:00
Andreas Kling
6a96920dbc LibGfx: Remove Bitmap and Painter "scale" concept
We don't need intrinsic scale factors for Gfx::Bitmap in Ladybird,
as everything flows through the CSS / device pixel ratio mechanism.

This patch also removes various unused functions instead of adapting
them to the change.
2024-06-05 15:37:05 +02:00
Aliaksandr Kalenik
881e970846 LibWeb: Implement scrollbars dragging 2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
94eacf6da7 LibWeb: Remove did_request_scroll_to IPC call
No longer used after moving scrollbar painting into WebContent.
2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
cc3d95a356 LibWeb: Remove did_request_scroll IPC call
No longer used after moving scrollbar painting into WebContent.
2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
5285e22f2a LibWeb+WebContent: Move scrollbar painting into WebContent
The main intention of this change is to have a consistent look and
behavior across all scrollbars, including elements with
`overflow: scroll` and `overflow: auto`, iframes, and a page.

Before:
- Page's scrollbar is painted by Browser (Qt/AppKit) using the
  corresponding UI framework style,
- Both WebContent and Browser know the scroll position offset.
- WebContent uses did_request_scroll_to() IPC call to send updates.
- Browser uses set_viewport_rect() to send updates.

After:
- Page's scrollbar is painted on WebContent side using the same style as
  currently used for elements with `overflow: scroll` and
  `overflow: auto`. A nice side effects: scrollbars are now painted for
  iframes, and page's scrollbar respects scrollbar-width CSS property.
- Only WebContent knows scroll position offset.
- did_request_scroll_to() is no longer used.
- set_viewport_rect() is changed to set_viewport_size().
2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
eb909118bf LibWeb: Propagate scrollbar-width property from root element to viewport 2024-06-05 07:03:42 +02:00
Aliaksandr Kalenik
50920b0595 LibWeb: Scroll into viewport from a task in set_focused_element()
This is a hack needed to preserve current behaviour after making set
viewport_rect() being not async in upcoming changes.

For example both handle_mousedown and handle_mouseup should use the same
viewport scroll offset even though handle_mousedown runs focusing steps
that might cause scrolling to focused element:
- handle_mousedown({ 0, 0 })
  - run_focusing_steps()
  - set_focused_element()
  - scroll_into_viewport() changes viewport scroll offset
- handle_mouseup({ 0, 0 })
2024-06-05 07:03:42 +02:00
Jamie Mansfield
8e062a52a3 LibWeb: Move NetworkPartitionKey into a header
This is used elsewhere, such as the HTMLLinkElement.
2024-06-05 05:42:47 +01:00
Jamie Mansfield
2ffda00347 LibWeb: Implement HTMLImageElement.crossOrigin 2024-06-05 05:42:47 +01:00
Jamie Mansfield
d7d60268ec LibWeb: Implement HTMLLinkElement.crossOrigin 2024-06-05 05:42:47 +01:00
Jamie Mansfield
735859bc10 LibWeb: Implement HTMLLinkElement.fetchPriority 2024-06-05 05:42:47 +01:00
Jamie Mansfield
d1f884533e LibWeb: Update "create a link request" for spec changes
Fetch priority is added, and one line is split into two :)
2024-06-05 05:42:47 +01:00
Jamie Mansfield
21cf2c2981 LibWeb: Implement HTMLScriptElement.fetchPriority 2024-06-05 05:42:47 +01:00
Jamie Mansfield
8315ad6759 LibWeb: Implement HTMLImageElement.fetchPriority 2024-06-05 05:42:47 +01:00
Jamie Mansfield
956106c6d8 LibWeb: Add from_string function for request priority 2024-06-05 05:42:47 +01:00
Jamie Mansfield
2fde20adf9 LibWeb: Add IDL enum for fetch priority attribute 2024-06-05 05:42:47 +01:00
Andreas Kling
4822d1da4e LibWeb: Remove unused CRC2D::bitmap_font_fill_text() 2024-06-04 18:45:30 +02:00
Andreas Kling
d86f54da30 LibGfx: Remove Font::presentation_size()
This was a legacy version of point_size() that returned a u8.
2024-06-04 18:45:30 +02:00
Andreas Kling
1a2a34fa43 LibGfx: Remove Bitmap::glyph_spacing()
This was only ever non-zero for SerenityOS bitmap fonts.
2024-06-04 18:45:30 +02:00
Andreas Kling
04a6e2f83d LibWeb: Remove Gfx::BitmapFont
This class supported the binary bitmap font file format in SerenityOS,
and isn't something we need in Ladybird.
2024-06-04 18:45:30 +02:00
Andreas Kling
966d442152 LibWeb+Ladybird: Remove FontPluginSerenity (+ use Ladybird::FontPlugin) 2024-06-04 18:45:30 +02:00
Andreas Kling
fac126bce9 Ladybird+LibWeb: Stop using Gfx::FontDatabase default fonts
This closes the window at WebContent process startup where we were
relying on Gfx::FontDatabase having some resolvable value in its default
font query.
2024-06-04 18:45:30 +02:00
Andreas Kling
ba8945f6f3 LibWeb: Make DrawText paint command always have a font
Nobody ever tries to create one without a font anyway.
2024-06-04 18:45:30 +02:00
Andreas Kling
1b2d08ee7e LibGfx: Remove a bunch of unused classes 2024-06-04 18:45:30 +02:00
Simon Wanner
6b2c459901 LibTextCodec: Fix ISO-8859-1 vs. windows-1252 handling in web contexts
The Encoding specification maps ISO-8859-1 to windows-1252 and expects
the windows-1252 translation table to be used, which differs from
ISO-8859-1 for 0x80-0x9F.

Other contexts expect to get the actual ISO-8859-1 encoding, with 1-to-1
mapping to U+0000-U+00FF, when requesting it.

`decoder_for_exact_name` is introduced, which skips the mapping from
aliases to the encoding name done by `get_standardized_encoding`.
2024-06-04 10:21:07 +02:00
Simon Wanner
987910ad0f LibWeb: Bring TextDecoder constructor closer to spec 2024-06-04 10:21:07 +02:00
Andreas Kling
6321e97b09 AK: Remove various unused things 2024-06-04 09:19:39 +02:00
Andreas Kling
f2fd8fc928 Everywhere: Remove LibGemini
This hasn't been maintained (or worked at all) for a long time,
and it's not a widely supported protocol, so let's drop it.
2024-06-04 09:19:39 +02:00
Andreas Kling
e4cd91761d Everywhere: Remove LibMarkdown
This was used to convert markdown into HTML for display in the browser,
but no other browser behaves this way, so let's simplify things by
removing it.

(Yes, we could implement all kinds of "convert to HTML and display" for
every file format out there, but that's far outside the scope of a
browser engine.)
2024-06-04 09:19:39 +02:00
Jamie Mansfield
a419dcbe8b LibWeb/Fetch: Update "HTTP fetch" algorithm to latest spec comments
The spec and implementation's comments had diverged a little, this
brings them in line :)
2024-06-04 07:27:52 +02:00
Andreas Kling
e70d96e4e7 Everywhere: Remove a lot more things we don't need 2024-06-03 10:53:53 +02:00
Matthew Olsson
44bb6e8390 LibWeb: Handle the cssFloat and cssOffset keyframe properties properly 2024-06-03 10:53:32 +02:00
Matthew Olsson
36ceaf38d5 LibWeb: Check for nullish objects in process_a_keyframe algorithm 2024-06-03 10:53:32 +02:00
Matthew Olsson
37ee45db3d LibWeb: Use camelCase for JS keyframe objects 2024-06-03 10:53:32 +02:00
Matthew Olsson
b5c682bc2e LibWeb: Copy the keyframes in KeyframeEffect's copy constructor 2024-06-03 10:53:32 +02:00
Matthew Olsson
5b84bd6e45 LibWeb: Add DocumentOrShadowRoot::get_animations() 2024-06-03 10:53:32 +02:00
Matthew Olsson
37322baf54 LibWeb: Ensure all DocumentTimeline objects have the same time value
The DocumentTimeline constructor used the current millisecond time to
initialize its currentTime, but that means that a newly created timeline
would always have a different time value than other timelines that have
been through the update_animations_and_send_events function.
2024-06-03 10:53:32 +02:00
Andreas Kling
09980af4ea LibWeb: Add Web::UIEvents::MouseButton enum, drop dependency on LibGUI
This was the only thing LibWeb needed from LibGUI, and we can just
duplicate the enum in LibWeb and get rid of a bogus dependency.
2024-06-02 20:24:42 +02:00
Jamie Mansfield
295c4ef51a LibWeb/Fetch: Use MimeType in DataURL 2024-06-02 19:55:53 +02:00
Jamie Mansfield
2b59ba19e0 LibWeb/WebSockets: Use correct URL parser 2024-06-02 19:55:53 +02:00
Jamie Mansfield
48e834918a LibWeb/SVG: Implement SVGTransformList.numberOfItems 2024-06-02 19:55:53 +02:00
Jamie Mansfield
4a1d02e7d8 LibWeb/SVG: Implement SVGTransformList.length 2024-06-02 19:55:53 +02:00
Matthew Olsson
73aadddbc1 LibWeb: Reject invalid keyframe offset values 2024-06-02 16:07:12 +02:00
Matthew Olsson
e13cd914a9 LibWeb: Handle animating the 'all' property 2024-06-02 16:07:12 +02:00
Matthew Olsson
64ec66e209 LibWeb: Handle animating 'initial' property values 2024-06-02 16:07:12 +02:00
Matthew Olsson
2adb4c460d LibWeb: Change enum to enum class in KeyframeEffect 2024-06-02 16:07:12 +02:00
Matthew Olsson
6859826e3d LibWeb: Handle persisting an animation after it has been removed 2024-06-02 16:07:12 +02:00
Matthew Olsson
a80af938eb LibWeb: Support subtree option in Animatable.getAnimations() 2024-06-02 16:07:12 +02:00
Matthew Olsson
e2cb25e35c LibWeb: Support interpolation of mixed percentage dimension units 2024-06-02 15:12:17 +02:00
Diego
d906255cbb LibWasm: Improve table support
Implements `table.get`, `table.set`, `elem.drop`, `table.size`,
and `table.grow`. Also fixes a few issues when generating ref-related
spectests. Also changes the `TableInstance` type to use
`Vector<Reference>` instead of `Vector<Optional<Reference>>`, because
the ability to be null is already encoded in the `Reference` type.
2024-06-01 16:21:03 +02:00
Jamie Mansfield
e13b9bef5c LibWeb: Don't warn when 'scopes' is present in import maps
Another mistake I made when implementing import map support.
2024-06-01 07:42:48 -04:00
Jamie Mansfield
76eb7568c9 LibWeb: Set import map scopes when parsing 2024-06-01 07:42:48 -04:00
Timothy Flynn
b01e810a89 LibWeb+LibWebView+WebContent: Support case-insensitive find-in-page
This allows searching for text with case-insensitivity. As this is
probably what most users expect, the default behavior is changes to
perform case-insensitive lookups. Chromes may add UI to change the
behavior as they see fit.
2024-06-01 07:37:54 +02:00
Andreas Kling
a3782782fa LibJS: Remove two unused members from ExecutionContext 2024-05-31 16:31:33 +02:00
Andrew Kaster
46e00a8f5e LibWeb: Parse TokenizedFeatures from window.open 2024-05-30 16:16:33 -04:00
Andrew Kaster
e2d50dc5dd LibWeb: Move window.open TokenizedFeature parsing into its own file 2024-05-30 16:16:33 -04:00
Tim Ledbetter
79143833b6 LibWeb/WebDriver: Ensure error responses are serialized correctly 2024-05-30 13:53:24 -04:00
stelar7
a4e97c1598 WebDriver: Dont assume the pageLoad is an i64 2024-05-30 11:46:02 -04:00
stelar7
fa9c234976 WebDriver: Parse webSocketUrl capability 2024-05-30 11:46:02 -04:00
Matthew Olsson
9ea6ab0ad4 LibJS+LibWeb: Fix a ton of JS_CELL-like macro issues 2024-05-30 09:29:20 -06:00
Tim Ledbetter
7aea87c9df LibWeb+LibWebView+WebContent: Add basic find in page functionality
This allows the browser to send a query to the WebContent process,
which will search the page for the given string and highlight any
occurrences of that string.
2024-05-30 16:30:11 +02:00
Andrew Kaster
ca806a3e18 WebDriver+WebContent: Add /session/🆔/window/consume-user-activation
This extension to the WebDriver spec is defined in the HTML spec, how
fun.
2024-05-29 21:30:15 +02:00
Andrew Kaster
9bc1318a78 LibWeb: Consume user activation when showing a picker dialog 2024-05-29 21:30:15 +02:00
Andrew Kaster
a3a74245d6 LibWeb: Implement consume user activation AO 2024-05-29 21:30:15 +02:00
Andrew Kaster
45860e3878 LibWeb: Move consume history-action user activation to Window 2024-05-29 21:30:15 +02:00
Andrew Kaster
9c6ebe21d2 LibWeb: Remove get prefix from activation timestamp getters 2024-05-29 21:30:15 +02:00
Andrew Kaster
2fde20993b LibWeb: Update show the picker if applicable to latest spec text 2024-05-29 21:30:15 +02:00
Jamie Mansfield
7da449ce01 LibWeb: Check correct activation (spec fix)
See:
- https://github.com/whatwg/html/commit/d28284f
2024-05-29 09:32:59 -06:00
Jamie Mansfield
34b2a4f7ca LibWeb: Add getter for history-action activation 2024-05-29 09:32:59 -06:00
Jamie Mansfield
a741f68eb9 LibWeb: Implement "consume history-action user activation" 2024-05-29 09:32:59 -06:00
Jamie Mansfield
30539db2fc LibWeb: Use Infinity<double> for infinity
Co-authored-by: Matthew Olsson <matthewcolsson@gmail.com>
2024-05-29 09:32:59 -06:00
Jamie Mansfield
01bd179eef LibWeb: Implement UserActivation 2024-05-29 09:32:59 -06:00
Jamie Mansfield
227151b881 LibWeb: Add getter for sticky activation 2024-05-29 09:32:59 -06:00
Matthew Olsson
1965943026 LibWeb: Reject invalid AnimationEffect duration string values 2024-05-29 08:18:24 +02:00
Matthew Olsson
2bd8093449 LibWeb: Detect explicit null timeline given in KeyframeAnimationOptions
We already do this for the timeline argument in the KeyframeEffect
constructor
2024-05-29 08:18:24 +02:00
Matthew Olsson
7bd62809a9 LibWeb: Include leading colons in KeyframeEffect::pseudo_element() 2024-05-29 08:18:24 +02:00
Matthew Olsson
854d02fe10 LibWeb: Reject more invalid pseudo-element selectors in KeyframeEffect
The old way this was written wouldn't actually check for the presence of
the two initial colons in the pseudo-element string.
2024-05-29 08:18:24 +02:00
Matthew Olsson
e188ab1493 LibWeb: Add missing spec links to KeyframeEffect 2024-05-29 08:18:24 +02:00
Tim Ledbetter
bb923983fc LibWeb: Implement WorkerGlobalScope.importScripts()
This method allows workers to synchronously import one or more scripts.
2024-05-29 08:17:18 +02:00
Tim Ledbetter
975a067f58 LibWeb: Align worker ESO getters with the specification
The `api_base_url()` and `policy_container()` getters now get their
respective objects from the global scope.
2024-05-29 08:17:18 +02:00
Tim Ledbetter
2d487ee5ab LibWeb: Add spec comments to WorkerEnvironmentSettingsObject::setup()
No behavior change.
2024-05-29 08:17:18 +02:00
MacDue
9c711bc868 LibWeb+Ladybird: Add option to enable the AffineCommandExecutorCPU
This adds a `--experimental-cpu-transforms` option to Ladybird and
WebContent (which defaults to false/off).

When enabled the AffineCommandExecutorCPU will be used to handle
painting transformed stacking contexts (i.e. stacking contexts where
the transform is something other than a simple translation). The regular
command executor will still handle the non-transformed cases.

This is hidden under a flag as the `AffineCommandExecutorCPU` is very
incomplete now. It missing support for clipping, text, and other basic
commands. Once most common commands have been implemented this flag
will be removed.
2024-05-29 08:17:01 +02:00
MacDue
b9db9013f5 LibWeb: Add (initial) AffineCommandExecutorCPU
This CommandExecutor is intended to provide better support for painting
stacking contexts where the transform is not a simple translation. It
is not intended to replace the CPU command executor (as its methods of
painting will likely be slower for the non-transformed case), instead,
it will function as a companion executor to handle transformations.

This is only intended to properly handle 2D transformations (skews,
rotations, scaling, etc). Full support for 3D transformations would
need further changes in LibGfx.

As it stands this is (very) incomplete and experimental, but hopefully,
this can be fleshed out to the point where it supports most common
painting commands.
2024-05-29 08:17:01 +02:00
MacDue
6333159108 LibWeb: Add support for nested painting command executors
This adds two new CommandResults: ContinueWithNestedExecutor and
ContinueWithParentExecutor.

ContinueWithNestedExecutor switches the command executor to the result
of calling `.nested_executor()` on the current CommandExecutor.

ContinueWithParentExecutor returns to the previous command executor
(i.e. what it was before the last ContinueWithNestedExecutor).
2024-05-29 08:17:01 +02:00
MacDue
f7bf14605c LibWeb: Remove PaintBorders recording painter command
`Painting::paint_all_borders()` only uses `.draw_line()` for simple
borders and `.fill_path()` for more complex cases. These are both
already supported by the `RecordingPainter` so removing this command
simplifies the painting API.

Two test changes:

css-background-clip-text: Borders are now drawn via the AA painter
(which makes them closer to how they appear in other browsers).

corner-clip-inside-scrollable: Borders removed (does not change test)
due to imperceptible sub-pixel changes.
2024-05-29 08:17:01 +02:00
Aliaksandr Kalenik
b8d18ebcf7 LibWeb+WebContent: Change event loop to synchronously paint next frame
...instead of scheduling repaint timer in PageClient.

This change fixes flickering on Discord that happened because:
- Event loop schedules repainting by activating repaint timer
- `Document::tear_down_layout_tree()` destroys paintable tree
- Repaint timer invokes callback and renders an empty frame because
  paintable tree was destroyed
2024-05-28 18:21:18 +02:00
Aliaksandr Kalenik
e806136116 LibWeb: Refresh clip and scroll state only when needed
Although refreshing is cheap, it was performed before each hit-testing
and was 2-4% in profiles on Discord and Twitter.

Now clip and scroll states are refreshed only if scroll offset has
changed.
2024-05-28 17:45:49 +02:00
Tim Ledbetter
d6297ec074 LibWeb: Cast to the correct type in Element::auto_directionality()
Previously, we always cast to a HTMLInputElement when getting the value
of an auto directionality form associated element. This caused
undefined behavior when determining the directionality of an element
that wasn't a HTMLInputElement.
2024-05-28 09:51:07 +02:00
Tim Ledbetter
0b0ad5c9db LibWeb: Calculate width property resolved value correctly
This means that relative width values are now correctly resolved when
calling `getComputedStyle()`.
2024-05-28 08:08:31 +02:00
Tim Ledbetter
7d192ed8c1 LibWeb: Don't crash on clicking a label with an associated text input
Previously, we assumed that all label control paintables were of type
`LabelablePaintable`. This caused a crash when clicking on a label with
a text input control.
2024-05-28 08:07:05 +02:00
Shannon Booth
6466fca20a LibWeb: Implement BaseAudioContext.createGain 2024-05-28 08:06:09 +02:00
Shannon Booth
1fa7235fec LibWeb: Add Implement GainNode interface
As with all other current audio nodes we still need to wire up the
inputs and outputs so it can be properly used in an audio context - but
this is enough to implement the public IDL interface.
2024-05-28 08:06:09 +02:00
Shannon Booth
97bf9e7953 LibWeb: Stub out Window-Management proposal extensions to Screen API
As defined in https://w3c.github.io/window-management
2024-05-27 17:24:51 -06:00
Simon Wanner
3029406c4b LibWeb: Handle TextDecoder's fatal flag 2024-05-27 20:50:50 +02:00
Jamie Mansfield
3095daa7c8 LibWeb: Implement HTMLImageElement.currentSrc
Removes some console noise from lner.co.uk :)
2024-05-27 17:34:59 +02:00
Jamie Mansfield
600daea544 LibWeb: Implement HTMLIFrameElement.loading 2024-05-27 17:34:59 +02:00
Jamie Mansfield
9ee061ea14 LibWeb: Implement HTMLImageElement.loading
Removes some console noise while loading mmu.ac.uk :)
2024-05-27 17:34:59 +02:00
Jamie Mansfield
c484625631 LibWeb: Add IDL enum for lazy loading attribute 2024-05-27 17:34:59 +02:00
Aliaksandr Kalenik
f989ebe180 LibWeb: Replace visit() with ifelseif chain in CommandList::execute()
Deeply nested stack traces caused by using visit() were really hard to
read in profiles.
2024-05-27 17:33:40 +02:00
Aliaksandr Kalenik
eff9bbf4c8 LibWeb: Pass whole command by reference into painting command executor
Now after making a change in a painting command we could avoid updating
method's parameters list across 3 classes.
2024-05-27 17:33:40 +02:00
Andreas Kling
802af5ad9d LibWeb: Allow Element.insertAdjacentHTML on the document element
This fixes wpt/domparsing/insert_adjacent_html.html
2024-05-27 17:33:29 +02:00
Andreas Kling
f12dae7ea4 LibWeb: Update spec link & comments in Element.insertAdjacentHTML()
This has moved from DOM Parsing to HTML, and the comments are slightly
different.
2024-05-27 17:33:29 +02:00
Andreas Kling
e7febd347b LibWeb: Don't advertise the empty string as HTMLCollection property name
This fixes wpt/dom/collections/HTMLCollection-empty-name.html
2024-05-27 17:33:29 +02:00
Aliaksandr Kalenik
0eeae7ff24 LibWeb: Use stack to represent blit/sample corners commands state
...instead of allocating separate BorderRadiusCornerClipper for each
executed sample/blit commands pair.

With this change a vector of BorderRadiusCornerClipper has far fewer
items. For example on twitter profile page its size goes down from
~3000 to ~3 items.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik
9b65a2731b LibWeb: Remove clipper creation error check in sample_under_corners()
Before, this check was needed to prevent crashing when attempting to
allocate zero-size bitmap for sampled corners, which could have happened
if a corner had 0 radius in one axis.

Now, since SampleUnderCorners command is not emmited when radius is 0
in one axis, this check is no longer needed.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik
9be65e35b5 Revert "LibGfx+LibWeb: Do not ignore corner radius if it is defined..."
This reverts commit 6b7b9ca1c4b32e76e0afef6bca0cb300e615b576.

The whole corner radius is invisible if it has 0 radius in any axis, so
the reverted commit was a mistake that led to error checking during
painting command execution b61aab66d9 to
avoid crashing on attempt to allocate 0 size bitmap.
2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik
49f75d2c0f LibWeb: Verify each sample corners command has matching blit command 2024-05-27 04:26:17 +02:00
Aliaksandr Kalenik
1a6cf7fadc LibWeb: Fix blit corner clipping command recording order
Before:
- sample corners id = 0
- sample corners id = 1
- sample corners id = 2
- blit corners   id = 0
- blit corners   id = 1
- blit corners   id = 2

After:
 - sample corners id = 0
 - sample corners id = 1
 - sample corners id = 2
 - blit corners   id = 2
 - blit corners   id = 1
 - blit corners   id = 0
2024-05-27 04:26:17 +02:00
Timothy Flynn
eb3b8f8ee4 LibWeb: Implement EventSource for server-sent events
EventSource allows opening a persistent HTTP connection to a server over
which events are continuously streamed.

Unfortunately, our test infrastructure does not allow for automating any
tests of this feature yet. It only works with HTTP connections.
2024-05-26 18:29:24 +02:00
Timothy Flynn
79223f3e1b LibWeb: Correctly check the document's salvageable state during cleanup
The condition here was flipped.
2024-05-26 18:29:24 +02:00
Timothy Flynn
88d46b51ed LibWeb: Implement operation to error a ReadableStream 2024-05-26 18:29:24 +02:00
Timothy Flynn
2a2c59e74b LibWeb: Partially implement the ReadableStream pull-from-bytes AO
We do not handle BYOB request views yet, as they are not needed for the
upcoming usage of this AO.
2024-05-26 18:29:24 +02:00
Timothy Flynn
9cc186b929 LibWeb: Implement the "queue a task" steps as a distinct AO
This will be needed by EventSource.
2024-05-26 18:29:24 +02:00
Timothy Flynn
6056428cb5 LibWeb: Support unbuffered fetch requests
Supporting unbuffered fetches is actually part of the fetch spec in its
HTTP-network-fetch algorithm. We had previously implemented this method
in a very ad-hoc manner as a simple wrapper around ResourceLoader. This
is still the case, but we now implement a good amount of these steps
according to spec, using ResourceLoader's unbuffered API. The response
data is forwarded through to the fetch response using streams.

This will eventually let us remove the use of ResourceLoader's buffered
API, as all responses should just be streamed this way. The streams spec
then supplies ways to wait for completion, thus allowing fully buffered
responses. However, we have more work to do to make the other parts of
our fetch implementation (namely, Body::fully_read) use streams before
we can do this.
2024-05-26 18:29:24 +02:00
Timothy Flynn
1e97ae66e5 LibWeb: Support unbuffered resource load requests
This adds an alternate API to ResourceLoader to load HTTP/HTTPS/Gemini
requests unbuffered. Most of the changes here are moving parts of the
existing ResourceLoader::load method to helper methods so they can be
re-used by the new ResourceLoader::load_unbuffered.
2024-05-26 18:29:24 +02:00
Timothy Flynn
168d28c15f LibProtocol+Userland: Support unbuffered protocol requests
LibWeb will need to use unbuffered requests to support server-sent
events. Connection for such events remain open and the remote end sends
data as HTTP bodies at its leisure. The browser needs to be able to
handle this data as it arrives, as the request essentially never
finishes.

To support this, this make Protocol::Request operate in one of two
modes: buffered or unbuffered. The existing mechanism for setting up a
buffered request was a bit awkward; you had to set specific callbacks,
but be sure not to set some others, and then set a flag. The new
mechanism is to set the mode and the callbacks that the mode needs in
one API.
2024-05-26 18:29:24 +02:00
Timothy Flynn
086ddd481d Ladybird+LibWeb: Move User-Agent definitions to their own file
This is to avoid including any LibProtocol header in Objective-C source
files, which will cause a conflict between the Protocol namespace and a
@Protocol interface.

See Ladybird/AppKit/Application/ApplicationBridge.cpp for why this
conflict unfortunately cannot be worked around.
2024-05-26 18:29:24 +02:00
Aliaksandr Kalenik
663cc753a7 LibWeb: Fix clip box calculation in PaintableWithLines
All painting commands except SetClipRect are shifted by scroll offset
before command list execution. This change removes scroll offset
translation for sample/blit corner commands in
`PaintableWithLines::paint` so it is only applied once in
`CommandList::apply_scroll_offsets()`.
2024-05-26 16:11:53 +01:00
Aliaksandr Kalenik
7855d4a8f5 LibWeb: Transform blit corner clipping rectangle to device pixels
Rectangle saved in this command is only used to filter by bounding box,
so the problem was not very visible before.
2024-05-26 16:11:53 +01:00
Aliaksandr Kalenik
3d8349eb88 LibWeb: Fix blit corner clip position in PaintableWithLines
Fixes the bug when blit and sample commands position didn't match.

Before:
1. Emit sample under corners
2. Apply scroll offset
3. Paint content
3. Blit corner clipping

After:
1. Emit sample under corners
2. Save state
3. Apply scroll offset
4. Paint content
5. Restore state
6. Blit corner clipping
2024-05-26 16:11:53 +01:00
MacDue
9e2c4f84fd LibWeb: Paint/apply basic-shape clip paths to PaintableBoxes
Currently, these only work when there are no CSS transforms (as the
stacking context painting is not set up to handle that case yet). This
is still enough to get most chat/comment markers working on GitHub
though :^)
2024-05-26 07:55:50 +02:00
MacDue
517379ff80 LibWeb: Resolve basic-shape clip-paths
These will be ignored within SVGs (for now SVGs only support <clipPath>
elements), but will allow clipping standard HTML elements.
2024-05-26 07:55:50 +02:00
MacDue
0135af6e60 Meta: Add basic-shape as a CSS property value type 2024-05-26 07:55:50 +02:00
MacDue
120915048c LibWeb: Parse the polygon() basic shape function 2024-05-26 07:55:50 +02:00
MacDue
5f17d9b34a LibWeb: Add BasicShapeStyleValue to represent CSS basic shapes
See: https://www.w3.org/TR/css-shapes-1/#basic-shape-functions

This patch only implements the `polygon()` basic shape (with the rest
left as FIXMEs).
2024-05-26 07:55:50 +02:00
Shannon Booth
71ccd8ad25 LibWeb: Implement BaseAudioContext.createBuffer
This is a simple factory function which effectively just calls the
AudioBuffer constructor.
2024-05-26 07:49:49 +02:00
Shannon Booth
17ae65cedc LibWeb: Implement AudioBuffer.copyToChannel 2024-05-26 07:48:37 +02:00
Shannon Booth
848d6f5074 LibWeb: Add const qualified BufferableObjectBase::raw_object 2024-05-26 07:48:37 +02:00
Shannon Booth
67b1f4af55 LibWeb: Implement HTMLFormElement.encoding 2024-05-26 07:47:59 +02:00
Shannon Booth
aeb815cc66 LibWeb: Implement HTMLFormElement.enctype 2024-05-26 07:47:59 +02:00
Matthew Olsson
a8ef84f8c3 LibWeb: Use LengthPercentage for calc values in Transformation matrix 2024-05-25 22:19:47 +02:00
Aliaksandr Kalenik
e2b2b2439c LibWeb: Apply corner clip before scroll offset for PaintableWithLines
Fixes bug when corner clip mask moves along with the scrolled text.
2024-05-25 22:19:40 +02:00
Aliaksandr Kalenik
c413cd0f74 LibWbe: Skip recording of empty painting commands
- Less allocations
- Optimization pass that skips unnecessary sample/blit corner commands
  could be more effecient by ignoring corner radius clipping for empty
  painting commands
2024-05-24 12:34:52 +02:00
Aliaksandr Kalenik
3f3f3766be LibWeb: Make sample_under_corners() go faster
Both page target bitmap and mask bitmap are always BGRA8888, so we can
use `get_pixel<StorageFormat::BGRA8888>` and
`set_pixel<StorageFormat::BGRA8888>` to avoid branching by not
checking a bitmap format.
2024-05-24 12:34:52 +02:00
Matthew Olsson
15a8baee03 LibWeb: Save time for animationcancel event before transitioning to idle
The if statement in the dispatch implies we are in the idle state, so of
course the active time will always be undefined. If this was cancelled
via a call to cancel(), we can save the time at that point. Otherwise,
just send 0.
2024-05-24 07:25:10 +02:00
Lucas CHOLLET
b30c361b08 LibWeb/Fetch: Implement logic to process a response from HTTP's cache
Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2024-05-23 13:25:29 -04:00