Commit graph

1376 commits

Author SHA1 Message Date
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 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
MacDue 18d39deefe Tests/LibWeb: Add ref test for clip-path: polygon(...) 2024-05-26 07:55:50 +02:00
Shannon Booth 17ae65cedc LibWeb: Implement AudioBuffer.copyToChannel 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
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
Andreas Kling f4636a0cf5 LibWeb: Stop spamming animation events on the wrong event target
This patch fixes two issues:

- Animation events that should go to the target element now do
  (some were previously being dispatched on the animation itself.)
- We update the "previous phase" and "previous iteration" fields of
  animation effects, so that we can actually detect phase changes.
  This means we stop thinking animations always just started,
  something that caused each animation to send 60 animationstart
  events every second (to the wrong target!)
2024-05-23 12:10:06 +02:00
Andrew Kaster bab546472e LibWeb: Mark FontFaceSet as a setlike IDL interface
And implement more of the constructor logic.
2024-05-23 10:57:34 +02:00
Tim Ledbetter d2b3007248 IDLGenerators: Use spec-compliant algorithm to parse integer values 2024-05-23 04:15:46 +02:00
Tim Ledbetter 2a7cf1c588 LibWeb: Implement the width and height attributes where missing
This change adds the `width` and `height` properties to
`HTMLVideoElement` and `HTMLSourceElement`. These properties reflect
their respective content attribute values.
2024-05-21 19:28:43 +02:00
Tim Ledbetter 9f9aa62128 LibWeb: Implement the hspace and vspace attributes
These properties reflect their respective content attributes.
2024-05-21 19:28:43 +02:00
Kenneth Myhra e2c4019bfc LibWeb: Close acquired writer in AO readable_stream_pipe_to()
Also adds a test to prove that the WritableStream's close callback is
called.
2024-05-20 16:57:52 -04:00
Tim Ledbetter a6d6729034 LibWeb: Implement the MouseEvent.relatedTarget attribute
This returns the secondary target of a mouse event. For `onmouseenter`
and `onmouseover` events, this is the EventTarget the mouse exited
from. For `onmouseleave` and `onmouseout` events, this is the
EventTarget the mouse entered to.
2024-05-20 08:21:41 +02:00
Jamie Mansfield 08a3904309 LibWeb/MimeSniff: Implement "minimize a supported MIME type"
See:
- https://github.com/whatwg/mimesniff/commit/227a469
2024-05-19 16:25:50 +02:00
Shannon Booth 3ccbc83168 LibWeb: Add a stubbed slot for DynamicsCompressorNode.reduction
For now, this slot is always 0 - (the default value per spec). But
once we start actually processing audio streams this internal slot
should be changed correspondingly.
2024-05-19 09:26:20 +02:00
Shannon Booth cf615cbd1c LibWeb: Add AudioParams for DynamicsCompressorNode 2024-05-19 09:26:20 +02:00
Shannon Booth ccdf82c9be LibWeb: Implement scrollIntoView with 'center' block position
This fixes a crash on:

