Improves the implementation of keys to a point where key ranges can be
implemented as well.
Due to me making branching mistakes I'll have to cherry-pick out the
first commit (it's from #37682)
---------
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Previously, we SendKeys will be forwarded to constellation by the
embedder. Now we use webview.notify_input_event, which will send
WebDriverCommandMsg::ForwardInputEvent for the KeyboardEvent and
CompositionEvent.
Fixes: part of https://github.com/servo/servo/issues/37370
---------
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
Add support for APNG animated image decoding. Rework `load_from_memory`
image decoding api, to handle all the image format that currently
supported.
Testing: This change should allow `apng` and `webp` format image start
moving, and should make some WPT test related to APNG pass.
Partially address: https://github.com/servo/servo/issues/37493
[wpt try
run](https://github.com/rayguo17/servo/actions/runs/15840339570)
cc @xiaochengh
Signed-off-by: rayguo17 <rayguo17@gmail.com>
With the work to unify the layout logic for replaced and non-replaced
boxes (#37942), I think the `IndependentNonReplacedContents` enum does
no longer make much sense.
Therefore, this removes `IndependentNonReplacedContents`, merging its
values into `IndependentFormattingContextContents`.
The methods defined on `IndependentFormattingContextContents` can now be
on `IndependentFormattingContext`, in particular this implies that the
layout results of a replaced box will now be cached.
Testing: Unneeded (no behavior change)
This part of #37942
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Laying out a float or atomic inline will now use the same logic
regardless of whether it's replaced or not.
This reduces the amount of code, and should have no observable effect.
Testing: Unneeded (no behavior change)
This part of #37942
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Does not yet handle failures of endpoints, which requires us to update
metadata. I don't see that metadata being used anywhere, so I am not
sure if there is WPT coverage for it.
Part of #37238
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
When a style change does not chang the structure of the box tree, it is
possible to skip box tree rebuilding for an element. This change adds
support for reusing old box trees when no element has that type of
damage. In order to make this happen, there needs to be a type of
"empty" `LayoutDamage` that just indicates that a fragment tree layout
is necessary.
This is the first step toward incremental fragment tree layout.
Testing: This should not change observable behavior and thus is covered
by
existing WPT tests. Performance numbers to follow.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Laying out a flex item will now use the same logic regardless of whether
it's replaced or not.
This reduces the amount of code, and should have no observable effect.
Testing: Unneeded (no behavior change)
This part of #37942
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Implement internal pseudo element, which would be resolved as a
"Implemented Pseudo Element" within style computation. This is an
concrete element that would has a primary style after the style
computation, but could match and style resolved like an pseudo element.
Therefore, it would have a different behavior compared to how does
`pseudo`s that `ServoLayoutNode` had. Where they would not have a
concrete element behind it. Note that, due to the nature of these pseudo
elements residing inside a UA widget, these pseudo elements would
therefore not be accessible in JavaScript by default.
This kind of element is required in order to implement the [form control
pseudo element](https://drafts.csswg.org/css-forms-1/#pseudo-elements)
like `::placeholder`, `::color-swatch`, `::field-text`, etc.
See [this docs](https://hackmd.io/@ChaKweTiau/BJ3zRdLQlg) for more
details of the implementation.
Then, the implemented pseudo element is utilized to implement style
matching for input `type=text`.
Servo's side of: https://github.com/servo/stylo/pull/212
Testing: No WPT regression.
---------
Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
`BoxFragment` had 2 fields that are only relevant for block-level boxes:
`clearance` and a boxed `block_margins_collapsed_with_children`.
This moves both pieces of data into a new `BlockLevelLayoutInfo` struct,
which is boxed.
As a result, the size of `BoxFragment` is reduced from 272 to 264 bytes.
Testing: Unneeded (no behavior change)
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
During the object (de)serialization steps on structured cloning
https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data
it is possible to throw a JS exception.
`self.postMessage({ get whatever() { throw customError } }));`
Require to propagate a pending JS exception and not throw the default
"DataCloneError" DOM exception.
Testing: Improvements in the following tests
- html/infrastructure/safe-passing-of-structured-data/*
- html/webappapis/structured-clone/structured-clone.any.js*
- wasm/serialization/arraybuffer/transfer.window.js
- webmessaging/without-ports/026.html
- workers/semantics/structured-clone/dedicated.html
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Let `WebDriverCommandMsg::ScriptCommand` goes through embedder first.
Give `embedder` the ability to release `webdriver` from waiting for a
response of `ExecuteScript`.
Tests: https://github.com/longvatrong111/servo/actions/runs/16071375821
No regression compared to CI run on main branch.
Fixes: https://github.com/servo/servo/issues/37370
cc: @xiaochengh
---------
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This PR updates the webidl files for `TextEncoder` and `TextDecoder`.
For `TextDecoder.webidl`, the type `AllowSharedBufferSource`, as defined
in the latest spec, is replaced with `BufferSource` as servo currently
does not support `ShareArrayBuffer`
Testing: This update does not introduce any change to the generated rust
binding, so the existing testing would suffice
---------
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
The structured cloning with transfer list
https://html.spec.whatwg.org/multipage/#structuredserializewithtransfer
throws a "DataCloneError" DOM expection by default if
serialization/transferral
is not possible, but a platform object can throw a custom excepton on
its serialization/transfer steps.
One example is OffscreenCanvas, which can throw
an "InvalidStateError" exception if the context mode is not none on
transfer steps.
https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transfer-steps
Testing: Improvements in the following tests
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transferrable*
Fixes: #37919
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Laying out an absolutely or fixedly positioned box will now use the same
logic regardless of whether it's replaced or not.
This reduces the amount of code, and should have no observable effect.
Testing: Unneeded (no behavior change)
This part of #37942
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Previously when scroll offsets were restored to a new scroll tree
post-layout or when receiving scroll offsets from the compositor, they
were not clamped to the available scroll area. This change fixes that.
Testing: This change fixes some WPT subtests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This will help us make "update the rendering" a proper task.
Testing: Existing WPT tests.
try run: https://github.com/sagudev/servo/actions/runs/16085256131
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Previously, anonymous boxes, such for anonymous table parts were not
associated with their non-pseudo ancestor DOM nodes. This presents a
problem when it comes time to clear layout data during incremental
layouts. This change reworks the way that pseudo-elements in general are
stored in their non-pseudo ancestor DOM nodes, allowing for any number
to be placed there.
This trades a bit of performance for space, as just adding a vector to
the node would add something like 24 bytes of storage to every node.
This change should have a neutral runtime memory usage.
Testing: This shouldn't change observable behavior and is thus covered
by
existing WPT tests. It will allow tests to pass in a subsequent PR.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Follow the specification and make OffscreenCanvas objects are
transferable,
but not in case if there are a weak reference to placeholder canvas
element.
To handle it properly need to implement dedicated frame
provider/dispatcher
between canvas element (script thread) and offscreen canvas (dedicated
worker thread).
https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transferable-objects
Testing: Improvements in the following tests
-
html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas.html
-
html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob*
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer*
-
html/infrastructure/safe-passing-of-structured-data/transfer-errors.window.js
Part of #24276
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Clearance only applies to block-level boxes, so it was unnecessary to
require it as a parameter. Instead, in block layout we can set it using
the new `.with_clearance()` method.
Testing: Unnecessary (no behavior change)
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Previously, we KeyboardAction will be forwarded to constellation by the
embedder. Now we use `webview.notify_input_event`, which will send
`WebDriverCommandMsg::ForwardInputEvent` for KeyboardAction
Fixes: part of https://github.com/servo/servo/issues/37370
---------
Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
It was very easy to forget about using `.with_specific_layout_info()` to
set the specific layout info, so it's better to make it a parameter.
In fact this already happened in the past: #36993 fixed the missing
specific layout info for flex items.
This patch fixes it for floats and atomic inlines. It also propagates it
in other cases where not doing so was not a big deal because the
specific layout info was None, but that was a fragile assumption.
Testing: Various WPT improvements
Fixes: #37898
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Client messages, which are always requests, are dispatched to Actor
instances one at a time via Actor::handle_message. Each request must be
paired with exactly one reply from the same actor the request was sent
to, where a reply is a message with no type (if a message from the
server has a type, it’s a notification, not a reply).
Failing to reply to a request will almost always permanently break that
actor, because either the client gets stuck waiting for a reply, or the
client receives the reply for a subsequent request as if it was the
reply for the current request. If an actor fails to reply to a request,
we want the dispatcher (ActorRegistry::handle_message) to send an error
of type `unrecognizedPacketType`, to keep the conversation for that
actor in sync. Since replies come in all shapes and sizes, we want to
allow Actor types to send replies without having to return them to the
dispatcher.
This patch adds a wrapper type around a client stream that guarantees
request/reply invariants. It allows the dispatcher to check if a valid
reply was sent, and guarantees that if the actor tries to send a reply,
it’s actually a valid reply (see ClientRequest::is_valid_reply). It does
not currently guarantee anything about messages sent via the TcpStream
released via ClientRequest::try_clone_stream or the return value of
ClientRequest::reply. We also send `unrecognizedPacketType`,
`missingParameter`, `badParameterType`, and `noSuchActor` messages per
the
[protocol](https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#error-packets)
[docs](https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#packets).
Testing: automated tests all pass, and manual testing looks ok
Fixes: #37683 and at least six bugs, plus one with a different root
cause, plus three with zero impact
---------
Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: delan azabani <dazabani@igalia.com>
Co-authored-by: Simon Wülker <simon.wuelker@arcor.de>
Co-authored-by: the6p4c <me@doggirl.gay>
The specification moved around lately with how it defines its reports
and report bodies. They became dictionaries, but are currently missing
some fields [1].
Most tests won't be passing yet, since the `Reporting-Endpoints` header
isn't used yet. In fact, the specification leaves it up to the browser
to figure out when to run this task [2]. I am not sure if there some
background scheduling we can do here.
Confirmed with content-security-policy/reporting-api/
report-to-directive-allowed-in-meta.https.sub.html that the callback is
invoked. The test doesn't pass, since
the `describe_scripted_caller` is empty for HTML elements. Thus the
`source_file` is empty, whereas it should be equivalent to the current
document URL.
Part of #37328
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
[1]: https://github.com/w3c/reporting/issues/286
[2]: https://w3c.github.io/reporting/#report-delivery
Printing using log macro for Android and OhOS, while retaining original
stderr behavior for other platforms.
Fixes: #37877
Signed-off-by: abdelrahman1234567 <boudyalex321@gmail.com>
I'm getting an unused import warning when I use Rust-Analyzer in VS
Code. I also fixed the license text which I think had gotten changed by
accident.
Testing: I built and ran the example with `cargo build --example
winit_minimal` in the `components/servo` folder. There were some unused
code warnings but they don't show up in Rust-Analyzer's output and I
suspect they are used by other code.
Signed-off-by: Michael Mc Donnell <michael@mcdonnell.dk>
Before #37703 we were actually doing update rendering of canvases/images
as part of `allow_layout_if_necessary` so let's keep doing that until we
fix this properly as this will be much more involved and we want usable
canvases in the mean time.
Testing: Manual testing + WPT tests
Fixes: #37891
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
The will-navigate message tells the devtools client to expect a
navigation for a browsing context. This makes the network monitor clear
any previous entries and show the requests for the new page that is
loaded. In order to support this correctly, we need to send the
navigation notification from the constellation instead of the script
thread, otherwise we silently ignore navigations triggered by the
browser URL bar.
Testing: Ran servo in devtools mode , now the requests appear for new
loaded page
Fixes: https://github.com/servo/servo/issues/37334
---------
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Layout: Add incremental box tree construction for inline floats and
abspos
Due to false positives in the memory benchmark on CI, the previous PR
[37868](https://github.com/servo/servo/pull/37868) reverted. Now it is
resubmitted.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This reverts commit 19ceccc8eb due to a
significant increase in resident memory usage (See
https://github.com/servo/servo/issues/37887).
Testing: This is a revert due to a regression
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This removes assumption about pixel format from backend abstraction to
actual backend implementation. This is important for vello.
Testing: WPT tests
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
The logic for laying out block-level replaced elements wasn't taking
floats into account when resolving a `stretch` inline size. By handling
them with the same logic as non-replaced elements, we fix that problem,
and reduce the amount of code.
Testing: Adding new tests
Fixes: #37861
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Dealing with both path and builder makes code complicated and this is
backend internal specific anyway (we often do conversions between the
two just so we get specific functionality). Now I joined both into
single abstractions `Path`, that has all what one needs and let raqote
backend deal with path/pathbuilder coversions.
Motivation: Simplification and in Vello there is only
[BezPath](https://docs.rs/kurbo/0.11.2/kurbo/struct.BezPath.html) so we
use it as both path and pathbuilder.
Reviewable per commit.
Testing: Existing WPT tests
---------
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Follow the HTML speficication and add missing 'transferToImageBitmap'
method to OffscreenCanvas interface.
https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-transfertoimagebitmap
Testing: Improvements in the following tests
- html/canvas/offscreen/compositing/2d.composite.grid*
- html/canvas/offscreen/fill-and-stroke-styles/2d.gradient*
- html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas*
- html/canvas/offscreen/reset/2d.reset*
- html/canvas/offscreen/text/2d.text*
Fixes (partially): #34111
Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
Testing: Just add comment. It turns out difficult to achieve, see
https://github.com/rust-windowing/winit/issues/2494.
Fixes: Nothing. Provide some guidance to #37878
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This changes extend the incremental box tree construction for inline
out-of-flow-box, including the
`InlineItem::OutOfFlowAbsolutelyPositionedBox` and
`InlineItem::OutOfFlowFloatBox`.
Testing: This should not change observable behavior and is thus covered
by existing WPT tests.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This changes extend the incremental box tree construction for inline
atomic
Testing: This should not change observable behavior and is thus covered
by existing WPT tests.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
[RootCause]:Tochdown executes normally, but touchup fails during hittest
and does not send a touchup event to the script, causing the script to
save an incorrect number of active_touch_points. The application
receives an incorrect event.touches.length, causing a logic error and
preventing the carousel from sliding.
[Solution]:
When hit test on compositor fails, we also need to send the
EmbedderToConstellationMessage::ForwardInputEvent message to
constellation. In the script's handle_touch_event, if it exits early, we
also need to update active_touch_points.
Testing:
Fixes: #37763
---------
Signed-off-by: kongbai1996 <1782765876@qq.com>
Layout: Continue support incremental box tree reconstruction for
flex&taffy level box
This change reuse the flex/taffy level box from old box slot if the box
slot is valid and there is no LayoutDamage to the element.
Testing: This should not change observable behavior and is thus covered
by existing WPT tests.
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This pull request introduces changes to the storage subsystem to:
- Isolate sessionStorage per top-level browsing context (WebViewId), in
addition to origin.
- Copy sessionStorage when creating a new auxiliary browsing context
without
noopener, as required by the corresponding spec
These changes bring Servo closer to spec compliance, matching expected
browser
behavior.
Testing: This work affects observable behavior. As a result, some
previously
failing WPT tests now pass. No new tests are added, since the behavior
is
already covered by existing web-platform-tests.
Fixes: #21291
---------
Signed-off-by: Jan Varga <jan.varga@gmail.com>
Dirty roots are never shadow roots, since we use the flat tree for
invalidation. The flat tree does not contain shadow roots.
Reverts https://github.com/servo/servo/pull/35132. When that patch was
submitted we used the DOM tree for invalidation, so it was possible to
encounter shadow roots.
Testing: Covered by
`shadow-dom/untriaged/events/event-dispatch/test-003.html`
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>