Commit graph

34158 commits

Author SHA1 Message Date
Jamie Mansfield 38fb02cf4d LibWeb/SVG: SVGAElement includes SVGURIReference
(cherry picked from commit 796de74956b6d2689fb5a48280b7465d60560495)
2024-07-21 16:55:11 -04:00
Jamie Mansfield 2ad1fa17fb LibWeb/SVG: Implement SVGAElement.relList
(cherry picked from commit 6ca4c2beb08a81bc4aaa2571ee8c5b3207d0b3a2)
2024-07-21 16:55:11 -04:00
Jamie Mansfield 3ffd1e7ee7 LibWeb/SVG: Implement reflected attributes in SVGAElement
This change implements the download, ping, rel, hreflang, and type
attributes using the [Reflect] annotation in the IDL file.

(cherry picked from commit 7562f89d4e2b0dd22430962e102a2195186f8458)
2024-07-21 16:55:11 -04:00
Jamie Mansfield 6bdf8a97c8 LibWeb/SVG: Add spec link to SVGAElement
(cherry picked from commit 5bac8e77304528d6752a9550c3d104ea31c34419)
2024-07-21 16:55:11 -04:00
Jamie Mansfield 40eaf964d2 LibWeb/SVG: Implement SVGElement.ownerSVGElement
(cherry picked from commit 6f3c5f5ae9f0ee055c44ace5efab0c443626bb5d)
2024-07-21 16:55:11 -04:00
mobounya 219c40a4ba LibWeb: Conform HTTP-network-or-cache to specs
Implement step 8.10 in '4.5. HTTP-network-or-cache fetch' from the
fetch specs.

(cherry picked from commit 9c93630d02c5e86130bfb45f9d94ba6e5c6c3ba5)
2024-07-21 16:54:54 -04:00
mobounya 1146868f6d LibWeb: Add fetch group from the fetch spec
Add fetch group concept from the '2.4. Fetch groups' in
the fetch specs to the environment settings object.

(cherry picked from commit 9e223f6daeb3969d3997084a973b26daff6b4f7e)
2024-07-21 16:54:54 -04:00
mobounya e4fa0e7f63 LibWeb: Implement fetch record from the fetch spec
Implement fetch record concept from the '2.4. Fetch groups' in
the fetch specs.

(cherry picked from commit 8d38a1326e5a3cfe4ebbb0bf3d12c8307a6fbb3c)
2024-07-21 16:54:54 -04:00
Tim Ledbetter eb3c4f2caa LibWeb: Expose ChildNode methods on the DocumentType IDL interface
(cherry picked from commit bd72ff566959d8a3fc77e9b5f6b47d475453e3e8)
2024-07-21 16:54:29 -04:00
Tim Ledbetter a5d05b4925 LibWeb: Compare node names case insensitively in Node::is_equal_node()
(cherry picked from commit 5a578e8f152c1183b96e3f5c9d9b389f4f22235a)
2024-07-21 16:54:29 -04:00
Tim Ledbetter 21760cbffe LibWeb: Don't consider nodes in different namespaces to be equal
Previously, `Node::is_equal_node()` would return true for nodes in
different namespaces that were otherwise equal.

(cherry picked from commit 7ab7be694d1232f4cdc108a2adc88812fc0a9ca9)
2024-07-21 16:54:29 -04:00
Tim Ledbetter 75d1715f29 LibWeb: Fire a change event on mouseup of number input buttons
This matches the behavior of other browsers.

(cherry picked from commit e9e195418ef32e73e7c7beb97f4653e5868ee4ef)
2024-07-21 16:54:15 -04:00
Tim Ledbetter d91ea8ceb8 LibWeb: Update number input on mousedown of number input buttons
This matches the behavior of other browsers. Previously, a click event
was used, so the value was only updated when the mouse was released.

(cherry picked from commit b4b947c60797328d930c8d3de466b8ef292d0ed4)
2024-07-21 16:54:15 -04:00
Tim Ledbetter c9b06f3a90 LibWeb: Fire input event on user interaction with input element buttons
An input event is now fired when the step up or step down button of an
input element of type number is clicked.

This ensures that any associated <output> element is updated when these
buttons are clicked.

(cherry picked from commit 2a980816e756d727261d53450b4b3f48069d5d50)
2024-07-21 16:54:15 -04:00
Tim Ledbetter c219ebc0db LibWeb: Deduplicate the firing of input events in HTMLInputElement
Input elements without a defined user-interaction behavior need to fire
an input event when the user changes the element's value in some way.
This change moves the code to do this into its own function and adds
some spec text to explain what is being done.

