Commit graph

2183 commits

Author SHA1 Message Date
Tim Ledbetter
8b5e9c2a1d LibWeb: Emit comment token for unterminated bogus comments on EOF 2025-01-11 11:09:47 +01:00
Shannon Booth
627b7dd936 LibWeb/Bindings: Define constructor properties in the correct order 2025-01-11 01:43:31 +00:00
Tim Ledbetter
3261f873c5 LibWeb: Validate parameters for source node start() and stop() methods 2025-01-10 23:35:20 +01:00
Jelle Raaijmakers
98ec1825de LibWeb: Implement the "useCSS" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
70af48c18b LibWeb: Implement the "selectAll" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
03bcfb9b8c LibWeb: Implement the "outdent" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
fbc0d40d2c LibWeb: Implement the "justifyCenter/Full/Left/Right" editing commands 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1c3251e2d5 LibWeb: Implement the "insertUnorderedList" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
26cadf06d2 LibWeb: Implement the "insertText" editing command
Minus the autolinking algorithm.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
199eaf0d3e LibWeb: Implement the "insertOrderedList" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
01ce9cb151 LibWeb: Implement the "insertImage" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
20fb7b1a49 LibWeb: Implement the "insertHTML" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
cb05ab6515 LibWeb: Implement the "insertHorizontalRule" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
c6cde85534 LibWeb: Implement the "indent" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
a12d887eb4 LibWeb: Implement the "formatBlock" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e686328cbd LibWeb: Implement the "unlink" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
043a28baeb LibWeb: Implement the "underline" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
679fbb5eda LibWeb: Implement the "superscript" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
ef8af01e1d LibWeb: Implement the "subscript" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
8c51d6863f LibWeb: Implement the "strikethrough" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
aee8a75c40 LibWeb: Implement the "removeFormat" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
ae12f7036b LibWeb: Implement the "italic" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
228c66f2e1 LibWeb: Implement the "foreColor" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1d2500e31f LibWeb: Implement the "fontSize" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
9366a50dd3 LibWeb: Implement the "fontName" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
1b02e0dea3 LibWeb: Implement the "createLink" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
05386fe99c LibWeb: Implement the "backColor" and "hiliteColor" editing commands 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
7736d63290 LibWeb: Implement the "forwardDelete" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
a71e999ac8 LibWeb: Implement the "bold" editing command 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
fef02036dd LibWeb: Implement the "set the selection's value" editing algorithm 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
aeec57a440 LibWeb: Implement the "indent" and "outdent" editing algorithms 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
9750896af3 LibWeb: Implement the "push down values" editing algorithm 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
9bcf2fc0f5 LibWeb: Implement last remaining FIXME for wrap editing algorithm 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
148e465131 LibWeb: Implement remaining FIXMEs in "specified command value" algo 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
5e7a31bf60 LibWeb: Implement "move node preserving ranges" editing algorithm 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2b6a14c5ee LibWeb: Implement "preserves overrides" property of editing commands 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e21ee10b3c LibWeb: Add command state & value overrides to DOM::Document 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
67800091c5 LibWeb: Check for editability and visibility of "formattable nodes"
The associated spec was only partially implemented.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
85abad30b0 LibWeb: Add explicit "active range" editing algorithm
This makes some of the spec implementations easier to follow and makes
it extra clear that the range is optional.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2987dd1060 LibWeb: Fix node insertion in split_the_parent_of_nodes()
If we are to insert nodes _before_ the original parent, we need to
insert them at the original parent's index, not the index before that.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
83f48a07d4 LibWeb: Make normalize_sublists_in_node() take a Node instead of Element
This prevents some unnecessary casting to DOM::Element.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
d08febcf67 LibWeb: Add Node::for_each(_inclusive)_ancestor()
Allows for easy iteration over the chain of ancestors for a node.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
4323669939 LibWeb: Add Range::for_each_contained()
This centralizes the logic for iterating over a Range's contained nodes.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
2466021e55 LibWeb: Rename argument to split_the_parent_of_nodes() to reflect spec
The spec calls it a "node list", not "nodes".
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
f4c822ee38 LibWeb: Simplify fix_disallowed_ancestors_of_node()'s usage of node
Commit 98df4c2b changes the node argument to a GC::Ref<DOM::Node>, but
not all usages were updated accordingly.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
bd2488a468 LibWeb: Make block_extend_a_range() take a GC::Ref for the range
This makes it more consistent with the other signatures.
2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e5b107b6b6 LibWeb: Fix typo in spec comment for non-list single line containers 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
acef5a34de LibWeb: Remove useless move from remove_node_preserving_its_descendants 2025-01-10 23:33:35 +01:00
Jelle Raaijmakers
e64766d54d LibWeb: Add spec links to editing command definitions 2025-01-10 23:33:35 +01:00
Aliaksandr Kalenik
cf57efd252 LibWeb: Unload fonts when adopted style sheet is removed
Add missing unloading step that we do for regular style sheets but
mistakenly missed for adopted style sheets.
2025-01-10 19:12:48 +03:00
Aliaksandr Kalenik
d8b0b1535b LibWeb: Skip keyframe animation update if target element isn't connected
Makes some pages on Github faster as previously we had to update
animation for elements in not connected shadow trees.
2025-01-10 15:41:37 +01:00
Aliaksandr Kalenik
de062e4d2c LibWeb: Invalidate style if url changed in HTMLHyperlinkElementUtils
Previously, <a> elements were frequently invalidated because
`set_the_url()` was called by `reinitialize_url()`, which is a
preparation step in every HTMLHyperlinkElementUtils function. As a
result, styles were unnecessarily invalidated each time any of these
functions were invoked without changing the URL.
2025-01-10 14:35:33 +00:00
Tim Ledbetter
84b69c2387 LibWeb: Make TemporaryExecutionContext [[nodiscard]] 2025-01-10 13:21:36 +00:00
Shannon Booth
1f4c7ac62b LibWeb/DOM: Remove uneccessary ExceptionOr for NodeIterator::create 2025-01-10 08:08:46 +00:00
Shannon Booth
17c92d7c2b LibWeb/DOM: Create TreeWalker in document's realm 2025-01-10 08:08:46 +00:00
Shannon Booth
84f22cb6b3 LibWeb/DOM: Create NodeIterator in document's realm 2025-01-10 08:08:46 +00:00
sideshowbarker
10766ecf54 LibWeb: Ignore role=none for focusable & has-global-ARIA-attribute cases
This change causes explicit role=none and role=presentation attribute
values to be ignored in cases where the elements for which those values
are specified are either focusable, or have global ARIA attributes —
per https://w3c.github.io/aria/#conflict_resolution_presentation_none.
2025-01-09 14:08:23 +00:00
sideshowbarker
ead3af0163 LibWeb: Ignore name-required landmark roles which lack accessible names
This change implements the role-checking requirement from the ARIA spec
at https://w3c.github.io/aria/#document-handling_author-errors_roles
that the “form” and “region” roles are required to have accessible
names — and that if they don’t have accessible names as required, UAs
must treat them as if they’d not been specified at all.
2025-01-09 14:08:23 +00:00
sideshowbarker
2cb7baa581 LibWeb: Ignore “orphaned” ARIA roles
This change causes explicitly-specified role attributes to be ignored in
the case where the specified role is “orphaned” — that is, when its
element lacks a required ancestor with an appropriate role.
2025-01-09 14:08:23 +00:00
sideshowbarker
56c7857053 LibWeb: Return true for is_focusable() elements with non-null tabindex
This change implements the requirements stated in the HTML spec at
https://html.spec.whatwg.org/multipage/interaction.html#tabindex-value
that UAs must allow HTML elements with non-null tabindex values to be
considered as focusable areas.
2025-01-09 14:08:23 +00:00
sideshowbarker
173368bd5e LibWeb: Allow accessible-name computation to skip role-attribute lookup
Per https://w3c.github.io/aria/#document-handling_author-errors_roles,
determining whether to ignore certain specified landmark roles requires
first determining whether the element for which the role is specified
has an accessible name.

