Commit Graph

8187 Commits

Author SHA1 Message Date
Aliaksandr Kalenik
bf14de4118 LibWeb: Remove direct calls of page_did_request_scroll_to()
By replacing the `page_did_request_scroll_to()` calls with a request
to perform scrolling in the corresponding navigable, we ensure that
the scrolling of iframes will scroll within them instead of triggering
scroll of top level document.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
607e4cab0a LibWeb: Use associated navigable in scrollX and scrollY in Window
If these functions are invoked from inside an iframe, we should use
the navigable associated with the iframe to get the viewport.
2024-02-03 19:00:26 +01:00
Aliaksandr Kalenik
531025465a LibWeb: Remove list_of_descendant_browsing_contexts()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Aliaksandr Kalenik
2175c85cea LibWeb: Remove did_stop_being_active_document_in_browsing_context()
No longer used after migrating to navigables.
2024-02-03 14:54:55 +01:00
Aliaksandr Kalenik
1af466babf LibWeb: Fix invalidation of CSS properties that do not affect layout
Recently, we moved the resolution of CSS properties that do not affect
layout to occur within LayoutState::commit(). This decision was a
mistake as it breaks invalidation. With this change, we now re-resolve
all properties that do not affect layout before each repaint.
2024-02-03 09:28:03 +01:00
Kemal Zebari
dbb3c07e56 LibWeb/HTML: Sniff text or binary resources in HTMLObjectElement 2024-02-02 14:34:17 -05:00
Kemal Zebari
8e5410347b LibWeb/MimeSniff: Add non-standard text or binary context sniffing
This is used in cases where the spec expects us to only run the
"rules for distinguishing if a resource is a text or binary" algo.
2024-02-02 14:34:17 -05:00
Aliaksandr Kalenik
79b73b7fbb LibWeb: Use Window::scroll() in Element::set_scroll_top()
Now when Window::scroll() could do actual scrolling we can remove
this FIXME.
2024-02-01 09:23:48 -05:00
Aliaksandr Kalenik
a4d78c7df9 LibWeb: Use Window::scroll() in Element::set_scroll_left()
Now when Window::scroll() could do actual scrolling we can remove
this FIXME.
2024-02-01 09:23:48 -05:00
Aliaksandr Kalenik
5484062095 LibWeb: Apply scroll offset to PushStackingContext command
In cases where the stacking context painting requires a separate
bitmap, the destination position needs to be translated by the
scrolling offset to ensure it ends up in the correct position.
2024-02-01 13:38:45 +01:00
Aliaksandr Kalenik
dc47d01fdc LibWeb: Remove contained_by_inline_node flag in PaintableFragment
No longer used after we made inline paintables own their fragments.
2024-01-31 07:15:49 +01:00
Aliaksandr Kalenik
9dddd6b028 LibWeb: Account for scroll offset in overflow clip rect calculation
This change addresses an issue with overflow clipping in scenarios
where `overflow: hidden` is applied to boxes nested within elements
with `overflow: scroll`.

Fixes https://github.com/SerenityOS/serenity/issues/22733
2024-01-31 07:15:25 +01:00
Aliaksandr Kalenik
fb2166f19c LibWeb: Account for CSS transform in Element::getClientRects() 2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
96d5f555e1 LibWeb: Simplify InlinePaintable::bounding_rect() implementation
No behavior change expected.
2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
768b8415f2 LibWeb: Follow the spec more precisely in Element::getClientRects()
Now, `Element::getBoundingClientRect()` implementation depends on
`Element::getClientRects()`, as defined in the specification.
2024-01-30 14:50:25 +01:00
Aliaksandr Kalenik
16f1962f10 LibWeb: Use clip rectangles assigned to paintables in hit-testing
This change makes hit-testing more consistent in the handling of hidden
overflow by reusing the same clip-rectangles.

Also, it fixes bugs where the box is visible for hit-testing even
though it is clipped by the hidden overflow of the containing block.
2024-01-30 11:22:22 +01:00
Aliaksandr Kalenik
d3b983b201 LibWeb: Ensure scroll offsets and clip rects updated before hit-testing
Hit-testing relies on updated clip rectangles and containing scroll
offsets, so it's necessary to ensure that paintables have these elements
updated.

