Add the Storage Standard WebIDL for NavigatorStorage and StorageManager,
wire navigator.storage on Window and Worker, and implement persisted(),
persist(), and estimate().
Testing: covered by WP test.
part of #39100fixes#39101
---------
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
Initialize Sanitizer API implementation with partially implemented
constructor and `get()` methods of the `Sanitizer` interface, which
allows the sub-sequential implementation to be tested by WPT.
The `Sanitizer` interface is hidden behind the feature flag
`dom_sanitizer_enabled`, which is disabled by default.
Specification: https://wicg.github.io/sanitizer-api/
Testing: Enable WPT tests for Sanitizer API.
Fixes: Part of #43948
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Depends on #42251 for the overflow query.
Use containing block queries to implement the iteration of step [3.2.7.
Compute the Intersection of a Target Element and the
Root](https://w3c.github.io/IntersectionObserver/#compute-the-intersection)
within `IntersectionObserver` algorithm.
Contrary to the algorithm in the spec that maps the coordinate space of
the element for each iteration, we uses bounding client rect queries to
get the appropriate clip rect. And, to handle the mapping between
different coordinate spaces of iframes, we use a simple translation.
Due to the platform limitation, currently it would only handle the same
`ScriptThread` browsing context. Therefore innaccuracy any usage with
cross origin iframes is expected.
Testing: Existing and new WPTs.
Part of: https://github.com/servo/servo/issues/35767
Co-authored-by: Josh Matthews
[josh@joshmatthews.net](josh@joshmatthews.net)
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This "JSContextify"s part of DocumentEventHandler, namely the actions
from `handle_pending_input_events`.
Additionally, we also switch the MouseEvent and KeyboardEvent. This does
not change yet PointerEvent and some other events used to keep the diff
reasonable.
Testing: This is part of the JSContextify work that is fundamental and
tested by WPT.
---------
Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
For any generic command, the spec doesn't specify how to determine
whether its state is set. In the case of underline, it at least means
that it has an effective command value that is set (to underline in this
case).
Also implements "simple modifiable" elements, since the relevant tests
depend on that for correctness.
Lastly, also rewrite `JSContext` to use imports.
Part of #25005
Testing: WPT
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Refactor AudioContext methods to use &mut JSContext
Testing: Just refactor.
Fixes: Part of #42638
---------
Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
Implementing Drop for DOM types is being forbidden. This change moves
the shader deletion logic into a separate DroppableWebGLShader struct,
allowing WebGLShader to comply with this restriction while still
ensuring GPU resources are released when the object is finalized.
Testing: Covered by existing WebGL tests.
Fixes: #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
There are two times that Servo needs to ask other `Document`s to either
focus or blur.
- During processing of the "focusing steps". When a new element gains
focus this may cause focus to be lost or gained in parent `<iframe>`s.
- When calling `focus()` on a DOM Window from another origin.
In both of these cases we need to request that a `Document` gain or lose
focus via the Constellation, but in the second case we may have a
`BrowsingContextId` of the `<iframe>` gaining focus and a
`FocusSequence`. This change splits those cases into two kinds of
messages.
Finally, run the entire focusing steps when calling `window.focus()`
instead of going to the constellation immediately. This will be
important in a followup changes where messaging order is made more
consistent.
Testing: This should not change behavior so is covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Fixes: #43968
made get callable property accept ` &CStr ` instead of `&str`
Testing: no behaviour change expected, so existing WPT tests are
sufficient.
Signed-off-by: Rover track <rishan.pgowda@gmail.com>
This makes the most basic tests pass for the font-size command. Future
PR's will continue the work,
but since this is already large enough, this is a good save point.
Part of #25005
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
A lot (and I mean, really a lot) depends on these constructors.
Therefore, this is the one spaghetti ball that I could extract and
convert all `can_gc` to `cx`. There are some new introductions of
`temp_cx` in the callbacks of the servo parser, but we already had some
in other callbacks.
Part of #40600
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Replaced the hand-written CONTENT_EVENT_HANDLER_NAMES list in
eventtarget.rs with an auto-generated version. A new
ContentEventHandlerNames method in codegen.py iterates through WebIDL
descriptors whose prototype chain includes Node, collects attribute
members with EventHandler callback types, and generates a sorted,
duplicate free Rust array. The list is included from eventtarget.rs
eliminating manual maintenance and ensuring it stays in sync
automatically.
Testing: Build passes with cargo build -j2 -p servo-script. The
generated ContentEventHandlerNames.rs produces the same set of event
handler names as the previous hand-written list. No new runtime tests
are needed since this is a compile time change.
Fixes: #43611
Signed-off-by: staysafe020 <jambongralpher@gmail.com>
Rather than specifying a cx for every single CSS property from Stylo, we
instead make it implicit. This allows us to remove the `CanGc::note()`
from the macro and pass in the `cx` as normal.
We can use a similar approach for setters in other elements where we use
the setter macros.
Part of #42812
Testing: It compiles
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
<https://heycam.github.io/webidl/#es-operations>
<https://html.spec.whatwg.org/multipage/#integration-with-idl>
This PR implements the IDL security check, which is an important (but
not only) mechanism to restrict cross-origin DOM accesses.
This implementation follows WebKit's behavior and not the specification
for the following reasons:
- Neither Gecko nor WebKit implements the specification's behavior.
- This would require a relatively elaborate mechanism *just* to have
access to the target object's `CrossOriginProperties`.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
---
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
The WebIDL file for `HTMLElement` was quite out of date. This change
makes it match the current HTML specification and also moves `blur()` to
`HTMLOrSVGElement` as it is in the spec. The implementation is just a
copy of the one for `HTMLElement` as we do for `focus()`.
Testing: This should not change behavior (other than adding a `blur()`
method
for SVG -- which we don't support), so should be covered by existing
tests.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Implement the `SubtleCrypto.supports` method in our WebCrypto API. The
*check support for an algorithm* algorithm is also implemented to
support the functionality of the `SubtleCrypto.supports` method.
The `SubtleCrypto.supports` method has two overloads. One of them has a
union containing a non-object value at the distinguishing index. Our
`codegen.py` currently does not support unions of non-object values at
distinguish index. So, `codegen.py` is also patched to extend its
support to unions of objects, strings, numbers and boolean values.
Specification of `SubtleCrypto.supports`:
https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
Specification of "check support for an algorithm":
https://wicg.github.io/webcrypto-modern-algos/#dfn-check-support-for-algorithm
Testing:
- Pass WPT tests related to `supports` method.
- Add new tests for IDL operation overloading with unions of various
types.
Fixes: Part of #40687
---------
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
This change has two main interdependent parts:
1. It starts to align Servo's focus code with what is written in the
HTML specification. This is going to be a gradual change, so there
are still many parts that do not match the specification yet. Still,
this adds the major pieces.
2. It adds initial support for the `ShadowRoot.delegatesFocus` property
which controls how focusing a shadow DOM root can delegate focus to
one of its children.
Testing: This causes a few WPT tests to start passing.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Moves the cleanup logic to a separate helper struct to comply with the
prohibition of manual `Drop` implementations for DOM types.
Testing: WebGL tests cover these cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Move CookieStore methods from CanGc to &mut JSContext.
Testing: Just refactor.
Fixes: Part of #42638
Signed-off-by: Jayanta Pradhan <pradhanjayanta91@gmail.com>
Move `CSSGroupingRule` methods from `CanGc` to `&mut JSContext`.
Testing: Just refactor.
Fixes: Part of #42638
Signed-off-by: Jayanta Pradhan <pradhanjayanta91@gmail.com>
Move `CSSStyleRule::Style` from `CanGc` to `&mut JSContext`. Also fix
the caller in `devtools.rs` to pass `cx` directly.
Testing: Refactoring, It compiles.
Fixes: Part of #42638
Signed-off-by: arabson99 <arabiusman99@gmail.com>
Moves the cleanup logic to a separate helper struct to comply with the
prohibition of manual `Drop` implementations for DOM types.
Testing: WebGL tests just cover its cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Move `CSSKeyframesRule` methods (`CssRules`, `AppendRule`, `DeleteRule`,
`FindRule`) from `CanGc` to `&mut JSContext`.
Testing: It compiles.
Fixes: Part of #42638
Signed-off-by: arabson99 <arabiusman99@gmail.com>
Move `CSSNestedDeclarations::Style` from `CanGc` to `&mut JSContext`.
Testing: It compiles.
Fixes: Part of #42638
Signed-off-by: arabson99 <arabiusman99@gmail.com>
Move `CSSKeyframeRule::Style` from `CanGc` to `&mut JSContext`.
Testing: Just a refactor, Existing tests suffice.
Fixes: Part of #42638
Signed-off-by: arabson99 <arabiusman99@gmail.com>
Moves the cleanup logic to a separate helper struct to comply with the
prohibition of manual `Drop` implementations for DOM types.
Testing: WebGL tests just cover its parts
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>
Pass `&mut JSContext` to `CustomElementReaction::invoke` and
`upgrade_element` algorithm.
Testing: A successful build is enough
Part of #40600
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
Add a check for a valid key path when create index on idb object store
Testing: `./mach test-wpt
tests/wpt/tests/IndexedDB/keypath_invalid.any.js`
Fixes: #42434
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Pass `&mut JsContext` to `TransformStreamDefaultController::enqueue`, in
preparation of porting the remaining BlobMethods.
Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638
---------
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
Pass `&mut JSContext` to `ReadableStream::cancel`, in preparation of
porting the remaining `BlobMethods`.
Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
Pass `&mut JSContext` and `&mut CurrentRealm` to more functions in
`dom/stream`, focusing on functions that need to be ported to finish
porting the remaining methods in `Blob`.
Testing: Just a refactor, ./mach test-unit still passes.
Fixes: Part of #42638
---------
Signed-off-by: Uiniel <174327181+uiniel@users.noreply.github.com>
Mission No.2
Divided into three parts
- Import `js::context::JSContext;` and use it. This is fine as we
already renamed the traditional one.
- Major mission of porting
- Add space between functions
Testing: It compiles
---------
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Implementing `Drop` for DOM types is being forbidden. This moves the
resource cleanup logic for `GPUShaderModule`, `GPUTexture`, and
`GPUTextureView` to separate helper structs and removes the
`allowDropImpl` flag from the bindings configuration.
Testing: WebGpu tests just cover their cases
Fixes: Partially #26488
Signed-off-by: Domenico Rizzo <domenico.rizzo@gmail.com>