But if we then try to retrieve a role for such elements, we end up
calling right back into the accessible-name computation code — which
would cause the calls to loop infinitely.

So to avoid that — and to have handling for any other future cases the
spec may introduce of such recursive calls that will loop indefinitely —
this change introduces a parameter that callers can pass to cause
role-attribute lookup to be skipped during accessible-name computation.
2025-01-09 14:08:23 +00:00
sideshowbarker
9f01eebff3 LibWeb: Add a to_element function to ARIAMixin
This change adds a virtual to_element function to ARIAMixin, and
overrides it in DOM::Element so it can then be used back inside
ARIAMixin to get an element when needed (for example, when computing a
role requires checking the roles of ancestors of an element).
2025-01-09 14:08:23 +00:00
Tim Ledbetter
81d6cd497a LibWeb: Validate AudioNode::disconnect() input and output arguments 2025-01-09 11:34:38 +00:00
Tim Ledbetter
5c57acf140 LibWeb: Validate AudioParam context in AudioNode::connect()
An exception is now thown if an `AudioNode` attempts to connect to an
`AudioParam` from a different `BaseAudioContext`.
2025-01-09 11:34:38 +00:00
Tim Ledbetter
2edd0812ca LibWeb: Validate AudioNode::connect() input and output arguments 2025-01-09 11:34:38 +00:00
Jelle Raaijmakers
e6334d217b LibWeb: Update implementation of Range::partially_contains_node()
This accurately reflects the spec it's implementing. This algorithm is
used in 5 spots in the spec but the old buggy behavior was never
triggered:

  * In both ::extract() and ::clone_the_contents(), invocations to this
    method are guarded by a check to see if the start node is the
    inclusive ancestor of the end node, or vice versa - effectively
    resulting in the inequality checks to be accidentally correct.

  * In ::surround_contents(), we forego the usage of this algorithm as
    stated in the spec, and instead use a correct and more optimized
    version that simply compares the start and end nodes.