This also removes the enclosing scroll offsets update from
`Internals::hit_test()`, as it is no longer needed.
2024-01-30 11:22:22 +01:00
Aliaksandr Kalenik
d27b376699 LibWeb: Store clip border radii in CSSPixels instead of DevicePixels
Paintable boxes should not hold information stored in device pixels.
It should be converted from CSS pixels only by the time painting
command recording occurs.
2024-01-30 11:22:22 +01:00
Timothy Flynn
5a99a6afb4 LibWeb: Implement ReadableStreamBYOBRequest.respondWithNewView
The AO behind this prototype was added in commit ed1076d9ca,
so we can now trivially expose the prototype as well.
2024-01-29 17:10:56 -05:00
Timothy Flynn
3c11a1551d LibWeb: Add missing spec link to ReadableStreamBYOBRequest::respond 2024-01-29 17:10:56 -05:00
Tim Ledbetter
4e383bdac1 LibWeb: Set select element text when an option is initially selected
Previously, a select element's text would initially be empty if the
`selected` property was set on one of its options.
2024-01-29 20:05:14 +00:00
MacDue
b10f58a1fe LibWeb: Support x and y attributes on nested SVGs
This allows positioning a child SVG relative to its parent SVG.

Note: These have been implemented as CSS properties as in SVG 2, these
are geometry properties that can be used in CSS (see
https://www.w3.org/TR/SVG/geometry.html), but there is not much browser
support for this. It is nicer to implement than the ad-hoc SVG
attribute parsing though, so I feel it may make sense to port the rest
of the attributes specified here (which should fix some issues with
viewport relative sizes).
2024-01-29 10:01:10 +00:00
Aliaksandr Kalenik
556679fedd LibWeb: Account for scroll offset in hit-testing
The hit-testing position is now shifted by the scroll offsets before
performing any checks for containment. This is implemented by assigning
each PaintableBox/InlinePaintable an offset corresponding to the scroll
frame in which it is contained. The non-scroll-adjusted position is
still passed down when recursing to children because the assigned
offset accumulated for nested scroll frames.

With this change, hit testing works in the Inspector.
Fixes https://github.com/SerenityOS/serenity/issues/22068
2024-01-29 09:57:40 +01:00
Aliaksandr Kalenik
beb1c85b6b LibWeb: Force scroll offsets update in Internals::hit_test()
Since we might enter Internals::hit_test() before the enclosing scroll
offsets are updated in the paintables tree during pre-paint, this
update need to be enforced.
2024-01-29 09:57:40 +01:00
Timothy Flynn
66959bcc09 LibWeb: Use the stream teeing methods for cloning Fetch response bodies 2024-01-29 07:21:59 +01:00
Timothy Flynn
6981ddfe13 LibWeb: Implement the ReadableByteStreamTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
d7612969e0 LibWeb: Invoke the correct Streams BYOB AOs when in a closed state 2024-01-29 07:21:59 +01:00
Timothy Flynn
ed1076d9ca LibWeb: Implement the ReadableByteStreamControllerRespondWithNewView AO 2024-01-29 07:21:59 +01:00
Timothy Flynn
5e5b42730c LibWeb: Implement the CloneAsUint8Array AO 2024-01-29 07:21:59 +01:00
Timothy Flynn
debfe996d7 LibWeb: Implement the ReadableStreamDefaultTee half of ReadableStreamTee 2024-01-29 07:21:59 +01:00
Timothy Flynn
d8413774df LibWeb: Expose the ReadableStream tee IDL interface
This just sets up the plumbing to the underlying ReadableStreamTee AO,
which as of this commit, will just throw a NotImplemented exception.
2024-01-29 07:21:59 +01:00
Timothy Flynn
5ccd1ff1bf LibWeb: Implement the StructuredClone AO 2024-01-29 07:21:59 +01:00
Aliaksandr Kalenik
20de69693b LibWeb: Fix hidden overflow clipping with nested CSS transforms
This is a fix for regression introduced in
0bf82f748f

All CSS transforms need to be removed from the clip rectangle before
applying it. However, it is still necessary to calculate it with
applied transforms to find the correct intersection of all clip
rectangles in the containing block chain.
2024-01-29 07:21:38 +01:00
Tim Ledbetter
d1226f0b15 LibWeb: Don't crash when querying offsets of empty inline elements
Previously, querying `offsetTop` or `offsetLeft` of an inline element
with no text would cause a crash.
2024-01-28 23:32:40 +01:00
Tim Ledbetter
99fbd33d7d LibWeb: Make button flex wrapper inherit min-height property
This ensures that the vertical positioning of button text is correct
if a `min-height` property is present.
2024-01-28 14:48:33 +01:00
Aliaksandr Kalenik
0bf82f748f LibWeb: Move clip rect calculation to happen before painting
With this change, clip rectangles for boxes with hidden overflow or the
clip property are no longer calculated during the recording of painting
commands. Instead, it has moved to the "pre-paint" phase, along with
the assignment of scrolling offsets, and works in the following way:

1. The paintable tree is traversed to collect all paintable boxes that
   have hidden overflow or use the CSS clip property. For each of these
   boxes, the "final" clip rectangle is calculated by intersecting clip
   rectangles in the containing block chain for a box.
2. The paintable tree is traversed another time, and a clip rectangle
   is assigned for each paintable box contained by a node with hidden
   overflow or the clip property.

This way, clipping becomes much easier during the painting commands
recording phase, as it only concerns the use of already assigned clip
rectangles. The same approach is applied to handle scrolling offsets.

Also, clip rectangle calculation is now implemented more correctly, as
we no longer stop at the stacking context boundary while intersecting
clip rectangles in the containing block chain.

Fixes:
https://github.com/SerenityOS/serenity/issues/22932
https://github.com/SerenityOS/serenity/issues/22883
https://github.com/SerenityOS/serenity/issues/22679
https://github.com/SerenityOS/serenity/issues/22534
2024-01-28 08:25:28 +01:00
Shannon Booth
eaf9a56c10 LibWeb: Actually clear stream controller algorithms when needed
Now that these algorithms are a HeapFunction as opposed to SafeFunction,
the problem mentioned in the FIXME is no longer applicable as these
functions are GC-allocated like everything else.
2024-01-27 21:40:25 -05:00
Shannon Booth
5f484d200a LibWeb: Port Stream algorithms from JS::SafeFunction to JS::HeapFunction 2024-01-27 21:40:25 -05:00
Tim Ledbetter
6f5dd9e11c LibWeb: Return correct RoleType for composite ARIA role 2024-01-27 14:52:41 -05:00
Tim Ledbetter
f0d2a21d77 LibWeb: Add missing ARIA roles to RoleType::build_role_object()
This change allows `contentinfo`, `none`, `subscript` and `superscript`
RoleTypes to be built. These were the only non-abstract role types
missing from this function.

This fixes an issue where clicking on an element with one of these role
types in Inspector would cause a crash.
2024-01-27 14:52:41 -05:00
MacDue
5cf1570f40 LibWeb: Add initial support for nesting SVG viewports
Previously, we were handling viewBoxes/viewports in a slightly hacky
way, asking graphics elements to figure out what viewBox to use during
layout. This does not work in all cases, and can't allow for more
complex SVGs where it is possible to have nested viewports.

This commit makes the SVGFormattingContext keep track of the
viewport/boxes, and it now lays out each viewport recursively, where
each nested `<svg>` or `<symbol>` can establish a new viewport.

This fixes some previous edge cases, and starts to allow nested
viewports (there's still some issues to resolve there).

Fixes #22931
2024-01-27 18:12:13 +01:00
Andreas Kling
546143e9a6 LibWeb: Fix vector OOB access when comparing some calc() values
Before comparing the elements of two vectors, we have to check that
they have the same length. :^)

Fixes a crash seen on https://chat.openai.com/
2024-01-27 17:06:43 +01:00
Timothy Flynn
9272d185ad LibWeb: Implement a slightly better ad-hoc Body::clone method
Just creating a stream on the JS heap isn't enough, as we will later
crash when trying to read from that stream as it hasn't been properly
initialized. Instead, until we have teeing implemented (which is a
rather huge part of the Streams spec), create streams using proper AOs
that do initialize the stream.
2024-01-27 16:01:56 +01:00
Timothy Flynn
c8c3866101 LibWeb: Implement the CreateReadableByteStream AO 2024-01-27 16:01:56 +01:00
Andreas Kling
8e20a44380 LibWeb: Avoid expensive containing_block lookups in PaintableFragment
The paintable has the containing block cached, so it's better (and less
code in general) to ask for it there.
2024-01-27 14:31:47 +01:00
Andreas Kling
ad7e6878fe LibWeb: Allocate CSS::ComputedValues objects on the heap
This makes them cheap to move around, since we can store them in a
NonnullOwnPtr instead of memcopying 2584(!) bytes.

Drastically reduces the chance of stack overflow while building the
layout tree for deeply nested DOMs (since tree building was putting
these things on the stack).

This change also exposed a completely unnecessary ComputedValues deep
copy in block layout.
2024-01-27 12:27:44 +01:00
Sam Atkins
e025bcc4f9 LibWeb: Make use of transform-box when calculating transforms
We don't currently calculate the fill- or stroke-boxes of SVG elements,
so for now we use the content- and border-boxes respectively, as those
are the closest equivalents. The test will need updating when we do
support them.

Also, the test is a screenshot because of rendering differences when
applying transforms: a 20px box does not get painted the same as a 10px
box scaled up 2x. Otherwise that would be the more ideal form of test.
2024-01-27 07:46:37 +01:00
Sam Atkins
391cfdc085 LibWeb: Parse the CSS transform-box property 2024-01-27 07:46:37 +01:00
Timothy Flynn
c4820838bf LibWeb+WebContent: Port the did_request_named_cookie IPC to String 2024-01-26 20:22:39 +01:00
Timothy Flynn
85b8971a80 Ladybird+LibWeb+WebContent: Port the did_request_cookie IPC to String 2024-01-26 20:22:39 +01:00