From 1771f9a9a1d75e39c5ef9ccd06d247f024b0d8fe Mon Sep 17 00:00:00 2001 From: Daniel Adams <70986246+msub2@users.noreply.github.com> Date: Fri, 8 Mar 2024 00:35:27 -0500 Subject: [PATCH 01/82] Fix broken wiki link in README for Android instructions (#31574) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cdd3f52a5e9..e82954f54cc 100644 --- a/README.md +++ b/README.md @@ -204,4 +204,4 @@ The generated documentation can be found on https://doc.servo.org/servo/index.ht [manual-build]: https://github.com/servo/servo/wiki/Building#manual-build-setup [windows-tips]: https://github.com/servo/servo/wiki/Building#troubleshooting-the-windows-build -[android-docs]: https://github.com/servo/servo/wiki/Android +[android-docs]: https://github.com/servo/servo/wiki/Building-for-Android From 88033bd65435ff502b847ecc783616c4f2ff74bd Mon Sep 17 00:00:00 2001 From: eri Date: Fri, 8 Mar 2024 08:10:15 +0100 Subject: [PATCH 02/82] clippy: fix warnings in components/gfx (#31560) * clippy: fix warnings in components/gfx * refactor: switched the order of impl so that its intent is clearer * fix: add font context default in other platforms --- components/gfx/font.rs | 32 ++++----- components/gfx/font_cache_thread.rs | 34 ++++------ components/gfx/font_context.rs | 53 +++++++-------- components/gfx/font_template.rs | 16 ++--- components/gfx/platform/freetype/font.rs | 29 ++++---- .../gfx/platform/freetype/font_context.rs | 4 +- components/gfx/platform/freetype/font_list.rs | 10 +-- .../gfx/platform/freetype/font_template.rs | 5 +- components/gfx/platform/macos/font_context.rs | 10 +-- .../gfx/platform/windows/font_context.rs | 9 +-- components/gfx/rendering_context.rs | 60 ++++++++--------- components/gfx/tests/font_context.rs | 8 +-- components/gfx/tests/font_template.rs | 2 +- components/gfx/text/glyph.rs | 58 ++++++++-------- components/gfx/text/shaping/harfbuzz.rs | 66 +++++++++---------- components/gfx/text/text_run.rs | 26 ++++---- components/gfx/text/util.rs | 7 +- 17 files changed, 195 insertions(+), 234 deletions(-) diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 9fd25b839d0..885a89db25a 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -96,7 +96,7 @@ impl FontTableTagConversions for FontTableTag { (self >> 24) as u8, (self >> 16) as u8, (self >> 8) as u8, - (self >> 0) as u8, + *self as u8, ]; str::from_utf8(&bytes).unwrap().to_owned() } @@ -190,7 +190,7 @@ impl Font { let metrics = handle.metrics(); Font { - handle: handle, + handle, shaper: None, descriptor, metrics, @@ -403,7 +403,7 @@ impl FontGroup { .font_family .families .iter() - .map(|family| FontGroupFamily::new(descriptor.clone(), &family)) + .map(|family| FontGroupFamily::new(descriptor.clone(), family)) .collect(); FontGroup { @@ -419,7 +419,7 @@ impl FontGroup { /// found, returns None. pub fn find_by_codepoint( &mut self, - mut font_context: &mut FontContext, + font_context: &mut FontContext, codepoint: char, ) -> Option { let should_look_for_small_caps = self.descriptor.variant == font_variant_caps::T::SmallCaps && @@ -436,43 +436,40 @@ impl FontGroup { let has_glyph = |font: &FontRef| font.borrow().has_glyph_for(codepoint); - if let Some(font) = self.find(&mut font_context, |font| has_glyph(font)) { + if let Some(font) = self.find(font_context, has_glyph) { return font_or_synthesized_small_caps(font); } if let Some(ref last_matching_fallback) = self.last_matching_fallback { - if has_glyph(&last_matching_fallback) { + if has_glyph(last_matching_fallback) { return font_or_synthesized_small_caps(last_matching_fallback.clone()); } } - if let Some(font) = self.find_fallback(&mut font_context, Some(codepoint), has_glyph) { + if let Some(font) = self.find_fallback(font_context, Some(codepoint), has_glyph) { self.last_matching_fallback = Some(font.clone()); return font_or_synthesized_small_caps(font); } - self.first(&mut font_context) + self.first(font_context) } /// Find the first available font in the group, or the first available fallback font. - pub fn first( - &mut self, - mut font_context: &mut FontContext, - ) -> Option { - self.find(&mut font_context, |_| true) - .or_else(|| self.find_fallback(&mut font_context, None, |_| true)) + pub fn first(&mut self, font_context: &mut FontContext) -> Option { + self.find(font_context, |_| true) + .or_else(|| self.find_fallback(font_context, None, |_| true)) } /// Find a font which returns true for `predicate`. This method mutates because we may need to /// load new font data in the process of finding a suitable font. - fn find(&mut self, mut font_context: &mut FontContext, predicate: P) -> Option + fn find(&mut self, font_context: &mut FontContext, predicate: P) -> Option where S: FontSource, P: FnMut(&FontRef) -> bool, { self.families .iter_mut() - .filter_map(|family| family.font(&mut font_context)) + .filter_map(|family| family.font(font_context)) .find(predicate) } @@ -567,8 +564,7 @@ impl RunMetrics { } pub fn get_and_reset_text_shaping_performance_counter() -> usize { - let value = TEXT_SHAPING_PERFORMANCE_COUNTER.swap(0, Ordering::SeqCst); - value + TEXT_SHAPING_PERFORMANCE_COUNTER.swap(0, Ordering::SeqCst) } /// The scope within which we will look for a font. diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index bc8e7680417..5b954a33346 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -31,6 +31,7 @@ use crate::platform::font_list::{ use crate::platform::font_template::FontTemplateData; /// A list of font templates that make up a given font family. +#[derive(Default)] pub struct FontTemplates { templates: Vec, } @@ -61,10 +62,6 @@ impl SerializedFontTemplate { } impl FontTemplates { - pub fn new() -> FontTemplates { - FontTemplates { templates: vec![] } - } - /// Find a font in this family that matches a given descriptor. pub fn find_font_for_style( &mut self, @@ -214,7 +211,7 @@ impl FontCache { font_key: font_template_info.font_key, }, ))); - let _ = bytes_sender.send(&*font_template_info.font_template.bytes()); + let _ = bytes_sender.send(&font_template_info.font_template.bytes()); }, }; }, @@ -262,7 +259,7 @@ impl FontCache { }; if !self.web_families.contains_key(&family_name) { - let templates = FontTemplates::new(); + let templates = FontTemplates::default(); self.web_families.insert(family_name.clone(), templates); } @@ -298,7 +295,7 @@ impl FontCache { FetchResponseMsg::ProcessResponseChunk(new_bytes) => { trace!("@font-face {} chunk={:?}", family_name, new_bytes); if *response_valid.lock().unwrap() { - bytes.lock().unwrap().extend(new_bytes.into_iter()) + bytes.lock().unwrap().extend(new_bytes) } }, FetchResponseMsg::ProcessResponseEOF(response) => { @@ -312,7 +309,7 @@ impl FontCache { channel_to_self.send(msg).unwrap(); return; } - let bytes = mem::replace(&mut *bytes.lock().unwrap(), vec![]); + let bytes = mem::take(&mut *bytes.lock().unwrap()); trace!("@font-face {} data={:?}", family_name, bytes); let bytes = match fontsan::process(&bytes) { Ok(san) => san, @@ -365,10 +362,7 @@ impl FontCache { self.local_families.clear(); for_each_available_family(|family_name| { let family_name = LowercaseString::new(&family_name); - if !self.local_families.contains_key(&family_name) { - let templates = FontTemplates::new(); - self.local_families.insert(family_name, templates); - } + self.local_families.entry(family_name).or_default(); }); } @@ -443,7 +437,7 @@ impl FontCache { FontTemplateInfo { font_template: template, - font_key: font_key, + font_key, } } @@ -454,13 +448,13 @@ impl FontCache { ) -> Option { match family_descriptor.scope { FontSearchScope::Any => self - .find_font_in_web_family(&template_descriptor, &family_descriptor.name) + .find_font_in_web_family(template_descriptor, &family_descriptor.name) .or_else(|| { - self.find_font_in_local_family(&template_descriptor, &family_descriptor.name) + self.find_font_in_local_family(template_descriptor, &family_descriptor.name) }), FontSearchScope::Local => { - self.find_font_in_local_family(&template_descriptor, &family_descriptor.name) + self.find_font_in_local_family(template_descriptor, &family_descriptor.name) }, } .map(|t| self.get_font_template_info(t)) @@ -489,12 +483,12 @@ impl FontCacheThread { let generic_fonts = populate_generic_fonts(); let mut cache = FontCache { - port: port, + port, channel_to_self, generic_fonts, local_families: HashMap::new(), web_families: HashMap::new(), - font_context: FontContextHandle::new(), + font_context: FontContextHandle::default(), core_resource_thread, webrender_api, webrender_fonts: HashMap::new(), @@ -506,7 +500,7 @@ impl FontCacheThread { }) .expect("Thread spawning failed"); - FontCacheThread { chan: chan } + FontCacheThread { chan } } pub fn add_web_font( @@ -621,7 +615,7 @@ impl Deref for LowercaseString { #[inline] fn deref(&self) -> &str { - &*self.inner + &self.inner } } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 3a577a1fbd1..bd4a80d82f3 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -65,7 +65,7 @@ pub struct FontContext { impl FontContext { pub fn new(font_source: S) -> FontContext { - let handle = FontContextHandle::new(); + let handle = FontContextHandle::default(); FontContext { platform_handle: handle, font_source, @@ -99,8 +99,8 @@ impl FontContext { style, }; - if let Some(ref font_group) = self.font_group_cache.get(&cache_key) { - return (*font_group).clone(); + if let Some(font_group) = self.font_group_cache.get(&cache_key) { + return font_group.clone(); } let font_group = Rc::new(RefCell::new(FontGroup::new(&cache_key.style))); @@ -150,30 +150,27 @@ impl FontContext { family_descriptor: family_descriptor.clone(), }; - self.font_cache - .get(&cache_key) - .map(|v| v.clone()) - .unwrap_or_else(|| { - debug!( - "FontContext::font cache miss for font_descriptor={:?} family_descriptor={:?}", - font_descriptor, family_descriptor - ); + self.font_cache.get(&cache_key).cloned().unwrap_or_else(|| { + debug!( + "FontContext::font cache miss for font_descriptor={:?} family_descriptor={:?}", + font_descriptor, family_descriptor + ); - let font = self - .font_template(&font_descriptor.template_descriptor, family_descriptor) - .and_then(|template_info| { - self.create_font( - template_info, - font_descriptor.to_owned(), - synthesized_small_caps_font, - ) - .ok() - }) - .map(|font| Rc::new(RefCell::new(font))); + let font = self + .font_template(&font_descriptor.template_descriptor, family_descriptor) + .and_then(|template_info| { + self.create_font( + template_info, + font_descriptor.to_owned(), + synthesized_small_caps_font, + ) + .ok() + }) + .map(|font| Rc::new(RefCell::new(font))); - self.font_cache.insert(cache_key, font.clone()); - font - }) + self.font_cache.insert(cache_key, font.clone()); + font + }) } fn font_template( @@ -182,11 +179,11 @@ impl FontContext { family_descriptor: &FontFamilyDescriptor, ) -> Option { let cache_key = FontTemplateCacheKey { - template_descriptor: template_descriptor.clone(), + template_descriptor: *template_descriptor, family_descriptor: family_descriptor.clone(), }; - self.font_template_cache.get(&cache_key).map(|v| v.clone()).unwrap_or_else(|| { + self.font_template_cache.get(&cache_key).cloned().unwrap_or_else(|| { debug!( "FontContext::font_template cache miss for template_descriptor={:?} family_descriptor={:?}", template_descriptor, @@ -194,7 +191,7 @@ impl FontContext { ); let template_info = self.font_source.font_template( - template_descriptor.clone(), + *template_descriptor, family_descriptor.clone(), ); diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index 3ac7026c29a..ff4e1d49824 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -109,18 +109,12 @@ impl FontTemplate { None => None, }; - let maybe_strong_ref = match maybe_data { - Some(data) => Some(Arc::new(data)), - None => None, - }; + let maybe_strong_ref = maybe_data.map(Arc::new); - let maybe_weak_ref = match maybe_strong_ref { - Some(ref strong_ref) => Some(Arc::downgrade(strong_ref)), - None => None, - }; + let maybe_weak_ref = maybe_strong_ref.as_ref().map(Arc::downgrade); Ok(FontTemplate { - identifier: identifier, + identifier, descriptor: None, weak_ref: maybe_weak_ref, strong_ref: maybe_strong_ref, @@ -161,7 +155,7 @@ impl FontTemplate { fctx: &FontContextHandle, requested_desc: &FontTemplateDescriptor, ) -> Option> { - self.descriptor(&fctx).and_then(|descriptor| { + self.descriptor(fctx).and_then(|descriptor| { if *requested_desc == descriptor { self.data().ok() } else { @@ -177,7 +171,7 @@ impl FontTemplate { font_context: &FontContextHandle, requested_descriptor: &FontTemplateDescriptor, ) -> Option<(Arc, f32)> { - self.descriptor(&font_context).and_then(|descriptor| { + self.descriptor(font_context).and_then(|descriptor| { self.data() .ok() .map(|data| (data, descriptor.distance_from(requested_descriptor))) diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index a0de645a544..39cd4958d5f 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -147,7 +147,7 @@ impl FontHandleMethods for FontHandle { let face = create_face(ft_ctx, &template, pt_size)?; let mut handle = FontHandle { - face: face, + face, font_data: template, context_handle: fctx.clone(), can_do_fast_shaping: false, @@ -264,7 +264,7 @@ impl FontHandleMethods for FontHandle { let res = FT_Load_Glyph(self.face, glyph as FT_UInt, GLYPH_LOAD_FLAGS); if succeeded(res) { let void_glyph = (*self.face).glyph; - let slot: FT_GlyphSlot = mem::transmute(void_glyph); + let slot: FT_GlyphSlot = void_glyph; assert!(!slot.is_null()); let advance = (*slot).metrics.horiAdvance; debug!("h_advance for {} is {}", glyph, advance); @@ -313,17 +313,17 @@ impl FontHandleMethods for FontHandle { .map_or(max_advance, |advance| self.font_units_to_au(advance)); let metrics = FontMetrics { - underline_size: underline_size, - underline_offset: underline_offset, - strikeout_size: strikeout_size, - strikeout_offset: strikeout_offset, - leading: leading, - x_height: x_height, - em_size: em_size, - ascent: ascent, + underline_size, + underline_offset, + strikeout_size, + strikeout_offset, + leading, + x_height, + em_size, + ascent, descent: -descent, // linux font's seem to use the opposite sign from mac - max_advance: max_advance, - average_advance: average_advance, + max_advance, + average_advance, line_gap: height, }; @@ -392,6 +392,7 @@ impl<'a> FontHandle { } } + #[allow(clippy::mut_from_ref)] // Intended for this function fn face_rec_mut(&'a self) -> &'a mut FT_FaceRec { unsafe { &mut (*self.face) } } @@ -402,10 +403,10 @@ impl<'a> FontHandle { // face.size is a *c_void in the bindings, presumably to avoid // recursive structural types let size: &FT_SizeRec = unsafe { mem::transmute(&(*face.size)) }; - let metrics: &FT_Size_Metrics = &(*size).metrics; + let metrics: &FT_Size_Metrics = &(size).metrics; let em_size = face.units_per_EM as f64; - let x_scale = (metrics.x_ppem as f64) / em_size as f64; + let x_scale = (metrics.x_ppem as f64) / em_size; // If this isn't true then we're scaling one of the axes wrong assert_eq!(metrics.x_ppem, metrics.y_ppem); diff --git a/components/gfx/platform/freetype/font_context.rs b/components/gfx/platform/freetype/font_context.rs index c5df0598563..b08ff552261 100644 --- a/components/gfx/platform/freetype/font_context.rs +++ b/components/gfx/platform/freetype/font_context.rs @@ -109,8 +109,8 @@ impl MallocSizeOf for FontContextHandle { } } -impl FontContextHandle { - pub fn new() -> FontContextHandle { +impl Default for FontContextHandle { + fn default() -> Self { let user = Box::into_raw(Box::new(User { size: 0 })); let mem = Box::into_raw(Box::new(FT_MemoryRec_ { user: user as *mut c_void, diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs index a5363fc4848..e9e9ad7a531 100644 --- a/components/gfx/platform/freetype/font_list.rs +++ b/components/gfx/platform/freetype/font_list.rs @@ -17,10 +17,10 @@ use log::debug; use super::c_str_to_string; use crate::text::util::is_cjk; -static FC_FAMILY: &'static [u8] = b"family\0"; -static FC_FILE: &'static [u8] = b"file\0"; -static FC_INDEX: &'static [u8] = b"index\0"; -static FC_FONTFORMAT: &'static [u8] = b"fontformat\0"; +static FC_FAMILY: &[u8] = b"family\0"; +static FC_FILE: &[u8] = b"file\0"; +static FC_INDEX: &[u8] = b"index\0"; +static FC_FONTFORMAT: &[u8] = b"fontformat\0"; pub fn for_each_available_family(mut callback: F) where @@ -150,7 +150,7 @@ pub fn system_default_family(generic_name: &str) -> Option { } } -pub static SANS_SERIF_FONT_FAMILY: &'static str = "DejaVu Sans"; +pub static SANS_SERIF_FONT_FAMILY: &str = "DejaVu Sans"; // Based on gfxPlatformGtk::GetCommonFallbackFonts() in Gecko pub fn fallback_font_families(codepoint: Option) -> Vec<&'static str> { diff --git a/components/gfx/platform/freetype/font_template.rs b/components/gfx/platform/freetype/font_template.rs index cb3a1ef3857..b65bb8f4b04 100644 --- a/components/gfx/platform/freetype/font_template.rs +++ b/components/gfx/platform/freetype/font_template.rs @@ -36,10 +36,7 @@ impl fmt::Debug for FontTemplateData { impl FontTemplateData { pub fn new(identifier: Atom, bytes: Option>) -> Result { - Ok(FontTemplateData { - bytes: bytes, - identifier: identifier, - }) + Ok(FontTemplateData { bytes, identifier }) } /// Returns a clone of the data in this font. This may be a hugely expensive diff --git a/components/gfx/platform/macos/font_context.rs b/components/gfx/platform/macos/font_context.rs index 753cb97a572..b296ce6738b 100644 --- a/components/gfx/platform/macos/font_context.rs +++ b/components/gfx/platform/macos/font_context.rs @@ -4,16 +4,10 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct FontContextHandle { - _ctx: (), -} - -impl FontContextHandle { // this is a placeholder until NSFontManager or whatever is bound in here. - pub fn new() -> FontContextHandle { - FontContextHandle { _ctx: () } - } + _ctx: (), } impl MallocSizeOf for FontContextHandle { diff --git a/components/gfx/platform/windows/font_context.rs b/components/gfx/platform/windows/font_context.rs index d5e0015dd56..a67a366fc11 100644 --- a/components/gfx/platform/windows/font_context.rs +++ b/components/gfx/platform/windows/font_context.rs @@ -4,14 +4,7 @@ use malloc_size_of::malloc_size_of_is_0; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct FontContextHandle; -impl FontContextHandle { - // *shrug* - pub fn new() -> FontContextHandle { - FontContextHandle {} - } -} - malloc_size_of_is_0!(FontContextHandle); diff --git a/components/gfx/rendering_context.rs b/components/gfx/rendering_context.rs index 4e78ba9117c..9f3f733efd3 100644 --- a/components/gfx/rendering_context.rs +++ b/components/gfx/rendering_context.rs @@ -30,8 +30,8 @@ struct RenderingContextData { impl Drop for RenderingContextData { fn drop(&mut self) { - let ref mut device = self.device.borrow_mut(); - let ref mut context = self.context.borrow_mut(); + let device = &mut self.device.borrow_mut(); + let context = &mut self.context.borrow_mut(); if let Some(ref swap_chain) = self.swap_chain { let _ = swap_chain.destroy(device, context); } @@ -45,7 +45,7 @@ impl RenderingContext { adapter: &Adapter, surface_type: SurfaceType, ) -> Result { - let mut device = connection.create_device(&adapter)?; + let mut device = connection.create_device(adapter)?; let flags = ContextAttributeFlags::ALPHA | ContextAttributeFlags::DEPTH | ContextAttributeFlags::STENCIL; @@ -94,8 +94,8 @@ impl RenderingContext { &self, surface: Surface, ) -> Result { - let ref device = self.0.device.borrow(); - let ref mut context = self.0.context.borrow_mut(); + let device = &self.0.device.borrow(); + let context = &mut self.0.context.borrow_mut(); device.create_surface_texture(context, surface) } @@ -103,14 +103,14 @@ impl RenderingContext { &self, surface_texture: SurfaceTexture, ) -> Result { - let ref device = self.0.device.borrow(); - let ref mut context = self.0.context.borrow_mut(); + let device = &self.0.device.borrow(); + let context = &mut self.0.context.borrow_mut(); device.destroy_surface_texture(context, surface_texture) } pub fn make_gl_context_current(&self) -> Result<(), Error> { - let ref device = self.0.device.borrow(); - let ref context = self.0.context.borrow(); + let device = &self.0.device.borrow(); + let context = &self.0.context.borrow(); device.make_context_current(context) } @@ -119,8 +119,8 @@ impl RenderingContext { } pub fn resize(&self, size: Size2D) -> Result<(), Error> { - let ref mut device = self.0.device.borrow_mut(); - let ref mut context = self.0.context.borrow_mut(); + let device = &mut self.0.device.borrow_mut(); + let context = &mut self.0.context.borrow_mut(); if let Some(swap_chain) = self.0.swap_chain.as_ref() { return swap_chain.resize(device, context, size); } @@ -135,8 +135,8 @@ impl RenderingContext { } pub fn present(&self) -> Result<(), Error> { - let ref mut device = self.0.device.borrow_mut(); - let ref mut context = self.0.context.borrow_mut(); + let device = &mut self.0.device.borrow_mut(); + let context = &mut self.0.context.borrow_mut(); if let Some(ref swap_chain) = self.0.swap_chain { return swap_chain.swap_buffers(device, context, PreserveBuffer::No); } @@ -153,8 +153,8 @@ impl RenderingContext { /// Invoke a closure with the surface associated with the current front buffer. /// This can be used to create a surfman::SurfaceTexture to blit elsewhere. pub fn with_front_buffer Surface>(&self, mut f: F) { - let ref mut device = self.0.device.borrow_mut(); - let ref mut context = self.0.context.borrow_mut(); + let device = &mut self.0.device.borrow_mut(); + let context = &mut self.0.context.borrow_mut(); let surface = device .unbind_surface_from_context(context) .unwrap() @@ -168,52 +168,52 @@ impl RenderingContext { } pub fn connection(&self) -> Connection { - let ref device = self.0.device.borrow(); + let device = &self.0.device.borrow(); device.connection() } pub fn adapter(&self) -> Adapter { - let ref device = self.0.device.borrow(); + let device = &self.0.device.borrow(); device.adapter() } pub fn native_context(&self) -> NativeContext { - let ref device = self.0.device.borrow(); - let ref context = self.0.context.borrow(); + let device = &self.0.device.borrow(); + let context = &self.0.context.borrow(); device.native_context(context) } pub fn native_device(&self) -> NativeDevice { - let ref device = self.0.device.borrow(); + let device = &self.0.device.borrow(); device.native_device() } pub fn context_attributes(&self) -> ContextAttributes { - let ref device = self.0.device.borrow(); - let ref context = self.0.context.borrow(); - let ref descriptor = device.context_descriptor(context); + let device = &self.0.device.borrow(); + let context = &self.0.context.borrow(); + let descriptor = &device.context_descriptor(context); device.context_descriptor_attributes(descriptor) } pub fn context_surface_info(&self) -> Result, Error> { - let ref device = self.0.device.borrow(); - let ref context = self.0.context.borrow(); + let device = &self.0.device.borrow(); + let context = &self.0.context.borrow(); device.context_surface_info(context) } pub fn surface_info(&self, surface: &Surface) -> SurfaceInfo { - let ref device = self.0.device.borrow(); + let device = &self.0.device.borrow(); device.surface_info(surface) } pub fn surface_texture_object(&self, surface: &SurfaceTexture) -> u32 { - let ref device = self.0.device.borrow(); + let device = &self.0.device.borrow(); device.surface_texture_object(surface) } pub fn get_proc_address(&self, name: &str) -> *const c_void { - let ref device = self.0.device.borrow(); - let ref context = self.0.context.borrow(); + let device = &self.0.device.borrow(); + let context = &self.0.context.borrow(); device.get_proc_address(context, name) } @@ -221,7 +221,7 @@ impl RenderingContext { let device = self.0.device.borrow_mut(); let mut context = self.0.context.borrow_mut(); let mut surface = device.unbind_surface_from_context(&mut context)?.unwrap(); - let _ = device.destroy_surface(&mut context, &mut surface)?; + device.destroy_surface(&mut context, &mut surface)?; Ok(()) } diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index 6ea58172c27..10a193272ec 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -34,13 +34,13 @@ struct TestFontSource { impl TestFontSource { fn new() -> TestFontSource { - let mut csstest_ascii = FontTemplates::new(); + let mut csstest_ascii = FontTemplates::default(); Self::add_face(&mut csstest_ascii, "csstest-ascii", None); - let mut csstest_basic = FontTemplates::new(); + let mut csstest_basic = FontTemplates::default(); Self::add_face(&mut csstest_basic, "csstest-basic-regular", None); - let mut fallback = FontTemplates::new(); + let mut fallback = FontTemplates::default(); Self::add_face(&mut fallback, "csstest-basic-regular", Some("fallback")); let mut families = HashMap::new(); @@ -49,7 +49,7 @@ impl TestFontSource { families.insert(fallback_font_families(None)[0].to_owned(), fallback); TestFontSource { - handle: FontContextHandle::new(), + handle: FontContextHandle::default(), families, find_font_count: Rc::new(Cell::new(0)), } diff --git a/components/gfx/tests/font_template.rs b/components/gfx/tests/font_template.rs index eecaacbd695..d3958ce4a2e 100644 --- a/components/gfx/tests/font_template.rs +++ b/components/gfx/tests/font_template.rs @@ -35,7 +35,7 @@ fn test_font_template_descriptor() { ) .unwrap(); - let context = FontContextHandle::new(); + let context = FontContextHandle::default(); template.descriptor(&context).unwrap() } diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 98dc39bc0e4..976fe012336 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -28,7 +28,7 @@ pub struct GlyphEntry { impl GlyphEntry { fn new(value: u32) -> GlyphEntry { - GlyphEntry { value: value } + GlyphEntry { value } } fn initial() -> GlyphEntry { @@ -40,7 +40,7 @@ impl GlyphEntry { assert!(is_simple_glyph_id(id)); assert!(is_simple_advance(advance)); - let id_mask = id as u32; + let id_mask = id; let Au(advance) = advance; let advance_mask = (advance as u32) << GLYPH_ADVANCE_SHIFT; @@ -89,7 +89,7 @@ const GLYPH_ID_MASK: u32 = 0x0000FFFF; const GLYPH_COUNT_MASK: u32 = 0x0000FFFF; fn is_simple_glyph_id(id: GlyphId) -> bool { - ((id as u32) & GLYPH_ID_MASK) == id + (id & GLYPH_ID_MASK) == id } fn is_simple_advance(advance: Au) -> bool { @@ -157,9 +157,9 @@ struct DetailedGlyph { impl DetailedGlyph { fn new(id: GlyphId, advance: Au, offset: Point2D) -> DetailedGlyph { DetailedGlyph { - id: id, - advance: advance, - offset: offset, + id, + advance, + offset, } } } @@ -172,18 +172,18 @@ struct DetailedGlyphRecord { detail_offset: usize, } -impl PartialOrd for DetailedGlyphRecord { - fn partial_cmp(&self, other: &DetailedGlyphRecord) -> Option { - self.entry_offset.partial_cmp(&other.entry_offset) - } -} - impl Ord for DetailedGlyphRecord { fn cmp(&self, other: &DetailedGlyphRecord) -> Ordering { self.entry_offset.cmp(&other.entry_offset) } } +impl PartialOrd for DetailedGlyphRecord { + fn partial_cmp(&self, other: &DetailedGlyphRecord) -> Option { + Some(self.cmp(other)) + } +} + // Manages the lookup table for detailed glyphs. Sorting is deferred // until a lookup is actually performed; this matches the expected // usage pattern of setting/appending all the detailed glyphs, and @@ -210,7 +210,7 @@ impl<'a> DetailedGlyphStore { fn add_detailed_glyphs_for_entry(&mut self, entry_offset: ByteIndex, glyphs: &[DetailedGlyph]) { let entry = DetailedGlyphRecord { - entry_offset: entry_offset, + entry_offset, detail_offset: self.detail_buffer.len(), }; @@ -245,7 +245,7 @@ impl<'a> DetailedGlyphStore { assert!(self.lookup_is_sorted); let key = DetailedGlyphRecord { - entry_offset: entry_offset, + entry_offset, detail_offset: 0, // unused }; @@ -268,7 +268,7 @@ impl<'a> DetailedGlyphStore { assert!(self.lookup_is_sorted); let key = DetailedGlyphRecord { - entry_offset: entry_offset, + entry_offset, detail_offset: 0, // unused }; @@ -329,11 +329,11 @@ impl GlyphData { ligature_start: bool, ) -> GlyphData { GlyphData { - id: id, - advance: advance, + id, + advance, offset: offset.unwrap_or(Point2D::zero()), - cluster_start: cluster_start, - ligature_start: ligature_start, + cluster_start, + ligature_start, } } } @@ -455,8 +455,8 @@ impl<'a> GlyphStore { total_advance: Au(0), total_word_separators: 0, has_detailed_glyphs: false, - is_whitespace: is_whitespace, - is_rtl: is_rtl, + is_whitespace, + is_rtl, } } @@ -490,7 +490,7 @@ impl<'a> GlyphStore { let mut total_advance = Au(0); let mut total_word_separators = 0; for glyph in self.iter_glyphs_for_byte_range(&Range::new(ByteIndex(0), self.len())) { - total_advance = total_advance + glyph.advance(); + total_advance += glyph.advance(); if glyph.char_is_word_separator() { total_word_separators += 1; } @@ -539,7 +539,7 @@ impl<'a> GlyphStore { pub fn add_glyphs_for_byte_index(&mut self, i: ByteIndex, data_for_glyphs: &[GlyphData]) { assert!(i < self.len()); - assert!(data_for_glyphs.len() > 0); + assert!(!data_for_glyphs.is_empty()); let glyph_count = data_for_glyphs.len(); @@ -623,8 +623,6 @@ impl<'a> GlyphStore { pub fn advance_for_byte_range(&self, range: &Range, extra_word_spacing: Au) -> Au { if range.begin() == ByteIndex(0) && range.end() == self.len() { self.total_advance + extra_word_spacing * (self.total_word_separators as i32) - } else if !self.has_detailed_glyphs { - self.advance_for_byte_range_simple_glyphs(range, extra_word_spacing) } else { self.advance_for_byte_range_simple_glyphs(range, extra_word_spacing) } @@ -664,13 +662,13 @@ impl<'a> GlyphStore { impl fmt::Debug for GlyphStore { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "GlyphStore:\n")?; + writeln!(formatter, "GlyphStore:")?; let mut detailed_buffer = self.detail_store.detail_buffer.iter(); for entry in self.entry_buffer.iter() { if entry.is_simple() { - write!( + writeln!( formatter, - " simple id={:?} advance={:?}\n", + " simple id={:?} advance={:?}", entry.id(), entry.advance() )?; @@ -683,9 +681,9 @@ impl fmt::Debug for GlyphStore { if detailed_buffer.next().is_none() { continue; } - write!( + writeln!( formatter, - " detailed id={:?} advance={:?}\n", + " detailed id={:?} advance={:?}", entry.id(), entry.advance() )?; diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 389a44b5457..96d5ccc3251 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -47,21 +47,19 @@ pub struct ShapedGlyphEntry { } impl ShapedGlyphData { - pub fn new(buffer: *mut hb_buffer_t) -> ShapedGlyphData { - unsafe { - let mut glyph_count = 0; - let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count); - assert!(!glyph_infos.is_null()); - let mut pos_count = 0; - let pos_infos = hb_buffer_get_glyph_positions(buffer, &mut pos_count); - assert!(!pos_infos.is_null()); - assert_eq!(glyph_count, pos_count); + pub unsafe fn new(buffer: *mut hb_buffer_t) -> ShapedGlyphData { + let mut glyph_count = 0; + let glyph_infos = hb_buffer_get_glyph_infos(buffer, &mut glyph_count); + assert!(!glyph_infos.is_null()); + let mut pos_count = 0; + let pos_infos = hb_buffer_get_glyph_positions(buffer, &mut pos_count); + assert!(!pos_infos.is_null()); + assert_eq!(glyph_count, pos_count); - ShapedGlyphData { - count: glyph_count as usize, - glyph_infos: glyph_infos, - pos_infos: pos_infos, - } + ShapedGlyphData { + count: glyph_count as usize, + glyph_infos, + pos_infos, } } @@ -70,7 +68,7 @@ impl ShapedGlyphData { assert!(i < self.count); unsafe { - let glyph_info_i = self.glyph_infos.offset(i as isize); + let glyph_info_i = self.glyph_infos.add(i); (*glyph_info_i).cluster } } @@ -79,13 +77,17 @@ impl ShapedGlyphData { self.count } + pub fn is_empty(&self) -> bool { + self.count == 0 + } + /// Returns shaped glyph data for one glyph, and updates the y-position of the pen. pub fn entry_for_glyph(&self, i: usize, y_pos: &mut Au) -> ShapedGlyphEntry { assert!(i < self.count); unsafe { - let glyph_info_i = self.glyph_infos.offset(i as isize); - let pos_info_i = self.pos_infos.offset(i as isize); + let glyph_info_i = self.glyph_infos.add(i); + let pos_info_i = self.pos_infos.add(i); let x_offset = Shaper::fixed_to_float((*pos_info_i).x_offset); let y_offset = Shaper::fixed_to_float((*pos_info_i).y_offset); let x_advance = Shaper::fixed_to_float((*pos_info_i).x_advance); @@ -101,7 +103,7 @@ impl ShapedGlyphData { } else { // adjust the pen.. if y_advance > Au(0) { - *y_pos = *y_pos - y_advance; + *y_pos -= y_advance; } Some(Point2D::new(x_offset, *y_pos - y_offset)) @@ -110,7 +112,7 @@ impl ShapedGlyphData { ShapedGlyphEntry { codepoint: (*glyph_info_i).codepoint as GlyphId, advance: x_advance, - offset: offset, + offset, } } } @@ -136,6 +138,7 @@ impl Drop for Shaper { } impl Shaper { + #[allow(clippy::not_unsafe_ptr_arg_deref)] // Has an unsafe block inside pub fn new(font: *const Font) -> Shaper { unsafe { let hb_face: *mut hb_face_t = hb_face_create_for_tables( @@ -165,9 +168,9 @@ impl Shaper { ); Shaper { - hb_face: hb_face, - hb_font: hb_font, - font: font, + hb_face, + hb_font, + font, } } } @@ -415,7 +418,7 @@ impl Shaper { glyphs: &mut GlyphStore, buffer: *mut hb_buffer_t, ) { - let glyph_data = ShapedGlyphData::new(buffer); + let glyph_data = unsafe { ShapedGlyphData::new(buffer) }; let glyph_count = glyph_data.len(); let byte_max = text.len(); @@ -485,7 +488,7 @@ impl Shaper { } // if no glyphs were found yet, extend the char byte range more. - if glyph_span.len() == 0 { + if glyph_span.is_empty() { continue; } @@ -508,8 +511,8 @@ impl Shaper { // span or reach the end of the text. } - assert!(byte_range.len() > 0); - assert!(glyph_span.len() > 0); + assert!(!byte_range.is_empty()); + assert!(!glyph_span.is_empty()); // Now byte_range is the ligature clump formed by the glyphs in glyph_span. // We will save these glyphs to the glyph store at the index of the first byte. @@ -580,7 +583,7 @@ impl Shaper { options: &ShapingOptions, ) -> Au { if let Some(letter_spacing) = options.letter_spacing { - advance = advance + letter_spacing; + advance += letter_spacing; }; // CSS 2.1 § 16.4 states that "word spacing affects each space (U+0020) and non-breaking @@ -654,13 +657,10 @@ extern "C" fn glyph_h_advance_func( fn glyph_space_advance(font: *const Font) -> (hb_codepoint_t, f64) { let space_unicode = ' '; - let space_glyph: hb_codepoint_t; - match unsafe { (*font).glyph_index(space_unicode) } { - Some(g) => { - space_glyph = g as hb_codepoint_t; - }, + let space_glyph: hb_codepoint_t = match unsafe { (*font).glyph_index(space_unicode) } { + Some(g) => g as hb_codepoint_t, None => panic!("No space info"), - } + }; let space_advance = unsafe { (*font).glyph_h_advance(space_glyph as GlyphId) }; (space_glyph, space_advance) } diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index 011ba784107..21c239257fb 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -129,7 +129,7 @@ impl<'a> Iterator for NaturalWordSliceIterator<'a> { if !byte_range.is_empty() { Some(TextRunSlice { - glyphs: &*slice_glyphs.glyph_store, + glyphs: &slice_glyphs.glyph_store, offset: slice_range_begin, range: byte_range, }) @@ -172,7 +172,7 @@ impl<'a> Iterator for CharacterSliceIterator<'a> { let index_within_glyph_run = byte_start - glyph_run.range.begin(); Some(TextRunSlice { - glyphs: &*glyph_run.glyph_store, + glyphs: &glyph_run.glyph_store, offset: glyph_run.range.begin(), range: Range::new(index_within_glyph_run, byte_len), }) @@ -197,7 +197,7 @@ impl<'a> TextRun { font_key: font.font_key, pt_size: font.descriptor.pt_size, glyphs: Arc::new(glyphs), - bidi_level: bidi_level, + bidi_level, extra_word_spacing: Au(0), }, break_at_zero, @@ -217,7 +217,7 @@ impl<'a> TextRun { let mut break_at_zero = false; if breaker.is_none() { - if text.len() == 0 { + if text.is_empty() { return (glyphs, true); } *breaker = Some(LineBreakLeafIter::new(text, 0)); @@ -253,7 +253,7 @@ impl<'a> TextRun { // keep-all, try increasing the slice. continue; } - if slice.len() > 0 { + if !slice.is_empty() { glyphs.push(GlyphRun { glyph_store: font.shape_text(&text[slice.clone()], options), range: Range::new( @@ -262,8 +262,8 @@ impl<'a> TextRun { ), }); } - if whitespace.len() > 0 { - let mut options = options.clone(); + if !whitespace.is_empty() { + let mut options = *options; options .flags .insert(ShapingFlags::IS_WHITESPACE_SHAPING_FLAG); @@ -348,7 +348,9 @@ impl<'a> TextRun { } } - if let Ok(result) = (&**self.glyphs).binary_search_by(|current| current.compare(&index)) + if let Ok(result) = self + .glyphs + .binary_search_by(|current| current.compare(&index)) { index_of_first_glyph_run_cache.set(Some((self_ptr, index, result))); Some(result) @@ -396,7 +398,7 @@ impl<'a> TextRun { }; NaturalWordSliceIterator { glyphs: &self.glyphs[..], - index: index, + index, range: *range, reverse: false, } @@ -424,9 +426,9 @@ impl<'a> TextRun { }; NaturalWordSliceIterator { glyphs: &self.glyphs[..], - index: index, + index, range: *range, - reverse: reverse, + reverse, } } @@ -445,7 +447,7 @@ impl<'a> TextRun { CharacterSliceIterator { text: &self.text, glyph_run: first_glyph_run, - glyph_run_iter: glyph_run_iter, + glyph_run_iter, range: *range, } } diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index a2644b8b302..be9ba144dca 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -113,12 +113,7 @@ pub fn fixed_to_float(before: usize, f: i32) -> f64 { } pub fn is_bidi_control(c: char) -> bool { - match c { - '\u{202A}'..='\u{202E}' => true, - '\u{2066}'..='\u{2069}' => true, - '\u{200E}' | '\u{200F}' | '\u{061C}' => true, - _ => false, - } + matches!(c, '\u{202A}'..='\u{202E}' | '\u{2066}'..='\u{2069}' | '\u{200E}' | '\u{200F}' | '\u{061C}') } pub fn unicode_plane(codepoint: char) -> u32 { From ef3dad3a610d9d73754e976bece64a2184ed3821 Mon Sep 17 00:00:00 2001 From: eri Date: Fri, 8 Mar 2024 08:15:56 +0100 Subject: [PATCH 03/82] clippy: fix warnings in components/config* (#31562) --- components/config/basedir.rs | 2 +- components/config/opts.rs | 6 +++--- components/config/pref_util.rs | 19 +++++++++---------- components/config/prefs.rs | 12 ++++++------ components/config_plugins/parse.rs | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/components/config/basedir.rs b/components/config/basedir.rs index fbae2a7edca..fd17e482b88 100644 --- a/components/config/basedir.rs +++ b/components/config/basedir.rs @@ -35,7 +35,7 @@ pub fn default_config_dir() -> Option { Some(config_dir) } -#[cfg(all(target_os = "windows"))] +#[cfg(target_os = "windows")] pub fn default_config_dir() -> Option { let mut config_dir = ::dirs_next::config_dir().unwrap(); config_dir.push("Servo"); diff --git a/components/config/opts.rs b/components/config/opts.rs index 5cf394bb297..43348fccc2e 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -7,7 +7,7 @@ use std::default::Default; use std::fs::{self, File}; -use std::io::{self, Read, Write}; +use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{RwLock, RwLockReadGuard}; @@ -385,7 +385,7 @@ pub enum OutputOptions { } fn args_fail(msg: &str) -> ! { - writeln!(io::stderr(), "{}", msg).unwrap(); + eprintln!("{}", msg); process::exit(1) } @@ -793,7 +793,7 @@ pub fn from_cmdline_args(mut opts: Options, args: &[String]) -> ArgumentParsingR set_pref!(layout.threads, layout_threads as i64); } - return ArgumentParsingResult::ChromeProcess(opt_match); + ArgumentParsingResult::ChromeProcess(opt_match) } pub enum ArgumentParsingResult { diff --git a/components/config/pref_util.rs b/components/config/pref_util.rs index 11e2f7f94a8..d8cfa78aaea 100644 --- a/components/config/pref_util.rs +++ b/components/config/pref_util.rs @@ -55,10 +55,7 @@ impl PrefValue { } pub fn is_missing(&self) -> bool { - match self { - PrefValue::Missing => true, - _ => false, - } + matches!(self, PrefValue::Missing) } pub fn from_json_value(value: &Value) -> Option { @@ -164,7 +161,7 @@ impl From for [f64; 4] { let mut f = values.into_iter().map(|v| v.try_into()); if f.all(|v| v.is_ok()) { let f = f.flatten().collect::>(); - return [f[0], f[1], f[2], f[3]]; + [f[0], f[1], f[2], f[3]] } else { panic!( "Cannot convert PrefValue to {:?}", @@ -191,7 +188,7 @@ pub enum PrefError { impl fmt::Display for PrefError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - PrefError::NoSuchPref(s) | PrefError::InvalidValue(s) => f.write_str(&s), + PrefError::NoSuchPref(s) | PrefError::InvalidValue(s) => f.write_str(s), PrefError::JsonParseErr(e) => e.fmt(f), } } @@ -201,6 +198,7 @@ impl std::error::Error for PrefError {} pub struct Accessor { pub getter: Box V + Sync>, + #[allow(clippy::type_complexity)] pub setter: Box, } @@ -261,7 +259,7 @@ impl<'m, P: Clone> Preferences<'m, P> { } /// Creates an iterator over all keys and values - pub fn iter<'a>(&'a self) -> impl Iterator + 'a { + pub fn iter(&self) -> impl Iterator + '_ { let prefs = self.user_prefs.read().unwrap(); self.accessors .iter() @@ -269,16 +267,17 @@ impl<'m, P: Clone> Preferences<'m, P> { } /// Creates an iterator over all keys - pub fn keys<'a>(&'a self) -> impl Iterator + 'a { + pub fn keys(&self) -> impl Iterator { self.accessors.keys().map(String::as_str) } - fn set_inner(&self, key: &str, mut prefs: &mut P, val: V) -> Result<(), PrefError> + fn set_inner(&self, key: &str, prefs: &mut P, val: V) -> Result<(), PrefError> where V: Into, { if let Some(accessor) = self.accessors.get(key) { - Ok((accessor.setter)(&mut prefs, val.into())) + (accessor.setter)(prefs, val.into()); + Ok(()) } else { Err(PrefError::NoSuchPref(String::from(key))) } diff --git a/components/config/prefs.rs b/components/config/prefs.rs index 826605da6d9..f9c7c39bf82 100644 --- a/components/config/prefs.rs +++ b/components/config/prefs.rs @@ -67,7 +67,7 @@ pub fn add_user_prefs(prefs: HashMap) { for (key, value) in prefs.iter() { set_stylo_pref_ref(key, value); } - if let Err(error) = PREFS.set_all(prefs.into_iter()) { + if let Err(error) = PREFS.set_all(prefs) { panic!("Error setting preference: {:?}", error); } } @@ -106,15 +106,15 @@ impl TryFrom<&PrefValue> for StyloPrefValue { type Error = TryFromPrefValueError; fn try_from(value: &PrefValue) -> Result { - match value { - &PrefValue::Int(value) => { + match *value { + PrefValue::Int(value) => { if let Ok(value) = value.try_into() { Ok(Self::Int(value)) } else { Err(TryFromPrefValueError::IntegerOverflow(value)) } }, - &PrefValue::Bool(value) => Ok(Self::Bool(value)), + PrefValue::Bool(value) => Ok(Self::Bool(value)), _ => Err(TryFromPrefValueError::UnmappedType), } } @@ -122,7 +122,7 @@ impl TryFrom<&PrefValue> for StyloPrefValue { pub fn read_prefs_map(txt: &str) -> Result, PrefError> { let prefs: HashMap = - serde_json::from_str(txt).map_err(|e| PrefError::JsonParseErr(e))?; + serde_json::from_str(txt).map_err(PrefError::JsonParseErr)?; prefs .into_iter() .map(|(k, pref_value)| { @@ -133,7 +133,7 @@ pub fn read_prefs_map(txt: &str) -> Result, PrefError Value::Number(n) if n.is_f64() => PrefValue::Float(n.as_f64().unwrap()), Value::String(s) => PrefValue::Str(s.to_owned()), Value::Array(v) => { - let mut array = v.iter().map(|v| PrefValue::from_json_value(v)); + let mut array = v.iter().map(PrefValue::from_json_value); if array.all(|v| v.is_some()) { PrefValue::Array(array.flatten().collect()) } else { diff --git a/components/config_plugins/parse.rs b/components/config_plugins/parse.rs index 3a390f2f07f..63a3d66dfda 100644 --- a/components/config_plugins/parse.rs +++ b/components/config_plugins/parse.rs @@ -132,7 +132,7 @@ impl Parse for RootTypeDef { impl Parse for NewTypeDef { fn parse(input: ParseStream<'_>) -> Result { let content; - #[allow(clippy::eval_order_dependence)] + #[allow(clippy::mixed_read_write_in_expression)] Ok(NewTypeDef { _braces: braced!(content in input), fields: Punctuated::parse_terminated_with(&content, Field::parse)?, From 5c4f8cf0df2292537dce26856e8d16d71309a24c Mon Sep 17 00:00:00 2001 From: eri Date: Fri, 8 Mar 2024 08:24:01 +0100 Subject: [PATCH 04/82] clippy: fix some warnings in components/canvas (#31563) --- components/canvas/canvas_data.rs | 42 ++++++------- components/canvas/canvas_paint_thread.rs | 6 +- components/canvas/raqote_backend.rs | 59 +++++++++---------- components/canvas/webgl_mode/inprocess.rs | 2 +- components/canvas/webgl_thread.rs | 72 +++++++++++------------ components/compositing/build.rs | 6 +- components/compositing/compositor.rs | 1 + 7 files changed, 90 insertions(+), 98 deletions(-) diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 477d08d328c..59a0fed8345 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -74,23 +74,23 @@ impl PathState { pub trait Backend { fn get_composition_op(&self, opts: &DrawOptions) -> CompositionOp; fn need_to_draw_shadow(&self, color: &Color) -> bool; - fn set_shadow_color<'a>(&mut self, color: RGBA, state: &mut CanvasPaintState<'a>); - fn set_fill_style<'a>( + fn set_shadow_color(&mut self, color: RGBA, state: &mut CanvasPaintState<'_>); + fn set_fill_style( &mut self, style: FillOrStrokeStyle, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, drawtarget: &dyn GenericDrawTarget, ); - fn set_stroke_style<'a>( + fn set_stroke_style( &mut self, style: FillOrStrokeStyle, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, drawtarget: &dyn GenericDrawTarget, ); - fn set_global_composition<'a>( + fn set_global_composition( &mut self, op: CompositionOrBlending, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, ); fn create_drawtarget(&self, size: Size2D) -> Box; fn recreate_paint_state<'a>(&self, state: &CanvasPaintState<'a>) -> CanvasPaintState<'a>; @@ -222,10 +222,9 @@ impl<'a> PathBuilderRef<'a> { Some(i) => i, None => return None, }; - match self.builder.get_current_point() { - Some(point) => Some(inverse.transform_point(Point2D::new(point.x, point.y))), - None => None, - } + self.builder + .get_current_point() + .map(|point| inverse.transform_point(Point2D::new(point.x, point.y))) } fn close(&mut self) { @@ -428,7 +427,7 @@ impl<'a> CanvasData<'a> { let source_rect = source_rect.ceil(); // It discards the extra pixels (if any) that won't be painted let image_data = if Rect::from_size(image_size).contains_rect(&source_rect) { - pixels::rgba8_get_rect(&image_data, image_size.to_u64(), source_rect.to_u64()).into() + pixels::rgba8_get_rect(image_data, image_size.to_u64(), source_rect.to_u64()).into() } else { image_data.into() }; @@ -493,7 +492,7 @@ impl<'a> CanvasData<'a> { let font = font_style.map_or_else( || load_system_font_from_style(None), |style| { - with_thread_local_font_context(&self, |font_context| { + with_thread_local_font_context(self, |font_context| { let font_group = font_context.font_group(ServoArc::new(style.clone())); let font = font_group .borrow_mut() @@ -651,7 +650,7 @@ impl<'a> CanvasData<'a> { } if self.need_to_draw_shadow() { - self.draw_with_shadow(&rect, |new_draw_target: &mut dyn GenericDrawTarget| { + self.draw_with_shadow(rect, |new_draw_target: &mut dyn GenericDrawTarget| { new_draw_target.stroke_rect( rect, self.state.stroke_style.clone(), @@ -918,7 +917,7 @@ impl<'a> CanvasData<'a> { Some(p) => p, None => { self.path_builder().move_to(cp1); - cp1.clone() + *cp1 }, }; let cp1 = *cp1; @@ -1042,7 +1041,7 @@ impl<'a> CanvasData<'a> { } }, } - self.state.transform = transform.clone(); + self.state.transform = *transform; self.drawtarget.set_transform(transform) } @@ -1200,10 +1199,7 @@ impl<'a> CanvasData<'a> { draw_shadow_source(&mut *new_draw_target); self.drawtarget.draw_surface_with_shadow( new_draw_target.snapshot(), - &Point2D::new( - shadow_src_rect.origin.x as f32, - shadow_src_rect.origin.y as f32, - ), + &Point2D::new(shadow_src_rect.origin.x, shadow_src_rect.origin.y), &self.state.shadow_color, &Vector2D::new( self.state.shadow_offset_x as f32, @@ -1394,18 +1390,18 @@ fn load_system_font_from_style(font_style: Option<&FontStyleStruct>) -> Option handle, Err(e) => { error!("error getting font handle for style {:?}: {}", style, e); - return load_default_system_fallback_font(&properties); + return load_default_system_fallback_font(properties); }, }; match font_handle.load() { Ok(f) => Some(f), Err(e) => { error!("error loading font for style {:?}: {}", style, e); - load_default_system_fallback_font(&properties) + load_default_system_fallback_font(properties) }, } } diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 808714b14e8..17b5fb762fe 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -130,7 +130,7 @@ impl<'a> CanvasPaintThread<'a> { let font_cache_thread = self.font_cache_thread.clone(); - let canvas_id = self.next_canvas_id.clone(); + let canvas_id = self.next_canvas_id; self.next_canvas_id.0 += 1; let canvas_data = CanvasData::new( @@ -139,7 +139,7 @@ impl<'a> CanvasPaintThread<'a> { antialias, font_cache_thread, ); - self.canvases.insert(canvas_id.clone(), canvas_data); + self.canvases.insert(canvas_id, canvas_data); canvas_id } @@ -181,7 +181,7 @@ impl<'a> CanvasPaintThread<'a> { source_rect, smoothing_enabled, ) => self.canvas(canvas_id).draw_image( - &*image_data, + image_data, image_size, dest_rect, source_rect, diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 36e0de9351b..902f535e42f 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -29,14 +29,14 @@ impl Backend for RaqoteBackend { color.as_raqote().a != 0 } - fn set_shadow_color<'a>(&mut self, color: RGBA, state: &mut CanvasPaintState<'a>) { + fn set_shadow_color(&mut self, color: RGBA, state: &mut CanvasPaintState<'_>) { state.shadow_color = Color::Raqote(color.to_raqote_style()); } - fn set_fill_style<'a>( + fn set_fill_style( &mut self, style: FillOrStrokeStyle, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, _drawtarget: &dyn GenericDrawTarget, ) { if let Some(pattern) = style.to_raqote_pattern() { @@ -44,10 +44,10 @@ impl Backend for RaqoteBackend { } } - fn set_stroke_style<'a>( + fn set_stroke_style( &mut self, style: FillOrStrokeStyle, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, _drawtarget: &dyn GenericDrawTarget, ) { if let Some(pattern) = style.to_raqote_pattern() { @@ -55,10 +55,10 @@ impl Backend for RaqoteBackend { } } - fn set_global_composition<'a>( + fn set_global_composition( &mut self, op: CompositionOrBlending, - state: &mut CanvasPaintState<'a>, + state: &mut CanvasPaintState<'_>, ) { state.draw_options.as_raqote_mut().blend_mode = op.to_raqote_style(); } @@ -125,9 +125,9 @@ pub struct LinearGradientPattern { impl LinearGradientPattern { fn new(start: Point2D, end: Point2D, stops: Vec) -> Self { LinearGradientPattern { - gradient: raqote::Gradient { stops: stops }, - start: start, - end: end, + gradient: raqote::Gradient { stops }, + start, + end, } } } @@ -150,11 +150,11 @@ impl RadialGradientPattern { stops: Vec, ) -> Self { RadialGradientPattern { - gradient: raqote::Gradient { stops: stops }, - center1: center1, - radius1: radius1, - center2: center2, - radius2: radius2, + gradient: raqote::Gradient { stops }, + center1, + radius1, + center2, + radius2, } } } @@ -177,10 +177,10 @@ impl<'a> SurfacePattern<'a> { }, }; SurfacePattern { - image: image, - filter: filter, - extend: extend, - repeat: repeat, + image, + filter, + extend, + repeat, transform: Transform2D::identity(), } } @@ -389,7 +389,7 @@ impl GenericDrawTarget for raqote::DrawTarget { fn create_gradient_stops(&self, gradient_stops: Vec) -> GradientStops { let mut stops = gradient_stops .into_iter() - .map(|item| item.as_raqote().clone()) + .map(|item| *item.as_raqote()) .collect::>(); // https://www.w3.org/html/test/results/2dcontext/annotated-spec/canvas.html#testrefs.2d.gradient.interpolate.overlap stops.sort_by(|a, b| a.position.partial_cmp(&b.position).unwrap()); @@ -492,7 +492,7 @@ impl GenericDrawTarget for raqote::DrawTarget { raqote::BlendMode::SrcOut | raqote::BlendMode::DstIn | raqote::BlendMode::DstAtop => { - let mut options = draw_options.as_raqote().clone(); + let mut options = *draw_options.as_raqote(); self.push_layer_with_blend(1., options.blend_mode); options.blend_mode = raqote::BlendMode::SrcOver; self.fill(path.as_raqote(), &pattern.source(), &options); @@ -654,22 +654,17 @@ impl GenericDrawTarget for raqote::DrawTarget { #[allow(unsafe_code)] fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec) -> Vec { let v = self.get_data(); - f(unsafe { - std::slice::from_raw_parts( - v.as_ptr() as *const u8, - v.len() * std::mem::size_of::(), - ) - }) + f( + unsafe { + std::slice::from_raw_parts(v.as_ptr() as *const u8, std::mem::size_of_val(v)) + }, + ) } #[allow(unsafe_code)] fn snapshot_data_owned(&self) -> Vec { let v = self.get_data(); unsafe { - std::slice::from_raw_parts( - v.as_ptr() as *const u8, - v.len() * std::mem::size_of::(), - ) - .into() + std::slice::from_raw_parts(v.as_ptr() as *const u8, std::mem::size_of_val(v)).into() } } } diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs index ba9cee6ac02..fba01b39411 100644 --- a/components/canvas/webgl_mode/inprocess.rs +++ b/components/canvas/webgl_mode/inprocess.rs @@ -65,7 +65,7 @@ impl WebGLComm { WebGLComm { webgl_threads: WebGLThreads(sender), image_handler: Box::new(external), - webxr_layer_grand_manager: webxr_layer_grand_manager, + webxr_layer_grand_manager, } } } diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs index 656ca35a463..7362b61e9f4 100644 --- a/components/canvas/webgl_thread.rs +++ b/components/canvas/webgl_thread.rs @@ -289,7 +289,7 @@ impl WebGLThread { let exit = self.handle_msg(msg, &webgl_chan); if exit { // Call remove_context functions in order to correctly delete WebRender image keys. - let context_ids: Vec = self.contexts.keys().map(|id| *id).collect(); + let context_ids: Vec = self.contexts.keys().copied().collect(); for id in context_ids { self.remove_webgl_context(id); } @@ -323,7 +323,7 @@ impl WebGLThread { &mut self.bound_context_id, ) .expect("WebGLContext not found"); - let glsl_version = Self::get_glsl_version(&*data.gl); + let glsl_version = Self::get_glsl_version(&data.gl); let api_type = match data.gl.get_type() { gl::GlType::Gl => GlType::Gl, gl::GlType::Gles => GlType::Gles, @@ -458,7 +458,7 @@ impl WebGLThread { WebGLImpl::apply( &self.device, &data.ctx, - &*data.gl, + &data.gl, &mut data.state, &data.attributes, command, @@ -497,12 +497,12 @@ impl WebGLThread { ContextAttributeFlags::STENCIL; let context_attributes = &ContextAttributes { version: webgl_version.to_surfman_version(self.api_type), - flags: flags, + flags, }; let context_descriptor = self .device - .create_context_descriptor(&context_attributes) + .create_context_descriptor(context_attributes) .map_err(|err| format!("Failed to create context descriptor: {:?}", err))?; let safe_size = Size2D::new( @@ -562,7 +562,7 @@ impl WebGLThread { })), }; - let limits = GLLimits::detect(&*gl, webgl_version); + let limits = GLLimits::detect(&gl, webgl_version); let size = clamp_viewport(&gl, requested_size); if safe_size != size { @@ -583,7 +583,7 @@ impl WebGLThread { .device .context_surface_info(&ctx) .map_err(|err| format!("Failed to get context surface info: {:?}", err))? - .ok_or_else(|| format!("Failed to get context surface info"))? + .ok_or_else(|| "Failed to get context surface info".to_string())? .framebuffer_object; gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer); @@ -616,7 +616,7 @@ impl WebGLThread { }; debug!("Created state {:?}", state); - state.restore_invariant(&*gl); + state.restore_invariant(&gl); debug_assert_eq!(gl.get_error(), gl::NO_ERROR); self.contexts.insert( @@ -663,7 +663,7 @@ impl WebGLThread { // Check to see if any of the current framebuffer bindings are the surface we're about to // throw out. If so, we'll have to reset them after destroying the surface. let framebuffer_rebinding_info = - FramebufferRebindingInfo::detect(&self.device, &data.ctx, &*data.gl); + FramebufferRebindingInfo::detect(&self.device, &data.ctx, &data.gl); // Resize the swap chains if let Some(swap_chain) = self.webrender_swap_chains.get(context_id) { @@ -676,14 +676,14 @@ impl WebGLThread { .resize(&mut self.device, &mut data.ctx, size.to_i32()) .map_err(|err| format!("Failed to resize swap chain: {:?}", err))?; swap_chain - .clear_surface(&mut self.device, &mut data.ctx, &*data.gl, clear_color) + .clear_surface(&mut self.device, &mut data.ctx, &data.gl, clear_color) .map_err(|err| format!("Failed to clear resized swap chain: {:?}", err))?; } else { error!("Failed to find swap chain"); } // Reset framebuffer bindings as appropriate. - framebuffer_rebinding_info.apply(&self.device, &data.ctx, &*data.gl); + framebuffer_rebinding_info.apply(&self.device, &data.ctx, &data.gl); debug_assert_eq!(data.gl.get_error(), gl::NO_ERROR); let has_alpha = data @@ -764,7 +764,7 @@ impl WebGLThread { // Check to see if any of the current framebuffer bindings are the surface we're about // to swap out. If so, we'll have to reset them after destroying the surface. let framebuffer_rebinding_info = - FramebufferRebindingInfo::detect(&self.device, &data.ctx, &*data.gl); + FramebufferRebindingInfo::detect(&self.device, &data.ctx, &data.gl); debug_assert_eq!(data.gl.get_error(), gl::NO_ERROR); debug!("Getting swap chain for {:?}", context_id); @@ -779,7 +779,7 @@ impl WebGLThread { &mut self.device, &mut data.ctx, if data.attributes.preserve_drawing_buffer { - PreserveBuffer::Yes(&*data.gl) + PreserveBuffer::Yes(&data.gl) } else { PreserveBuffer::No }, @@ -795,14 +795,14 @@ impl WebGLThread { .contains(ContextAttributeFlags::ALPHA); let clear_color = [0.0, 0.0, 0.0, !alpha as i32 as f32]; swap_chain - .clear_surface(&mut self.device, &mut data.ctx, &*data.gl, clear_color) + .clear_surface(&mut self.device, &mut data.ctx, &data.gl, clear_color) .unwrap(); debug_assert_eq!(data.gl.get_error(), gl::NO_ERROR); } // Rebind framebuffers as appropriate. debug!("Rebinding {:?}", context_id); - framebuffer_rebinding_info.apply(&self.device, &data.ctx, &*data.gl); + framebuffer_rebinding_info.apply(&self.device, &data.ctx, &data.gl); debug_assert_eq!(data.gl.get_error(), gl::NO_ERROR); let SurfaceInfo { @@ -941,7 +941,7 @@ impl WebGLThread { image_buffer_kind: ImageBufferKind, ) -> ImageData { let data = ExternalImageData { - id: ExternalImageId(context_id.0 as u64), + id: ExternalImageId(context_id.0), channel_index: 0, image_type: ExternalImageType::TextureHandle(image_buffer_kind), }; @@ -1288,7 +1288,7 @@ impl WebGLImpl { sender.send(location).unwrap(); }, WebGLCommand::GetUniformLocation(program_id, ref name, ref chan) => { - Self::uniform_location(gl, program_id, &name, chan) + Self::uniform_location(gl, program_id, name, chan) }, WebGLCommand::GetShaderInfoLog(shader_id, ref chan) => { Self::shader_info_log(gl, shader_id, chan) @@ -1297,7 +1297,7 @@ impl WebGLImpl { Self::program_info_log(gl, program_id, chan) }, WebGLCommand::CompileShader(shader_id, ref source) => { - Self::compile_shader(gl, shader_id, &source) + Self::compile_shader(gl, shader_id, source) }, WebGLCommand::CreateBuffer(ref chan) => Self::create_buffer(gl, chan), WebGLCommand::CreateFramebuffer(ref chan) => Self::create_framebuffer(gl, chan), @@ -1426,7 +1426,7 @@ impl WebGLImpl { alpha_treatment, y_axis_treatment, pixel_format, - Cow::Borrowed(&*data), + Cow::Borrowed(data), ); gl.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32); @@ -1489,7 +1489,7 @@ impl WebGLImpl { alpha_treatment, y_axis_treatment, pixel_format, - Cow::Borrowed(&*data), + Cow::Borrowed(data), ); gl.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32); @@ -1519,7 +1519,7 @@ impl WebGLImpl { size.width as i32, size.height as i32, 0, - &*data, + data, ); }, WebGLCommand::CompressedTexSubImage2D { @@ -1533,13 +1533,13 @@ impl WebGLImpl { } => { gl.compressed_tex_sub_image_2d( target, - level as i32, - xoffset as i32, - yoffset as i32, + level, + xoffset, + yoffset, size.width as i32, size.height as i32, format, - &*data, + data, ); }, WebGLCommand::TexStorage2D(target, levels, internal_format, width, height) => gl @@ -1561,7 +1561,7 @@ impl WebGLImpl { ), WebGLCommand::DrawingBufferWidth(ref sender) => { let size = device - .context_surface_info(&ctx) + .context_surface_info(ctx) .unwrap() .expect("Where's the front buffer?") .size; @@ -1569,7 +1569,7 @@ impl WebGLImpl { }, WebGLCommand::DrawingBufferHeight(ref sender) => { let size = device - .context_surface_info(&ctx) + .context_surface_info(ctx) .unwrap() .expect("Where's the front buffer?") .size; @@ -1615,7 +1615,7 @@ impl WebGLImpl { sender.send(value).unwrap(); }, WebGLCommand::ClientWaitSync(sync_id, flags, timeout, ref sender) => { - let value = gl.client_wait_sync(sync_id.get() as *const _, flags, timeout as u64); + let value = gl.client_wait_sync(sync_id.get() as *const _, flags, timeout); sender.send(value).unwrap(); }, WebGLCommand::WaitSync(sync_id, flags, timeout) => { @@ -1744,10 +1744,10 @@ impl WebGLImpl { } }, WebGLCommand::TexParameteri(target, param, value) => { - gl.tex_parameter_i(target, param as u32, value) + gl.tex_parameter_i(target, param, value) }, WebGLCommand::TexParameterf(target, param, value) => { - gl.tex_parameter_f(target, param as u32, value) + gl.tex_parameter_f(target, param, value) }, WebGLCommand::LinkProgram(program_id, ref sender) => { return sender.send(Self::link_program(gl, program_id)).unwrap(); @@ -2503,7 +2503,7 @@ impl WebGLImpl { /// /// To avoid hard-coding this we would need to use the `sh::GetAttributes` and `sh::GetUniforms` /// API to look up the `x.name` and `x.mappedName` members. -const ANGLE_NAME_PREFIX: &'static str = "_u"; +const ANGLE_NAME_PREFIX: &str = "_u"; fn to_name_in_compiled_shader(s: &str) -> String { map_dot_separated(s, |s, mapped| { @@ -3057,7 +3057,7 @@ impl WebXRBridge { .map_err(|_| WebXRError::CommunicationError)?; let manager = factory.build(device, contexts)?; let manager_id = unsafe { WebXRLayerManagerId::new(self.next_manager_id) }; - self.next_manager_id = self.next_manager_id + 1; + self.next_manager_id += 1; self.managers.insert(manager_id, manager); Ok(manager_id) } @@ -3315,8 +3315,8 @@ impl<'a> WebXRContexts for WebXRBridgeContexts<'a> { let data = WebGLThread::make_current_if_needed_mut( device, WebGLContextId::from(context_id), - &mut self.contexts, - &mut self.bound_context_id, + self.contexts, + self.bound_context_id, )?; Some(&mut data.ctx) } @@ -3324,8 +3324,8 @@ impl<'a> WebXRContexts for WebXRBridgeContexts<'a> { let data = WebGLThread::make_current_if_needed( device, WebGLContextId::from(context_id), - &self.contexts, - &mut self.bound_context_id, + self.contexts, + self.bound_context_id, )?; Some(&data.gl) } diff --git a/components/compositing/build.rs b/components/compositing/build.rs index 3fe277ca541..828bf622fcb 100644 --- a/components/compositing/build.rs +++ b/components/compositing/build.rs @@ -38,11 +38,11 @@ fn main() { .and_then(|pkg| pkg.get("source").and_then(|source| source.as_str())) .unwrap_or("unknown"); - let parsed: Vec<&str> = source.split("#").collect(); + let parsed: Vec<&str> = source.split('#').collect(); let revision = if parsed.len() > 1 { parsed[1] } else { source }; - let mut revision_module_file = File::create(&revision_file_path).unwrap(); - write!(&mut revision_module_file, "{}", format!("\"{}\"", revision)).unwrap(); + let mut revision_module_file = File::create(revision_file_path).unwrap(); + write!(&mut revision_module_file, "\"{}\"", revision).unwrap(); }, _ => panic!("Cannot find package definitions in lockfile"), } diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 1700424fbb6..8830ddee79e 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -530,6 +530,7 @@ impl IOCompositor { /// and the system creates a new native surface that needs to bound to the current /// context. #[allow(unsafe_code)] + #[allow(clippy::not_unsafe_ptr_arg_deref)] // It has an unsafe block inside pub fn replace_native_surface(&mut self, native_widget: *mut c_void, coords: DeviceIntSize) { debug!("Replacing native surface in compositor: {native_widget:?}"); let connection = self.rendering_context.connection(); From 52c4f57085eee5e9a6525fd0a9d380f55e8b1a88 Mon Sep 17 00:00:00 2001 From: Munish Mummadi <141582088+MunishMummadi@users.noreply.github.com> Date: Fri, 8 Mar 2024 01:25:12 -0600 Subject: [PATCH 05/82] Update phf_codegen and phf_shared to 0.11 (#31537) * Update phf_codegen and phf_shared to 0.11 * Updated the Cargo.lock With ./mach build --- Cargo.lock | 4 ++-- components/script/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1b22896860..92b79912d05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4928,8 +4928,8 @@ dependencies = [ "parking_lot", "percent-encoding", "phf 0.10.1", - "phf_codegen 0.10.0", - "phf_shared 0.10.0", + "phf_codegen 0.11.2", + "phf_shared 0.11.2", "pixels", "profile_traits", "range", diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index a9d2d52b94e..1fc2f1a69cc 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -22,8 +22,8 @@ refcell_backtrace = ["accountable-refcell"] xr-profile = ["webxr-api/profile"] [build-dependencies] -phf_codegen = "0.10" -phf_shared = "0.10" +phf_codegen = "0.11" +phf_shared = "0.11" serde_json = { workspace = true } [dependencies] From 07485798032bf4703e405a1d756435b4135b63f9 Mon Sep 17 00:00:00 2001 From: zawz <34189424+zawwz@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:37:18 +0100 Subject: [PATCH 06/82] Fix clippy warnings in components/shared/net/request.rs (#31551) * Fix clippy warnings in components/shared/net/request.rs Signed-off-by: mateoferon * fixup! Fix clippy warnings in components/shared/net/request.rs --------- Signed-off-by: mateoferon --- components/shared/net/request.rs | 67 +++++++++++++++----------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/components/shared/net/request.rs b/components/shared/net/request.rs index 1f9f0abf986..b1aa5fd0f04 100644 --- a/components/shared/net/request.rs +++ b/components/shared/net/request.rs @@ -208,7 +208,7 @@ impl RequestBody { } pub fn len(&self) -> Option { - self.total_bytes.clone() + self.total_bytes } } @@ -567,19 +567,19 @@ impl Request { /// pub fn is_subresource_request(&self) -> bool { - match self.destination { + matches!( + self.destination, Destination::Audio | - Destination::Font | - Destination::Image | - Destination::Manifest | - Destination::Script | - Destination::Style | - Destination::Track | - Destination::Video | - Destination::Xslt | - Destination::None => true, - _ => false, - } + Destination::Font | + Destination::Image | + Destination::Manifest | + Destination::Script | + Destination::Style | + Destination::Track | + Destination::Video | + Destination::Xslt | + Destination::None + ) } pub fn timing_type(&self) -> ResourceTimingType { @@ -605,7 +605,7 @@ impl Referrer { // TODO: values in the control-code range are being quietly stripped out by // HeaderMap and never reach this function to be loudly rejected! fn is_cors_unsafe_request_header_byte(value: &u8) -> bool { - match value { + matches!(value, 0x00..=0x08 | 0x10..=0x19 | 0x22 | @@ -621,9 +621,8 @@ fn is_cors_unsafe_request_header_byte(value: &u8) -> bool { 0x5D | 0x7B | 0x7D | - 0x7F => true, - _ => false, - } + 0x7F + ) } // https://fetch.spec.whatwg.org/#cors-safelisted-request-header @@ -635,18 +634,19 @@ fn is_cors_safelisted_request_accept(value: &[u8]) -> bool { // https://fetch.spec.whatwg.org/#cors-safelisted-request-header // subclauses `accept-language`, `content-language` fn is_cors_safelisted_language(value: &[u8]) -> bool { - value.iter().all(|&x| match x { - 0x30..=0x39 | - 0x41..=0x5A | - 0x61..=0x7A | - 0x20 | - 0x2A | - 0x2C | - 0x2D | - 0x2E | - 0x3B | - 0x3D => true, - _ => false, + value.iter().all(|&x| { + matches!(x, + 0x30..=0x39 | + 0x41..=0x5A | + 0x61..=0x7A | + 0x20 | + 0x2A | + 0x2C | + 0x2D | + 0x2E | + 0x3B | + 0x3D + ) }) } @@ -697,10 +697,7 @@ pub fn is_cors_safelisted_request_header, V: AsRef<[u8]>>( /// pub fn is_cors_safelisted_method(m: &Method) -> bool { - match *m { - Method::GET | Method::HEAD | Method::POST => true, - _ => false, - } + matches!(*m, Method::GET | Method::HEAD | Method::POST) } /// @@ -733,7 +730,7 @@ pub fn get_cors_unsafe_header_names(headers: &HeaderMap) -> Vec { } // Step 6 - return convert_header_names_to_sorted_lowercase_set(unsafe_names); + convert_header_names_to_sorted_lowercase_set(unsafe_names) } /// @@ -745,5 +742,5 @@ pub fn convert_header_names_to_sorted_lowercase_set( let mut ordered_set = header_names.to_vec(); ordered_set.sort_by(|a, b| a.as_str().partial_cmp(b.as_str()).unwrap()); ordered_set.dedup(); - return ordered_set.into_iter().cloned().collect(); + ordered_set.into_iter().cloned().collect() } From a5a0e1cb3c339f9314777ebe18c88ca7c933b2c0 Mon Sep 17 00:00:00 2001 From: Azhar Ismagulova <31756707+azharcodeit@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:13:39 +0000 Subject: [PATCH 07/82] Fix inheritance.sub.html WPT to work on Servo (#31534) --- .../css/css-backgrounds/inheritance.sub.html.ini | 15 --------------- tests/wpt/meta/MANIFEST.json | 2 +- .../css/css-backgrounds/inheritance.sub.html.ini | 12 ------------ .../css/css-backgrounds/inheritance.sub.html | 2 +- 4 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 tests/wpt/meta/css/css-backgrounds/inheritance.sub.html.ini diff --git a/tests/wpt/meta-legacy-layout/css/css-backgrounds/inheritance.sub.html.ini b/tests/wpt/meta-legacy-layout/css/css-backgrounds/inheritance.sub.html.ini index 06216373de1..fb8dada39fb 100644 --- a/tests/wpt/meta-legacy-layout/css/css-backgrounds/inheritance.sub.html.ini +++ b/tests/wpt/meta-legacy-layout/css/css-backgrounds/inheritance.sub.html.ini @@ -1,21 +1,6 @@ [inheritance.sub.html] - [Inheritance of CSS Backgrounds and Borders properties] - expected: FAIL - [Property background-position has initial value 0% 0%] expected: FAIL [Property background-position does not inherit] expected: FAIL - - [Property border-bottom-width has initial value undefined] - expected: FAIL - - [Property border-left-width has initial value undefined] - expected: FAIL - - [Property border-right-width has initial value undefined] - expected: FAIL - - [Property border-top-width has initial value undefined] - expected: FAIL diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index b75c27713e1..0690fe385b7 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -522299,7 +522299,7 @@ ] ], "inheritance.sub.html": [ - "01bb8422991ee48da525087d5462c380c5eb8b84", + "8af2dada5217ccf1b59620ab400afba052ff460f", [ null, {} diff --git a/tests/wpt/meta/css/css-backgrounds/inheritance.sub.html.ini b/tests/wpt/meta/css/css-backgrounds/inheritance.sub.html.ini deleted file mode 100644 index 97675fbef42..00000000000 --- a/tests/wpt/meta/css/css-backgrounds/inheritance.sub.html.ini +++ /dev/null @@ -1,12 +0,0 @@ -[inheritance.sub.html] - [Property border-bottom-width has initial value undefined] - expected: FAIL - - [Property border-left-width has initial value undefined] - expected: FAIL - - [Property border-right-width has initial value undefined] - expected: FAIL - - [Property border-top-width has initial value undefined] - expected: FAIL diff --git a/tests/wpt/tests/css/css-backgrounds/inheritance.sub.html b/tests/wpt/tests/css/css-backgrounds/inheritance.sub.html index 01bb8422991..8af2dada521 100644 --- a/tests/wpt/tests/css/css-backgrounds/inheritance.sub.html +++ b/tests/wpt/tests/css/css-backgrounds/inheritance.sub.html @@ -31,7 +31,7 @@ - - - - - -
diff --git a/tests/wpt/tests/IndexedDB/idbindex_count2.htm b/tests/wpt/tests/IndexedDB/idbindex_count2.htm deleted file mode 100644 index 2a68770df91..00000000000 --- a/tests/wpt/tests/IndexedDB/idbindex_count2.htm +++ /dev/null @@ -1,37 +0,0 @@ - - -IDBIndex.count() - returns the number of records that have keys within the range - - - - - - - -
diff --git a/tests/wpt/tests/IndexedDB/idbindex_count3.htm b/tests/wpt/tests/IndexedDB/idbindex_count3.htm deleted file mode 100644 index a94e8985546..00000000000 --- a/tests/wpt/tests/IndexedDB/idbindex_count3.htm +++ /dev/null @@ -1,28 +0,0 @@ - - -IDBIndex.count() - returns the number of records that have keys with the key - - - - - - -
diff --git a/tests/wpt/tests/IndexedDB/idbindex_count4.htm b/tests/wpt/tests/IndexedDB/idbindex_count4.htm deleted file mode 100644 index ce19968bf16..00000000000 --- a/tests/wpt/tests/IndexedDB/idbindex_count4.htm +++ /dev/null @@ -1,37 +0,0 @@ - - -IDBIndex.count() - throw DataError when using invalid key - - - - - -
- - diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add.any.js index b3071c1f94c..dfc15294e82 100644 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add.any.js +++ b/tests/wpt/tests/IndexedDB/idbobjectstore_add.any.js @@ -1,30 +1,408 @@ // META: global=window,worker -// META: title=IDBObjectStore.add() - add with an inline key +// META: title=IDBObjectStore.add() // META: script=resources/support.js // @author Microsoft +// @author Intel 'use_strict'; -let db; -const t = async_test(); -const record = { key: 1, property: "data" }; +async_test(t => { + let db; + const record = { key: 1, property: "data" }; -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "key" }); + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); - objStore.add(record); -}; + objStore.add(record); + }; -open_rq.onsuccess = function(e) { - const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .get(record.key); + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(record.key); - rq.onsuccess = t.step_func(function(e) { + rq.onsuccess = t.step_func(function(e) { assert_equals(e.target.result.property, record.property); assert_equals(e.target.result.key, record.key); t.done(); - }); -}; + }); + }; +}, 'add() with an inline key'); + +async_test(t => { + let db; + const key = 1; + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store"); + + objStore.add(record, key); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +}, 'add() with an out-of-line key'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + objStore.add(record); + + const rq = objStore.add(record); + rq.onsuccess = fail(t, "success on adding duplicate record"); + + rq.onerror = t.step_func(function(e) { + assert_equals(e.target.error.name, "ConstraintError"); + assert_equals(rq.error.name, "ConstraintError"); + assert_equals(e.type, "error"); + + e.preventDefault(); + e.stopPropagation(); + }); + }; + + // Defer done, giving rq.onsuccess a chance to run + open_rq.onsuccess = function(e) { + t.done(); + }; +}, 'add() record with same key already exists'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + const objStore = db.createObjectStore("store", { autoIncrement: true }); + objStore.createIndex("i1", "property", { unique: true }); + objStore.add(record); + + const rq = objStore.add(record); + rq.onsuccess = fail(t, "success on adding duplicate indexed record"); + + rq.onerror = t.step_func(function(e) { + assert_equals(rq.error.name, "ConstraintError"); + assert_equals(e.target.error.name, "ConstraintError"); + assert_equals(e.type, "error"); + + e.preventDefault(); + e.stopPropagation(); + }); + }; + + // Defer done, giving a spurious rq.onsuccess a chance to run + open_rq.onsuccess = function(e) { + t.done(); + }; +}, 'add() where an index has unique:true specified'); + +async_test(t => { + let db; + const record = { test: { obj: { key: 1 } }, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", + { keyPath: "test.obj.key" }); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(record.test.obj.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +}, 'add() object store\'s key path is an object attribute'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key", + autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'add() autoIncrement and inline keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'add() autoIncrement and out-of-line keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "test.obj.key", + autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.test.obj.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'Object store has autoIncrement:true and the key path is an object \ +attribute'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let rq; + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record, 1); + }); + + assert_equals(rq, undefined); + t.done(); + }; + }, 'Attempt to \'add()\' a record that does not meet the constraints of an \ + object store\'s inline key requirements'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + let rq; + const objStore = db.createObjectStore("store"); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to call \'add()\' without a key parameter when the object store \ +uses out-of-line keys'); + +async_test(t => { + const record = { key: { value: 1 }, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the record\'s key does not meet the \ +constraints of a valid key'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the record\'s in-line key is not \ + defined'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store"); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record, { value: 1 }); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the out of line key provided does not \ +meet the constraints of a valid key'); + +async_test(t => { + const record = { key: 1, indexedProperty: { property: "data" } }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + objStore.createIndex("index", "indexedProperty"); + + rq = objStore.add(record); + + assert_true(rq instanceof IDBRequest); + rq.onsuccess = function() { + t.done(); + } + }; +}, 'add() a record where a value being indexed does not meet the constraints \ +of a valid key'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function (event) { + db = event.target.result; + db.createObjectStore("store", {keyPath: "pKey"}); + } + + open_rq.onsuccess = function (event) { + const txn = db.transaction("store", "readonly", + {durability: 'relaxed'}); + const ostore = txn.objectStore("store"); + t.step(function() { + assert_throws_dom("ReadOnlyError", function() { + ostore.add({pKey: "primaryKey_0"}); + }); + }); + t.done(); + } +}, 'If the transaction this IDBObjectStore belongs to has its mode set to \ +readonly, throw ReadOnlyError'); + +async_test(t => { + const open_rq = createdb(t); + open_rq.onupgradeneeded = function (event) { + let db = event.target.result; + const ostore = db.createObjectStore("store", {keyPath: "pKey"}); + db.deleteObjectStore("store"); + assert_throws_dom("InvalidStateError", function() { + ostore.add({pKey: "primaryKey_0"}); + }); + t.done(); + }; +}, 'If the object store has been deleted, the implementation must throw a \ +DOMException of type InvalidStateError'); diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add10.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add10.any.js deleted file mode 100644 index 7b93dec16a0..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add10.any.js +++ /dev/null @@ -1,24 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Attempt to call 'add' without an key parameter when the object store uses out-of-line keys -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - - let rq; - const objStore = db.createObjectStore("store"); - - assert_throws_dom("DataError", - function() { rq = objStore.add(record); }); - - assert_equals(rq, undefined); - t.done(); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add11.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add11.any.js deleted file mode 100644 index cff8f6f1a02..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add11.any.js +++ /dev/null @@ -1,24 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Attempt to add a record where the record's key does not meet the constraints of a valid key -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { key: { value: 1 }, property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - - let rq; - const objStore = db.createObjectStore("store", { keyPath: "key" }); - - assert_throws_dom("DataError", - function() { rq = objStore.add(record); }); - - assert_equals(rq, undefined); - t.done(); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add12.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add12.any.js deleted file mode 100644 index c7ebe751d7e..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add12.any.js +++ /dev/null @@ -1,24 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Attempt to add a record where the record's in-line key is not defined -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - - let rq; - const objStore = db.createObjectStore("store", { keyPath: "key" }); - - assert_throws_dom("DataError", - function() { rq = objStore.add(record); }); - - assert_equals(rq, undefined); - t.done(); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add13.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add13.any.js deleted file mode 100644 index fdd77751c00..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add13.any.js +++ /dev/null @@ -1,24 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Attempt to add a record where the out of line key provided does not meet the constraints of a valid key -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - - let rq; - const objStore = db.createObjectStore("store"); - - assert_throws_dom("DataError", - function() { rq = objStore.add(record, { value: 1 }); }); - - assert_equals(rq, undefined); - t.done(); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add14.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add14.any.js deleted file mode 100644 index 9952a6d12c9..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add14.any.js +++ /dev/null @@ -1,27 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Add a record where a value being indexed does not meet the constraints of a valid key -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { key: 1, indexedProperty: { property: "data" } }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - - let rq; - const objStore = db.createObjectStore("store", { keyPath: "key" }); - - objStore.createIndex("index", "indexedProperty"); - - rq = objStore.add(record); - - assert_true(rq instanceof IDBRequest); - rq.onsuccess = function() { - t.done(); - } -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add15.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add15.any.js deleted file mode 100644 index f1820b0259d..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add15.any.js +++ /dev/null @@ -1,26 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError -// META: script=resources/support.js -// @author Intel - -'use_strict'; - -let db; -const t = async_test(); - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function (event) { - db = event.target.result; - db.createObjectStore("store", {keyPath:"pKey"}); -} - -open_rq.onsuccess = function (event) { - const txn = db.transaction("store", "readonly", {durability: 'relaxed'}); - const ostore = txn.objectStore("store"); - t.step(function(){ - assert_throws_dom("ReadOnlyError", function(){ - ostore.add({ pKey: "primaryKey_0"}); - }); - }); - t.done(); -} diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add16.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add16.any.js deleted file mode 100644 index 42f943fd25f..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add16.any.js +++ /dev/null @@ -1,21 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError -// META: script=resources/support.js -// @author Intel - -'use_strict'; - -let db; -let ostore; -const t = async_test(); - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function (event) { - db = event.target.result; - ostore = db.createObjectStore("store", {keyPath:"pKey"}); - db.deleteObjectStore("store"); - assert_throws_dom("InvalidStateError", function(){ - ostore.add({ pKey: "primaryKey_0"}); - }); - t.done(); -} diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add2.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add2.any.js deleted file mode 100644 index ddddb4ca130..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add2.any.js +++ /dev/null @@ -1,31 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - add with an out-of-line key -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const key = 1; -const record = { property: "data" }; - -var open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store"); - - objStore.add(record, key); -}; - -open_rq.onsuccess = function(e) { - const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .get(key); - - rq.onsuccess = t.step_func(function(e) { - assert_equals(e.target.result.property, record.property); - - t.done(); - }); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add3.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add3.any.js deleted file mode 100644 index a108f6b132c..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add3.any.js +++ /dev/null @@ -1,34 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - record with same key already exists -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { key: 1, property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "key" }); - objStore.add(record); - - const rq = objStore.add(record); - rq.onsuccess = fail(t, "success on adding duplicate record"); - - rq.onerror = t.step_func(function(e) { - assert_equals(e.target.error.name, "ConstraintError"); - assert_equals(rq.error.name, "ConstraintError"); - assert_equals(e.type, "error"); - - e.preventDefault(); - e.stopPropagation(); - }); -}; - -// Defer done, giving rq.onsuccess a chance to run -open_rq.onsuccess = function(e) { - t.done(); -} diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add4.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add4.any.js deleted file mode 100644 index 6a4f61e0d5b..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add4.any.js +++ /dev/null @@ -1,35 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - add where an index has unique:true specified -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { key: 1, property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { autoIncrement: true }); - objStore.createIndex("i1", "property", { unique: true }); - objStore.add(record); - - const rq = objStore.add(record); - rq.onsuccess = fail(t, "success on adding duplicate indexed record"); - - rq.onerror = t.step_func(function(e) { - assert_equals(rq.error.name, "ConstraintError"); - assert_equals(e.target.error.name, "ConstraintError"); - assert_equals(e.type, "error"); - - e.preventDefault(); - e.stopPropagation(); - }); -}; - -// Defer done, giving a spurious rq.onsuccess a chance to run -open_rq.onsuccess = function(e) { - t.done(); -} diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add5.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add5.any.js deleted file mode 100644 index 002e7dcf87e..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add5.any.js +++ /dev/null @@ -1,29 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - object store's key path is an object attribute -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { test: { obj: { key: 1 } }, property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "test.obj.key" }); - objStore.add(record); -}; - -open_rq.onsuccess = function(e) { - const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .get(record.test.obj.key); - - rq.onsuccess = t.step_func(function(e) { - assert_equals(e.target.result.property, record.property); - - t.done(); - }); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add6.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add6.any.js deleted file mode 100644 index bc5242156d4..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add6.any.js +++ /dev/null @@ -1,42 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - autoIncrement and inline keys -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; -const expected_keys = [ 1, 2, 3, 4 ]; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "key", autoIncrement: true }); - - objStore.add(record); - objStore.add(record); - objStore.add(record); - objStore.add(record); -}; - -open_rq.onsuccess = function(e) { - const actual_keys = [], - rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .openCursor(); - - rq.onsuccess = t.step_func(function(e) { - const cursor = e.target.result; - - if (cursor) { - actual_keys.push(cursor.value.key); - cursor.continue(); - } - else { - assert_array_equals(actual_keys, expected_keys); - t.done(); - } - }); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add7.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add7.any.js deleted file mode 100644 index eb381c4d45a..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add7.any.js +++ /dev/null @@ -1,42 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - autoIncrement and out-of-line keys -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; -const expected_keys = [ 1, 2, 3, 4 ]; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { autoIncrement: true }); - - objStore.add(record); - objStore.add(record); - objStore.add(record); - objStore.add(record); -}; - -open_rq.onsuccess = function(e) { - const actual_keys = [], - rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .openCursor(); - - rq.onsuccess = t.step_func(function(e) { - const cursor = e.target.result; - - if (cursor) { - actual_keys.push(cursor.key); - cursor.continue(); - } - else { - assert_array_equals(actual_keys, expected_keys); - t.done(); - } - }); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add8.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add8.any.js deleted file mode 100644 index 60266835bcb..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add8.any.js +++ /dev/null @@ -1,42 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - object store has autoIncrement:true and the key path is an object attribute -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let db; -const t = async_test(); -const record = { property: "data" }; -const expected_keys = [ 1, 2, 3, 4 ]; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "test.obj.key", autoIncrement: true }); - - objStore.add(record); - objStore.add(record); - objStore.add(record); - objStore.add(record); -}; - -open_rq.onsuccess = function(e) { - const actual_keys = [], - rq = db.transaction("store", "readonly", {durability: 'relaxed'}) - .objectStore("store") - .openCursor(); - - rq.onsuccess = t.step_func(function(e) { - const cursor = e.target.result; - - if (cursor) { - actual_keys.push(cursor.value.test.obj.key); - cursor.continue(); - } - else { - assert_array_equals(actual_keys, expected_keys); - t.done(); - } - }); -}; diff --git a/tests/wpt/tests/IndexedDB/idbobjectstore_add9.any.js b/tests/wpt/tests/IndexedDB/idbobjectstore_add9.any.js deleted file mode 100644 index dba9655867e..00000000000 --- a/tests/wpt/tests/IndexedDB/idbobjectstore_add9.any.js +++ /dev/null @@ -1,22 +0,0 @@ -// META: global=window,worker -// META: title=IDBObjectStore.add() - Attempt to add a record that does not meet the constraints of an object store's inline key requirements -// META: script=resources/support.js -// @author Microsoft - -'use_strict'; - -let t = async_test(); -const record = { key: 1, property: "data" }; - -const open_rq = createdb(t); -open_rq.onupgradeneeded = function(e) { - let rq; - db = e.target.result; - const objStore = db.createObjectStore("store", { keyPath: "key" }); - - assert_throws_dom("DataError", - function() { rq = objStore.add(record, 1); }); - - assert_equals(rq, undefined); - t.done(); -}; diff --git a/tests/wpt/tests/accessibility/crashtests/svg-mouse-listener.html b/tests/wpt/tests/accessibility/crashtests/svg-mouse-listener.html deleted file mode 100644 index 2de613e1d37..00000000000 --- a/tests/wpt/tests/accessibility/crashtests/svg-mouse-listener.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - diff --git a/tests/wpt/tests/accessibility/svg-mouse-listener.html b/tests/wpt/tests/accessibility/svg-mouse-listener.html new file mode 100644 index 00000000000..e2ca983d00a --- /dev/null +++ b/tests/wpt/tests/accessibility/svg-mouse-listener.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/accname/name/comp_name_from_content.html b/tests/wpt/tests/accname/name/comp_name_from_content.html index deae6699c6e..3504658ea46 100644 --- a/tests/wpt/tests/accname/name/comp_name_from_content.html +++ b/tests/wpt/tests/accname/name/comp_name_from_content.html @@ -49,6 +49,12 @@ content: " after "; /* [sic] leading and trailing space */ content: " after " / " alt-after "; /* Override the previous line for engines that support the Alternative Text syntax. */ } + .fallback-before-empty::before { + content: "before" / ""; + } + .fallback-before-image-empty::before { + content: "before " url(/images/blue.png) / ""; + } .fallback-before-mixed::before { content: " before "; /* [sic] leading and trailing space */ content: " before " / " start " attr(data-alt-text-before) " end "; /* Override the previous line for engines that support the Alternative Text syntax. */ @@ -145,6 +151,10 @@ label

+

Empty alternative text for CSS content in pseudo-elements when applied to primitive appearance form controls

+

+

+

simple w/ for each child


one two three

diff --git a/tests/wpt/tests/appmanifest/display-override-member/display-override-member-media-feature-tabbed-manual.tentative.html b/tests/wpt/tests/appmanifest/display-override-member/display-override-member-media-feature-tabbed-manual.tentative.html new file mode 100644 index 00000000000..04560071dfa --- /dev/null +++ b/tests/wpt/tests/appmanifest/display-override-member/display-override-member-media-feature-tabbed-manual.tentative.html @@ -0,0 +1,36 @@ + +Test "tabbed" in display-override member + media feature + + + + + + +

Test "tabbed" in display-override member + media feature

+ + +

+ To pass, the background color must be green after installing. +

diff --git a/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest b/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest new file mode 100644 index 00000000000..b8b5fdb0f0b --- /dev/null +++ b/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest @@ -0,0 +1,11 @@ +{ + "name": "Display override member media feature WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "192x192" + } + ], + "start_url": "../display-override-member-media-feature-tabbed-manual.tentative.html", + "display_override": [ "tabbed" ] +} diff --git a/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest.headers b/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest.headers new file mode 100644 index 00000000000..2bab061d43a --- /dev/null +++ b/tests/wpt/tests/appmanifest/display-override-member/resources/display-override-member-media-feature-tabbed.webmanifest.headers @@ -0,0 +1 @@ +Content-Type: application/manifest+json; charset=utf-8 diff --git a/tests/wpt/tests/attribution-reporting/header-parsing-error-debug-report.sub.https.html b/tests/wpt/tests/attribution-reporting/header-parsing-error-debug-report.sub.https.html new file mode 100644 index 00000000000..3c3ebe48d9f --- /dev/null +++ b/tests/wpt/tests/attribution-reporting/header-parsing-error-debug-report.sub.https.html @@ -0,0 +1,33 @@ + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/closewatcher-dialog-popover.html b/tests/wpt/tests/close-watcher/closewatcher-dialog-popover.html deleted file mode 100644 index 50d5cb7a4ca..00000000000 --- a/tests/wpt/tests/close-watcher/closewatcher-dialog-popover.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - -
popover
-
- - diff --git a/tests/wpt/tests/close-watcher/esc-key.html b/tests/wpt/tests/close-watcher/esc-key.html deleted file mode 100644 index 16fcce69173..00000000000 --- a/tests/wpt/tests/close-watcher/esc-key.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/wpt/tests/close-watcher/esc-key/README.md b/tests/wpt/tests/close-watcher/esc-key/README.md new file mode 100644 index 00000000000..817edc09ab8 --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/README.md @@ -0,0 +1,4 @@ +Tests in this directory are around the interaction of the Esc key specifically, +not the general concept of close requests. Ideally, all other tests would work +as-is if you changed the implementation of `sendCloseRequest()`. These tests +assume that Esc is the close request for the platform being tested. diff --git a/tests/wpt/tests/close-watcher/esc-key/keydown.html b/tests/wpt/tests/close-watcher/esc-key/keydown.html new file mode 100644 index 00000000000..cb0ddf0638f --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/keydown.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/esc-key/keypress.html b/tests/wpt/tests/close-watcher/esc-key/keypress.html new file mode 100644 index 00000000000..8dd58b064d7 --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/keypress.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/esc-key/keyup.html b/tests/wpt/tests/close-watcher/esc-key/keyup.html new file mode 100644 index 00000000000..341012d6bc8 --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/keyup.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/esc-key/not-user-activation.html b/tests/wpt/tests/close-watcher/esc-key/not-user-activation.html new file mode 100644 index 00000000000..ac29f84f06c --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/not-user-activation.html @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/esc-key/synthetic-keyboard-event.html b/tests/wpt/tests/close-watcher/esc-key/synthetic-keyboard-event.html new file mode 100644 index 00000000000..37b5507ac4a --- /dev/null +++ b/tests/wpt/tests/close-watcher/esc-key/synthetic-keyboard-event.html @@ -0,0 +1,28 @@ + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/resources/helpers.js b/tests/wpt/tests/close-watcher/resources/helpers.js index 97a62309cd5..dd9e191c4db 100644 --- a/tests/wpt/tests/close-watcher/resources/helpers.js +++ b/tests/wpt/tests/close-watcher/resources/helpers.js @@ -38,6 +38,14 @@ window.createBlessedRecordingCloseWatcher = async (t, events, name, type, parent return createRecordingCloseWatcher(t, events, name, type, parentWatcher); }; +window.destroyCloseWatcher = (watcher) => { + if (watcher instanceof HTMLElement) { + watcher.remove(); + } else { + watcher.destroy(); + } +}; + window.sendEscKey = () => { // Esc is \uE00C, *not* \uu001B; see https://w3c.github.io/webdriver/#keyboard-actions. // @@ -59,3 +67,9 @@ window.maybeTopLayerBless = (watcher) => { } return test_driver.bless(); }; + +window.waitForPotentialCloseEvent = () => { + // CloseWatchers fire close events synchronously, but dialog elements wait + // for a rAF before firing them. + return new Promise(requestAnimationFrame); +}; diff --git a/tests/wpt/tests/close-watcher/user-activation-CloseWatcher.html b/tests/wpt/tests/close-watcher/user-activation-CloseWatcher.html deleted file mode 100644 index 70435993f54..00000000000 --- a/tests/wpt/tests/close-watcher/user-activation-CloseWatcher.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/wpt/tests/close-watcher/user-activation-multiple-plus-free.html b/tests/wpt/tests/close-watcher/user-activation-multiple-plus-free.html deleted file mode 100644 index a94b47904a1..00000000000 --- a/tests/wpt/tests/close-watcher/user-activation-multiple-plus-free.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - diff --git a/tests/wpt/tests/close-watcher/user-activation-shared.html b/tests/wpt/tests/close-watcher/user-activation-shared.html deleted file mode 100644 index 77e748532a3..00000000000 --- a/tests/wpt/tests/close-watcher/user-activation-shared.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/wpt/tests/close-watcher/user-activation/n-activate-preventDefault.html b/tests/wpt/tests/close-watcher/user-activation/n-activate-preventDefault.html new file mode 100644 index 00000000000..531ef425998 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/n-activate-preventDefault.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/n-activate.html b/tests/wpt/tests/close-watcher/user-activation/n-activate.html new file mode 100644 index 00000000000..babcf54c3c1 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/n-activate.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/n-closerequest-n.html b/tests/wpt/tests/close-watcher/user-activation/n-closerequest-n.html new file mode 100644 index 00000000000..2424af7820e --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/n-closerequest-n.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/n-destroy-n.html b/tests/wpt/tests/close-watcher/user-activation/n-destroy-n.html new file mode 100644 index 00000000000..c26f87dd6f8 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/n-destroy-n.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/n.html b/tests/wpt/tests/close-watcher/user-activation/n.html new file mode 100644 index 00000000000..fe04e0dc1b9 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/n.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nn-activate-CloseWatcher.html b/tests/wpt/tests/close-watcher/user-activation/nn-activate-CloseWatcher.html new file mode 100644 index 00000000000..8045f30b482 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nn-activate-CloseWatcher.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nn-activate-dialog.html b/tests/wpt/tests/close-watcher/user-activation/nn-activate-dialog.html new file mode 100644 index 00000000000..5cc866044ce --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nn-activate-dialog.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nn.html b/tests/wpt/tests/close-watcher/user-activation/nn.html new file mode 100644 index 00000000000..beb63f1b4f5 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nn.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nnn-CloseWatcher-dialog-popover.html b/tests/wpt/tests/close-watcher/user-activation/nnn-CloseWatcher-dialog-popover.html new file mode 100644 index 00000000000..f8b9061d019 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nnn-CloseWatcher-dialog-popover.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + +
popover
+
+ + diff --git a/tests/wpt/tests/close-watcher/user-activation/nnn-popovers.html b/tests/wpt/tests/close-watcher/user-activation/nnn-popovers.html new file mode 100644 index 00000000000..ed5d15598fc --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nnn-popovers.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + +
+ + +
+ + +
p3
+
+
+ + diff --git a/tests/wpt/tests/close-watcher/user-activation/nnn.html b/tests/wpt/tests/close-watcher/user-activation/nnn.html new file mode 100644 index 00000000000..9b604e91db2 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nnn.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/ny-activate-preventDefault.html b/tests/wpt/tests/close-watcher/user-activation/ny-activate-preventDefault.html new file mode 100644 index 00000000000..5ffb64b1134 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/ny-activate-preventDefault.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/ny.html b/tests/wpt/tests/close-watcher/user-activation/ny.html new file mode 100644 index 00000000000..226912233e2 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/ny.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/popover-closewatcher-multiple-plus-free.html b/tests/wpt/tests/close-watcher/user-activation/nyn-popovers.html similarity index 89% rename from tests/wpt/tests/close-watcher/popover-closewatcher-multiple-plus-free.html rename to tests/wpt/tests/close-watcher/user-activation/nyn-popovers.html index 4913b1454ef..b6df610ae03 100644 --- a/tests/wpt/tests/close-watcher/popover-closewatcher-multiple-plus-free.html +++ b/tests/wpt/tests/close-watcher/user-activation/nyn-popovers.html @@ -6,7 +6,7 @@ - + @@ -39,5 +39,5 @@ promise_test(async () => { assert_false(p1.matches(':popover-open'), 'second escape: p1 should be closed.'); assert_false(p2.matches(':popover-open'), 'second escape: p2 should be closed.'); assert_false(p3.matches(':popover-open'), 'second escape: p3 should be closed.'); -}, 'Multiple popovers opened from a single user activation close together, but original popover closes separately.'); +}, 'Create a popover without user activation; create a popover with user activation; create a popover without user activation'); diff --git a/tests/wpt/tests/close-watcher/user-activation/nyn.html b/tests/wpt/tests/close-watcher/user-activation/nyn.html new file mode 100644 index 00000000000..ec5153c7674 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nyn.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nynn-destroy.html b/tests/wpt/tests/close-watcher/user-activation/nynn-destroy.html new file mode 100644 index 00000000000..8519c8a2a94 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nynn-destroy.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nynn.html b/tests/wpt/tests/close-watcher/user-activation/nynn.html new file mode 100644 index 00000000000..f6e74a0ba11 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nynn.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nyyn.html b/tests/wpt/tests/close-watcher/user-activation/nyyn.html new file mode 100644 index 00000000000..f3987c1a214 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nyyn.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/nyyyn.html b/tests/wpt/tests/close-watcher/user-activation/nyyyn.html new file mode 100644 index 00000000000..6cb8f3a4456 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/nyyyn.html @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/y.html b/tests/wpt/tests/close-watcher/user-activation/y.html new file mode 100644 index 00000000000..ee58a92293a --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/y.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/yn-activate.html b/tests/wpt/tests/close-watcher/user-activation/yn-activate.html new file mode 100644 index 00000000000..af7289aa28e --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yn-activate.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/yn.html b/tests/wpt/tests/close-watcher/user-activation/yn.html new file mode 100644 index 00000000000..8f7e90e2d85 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yn.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/ynn.html b/tests/wpt/tests/close-watcher/user-activation/ynn.html new file mode 100644 index 00000000000..8cc7f5bfb66 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/ynn.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/yy.html b/tests/wpt/tests/close-watcher/user-activation/yy.html new file mode 100644 index 00000000000..0aa03cdd050 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yy.html @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/yyn.html b/tests/wpt/tests/close-watcher/user-activation/yyn.html new file mode 100644 index 00000000000..b87cf7a7e34 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yyn.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/close-watcher/user-activation/yyy-CloseWatcher-dialog-popover.html b/tests/wpt/tests/close-watcher/user-activation/yyy-CloseWatcher-dialog-popover.html new file mode 100644 index 00000000000..f0a1cb06d10 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yyy-CloseWatcher-dialog-popover.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + +
popover
+
+ + diff --git a/tests/wpt/tests/close-watcher/user-activation/yyy-activate-CloseWatcher-dialog-popover.html b/tests/wpt/tests/close-watcher/user-activation/yyy-activate-CloseWatcher-dialog-popover.html new file mode 100644 index 00000000000..ed41d1bc321 --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yyy-activate-CloseWatcher-dialog-popover.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + +
popover
+
+ + diff --git a/tests/wpt/tests/close-watcher/popover-closewatcher.html b/tests/wpt/tests/close-watcher/user-activation/yyy-popovers.html similarity index 70% rename from tests/wpt/tests/close-watcher/popover-closewatcher.html rename to tests/wpt/tests/close-watcher/user-activation/yyy-popovers.html index b40ea2ec7c5..6f1b7394655 100644 --- a/tests/wpt/tests/close-watcher/popover-closewatcher.html +++ b/tests/wpt/tests/close-watcher/user-activation/yyy-popovers.html @@ -6,7 +6,7 @@ - + @@ -21,20 +21,6 @@ diff --git a/tests/wpt/tests/close-watcher/user-activation/yyy.html b/tests/wpt/tests/close-watcher/user-activation/yyy.html new file mode 100644 index 00000000000..f16767a86bd --- /dev/null +++ b/tests/wpt/tests/close-watcher/user-activation/yyy.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-opener.html b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-opener.html index 0e25f792619..a09b07e5b70 100644 --- a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-opener.html +++ b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-opener.html @@ -1,4 +1,6 @@ + + Window that opens a popup in a cross-site context @@ -26,17 +28,17 @@ } // Verify whether third-party cookies are blocked by default. - promise_test(async () => { - const thirdPartyHttpCookie = "3P_http" - await credFetch( - `${origin}/cookies/resources/set.py?${thirdPartyHttpCookie}=foobar;` + - "Secure;Path=/;SameSite=None"); - await assertHttpOriginCanAccessCookies({ + if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) { + assertThirdPartyHttpCookies({ + desc: "3P fetch", origin, - cookieNames: [thirdPartyHttpCookie], + cookieNames, expectsCookie: false, }); - }, "3P fetch: Cross site window setting HTTP cookies"); + } else { + // Default behavior for third-party cookie blocking is flaky in Firefox. + throw new AssertionError("Testing default third-party cookie blocking is not implemented in Firefox."); + } // Open the cookies' origin in a popup to activate the heuristic. const popupUrl = new URL( diff --git a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-verify.html b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-verify.html index 8d4819ad829..6deb88b5d03 100644 --- a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-verify.html +++ b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup-verify.html @@ -1,4 +1,6 @@ + + Verifies heuristics enabled by popup diff --git a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup.html b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup.html index 6f802007f8d..7addc7943c0 100644 --- a/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup.html +++ b/tests/wpt/tests/cookies/third-party-cookies/resources/third-party-cookies-cross-site-popup.html @@ -1,4 +1,6 @@ + + Cross-site popup diff --git a/tests/wpt/tests/cookies/third-party-cookies/third-party-cookie-heuristics.tentative.https.html b/tests/wpt/tests/cookies/third-party-cookies/third-party-cookie-heuristics.tentative.https.html index 3eb70432b94..32e7ab6d9ab 100644 --- a/tests/wpt/tests/cookies/third-party-cookies/third-party-cookie-heuristics.tentative.https.html +++ b/tests/wpt/tests/cookies/third-party-cookies/third-party-cookie-heuristics.tentative.https.html @@ -1,4 +1,6 @@ + + Test third-party cookie heuristics diff --git a/tests/wpt/tests/credential-management/digital-identity.https.html b/tests/wpt/tests/credential-management/digital-identity.https.html new file mode 100644 index 00000000000..1a9e09dbf3c --- /dev/null +++ b/tests/wpt/tests/credential-management/digital-identity.https.html @@ -0,0 +1,123 @@ + +Digital Identity Credential tests. + + + + + + + + + diff --git a/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html new file mode 100644 index 00000000000..a71e2621352 --- /dev/null +++ b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html @@ -0,0 +1,34 @@ + +Federated Credential Management API Button Mode basic tests. + + + + + + + diff --git a/tests/wpt/tests/credential-management/fedcm-button-mode-basics.https.html b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html similarity index 77% rename from tests/wpt/tests/credential-management/fedcm-button-mode-basics.https.html rename to tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html index abf46ee7db0..b71e84db47e 100644 --- a/tests/wpt/tests/credential-management/fedcm-button-mode-basics.https.html +++ b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html @@ -1,5 +1,5 @@ -Federated Credential Management API auto selected flag tests. +Federated Credential Management API Button Mode priority tests. @@ -9,41 +9,7 @@ + + + + + diff --git a/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html new file mode 100644 index 00000000000..2022bbc0f72 --- /dev/null +++ b/tests/wpt/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html @@ -0,0 +1,49 @@ + +Federated Credential Management API Use Another Account API tests. + + + + + + + diff --git a/tests/wpt/tests/credential-management/support/fedcm/manifest_with_variable_accounts.json b/tests/wpt/tests/credential-management/support/fedcm/manifest_with_variable_accounts.json index 10c2ddd55d1..9e4af250045 100644 --- a/tests/wpt/tests/credential-management/support/fedcm/manifest_with_variable_accounts.json +++ b/tests/wpt/tests/credential-management/support/fedcm/manifest_with_variable_accounts.json @@ -2,5 +2,13 @@ "accounts_endpoint": "variable_accounts.py", "client_metadata_endpoint": "client_metadata.py", "id_assertion_endpoint": "token_with_account_id.py", - "login_url": "login.html" + "login_url": "login.html", + "modes": { + "button": { + "supports_use_other_account": true + }, + "widget": { + "supports_use_other_account": true + } + } } diff --git a/tests/wpt/tests/credential-management/support/fedcm/set_accounts_cookie.py b/tests/wpt/tests/credential-management/support/fedcm/set_accounts_cookie.py new file mode 100644 index 00000000000..ab349922104 --- /dev/null +++ b/tests/wpt/tests/credential-management/support/fedcm/set_accounts_cookie.py @@ -0,0 +1,21 @@ +def main(request, response): + query_string = request.url_parts[3] + # We mark the cookie as HttpOnly so that this request + # can be made before login.html, which would overwrite + # the value to 1. + header_value = "accounts={}; SameSite=None; Secure; HttpOnly".format(query_string) + response.headers.set(b"Set-Cookie", header_value.encode("utf-8")) + response.headers.set(b"Content-Type", b"text/html") + + return """ + + +Sent header value: {}".format(header_value) +""" diff --git a/tests/wpt/tests/credential-management/support/fedcm/variable_accounts.py b/tests/wpt/tests/credential-management/support/fedcm/variable_accounts.py index c9db2c4528e..fc4446acc49 100644 --- a/tests/wpt/tests/credential-management/support/fedcm/variable_accounts.py +++ b/tests/wpt/tests/credential-management/support/fedcm/variable_accounts.py @@ -1,25 +1,14 @@ import importlib error_checker = importlib.import_module("credential-management.support.fedcm.request-params-check") -def main(request, response): - request_error = error_checker.accountsCheck(request) - if (request_error): - return request_error - - response.headers.set(b"Content-Type", b"application/json") - - if request.cookies.get(b"accounts") != b"1": - return """ -{ - "accounts": [ - ] -} +result_json = """ +{{ + "accounts": [{}] +}} """ - - return """ +one_account = """ { - "accounts": [{ "id": "1234", "given_name": "John", "name": "John Doe", @@ -28,6 +17,33 @@ def main(request, response): "approved_clients": ["123", "456", "789"], "login_hints": ["john_doe"], "hosted_domains": ["idp.example", "example"] - }] + } +""" + + +two_accounts = one_account + """ +, { + "id": "jane_doe", + "given_name": "Jane", + "name": "Jane Doe", + "email": "jane_doe@idp.example", + "picture": "https://idp.example/profile/5678", + "approved_clients": ["123", "abc"] } """ + +def main(request, response): + request_error = error_checker.accountsCheck(request) + if (request_error): + return request_error + + response.headers.set(b"Content-Type", b"application/json") + + if request.cookies.get(b"accounts") == b"1": + return result_json.format(one_account) + if request.cookies.get(b"accounts") == b"2": + return result_json.format(two_accounts) + + return result_json.format("") + + diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-default-001.html b/tests/wpt/tests/css/css-anchor-position/anchor-default-001.html index 8bb59851ee6..1700a84aa88 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-default-001.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-default-001.html @@ -13,16 +13,15 @@ .target { position: fixed; background: lime; - position-fallback: --pf; + position-try-options: --pf; + left: 999999px; /* force fallback */ } -@position-fallback --pf { - @try { - top: anchor(bottom, 0px); - left: anchor(left, 0px); - width: anchor-size(width, 0px); - height: anchor-size(height, 0px); - } +@position-try --pf { + top: anchor(bottom, 0px); + left: anchor(left, 0px); + width: anchor-size(width, 0px); + height: anchor-size(height, 0px); } body { diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-default-002.html b/tests/wpt/tests/css/css-anchor-position/anchor-default-002.html index 261119e0174..c0a962ad367 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-default-002.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-default-002.html @@ -13,16 +13,15 @@ .target { position: fixed; background: lime; - position-fallback: --pf; + position-try-options: --pf; + left: 999999px; /* force fallback */ } -@position-fallback --pf { - @try { - top: anchor(bottom, 0px); - left: anchor(left, 0px); - width: anchor-size(width, 0px); - height: anchor-size(height, 0px); - } +@position-try --pf { + top: anchor(bottom, 0px); + left: anchor(left, 0px); + width: anchor-size(width, 0px); + height: anchor-size(height, 0px); } body { diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-getComputedStyle-003.html b/tests/wpt/tests/css/css-anchor-position/anchor-getComputedStyle-003.html index f9fca976544..da9ec4a1451 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-getComputedStyle-003.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-getComputedStyle-003.html @@ -28,22 +28,21 @@ body { .target { position: absolute; + left: 999999px; width: 100px; height: 100px; background: lime; - position-fallback: --pf; + position-try-options: --pf, --pf2; } -@position-fallback --pf { - @try { - top: anchor(top); - left: anchor(right); - } - - @try { - top: anchor(top); - right: anchor(left); - } +@position-try --pf { + top: anchor(top); + left: anchor(right); +} +@position-try --pf2 { + top: anchor(top); + right: anchor(left); + left: auto; } #anchor1 { diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html index bc7e231e7ce..32cd9de0054 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-chained-fallback.tentative.html @@ -29,8 +29,10 @@ div { position: absolute; anchor-default: --a1; background: green; - position-fallback: --fallback; + position-try-options: --fallback; anchor-name: --a2; + left: anchor(--a1 left); + bottom: anchor(--a1 top); } #anchored2 { @@ -41,15 +43,9 @@ div { background: lime; } -@position-fallback --fallback { - @try { - left: anchor(--a1 left); - bottom: anchor(--a1 top); - } - @try { - left: anchor(--a1 right); - top: anchor(--a1 top); - } +@position-try --fallback { + left: anchor(--a1 right); + top: anchor(--a1 top); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-001.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-001.html similarity index 85% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-001.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-001.html index 04518e50193..b696ae0060c 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-001.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-001.html @@ -36,29 +36,28 @@ position: absolute; background: green; anchor-default: --a; - position-fallback: --fallback; + position-try-options: --f1, --f2; + width: 100px; height: 100px; + /* Above the anchor */ + left: anchor(--a left); + bottom: anchor(--a top); } -@position-fallback --fallback { - /* Above the anchor */ - @try { - width: 100px; height: 100px; - left: anchor(--a left); - bottom: anchor(--a top); - } +@position-try --f1 { /* Left of the anchor */ - @try { - width: 100px; height: 100px; - right: anchor(--a left); - top: anchor(--a top); - } - /* Right of the anchor */ - @try { - width: 100px; height: 100px; - left: anchor(--a right); - top: anchor(--a top); - } + right: anchor(--a left); + top: anchor(--a top); + bottom: auto; + left: auto; } + +@position-try --f2 { + /* Right of the anchor */ + left: anchor(--a right); + top: anchor(--a top); + bottom: auto; +} +
diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-002.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-002.html similarity index 91% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-002.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-002.html index f30c35d390d..3b84124705c 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-002.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-002.html @@ -33,12 +33,13 @@ body { background: green; anchor-default: --a; top: anchor(--a top); - position-fallback: --pf; + left: anchor(--a right); + position-try-options: --pf; } -@position-fallback --pf { - @try { left: anchor(--a right); } - @try { right: anchor(--a left); } +@position-try --pf { + left: auto; + right: anchor(--a left); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-003.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-003.html similarity index 92% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-003.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-003.html index 60bc9b919af..dd9fdc92c2e 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-003.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-003.html @@ -35,16 +35,17 @@ #anchored { position: absolute; + top: anchor(--a bottom); width: 100px; height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf; } -@position-fallback --pf { - @try { top: anchor(--a bottom); } - @try { bottom: anchor(--a top); } +@position-try --pf { + top: auto; + bottom: anchor(--a top); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-004.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-004.html similarity index 87% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-004.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-004.html index 99e4f9c30d1..0aab60b7a81 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-004.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-004.html @@ -34,16 +34,23 @@ body { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2; + /* Top of the anchor */ + bottom: anchor(--a top); + left: anchor(--a left); } -@position-fallback --pf { - /* Top of the anchor */ - @try { bottom: anchor(--a top); left: anchor(--a left); } +@position-try --pf1 { /* Bottom of the anchor */ - @try { top: anchor(--a bottom); left: anchor(--a left); } + top: anchor(--a bottom); + bottom: auto; +} +@position-try --pf2 { /* Left of the anchor */ - @try { top: anchor(--a top); right: anchor(--a left); } + top: anchor(--a top); + right: anchor(--a left); + bottom: auto; + left: auto; } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-005.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-005.html similarity index 91% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-005.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-005.html index 0adfe0834d8..e2dac13abd7 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-005.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-005.html @@ -34,12 +34,13 @@ body { background: green; anchor-default: --a; top: anchor(--a top); - position-fallback: --pf; + left: anchor(--a right); + position-try-options: --pf; } -@position-fallback --pf { - @try { left: anchor(--a right); } - @try { right: anchor(--a left); } +@position-try --pf { + left: auto; + right: anchor(--a left); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-006.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-006.html similarity index 83% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-006.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-006.html index b4a1a24de69..1f9004de54f 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-006.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-006.html @@ -29,26 +29,25 @@ body { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try: --pf1, --pf2, --pf3; + inset-block-start: anchor(--a end); + inset-inline-start: anchor(--a end); } -@position-fallback --pf { - @try { - inset-block-start: anchor(--a end); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-start: anchor(--a end); - inset-inline-end: anchor(--a start); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-end: anchor(--a start); - } +@position-try --pf1 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-start: anchor(--a end); +} +@position-try --pf2 { + inset: auto; + inset-block-start: anchor(--a end); + inset-inline-end: anchor(--a start); +} +@position-try --pf3 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-end: anchor(--a start); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-007.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-007.html similarity index 83% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-007.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-007.html index baa283ba944..32b7f641732 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-007.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-007.html @@ -33,26 +33,25 @@ html { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2, --pf3; + inset-block-start: anchor(--a end); + inset-inline-start: anchor(--a end); } -@position-fallback --pf { - @try { - inset-block-start: anchor(--a end); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-start: anchor(--a end); - inset-inline-end: anchor(--a start); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-end: anchor(--a start); - } +@position-try --pf1 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-start: anchor(--a end); +} +@position-try --pf2 { + inset: auto; + inset-block-start: anchor(--a end); + inset-inline-end: anchor(--a start); +} +@position-try --pf3 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-end: anchor(--a start); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-008.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-008.html similarity index 83% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-008.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-008.html index ae625d58239..99f180bb463 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-008.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-008.html @@ -34,26 +34,25 @@ html { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2, --pf3; + inset-block-start: anchor(--a end); + inset-inline-start: anchor(--a end); } -@position-fallback --pf { - @try { - inset-block-start: anchor(--a end); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-start: anchor(--a end); - inset-inline-end: anchor(--a start); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-end: anchor(--a start); - } +@position-try --pf1 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-start: anchor(--a end); +} +@position-try --pf2 { + inset: auto; + inset-block-start: anchor(--a end); + inset-inline-end: anchor(--a start); +} +@position-try --pf3 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-end: anchor(--a start); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-009.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-009.html similarity index 83% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-009.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-009.html index b355d476e6b..0267d1987be 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-009.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-009.html @@ -33,26 +33,25 @@ html { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2, --pf3; + inset-block-start: anchor(--a end); + inset-inline-start: anchor(--a end); } -@position-fallback --pf { - @try { - inset-block-start: anchor(--a end); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-start: anchor(--a end); - inset-inline-end: anchor(--a start); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-end: anchor(--a start); - } +@position-try --pf1 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-start: anchor(--a end); +} +@position-try --pf2 { + inset: auto; + inset-block-start: anchor(--a end); + inset-inline-end: anchor(--a start); +} +@position-try --pf3 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-end: anchor(--a start); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-010.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-010.html similarity index 83% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-010.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-010.html index a0dd599b3b6..133649c720f 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-010.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-010.html @@ -34,26 +34,25 @@ html { height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2, --pf3; + inset-block-start: anchor(--a end); + inset-inline-start: anchor(--a end); } -@position-fallback --pf { - @try { - inset-block-start: anchor(--a end); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-start: anchor(--a end); - } - @try { - inset-block-start: anchor(--a end); - inset-inline-end: anchor(--a start); - } - @try { - inset-block-end: anchor(--a start); - inset-inline-end: anchor(--a start); - } +@position-try --pf1 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-start: anchor(--a end); +} +@position-try --pf2 { + inset: auto; + inset-block-start: anchor(--a end); + inset-inline-end: anchor(--a start); +} +@position-try --pf3 { + inset: auto; + inset-block-end: anchor(--a start); + inset-inline-end: anchor(--a start); } diff --git a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-011.html b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-011.html similarity index 87% rename from tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-011.html rename to tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-011.html index 98fa4b5f86c..005a4ee728c 100644 --- a/tests/wpt/tests/css/css-anchor-position/anchor-scroll-fallback-position-011.html +++ b/tests/wpt/tests/css/css-anchor-position/anchor-scroll-position-try-011.html @@ -46,26 +46,25 @@ height: 100px; background: green; anchor-default: --a; - position-fallback: --pf; + position-try-options: --pf1, --pf2, --pf3; + bottom: anchor(--a top); + left: anchor(--a right); } -@position-fallback --pf { - @try { - bottom: anchor(--a top); - left: anchor(--a right); - } - @try { - top: anchor(--a bottom); - left: anchor(--a right); - } - @try { - bottom: anchor(--a top); - right: anchor(--a left); - } - @try { - top: anchor(--a bottom); - right: anchor(--a left); - } +@position-try --pf1 { + inset: auto; + top: anchor(--a bottom); + left: anchor(--a right); +} +@position-try --pf2 { + inset: auto; + bottom: anchor(--a top); + right: anchor(--a left); +} +@position-try --pf3 { + inset: auto; + top: anchor(--a bottom); + right: anchor(--a left); } diff --git a/tests/wpt/tests/css/css-anchor-position/at-fallback-position-parse.html b/tests/wpt/tests/css/css-anchor-position/at-fallback-position-parse.html deleted file mode 100644 index 942d9a29845..00000000000 --- a/tests/wpt/tests/css/css-anchor-position/at-fallback-position-parse.html +++ /dev/null @@ -1,39 +0,0 @@ - -Tests parsing of @fallback-position rule - - - - - - diff --git a/tests/wpt/tests/css/css-anchor-position/at-position-fallback-cssom.html b/tests/wpt/tests/css/css-anchor-position/at-position-fallback-cssom.html deleted file mode 100644 index df295bf2d0a..00000000000 --- a/tests/wpt/tests/css/css-anchor-position/at-position-fallback-cssom.html +++ /dev/null @@ -1,81 +0,0 @@ - -Tests the CSSOM interfaces of @position-fallback and @try rules - - - - - -
-
-
- - diff --git a/tests/wpt/tests/css/css-anchor-position/at-fallback-position-allowed-declarations.html b/tests/wpt/tests/css/css-anchor-position/at-position-try-allowed-declarations.html similarity index 85% rename from tests/wpt/tests/css/css-anchor-position/at-fallback-position-allowed-declarations.html rename to tests/wpt/tests/css/css-anchor-position/at-position-try-allowed-declarations.html index cca222ac6d7..622e9827b44 100644 --- a/tests/wpt/tests/css/css-anchor-position/at-fallback-position-allowed-declarations.html +++ b/tests/wpt/tests/css/css-anchor-position/at-position-try-allowed-declarations.html @@ -1,5 +1,5 @@ -Tests which properties are allowed in @fallback-position +Tests which properties are allowed in @position-try @@ -15,21 +15,21 @@ function test_allowed_declaration(property, value = '1px') { test(t => { t.add_cleanup(cleanup); const serialization = `${property}: ${value}`; - const rule = `@position-fallback --foo { @try { ${property}: ${value}; } }`; + const rule = `@position-try --foo { ${property}: ${value}; }`; const index = style.sheet.insertRule(rule); - const parsed = style.sheet.cssRules[index].cssRules[0]; - assert_equals(parsed.cssText, `@try { ${serialization}; }`); - }, `${property}: ${value} is allowed in @fallback-position`); + const parsed = style.sheet.cssRules[index]; + assert_equals(parsed.cssText, `@position-try --foo { ${serialization}; }`); + }, `${property}: ${value} is allowed in @position-try`); } function test_disallowed_declaration(property, value = '1px') { test(t => { t.add_cleanup(cleanup); - const rule = `@position-fallback --foo { @try { ${property}: ${value}; } }`; + const rule = `@position-try --foo { ${property}: ${value}; }`; const index = style.sheet.insertRule(rule); - const parsed = style.sheet.cssRules[index].cssRules[0]; - assert_equals(parsed.cssText, `@try { }`); - }, `${property}: ${value} is disallowed in @fallback-position`); + const parsed = style.sheet.cssRules[index]; + assert_equals(parsed.cssText, `@position-try --foo { }`); + }, `${property}: ${value} is disallowed in @position-try`); } // Inset properties are allowed diff --git a/tests/wpt/tests/css/css-anchor-position/at-position-try-cssom.html b/tests/wpt/tests/css/css-anchor-position/at-position-try-cssom.html new file mode 100644 index 00000000000..d4a1f4fa24c --- /dev/null +++ b/tests/wpt/tests/css/css-anchor-position/at-position-try-cssom.html @@ -0,0 +1,61 @@ + +Tests the CSSOM interfaces of @position-try rules + + + + + +
+
+
+ + diff --git a/tests/wpt/tests/css/css-anchor-position/at-position-fallback-invalidation-shadow-dom.html b/tests/wpt/tests/css/css-anchor-position/at-position-try-invalidation-shadow-dom.html similarity index 62% rename from tests/wpt/tests/css/css-anchor-position/at-position-fallback-invalidation-shadow-dom.html rename to tests/wpt/tests/css/css-anchor-position/at-position-try-invalidation-shadow-dom.html index 066cba1dac7..e5d6c51a0b9 100644 --- a/tests/wpt/tests/css/css-anchor-position/at-position-fallback-invalidation-shadow-dom.html +++ b/tests/wpt/tests/css/css-anchor-position/at-position-try-invalidation-shadow-dom.html @@ -1,5 +1,5 @@ -CSS Anchor Positioning Test: Dynamically change @position-fallback rules in Shadow DOM +CSS Anchor Positioning Test: Dynamically change @position-try rules in Shadow DOM @@ -11,8 +11,9 @@