A lot of words to say: no functional changes :^)
2025-01-09 10:15:55 +00:00
Tim Ledbetter
e469c884d4 LibWeb: Use correct ranges for BiquadFilterNode parameters 2025-01-08 19:05:51 +00:00
Tim Ledbetter
911cd4aefd LibWeb/WebAudio: Add BaseAudioContext.createDelay() factory method 2025-01-08 15:31:59 +00:00
Tim Ledbetter
6c4c925f02 LibWeb/WebAudio: Add DelayNode interface 2025-01-08 15:31:59 +00:00
Luke Wilde
71746c47c2 LibWeb/WebGL: Bind default frame/render buffer when binding is null
This fixes the depth issues on github.com, as the depth commands are
now sent to the right frame/render buffer.
2025-01-08 17:55:17 +03:00
Luke Wilde
e5d59a2d42 LibWeb/WebGL2: Implement getSyncParameter 2025-01-08 17:55:17 +03:00
Luke Wilde
49c966b4e7 LibWeb/WebGL2: Implement uniform{1,2,3,4}ui 2025-01-08 17:55:17 +03:00
Luke Wilde
2f26ade426 LibWeb/WebGL2: Implement copyBufferSubData 2025-01-08 17:55:17 +03:00
Luke Wilde
db2d8f8f17 LibWeb/WebGL2: Implement bindBufferRange 2025-01-08 17:55:17 +03:00
Luke Wilde
c30c1d65f4 LibWeb/WebGL2: Implement clearBuffer{fv,iv,uiv,fi} 2025-01-08 17:55:17 +03:00
Luke Wilde
f627c91bf3 LibWeb/WebGL2: Implement deleteSampler 2025-01-08 17:55:17 +03:00
Luke Wilde
09ad685238 LibWeb/WebGL2: Implement samplerParameter{i,f} 2025-01-08 17:55:17 +03:00
Luke Wilde
42cce393f4 LibWeb/WebGL2: Implement drawElementsInstanced 2025-01-08 17:55:17 +03:00
Luke Wilde
c05fa44cf8 LibWeb/WebGL2: Implement vertexAttribDivisor 2025-01-08 17:55:17 +03:00
Luke Wilde
b6bc5912d6 LibWeb/WebGL: Implement tex(Sub)Image2D with TexImageSource 2025-01-08 17:55:17 +03:00
Luke Wilde
f66f01ce53 LibWeb/WebGL: Implement getUniformBlockIndex 2025-01-08 17:55:17 +03:00
Luke Wilde
216d5b33be LibWeb/WebGL: Enforce minimum size when resizing existing context
Previously the enforcement was only done on creation. Not enforcing it
on change would cause a crash if the canvas width/height was set to
zero or less.
2025-01-08 17:55:17 +03:00
Luke Wilde
8e453d5069 LibWeb/WebGL: Preserve original bound objects to return in getParameter
Required by https://qwasm2.m-h.org.uk, which adds a custom `name`
attribute to objects it generates. It then gets some of these objects
out with getParameter, and expects the `name` attribute to be there.
2025-01-08 17:55:17 +03:00
Luke Wilde
c067271897 LibWeb/WebGL2: Implement getActiveUniformBlockParameter 2025-01-08 17:55:17 +03:00
Luke Wilde
191ceb0f61 LibWeb/WebGL2: Implement getActiveUniformBlockName 2025-01-08 17:55:17 +03:00
Luke Wilde
7957793863 LibWeb/WebGL2: Implement uniformBlockBinding 2025-01-08 17:55:17 +03:00
Luke Wilde
28a73dc392 LibWeb/WebGL: Implement deleteRenderbuffer 2025-01-08 17:55:17 +03:00
Luke Wilde
e26b524721 LibWeb/WebGL2: Implement invalidateFramebuffer 2025-01-08 17:55:17 +03:00
Luke Wilde
63b792c205 LibWeb/WebGL2: Implement bufferSubData with offset and length 2025-01-08 17:55:17 +03:00
Luke Wilde
18ea91715b LibWeb/WebGL2: Implement bufferData with offset and length 2025-01-08 17:55:17 +03:00
Tim Ledbetter
a6ab9cc983 LibWeb: Initialize AudioBufferSourceNode with correct defaults 2025-01-08 14:45:51 +00:00
Psychpsyo
9370990ff2 LibWeb: Implement user-select
This implements all values of user-select.
2025-01-08 14:37:28 +00:00
Sam Atkins
ba43dfe49a LibWeb/CSS: Remove use of Dimension in calc() parsing
Rather than partly-converting number, dimension, and ident tokens at the
start of parsing a calculation, and then later finishing it off, we can
just do the whole step in convert_to_calculation_node(). This is a
little less code, but mainly means we are left with only a single use
of the Dimension type in the codebase, so that can be removed soon.
2025-01-08 14:28:54 +00:00
Sam Atkins
5cda2ac961 LibWeb/CSS: Remove illegal <number-percentage> type
Various places in the spec allow for `<number> | <percentage>`, but this
is either/or, and they are not allowed to be combined like dimensions
and percentages are. (For example, `calc(12 + 50%)` is never valid.)