https://docs.github.com/en/get-started/learning-about-github/githubs-plans
2024-05-19 07:22:17 +02:00
Shannon Booth dd20156010 LibWeb: Fix division by zero on a zero-height viewport SVG image 2024-05-19 07:19:42 +02:00
Shannon Booth d48316ce15 LibWeb: Fix division by zero on a zero-width viewport SVG image
We were previously crashing by a division by zero due to an aspect ratio
of zero on https://comicbookshop.co.nz/
2024-05-19 07:19:42 +02:00
Tim Ledbetter c36ba450be LibWeb: Generate binding for HTMLObjectElement.contentWindow attribute
This only required adding the appropriate definition to the IDL file,
as `NavigableContainer` already implements the logic that we need.
2024-05-18 18:12:08 +02:00
Tim Ledbetter 2447a25753 LibWeb: Implement the labels attribute for all labelable elements
This returns a `NodeList` of all the labels associated with the given
element.
2024-05-18 18:09:18 +02:00
Tim Ledbetter 3dc86747f0 LibWeb: Implement the HTMLOutputElement.htmlFor attribute
This returns a DOMTokenList that reflects the `for` attribute.
2024-05-18 11:23:20 +02:00
Tim Ledbetter acc1fa3c62 LibWeb: Generate binding for the HTMLObjectElement.form attribute
This only required adding the appropriate definition to the IDL file,
as `FormAssociatedElement` already implements the logic that we need.
2024-05-18 11:04:04 +02:00
Tim Ledbetter 6bf22075ed LibWeb: Implement the HTMLLabelElement.form attribute
This returns the form element associated with the given label element's
control or null if the label has no control.
2024-05-18 11:04:04 +02:00
Tim Ledbetter d0555f3176 LibWeb: Flesh out DOMTokenList::supports() implementation
This change makes `DOMTokenList::supports()` work as expected for
`relList` attributes.
2024-05-16 20:31:23 +02:00
Tim Ledbetter 51fc30a191 LibWeb: Implement the HTMLLinkElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter fc4e0cf10e LibWeb: Implement the HTMLFormElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter 0a3e1846f0 LibWeb: Implement the HTMLAreaElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter b7fd39c2e6 LibWeb: Implement the HTMLAnchorElement.relList attribute
This returns a DOMTokenList that reflects the `rel` attribute.
2024-05-16 08:06:26 +02:00
Tim Ledbetter 763b7f0e0c LibWeb: Implement the HTMLOptionElement.form attribute
This returns the parent form of a HTMLOptionElement or null if the
element has no parent form.
2024-05-16 08:03:13 +02:00
Andrew Kaster 28f728dfdb LibWeb: Implement FontFace.load() for url() based font sources 2024-05-16 08:02:43 +02:00
MacDue 6c9069fa5d LibWeb: Implement the SVG clip-rule attribute
This controls the fill rule used when rasterizing `<clipPath>` elements.
2024-05-14 23:01:18 +01:00
Andrew Kaster 60b3436ea3 LibWeb: Support loading FontFaces constructed with binary data 2024-05-14 12:31:10 -06:00
Shannon Booth 452ffa56dc LibWeb: Implement BaseAudioContext.createDynamicsCompressor 2024-05-14 13:45:43 -04:00
Shannon Booth 27242c6be6 LibWeb: Implement Document.dir
This was seen getting called on stuff.co.nz (before it crashes due to an
unrelated navigation bug)
2024-05-14 13:35:36 -04:00
Shannon Booth 9b6a1de777 LibWeb: Implement URL.parse
This was an addition to the URL spec, see:

https://github.com/whatwg/url/commit/58acb0
2024-05-13 09:21:12 +02:00
Shannon Booth 5a0f7c5f63 LibWeb/Tests: Add a basic test for a blob URL given to a Worker 2024-05-12 15:46:29 -06:00
Shannon Booth 5e7678d1c6 LibWeb: Implement AudioBuffer.copyFromChannel 2024-05-12 19:11:37 +02:00
Shannon Booth 793cab7357 LibWeb: Add a test for construction of WheelEvent 2024-05-12 14:24:18 +00:00
Shannon Booth e5206f5529 LibWeb: Only use lowercase attributes on toggle for HTML documents 2024-05-12 07:28:09 +01:00
Shannon Booth 4fd7d58c51 LibWeb/Tests: Add a layout test for insertAdjacentHTML 2024-05-11 12:53:26 +02:00
Andrew Kaster 2bc51f08d9 LibWeb: Implement or stub FontFace interface's attribute getters/setters
We only support parsing half of these, so the ones we don't recognize
get a friendly exception thrown.
2024-05-11 07:30:29 +01:00
Timothy Flynn 1fbf1bc4ac LibWeb: Don't try to click a form image until it has loaded
We are often trying to click the image before it has finished loading.
This results in us trying to click a 0x0 rect. Instead, wait until the
image load event.

This fixes a flake with form-image-submission.html often seen on CI.
2024-05-09 19:29:47 +02:00
Shannon Booth 71819153cb LibWeb: Implement Element::scroll(HTML::ScrollToOptions) 2024-05-07 17:21:52 -06:00
Tim Ledbetter 57f0ea186e LibWeb: Update Element::directionality() to match current spec text
This fixes a crash that occurred when determining the directionality of
input elements.
2024-05-07 16:45:28 -06:00
Jamie Mansfield 8c4dc9476b LibWeb: Precision when using background-size: contain
This ensures that precision is maintained when calculating the image
size when using `background-size: contain`.
2024-05-07 11:15:04 -04:00
Jamie Mansfield e48cb80a66 LibWeb: Precision when using background-size: cover
This ensures that precision is maintained when calculating the image
size when using `background-size: cover`.
2024-05-07 11:15:04 -04:00
matjojo cd1eeb3cdd LibWeb: Do not consume scroll event in PaintableBox without overflow
Specifically, without scrollable overflow.

