aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/net/image_cache.rs16
-rw-r--r--components/script/canvas_context.rs6
-rw-r--r--components/script/dom/document.rs7
-rw-r--r--components/script/dom/element.rs29
-rw-r--r--components/script/dom/htmlbodyelement.rs19
-rw-r--r--components/script/dom/htmlcanvaselement.rs55
-rw-r--r--components/script/dom/htmlelement.rs3
-rw-r--r--components/script/dom/htmloptgroupelement.rs4
-rw-r--r--components/script/dom/htmloptionelement.rs24
-rw-r--r--components/script/dom/htmlselectelement.rs11
-rw-r--r--components/script/dom/intersectionobserver.rs14
-rw-r--r--components/script/dom/macros.rs35
-rw-r--r--components/script/dom/offscreencanvas.rs20
-rw-r--r--components/script_bindings/webidls/Document.webidl1
-rw-r--r--components/script_bindings/webidls/EventHandler.webidl30
-rw-r--r--components/script_bindings/webidls/HTMLElement.webidl1
-rw-r--r--components/webdriver_server/actions.rs32
17 files changed, 203 insertions, 104 deletions
diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs
index e3d31b11736..46a2a4ea111 100644
--- a/components/net/image_cache.rs
+++ b/components/net/image_cache.rs
@@ -7,7 +7,7 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::sync::{Arc, Mutex};
use std::{mem, thread};
-use compositing_traits::{CrossProcessCompositorApi, SerializableImageData};
+use compositing_traits::{CrossProcessCompositorApi, ImageUpdate, SerializableImageData};
use imsz::imsz_from_reader;
use ipc_channel::ipc::IpcSharedMemory;
use log::{debug, warn};
@@ -675,6 +675,20 @@ impl ImageCache for ImageCacheImpl {
}
}
+impl Drop for ImageCacheStore {
+ fn drop(&mut self) {
+ let image_updates = self
+ .completed_loads
+ .values()
+ .filter_map(|load| match &load.image_response {
+ ImageResponse::Loaded(image, _) => image.id.map(ImageUpdate::DeleteImage),
+ _ => None,
+ })
+ .collect();
+ self.compositor_api.update_images(image_updates);
+ }
+}
+
impl ImageCacheImpl {
/// Require self.store.lock() before calling.
fn add_listener_with_store(&self, store: &mut ImageCacheStore, listener: ImageResponder) {
diff --git a/components/script/canvas_context.rs b/components/script/canvas_context.rs
index 7dfdf48e3f5..ec388e039f1 100644
--- a/components/script/canvas_context.rs
+++ b/components/script/canvas_context.rs
@@ -125,7 +125,11 @@ impl CanvasContext for RenderingContext {
fn resize(&self) {
match self {
- RenderingContext::Placeholder(context) => (*context.context().unwrap()).resize(),
+ RenderingContext::Placeholder(offscreen_canvas) => {
+ if let Some(context) = offscreen_canvas.context() {
+ context.resize()
+ }
+ },
RenderingContext::Context2d(context) => context.resize(),
RenderingContext::WebGL(context) => context.resize(),
RenderingContext::WebGL2(context) => context.resize(),
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index a4b05e7f445..ad95b9b9a94 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -4313,9 +4313,7 @@ impl Document {
},
Some(csp_list) => {
let element = csp::Element {
- nonce: el
- .get_attribute(&ns!(), &local_name!("nonce"))
- .map(|attr| Cow::Owned(attr.value().to_string())),
+ nonce: el.nonce_attribute_if_nonceable().map(Cow::Owned),
};
csp_list.should_elements_inline_type_behavior_be_blocked(&element, type_, source)
},
@@ -6569,9 +6567,6 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
Ok(())
}
- // https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
- document_and_element_event_handlers!();
-
// https://fullscreen.spec.whatwg.org/#handler-document-onfullscreenerror
event_handler!(fullscreenerror, GetOnfullscreenerror, SetOnfullscreenerror);
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 7770d0c8fa5..5c79dbc0a5b 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -125,6 +125,7 @@ use crate::dom::htmllinkelement::HTMLLinkElement;
use crate::dom::htmlobjectelement::HTMLObjectElement;
use crate::dom::htmloptgroupelement::HTMLOptGroupElement;
use crate::dom::htmloutputelement::HTMLOutputElement;
+use crate::dom::htmlscriptelement::HTMLScriptElement;
use crate::dom::htmlselectelement::HTMLSelectElement;
use crate::dom::htmlslotelement::{HTMLSlotElement, Slottable};
use crate::dom::htmlstyleelement::HTMLStyleElement;
@@ -2174,6 +2175,34 @@ impl Element {
};
}
+ /// <https://www.w3.org/TR/CSP/#is-element-nonceable>
+ pub(crate) fn nonce_attribute_if_nonceable(&self) -> Option<String> {
+ // Step 1: If element does not have an attribute named "nonce", return "Not Nonceable".
+ let nonce_attribute = self.get_attribute(&ns!(), &local_name!("nonce"))?;
+ // Step 2: If element is a script element, then for each attribute of element’s attribute list:
+ if self.downcast::<HTMLScriptElement>().is_some() {
+ for attr in self.attrs().iter() {
+ // Step 2.1: If attribute’s name contains an ASCII case-insensitive match
+ // for "<script" or "<style", return "Not Nonceable".
+ let attr_name = attr.name().to_ascii_lowercase();
+ if attr_name.contains("<script") || attr_name.contains("<style") {
+ return None;
+ }
+ // Step 2.2: If attribute’s value contains an ASCII case-insensitive match
+ // for "<script" or "<style", return "Not Nonceable".
+ let attr_value = attr.value().to_ascii_lowercase();
+ if attr_value.contains("<script") || attr_value.contains("<style") {
+ return None;
+ }
+ }
+ }
+ // Step 3: If element had a duplicate-attribute parse error during tokenization, return "Not Nonceable".
+ // TODO(https://github.com/servo/servo/issues/4577 and https://github.com/whatwg/html/issues/3257):
+ // Figure out how to retrieve this information from the parser
+ // Step 4: Return "Nonceable".
+ Some(nonce_attribute.value().to_string().trim().to_owned())
+ }
+
// https://dom.spec.whatwg.org/#insert-adjacent
pub(crate) fn insert_adjacent(
&self,
diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs
index b4efba9bed9..19b0ab4efce 100644
--- a/components/script/dom/htmlbodyelement.rs
+++ b/components/script/dom/htmlbodyelement.rs
@@ -181,26 +181,31 @@ impl VirtualMethods for HTMLBodyElement {
(name, AttributeMutation::Set(_)) if name.starts_with("on") => {
let window = self.owner_window();
// https://html.spec.whatwg.org/multipage/
- // #event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-3
+ // #event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-6
match name {
- &local_name!("onfocus") |
- &local_name!("onload") |
- &local_name!("onscroll") |
&local_name!("onafterprint") |
&local_name!("onbeforeprint") |
&local_name!("onbeforeunload") |
+ &local_name!("onerror") |
+ &local_name!("onfocus") |
&local_name!("onhashchange") |
+ &local_name!("onload") |
&local_name!("onlanguagechange") |
&local_name!("onmessage") |
+ &local_name!("onmessageerror") |
&local_name!("onoffline") |
&local_name!("ononline") |
&local_name!("onpagehide") |
+ &local_name!("onpagereveal") |
&local_name!("onpageshow") |
+ &local_name!("onpageswap") |
&local_name!("onpopstate") |
- &local_name!("onstorage") |
+ &local_name!("onrejectionhandled") |
&local_name!("onresize") |
- &local_name!("onunload") |
- &local_name!("onerror") => {
+ &local_name!("onscroll") |
+ &local_name!("onstorage") |
+ &local_name!("onunhandledrejection") |
+ &local_name!("onunload") => {
let source = &**attr.value();
let evtarget = window.upcast::<EventTarget>(); // forwarded event
let source_line = 1; //TODO(#9604) obtain current JS execution line
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index 56e008839ba..c2bfc9c2d7f 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -103,10 +103,14 @@ impl EncodedImageType {
}
}
+/// <https://html.spec.whatwg.org/multipage/#htmlcanvaselement>
#[dom_struct]
pub(crate) struct HTMLCanvasElement {
htmlelement: HTMLElement,
- context: DomRefCell<Option<RenderingContext>>,
+
+ /// <https://html.spec.whatwg.org/multipage/#concept-canvas-context-mode>
+ context_mode: DomRefCell<Option<RenderingContext>>,
+
// This id and hashmap are used to keep track of ongoing toBlob() calls.
callback_id: Cell<u32>,
#[ignore_malloc_size_of = "not implemented for webidl callbacks"]
@@ -121,7 +125,7 @@ impl HTMLCanvasElement {
) -> HTMLCanvasElement {
HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
- context: DomRefCell::new(None),
+ context_mode: DomRefCell::new(None),
callback_id: Cell::new(0),
blob_callbacks: RefCell::new(HashMap::new()),
}
@@ -146,7 +150,7 @@ impl HTMLCanvasElement {
}
fn recreate_contexts_after_resize(&self) {
- if let Some(ref context) = *self.context.borrow() {
+ if let Some(ref context) = *self.context_mode.borrow() {
context.resize()
}
}
@@ -156,14 +160,14 @@ impl HTMLCanvasElement {
}
pub(crate) fn origin_is_clean(&self) -> bool {
- match *self.context.borrow() {
+ match *self.context_mode.borrow() {
Some(ref context) => context.origin_is_clean(),
_ => true,
}
}
pub(crate) fn mark_as_dirty(&self) {
- if let Some(ref context) = *self.context.borrow() {
+ if let Some(ref context) = *self.context_mode.borrow() {
context.mark_as_dirty()
}
}
@@ -193,7 +197,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
#[allow(unsafe_code)]
fn data(self) -> HTMLCanvasData {
let source = unsafe {
- match self.unsafe_get().context.borrow_for_layout().as_ref() {
+ match self.unsafe_get().context_mode.borrow_for_layout().as_ref() {
Some(RenderingContext::Context2d(context)) => {
context.to_layout().canvas_data_source()
},
@@ -221,7 +225,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> {
impl HTMLCanvasElement {
pub(crate) fn context(&self) -> Option<Ref<RenderingContext>> {
- ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref())
+ ref_filter_map(self.context_mode.borrow(), |ctx| ctx.as_ref())
}
fn get_or_init_2d_context(&self, can_gc: CanGc) -> Option<DomRoot<CanvasRenderingContext2D>> {
@@ -235,7 +239,8 @@ impl HTMLCanvasElement {
let window = self.owner_window();
let size = self.get_size();
let context = CanvasRenderingContext2D::new(window.as_global_scope(), self, size, can_gc);
- *self.context.borrow_mut() = Some(RenderingContext::Context2d(Dom::from_ref(&*context)));
+ *self.context_mode.borrow_mut() =
+ Some(RenderingContext::Context2d(Dom::from_ref(&*context)));
Some(context)
}
@@ -263,7 +268,7 @@ impl HTMLCanvasElement {
attrs,
can_gc,
)?;
- *self.context.borrow_mut() = Some(RenderingContext::WebGL(Dom::from_ref(&*context)));
+ *self.context_mode.borrow_mut() = Some(RenderingContext::WebGL(Dom::from_ref(&*context)));
Some(context)
}
@@ -288,7 +293,7 @@ impl HTMLCanvasElement {
let attrs = Self::get_gl_attributes(cx, options)?;
let canvas = HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(DomRoot::from_ref(self));
let context = WebGL2RenderingContext::new(&window, &canvas, size, attrs, can_gc)?;
- *self.context.borrow_mut() = Some(RenderingContext::WebGL2(Dom::from_ref(&*context)));
+ *self.context_mode.borrow_mut() = Some(RenderingContext::WebGL2(Dom::from_ref(&*context)));
Some(context)
}
@@ -315,7 +320,7 @@ impl HTMLCanvasElement {
.expect("Failed to get WebGPU channel")
.map(|channel| {
let context = GPUCanvasContext::new(&global_scope, self, channel, can_gc);
- *self.context.borrow_mut() =
+ *self.context_mode.borrow_mut() =
Some(RenderingContext::WebGPU(Dom::from_ref(&*context)));
context
})
@@ -323,7 +328,7 @@ impl HTMLCanvasElement {
/// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists.
pub(crate) fn get_base_webgl_context(&self) -> Option<DomRoot<WebGLRenderingContext>> {
- match *self.context.borrow() {
+ match *self.context_mode.borrow() {
Some(RenderingContext::WebGL(ref context)) => Some(DomRoot::from_ref(context)),
Some(RenderingContext::WebGL2(ref context)) => Some(context.base_context()),
_ => None,
@@ -352,7 +357,7 @@ impl HTMLCanvasElement {
}
pub(crate) fn get_image_data(&self) -> Option<Snapshot> {
- match self.context.borrow().as_ref() {
+ match self.context_mode.borrow().as_ref() {
Some(context) => context.get_image_data(),
None => {
let size = self.get_size();
@@ -431,12 +436,12 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
// https://html.spec.whatwg.org/multipage/#dom-canvas-width
make_uint_getter!(Width, "width", DEFAULT_WIDTH);
- // https://html.spec.whatwg.org/multipage/#dom-canvas-width
- // When setting the value of the width or height attribute, if the context mode of the canvas element
- // is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
- // attribute's value unchanged.
+ /// <https://html.spec.whatwg.org/multipage/#dom-canvas-width>
fn SetWidth(&self, value: u32, can_gc: CanGc) -> Fallible<()> {
- if let Some(RenderingContext::Placeholder(_)) = *self.context.borrow() {
+ // > When setting the value of the width or height attribute, if the context mode of the canvas element
+ // > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
+ // > attribute's value unchanged.
+ if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
return Err(Error::InvalidState);
}
@@ -453,9 +458,12 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
// https://html.spec.whatwg.org/multipage/#dom-canvas-height
make_uint_getter!(Height, "height", DEFAULT_HEIGHT);
- // https://html.spec.whatwg.org/multipage/#dom-canvas-height
+ /// <https://html.spec.whatwg.org/multipage/#dom-canvas-height>
fn SetHeight(&self, value: u32, can_gc: CanGc) -> Fallible<()> {
- if let Some(RenderingContext::Placeholder(_)) = *self.context.borrow() {
+ // > When setting the value of the width or height attribute, if the context mode of the canvas element
+ // > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
+ // > attribute's value unchanged.
+ if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
return Err(Error::InvalidState);
}
@@ -478,7 +486,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
can_gc: CanGc,
) -> Fallible<Option<RootedRenderingContext>> {
// Always throw an InvalidState exception when the canvas is in Placeholder mode (See table in the spec).
- if let Some(RenderingContext::Placeholder(_)) = *self.context.borrow() {
+ if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
return Err(Error::InvalidState);
}
@@ -622,7 +630,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
/// <https://html.spec.whatwg.org/multipage/#dom-canvas-transfercontroltooffscreen>
fn TransferControlToOffscreen(&self, can_gc: CanGc) -> Fallible<DomRoot<OffscreenCanvas>> {
- if self.context.borrow().is_some() {
+ if self.context_mode.borrow().is_some() {
// Step 1.
// If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException.
return Err(Error::InvalidState);
@@ -641,8 +649,9 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
Some(&Dom::from_ref(self)),
can_gc,
);
+
// Step 4. Set this canvas element's context mode to placeholder.
- *self.context.borrow_mut() =
+ *self.context_mode.borrow_mut() =
Some(RenderingContext::Placeholder(offscreen_canvas.as_traced()));
// Step 5. Return offscreenCanvas.
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 59b71543d6d..32a979ad138 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -191,9 +191,6 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement {
// https://html.spec.whatwg.org/multipage/#globaleventhandlers
global_event_handlers!(NoOnload);
- // https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
- document_and_element_event_handlers!();
-
// https://html.spec.whatwg.org/multipage/#dom-dataset
fn Dataset(&self, can_gc: CanGc) -> DomRoot<DOMStringMap> {
self.dataset.or_init(|| DOMStringMap::new(self, can_gc))
diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs
index 55ffa92257b..f5256e71b70 100644
--- a/components/script/dom/htmloptgroupelement.rs
+++ b/components/script/dom/htmloptgroupelement.rs
@@ -135,8 +135,8 @@ impl VirtualMethods for HTMLOptGroupElement {
}
fn bind_to_tree(&self, context: &BindContext, can_gc: CanGc) {
- if let Some(s) = self.super_type() {
- s.bind_to_tree(context, can_gc);
+ if let Some(super_type) = self.super_type() {
+ super_type.bind_to_tree(context, can_gc);
}
self.update_select_validity(can_gc);
diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs
index b573388c73a..800e88f0758 100644
--- a/components/script/dom/htmloptionelement.rs
+++ b/components/script/dom/htmloptionelement.rs
@@ -29,7 +29,7 @@ use crate::dom::htmlformelement::HTMLFormElement;
use crate::dom::htmloptgroupelement::HTMLOptGroupElement;
use crate::dom::htmlscriptelement::HTMLScriptElement;
use crate::dom::htmlselectelement::HTMLSelectElement;
-use crate::dom::node::{BindContext, Node, ShadowIncluding, UnbindContext};
+use crate::dom::node::{BindContext, ChildrenMutation, Node, ShadowIncluding, UnbindContext};
use crate::dom::text::Text;
use crate::dom::validation::Validatable;
use crate::dom::validitystate::ValidationFlags;
@@ -380,4 +380,26 @@ impl VirtualMethods for HTMLOptionElement {
el.check_disabled_attribute();
}
}
+
+ fn children_changed(&self, mutation: &ChildrenMutation) {
+ if let Some(super_type) = self.super_type() {
+ super_type.children_changed(mutation);
+ }
+
+ // Changing the descendants of a selected option can change it's displayed label
+ // if it does not have a label attribute
+ if !self
+ .upcast::<Element>()
+ .has_attribute(&local_name!("label"))
+ {
+ if let Some(owner_select) = self.owner_select_element() {
+ if owner_select
+ .selected_option()
+ .is_some_and(|selected_option| self == &*selected_option)
+ {
+ owner_select.update_shadow_tree(CanGc::note());
+ }
+ }
+ }
+ }
}
diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs
index f4a62abe8b4..56fac20e841 100644
--- a/components/script/dom/htmlselectelement.rs
+++ b/components/script/dom/htmlselectelement.rs
@@ -153,7 +153,7 @@ impl HTMLSelectElement {
n
}
- // https://html.spec.whatwg.org/multipage/#concept-select-option-list
+ /// <https://html.spec.whatwg.org/multipage/#concept-select-option-list>
pub(crate) fn list_of_options(
&self,
) -> impl Iterator<Item = DomRoot<HTMLOptionElement>> + use<'_> {
@@ -353,8 +353,10 @@ impl HTMLSelectElement {
.fire_bubbling_event(atom!("change"), can_gc);
}
- fn selected_option(&self) -> Option<DomRoot<HTMLOptionElement>> {
- self.list_of_options().find(|opt_elem| opt_elem.Selected())
+ pub(crate) fn selected_option(&self) -> Option<DomRoot<HTMLOptionElement>> {
+ self.list_of_options()
+ .find(|opt_elem| opt_elem.Selected())
+ .or_else(|| self.list_of_options().next())
}
pub(crate) fn show_menu(&self, can_gc: CanGc) -> Option<usize> {
@@ -539,7 +541,8 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
/// <https://html.spec.whatwg.org/multipage/#dom-select-value>
fn Value(&self) -> DOMString {
- self.selected_option()
+ self.list_of_options()
+ .find(|opt_elem| opt_elem.Selected())
.map(|opt_elem| opt_elem.Value())
.unwrap_or_default()
}
diff --git a/components/script/dom/intersectionobserver.rs b/components/script/dom/intersectionobserver.rs
index ec98116d3a4..6a6f9ce45eb 100644
--- a/components/script/dom/intersectionobserver.rs
+++ b/components/script/dom/intersectionobserver.rs
@@ -524,11 +524,10 @@ impl IntersectionObserver {
// Step 9
// > Let targetArea be targetRect’s area.
- let target_area = target_rect.size.width.0 * target_rect.size.height.0;
-
// Step 10
// > Let intersectionArea be intersectionRect’s area.
- let intersection_area = intersection_rect.size.width.0 * intersection_rect.size.height.0;
+ // These steps are folded in Step 12, rewriting (w1 * h1) / (w2 * h2) as (w1 / w2) * (h1 / h2)
+ // to avoid multiplication overflows.
// Step 11
// > Let isIntersecting be true if targetRect and rootBounds intersect or are edge-adjacent,
@@ -545,9 +544,12 @@ impl IntersectionObserver {
// Step 12
// > If targetArea is non-zero, let intersectionRatio be intersectionArea divided by targetArea.
// > Otherwise, let intersectionRatio be 1 if isIntersecting is true, or 0 if isIntersecting is false.
- let intersection_ratio = match target_area {
- 0 => is_intersecting.into(),
- _ => (intersection_area as f64) / (target_area as f64),
+ let intersection_ratio = if target_rect.size.width.0 == 0 || target_rect.size.height.0 == 0
+ {
+ is_intersecting.into()
+ } else {
+ (intersection_rect.size.width.0 as f64 / target_rect.size.width.0 as f64) *
+ (intersection_rect.size.height.0 as f64 / target_rect.size.height.0 as f64)
};
// Step 13
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index cc44497d0b9..564fe810db0 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -523,21 +523,29 @@ macro_rules! global_event_handlers(
);
(NoOnload) => (
event_handler!(abort, GetOnabort, SetOnabort);
+ event_handler!(auxclick, GetOnauxclick, SetOnauxclick);
event_handler!(animationend, GetOnanimationend, SetOnanimationend);
event_handler!(animationiteration, GetOnanimationiteration, SetOnanimationiteration);
+ event_handler!(beforeinput, GetOnbeforeinput, SetOnbeforeinput);
+ event_handler!(beforematch, GetOnbeforematch, SetOnbeforematch);
+ event_handler!(beforetoggle, GetOnbeforetoggle, SetOnbeforetoggle);
event_handler!(cancel, GetOncancel, SetOncancel);
event_handler!(canplay, GetOncanplay, SetOncanplay);
event_handler!(canplaythrough, GetOncanplaythrough, SetOncanplaythrough);
event_handler!(change, GetOnchange, SetOnchange);
event_handler!(click, GetOnclick, SetOnclick);
event_handler!(close, GetOnclose, SetOnclose);
+ event_handler!(command, GetOncommand, SetOncommand);
+ event_handler!(contextlost, GetOncontextlost, SetOncontextlost);
event_handler!(contextmenu, GetOncontextmenu, SetOncontextmenu);
+ event_handler!(contextrestored, GetOncontextrestored, SetOncontextrestored);
+ event_handler!(copy, GetOncopy, SetOncopy);
event_handler!(cuechange, GetOncuechange, SetOncuechange);
+ event_handler!(cut, GetOncut, SetOncut);
event_handler!(dblclick, GetOndblclick, SetOndblclick);
event_handler!(drag, GetOndrag, SetOndrag);
event_handler!(dragend, GetOndragend, SetOndragend);
event_handler!(dragenter, GetOndragenter, SetOndragenter);
- event_handler!(dragexit, GetOndragexit, SetOndragexit);
event_handler!(dragleave, GetOndragleave, SetOndragleave);
event_handler!(dragover, GetOndragover, SetOndragover);
event_handler!(dragstart, GetOndragstart, SetOndragstart);
@@ -561,20 +569,21 @@ macro_rules! global_event_handlers(
event_handler!(mouseout, GetOnmouseout, SetOnmouseout);
event_handler!(mouseover, GetOnmouseover, SetOnmouseover);
event_handler!(mouseup, GetOnmouseup, SetOnmouseup);
- event_handler!(wheel, GetOnwheel, SetOnwheel);
+ event_handler!(paste, GetOnpaste, SetOnpaste);
event_handler!(pause, GetOnpause, SetOnpause);
event_handler!(play, GetOnplay, SetOnplay);
event_handler!(playing, GetOnplaying, SetOnplaying);
event_handler!(progress, GetOnprogress, SetOnprogress);
event_handler!(ratechange, GetOnratechange, SetOnratechange);
event_handler!(reset, GetOnreset, SetOnreset);
+ event_handler!(scrollend, GetOnscrollend, SetOnscrollend);
event_handler!(securitypolicyviolation, GetOnsecuritypolicyviolation, SetOnsecuritypolicyviolation);
event_handler!(seeked, GetOnseeked, SetOnseeked);
event_handler!(seeking, GetOnseeking, SetOnseeking);
event_handler!(select, GetOnselect, SetOnselect);
event_handler!(selectionchange, GetOnselectionchange, SetOnselectionchange);
event_handler!(selectstart, GetOnselectstart, SetOnselectstart);
- event_handler!(show, GetOnshow, SetOnshow);
+ event_handler!(slotchange, GetOnslotchange, SetOnslotchange);
event_handler!(stalled, GetOnstalled, SetOnstalled);
event_handler!(submit, GetOnsubmit, SetOnsubmit);
event_handler!(suspend, GetOnsuspend, SetOnsuspend);
@@ -585,6 +594,11 @@ macro_rules! global_event_handlers(
event_handler!(transitionrun, GetOntransitionrun, SetOntransitionrun);
event_handler!(volumechange, GetOnvolumechange, SetOnvolumechange);
event_handler!(waiting, GetOnwaiting, SetOnwaiting);
+ event_handler!(webkitanimationend, GetOnwebkitanimationend, SetOnwebkitanimationend);
+ event_handler!(webkitanimationiteration, GetOnwebkitanimationiteration, SetOnwebkitanimationiteration);
+ event_handler!(webkitanimationstart, GetOnwebkitanimationstart, SetOnwebkitanimationstart);
+ event_handler!(webkittransitionend, GetOnwebkittransitionend, SetOnwebkittransitionend);
+ event_handler!(wheel, GetOnwheel, SetOnwheel);
)
);
@@ -605,7 +619,9 @@ macro_rules! window_event_handlers(
event_handler!(offline, GetOnoffline, SetOnoffline);
event_handler!(online, GetOnonline, SetOnonline);
event_handler!(pagehide, GetOnpagehide, SetOnpagehide);
+ event_handler!(pagereveal, GetOnpagereveal, SetOnpagereveal);
event_handler!(pageshow, GetOnpageshow, SetOnpageshow);
+ event_handler!(pageswap, GetOnpageswap, SetOnpageswap);
event_handler!(popstate, GetOnpopstate, SetOnpopstate);
event_handler!(rejectionhandled, GetOnrejectionhandled,
SetOnrejectionhandled);
@@ -633,7 +649,9 @@ macro_rules! window_event_handlers(
window_owned_event_handler!(offline, GetOnoffline, SetOnoffline);
window_owned_event_handler!(online, GetOnonline, SetOnonline);
window_owned_event_handler!(pagehide, GetOnpagehide, SetOnpagehide);
+ window_owned_event_handler!(pagereveal, GetOnpagereveal, SetOnpagereveal);
window_owned_event_handler!(pageshow, GetOnpageshow, SetOnpageshow);
+ window_owned_event_handler!(pageswap, GetOnpageswap, SetOnpageswap);
window_owned_event_handler!(popstate, GetOnpopstate, SetOnpopstate);
window_owned_event_handler!(rejectionhandled, GetOnrejectionhandled,
SetOnrejectionhandled);
@@ -646,17 +664,6 @@ macro_rules! window_event_handlers(
);
);
-// https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
-// see webidls/EventHandler.webidl
-// As more methods get added, just update them here.
-macro_rules! document_and_element_event_handlers(
- () => (
- event_handler!(cut, GetOncut, SetOncut);
- event_handler!(copy, GetOncopy, SetOncopy);
- event_handler!(paste, GetOnpaste, SetOnpaste);
- )
-);
-
/// DOM struct implementation for simple interfaces inheriting from PerformanceEntry.
macro_rules! impl_performance_entry_struct(
($binding:ident, $struct:ident, $type:expr) => (
diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs
index 9947d35f4e0..bceed49ac7d 100644
--- a/components/script/dom/offscreencanvas.rs
+++ b/components/script/dom/offscreencanvas.rs
@@ -24,12 +24,20 @@ use crate::dom::htmlcanvaselement::HTMLCanvasElement;
use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D;
use crate::script_runtime::{CanGc, JSContext};
+/// <https://html.spec.whatwg.org/multipage/#offscreencanvas>
#[dom_struct]
pub(crate) struct OffscreenCanvas {
eventtarget: EventTarget,
width: Cell<u64>,
height: Cell<u64>,
+
+ /// Represents both the [bitmap] and the [context mode] of the canvas.
+ ///
+ /// [bitmap]: https://html.spec.whatwg.org/multipage/#offscreencanvas-bitmap
+ /// [context mode]: https://html.spec.whatwg.org/multipage/#offscreencanvas-context-mode
context: DomRefCell<Option<OffscreenRenderingContext>>,
+
+ /// <https://html.spec.whatwg.org/multipage/#offscreencanvas-placeholder>
placeholder: Option<Dom<HTMLCanvasElement>>,
}
@@ -119,7 +127,7 @@ impl OffscreenCanvas {
}
impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas>
fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
@@ -131,7 +139,7 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
Ok(offscreencanvas)
}
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-getcontext
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-getcontext>
fn GetContext(
&self,
_cx: JSContext,
@@ -155,12 +163,12 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
}
}
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width>
fn Width(&self) -> u64 {
self.width.get()
}
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-width>
fn SetWidth(&self, value: u64, can_gc: CanGc) {
self.width.set(value);
@@ -173,12 +181,12 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
}
}
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height>
fn Height(&self) -> u64 {
self.height.get()
}
- // https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height
+ /// <https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-height>
fn SetHeight(&self, value: u64, can_gc: CanGc) {
self.height.set(value);
diff --git a/components/script_bindings/webidls/Document.webidl b/components/script_bindings/webidls/Document.webidl
index 737e74d3bf2..e878b1642e4 100644
--- a/components/script_bindings/webidls/Document.webidl
+++ b/components/script_bindings/webidls/Document.webidl
@@ -154,7 +154,6 @@ partial /*sealed*/ interface Document {
// also has obsolete members
};
Document includes GlobalEventHandlers;
-Document includes DocumentAndElementEventHandlers;
// https://html.spec.whatwg.org/multipage/#Document-partial
partial interface Document {
diff --git a/components/script_bindings/webidls/EventHandler.webidl b/components/script_bindings/webidls/EventHandler.webidl
index f597ce237d3..d32302f4b37 100644
--- a/components/script_bindings/webidls/EventHandler.webidl
+++ b/components/script_bindings/webidls/EventHandler.webidl
@@ -28,6 +28,10 @@ typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;
[Exposed=Window]
interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
+ attribute EventHandler onauxclick;
+ attribute EventHandler onbeforeinput;
+ attribute EventHandler onbeforematch;
+ attribute EventHandler onbeforetoggle;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
@@ -35,13 +39,17 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
+ attribute EventHandler oncommand;
+ attribute EventHandler oncontextlost;
attribute EventHandler oncontextmenu;
+ attribute EventHandler oncontextrestored;
+ attribute EventHandler oncopy;
attribute EventHandler oncuechange;
+ attribute EventHandler oncut;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
- attribute EventHandler ondragexit;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
@@ -68,7 +76,7 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
- attribute EventHandler onwheel;
+ attribute EventHandler onpaste;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
@@ -77,11 +85,12 @@ interface mixin GlobalEventHandlers {
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
+ attribute EventHandler onscrollend;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
- attribute EventHandler onshow;
+ attribute EventHandler onslotchange;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
@@ -89,6 +98,11 @@ interface mixin GlobalEventHandlers {
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
+ attribute EventHandler onwebkitanimationend;
+ attribute EventHandler onwebkitanimationiteration;
+ attribute EventHandler onwebkitanimationstart;
+ attribute EventHandler onwebkittransitionend;
+ attribute EventHandler onwheel;
};
// https://drafts.csswg.org/css-animations/#interface-globaleventhandlers-idl
@@ -123,18 +137,12 @@ interface mixin WindowEventHandlers {
attribute EventHandler onoffline;
attribute EventHandler ononline;
attribute EventHandler onpagehide;
+ attribute EventHandler onpagereveal;
attribute EventHandler onpageshow;
+ attribute EventHandler onpageswap;
attribute EventHandler onpopstate;
attribute EventHandler onrejectionhandled;
attribute EventHandler onstorage;
attribute EventHandler onunhandledrejection;
attribute EventHandler onunload;
};
-
-// https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers
-[Exposed=Window]
-interface mixin DocumentAndElementEventHandlers {
- attribute EventHandler oncopy;
- attribute EventHandler oncut;
- attribute EventHandler onpaste;
-};
diff --git a/components/script_bindings/webidls/HTMLElement.webidl b/components/script_bindings/webidls/HTMLElement.webidl
index 76bfada1b94..19a4b515d11 100644
--- a/components/script_bindings/webidls/HTMLElement.webidl
+++ b/components/script_bindings/webidls/HTMLElement.webidl
@@ -73,7 +73,6 @@ partial interface HTMLElement {
};
HTMLElement includes GlobalEventHandlers;
-HTMLElement includes DocumentAndElementEventHandlers;
HTMLElement includes ElementContentEditable;
HTMLElement includes ElementCSSInlineStyle;
HTMLElement includes HTMLOrSVGElement;
diff --git a/components/webdriver_server/actions.rs b/components/webdriver_server/actions.rs
index b18a6eaaf2e..9136e091472 100644
--- a/components/webdriver_server/actions.rs
+++ b/components/webdriver_server/actions.rs
@@ -16,9 +16,9 @@ use webdriver::actions::{
PointerDownAction, PointerMoveAction, PointerOrigin, PointerType, PointerUpAction, WheelAction,
WheelActionItem, WheelScrollAction,
};
-use webdriver::error::ErrorStatus;
+use webdriver::error::{ErrorStatus, WebDriverError};
-use crate::Handler;
+use crate::{Handler, wait_for_script_response};
// Interval between wheelScroll and pointerMove increments in ms, based on common vsync
static POINTERMOVE_INTERVAL: u64 = 17;
@@ -399,8 +399,11 @@ impl Handler {
WebDriverScriptCommand::GetElementInViewCenterPoint(x.to_string(), sender),
)
.unwrap();
-
- let Some(point) = receiver.recv().unwrap()? else {
+ let response = match wait_for_script_response(receiver) {
+ Ok(response) => response,
+ Err(WebDriverError { error, .. }) => return Err(error),
+ };
+ let Ok(Some(point)) = response else {
return Err(ErrorStatus::UnknownError);
};
point
@@ -645,19 +648,14 @@ impl Handler {
.send(EmbedderToConstellationMessage::WebDriverCommand(cmd_msg))
.unwrap();
- match receiver.recv() {
- Ok(viewport_size) => {
- if x < 0 ||
- x as f32 > viewport_size.width ||
- y < 0 ||
- y as f32 > viewport_size.height
- {
- Err(ErrorStatus::MoveTargetOutOfBounds)
- } else {
- Ok(())
- }
- },
- Err(_) => Err(ErrorStatus::UnknownError),
+ let viewport_size = match wait_for_script_response(receiver) {
+ Ok(response) => response,
+ Err(WebDriverError { error, .. }) => return Err(error),
+ };
+ if x < 0 || x as f32 > viewport_size.width || y < 0 || y as f32 > viewport_size.height {
+ Err(ErrorStatus::MoveTargetOutOfBounds)
+ } else {
+ Ok(())
}
}
}