User code generally doesn't need to care about this distinction, but it
does now need to check if a calculation resolves to a number, or to a
percentage, instead of a single call.

The existing parse_number_percentage[_value]() methods have been kept
for simplicity, but updated to check for number/percentage separately.
2025-01-08 14:28:54 +00:00
Sam Atkins
ab5ac82db6 LibWeb/CSS: Parse dimension and number types individually
An upcoming change requires that we can determine which property we are
parsing before we parse the value. That's the opposite of what this
code previously did, which was to parse a generic dimension or calc()
and then figure out what property would accept it.
2025-01-08 14:28:54 +00:00
Sam Atkins
87da0453c8 LibWeb/CSS: Use parse_length_percentage() in parse_position_value()
Also some minor TokenStream-usage tweaks to make that possible.
2025-01-08 14:28:54 +00:00
Sam Atkins
e5c4a4e6c6 LibWeb/CSS: Parse gradient color stop positions directly
Rather than parsing a generic dimension and then converting it, just
parse the one we want to begin with.
2025-01-08 14:28:54 +00:00
Sam Atkins
34523f67cc LibWeb/CSS: Reuse dimension style value parsing code
Otherwise we're doing the same thing in two places.
2025-01-08 14:28:54 +00:00
Sam Atkins
f3a3344b9b LibWeb/CSS: Simplify parse_hue_none_value()
The motivation was to remove the parse_dimension() call, but this got a
lot smaller.
2025-01-08 14:28:54 +00:00
Sam Atkins
563f8572d5 LibWeb/CSS: Expand out parse_dimension_value()
When we know what kind of dimension we want, it's awkward to attempt to
parse any dimension type, including quirks that only affect lengths, to
then throw it away unless it's the type we wanted in the first place.

Additionally, move the unitless angle/length behavior for SVG attributes
into these methods, where it belongs.