Fixes #24009, both on brave.com and on the reduction.
2024-05-07 14:04:02 +00:00
MacDue b5a7a8dbfd Tests/LibWeb: Add ref tests for non-local SVG clipPaths 2024-05-04 21:24:37 +02:00
Shannon Booth f7ba07cc8b LibWeb: Handle non-object JSON in XMLHttpRequest response
This fixes a crash seen on https://web.basemark.com/run/
2024-05-04 14:11:10 +02:00
Shannon Booth 94354ea7fb LibWeb: Clamp AudioParam's value between min and max
The spec isn't _super_ clear on how this is meant to be done, but the
way I understand this is that we should simply clamp the returned
'current value' between 'min' and 'max'.

Firefox does not appear to do this clamping, but Chrome does.
2024-05-04 14:01:38 +02:00
Shannon Booth e2b5ff2450 LibWeb: Implement OscillatorNode.frequency
Which is an AudioParam clamped by the nyquist_frequency.
2024-05-04 14:01:38 +02:00
Shannon Booth 099c9e4a7e LibWeb: Implement OscillatorNode.type
This is a simple getter and setter of the OscillatorType enum, with
error checking to not allow 'custom', as that should only be changed
through 'setPeriodicWave()'.
2024-05-04 14:01:38 +02:00
Shannon Booth b48ba823b9 LibWeb: Implement AudioNode.context
This is just a simple getter which returns the audio context that
created this audio node.
2024-05-04 14:01:38 +02:00
Shannon Booth 97576d27b9 LibWeb: Add constructor for OscillatorNode
This is still missing a bunch of spec steps to construct the
audio node based on the parameters of the OscillatorNode, but it is at
least enough to construct an object to be able to add a basic test which
can get built upon as more is implemented.
2024-05-04 14:01:38 +02:00
Shannon Booth e070309258 LibWeb: Implement Element.outerHTML setter 2024-05-04 13:54:33 +02:00
Andreas Kling 527ad9ac01 LibWeb: Implement XMLHttpRequest.responseURL
This was used on https://twinings.co.uk/ so let's support it :^)
2024-05-01 12:52:03 +02:00
Andreas Kling 34f2cbf202 LibWeb: Honor intrinsic constraints on available space in table widths
When a table's containing block provides min-content or max-content
available space, we now size the table's width accordingly.
2024-05-01 11:13:48 +02:00
Tim Ledbetter 02a8966b61 LibWeb: Serialize empty media rules with a single newline
This deviates from the CSSOM specification but all modern browsers do
this.
2024-05-01 07:21:21 +02:00
Tim Ledbetter a2cccf9420 LibWeb: Use correct spacing when serializing media features
Previously, there was no space between the media feature name and value.
2024-05-01 07:21:21 +02:00
Andrew Kaster 416eb74fa5 Tests: Skip flaky unicode-range LibWeb Ref test
This seems related to CSS resources and the load event.
2024-04-30 07:18:40 -06:00
Tim Ledbetter b9f0ea2178 LibWeb: Evaluate media rules for adopted style sheets
Previously, media rules were not evaluated for adopted style sheets.
2024-04-29 08:10:38 +02:00
Tim Ledbetter f4e0c5395a LibWeb: Don't apply disabled adopted style sheets to the document
Previously, we would apply any adopted style sheet to the document if
its alternate flag was not set. This meant that all adopted style
sheets would be applied, since constructed style sheets never have this
flag set.
2024-04-29 08:10:38 +02:00
Tim Ledbetter 84193f2746 LibWeb: Align StyleSheet title getter with the specification
The CSSOM specification says that StyleSheet.title should return null
if the title field is empty.
2024-04-29 08:10:38 +02:00
Aliaksandr Kalenik 7bea2b68f4 LibWeb: Paint non-positioned SC with z-index=0 in paint_descendants()
Fixes the bug when non-positioned boxes that establish a stacking
context and have z-index=0 are ignored during paint commands recording.
2024-04-28 22:28:18 +02:00
Timothy Flynn 34b446ab34 LibWeb: Assign the Content-Type fetch response header as appropriate
The condition here was inverted.
2024-04-28 12:32:04 +02:00
Aliaksandr Kalenik 613cd6104d LibWeb: Support masking of SVGForeignObjectPaintable 2024-04-27 07:10:20 +02:00
Timothy Flynn c9a461ee75 LibWeb: Remove OOM propagation from Fetch::Infrastructure::HTTP 2024-04-27 07:08:14 +02:00
Tim Ledbetter 1127fa1e01 IDLGenerators: Set namespace object prototype to Object.prototype
Previously, namespace objects were constructed with no prototype, so
calling methods like `toString()` on them would unexpectedly throw an
exception.
2024-04-26 20:02:42 +02:00
Tim Ledbetter dda730c46b LibWeb: Exclude [Global] interfaces from legacy platform object method
Previously, [Global] interfaces were not excluded from the
`internal_own_property_keys()` call. This caused a crash when iterating
over the properties of the Window object.
2024-04-26 20:02:21 +02:00
Aliaksandr Kalenik dc4192c149 LibWeb: Remove CSS transform from InlinePaintable's clip rectangle
Fixes bug when CSS transform is applied twice to clip rect:
- While calculating absolute clip rectangles in `refresh_clip_state()`
- While executing `PushStackingContext` painting command.