(cherry picked from commit a3d12e569c88d0dae530657e5bddc18699fb9c9b)
2024-07-21 16:54:15 -04:00
Timothy Flynn 582305fdc3 LibJS: Implement Iterator.prototype.constructor according to spec
The spec allows setting a constructor on non built-in Iterator objects.

This is a normative change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/30b3501

(cherry picked from commit fb228a3d850eb5e4b06550823755719a377b41e6)
2024-07-21 14:54:16 -04:00
Timothy Flynn 978d3331fa LibJS: Implement Iterator.prototype [ @@toStringTag ] according to spec
The spec allows setting the prototype on non built-in Iterator objects.

This is a normative change in the Iterator Helpers proposal. See:
https://github.com/tc39/proposal-iterator-helpers/commit/30b3501

(cherry picked from commit 734e37442db4419b58228e25702bfe176e52f5e3)
2024-07-21 14:54:16 -04:00
Holger Hans Peter Freyther fbf44c1dca LibWeb: Fix assertion failure on telekom.de
The EntryType has three possible values: Fetching, Failed or
ModuleScript. It is possible that we transition from Fetching to Failed
as in #13.1. Change the assertion to include the failed scenario.

Fixes: https://github.com/LadybirdBrowser/ladybird/issues/661
(cherry picked from commit 319bb6353e0ba64fc5e54b32ddb2b38736cedef9)
2024-07-21 14:21:11 -04:00
Jamie Mansfield 6f58a3ee33 LibWeb: Stub Text.wholeText
(cherry picked from commit 0961d68ebc23185836562c5e1f954c47da213922)
2024-07-21 14:19:52 -04:00
Jamie Mansfield 63cac3088a LibWeb: Implement MouseEvent.initMouseEvent
(cherry picked from commit 807e63faaf6d9cb30ac01514309e532eb3742e96)
2024-07-21 14:19:52 -04:00
Jamie Mansfield 5ed5460553 LibWeb: Implement KeyboardEvent.initKeyboardEvent
(cherry picked from commit 3845d174e313d404c7b59b7d71637873712d4ee1)
2024-07-21 14:19:52 -04:00
Jamie Mansfield 5478695eee LibWeb: Short-circuit UIEvent.initMouseEvent if dispatched
This fixes some bugs on wpt.dom/events/Event-init-while-dispatching.html,
although the test still fails due to [GH-23722].

[GH-23722]: https://github.com/SerenityOS/serenity/issues/23722

(cherry picked from commit aefab1de38948b0d86a6aed33647e995340859e2)
2024-07-21 14:19:52 -04:00
Jamie Mansfield e8688eed3e LibWeb/HTML: Remove FIXMEs from HTMLTrackElement constants
(cherry picked from commit 87880e9b81a2dde1d0ea46c2d43877e502fd0ea0)
2024-07-21 14:19:52 -04:00
Jamie Mansfield 737e6215b6 LibWeb: Implement Performance.toJSON
(cherry picked from commit 66c3388b16f9ba325221572a0395b9be3a08ba0e)
2024-07-21 14:19:52 -04:00
Jamie Mansfield 750161723e LibWeb/DOM: Add FIXMEs for missing functions in Node
(cherry picked from commit 116c1f835df5ace3cedfb5c092d3f77c8db6df0e)
2024-07-21 14:19:52 -04:00
Jamie Mansfield ba2dedd160 LibWeb/DOM: Match order of Node.idl with the spec
This makes it easier to compare with the spec :^)

(cherry picked from commit 62f74f3b7765734eafef35327ee46d7bd97f7550)
2024-07-21 14:19:52 -04:00
Aliaksandr Kalenik 2f6c12cd15 LibWeb: Fix flexible track sizing in GFC
- Change min track sizing function to be "auto" when flex size is
  specified.
- Never check if min track sizing funciton is flexible, because only
  max is allowed to be flexible.
- Address FIXME in automatic_minimum_size to avoid regressions after
  making two fixes mentioned above.