Instead, only try to parse the type of dimension we want. This is
currently more code, but some could be factored together later.
2025-01-08 14:28:54 +00:00
Sam Atkins
f5b716c24d LibWeb/CSS: Simplify parsing of transform-function arguments
This was duplicating the logic in parse_length_value() and pals, so we
can switch to using those directly.
2025-01-08 14:28:54 +00:00
Tim Ledbetter
983540a244 LibWeb: Add missing spec links to HTML parser 2025-01-08 12:05:08 +00:00
Tim Ledbetter
27dbe49f00 LibWeb: Initialize OfflineAudioContext with correct defaults 2025-01-08 11:24:08 +00:00
Gingeh
2cac0dc20c LibWeb: Avoid crash from zero-duration transitions 2025-01-08 11:22:53 +00:00
Gingeh
8e56109515 LibWeb/CSS: Implement the light-dark color function 2025-01-08 11:18:13 +00:00
Gingeh
4a0ac312cc LibWeb: Obtain theme-color on meta element removal and modification 2025-01-08 11:18:13 +00:00
Gingeh
df70455d3f LibWeb: Implement the color-scheme meta tag name 2025-01-08 11:18:13 +00:00
Gingeh
ce5cd012b9 LibWeb/CSS: Implement the color-scheme CSS property 2025-01-08 11:18:13 +00:00
Sam Atkins
89296b88a0 LibWeb: Bring fragment parsing up to spec
Corresponds to https://github.com/whatwg/html/pull/10874

Also, parse_fragment() returns ExceptionOr, so stop voiding the error
from append_child().
2025-01-07 16:05:59 +01:00
Sam Atkins
7d502df807 LibWeb/DOM: Add Document::in_limited_quirks_mode() helper 2025-01-07 16:05:59 +01:00
stelar7
056b774b1e LibWeb: Provide default text for Reset and Submit buttons 2025-01-07 11:41:32 +00:00
InvalidUsernameException
c790cf2194 LibWeb: Prevent paths thinner than 1px from disappearing
SVGs are rendered with subpixel precision. As such it can happen that
paths are rendered with less than 1px width or height and that they can
have a bounding box thinner than 1px. Due to an optimization such paths
were ignored when painting because their bounding box was incorrectly
calculated to be empty.

As a result horizontal or vertical lines inside SVGs were missing if:
* The SVG is displayed at viewbox size but the lines are defined with
  less than 1px.
* The SVG contians 1px-thin lines, but is displayed at a size smaller
  than viewbox size.

To prevent this, the bounding box of the path is now enlarged to contain
all pixels that are partially affected.
2025-01-07 09:05:04 +00:00
Shannon Booth
b08db3dc1e LibWeb/HTML: Update editorial spec comments for Storage
See: https://github.com/whatwg/html/commit/8d2829a
2025-01-07 07:06:16 +00:00
Shannon Booth
7fee54b34e LibWeb/FileAPI: Update FIXME to point to spec bug
This is indeed a spec bug, and has been raised upstream to the FileAPI
spec.
2025-01-07 07:04:41 +00:00
Ryan Liptak
1ba15e1fa3 LibWeb: Fix hex character references accepting all alphabetic ASCII
Instead of just A-F/a-f, any char A-Z/a-z was being accepted as a valid
hexadecimal digit.
2025-01-07 00:43:41 +01:00
Ryan Liptak
df87a9689c LibWeb: Fix numeric character reference at EOF leaking its last digit
Previously, if the NumericCharacterReferenceEnd state was reached when
current_input_character was None, then the
DONT_CONSUME_NEXT_INPUT_CHARACTER macro would restore back before the
EOF, and allow the next state (after the SWITCH_TO_RETURN_STATE) to
proceed with the last digit of the numeric character reference.

For example, with something like `&#1111`, before this commit the
output would incorrectly be `<code point with the value 1111>1` instead
of just `<code point with the value 1111>`.

Instead of putting the `if (current_input_character.has_value())` check
inside NumericCharacterReferenceEnd directly, it was instead added to
DONT_CONSUME_NEXT_INPUT_CHARACTER, because all usages of the macro
benefit from this check, even if the other existing usage sites don't
exhibit any bugs without it:

- In MarkupDeclarationOpen, if the current_input_character is EOF, then
  the previous character is always `!`, so restoring and then checking
  forward for strings like `--`, `DOCTYPE`, etc won't match and the
  BogusComment state will run one extra time (once for `!` and once
  for EOF) with no practical consequences. With the `has_value()` check,
  BogusComment will only run once with EOF.

- In AfterDOCTYPEName, ConsumeNextResult::RanOutOfCharacters can only
  occur when stopping at the insertion point, and because of how
  the code is structured, it is guaranteed that current_input_character
  is either `P` or `S`, so the `has_value()` check is irrelevant.