Duplicated transform is already removed for PaintableBox and this change
adds this for InlinePaintable.
2024-04-26 18:40:45 +02:00
Shannon Booth baaaa0008e LibWeb: Look for first ID _or_ name in HTMLCollection::named_item
Previously we would look for a matching ID, and then for a matching
name. If there was an element in the collection which had a matching ID
as well as an element with a matching name, we would always return the
element with a matching ID irrespective of what order that element was
in.
2024-04-26 07:44:01 -04:00
Timothy Flynn f6407276f7 LibWeb: Stop the video decoder thread when the video element is GC'd
Otherwise, the thread will continue to run and access the media data
buffer, which will have been freed.

The test here is a bit strange, but the issue would only consistently
repro after several GC runs.
2024-04-26 09:49:11 +02:00
Shannon Booth 0c8a98ac94 LibWeb: Begin implementing the interface for AudioBuffer
Implement the constructor and getChannelData function, working towards
the functionality that we need in order to implement
OfflineAudioContext.
2024-04-25 19:26:19 -04:00
goldenzach 65eb7699f4 LibWeb: Resolve vertical padding of inline elements 2024-04-25 12:45:39 +02:00
Aliaksandr Kalenik 988c8451d4 LibWeb: Skip HTMLLinkElement resource fetching for documents without BC
Fixes crashing after following steps:
1. Open https://github.com/SerenityOS/serenity
2. Click on "Pull requests" tab

The problem was `navigable` null pointer dereferencing in
`decode_favicon()`. But navigable is null because the document was
created by `parseFromString()` DOMParser API.

With this change we skip fetching initiated by HTMLLinkElement if
document does not have a browsing context:
- Favicon is not displayed for such documents so no need to fetch.
- Stylesheets fetching won't affect such document because style or
  layout does not run for them.
2024-04-25 09:31:01 +02:00
Cnidarias 1a1e5aaf54 LibWeb: Add null check for get_client_rects() on non paintable elements 2024-04-24 18:04:28 +02:00
Bastiaan van der Plaat 7fa45c5fdf LibWeb: Add map element areas property 2024-04-24 15:23:45 +02:00
Bastiaan van der Plaat 3e507102ea LibWeb: Add datalist element options property 2024-04-24 15:23:45 +02:00
Andrew Kaster 651e78fedb LibWeb: Convert callers of ImageCodecPlugin to the async API
The HTMLLinkElement caller is a bit hairy, so we shove an await() in
there temporarily. This is sure to cause fun times for anyone debugging
task/microtask execution order.
2024-04-23 12:32:04 -06:00
Aliaksandr Kalenik d4f08fb0a1 LibWeb: Fix division by zero in solve_replaced_size_constraint()
Happened when input_width > 0 but input_height == 0.

Fixes crashing on Discord that happens after clicking on direct
messages conversation.
2024-04-23 16:21:48 +02:00
Aliaksandr Kalenik a044e9cf4f LibWeb: Add background-clip: text support for InlinePaintable
Moves background mask calculation into `paint_background()` that is
shared between PaintableBox and InlinePaintable.
2024-04-23 12:50:07 +02:00
Tim Ledbetter 3aea14093f LibWeb: Don't crash if the document element is not visible
Previously, setting the `hidden` property on the `<html>` element would
cause a crash.
2024-04-23 11:17:54 +02:00
Aliaksandr Kalenik dd73cccf8f LibWeb: Fire "scroll" events on DOM elements
Before this change "scroll" events were only fired on document but now
it happens for all elements with scrollable overflow.
2024-04-23 11:00:35 +02:00
Andreas Kling 8e56367092 LibWeb: Allow moving StyleSheets between documents without falling apart
We have to unregister link element stylesheets from the old document's
StyleSheetList when moving them into a new document.