(cherry picked from commit 3270df476dd46b140e1b9de1e8328647744b56ab)
2024-07-21 14:19:12 -04:00
Aliaksandr Kalenik 409e3ae994 LibWeb: Subtract left inset from size_available_for_margins for abspos
Some checks failed
CI / Lagom (NO_FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / Lagom (NO_FUZZ, macos-14, macOS) (push) Waiting to run
CI / Lagom (FUZZ, ubuntu-22.04, Linux) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (x86_64, NORMAL_DEBUG, ubuntu-22.04, Clang) (push) Waiting to run
CI / SerenityOS (x86_64, ALL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
CI / SerenityOS (aarch64, NORMAL_DEBUG, ubuntu-22.04, GNU) (push) Waiting to run
Discord notifications / notify_discord (push) Waiting to run
Social media notifications / notify_mastodon (push) Waiting to run
Social media notifications / notify_twitter (push) Waiting to run
Build Wasm Modules / build (push) Waiting to run
Generate man pages / convert_using_pandoc (push) Has been cancelled
Fixes https://github.com/LadybirdBrowser/ladybird/issues/712

(cherry picked from commit 0be57df54dd57d1544eead1c1bc8fe117c0a3450)
2024-07-21 14:13:42 -04:00
Aliaksandr Kalenik c82f41dac8 LibWeb: Change grid item placement to look for area by boundary lines
Areas are disassembled into boundary lines on `build_grid_areas()` step,
so we can always use them to find grid item's position during placement.
This way we support both ways to define area: `grid-template-areas` and
implicitly using `-start` and `-end` boundary line names.

(cherry picked from commit 7a1f3f7ae3af2744e2f99df29baf09153d631b24)
2024-07-21 14:08:37 -04:00
Andreas Kling c6038071a4 LibWeb: Allow splitting surrogate pairs in CharacterData.replaceData()
We're expected to handle this situation gracefully, and certainly not
by falling apart like we were.

Found by Domato.

(cherry picked from commit 33207174a9c1c87657e2ae0875cc85cbf41075f8)
2024-07-21 14:07:57 -04:00
Andreas Kling 1484dbffae LibWeb: Don't try to set selection with anchor/focus in different roots
If the anchor and focus nodes are not within the same document, we can't
use them for a selection range.

Found by Domato.

(cherry picked from commit 416c4788763baa778465d1d004080d322462c0bf)
2024-07-21 14:07:57 -04:00
Andreas Kling 7ddd8bac62 LibWeb: Cap HTML dimension values at 17895700 (same as Firefox)
Instead of allowing arbitrarily large values (which could eventually
overflow an i32), let's just cap them at the same limit as Firefox does.

Found by Domato.

(cherry picked from commit 4e0edd42b95abf8ad707c64414dbe618313ce89e)
2024-07-21 14:07:57 -04:00
Andreas Kling e99c005c80 LibWeb: Propagate exceptions from setAttribute() in DOMStringMap setter
We were incorrectly assuming that setAttribute() could never fail here,
even when passed an invalid name.

Found by Domato.

(cherry picked from commit 093f1dd805f699801079f55d0d490d80b463ccbb)
2024-07-21 14:07:57 -04:00
Andreas Kling d2ae01f8ad LibWeb: Fix StringView OOB access when parsing 3-character legacy color
Found by Domato.

(cherry picked from commit 1c00e5688d3330626f809e758bb63c8348776971)
2024-07-21 14:07:57 -04:00
Sam Atkins 6ab6138fe6 LibWeb/CSS: Make StringStyleValue hold a FlyString
We already have a FlyString of its value from parsing, and most users
also want a FlyString from it, so let's use that instead of converting
backwards and forwards.

The two users that did want a String are:
- Quotes, which make sense as FlyString instead, so I've converted that.
- Animation names, which should probably be FlyString too, but the code
  currently also allows for other kinds of StyleValue, and I don't want
  to dive into this right now to figure out if that's needed or not.

(cherry picked from commit 9fb44cb05777c6d7a8a1950258edadfcee6d4e09)
2024-07-21 14:07:33 -04:00
Sam Atkins 6393e542ab LibWeb/CSS: Remove unused StyleProperties::grid_area()
This does not appear to be correct; the `grid-area` property's value is
quite complicated, and not just a string.

(cherry picked from commit d2f04b9f0415ebfebb1d8f6386ff13f8df053674)
2024-07-21 14:07:33 -04:00
Alec Murphy 09d7a45d73 Calendar: Initial support for iCalendar format
This PR adds basic support for loading iCalendar (.ics) files and
parsing VEVENT properties that are currently supported by Calendar
Events: summary, start and end.
2024-07-21 13:13:47 -04:00
Timothy Flynn 258e9335ef LibJS: Create exception messages as Strings
The JS::Error types all store their exception messages as a String. So
by using ByteString, we hit the StringView constructor, and end up
allocating the same string twice.

(cherry picked from commit c3f8202d0ca7761caaabf0af5f413dc25337801f)
2024-07-21 13:11:01 -04:00
Andreas Kling e1e05d5c6b LibWeb: Make getElementById() always return first match in tree order
We had a const and non-const version of this function, with slightly
different behavior (oops!)

This patch consolidates the implementations and keeps only the correct
behavior in there.

Fixes an issue where comments were not collapsible on Hacker News.

(cherry picked from commit 98f88d49de852e1e524655accb39724f1134a23f)
2024-07-21 12:37:18 -04:00
Andreas Kling fc462c6c65 LibWeb: Use static_cast<HTMLTemplateElement> right after an is<> check
The double verify_cast here was just barely visible in a profile.

(cherry picked from commit 7dacd6be89619d4c4ac7da3b5bb955cd772a2dc6)
2024-07-21 12:37:05 -04:00
Andreas Kling 630aff7a20 LibWeb: Stop creating transient throwaway JS::Handles in HTML parser
These were being immediately stored in JS::GCPtrs (and dutifully visited
by HTMLParser), so creating temporary handles for them was a complete
waste of time.

(cherry picked from commit f9f11dc51d50746ccb1a82cd304fe30901edc347)
2024-07-21 12:37:05 -04:00
Andreas Kling 4ce5aeb312 LibWeb: Skip CSS tokenizer filtering when string has no '\r' or '\f'
When loading a canned version of reddit.com, we end up parsing many many
shadow tree style sheets of roughly ~170 KiB text each.

None of them have '\r' or '\f', yet we spend 2-3 ms for each sheet just
looping over and reconstructing the text to see if we need to normalize
any newlines.

This patch makes the common case faster in two ways:

- We use TextCodec::Decoder::to_utf8() instead of process()
  This way, we do a one-shot fast validation and conversion to UTF-8,
  instead of using the generic code-point-at-a-time callback API.

- We scan for '\r' and '\f' before filtering, and if neither is present,
  we simply use the unfiltered string.

With these changes, we now spend 0 ms in the filtering function for the
vast majority of style sheets I've seen so far.

(cherry picked from commit dba6216caa71796f25831908035cd9eb0fb54715)
2024-07-21 12:37:05 -04:00
Andreas Kling 457de9e99d LibWeb: Use StringBuilder::append_code_point() over append(Utf32View)
When appending a single Unicode code point, we don't have to go through
the trouble of creating a Utf32View wrapper over it.

(cherry picked from commit 7892ee355df95f6414ab5334d8d997c2c0356a45)
2024-07-21 12:37:05 -04:00
Braydn d131f29ba8 LibJS: Implement CreatePerIterationEnvironment for 'for' statements
Implement for CreatePerIterationEnvironment for 'for' loops per the Ecma
Standard. This ensures each iteration of a 'for' loop has its own
lexical environment so that variables declared in the loop are scoped to
the current iteration.

(cherry picked from commit dbc2f7ed48f00234f5f94a30b06b83842d9cf4dd)
2024-07-21 11:31:13 -04:00
Colin Reeder 8908038f96 LibWeb: Add support for indexed setter of HTMLOptionsCollection
(cherry picked from commit 99824eae142b02c7bce84b9e98d10fc6428f31fe)
2024-07-21 11:29:07 -04:00
BenJilks 456a09e8c7 LibWeb: Propagate margin and offset when computing a box's baseline
When traversing the layout tree to find an appropriate box child to
derive the baseline from. Only the child's margin and offset was being
applied. Now we sum each offset on the recursive call.

(cherry picked from commit 3c897e7cf3594f02f559599e1bf28747c9edba13)
2024-07-21 11:28:55 -04:00
Diego Frias e4d3b9060a LibWeb: Implement the :has() pseudo-class
See https://drafts.csswg.org/selectors-4/#relational.

(cherry picked from commit f63a945ba0300551417c740e450957f29c9b73d1)
2024-07-21 11:10:11 -04:00
Liav A. 4aec3f4ef9 Kernel+Userland: Simplify loading of an ELF interpreter path
The LibELF validate_program_headers method tried to do too many things
at once, and as a result, we had an awkward return type from it.

To be able to simplify it, we no longer allow passing a StringBuilder*
but instead we require to pass an Optional<Elf_Phdr> by reference so
it could be filled with actual ELF program header that corresponds to
an INTERP header if such found.

As a result, we ensure that only certain implementations that actually
care about the ELF interpreter path will actually try to load it on
their own and if they fail, they can have better diagnostics for an
invalid INTERP header.

This change also fixes a bug that on which we failed to execute an ELF
program if the INTERP header is located outside the first 4KiB page of
the ELF file, as the kernel previously didn't have support for looking
beyond that for that header.
2024-07-21 15:38:52 +02:00
Liav A. ccf3d29afd Utilities: Introduce the watchfs utility
This utility is meant mainly for debugging purposes, to watch regular
files and directories being modified.
2024-07-21 12:15:44 +02:00
Liav A. fdcfa23e01 Userland+Base: Introduce userspace implementation for running containers
Together with a first JSON file for bringing up a fully functional
BuggieBox container, we allow users to take advantage of the kernel
unsharing features that were introduced in earlier commits.
2024-07-21 11:44:23 +02:00