2025-01-07 00:43:41 +01:00
Psychpsyo
eb7824339b LibWeb: Improve user-select support 2025-01-06 12:22:37 +00:00
Aliaksandr Kalenik
5cac301bb7 LibWeb: Optimize hover style invalidation for shadow trees
With this change we skip all :hover selectors that don't belong to a
"style scope" (document or shadow root) of old/new hovered node.
2025-01-06 12:15:06 +01:00
Tim Ledbetter
7356093af3 LibWeb: Fix selectionchange typo
This was a typo in the spec itself, which has since been fixed.
2025-01-06 08:55:00 +00:00
Sam Atkins
3dbaae5cfc LibWeb/HTML: Add cloning steps for HTMLScriptElement 2025-01-05 21:11:50 +00:00
Sam Atkins
2e96ba11e4 LibWeb/HTML: Update cloning steps to current spec algorithms
Reflects the changes in https://github.com/whatwg/html/pull/10859

I've also added missing calls to the Base::cloned() method, and modified
a couple of spec links to point to the multipage version.

I took the liberty to fix a spec typo, and submitted a PR for it:
https://github.com/whatwg/html/pull/10892
2025-01-05 21:11:50 +00:00
Shannon Booth
172d5f6987 LibWeb: Implement definition of remaining global event handlers 2025-01-05 16:19:19 +00:00
Andreas Kling
49a7a0f378 LibWeb: Avoid invalidation on .textContent setter no-op
When setting the textContent of an element with no children to null or
the empty string, nothing happens. Even so, we were still invalidating
style, layout and collections, causing pointless churn.

Skipping invalidation in this case also revealed that we were missing
invalidation when changing the selected state of HTMLOptionElement.
This was all caught by existing tests already in-tree. :^)
2025-01-05 13:36:17 +01:00
Shannon Booth
8214371ad5 LibWeb/HTML: Default ErrorEvent error to undefined
This was a change in the HTML spec, see:

https://github.com/whatwg/html/commit/032523196
2025-01-05 12:02:40 +01:00
Aliaksandr Kalenik
8fdfadb0c9 LibWeb: Optimize inherited style update caused by animation
It is possible to skip inherited style recalculation for children if
parent's recalculation does not cause any changes.

Improves performance on Github where we could avoid dozens of inherited
style calculations that do not produce any visible changes.
2025-01-05 11:31:03 +01:00
Aliaksandr Kalenik
482e5deb85 LibWeb: Further optimize :hover style invalidation
Previously, we optimized hover style invalidation to mark for style
updates only those elements that were matched by :hover selectors in the
last style calculation.

This change takes it a step further by invalidating only the elements
where the set of selectors that use :hover changes after hovered element
is modified. The implementation is as follows:
1. Collect all elements whose styles might be affected by a change in
   the hovered element.
2. Retrieve a list of all selectors that use :hover.
3. Test each selector against each element and record which selectors
   match.
4. Update m_hovered_node to the newly hovered element.
5. Repeat step 3.
6. For each element, compare the previous and current sets of matched
   selectors. If they differ, mark the element for style recalculation.
2025-01-04 20:32:35 +01:00
Aliaksandr Kalenik
e465e922bd LibWeb: Optimize :hover style invalidation
Instead of recalculating styles for all nodes in the common ancestor of
the new and old hovered nodes' subtrees, this change introduces the
following approach:
- While calculating ComputedProperties, a flag is saved if any rule
  applied to an element is affected by the hover state during the
  execution of SelectorEngine::matches().
- When the hovered element changes, styles are marked for recalculation
  only if the flag saved in ComputedProperties indicates that the
  element could be affected by the hover state.
2025-01-04 20:32:35 +01:00
Jaycadox
db58986e5f LibWeb/CSS: Recalculate calc() numeric type when resolving percentages
Previously, `percentage_of` would be called on the previous value,
potentially changing its numeric type, yet this potential change
was never reflected as the old numeric type was always used. Now,
the numeric type will be re-calculated every time after the
percentage is resolved. As well, VERIFY checks have been placed to
uphold the requirements for the numeric types to match what the
actual values are.
2025-01-04 18:47:44 +00:00
Sam Atkins
938ffe183e LibWeb/DOM: Update validate_and_extract to latest spec
The "strictly split" infra algorithm feels like an inefficient way of
doing basically what our existing split() does, except working with
code points instead of bytes. It didn't seem worth it to implement now.
2025-01-04 18:08:15 +00:00
Psychpsyo
33f87288e9 LibWeb: Remove unneeded spec deviation from font loading 2025-01-04 17:58:38 +00:00
Sam Atkins
c60ad5b0b8 LibWeb/DOM: Update node cloning to latest spec
Main difference is that a chunk of the "clone a node" steps are pulled
out into a "clone a single node" algorithm.