This makes it possible to load GitHub contributor graphs. :^)
2024-04-22 06:43:05 +02:00
Andreas Kling 193fc7ef98 LibWeb: Allow cloneNode() to clone elements with weird attributes
We can't rely on Element.setAttribute() in cloneNode() since that will
throw on weird attribute names. Instead, just follow the spec and copy
attributes into cloned elements verbatim.

This fixes a crash when loading the "issues" tab on GitHub repos.
They are actually sending us unintentionally broken markup, but we
should still support cloning it. :^)
2024-04-21 19:51:24 +02:00
Aliaksandr Kalenik 23d683cf6b LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before
popstate event is fired and so should we.

Fixes back/forward navigation on GitHub.
2024-04-21 12:41:36 +02:00
Aliaksandr Kalenik 9540af6489 LibWeb: Fix nodesToRemove collecting traversal in Range::delete_contents
With this change children are no longer skipped in tree traversal when
start node of range equals to end node of range.

Fixes https://github.com/SerenityOS/serenity/issues/24036
2024-04-20 13:32:24 +02:00
Aliaksandr Kalenik d3cfe35fbd LibWeb: Do not destroy document until whole subtree completed unloading
Fixes crashing when "unload" event handler tries to access active
document that has already been destroyed.
2024-04-20 10:22:14 +02:00
Alex 13abb1b2c7 LibWeb: Add name validation and document check to setAttribute
Co-authored-by: Rayyan Hamid <rayyanbwp@gmail.com>
Co-authored-by: Christian Ewing <u1273549@utah.edu>
Co-authored-by: Austin Fashimpaur <austin.fashimpaur@gmail.com>
2024-04-19 06:32:41 -04:00
Andreas Kling 5ef6df79ed LibWeb: Generate a simple error page when XML decode/parse fails
This fixes a regression on Acid3, since we are not expected to "best
effort" parse XML. The test specifically checks that you don't create an
incomplete, incorrect DOM.
2024-04-19 11:44:32 +02:00
PGHales 75626c6cd2 LibWeb/DOM: Implement the Document object's partial attributes 2024-04-19 10:58:45 +02:00
Aliaksandr Kalenik 7b75d0c1f0 LibWeb: Fix height distribution in "vertical-align: baseline" in TFC
This line changes padding top to align cell content to baseline:
`cell.padding_top += m_rows[cell.row_index].baseline - cell.baseline`

Which means available for distribution height `height_diff` could have
changed so it needs to be refreshed before assigning the rest of it to
padding bottom:
`cell_state.padding_bottom += height_diff;`

Fixes https://github.com/SerenityOS/serenity/issues/22032
2024-04-19 10:55:28 +02:00
Andreas Kling eb2c05e906 Tests/LibWeb: Fix rebaseline-libweb-test after RequestServer changes 2024-04-19 10:53:20 +02:00
Andreas Kling 4a795bef48 Tests/LibWeb: Fix iframe-load-event-for-bad-xml.html test
This was supposed to be an async test (and work correctly, too!)

This fixes up fa43321938
2024-04-18 21:17:01 +02:00
Andreas Kling fa43321938 LibWeb: Fire iframe load event for frames with badly encoded XML
When loading an XML resource into an iframe and the resource fails to
decode (e.g due to invalid UTF-8), we must still fire a load event.

This fixes the regression in subtest 69 of Acid3.
2024-04-18 15:40:16 +00:00
Aliaksandr Kalenik bad86ca6b4 LibWeb: Ignore mousewheel events in ViewportPaintable
That allow EventHandler process wheel event on corresponding navigable.
For top-level navigable that means IPC call to let chrome know about
scrollbar position update.

Fixes https://github.com/SerenityOS/serenity/issues/23599
Fixes https://github.com/SerenityOS/serenity/issues/23493
Fixes https://github.com/SerenityOS/serenity/issues/23966
2024-04-18 12:27:24 +02:00