Reflects these spec PRs:
https://github.com/whatwg/dom/pull/1332
https://github.com/whatwg/dom/pull/1334

Though this code is quite old so there may also be older spec changes
included here.
2025-01-04 12:14:25 +00:00
Psychpsyo
331b1b22f5 LibWeb: Implement some viewport proximity features 2025-01-04 11:53:39 +00:00
Psychpsyo
8632ce5cdd LibWeb: Hide audio element when controls is not set
When an audio element has no controls attribute,
it should not render at all and take up no space.
2025-01-04 11:47:09 +00:00
Psychpsyo
8f11dfc08a LibWeb: Make select element use option's label, not text content 2025-01-04 11:44:03 +00:00
Tim Ledbetter
8c4e4ec31b LibWeb: Implement OscillatorNode.setPeriodicWave() 2025-01-04 10:12:24 +00:00
Tim Ledbetter
acbae1b118 LibWeb: Set OscillatorNode type in the constructor 2025-01-04 10:12:24 +00:00
Tim Ledbetter
72818300c0 LibWeb: Implement the OscillatorNode.detune attribute 2025-01-04 10:12:24 +00:00
Tim Ledbetter
ed46d247de LibWeb: Initialize OcillatorNode with the correct default options 2025-01-04 10:12:24 +00:00
Sam Atkins
df702bd4d3 LibWeb/WebDriver: Extract "wait for an action queue token" algorithm
This reflects part of https://github.com/w3c/webdriver/pull/1853
2025-01-03 13:14:53 -08:00
Lucas CHOLLET
d879771044 LibWeb/CSS: Consider unresolved calc() when serializing in Normal mode
Unfortunately, there is no explicit and step-by-step spec to perform
the serialization of `color()` declared values, so while being
spec-informed, this is quite ad-hoc.

Fixes 81 subtests in:
 - css/css-color/parsing/color-valid-color-function.html
2025-01-03 16:49:23 +00:00
Gingeh
a4abb35776 LibWeb: Revert addition of VERIFY call to isomorphic-decode 2025-01-03 14:54:29 +01:00
Tim Ledbetter
a6f04506e4 LibWeb: Add BaseAudioContext.create_periodic_wave() factory method 2025-01-03 14:54:18 +01:00
Tim Ledbetter
f90b79fa1f LibWeb: Implement PeriodicWave constructor 2025-01-03 14:54:18 +01:00
Tim Ledbetter
72ca91ad1a LibWeb: Flesh out AudioBufferSourceNode buffer setter steps 2025-01-03 11:14:47 +01:00
Tim Ledbetter
6cab972248 LibWeb: Add BaseAudioContext.createConstantSource() factory method 2025-01-03 11:13:27 +01:00
Tim Ledbetter
1b160044c4 LibWeb: Add ConstantSourceNode interface 2025-01-03 11:13:27 +01:00
Aliaksandr Kalenik
ccb543ebb8 LibWeb/CSS: Skip build of rule cache for inactive documents
Some websites (Reddit, for example) create lots of temporary documents
for fragment parsing. Before this change, we had to build a rule cache
for these documents just to determine whether there are :has, :defined,
or attribute selectors, while it should be safe to simply return `false`
right away.
2025-01-03 10:59:41 +01:00
Shannon Booth
34b8a9ab75 LibWeb/HTML: Assert microtasks invoked on empty execution context stack
This a requirement from the ECMA-262 spec.
2025-01-03 10:59:20 +01:00
Shannon Booth
ee1b2dced3 LibWeb/XHR: Use HTML EventLoop to wait for response to arrive 2025-01-03 10:59:20 +01:00
Shannon Booth
2fb4fcf4a0 LibWeb/FileAPI: Use HTML EventLoop to wait for promise to be fulfilled
Which will have proper handling of the exection context when performing
a microtask checkpoint. This fixes an assertion to be added in the next
commit where perform_a_microtask_check is invoked on a non-empty
execution context stack.
2025-01-03 10:59:20 +01:00