diff options
Diffstat (limited to 'components')
416 files changed, 2129 insertions, 2500 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index aabb2e69b67..7078e063978 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -181,12 +181,15 @@ pub struct InlineBlockSplit { impl InlineBlockSplit { /// Flushes the given accumulator to the new split and makes a new accumulator to hold any /// subsequent fragments. - fn new<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>( + fn new<'dom, ConcreteThreadSafeLayoutNode>( fragment_accumulator: &mut InlineFragmentsAccumulator, node: &ConcreteThreadSafeLayoutNode, style_context: &SharedStyleContext, flow: FlowRef, - ) -> InlineBlockSplit { + ) -> InlineBlockSplit + where + ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>, + { fragment_accumulator.enclosing_node.as_mut().expect( "enclosing_node is None; Are {ib} splits being generated outside of an inline node?" ).flags.remove(InlineFragmentNodeFlags::LAST_FRAGMENT_OF_ELEMENT); @@ -272,13 +275,10 @@ impl InlineFragmentsAccumulator { } } - fn from_inline_node<N>( - node: &N, + fn from_inline_node<'dom>( + node: &impl ThreadSafeLayoutNode<'dom>, style_context: &SharedStyleContext, - ) -> InlineFragmentsAccumulator - where - N: ThreadSafeLayoutNode, - { + ) -> InlineFragmentsAccumulator { InlineFragmentsAccumulator { fragments: IntermediateInlineFragments::new(), enclosing_node: Some(InlineFragmentNodeInfo { @@ -305,12 +305,12 @@ impl InlineFragmentsAccumulator { .push_descendants(fragments.absolute_descendants); } - fn to_intermediate_inline_fragments<N>( + fn to_intermediate_inline_fragments<'dom, N>( self, context: &SharedStyleContext, ) -> IntermediateInlineFragments where - N: ThreadSafeLayoutNode, + N: ThreadSafeLayoutNode<'dom>, { let InlineFragmentsAccumulator { mut fragments, @@ -366,7 +366,7 @@ impl InlineFragmentsAccumulator { } /// An object that knows how to create flows. -pub struct FlowConstructor<'a, N: ThreadSafeLayoutNode> { +pub struct FlowConstructor<'a, N> { /// The layout context. pub layout_context: &'a LayoutContext<'a>, /// Satisfy the compiler about the unused parameters, which we use to improve the ergonomics of @@ -374,8 +374,9 @@ pub struct FlowConstructor<'a, N: ThreadSafeLayoutNode> { phantom2: PhantomData<N>, } -impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> - FlowConstructor<'a, ConcreteThreadSafeLayoutNode> +impl<'a, 'dom, ConcreteThreadSafeLayoutNode> FlowConstructor<'a, ConcreteThreadSafeLayoutNode> +where + ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>, { /// Creates a new flow constructor. pub fn new(layout_context: &'a LayoutContext<'a>) -> Self { @@ -1792,10 +1793,11 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> } } -impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode> +impl<'a, 'dom, ConcreteThreadSafeLayoutNode> + PostorderNodeMutTraversal<'dom, ConcreteThreadSafeLayoutNode> for FlowConstructor<'a, ConcreteThreadSafeLayoutNode> where - ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode, + ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>, { // Construct Flow based on 'display', 'position', and 'float' values. // @@ -1988,9 +1990,9 @@ trait NodeUtils { fn get_construction_result(self) -> ConstructionResult; } -impl<ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode +impl<'dom, ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode where - ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode, + ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>, { fn is_replaced_content(&self) -> bool { match self.type_id() { diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index d074c300e2f..289dc3f3094 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -411,10 +411,10 @@ impl ImageFragmentInfo { /// /// FIXME(pcwalton): The fact that image fragments store the cache in the fragment makes little /// sense to me. - pub fn new<N: ThreadSafeLayoutNode>( + pub fn new<'dom>( url: Option<ServoUrl>, density: Option<f64>, - node: &N, + node: &impl ThreadSafeLayoutNode<'dom>, layout_context: &LayoutContext, ) -> ImageFragmentInfo { // First use any image data present in the element... @@ -488,7 +488,7 @@ pub struct IframeFragmentInfo { impl IframeFragmentInfo { /// Creates the information specific to an iframe fragment. - pub fn new<N: ThreadSafeLayoutNode>(node: &N) -> IframeFragmentInfo { + pub fn new<'dom>(node: &impl ThreadSafeLayoutNode<'dom>) -> IframeFragmentInfo { let browsing_context_id = node.iframe_browsing_context_id(); let pipeline_id = node.iframe_pipeline_id(); IframeFragmentInfo { @@ -642,7 +642,7 @@ pub struct TableColumnFragmentInfo { impl TableColumnFragmentInfo { /// Create the information specific to an table column fragment. - pub fn new<N: ThreadSafeLayoutNode>(node: &N) -> TableColumnFragmentInfo { + pub fn new<'dom>(node: &impl ThreadSafeLayoutNode<'dom>) -> TableColumnFragmentInfo { let element = node.as_element().unwrap(); let span = element .get_attr(&ns!(), &local_name!("span")) @@ -663,8 +663,8 @@ pub struct TruncatedFragmentInfo { impl Fragment { /// Constructs a new `Fragment` instance. - pub fn new<N: ThreadSafeLayoutNode>( - node: &N, + pub fn new<'dom>( + node: &impl ThreadSafeLayoutNode<'dom>, specific: SpecificFragmentInfo, ctx: &LayoutContext, ) -> Fragment { diff --git a/components/layout/query.rs b/components/layout/query.rs index cda001c485c..cd3e75bf28c 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -688,9 +688,9 @@ pub fn process_client_rect_query( iterator.client_rect } -pub fn process_node_scroll_id_request<N: LayoutNode>( +pub fn process_node_scroll_id_request<'dom>( id: PipelineId, - requested_node: N, + requested_node: impl LayoutNode<'dom>, ) -> ExternalScrollId { let layout_node = requested_node.to_threadsafe(); layout_node.generate_scroll_id(id) @@ -747,16 +747,13 @@ pub fn process_node_scroll_area_request( /// Return the resolved value of property for a given (pseudo)element. /// <https://drafts.csswg.org/cssom/#resolved-value> -pub fn process_resolved_style_request<'a, N>( +pub fn process_resolved_style_request<'dom>( context: &LayoutContext, - node: N, + node: impl LayoutNode<'dom>, pseudo: &Option<PseudoElement>, property: &PropertyId, layout_root: &mut dyn Flow, -) -> String -where - N: LayoutNode, -{ +) -> String { use style::stylist::RuleInclusion; use style::traversal::resolve_style; @@ -797,15 +794,12 @@ where } /// The primary resolution logic, which assumes that the element is styled. -fn process_resolved_style_request_internal<'a, N>( - requested_node: N, +fn process_resolved_style_request_internal<'dom>( + requested_node: impl LayoutNode<'dom>, pseudo: &Option<PseudoElement>, property: &PropertyId, layout_root: &mut dyn Flow, -) -> String -where - N: LayoutNode, -{ +) -> String { let layout_el = requested_node.to_threadsafe().as_element().unwrap(); let layout_el = match *pseudo { Some(PseudoElement::Before) => layout_el.get_before_pseudo(), @@ -851,12 +845,15 @@ where // There are probably other quirks. let applies = true; - fn used_value_for_position_property<N: LayoutNode>( - layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode>::ConcreteThreadSafeLayoutElement, + fn used_value_for_position_property<'dom, N>( + layout_el: <N::ConcreteThreadSafeLayoutNode as ThreadSafeLayoutNode<'dom>>::ConcreteThreadSafeLayoutElement, layout_root: &mut dyn Flow, requested_node: N, longhand_id: LonghandId, - ) -> String { + ) -> String + where + N: LayoutNode<'dom>, + { let maybe_data = layout_el.borrow_layout_data(); let position = maybe_data.map_or(Point2D::zero(), |data| { match (*data).flow_construction_result { @@ -969,7 +966,7 @@ pub fn process_offset_parent_query( } } -pub fn process_style_query<N: LayoutNode>(requested_node: N) -> StyleResponse { +pub fn process_style_query<'dom>(requested_node: impl LayoutNode<'dom>) -> StyleResponse { let element = requested_node.as_element().unwrap(); let data = element.borrow_data(); @@ -982,8 +979,8 @@ enum InnerTextItem { } // https://html.spec.whatwg.org/multipage/#the-innertext-idl-attribute -pub fn process_element_inner_text_query<N: LayoutNode>( - node: N, +pub fn process_element_inner_text_query<'dom>( + node: impl LayoutNode<'dom>, indexable_text: &IndexableText, ) -> String { // Step 1. @@ -1027,8 +1024,8 @@ pub fn process_element_inner_text_query<N: LayoutNode>( // https://html.spec.whatwg.org/multipage/#inner-text-collection-steps #[allow(unsafe_code)] -fn inner_text_collection_steps<N: LayoutNode>( - node: N, +fn inner_text_collection_steps<'dom>( + node: impl LayoutNode<'dom>, indexable_text: &IndexableText, results: &mut Vec<InnerTextItem>, ) { diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 89d83702f0e..b1fa1852650 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -61,8 +61,8 @@ impl TableCellFlow { } } - pub fn from_node_fragment_and_visibility_flag<N: ThreadSafeLayoutNode>( - node: &N, + pub fn from_node_fragment_and_visibility_flag<'dom>( + node: &impl ThreadSafeLayoutNode<'dom>, fragment: Fragment, visible: bool, ) -> TableCellFlow { diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index e968c184341..244531cee46 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -38,10 +38,10 @@ impl<'a> RecalcStyleAndConstructFlows<'a> { } #[allow(unsafe_code)] -impl<'a, E> DomTraversal<E> for RecalcStyleAndConstructFlows<'a> +impl<'a, 'dom, E> DomTraversal<E> for RecalcStyleAndConstructFlows<'a> where E: TElement, - E::ConcreteNode: LayoutNode, + E::ConcreteNode: LayoutNode<'dom>, E::FontMetricsProvider: Send, { fn process_preorder<F>( @@ -175,7 +175,10 @@ pub trait InorderFlowTraversal { } /// A bottom-up, parallelizable traversal. -pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> { +pub trait PostorderNodeMutTraversal<'dom, ConcreteThreadSafeLayoutNode> +where + ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>, +{ /// The operation to perform. Return true to continue or false to stop. fn process(&mut self, node: &ConcreteThreadSafeLayoutNode); } @@ -183,10 +186,7 @@ pub trait PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode: ThreadSafeLayo /// The flow construction traversal, which builds flows for styled nodes. #[inline] #[allow(unsafe_code)] -fn construct_flows_at<N>(context: &LayoutContext, node: N) -where - N: LayoutNode, -{ +fn construct_flows_at<'dom>(context: &LayoutContext, node: impl LayoutNode<'dom>) { debug!("construct_flows_at: {:?}", node); // Construct flows for this node. diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 063d7f3d25d..af8d6b6a0c7 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -47,7 +47,10 @@ pub trait LayoutNodeLayoutData { fn flow_debug_id(self) -> usize; } -impl<T: GetLayoutData> LayoutNodeLayoutData for T { +impl<'dom, T> LayoutNodeLayoutData for T +where + T: GetLayoutData<'dom>, +{ fn borrow_layout_data(&self) -> Option<AtomicRef<LayoutData>> { self.get_raw_data().map(|d| d.layout_data.borrow()) } @@ -66,7 +69,10 @@ pub trait GetRawData { fn get_raw_data(&self) -> Option<&StyleAndLayoutData>; } -impl<T: GetLayoutData> GetRawData for T { +impl<'dom, T> GetRawData for T +where + T: GetLayoutData<'dom>, +{ fn get_raw_data(&self) -> Option<&StyleAndLayoutData> { self.get_style_and_layout_data().map(|opaque| { let container = opaque.ptr.as_ptr() as *mut StyleAndLayoutData; @@ -98,7 +104,10 @@ pub trait ThreadSafeLayoutNodeHelpers { fn restyle_damage(self) -> RestyleDamage; } -impl<T: ThreadSafeLayoutNode> ThreadSafeLayoutNodeHelpers for T { +impl<'dom, T> ThreadSafeLayoutNodeHelpers for T +where + T: ThreadSafeLayoutNode<'dom>, +{ fn flags(self) -> LayoutDataFlags { self.borrow_layout_data().as_ref().unwrap().flags } diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index a4cbe4c4ea1..0d3e30dba53 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -14,7 +14,7 @@ doctest = false [dependencies] app_units = "0.7" -atomic_refcell = "0.1" +atomic_refcell = "0.1.6" canvas_traits = {path = "../canvas_traits"} cssparser = "0.27" embedder_traits = {path = "../embedder_traits"} diff --git a/components/layout_2020/cell.rs b/components/layout_2020/cell.rs new file mode 100644 index 00000000000..8aae377b24c --- /dev/null +++ b/components/layout_2020/cell.rs @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +use atomic_refcell::AtomicRefCell; +use serde::{Serialize, Serializer}; +use servo_arc::Arc; +use std::fmt; +use std::ops::Deref; + +pub(crate) struct ArcRefCell<T> { + value: Arc<AtomicRefCell<T>>, +} + +impl<T> ArcRefCell<T> { + pub fn new(value: T) -> Self { + Self { + value: Arc::new(AtomicRefCell::new(value)), + } + } +} + +impl<T> Clone for ArcRefCell<T> { + fn clone(&self) -> Self { + Self { + value: self.value.clone(), + } + } +} + +impl<T> Default for ArcRefCell<T> +where + T: Default, +{ + fn default() -> Self { + Self { + value: Arc::new(AtomicRefCell::new(Default::default())), + } + } +} + +impl<T> Deref for ArcRefCell<T> { + type Target = AtomicRefCell<T>; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + +impl<T> fmt::Debug for ArcRefCell<T> +where + T: fmt::Debug, +{ + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + self.value.fmt(formatter) + } +} + +impl<T> Serialize for ArcRefCell<T> +where + T: Serialize, +{ + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: Serializer, + { + self.borrow().serialize(serializer) + } +} diff --git a/components/layout_2020/display_list/conversions.rs b/components/layout_2020/display_list/conversions.rs index 410797796dd..0b6dff8506c 100644 --- a/components/layout_2020/display_list/conversions.rs +++ b/components/layout_2020/display_list/conversions.rs @@ -4,6 +4,7 @@ use crate::geom::{PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize}; use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode; +use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle; use style::computed_values::transform_style::T as ComputedTransformStyle; use style::values::computed::Filter as ComputedFilter; use style::values::computed::Length; @@ -100,3 +101,16 @@ impl ToWebRender for PhysicalSides<Length> { ) } } + +impl ToWebRender for ComputedTextDecorationStyle { + type Type = webrender_api::LineStyle; + fn to_webrender(&self) -> Self::Type { + match *self { + ComputedTextDecorationStyle::Solid => wr::LineStyle::Solid, + ComputedTextDecorationStyle::Dotted => wr::LineStyle::Dotted, + ComputedTextDecorationStyle::Dashed => wr::LineStyle::Dashed, + ComputedTextDecorationStyle::Wavy => wr::LineStyle::Wavy, + _ => wr::LineStyle::Solid, + } + } +} diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index e8361ce5e9f..46c31934831 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -4,7 +4,7 @@ use crate::context::LayoutContext; use crate::display_list::conversions::ToWebRender; -use crate::fragments::{BoxFragment, Fragment}; +use crate::fragments::{BoxFragment, Fragment, TextFragment}; use crate::geom::{PhysicalPoint, PhysicalRect}; use crate::replaced::IntrinsicSizes; use embedder_traits::Cursor; @@ -13,10 +13,11 @@ use gfx::text::glyph::GlyphStore; use mitochondria::OnceCell; use net_traits::image_cache::UsePlaceholder; use std::sync::Arc; +use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle; use style::dom::OpaqueNode; use style::properties::ComputedValues; - use style::values::computed::{BorderStyle, Length, LengthPercentage}; +use style::values::specified::text::TextDecorationLine; use style::values::specified::ui::CursorKind; use webrender_api::{self as wr, units}; @@ -80,30 +81,6 @@ impl Fragment { Fragment::Box(b) => BuilderForBoxFragment::new(b, containing_block).build(builder), Fragment::AbsoluteOrFixedPositioned(_) => {}, Fragment::Anonymous(_) => {}, - Fragment::Text(t) => { - builder.is_contentful = true; - let rect = t - .rect - .to_physical(t.parent_style.writing_mode, containing_block) - .translate(containing_block.origin.to_vector()); - let mut baseline_origin = rect.origin.clone(); - baseline_origin.y += t.ascent; - let glyphs = glyphs(&t.glyphs, baseline_origin); - if glyphs.is_empty() { - return; - } - let mut common = builder.common_properties(rect.clone().to_webrender()); - common.hit_info = hit_info(&t.parent_style, t.tag, Cursor::Text); - let color = t.parent_style.clone_color(); - builder.wr.push_text( - &common, - rect.to_webrender(), - &glyphs, - t.font_key, - rgba(color), - None, - ); - }, Fragment::Image(i) => { builder.is_contentful = true; let rect = i @@ -120,8 +97,111 @@ impl Fragment { wr::ColorF::WHITE, ); }, + Fragment::Text(t) => { + self.build_display_list_for_text_fragment(t, builder, containing_block) + }, + } + } + + fn build_display_list_for_text_fragment( + &self, + fragment: &TextFragment, + builder: &mut DisplayListBuilder, + containing_block: &PhysicalRect<Length>, + ) { + // NB: The order of painting text components (CSS Text Decoration Module Level 3) is: + // shadows, underline, overline, text, text-emphasis, and then line-through. + + builder.is_contentful = true; + + let rect = fragment + .rect + .to_physical(fragment.parent_style.writing_mode, containing_block) + .translate(containing_block.origin.to_vector()); + let mut baseline_origin = rect.origin.clone(); + baseline_origin.y += fragment.font_metrics.ascent; + let glyphs = glyphs(&fragment.glyphs, baseline_origin); + if glyphs.is_empty() { + return; + } + + let mut common = builder.common_properties(rect.to_webrender()); + common.hit_info = hit_info(&fragment.parent_style, fragment.tag, Cursor::Text); + + let color = fragment.parent_style.clone_color(); + let font_metrics = &fragment.font_metrics; + + // Underline. + if fragment + .text_decoration_line + .contains(TextDecorationLine::UNDERLINE) + { + let mut rect = rect; + rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.underline_offset; + rect.size.height = font_metrics.underline_size; + self.build_display_list_for_text_decoration(fragment, builder, &rect, color); + } + + // Overline. + if fragment + .text_decoration_line + .contains(TextDecorationLine::OVERLINE) + { + let mut rect = rect; + rect.size.height = font_metrics.underline_size; + self.build_display_list_for_text_decoration(fragment, builder, &rect, color); + } + + // Text. + builder.wr.push_text( + &common, + rect.to_webrender(), + &glyphs, + fragment.font_key, + rgba(color), + None, + ); + + // Line-through. + if fragment + .text_decoration_line + .contains(TextDecorationLine::LINE_THROUGH) + { + let mut rect = rect; + rect.origin.y = rect.origin.y + font_metrics.ascent - font_metrics.strikeout_offset; + // XXX(ferjm) This does not work on MacOS #942 + rect.size.height = font_metrics.strikeout_size; + self.build_display_list_for_text_decoration(fragment, builder, &rect, color); } } + + fn build_display_list_for_text_decoration( + &self, + fragment: &TextFragment, + builder: &mut DisplayListBuilder, + rect: &PhysicalRect<Length>, + color: cssparser::RGBA, + ) { + let rect = rect.to_webrender(); + let wavy_line_thickness = (0.33 * rect.size.height).ceil(); + let text_decoration_color = fragment + .parent_style + .clone_text_decoration_color() + .to_rgba(color); + let text_decoration_style = fragment.parent_style.clone_text_decoration_style(); + if text_decoration_style == ComputedTextDecorationStyle::MozNone { + return; + } + builder.wr.push_line( + &builder.common_properties(rect), + &rect, + wavy_line_thickness, + wr::LineOrientation::Horizontal, + &rgba(text_decoration_color), + text_decoration_style.to_webrender(), + ); + // XXX(ferjm) support text-decoration-style: double + } } struct BuilderForBoxFragment<'a> { diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs index 87a170f499e..7059b2c3ccb 100644 --- a/components/layout_2020/display_list/stacking_context.rs +++ b/components/layout_2020/display_list/stacking_context.rs @@ -2,23 +2,24 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::display_list::conversions::ToWebRender; use crate::display_list::DisplayListBuilder; use crate::fragments::{ AbsoluteOrFixedPositionedFragment, AnonymousFragment, BoxFragment, Fragment, }; use crate::geom::PhysicalRect; -use crate::positioned::HoistedFragmentId; use crate::style_ext::ComputedValuesExt; use euclid::default::Rect; -use fnv::FnvHashMap; use gfx_traits::{combine_id_with_fragment_type, FragmentType}; +use servo_arc::Arc as ServoArc; use std::cmp::Ordering; use std::mem; use style::computed_values::float::T as ComputedFloat; use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode; use style::computed_values::overflow_x::T as ComputedOverflow; use style::computed_values::position::T as ComputedPosition; +use style::properties::ComputedValues; use style::values::computed::Length; use style::values::generics::box_::Perspective; use style::values::generics::transform; @@ -27,55 +28,38 @@ use webrender_api as wr; use webrender_api::units::{LayoutPoint, LayoutTransform, LayoutVector2D}; #[derive(Clone)] -pub(crate) struct ContainingBlock<'a> { +pub(crate) struct ContainingBlock { /// The SpaceAndClipInfo that contains the children of the fragment that /// established this containing block. space_and_clip: wr::SpaceAndClipInfo, /// The physical rect of this containing block. rect: PhysicalRect<Length>, - - /// Fragments for positioned descendants (including direct children) that were - /// hoisted into this containing block. They have hashed based on the - /// HoistedFragmentId that is generated during hoisting. - hoisted_children: FnvHashMap<HoistedFragmentId, &'a Fragment>, } -impl<'a> ContainingBlock<'a> { - pub(crate) fn new( - rect: &PhysicalRect<Length>, - space_and_clip: wr::SpaceAndClipInfo, - children: &'a Vec<Fragment>, - ) -> Self { - let mut hoisted_children = FnvHashMap::default(); - for child in children { - if let Some(hoisted_fragment_id) = child.hoisted_fragment_id() { - hoisted_children.insert(*hoisted_fragment_id, child); - } - } - +impl ContainingBlock { + pub(crate) fn new(rect: &PhysicalRect<Length>, space_and_clip: wr::SpaceAndClipInfo) -> Self { ContainingBlock { space_and_clip, rect: *rect, - hoisted_children, } } } #[derive(Clone)] -pub(crate) struct ContainingBlockInfo<'a> { +pub(crate) struct ContainingBlockInfo { /// The positioning rectangle established by the parent. This is sometimes /// called the "containing block" in layout_2020. pub rect: PhysicalRect<Length>, /// The nearest real containing block at this point in the construction of /// the stacking context tree. - pub nearest_containing_block: Option<ContainingBlock<'a>>, + pub nearest_containing_block: Option<ContainingBlock>, /// The nearest containing block for all descendants at this point in the /// stacking context tree. This containing blocks contains fixed position /// elements. - pub containing_block_for_all_descendants: ContainingBlock<'a>, + pub containing_block_for_all_descendants: ContainingBlock, } pub(crate) struct StackingContextBuilder<'a> { @@ -117,17 +101,18 @@ pub(crate) enum StackingContextSection { Content, } -pub(crate) struct StackingContextFragment<'a> { +pub(crate) struct StackingContextFragment { space_and_clip: wr::SpaceAndClipInfo, section: StackingContextSection, containing_block: PhysicalRect<Length>, - fragment: &'a Fragment, + fragment: ArcRefCell<Fragment>, } -impl<'a> StackingContextFragment<'a> { +impl StackingContextFragment { fn build_display_list(&self, builder: &mut DisplayListBuilder) { builder.current_space_and_clip = self.space_and_clip; self.fragment + .borrow() .build_display_list(builder, &self.containing_block); } } @@ -140,31 +125,31 @@ pub(crate) enum StackingContextType { PseudoAtomicInline, } -pub(crate) struct StackingContext<'a> { +pub(crate) struct StackingContext { /// The fragment that established this stacking context. - initializing_fragment: Option<&'a BoxFragment>, + initializing_fragment_style: Option<ServoArc<ComputedValues>>, /// The type of this StackingContext. Used for collecting and sorting. context_type: StackingContextType, /// Fragments that make up the content of this stacking context. - fragments: Vec<StackingContextFragment<'a>>, + fragments: Vec<StackingContextFragment>, /// All non-float stacking context and pseudo stacking context children /// of this stacking context. - stacking_contexts: Vec<StackingContext<'a>>, + stacking_contexts: Vec<StackingContext>, /// All float pseudo stacking context children of this stacking context. - float_stacking_contexts: Vec<StackingContext<'a>>, + float_stacking_contexts: Vec<StackingContext>, } -impl<'a> StackingContext<'a> { +impl StackingContext { pub(crate) fn new( - initializing_fragment: &'a BoxFragment, + initializing_fragment_style: ServoArc<ComputedValues>, context_type: StackingContextType, ) -> Self { Self { - initializing_fragment: Some(initializing_fragment), + initializing_fragment_style: Some(initializing_fragment_style), context_type, fragments: vec![], stacking_contexts: vec![], @@ -174,7 +159,7 @@ impl<'a> StackingContext<'a> { pub(crate) fn create_root() -> Self { Self { - initializing_fragment: None, + initializing_fragment_style: None, context_type: StackingContextType::Real, fragments: vec![], stacking_contexts: vec![], @@ -183,10 +168,9 @@ impl<'a> StackingContext<'a> { } fn z_index(&self) -> i32 { - match self.initializing_fragment { - Some(fragment) => fragment.style.effective_z_index(), - None => 0, - } + self.initializing_fragment_style + .as_ref() + .map_or(0, |style| style.effective_z_index()) } pub(crate) fn sort(&mut self) { @@ -210,18 +194,17 @@ impl<'a> StackingContext<'a> { }); } - fn push_webrender_stacking_context_if_necessary( + fn push_webrender_stacking_context_if_necessary<'a>( &self, builder: &'a mut DisplayListBuilder, ) -> bool { - let fragment = match self.initializing_fragment { - Some(fragment) => fragment, + let effects = match self.initializing_fragment_style.as_ref() { + Some(style) => style.get_effects(), None => return false, }; // WebRender only uses the stacking context to apply certain effects. If we don't // actually need to create a stacking context, just avoid creating one. - let effects = fragment.style.get_effects(); if effects.filter.0.is_empty() && effects.opacity == 1.0 && effects.mix_blend_mode == ComputedMixBlendMode::Normal @@ -261,7 +244,7 @@ impl<'a> StackingContext<'a> { true } - pub(crate) fn build_display_list(&'a self, builder: &'a mut DisplayListBuilder) { + pub(crate) fn build_display_list<'a>(&self, builder: &'a mut DisplayListBuilder) { let pushed_context = self.push_webrender_stacking_context_if_necessary(builder); // Properly order display items that make up a stacking context. "Steps" here @@ -323,21 +306,24 @@ pub(crate) enum StackingContextBuildMode { } impl Fragment { - pub(crate) fn build_stacking_context_tree<'a>( - &'a self, + pub(crate) fn build_stacking_context_tree( + &self, + fragment_ref: &ArcRefCell<Fragment>, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, - stacking_context: &mut StackingContext<'a>, + containing_block_info: &ContainingBlockInfo, + stacking_context: &mut StackingContext, mode: StackingContextBuildMode, ) { - if mode == StackingContextBuildMode::SkipHoisted && self.is_hoisted() { - return; - } - match self { Fragment::Box(fragment) => { + if mode == StackingContextBuildMode::SkipHoisted && + fragment.style.clone_position().is_absolutely_positioned() + { + return; + } + fragment.build_stacking_context_tree( - self, + fragment_ref, builder, containing_block_info, stacking_context, @@ -362,7 +348,7 @@ impl Fragment { section: StackingContextSection::Content, space_and_clip: builder.current_space_and_clip, containing_block: containing_block_info.rect, - fragment: self, + fragment: fragment_ref.clone(), }); }, } @@ -407,14 +393,14 @@ impl BoxFragment { &'a self, builder: &mut StackingContextBuilder, padding_rect: &PhysicalRect<Length>, - containing_block_info: &mut ContainingBlockInfo<'a>, + containing_block_info: &mut ContainingBlockInfo, ) { if !self.style.establishes_containing_block() { return; } let new_containing_block = - ContainingBlock::new(padding_rect, builder.current_space_and_clip, &self.children); + ContainingBlock::new(padding_rect, builder.current_space_and_clip); if self .style @@ -427,12 +413,12 @@ impl BoxFragment { } } - fn build_stacking_context_tree<'a>( - &'a self, - fragment: &'a Fragment, + fn build_stacking_context_tree( + &self, + fragment: &ArcRefCell<Fragment>, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, - stacking_context: &mut StackingContext<'a>, + containing_block_info: &ContainingBlockInfo, + stacking_context: &mut StackingContext, ) { builder.clipping_and_scrolling_scope(|builder| { self.adjust_spatial_id_for_positioning(builder); @@ -450,7 +436,7 @@ impl BoxFragment { }, }; - let mut child_stacking_context = StackingContext::new(self, context_type); + let mut child_stacking_context = StackingContext::new(self.style.clone(), context_type); self.build_stacking_context_tree_for_children( fragment, builder, @@ -478,10 +464,10 @@ impl BoxFragment { fn build_stacking_context_tree_for_children<'a>( &'a self, - fragment: &'a Fragment, + fragment: &ArcRefCell<Fragment>, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, - stacking_context: &mut StackingContext<'a>, + containing_block_info: &ContainingBlockInfo, + stacking_context: &mut StackingContext, ) { let relative_border_rect = self .border_rect() @@ -506,7 +492,7 @@ impl BoxFragment { space_and_clip: builder.current_space_and_clip, section: self.get_stacking_context_section(), containing_block: new_containing_block_info.rect, - fragment, + fragment: fragment.clone(), }); // We want to build the scroll frame after the background and border, because @@ -528,7 +514,8 @@ impl BoxFragment { self.build_containing_block(builder, &padding_rect, &mut new_containing_block_info); for child in &self.children { - child.build_stacking_context_tree( + child.borrow().build_stacking_context_tree( + child, builder, &new_containing_block_info, stacking_context, @@ -551,7 +538,7 @@ impl BoxFragment { fn build_scroll_frame_if_necessary<'a>( &self, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, + containing_block_info: &ContainingBlockInfo, ) { let overflow_x = self.style.get_box().overflow_x; let overflow_y = self.style.get_box().overflow_y; @@ -580,7 +567,8 @@ impl BoxFragment { builder.current_space_and_clip = builder.wr.define_scroll_frame( &original_scroll_and_clip_info, Some(external_id), - self.scrollable_overflow().to_webrender(), + self.scrollable_overflow(&containing_block_info.rect) + .to_webrender(), padding_rect, vec![], // complex_clips None, // image_mask @@ -715,11 +703,11 @@ impl BoxFragment { } impl AnonymousFragment { - fn build_stacking_context_tree<'a>( - &'a self, + fn build_stacking_context_tree( + &self, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, - stacking_context: &mut StackingContext<'a>, + containing_block_info: &ContainingBlockInfo, + stacking_context: &mut StackingContext, ) { let mut new_containing_block_info = containing_block_info.clone(); new_containing_block_info.rect = self @@ -727,7 +715,8 @@ impl AnonymousFragment { .to_physical(self.mode, &containing_block_info.rect) .translate(containing_block_info.rect.origin.to_vector()); for child in &self.children { - child.build_stacking_context_tree( + child.borrow().build_stacking_context_tree( + child, builder, &new_containing_block_info, stacking_context, @@ -738,42 +727,42 @@ impl AnonymousFragment { } impl AbsoluteOrFixedPositionedFragment { - fn build_stacking_context_tree<'a>( - &'a self, + fn build_stacking_context_tree( + &self, builder: &mut StackingContextBuilder, - containing_block_info: &ContainingBlockInfo<'a>, - stacking_context: &mut StackingContext<'a>, + containing_block_info: &ContainingBlockInfo, + stacking_context: &mut StackingContext, ) { - let mut build_for_containing_block = |containing_block: &ContainingBlock<'a>| { - let hoisted_child = match containing_block.hoisted_children.get(&self.0) { - Some(hoisted_child) => hoisted_child, - None => return false, - }; - - builder.clipping_and_scrolling_scope(|builder| { - let mut new_containing_block_info = containing_block_info.clone(); - new_containing_block_info.rect = containing_block.rect; - builder.current_space_and_clip = containing_block.space_and_clip; - hoisted_child.build_stacking_context_tree( - builder, - &new_containing_block_info, - stacking_context, - StackingContextBuildMode::IncludeHoisted, - ); - }); + let hoisted_fragment = self.hoisted_fragment.borrow(); + let fragment_ref = match hoisted_fragment.as_ref() { + Some(fragment_ref) => fragment_ref, + None => unreachable!("Found hoisted box with missing fragment."), + }; - return true; + let containing_block = match self.position { + ComputedPosition::Fixed => &containing_block_info.containing_block_for_all_descendants, + ComputedPosition::Absolute => containing_block_info + .nearest_containing_block + .as_ref() + .unwrap_or(&containing_block_info.containing_block_for_all_descendants), + ComputedPosition::Static | ComputedPosition::Relative => unreachable!( + "Found an AbsoluteOrFixedPositionedFragment for a \ + non-absolutely or fixed position fragment." + ), }; - if let Some(containing_block) = containing_block_info.nearest_containing_block.as_ref() { - if build_for_containing_block(containing_block) { - return; - } - } + builder.clipping_and_scrolling_scope(|builder| { + let mut new_containing_block_info = containing_block_info.clone(); + new_containing_block_info.rect = containing_block.rect; + builder.current_space_and_clip = containing_block.space_and_clip; - if !build_for_containing_block(&containing_block_info.containing_block_for_all_descendants) - { - warn!("Could not find containing block of hoisted positioned child!"); - } + fragment_ref.borrow().build_stacking_context_tree( + fragment_ref, + builder, + &new_containing_block_info, + stacking_context, + StackingContextBuildMode::IncludeHoisted, + ); + }); } } diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs index 1a3a969919c..020282f50ff 100644 --- a/components/layout_2020/dom_traversal.rs +++ b/components/layout_2020/dom_traversal.rs @@ -2,13 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::element_data::{LayoutBox, LayoutDataForElement}; use crate::geom::PhysicalSize; use crate::replaced::{CanvasInfo, CanvasSource, ReplacedContent}; use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside}; use crate::wrapper::GetRawData; -use atomic_refcell::{AtomicRefCell, AtomicRefMut}; +use atomic_refcell::AtomicRefMut; use html5ever::LocalName; use net_traits::image::base::Image as NetImage; use script_layout_interface::wrapper_traits::{ @@ -317,12 +318,12 @@ where } pub struct BoxSlot<'dom> { - slot: Option<ServoArc<AtomicRefCell<Option<LayoutBox>>>>, + slot: Option<ArcRefCell<Option<LayoutBox>>>, marker: marker<&'dom ()>, } impl BoxSlot<'_> { - pub(crate) fn new(slot: ServoArc<AtomicRefCell<Option<LayoutBox>>>) -> Self { + pub(crate) fn new(slot: ArcRefCell<Option<LayoutBox>>) -> Self { *slot.borrow_mut() = None; let slot = Some(slot); Self { slot, marker } @@ -348,7 +349,7 @@ impl Drop for BoxSlot<'_> { } } -pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync { +pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode<'dom> + Send + Sync { fn is_element(self) -> bool; fn as_text(self) -> Option<String>; @@ -371,7 +372,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync { impl<'dom, T> NodeExt<'dom> for T where - T: 'dom + Copy + LayoutNode + Send + Sync, + T: 'dom + Copy + LayoutNode<'dom> + Send + Sync, { fn is_element(self) -> bool { self.to_threadsafe().as_element().is_some() diff --git a/components/layout_2020/element_data.rs b/components/layout_2020/element_data.rs index ccd48ac04e3..7385b7d84f0 100644 --- a/components/layout_2020/element_data.rs +++ b/components/layout_2020/element_data.rs @@ -2,25 +2,24 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::flow::inline::InlineLevelBox; use crate::flow::BlockLevelBox; -use atomic_refcell::AtomicRefCell; -use servo_arc::Arc; #[derive(Default)] pub struct LayoutDataForElement { - pub(super) self_box: Arc<AtomicRefCell<Option<LayoutBox>>>, + pub(super) self_box: ArcRefCell<Option<LayoutBox>>, pub(super) pseudo_elements: Option<Box<PseudoElementBoxes>>, } #[derive(Default)] pub(super) struct PseudoElementBoxes { - pub before: Arc<AtomicRefCell<Option<LayoutBox>>>, - pub after: Arc<AtomicRefCell<Option<LayoutBox>>>, + pub before: ArcRefCell<Option<LayoutBox>>, + pub after: ArcRefCell<Option<LayoutBox>>, } pub(super) enum LayoutBox { DisplayContents, - BlockLevel(Arc<BlockLevelBox>), - InlineLevel(Arc<InlineLevelBox>), + BlockLevel(ArcRefCell<BlockLevelBox>), + InlineLevel(ArcRefCell<InlineLevelBox>), } diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index cff3fa281a6..fe9465f775e 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom_traversal::{BoxSlot, Contents, NodeExt, NonReplacedContents, TraversalHandler}; use crate::element_data::LayoutBox; @@ -18,6 +19,7 @@ use servo_arc::Arc; use std::convert::{TryFrom, TryInto}; use style::properties::ComputedValues; use style::selector_parser::PseudoElement; +use style::values::specified::text::TextDecorationLine; impl BlockFormattingContext { pub fn construct<'dom>( @@ -26,9 +28,16 @@ impl BlockFormattingContext { style: &Arc<ComputedValues>, contents: NonReplacedContents, content_sizes: ContentSizesRequest, + propagated_text_decoration_line: TextDecorationLine, ) -> (Self, BoxContentSizes) { - let (contents, contains_floats, inline_content_sizes) = - BlockContainer::construct(context, node, style, contents, content_sizes); + let (contents, contains_floats, inline_content_sizes) = BlockContainer::construct( + context, + node, + style, + contents, + content_sizes, + propagated_text_decoration_line, + ); // FIXME: add contribution to `inline_content_sizes` of floats in this formatting context // https://dbaron.org/css/intrinsic/#intrinsic let bfc = Self { @@ -51,6 +60,7 @@ enum BlockLevelCreator { Independent { display_inside: DisplayInside, contents: Contents, + propagated_text_decoration_line: TextDecorationLine, }, OutOfFlowAbsolutelyPositionedBox { display_inside: DisplayInside, @@ -71,7 +81,7 @@ enum BlockLevelCreator { /// Deferring allows using rayon’s `into_par_iter`. enum IntermediateBlockContainer { InlineFormattingContext(InlineFormattingContext), - Deferred(NonReplacedContents), + Deferred(NonReplacedContents, TextDecorationLine), } /// A builder for a block container. @@ -139,13 +149,16 @@ impl BlockContainer { block_container_style: &Arc<ComputedValues>, contents: NonReplacedContents, content_sizes: ContentSizesRequest, + propagated_text_decoration_line: TextDecorationLine, ) -> (BlockContainer, ContainsFloats, BoxContentSizes) { + let text_decoration_line = + propagated_text_decoration_line | block_container_style.clone_text_decoration_line(); let mut builder = BlockContainerBuilder { context, root, block_container_style, block_level_boxes: Vec::new(), - ongoing_inline_formatting_context: InlineFormattingContext::default(), + ongoing_inline_formatting_context: InlineFormattingContext::new(text_decoration_line), ongoing_inline_boxes_stack: Vec::new(), anonymous_style: None, contains_floats: ContainsFloats::No, @@ -282,54 +295,48 @@ where // context with the parent style of that builder. let inlines = self.current_inline_level_boxes(); - fn last_text(inlines: &mut [Arc<InlineLevelBox>]) -> Option<&mut String> { - let last = inlines.last_mut()?; - if let InlineLevelBox::TextRun(_) = &**last { - // We never clone text run boxes, so the refcount is 1 and unwrap succeeds: - let last = Arc::get_mut(last).unwrap(); - if let InlineLevelBox::TextRun(TextRun { text, .. }) = last { - Some(text) - } else { - unreachable!() - } - } else { - None - } - } - let mut new_text_run_contents; let output; - if let Some(text) = last_text(inlines) { - // Append to the existing text run - new_text_run_contents = None; - output = text; - } else { - new_text_run_contents = Some(String::new()); - output = new_text_run_contents.as_mut().unwrap(); - } - if leading_whitespace { - output.push(' ') - } - loop { - if let Some(i) = input.bytes().position(|b| b.is_ascii_whitespace()) { - let (non_whitespace, rest) = input.split_at(i); - output.push_str(non_whitespace); - output.push(' '); - if let Some(i) = rest.bytes().position(|b| !b.is_ascii_whitespace()) { - input = &rest[i..]; + { + let mut last_box = inlines.last_mut().map(|last| last.borrow_mut()); + let last_text = last_box.as_mut().and_then(|last| match &mut **last { + InlineLevelBox::TextRun(last) => Some(&mut last.text), + _ => None, + }); + + if let Some(text) = last_text { + // Append to the existing text run + new_text_run_contents = None; + output = text; + } else { + new_text_run_contents = Some(String::new()); + output = new_text_run_contents.as_mut().unwrap(); + } + + if leading_whitespace { + output.push(' ') + } + loop { + if let Some(i) = input.bytes().position(|b| b.is_ascii_whitespace()) { + let (non_whitespace, rest) = input.split_at(i); + output.push_str(non_whitespace); + output.push(' '); + if let Some(i) = rest.bytes().position(|b| !b.is_ascii_whitespace()) { + input = &rest[i..]; + } else { + break; + } } else { + output.push_str(input); break; } - } else { - output.push_str(input); - break; } } if let Some(text) = new_text_run_contents { let parent_style = parent_style.clone(); - inlines.push(Arc::new(InlineLevelBox::TextRun(TextRun { + inlines.push(ArcRefCell::new(InlineLevelBox::TextRun(TextRun { tag: node.as_opaque(), parent_style, text, @@ -353,29 +360,53 @@ where if !text.starts_with(|c: char| c.is_ascii_whitespace()) { return (false, text); } - let mut inline_level_boxes = self.current_inline_level_boxes().iter().rev(); - let mut stack = Vec::new(); - let preserved = loop { - match inline_level_boxes.next().map(|b| &**b) { - Some(InlineLevelBox::TextRun(r)) => break !r.text.ends_with(' '), - Some(InlineLevelBox::Atomic { .. }) => break false, - Some(InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(_)) | - Some(InlineLevelBox::OutOfFlowFloatBox(_)) => {}, - Some(InlineLevelBox::InlineBox(b)) => { - stack.push(inline_level_boxes); - inline_level_boxes = b.children.iter().rev() - }, - None => { - if let Some(iter) = stack.pop() { - inline_level_boxes = iter - } else { - break false; // Paragraph start - } - }, - } + + let preserved = match whitespace_is_preserved(self.current_inline_level_boxes()) { + WhitespacePreservedResult::Unknown => { + // Paragraph start. + false + }, + WhitespacePreservedResult::NotPreserved => false, + WhitespacePreservedResult::Preserved => true, }; + let text = text.trim_start_matches(|c: char| c.is_ascii_whitespace()); - (preserved, text) + return (preserved, text); + + fn whitespace_is_preserved( + inline_level_boxes: &[ArcRefCell<InlineLevelBox>], + ) -> WhitespacePreservedResult { + for inline_level_box in inline_level_boxes.iter().rev() { + match *inline_level_box.borrow() { + InlineLevelBox::TextRun(ref r) => { + if r.text.ends_with(' ') { + return WhitespacePreservedResult::NotPreserved; + } + return WhitespacePreservedResult::Preserved; + }, + InlineLevelBox::Atomic { .. } => { + return WhitespacePreservedResult::NotPreserved; + }, + InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(_) | + InlineLevelBox::OutOfFlowFloatBox(_) => {}, + InlineLevelBox::InlineBox(ref b) => { + match whitespace_is_preserved(&b.children) { + WhitespacePreservedResult::Unknown => {}, + result => return result, + } + }, + } + } + + WhitespacePreservedResult::Unknown + } + + #[derive(Clone, Copy, PartialEq)] + enum WhitespacePreservedResult { + Preserved, + NotPreserved, + Unknown, + } } fn handle_inline_level_element( @@ -384,7 +415,7 @@ where style: &Arc<ComputedValues>, display_inside: DisplayInside, contents: Contents, - ) -> Arc<InlineLevelBox> { + ) -> ArcRefCell<InlineLevelBox> { let box_ = if display_inside == DisplayInside::Flow && !contents.is_replaced() { // We found un inline box. // Whatever happened before, all we need to do before recurring @@ -410,9 +441,9 @@ where .pop() .expect("no ongoing inline level box found"); inline_box.last_fragment = true; - Arc::new(InlineLevelBox::InlineBox(inline_box)) + ArcRefCell::new(InlineLevelBox::InlineBox(inline_box)) } else { - Arc::new(InlineLevelBox::Atomic( + ArcRefCell::new(InlineLevelBox::Atomic( IndependentFormattingContext::construct( self.context, node, @@ -420,6 +451,8 @@ where display_inside, contents, ContentSizesRequest::inline_if(!style.inline_size_is_length()), + // Text decorations are not propagated to atomic inline-level descendants. + TextDecorationLine::NONE, ), )) }; @@ -466,15 +499,18 @@ where for mut fragmented_parent_inline_box in fragmented_inline_boxes { fragmented_parent_inline_box .children - .push(Arc::new(fragmented_inline)); + .push(ArcRefCell::new(fragmented_inline)); fragmented_inline = InlineLevelBox::InlineBox(fragmented_parent_inline_box); } self.ongoing_inline_formatting_context .inline_level_boxes - .push(Arc::new(fragmented_inline)); + .push(ArcRefCell::new(fragmented_inline)); } + let propagated_text_decoration_line = + self.ongoing_inline_formatting_context.text_decoration_line; + // We found a block level element, so the ongoing inline formatting // context needs to be ended. self.end_ongoing_inline_formatting_context(); @@ -482,11 +518,12 @@ where let kind = match contents.try_into() { Ok(contents) => match display_inside { DisplayInside::Flow => BlockLevelCreator::SameFormattingContextBlock( - IntermediateBlockContainer::Deferred(contents), + IntermediateBlockContainer::Deferred(contents, propagated_text_decoration_line), ), _ => BlockLevelCreator::Independent { display_inside, contents: contents.into(), + propagated_text_decoration_line, }, }, Err(contents) => { @@ -494,6 +531,7 @@ where BlockLevelCreator::Independent { display_inside, contents, + propagated_text_decoration_line, } }, }; @@ -525,7 +563,7 @@ where kind, }); } else { - let box_ = Arc::new(InlineLevelBox::OutOfFlowAbsolutelyPositionedBox( + let box_ = ArcRefCell::new(InlineLevelBox::OutOfFlowAbsolutelyPositionedBox(Arc::new( AbsolutelyPositionedBox::construct( self.context, node, @@ -533,7 +571,7 @@ where display_inside, contents, ), - )); + ))); self.current_inline_level_boxes().push(box_.clone()); box_slot.set(LayoutBox::InlineLevel(box_)) } @@ -561,7 +599,7 @@ where kind, }); } else { - let box_ = Arc::new(InlineLevelBox::OutOfFlowFloatBox(FloatBox::construct( + let box_ = ArcRefCell::new(InlineLevelBox::OutOfFlowFloatBox(FloatBox::construct( self.context, node, style, @@ -610,7 +648,7 @@ where }); } - fn current_inline_level_boxes(&mut self) -> &mut Vec<Arc<InlineLevelBox>> { + fn current_inline_level_boxes(&mut self) -> &mut Vec<ArcRefCell<InlineLevelBox>> { match self.ongoing_inline_boxes_stack.last_mut() { Some(last) => &mut last.children, None => &mut self.ongoing_inline_formatting_context.inline_level_boxes, @@ -634,7 +672,7 @@ where self, context: &LayoutContext, max_assign_in_flow_outer_content_sizes_to: Option<&mut ContentSizes>, - ) -> (Arc<BlockLevelBox>, ContainsFloats) { + ) -> (ArcRefCell<BlockLevelBox>, ContainsFloats) { let node = self.node; let style = self.style; let (block_level_box, contains_floats) = match self.kind { @@ -651,7 +689,7 @@ where if let Some(to) = max_assign_in_flow_outer_content_sizes_to { to.max_assign(&box_content_sizes.outer_inline(&style)) } - let block_level_box = Arc::new(BlockLevelBox::SameFormattingContextBlock { + let block_level_box = ArcRefCell::new(BlockLevelBox::SameFormattingContextBlock { tag: node.as_opaque(), contents, style, @@ -661,6 +699,7 @@ where BlockLevelCreator::Independent { display_inside, contents, + propagated_text_decoration_line, } => { let content_sizes = ContentSizesRequest::inline_if( max_assign_in_flow_outer_content_sizes_to.is_some() && @@ -673,12 +712,13 @@ where display_inside, contents, content_sizes, + propagated_text_decoration_line, ); if let Some(to) = max_assign_in_flow_outer_content_sizes_to { to.max_assign(&contents.content_sizes.outer_inline(&contents.style)) } ( - Arc::new(BlockLevelBox::Independent(contents)), + ArcRefCell::new(BlockLevelBox::Independent(contents)), ContainsFloats::No, ) }, @@ -686,22 +726,23 @@ where display_inside, contents, } => { - let block_level_box = Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox( - AbsolutelyPositionedBox::construct( - context, - node, - style, - display_inside, - contents, - ), - )); + let block_level_box = + ArcRefCell::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(Arc::new( + AbsolutelyPositionedBox::construct( + context, + node, + style, + display_inside, + contents, + ), + ))); (block_level_box, ContainsFloats::No) }, BlockLevelCreator::OutOfFlowFloatBox { display_inside, contents, } => { - let block_level_box = Arc::new(BlockLevelBox::OutOfFlowFloatBox( + let block_level_box = ArcRefCell::new(BlockLevelBox::OutOfFlowFloatBox( FloatBox::construct(context, node, style, display_inside, contents), )); (block_level_box, ContainsFloats::Yes) @@ -722,8 +763,15 @@ impl IntermediateBlockContainer { content_sizes: ContentSizesRequest, ) -> (BlockContainer, ContainsFloats, BoxContentSizes) { match self { - IntermediateBlockContainer::Deferred(contents) => { - BlockContainer::construct(context, node, style, contents, content_sizes) + IntermediateBlockContainer::Deferred(contents, propagated_text_decoration_line) => { + BlockContainer::construct( + context, + node, + style, + contents, + content_sizes, + propagated_text_decoration_line, + ) }, IntermediateBlockContainer::InlineFormattingContext(ifc) => { let content_sizes = content_sizes.compute(|| ifc.inline_content_sizes(context)); diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs index 5b34392ac8c..4a647f23071 100644 --- a/components/layout_2020/flow/float.rs +++ b/components/layout_2020/flow/float.rs @@ -9,6 +9,7 @@ use crate::sizing::ContentSizesRequest; use crate::style_ext::{ComputedValuesExt, DisplayInside}; use servo_arc::Arc; use style::properties::ComputedValues; +use style::values::specified::text::TextDecorationLine; #[derive(Debug, Serialize)] pub(crate) struct FloatBox { @@ -43,6 +44,8 @@ impl FloatBox { display_inside, contents, content_sizes, + // Text decorations are not propagated to any out-of-flow descendants + TextDecorationLine::NONE, ), } } diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index bd8f5bc784f..6588a6a3137 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -2,16 +2,20 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::flow::float::FloatBox; use crate::flow::FlowLayout; use crate::formatting_contexts::IndependentFormattingContext; use crate::fragments::{ AbsoluteOrFixedPositionedFragment, AnonymousFragment, BoxFragment, CollapsedBlockMargins, - DebugId, Fragment, TextFragment, + DebugId, FontMetrics, Fragment, TextFragment, }; use crate::geom::flow_relative::{Rect, Sides, Vec2}; -use crate::positioned::{relative_adjustement, AbsolutelyPositionedBox, PositioningContext}; +use crate::positioned::{ + relative_adjustement, AbsolutelyPositionedBox, HoistedAbsolutelyPositionedBox, + PositioningContext, +}; use crate::sizing::ContentSizes; use crate::style_ext::{ComputedValuesExt, Display, DisplayGeneratingBox, DisplayOutside}; use crate::ContainingBlock; @@ -22,19 +26,21 @@ use style::dom::OpaqueNode; use style::properties::ComputedValues; use style::values::computed::{Length, LengthPercentage, Percentage}; use style::values::specified::text::TextAlignKeyword; +use style::values::specified::text::TextDecorationLine; use style::Zero; use webrender_api::FontInstanceKey; #[derive(Debug, Default, Serialize)] pub(crate) struct InlineFormattingContext { - pub(super) inline_level_boxes: Vec<Arc<InlineLevelBox>>, + pub(super) inline_level_boxes: Vec<ArcRefCell<InlineLevelBox>>, + pub(super) text_decoration_line: TextDecorationLine, } #[derive(Debug, Serialize)] pub(crate) enum InlineLevelBox { InlineBox(InlineBox), TextRun(TextRun), - OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox), + OutOfFlowAbsolutelyPositionedBox(Arc<AbsolutelyPositionedBox>), OutOfFlowFloatBox(FloatBox), Atomic(IndependentFormattingContext), } @@ -46,7 +52,7 @@ pub(crate) struct InlineBox { pub style: Arc<ComputedValues>, pub first_fragment: bool, pub last_fragment: bool, - pub children: Vec<Arc<InlineLevelBox>>, + pub children: Vec<ArcRefCell<InlineLevelBox>>, } /// https://www.w3.org/TR/css-display-3/#css-text-run @@ -59,10 +65,16 @@ pub(crate) struct TextRun { } struct InlineNestingLevelState<'box_tree> { - remaining_boxes: std::slice::Iter<'box_tree, Arc<InlineLevelBox>>, + remaining_boxes: InlineBoxChildIter<'box_tree>, fragments_so_far: Vec<Fragment>, inline_start: Length, max_block_size_of_fragments_so_far: Length, + positioning_context: Option<PositioningContext>, + /// Indicates whether this nesting level have text decorations in effect. + /// From https://drafts.csswg.org/css-text-decor/#line-decoration + // "When specified on or propagated to a block container that establishes + // an IFC..." + text_decoration_line: TextDecorationLine, } struct PartialInlineBoxFragment<'box_tree> { @@ -77,7 +89,7 @@ struct PartialInlineBoxFragment<'box_tree> { } struct InlineFormattingContextState<'box_tree, 'a, 'b> { - positioning_context: &'a mut PositioningContext<'box_tree>, + positioning_context: &'a mut PositioningContext, containing_block: &'b ContainingBlock<'b>, lines: Lines, inline_position: Length, @@ -85,6 +97,31 @@ struct InlineFormattingContextState<'box_tree, 'a, 'b> { current_nesting_level: InlineNestingLevelState<'box_tree>, } +impl<'box_tree, 'a, 'b> InlineFormattingContextState<'box_tree, 'a, 'b> { + fn push_hoisted_box_to_positioning_context( + &mut self, + hoisted_box: HoistedAbsolutelyPositionedBox, + ) { + if let Some(context) = self.current_nesting_level.positioning_context.as_mut() { + context.push(hoisted_box); + return; + } + + for nesting_level in self.partial_inline_boxes_stack.iter_mut().rev() { + if let Some(context) = nesting_level + .parent_nesting_level + .positioning_context + .as_mut() + { + context.push(hoisted_box); + return; + } + } + + self.positioning_context.push(hoisted_box); + } +} + struct Lines { // One anonymous fragment per line fragments: Vec<Fragment>, @@ -92,6 +129,13 @@ struct Lines { } impl InlineFormattingContext { + pub(super) fn new(text_decoration_line: TextDecorationLine) -> InlineFormattingContext { + InlineFormattingContext { + inline_level_boxes: Default::default(), + text_decoration_line, + } + } + // This works on an already-constructed `InlineFormattingContext`, // Which would have to change if/when // `BlockContainer::construct` parallelize their construction. @@ -105,10 +149,10 @@ impl InlineFormattingContext { fn traverse( &mut self, layout_context: &LayoutContext, - inline_level_boxes: &[Arc<InlineLevelBox>], + inline_level_boxes: &[ArcRefCell<InlineLevelBox>], ) { for inline_level_box in inline_level_boxes { - match &**inline_level_box { + match &*inline_level_box.borrow() { InlineLevelBox::InlineBox(inline_box) => { let padding = inline_box.style.padding(); let border = inline_box.style.border_width(); @@ -204,10 +248,10 @@ impl InlineFormattingContext { computation.paragraph } - pub(super) fn layout<'a>( - &'a self, + pub(super) fn layout( + &self, layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tree_rank: usize, ) -> FlowLayout { @@ -221,17 +265,20 @@ impl InlineFormattingContext { }, inline_position: Length::zero(), current_nesting_level: InlineNestingLevelState { - remaining_boxes: self.inline_level_boxes.iter(), + remaining_boxes: InlineBoxChildIter::from_formatting_context(self), fragments_so_far: Vec::with_capacity(self.inline_level_boxes.len()), inline_start: Length::zero(), max_block_size_of_fragments_so_far: Length::zero(), + positioning_context: None, + text_decoration_line: self.text_decoration_line, }, }; + loop { if let Some(child) = ifc.current_nesting_level.remaining_boxes.next() { - match &**child { + match &*child.borrow() { InlineLevelBox::InlineBox(inline) => { - let partial = inline.start_layout(&mut ifc); + let partial = inline.start_layout(child.clone(), &mut ifc); ifc.partial_inline_boxes_stack.push(partial) }, InlineLevelBox::TextRun(run) => run.layout(layout_context, &mut ifc), @@ -256,14 +303,17 @@ impl InlineFormattingContext { panic!("display:none does not generate an abspos box") }, }; - let hoisted_fragment = box_.to_hoisted(initial_start_corner, tree_rank); - let hoisted_fragment_id = hoisted_fragment.fragment_id; - ifc.positioning_context.push(hoisted_fragment); - ifc.lines - .fragments - .push(Fragment::AbsoluteOrFixedPositioned( - AbsoluteOrFixedPositionedFragment(hoisted_fragment_id), - )); + let hoisted_box = box_.clone().to_hoisted(initial_start_corner, tree_rank); + let hoisted_fragment = hoisted_box.fragment.clone(); + ifc.push_hoisted_box_to_positioning_context(hoisted_box); + ifc.current_nesting_level.fragments_so_far.push( + Fragment::AbsoluteOrFixedPositioned( + AbsoluteOrFixedPositionedFragment { + hoisted_fragment, + position: box_.contents.style.clone_position(), + }, + ), + ); }, InlineLevelBox::OutOfFlowFloatBox(_box_) => { // TODO @@ -273,6 +323,7 @@ impl InlineFormattingContext { // Reached the end of ifc.remaining_boxes if let Some(mut partial) = ifc.partial_inline_boxes_stack.pop() { partial.finish_layout( + layout_context, &mut ifc.current_nesting_level, &mut ifc.inline_position, false, @@ -353,6 +404,7 @@ impl Lines { block: line_block_size, }; self.next_line_block_position += size.block; + self.fragments .push(Fragment::Anonymous(AnonymousFragment::new( Rect { start_corner, size }, @@ -364,7 +416,8 @@ impl Lines { impl InlineBox { fn start_layout<'box_tree>( - &'box_tree self, + &self, + this_inline_level_box: ArcRefCell<InlineLevelBox>, ifc: &mut InlineFormattingContextState<'box_tree, '_, '_>, ) -> PartialInlineBoxFragment<'box_tree> { let style = self.style.clone(); @@ -389,6 +442,9 @@ impl InlineBox { if style.clone_position().is_relative() { start_corner += &relative_adjustement(&style, ifc.containing_block) } + let positioning_context = PositioningContext::new_for_style(&style); + let text_decoration_line = + ifc.current_nesting_level.text_decoration_line | style.clone_text_decoration_line(); PartialInlineBoxFragment { tag: self.tag, style, @@ -400,10 +456,14 @@ impl InlineBox { parent_nesting_level: std::mem::replace( &mut ifc.current_nesting_level, InlineNestingLevelState { - remaining_boxes: self.children.iter(), + remaining_boxes: InlineBoxChildIter::from_inline_level_box( + this_inline_level_box, + ), fragments_so_far: Vec::with_capacity(self.children.len()), inline_start: ifc.inline_position, max_block_size_of_fragments_so_far: Length::zero(), + positioning_context, + text_decoration_line: text_decoration_line, }, ), } @@ -413,6 +473,7 @@ impl InlineBox { impl<'box_tree> PartialInlineBoxFragment<'box_tree> { fn finish_layout( &mut self, + layout_context: &LayoutContext, nesting_level: &mut InlineNestingLevelState, inline_position: &mut Length, at_line_break: bool, @@ -434,7 +495,6 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> { self.border.clone(), self.margin.clone(), CollapsedBlockMargins::zero(), - None, // hoisted_fragment_id ); let last_fragment = self.last_box_tree_fragment && !at_line_break; if last_fragment { @@ -454,16 +514,21 @@ impl<'box_tree> PartialInlineBoxFragment<'box_tree> { fragment.border.block_sum() + fragment.margin.block_sum(), ); + + if let Some(context) = nesting_level.positioning_context.as_mut() { + context.layout_collected_children(layout_context, &mut fragment); + } + self.parent_nesting_level .fragments_so_far .push(Fragment::Box(fragment)); } } -fn layout_atomic<'box_tree>( +fn layout_atomic( layout_context: &LayoutContext, - ifc: &mut InlineFormattingContextState<'box_tree, '_, '_>, - atomic: &'box_tree IndependentFormattingContext, + ifc: &mut InlineFormattingContextState, + atomic: &IndependentFormattingContext, ) { let cbis = ifc.containing_block.inline_size; let padding = atomic.style.padding().percentages_relative_to(cbis); @@ -497,7 +562,6 @@ fn layout_atomic<'box_tree>( border, margin, CollapsedBlockMargins::zero(), - None, // hoisted_fragment_id ) }, Err(non_replaced) => { @@ -573,7 +637,6 @@ fn layout_atomic<'box_tree>( border, margin, CollapsedBlockMargins::zero(), - None, // hoisted_fragment_id ) }, }; @@ -588,8 +651,7 @@ fn layout_atomic<'box_tree>( } struct BreakAndShapeResult { - font_ascent: Au, - font_line_gap: Au, + font_metrics: FontMetrics, font_key: FontInstanceKey, runs: Vec<GlyphRun>, break_at_start: bool, @@ -656,8 +718,7 @@ impl TextRun { ); BreakAndShapeResult { - font_ascent: font.metrics.ascent, - font_line_gap: font.metrics.line_gap, + font_metrics: (&font.metrics).into(), font_key: font.font_key, runs, break_at_start, @@ -669,8 +730,7 @@ impl TextRun { use style::values::generics::text::LineHeight; let BreakAndShapeResult { - font_ascent, - font_line_gap, + font_metrics, font_key, runs, break_at_start: _, @@ -707,7 +767,7 @@ impl TextRun { } } let line_height = match self.parent_style.get_inherited_text().line_height { - LineHeight::Normal => font_line_gap.into(), + LineHeight::Normal => font_metrics.line_gap, LineHeight::Number(n) => font_size * n.0, LineHeight::Length(l) => l.0, }; @@ -732,9 +792,10 @@ impl TextRun { debug_id: DebugId::new(), parent_style: self.parent_style.clone(), rect, - ascent: font_ascent.into(), + font_metrics, font_key, glyphs, + text_decoration_line: ifc.current_nesting_level.text_decoration_line, })); if runs.is_empty() { break; @@ -743,7 +804,12 @@ impl TextRun { ifc.current_nesting_level.inline_start = Length::zero(); let mut nesting_level = &mut ifc.current_nesting_level; for partial in ifc.partial_inline_boxes_stack.iter_mut().rev() { - partial.finish_layout(nesting_level, &mut ifc.inline_position, true); + partial.finish_layout( + layout_context, + nesting_level, + &mut ifc.inline_position, + true, + ); partial.start_corner.inline = Length::zero(); partial.padding.inline_start = Length::zero(); partial.border.inline_start = Length::zero(); @@ -758,3 +824,54 @@ impl TextRun { } } } + +enum InlineBoxChildIter<'box_tree> { + InlineFormattingContext(std::slice::Iter<'box_tree, ArcRefCell<InlineLevelBox>>), + InlineBox { + inline_level_box: ArcRefCell<InlineLevelBox>, + child_index: usize, + }, +} + +impl<'box_tree> InlineBoxChildIter<'box_tree> { + fn from_formatting_context( + inline_formatting_context: &'box_tree InlineFormattingContext, + ) -> InlineBoxChildIter<'box_tree> { + InlineBoxChildIter::InlineFormattingContext( + inline_formatting_context.inline_level_boxes.iter(), + ) + } + + fn from_inline_level_box( + inline_level_box: ArcRefCell<InlineLevelBox>, + ) -> InlineBoxChildIter<'box_tree> { + InlineBoxChildIter::InlineBox { + inline_level_box, + child_index: 0, + } + } +} + +impl<'box_tree> Iterator for InlineBoxChildIter<'box_tree> { + type Item = ArcRefCell<InlineLevelBox>; + fn next(&mut self) -> Option<ArcRefCell<InlineLevelBox>> { + match *self { + InlineBoxChildIter::InlineFormattingContext(ref mut iter) => iter.next().cloned(), + InlineBoxChildIter::InlineBox { + ref inline_level_box, + ref mut child_index, + } => match *inline_level_box.borrow() { + InlineLevelBox::InlineBox(ref inline_box) => { + if *child_index >= inline_box.children.len() { + return None; + } + + let kid = inline_box.children[*child_index].clone(); + *child_index += 1; + Some(kid) + }, + _ => unreachable!(), + }, + } + } +} diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs index e15947f52b0..dcf2f9c4de3 100644 --- a/components/layout_2020/flow/mod.rs +++ b/components/layout_2020/flow/mod.rs @@ -4,6 +4,7 @@ //! Flow layout, also known as block-and-inline layout. +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::flow::float::{FloatBox, FloatContext}; use crate::flow::inline::InlineFormattingContext; @@ -38,7 +39,7 @@ pub(crate) struct BlockFormattingContext { #[derive(Debug, Serialize)] pub(crate) enum BlockContainer { - BlockLevelBoxes(Vec<Arc<BlockLevelBox>>), + BlockLevelBoxes(Vec<ArcRefCell<BlockLevelBox>>), InlineFormattingContext(InlineFormattingContext), } @@ -50,7 +51,7 @@ pub(crate) enum BlockLevelBox { style: Arc<ComputedValues>, contents: BlockContainer, }, - OutOfFlowAbsolutelyPositionedBox(AbsolutelyPositionedBox), + OutOfFlowAbsolutelyPositionedBox(Arc<AbsolutelyPositionedBox>), OutOfFlowFloatBox(FloatBox), Independent(IndependentFormattingContext), } @@ -65,10 +66,10 @@ struct FlowLayout { struct CollapsibleWithParentStartMargin(bool); impl BlockFormattingContext { - pub(super) fn layout<'a>( - &'a self, + pub(super) fn layout( + &self, layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tree_rank: usize, ) -> IndependentLayout { @@ -101,10 +102,10 @@ impl BlockFormattingContext { } impl BlockContainer { - fn layout<'a>( - &'a self, + fn layout( + &self, layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tree_rank: usize, float_context: Option<&mut FloatContext>, @@ -130,10 +131,10 @@ impl BlockContainer { } } -fn layout_block_level_children<'a>( +fn layout_block_level_children( layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, - child_boxes: &'a [Arc<BlockLevelBox>], + positioning_context: &mut PositioningContext, + child_boxes: &[ArcRefCell<BlockLevelBox>], containing_block: &ContainingBlock, tree_rank: usize, mut float_context: Option<&mut FloatContext>, @@ -204,7 +205,7 @@ fn layout_block_level_children<'a>( .iter() .enumerate() .map(|(tree_rank, box_)| { - let mut fragment = box_.layout( + let mut fragment = box_.borrow().layout( layout_context, positioning_context, containing_block, @@ -224,7 +225,7 @@ fn layout_block_level_children<'a>( .mapfold_reduce_into( positioning_context, |positioning_context, (tree_rank, box_)| { - box_.layout( + box_.borrow().layout( layout_context, positioning_context, containing_block, @@ -256,10 +257,10 @@ fn layout_block_level_children<'a>( } impl BlockLevelBox { - fn layout<'a>( - &'a self, + fn layout( + &self, layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tree_rank: usize, float_context: Option<&mut FloatContext>, @@ -314,12 +315,13 @@ impl BlockLevelBox { )) }, BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(box_) => { - let hoisted_fragment = box_.to_hoisted(Vec2::zero(), tree_rank); - let hoisted_fragment_id = hoisted_fragment.fragment_id.clone(); - positioning_context.push(hoisted_fragment); - Fragment::AbsoluteOrFixedPositioned(AbsoluteOrFixedPositionedFragment( - hoisted_fragment_id, - )) + let hoisted_box = box_.clone().to_hoisted(Vec2::zero(), tree_rank); + let hoisted_fragment = hoisted_box.fragment.clone(); + positioning_context.push(hoisted_box); + Fragment::AbsoluteOrFixedPositioned(AbsoluteOrFixedPositionedFragment { + hoisted_fragment, + position: box_.contents.style.clone_position(), + }) }, BlockLevelBox::OutOfFlowFloatBox(_box_) => { // FIXME: call layout_maybe_position_relative_fragment here @@ -338,13 +340,13 @@ enum NonReplacedContents<'a> { /// https://drafts.csswg.org/css2/visudet.html#blockwidth /// https://drafts.csswg.org/css2/visudet.html#normal-block -fn layout_in_flow_non_replaced_block_level<'a>( +fn layout_in_flow_non_replaced_block_level( layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tag: OpaqueNode, style: &Arc<ComputedValues>, - block_level_kind: NonReplacedContents<'a>, + block_level_kind: NonReplacedContents, tree_rank: usize, float_context: Option<&mut FloatContext>, ) -> BoxFragment { @@ -500,7 +502,6 @@ fn layout_in_flow_non_replaced_block_level<'a>( border, margin, block_margins_collapsed_with_children, - None, // hoisted_fragment_id ) } @@ -552,7 +553,6 @@ fn layout_in_flow_replaced_block_level<'a>( border, margin, block_margins_collapsed_with_children, - None, // hoisted_fragment_id ) } diff --git a/components/layout_2020/flow/root.rs b/components/layout_2020/flow/root.rs index 0b93701b01b..adbcb26d4c9 100644 --- a/components/layout_2020/flow/root.rs +++ b/components/layout_2020/flow/root.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::display_list::stacking_context::{ ContainingBlock, ContainingBlockInfo, StackingContext, StackingContextBuildMode, @@ -37,7 +38,7 @@ pub struct BoxTreeRoot(BlockFormattingContext); #[derive(Serialize)] pub struct FragmentTreeRoot { /// The children of the root of the fragment tree. - children: Vec<Fragment>, + children: Vec<ArcRefCell<Fragment>>, /// The scrollable overflow of the root of the fragment tree. scrollable_overflow: PhysicalRect<Length>, @@ -49,7 +50,7 @@ pub struct FragmentTreeRoot { impl BoxTreeRoot { pub fn construct<'dom, Node>(context: &LayoutContext, root_element: Node) -> Self where - Node: 'dom + Copy + LayoutNode + Send + Sync, + Node: 'dom + Copy + LayoutNode<'dom> + Send + Sync, { let (contains_floats, boxes) = construct_for_root_element(&context, root_element); Self(BlockFormattingContext { @@ -62,7 +63,7 @@ impl BoxTreeRoot { fn construct_for_root_element<'dom>( context: &LayoutContext, root_element: impl NodeExt<'dom>, -) -> (ContainsFloats, Vec<Arc<BlockLevelBox>>) { +) -> (ContainsFloats, Vec<ArcRefCell<BlockLevelBox>>) { let style = root_element.style(context); let replaced = ReplacedContent::for_element(root_element); let box_style = style.get_box(); @@ -83,27 +84,30 @@ fn construct_for_root_element<'dom>( if box_style.position.is_absolutely_positioned() { ( ContainsFloats::No, - vec![Arc::new(BlockLevelBox::OutOfFlowAbsolutelyPositionedBox( - AbsolutelyPositionedBox::construct( - context, - root_element, - style, - display_inside, - contents, - ), - ))], + vec![ArcRefCell::new( + BlockLevelBox::OutOfFlowAbsolutelyPositionedBox(Arc::new( + AbsolutelyPositionedBox::construct( + context, + root_element, + style, + display_inside, + contents, + ), + )), + )], ) } else if box_style.float.is_floating() { ( ContainsFloats::Yes, - vec![Arc::new(BlockLevelBox::OutOfFlowFloatBox( + vec![ArcRefCell::new(BlockLevelBox::OutOfFlowFloatBox( FloatBox::construct(context, root_element, style, display_inside, contents), ))], ) } else { + let propagated_text_decoration_line = style.clone_text_decoration_line(); ( ContainsFloats::No, - vec![Arc::new(BlockLevelBox::Independent( + vec![ArcRefCell::new(BlockLevelBox::Independent( IndependentFormattingContext::construct( context, root_element, @@ -111,6 +115,7 @@ fn construct_for_root_element<'dom>( display_inside, contents, ContentSizesRequest::None, + propagated_text_decoration_line, ), ))], ) @@ -142,44 +147,47 @@ impl BoxTreeRoot { let dummy_tree_rank = 0; let mut positioning_context = PositioningContext::new_for_containing_block_for_all_descendants(); - let mut independent_layout = self.0.layout( + let independent_layout = self.0.layout( layout_context, &mut positioning_context, &(&initial_containing_block).into(), dummy_tree_rank, ); + let mut children = independent_layout + .fragments + .into_iter() + .map(|fragment| ArcRefCell::new(fragment)) + .collect(); positioning_context.layout_initial_containing_block_children( layout_context, &initial_containing_block, - &mut independent_layout.fragments, + &mut children, ); - let scrollable_overflow = - independent_layout - .fragments - .iter() - .fold(PhysicalRect::zero(), |acc, child| { - let child_overflow = child.scrollable_overflow(); + let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| { + let child_overflow = child + .borrow() + .scrollable_overflow(&physical_containing_block); - // https://drafts.csswg.org/css-overflow/#scrolling-direction - // We want to clip scrollable overflow on box-start and inline-start - // sides of the scroll container. - // - // FIXME(mrobinson, bug 25564): This should take into account writing - // mode. - let child_overflow = PhysicalRect::new( - euclid::Point2D::zero(), - euclid::Size2D::new( - child_overflow.size.width + child_overflow.origin.x, - child_overflow.size.height + child_overflow.origin.y, - ), - ); - acc.union(&child_overflow) - }); + // https://drafts.csswg.org/css-overflow/#scrolling-direction + // We want to clip scrollable overflow on box-start and inline-start + // sides of the scroll container. + // + // FIXME(mrobinson, bug 25564): This should take into account writing + // mode. + let child_overflow = PhysicalRect::new( + euclid::Point2D::zero(), + euclid::Size2D::new( + child_overflow.size.width + child_overflow.origin.x, + child_overflow.size.height + child_overflow.origin.y, + ), + ); + acc.union(&child_overflow) + }); FragmentTreeRoot { - children: independent_layout.fragments, + children, scrollable_overflow, initial_containing_block: physical_containing_block, } @@ -197,12 +205,12 @@ impl FragmentTreeRoot { containing_block_for_all_descendants: ContainingBlock::new( &self.initial_containing_block, stacking_context_builder.current_space_and_clip, - &self.children, ), }; for fragment in &self.children { - fragment.build_stacking_context_tree( + fragment.borrow().build_stacking_context_tree( + fragment, &mut stacking_context_builder, &containing_block_info, &mut stacking_context, @@ -218,7 +226,7 @@ impl FragmentTreeRoot { pub fn print(&self) { let mut print_tree = PrintTree::new("Fragment Tree".to_string()); for fragment in &self.children { - fragment.print(&mut print_tree); + fragment.borrow().print(&mut print_tree); } } @@ -233,49 +241,11 @@ impl FragmentTreeRoot { &self, mut process_func: impl FnMut(&Fragment, &PhysicalRect<Length>) -> Option<T>, ) -> Option<T> { - fn recur<T>( - fragments: &[Fragment], - containing_block: &PhysicalRect<Length>, - process_func: &mut impl FnMut(&Fragment, &PhysicalRect<Length>) -> Option<T>, - ) -> Option<T> { - for fragment in fragments { - if let Some(result) = process_func(fragment, containing_block) { - return Some(result); - } - - match fragment { - Fragment::Box(fragment) => { - let new_containing_block = fragment - .content_rect - .to_physical(fragment.style.writing_mode, containing_block) - .translate(containing_block.origin.to_vector()); - if let Some(result) = - recur(&fragment.children, &new_containing_block, process_func) - { - return Some(result); - } - }, - Fragment::Anonymous(fragment) => { - let new_containing_block = fragment - .rect - .to_physical(fragment.mode, containing_block) - .translate(containing_block.origin.to_vector()); - if let Some(result) = - recur(&fragment.children, &new_containing_block, process_func) - { - return Some(result); - } - }, - _ => {}, - } - } - None - } - recur( - &self.children, - &self.initial_containing_block, - &mut process_func, - ) + self.children.iter().find_map(|child| { + child + .borrow() + .find(&self.initial_containing_block, &mut process_func) + }) } pub fn get_content_box_for_node(&self, requested_node: OpaqueNode) -> Rect<Au> { diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs index e4baf169476..9e73a17891e 100644 --- a/components/layout_2020/formatting_contexts.rs +++ b/components/layout_2020/formatting_contexts.rs @@ -16,6 +16,7 @@ use std::convert::TryInto; use style::dom::OpaqueNode; use style::properties::ComputedValues; use style::values::computed::Length; +use style::values::specified::text::TextDecorationLine; /// https://drafts.csswg.org/css-display/#independent-formatting-context #[derive(Debug, Serialize)] @@ -62,6 +63,7 @@ impl IndependentFormattingContext { display_inside: DisplayInside, contents: Contents, content_sizes: ContentSizesRequest, + propagated_text_decoration_line: TextDecorationLine, ) -> Self { match contents.try_into() { Ok(non_replaced) => match display_inside { @@ -72,6 +74,7 @@ impl IndependentFormattingContext { &style, non_replaced, content_sizes, + propagated_text_decoration_line, ); Self { tag: node.as_opaque(), @@ -104,11 +107,11 @@ impl IndependentFormattingContext { } } -impl<'a> NonReplacedIFC<'a> { +impl NonReplacedIFC<'_> { pub fn layout( &self, layout_context: &LayoutContext, - positioning_context: &mut PositioningContext<'a>, + positioning_context: &mut PositioningContext, containing_block: &ContainingBlock, tree_rank: usize, ) -> IndependentLayout { diff --git a/components/layout_2020/fragments.rs b/components/layout_2020/fragments.rs index 70c65dd470d..35c21e6dace 100644 --- a/components/layout_2020/fragments.rs +++ b/components/layout_2020/fragments.rs @@ -2,11 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::geom::flow_relative::{Rect, Sides}; use crate::geom::{PhysicalPoint, PhysicalRect}; #[cfg(debug_assertions)] use crate::layout_debug; -use crate::positioned::HoistedFragmentId; +use gfx::font::FontMetrics as GfxFontMetrics; use gfx::text::glyph::GlyphStore; use gfx_traits::print_tree::PrintTree; #[cfg(not(debug_assertions))] @@ -14,10 +15,12 @@ use serde::ser::{Serialize, Serializer}; use servo_arc::Arc as ServoArc; use std::sync::Arc; use style::computed_values::overflow_x::T as ComputedOverflow; +use style::computed_values::position::T as ComputedPosition; use style::dom::OpaqueNode; use style::logical_geometry::WritingMode; use style::properties::ComputedValues; use style::values::computed::Length; +use style::values::specified::text::TextDecorationLine; use style::Zero; use webrender_api::{FontInstanceKey, ImageKey}; @@ -31,7 +34,10 @@ pub(crate) enum Fragment { } #[derive(Serialize)] -pub(crate) struct AbsoluteOrFixedPositionedFragment(pub HoistedFragmentId); +pub(crate) struct AbsoluteOrFixedPositionedFragment { + pub position: ComputedPosition, + pub hoisted_fragment: ArcRefCell<Option<ArcRefCell<Fragment>>>, +} #[derive(Serialize)] pub(crate) struct BoxFragment { @@ -39,7 +45,7 @@ pub(crate) struct BoxFragment { pub debug_id: DebugId, #[serde(skip_serializing)] pub style: ServoArc<ComputedValues>, - pub children: Vec<Fragment>, + pub children: Vec<ArcRefCell<Fragment>>, /// From the containing block’s start corner…? /// This might be broken when the containing block is in a different writing mode: @@ -54,9 +60,6 @@ pub(crate) struct BoxFragment { /// The scrollable overflow of this box fragment. pub scrollable_overflow_from_children: PhysicalRect<Length>, - - /// XXX Add thsi - pub hoisted_fragment_id: Option<HoistedFragmentId>, } #[derive(Serialize)] @@ -77,13 +80,36 @@ pub(crate) struct CollapsedMargin { pub(crate) struct AnonymousFragment { pub debug_id: DebugId, pub rect: Rect<Length>, - pub children: Vec<Fragment>, + pub children: Vec<ArcRefCell<Fragment>>, pub mode: WritingMode, /// The scrollable overflow of this anonymous fragment's children. pub scrollable_overflow: PhysicalRect<Length>, } +#[derive(Clone, Copy, Serialize)] +pub(crate) struct FontMetrics { + pub ascent: Length, + pub line_gap: Length, + pub underline_offset: Length, + pub underline_size: Length, + pub strikeout_offset: Length, + pub strikeout_size: Length, +} + +impl From<&GfxFontMetrics> for FontMetrics { + fn from(metrics: &GfxFontMetrics) -> FontMetrics { + FontMetrics { + ascent: metrics.ascent.into(), + line_gap: metrics.line_gap.into(), + underline_offset: metrics.underline_offset.into(), + underline_size: metrics.underline_size.into(), + strikeout_offset: metrics.strikeout_offset.into(), + strikeout_size: metrics.strikeout_size.into(), + } + } +} + #[derive(Serialize)] pub(crate) struct TextFragment { pub debug_id: DebugId, @@ -91,10 +117,12 @@ pub(crate) struct TextFragment { #[serde(skip_serializing)] pub parent_style: ServoArc<ComputedValues>, pub rect: Rect<Length>, - pub ascent: Length, + pub font_metrics: FontMetrics, #[serde(skip_serializing)] pub font_key: FontInstanceKey, pub glyphs: Vec<Arc<GlyphStore>>, + /// A flag that represents the _used_ value of the text-decoration property. + pub text_decoration_line: TextDecorationLine, } #[derive(Serialize)] @@ -130,10 +158,10 @@ impl Fragment { } } - pub fn scrollable_overflow(&self) -> PhysicalRect<Length> { - // FIXME(mrobinson, bug 25564): We should be using the containing block - // here to properly convert scrollable overflow to physical geometry. - let containing_block = PhysicalRect::zero(); + pub fn scrollable_overflow( + &self, + containing_block: &PhysicalRect<Length>, + ) -> PhysicalRect<Length> { match self { Fragment::Box(fragment) => fragment.scrollable_overflow_for_parent(&containing_block), Fragment::AbsoluteOrFixedPositioned(_) => PhysicalRect::zero(), @@ -147,16 +175,36 @@ impl Fragment { } } - pub fn is_hoisted(&self) -> bool { - match self { - Fragment::Box(fragment) if fragment.hoisted_fragment_id.is_some() => true, - _ => false, + pub(crate) fn find<T>( + &self, + containing_block: &PhysicalRect<Length>, + process_func: &mut impl FnMut(&Fragment, &PhysicalRect<Length>) -> Option<T>, + ) -> Option<T> { + if let Some(result) = process_func(self, containing_block) { + return Some(result); } - } - pub fn hoisted_fragment_id(&self) -> Option<&HoistedFragmentId> { match self { - Fragment::Box(fragment) => fragment.hoisted_fragment_id.as_ref(), + Fragment::Box(fragment) => { + let new_containing_block = fragment + .content_rect + .to_physical(fragment.style.writing_mode, containing_block) + .translate(containing_block.origin.to_vector()); + fragment + .children + .iter() + .find_map(|child| child.borrow().find(&new_containing_block, process_func)) + }, + Fragment::Anonymous(fragment) => { + let new_containing_block = fragment + .rect + .to_physical(fragment.mode, containing_block) + .translate(containing_block.origin.to_vector()); + fragment + .children + .iter() + .find_map(|child| child.borrow().find(&new_containing_block, process_func)) + }, _ => None, } } @@ -164,7 +212,7 @@ impl Fragment { impl AbsoluteOrFixedPositionedFragment { pub fn print(&self, tree: &mut PrintTree) { - tree.add_item(format!("AbsoluteOrFixedPositionedFragment({:?})", self.0)); + tree.add_item(format!("AbsoluteOrFixedPositionedFragment")); } } @@ -180,18 +228,24 @@ impl AnonymousFragment { } pub fn new(rect: Rect<Length>, children: Vec<Fragment>, mode: WritingMode) -> Self { + // FIXME(mrobinson, bug 25564): We should be using the containing block + // here to properly convert scrollable overflow to physical geometry. + let containing_block = PhysicalRect::zero(); let content_origin = rect.start_corner.to_physical(mode); let scrollable_overflow = children.iter().fold(PhysicalRect::zero(), |acc, child| { acc.union( &child - .scrollable_overflow() + .scrollable_overflow(&containing_block) .translate(content_origin.to_vector()), ) }); AnonymousFragment { debug_id: DebugId::new(), rect, - children, + children: children + .into_iter() + .map(|fragment| ArcRefCell::new(fragment)) + .collect(), mode, scrollable_overflow, } @@ -206,7 +260,7 @@ impl AnonymousFragment { )); for child in &self.children { - child.print(tree); + child.borrow().print(tree); } tree.end_level(); } @@ -222,33 +276,38 @@ impl BoxFragment { border: Sides<Length>, margin: Sides<Length>, block_margins_collapsed_with_children: CollapsedBlockMargins, - hoisted_fragment_id: Option<HoistedFragmentId>, ) -> BoxFragment { + // FIXME(mrobinson, bug 25564): We should be using the containing block + // here to properly convert scrollable overflow to physical geometry. + let containing_block = PhysicalRect::zero(); let scrollable_overflow_from_children = children.iter().fold(PhysicalRect::zero(), |acc, child| { - acc.union(&child.scrollable_overflow()) + acc.union(&child.scrollable_overflow(&containing_block)) }); BoxFragment { tag, debug_id: DebugId::new(), style, - children, + children: children + .into_iter() + .map(|fragment| ArcRefCell::new(fragment)) + .collect(), content_rect, padding, border, margin, block_margins_collapsed_with_children, scrollable_overflow_from_children, - hoisted_fragment_id, } } - pub fn scrollable_overflow(&self) -> PhysicalRect<Length> { - // FIXME(mrobinson, bug 25564): We should be using the containing block - // here to properly convert scrollable overflow to physical geometry. + pub fn scrollable_overflow( + &self, + containing_block: &PhysicalRect<Length>, + ) -> PhysicalRect<Length> { let physical_padding_rect = self .padding_rect() - .to_physical(self.style.writing_mode, &PhysicalRect::zero()); + .to_physical(self.style.writing_mode, containing_block); let content_origin = self .content_rect @@ -277,20 +336,18 @@ impl BoxFragment { \nborder rect={:?}\ \nscrollable_overflow={:?}\ \noverflow={:?} / {:?}\ - \nstyle={:p}\ - \nhoisted_id={:?}", + \nstyle={:p}", self.content_rect, self.padding_rect(), self.border_rect(), - self.scrollable_overflow(), + self.scrollable_overflow(&PhysicalRect::zero()), self.style.get_box().overflow_x, self.style.get_box().overflow_y, self.style, - self.hoisted_fragment_id, )); for child in &self.children { - child.print(tree); + child.borrow().print(tree); } tree.end_level(); } @@ -311,7 +368,7 @@ impl BoxFragment { // https://www.w3.org/TR/css-overflow-3/#scrollable // Only include the scrollable overflow of a child box if it has overflow: visible. - let scrollable_overflow = self.scrollable_overflow(); + let scrollable_overflow = self.scrollable_overflow(&containing_block); let bottom_right = PhysicalPoint::new( overflow.max_x().max(scrollable_overflow.max_x()), overflow.max_y().max(scrollable_overflow.max_y()), diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index 610c5306f53..e34c6ba76ee 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -3,13 +3,13 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] +#![feature(arbitrary_self_types)] #![feature(exact_size_is_empty)] #[macro_use] -extern crate log; -#[macro_use] extern crate serde; +mod cell; pub mod context; pub mod data; pub mod display_list; diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index b40a3b8b1ab..2ca2376726a 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::cell::ArcRefCell; use crate::context::LayoutContext; use crate::dom_traversal::{Contents, NodeExt}; use crate::formatting_contexts::IndependentFormattingContext; @@ -13,42 +14,28 @@ use crate::{ContainingBlock, DefiniteContainingBlock}; use rayon::iter::{IntoParallelRefIterator, ParallelExtend}; use rayon_croissant::ParallelIteratorExt; use servo_arc::Arc; -use std::sync::atomic::{AtomicUsize, Ordering}; use style::computed_values::position::T as Position; use style::properties::ComputedValues; use style::values::computed::{Length, LengthOrAuto, LengthPercentage, LengthPercentageOrAuto}; +use style::values::specified::text::TextDecorationLine; use style::Zero; -static HOISTED_FRAGMENT_ID_COUNTER: AtomicUsize = AtomicUsize::new(0); - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize)] -pub(crate) struct HoistedFragmentId(u16); - -impl HoistedFragmentId { - pub fn new() -> HoistedFragmentId { - let new_id = HOISTED_FRAGMENT_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16; - HoistedFragmentId(new_id) - } -} - #[derive(Debug, Serialize)] pub(crate) struct AbsolutelyPositionedBox { pub contents: IndependentFormattingContext, } -pub(crate) struct PositioningContext<'box_tree> { - for_nearest_positioned_ancestor: Option<Vec<HoistedAbsolutelyPositionedBox<'box_tree>>>, +pub(crate) struct PositioningContext { + for_nearest_positioned_ancestor: Option<Vec<HoistedAbsolutelyPositionedBox>>, // For nearest `containing block for all descendants` as defined by the CSS transforms // spec. // https://www.w3.org/TR/css-transforms-1/#containing-block-for-all-descendants - for_nearest_containing_block_for_all_descendants: - Vec<HoistedAbsolutelyPositionedBox<'box_tree>>, + for_nearest_containing_block_for_all_descendants: Vec<HoistedAbsolutelyPositionedBox>, } -#[derive(Debug)] -pub(crate) struct HoistedAbsolutelyPositionedBox<'box_tree> { - absolutely_positioned_box: &'box_tree AbsolutelyPositionedBox, +pub(crate) struct HoistedAbsolutelyPositionedBox { + absolutely_positioned_box: Arc<AbsolutelyPositionedBox>, /// The rank of the child from which this absolutely positioned fragment /// came from, when doing the layout of a block container. Used to compute @@ -57,10 +44,10 @@ pub(crate) struct HoistedAbsolutelyPositionedBox<'box_tree> { box_offsets: Vec2<AbsoluteBoxOffsets>, - /// The id which is shared between this HoistedAbsolutelyPositionedBox and its - /// placeholder AbsoluteOrFixedPositionedFragment in its original tree position. + /// A reference to a Fragment which is shared between this `HoistedAbsolutelyPositionedBox` + /// and its placeholder `AbsoluteOrFixedPositionedFragment` in the original tree position. /// This will be used later in order to paint this hoisted box in tree order. - pub fragment_id: HoistedFragmentId, + pub fragment: ArcRefCell<Option<ArcRefCell<Fragment>>>, } #[derive(Clone, Debug)] @@ -105,12 +92,14 @@ impl AbsolutelyPositionedBox { display_inside, contents, content_sizes, + // Text decorations are not propagated to any out-of-flow descendants. + TextDecorationLine::NONE, ), } } pub(crate) fn to_hoisted( - &self, + self: Arc<Self>, initial_start_corner: Vec2<Length>, tree_rank: usize, ) -> HoistedAbsolutelyPositionedBox { @@ -145,12 +134,12 @@ impl AbsolutelyPositionedBox { box_offsets.block_end.clone(), ), }, - fragment_id: HoistedFragmentId::new(), + fragment: ArcRefCell::new(None), } } } -impl<'box_tree> PositioningContext<'box_tree> { +impl PositioningContext { pub(crate) fn new_for_containing_block_for_all_descendants() -> Self { Self { for_nearest_positioned_ancestor: None, @@ -173,6 +162,19 @@ impl<'box_tree> PositioningContext<'box_tree> { self.for_nearest_positioned_ancestor.is_some() } + pub(crate) fn new_for_style(style: &ComputedValues) -> Option<Self> { + if style.establishes_containing_block_for_all_descendants() { + Some(Self::new_for_containing_block_for_all_descendants()) + } else if style.establishes_containing_block() { + Some(Self { + for_nearest_positioned_ancestor: Some(Vec::new()), + for_nearest_containing_block_for_all_descendants: Vec::new(), + }) + } else { + None + } + } + /// Given `fragment_layout_fn`, a closure which lays out a fragment in a provided /// `PositioningContext`, create a new positioning context if necessary for the fragment and /// lay out the fragment and all its children. Returns the newly created `BoxFragment`. @@ -183,84 +185,59 @@ impl<'box_tree> PositioningContext<'box_tree> { style: &ComputedValues, fragment_layout_fn: impl FnOnce(&mut Self) -> BoxFragment, ) -> BoxFragment { - debug_assert!(style.clone_position() != Position::Fixed); - debug_assert!(style.clone_position() != Position::Absolute); + // Try to create a context, but if one isn't necessary, simply create the fragment + // using the given closure and the current `PositioningContext`. + let mut new_context = match Self::new_for_style(style) { + Some(new_context) => new_context, + None => return fragment_layout_fn(self), + }; - if style.establishes_containing_block_for_all_descendants() { - let mut fragment = Self::layout_containing_block_for_all_descendants( - layout_context, - fragment_layout_fn, - ); - if style.clone_position() == Position::Relative { - fragment.content_rect.start_corner += - &relative_adjustement(style, containing_block); - } - return fragment; - } + let mut new_fragment = fragment_layout_fn(&mut new_context); + new_context.layout_collected_children(layout_context, &mut new_fragment); + + // If the new context has any hoisted boxes for the nearest containing block for + // all descendants than collect them and pass them up the tree. + vec_append_owned( + &mut self.for_nearest_containing_block_for_all_descendants, + new_context.for_nearest_containing_block_for_all_descendants, + ); if style.clone_position() == Position::Relative { - let mut fragment = Self::create_and_layout_positioned( - layout_context, - style, - &mut self.for_nearest_containing_block_for_all_descendants, - fragment_layout_fn, - ); - fragment.content_rect.start_corner += &relative_adjustement(style, containing_block); - return fragment; + new_fragment.content_rect.start_corner += + &relative_adjustement(style, containing_block); } - // We don't need to create a new PositioningContext for this Fragment, so - // we pass in the current one to the fragment layout closure. - fragment_layout_fn(self) + new_fragment } /// Given `fragment_layout_fn`, a closure which lays out a fragment in a provided - /// `PositioningContext`, create a positioning context a positioned fragment and lay out the - /// fragment and all its children. Returns the resulting `BoxFragment`. + /// `PositioningContext`, create a positioning context for a positioned fragment and lay out + /// the fragment and all its children. Returns the resulting `BoxFragment`. fn create_and_layout_positioned( layout_context: &LayoutContext, style: &ComputedValues, - for_nearest_containing_block_for_all_descendants: &mut Vec< - HoistedAbsolutelyPositionedBox<'box_tree>, - >, + for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>, fragment_layout_fn: impl FnOnce(&mut Self) -> BoxFragment, ) -> BoxFragment { - if style.establishes_containing_block_for_all_descendants() { - return Self::layout_containing_block_for_all_descendants( - layout_context, - fragment_layout_fn, - ); - } - - let mut new = Self { - for_nearest_positioned_ancestor: Some(Vec::new()), - for_nearest_containing_block_for_all_descendants: std::mem::take( - for_nearest_containing_block_for_all_descendants, - ), + let mut new_context = match Self::new_for_style(style) { + Some(new_context) => new_context, + None => unreachable!(), }; - let mut positioned_box_fragment = fragment_layout_fn(&mut new); - new.layout_positioned_fragment_children(layout_context, &mut positioned_box_fragment); - *for_nearest_containing_block_for_all_descendants = - new.for_nearest_containing_block_for_all_descendants; - positioned_box_fragment + + let mut new_fragment = fragment_layout_fn(&mut new_context); + new_context.layout_collected_children(layout_context, &mut new_fragment); + for_nearest_containing_block_for_all_descendants + .extend(new_context.for_nearest_containing_block_for_all_descendants); + new_fragment } - /// Given `fragment_layout_fn`, a closure which lays out a fragment in a provided - /// `PositioningContext`, create a positioning context for a fragment that establishes a - /// containing block for all descendants and lay out the fragment and all its children using - /// the new positioning context. Returns the resulting `BoxFragment`. - fn layout_containing_block_for_all_descendants( + // Lay out the hoisted boxes collected into this `PositioningContext` and add them + // to the given `BoxFragment`. + pub fn layout_collected_children( + &mut self, layout_context: &LayoutContext, - fragment_layout_fn: impl FnOnce(&mut Self) -> BoxFragment, - ) -> BoxFragment { - let mut containing_block_for_all_descendants = - Self::new_for_containing_block_for_all_descendants(); - debug_assert!(containing_block_for_all_descendants - .for_nearest_positioned_ancestor - .is_none()); - - let mut new_fragment = fragment_layout_fn(&mut containing_block_for_all_descendants); - + new_fragment: &mut BoxFragment, + ) { let padding_rect = Rect { size: new_fragment.content_rect.size.clone(), // Ignore the content rect’s position in its own containing block: @@ -272,31 +249,33 @@ impl<'box_tree> PositioningContext<'box_tree> { style: &new_fragment.style, }; + let take_hoisted_boxes_pending_layout = |context: &mut Self| match context + .for_nearest_positioned_ancestor + .as_mut() + { + Some(fragments) => std::mem::take(fragments), + None => std::mem::take(&mut context.for_nearest_containing_block_for_all_descendants), + }; + // Loop because it’s possible that we discover (the static position of) // more absolutely-positioned boxes while doing layout for others. - let mut new_child_fragments = Vec::new(); - while !containing_block_for_all_descendants - .for_nearest_containing_block_for_all_descendants - .is_empty() - { + let mut hoisted_boxes = take_hoisted_boxes_pending_layout(self); + let mut laid_out_child_fragments = Vec::new(); + while !hoisted_boxes.is_empty() { HoistedAbsolutelyPositionedBox::layout_many( layout_context, - &std::mem::take( - &mut containing_block_for_all_descendants - .for_nearest_containing_block_for_all_descendants, - ), - &mut new_child_fragments, - &mut containing_block_for_all_descendants - .for_nearest_containing_block_for_all_descendants, + &hoisted_boxes, + &mut laid_out_child_fragments, + &mut self.for_nearest_containing_block_for_all_descendants, &containing_block, - ) + ); + hoisted_boxes = take_hoisted_boxes_pending_layout(self); } - new_fragment.children.extend(new_child_fragments); - new_fragment + new_fragment.children.extend(laid_out_child_fragments); } - pub(crate) fn push(&mut self, box_: HoistedAbsolutelyPositionedBox<'box_tree>) { + pub(crate) fn push(&mut self, box_: HoistedAbsolutelyPositionedBox) { if let Some(nearest) = &mut self.for_nearest_positioned_ancestor { match box_ .absolutely_positioned_box @@ -362,7 +341,7 @@ impl<'box_tree> PositioningContext<'box_tree> { &mut self, layout_context: &LayoutContext, initial_containing_block: &DefiniteContainingBlock, - fragments: &mut Vec<Fragment>, + fragments: &mut Vec<ArcRefCell<Fragment>>, ) { debug_assert!(self.for_nearest_positioned_ancestor.is_none()); @@ -381,67 +360,41 @@ impl<'box_tree> PositioningContext<'box_tree> { ) } } - - fn layout_positioned_fragment_children( - &mut self, - layout_context: &LayoutContext, - positioned_box_fragment: &mut BoxFragment, - ) { - let for_here = self.for_nearest_positioned_ancestor.take().unwrap(); - if !for_here.is_empty() { - let padding_rect = Rect { - size: positioned_box_fragment.content_rect.size.clone(), - // Ignore the content rect’s position in its own containing block: - start_corner: Vec2::zero(), - } - .inflate(&positioned_box_fragment.padding); - let containing_block = DefiniteContainingBlock { - size: padding_rect.size.clone(), - style: &positioned_box_fragment.style, - }; - let mut children = Vec::new(); - HoistedAbsolutelyPositionedBox::layout_many( - layout_context, - &for_here, - &mut children, - &mut self.for_nearest_containing_block_for_all_descendants, - &containing_block, - ); - positioned_box_fragment.children.extend(children); - } - } } -impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> { +impl HoistedAbsolutelyPositionedBox { pub(crate) fn layout_many( layout_context: &LayoutContext, boxes: &[Self], - fragments: &mut Vec<Fragment>, - for_nearest_containing_block_for_all_descendants: &mut Vec< - HoistedAbsolutelyPositionedBox<'box_tree>, - >, + fragments: &mut Vec<ArcRefCell<Fragment>>, + for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>, containing_block: &DefiniteContainingBlock, ) { if layout_context.use_rayon { fragments.par_extend(boxes.par_iter().mapfold_reduce_into( for_nearest_containing_block_for_all_descendants, |for_nearest_containing_block_for_all_descendants, box_| { - Fragment::Box(box_.layout( + let new_fragment = ArcRefCell::new(Fragment::Box(box_.layout( layout_context, for_nearest_containing_block_for_all_descendants, containing_block, - )) + ))); + + *box_.fragment.borrow_mut() = Some(new_fragment.clone()); + new_fragment }, Vec::new, vec_append_owned, )) } else { fragments.extend(boxes.iter().map(|box_| { - Fragment::Box(box_.layout( + let new_fragment = ArcRefCell::new(Fragment::Box(box_.layout( layout_context, for_nearest_containing_block_for_all_descendants, containing_block, - )) + ))); + *box_.fragment.borrow_mut() = Some(new_fragment.clone()); + new_fragment })) } } @@ -449,9 +402,7 @@ impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> { pub(crate) fn layout( &self, layout_context: &LayoutContext, - for_nearest_containing_block_for_all_descendants: &mut Vec< - HoistedAbsolutelyPositionedBox<'box_tree>, - >, + for_nearest_containing_block_for_all_descendants: &mut Vec<HoistedAbsolutelyPositionedBox>, containing_block: &DefiniteContainingBlock, ) -> BoxFragment { let style = &self.absolutely_positioned_box.contents.style; @@ -513,12 +464,10 @@ impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> { block_end: block_axis.margin_end, }; - let for_containing_block_for_all_descendants = - for_nearest_containing_block_for_all_descendants; PositioningContext::create_and_layout_positioned( layout_context, style, - for_containing_block_for_all_descendants, + for_nearest_containing_block_for_all_descendants, |positioning_context| { let size; let fragments; @@ -605,7 +554,6 @@ impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> { border, margin, CollapsedBlockMargins::zero(), - Some(self.fragment_id), ) }, ) diff --git a/components/layout_2020/query.rs b/components/layout_2020/query.rs index 45eb3b25ac0..fc4ac985253 100644 --- a/components/layout_2020/query.rs +++ b/components/layout_2020/query.rs @@ -192,9 +192,9 @@ pub fn process_node_geometry_request( fragment_tree_root.get_border_dimensions_for_node(requested_node) } -pub fn process_node_scroll_id_request<N: LayoutNode>( +pub fn process_node_scroll_id_request<'dom>( id: PipelineId, - requested_node: N, + requested_node: impl LayoutNode<'dom>, ) -> ExternalScrollId { let layout_node = requested_node.to_threadsafe(); layout_node.generate_scroll_id(id) @@ -207,15 +207,12 @@ pub fn process_node_scroll_area_request(_requested_node: OpaqueNode) -> Rect<i32 /// Return the resolved value of property for a given (pseudo)element. /// <https://drafts.csswg.org/cssom/#resolved-value> -pub fn process_resolved_style_request<'a, N>( +pub fn process_resolved_style_request<'dom>( _context: &LayoutContext, - _node: N, + _node: impl LayoutNode<'dom>, _pseudo: &Option<PseudoElement>, _property: &PropertyId, -) -> String -where - N: LayoutNode, -{ +) -> String { "".to_owned() } @@ -223,12 +220,12 @@ pub fn process_offset_parent_query(_requested_node: OpaqueNode) -> OffsetParentR OffsetParentResponse::empty() } -pub fn process_style_query<N: LayoutNode>(_requested_node: N) -> StyleResponse { +pub fn process_style_query<'dom>(_requested_node: impl LayoutNode<'dom>) -> StyleResponse { StyleResponse(None) } // https://html.spec.whatwg.org/multipage/#the-innertext-idl-attribute -pub fn process_element_inner_text_query<N: LayoutNode>(_node: N) -> String { +pub fn process_element_inner_text_query<'dom>(_node: impl LayoutNode<'dom>) -> String { "".to_owned() } diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs index 7ed41d1cd91..cdde69a7866 100644 --- a/components/layout_2020/style_ext.rs +++ b/components/layout_2020/style_ext.rs @@ -245,7 +245,9 @@ impl ComputedValuesExt for ComputedValues { /// Returns true if this style establishes a containing block for all descendants /// including fixed and absolutely positioned ones. fn establishes_containing_block_for_all_descendants(&self) -> bool { - if self.has_transform_or_perspective() { + if self.get_box().display.outside() != stylo::DisplayOutside::Inline && + self.has_transform_or_perspective() + { return true; } diff --git a/components/layout_2020/traversal.rs b/components/layout_2020/traversal.rs index 97a9874a20b..b57fe2b63f1 100644 --- a/components/layout_2020/traversal.rs +++ b/components/layout_2020/traversal.rs @@ -30,10 +30,10 @@ impl<'a> RecalcStyle<'a> { } #[allow(unsafe_code)] -impl<'a, E> DomTraversal<E> for RecalcStyle<'a> +impl<'a, 'dom, E> DomTraversal<E> for RecalcStyle<'a> where E: TElement, - E::ConcreteNode: LayoutNode, + E::ConcreteNode: LayoutNode<'dom>, E::FontMetricsProvider: Send, { fn process_preorder<F>( diff --git a/components/layout_2020/wrapper.rs b/components/layout_2020/wrapper.rs index 02a0f8ceeee..504ab9af2cc 100644 --- a/components/layout_2020/wrapper.rs +++ b/components/layout_2020/wrapper.rs @@ -11,7 +11,10 @@ pub trait GetRawData { fn get_raw_data(&self) -> Option<&StyleAndLayoutData>; } -impl<T: GetLayoutData> GetRawData for T { +impl<'dom, T> GetRawData for T +where + T: GetLayoutData<'dom>, +{ fn get_raw_data(&self) -> Option<&StyleAndLayoutData> { self.get_style_and_layout_data().map(|opaque| { let container = opaque.ptr.as_ptr() as *mut StyleAndLayoutData; diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index c47635afedb..2f502352d27 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -39,7 +39,6 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId}; use net_traits::image::base::{Image, ImageMetadata}; use range::Range; use script::layout_exports::NodeFlags; -use script::layout_exports::PendingRestyle; use script::layout_exports::ShadowRoot; use script::layout_exports::{ CharacterDataTypeId, DocumentFragmentTypeId, ElementTypeId, HTMLElementTypeId, NodeTypeId, @@ -71,7 +70,6 @@ use servo_url::ServoUrl; use std::fmt; use std::fmt::Debug; use std::hash::{Hash, Hasher}; -use std::marker::PhantomData; use std::ptr::NonNull; use std::sync::atomic::Ordering; use std::sync::Arc as StdArc; @@ -101,12 +99,9 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) { } #[derive(Clone, Copy)] -pub struct ServoLayoutNode<'a> { +pub struct ServoLayoutNode<'dom> { /// The wrapped node. - node: LayoutDom<Node>, - - /// Being chained to a PhantomData prevents `LayoutNode`s from escaping. - chain: PhantomData<&'a ()>, + node: LayoutDom<'dom, Node>, } impl<'ln> Debug for ServoLayoutNode<'ln> { @@ -131,25 +126,14 @@ impl<'a> PartialEq for ServoLayoutNode<'a> { } impl<'ln> ServoLayoutNode<'ln> { - fn from_layout_js(n: LayoutDom<Node>) -> ServoLayoutNode<'ln> { - ServoLayoutNode { - node: n, - chain: PhantomData, - } + fn from_layout_js(n: LayoutDom<'ln, Node>) -> Self { + ServoLayoutNode { node: n } } - pub unsafe fn new(address: &TrustedNodeAddress) -> ServoLayoutNode { + pub unsafe fn new(address: &TrustedNodeAddress) -> Self { ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address)) } - /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoLayoutNode<'ln> { - ServoLayoutNode { - node: *node, - chain: self.chain, - } - } - fn script_type_id(&self) -> NodeTypeId { unsafe { self.node.type_id_for_layout() } } @@ -167,12 +151,9 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> { } #[derive(Clone, Copy, PartialEq)] -pub struct ServoShadowRoot<'a> { +pub struct ServoShadowRoot<'dom> { /// The wrapped shadow root. - shadow_root: LayoutDom<ShadowRoot>, - - /// Being chained to a PhantomData prevents `ShadowRoot`s from escaping. - chain: PhantomData<&'a ()>, + shadow_root: LayoutDom<'dom, ShadowRoot>, } impl<'lr> Debug for ServoShadowRoot<'lr> { @@ -206,11 +187,8 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> { } impl<'lr> ServoShadowRoot<'lr> { - fn from_layout_js(shadow_root: LayoutDom<ShadowRoot>) -> ServoShadowRoot<'lr> { - ServoShadowRoot { - shadow_root, - chain: PhantomData, - } + fn from_layout_js(shadow_root: LayoutDom<'lr, ShadowRoot>) -> Self { + ServoShadowRoot { shadow_root } } pub unsafe fn flush_stylesheets( @@ -233,40 +211,24 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { unsafe { self.node .composed_parent_node_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(Self::from_layout_js) } } fn first_child(&self) -> Option<Self> { - unsafe { - self.node - .first_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.first_child_ref().map(Self::from_layout_js) } } fn last_child(&self) -> Option<Self> { - unsafe { - self.node - .last_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.last_child_ref().map(Self::from_layout_js) } } fn prev_sibling(&self) -> Option<Self> { - unsafe { - self.node - .prev_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.prev_sibling_ref().map(Self::from_layout_js) } } fn next_sibling(&self) -> Option<Self> { - unsafe { - self.node - .next_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.next_sibling_ref().map(Self::from_layout_js) } } fn owner_doc(&self) -> Self::ConcreteDocument { @@ -308,11 +270,11 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { } } -impl<'ln> LayoutNode for ServoLayoutNode<'ln> { +impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> { type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>; fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode { - ServoThreadSafeLayoutNode::new(self) + ServoThreadSafeLayoutNode::new(*self) } fn type_id(&self) -> LayoutNodeType { @@ -342,25 +304,25 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> { } } -impl<'ln> GetLayoutData for ServoLayoutNode<'ln> { +impl<'ln> GetLayoutData<'ln> for ServoLayoutNode<'ln> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { unsafe { self.get_jsmanaged().get_style_and_layout_data() } } } -impl<'le> GetLayoutData for ServoLayoutElement<'le> { +impl<'le> GetLayoutData<'le> for ServoLayoutElement<'le> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.as_node().get_style_and_layout_data() } } -impl<'ln> GetLayoutData for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> GetLayoutData<'ln> for ServoThreadSafeLayoutNode<'ln> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.node.get_style_and_layout_data() } } -impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> { +impl<'le> GetLayoutData<'le> for ServoThreadSafeLayoutElement<'le> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.element.as_node().get_style_and_layout_data() } @@ -369,16 +331,15 @@ impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> { impl<'ln> ServoLayoutNode<'ln> { /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - pub unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> { - &self.node + pub unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> { + self.node } } // A wrapper around documents that ensures ayout can only ever access safe properties. #[derive(Clone, Copy)] -pub struct ServoLayoutDocument<'ld> { - document: LayoutDom<Document>, - chain: PhantomData<&'ld ()>, +pub struct ServoLayoutDocument<'dom> { + document: LayoutDom<'dom, Document>, } impl<'ld> TDocument for ServoLayoutDocument<'ld> { @@ -405,14 +366,6 @@ impl<'ld> ServoLayoutDocument<'ld> { .next() } - pub fn drain_pending_restyles(&self) -> Vec<(ServoLayoutElement<'ld>, PendingRestyle)> { - let elements = unsafe { self.document.drain_pending_restyles() }; - elements - .into_iter() - .map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)) - .collect() - } - pub fn needs_paint_from_layout(&self) { unsafe { self.document.needs_paint_from_layout() } } @@ -455,19 +408,15 @@ impl<'ld> ServoLayoutDocument<'ld> { } } - pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> { - ServoLayoutDocument { - document: doc, - chain: PhantomData, - } + pub fn from_layout_js(doc: LayoutDom<'ld, Document>) -> Self { + ServoLayoutDocument { document: doc } } } /// A wrapper around elements that ensures layout can only ever access safe properties. #[derive(Clone, Copy)] -pub struct ServoLayoutElement<'le> { - element: LayoutDom<Element>, - chain: PhantomData<&'le ()>, +pub struct ServoLayoutElement<'dom> { + element: LayoutDom<'dom, Element>, } impl<'le> fmt::Debug for ServoLayoutElement<'le> { @@ -748,11 +697,8 @@ impl<'le> Hash for ServoLayoutElement<'le> { impl<'le> Eq for ServoLayoutElement<'le> {} impl<'le> ServoLayoutElement<'le> { - fn from_layout_js(el: LayoutDom<Element>) -> ServoLayoutElement<'le> { - ServoLayoutElement { - element: el, - chain: PhantomData, - } + fn from_layout_js(el: LayoutDom<'le, Element>) -> Self { + ServoLayoutElement { element: el } } #[inline] @@ -798,7 +744,7 @@ impl<'le> ServoLayoutElement<'le> { } } -fn as_element<'le>(node: LayoutDom<Node>) -> Option<ServoLayoutElement<'le>> { +fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> { node.downcast().map(ServoLayoutElement::from_layout_js) } @@ -1049,33 +995,24 @@ impl<'a> PartialEq for ServoThreadSafeLayoutNode<'a> { } } -impl<'ln> DangerousThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> DangerousThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> { unsafe fn dangerous_first_child(&self) -> Option<Self> { self.get_jsmanaged() .first_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(ServoLayoutNode::from_layout_js) + .map(Self::new) } unsafe fn dangerous_next_sibling(&self) -> Option<Self> { self.get_jsmanaged() .next_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(ServoLayoutNode::from_layout_js) + .map(Self::new) } } impl<'ln> ServoThreadSafeLayoutNode<'ln> { - /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime( - &self, - node: &LayoutDom<Node>, - ) -> ServoThreadSafeLayoutNode<'ln> { - ServoThreadSafeLayoutNode { - node: self.node.new_with_this_lifetime(node), - pseudo: PseudoElementType::Normal, - } - } - /// Creates a new `ServoThreadSafeLayoutNode` from the given `ServoLayoutNode`. - pub fn new<'a>(node: &ServoLayoutNode<'a>) -> ServoThreadSafeLayoutNode<'a> { + pub fn new(node: ServoLayoutNode<'ln>) -> Self { ServoThreadSafeLayoutNode { node: node.clone(), pseudo: PseudoElementType::Normal, @@ -1084,7 +1021,7 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> { /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> { + unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> { self.node.get_jsmanaged() } } @@ -1099,7 +1036,7 @@ impl<'ln> NodeInfo for ServoThreadSafeLayoutNode<'ln> { } } -impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> { type ConcreteNode = ServoLayoutNode<'ln>; type ConcreteThreadSafeLayoutElement = ServoThreadSafeLayoutElement<'ln>; type ConcreteElement = ServoLayoutElement<'ln>; @@ -1255,14 +1192,14 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } } -pub struct ThreadSafeLayoutNodeChildrenIterator<ConcreteNode: ThreadSafeLayoutNode> { +pub struct ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> { current_node: Option<ConcreteNode>, parent_node: ConcreteNode, } -impl<ConcreteNode> ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> +impl<'dom, ConcreteNode> ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> where - ConcreteNode: DangerousThreadSafeLayoutNode, + ConcreteNode: DangerousThreadSafeLayoutNode<'dom>, { pub fn new(parent: ConcreteNode) -> Self { let first_child: Option<ConcreteNode> = match parent.get_pseudo_element_type() { @@ -1282,9 +1219,9 @@ where } } -impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> +impl<'dom, ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> where - ConcreteNode: DangerousThreadSafeLayoutNode, + ConcreteNode: DangerousThreadSafeLayoutNode<'dom>, { type Item = ConcreteNode; fn next(&mut self) -> Option<ConcreteNode> { @@ -1366,7 +1303,7 @@ pub struct ServoThreadSafeLayoutElement<'le> { pseudo: PseudoElementType, } -impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> { +impl<'le> ThreadSafeLayoutElement<'le> for ServoThreadSafeLayoutElement<'le> { type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'le>; type ConcreteElement = ServoLayoutElement<'le>; diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 60710009ff5..54f1ec8d656 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1039,7 +1039,7 @@ impl LayoutThread { self.stylist.set_quirks_mode(quirks_mode); } - fn try_get_layout_root<N: LayoutNode>(&self, node: N) -> Option<FlowRef> { + fn try_get_layout_root<'dom>(&self, node: impl LayoutNode<'dom>) -> Option<FlowRef> { let result = node.mutate_layout_data()?.flow_construction_result.get(); let mut flow = match result { @@ -1450,17 +1450,19 @@ impl LayoutThread { guards.author.clone(), ); - let restyles = document.drain_pending_restyles(); + let restyles = std::mem::take(&mut data.pending_restyles); debug!("Draining restyles: {}", restyles.len()); let mut map = SnapshotMap::new(); let elements_with_snapshot: Vec<_> = restyles .iter() .filter(|r| r.1.snapshot.is_some()) - .map(|r| r.0) + .map(|r| unsafe { ServoLayoutNode::new(&r.0).as_element().unwrap() }) .collect(); for (el, restyle) in restyles { + let el = unsafe { ServoLayoutNode::new(&el).as_element().unwrap() }; + // Propagate the descendant bit up the ancestors. Do this before // the restyle calculation so that we can also do it for new // unstyled nodes, which the descendants bit helps us find. diff --git a/components/layout_thread_2020/dom_wrapper.rs b/components/layout_thread_2020/dom_wrapper.rs index e2bdc0f42a6..55277ea309c 100644 --- a/components/layout_thread_2020/dom_wrapper.rs +++ b/components/layout_thread_2020/dom_wrapper.rs @@ -39,7 +39,6 @@ use msg::constellation_msg::{BrowsingContextId, PipelineId}; use net_traits::image::base::{Image, ImageMetadata}; use range::Range; use script::layout_exports::NodeFlags; -use script::layout_exports::PendingRestyle; use script::layout_exports::ShadowRoot; use script::layout_exports::{ CharacterDataTypeId, DocumentFragmentTypeId, ElementTypeId, HTMLElementTypeId, NodeTypeId, @@ -71,7 +70,6 @@ use servo_url::ServoUrl; use std::fmt; use std::fmt::Debug; use std::hash::{Hash, Hasher}; -use std::marker::PhantomData; use std::ptr::NonNull; use std::sync::atomic::Ordering; use std::sync::Arc as StdArc; @@ -101,12 +99,9 @@ pub unsafe fn drop_style_and_layout_data(data: OpaqueStyleAndLayoutData) { } #[derive(Clone, Copy)] -pub struct ServoLayoutNode<'a> { +pub struct ServoLayoutNode<'dom> { /// The wrapped node. - node: LayoutDom<Node>, - - /// Being chained to a PhantomData prevents `LayoutNode`s from escaping. - chain: PhantomData<&'a ()>, + node: LayoutDom<'dom, Node>, } // Those are supposed to be sound, but they aren't because the entire system @@ -138,25 +133,14 @@ impl<'a> PartialEq for ServoLayoutNode<'a> { } impl<'ln> ServoLayoutNode<'ln> { - fn from_layout_js(n: LayoutDom<Node>) -> ServoLayoutNode<'ln> { - ServoLayoutNode { - node: n, - chain: PhantomData, - } + fn from_layout_js(n: LayoutDom<'ln, Node>) -> Self { + ServoLayoutNode { node: n } } - pub unsafe fn new(address: &TrustedNodeAddress) -> ServoLayoutNode { + pub unsafe fn new(address: &TrustedNodeAddress) -> Self { ServoLayoutNode::from_layout_js(LayoutDom::from_trusted_node_address(*address)) } - /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime(&self, node: &LayoutDom<Node>) -> ServoLayoutNode<'ln> { - ServoLayoutNode { - node: *node, - chain: self.chain, - } - } - fn script_type_id(&self) -> NodeTypeId { unsafe { self.node.type_id_for_layout() } } @@ -174,12 +158,9 @@ impl<'ln> NodeInfo for ServoLayoutNode<'ln> { } #[derive(Clone, Copy, PartialEq)] -pub struct ServoShadowRoot<'a> { +pub struct ServoShadowRoot<'dom> { /// The wrapped shadow root. - shadow_root: LayoutDom<ShadowRoot>, - - /// Being chained to a PhantomData prevents `ShadowRoot`s from escaping. - chain: PhantomData<&'a ()>, + shadow_root: LayoutDom<'dom, ShadowRoot>, } impl<'lr> Debug for ServoShadowRoot<'lr> { @@ -213,11 +194,8 @@ impl<'lr> TShadowRoot for ServoShadowRoot<'lr> { } impl<'lr> ServoShadowRoot<'lr> { - fn from_layout_js(shadow_root: LayoutDom<ShadowRoot>) -> ServoShadowRoot<'lr> { - ServoShadowRoot { - shadow_root, - chain: PhantomData, - } + fn from_layout_js(shadow_root: LayoutDom<'lr, ShadowRoot>) -> Self { + ServoShadowRoot { shadow_root } } pub unsafe fn flush_stylesheets( @@ -240,40 +218,24 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { unsafe { self.node .composed_parent_node_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(Self::from_layout_js) } } fn first_child(&self) -> Option<Self> { - unsafe { - self.node - .first_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.first_child_ref().map(Self::from_layout_js) } } fn last_child(&self) -> Option<Self> { - unsafe { - self.node - .last_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.last_child_ref().map(Self::from_layout_js) } } fn prev_sibling(&self) -> Option<Self> { - unsafe { - self.node - .prev_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.prev_sibling_ref().map(Self::from_layout_js) } } fn next_sibling(&self) -> Option<Self> { - unsafe { - self.node - .next_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) - } + unsafe { self.node.next_sibling_ref().map(Self::from_layout_js) } } fn owner_doc(&self) -> Self::ConcreteDocument { @@ -315,11 +277,11 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { } } -impl<'ln> LayoutNode for ServoLayoutNode<'ln> { +impl<'ln> LayoutNode<'ln> for ServoLayoutNode<'ln> { type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>; fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode { - ServoThreadSafeLayoutNode::new(self) + ServoThreadSafeLayoutNode::new(*self) } fn type_id(&self) -> LayoutNodeType { @@ -349,25 +311,25 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> { } } -impl<'ln> GetLayoutData for ServoLayoutNode<'ln> { +impl<'ln> GetLayoutData<'ln> for ServoLayoutNode<'ln> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { unsafe { self.get_jsmanaged().get_style_and_layout_data() } } } -impl<'le> GetLayoutData for ServoLayoutElement<'le> { +impl<'le> GetLayoutData<'le> for ServoLayoutElement<'le> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.as_node().get_style_and_layout_data() } } -impl<'ln> GetLayoutData for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> GetLayoutData<'ln> for ServoThreadSafeLayoutNode<'ln> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.node.get_style_and_layout_data() } } -impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> { +impl<'le> GetLayoutData<'le> for ServoThreadSafeLayoutElement<'le> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData> { self.element.as_node().get_style_and_layout_data() } @@ -376,16 +338,15 @@ impl<'le> GetLayoutData for ServoThreadSafeLayoutElement<'le> { impl<'ln> ServoLayoutNode<'ln> { /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - pub unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> { - &self.node + pub unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> { + self.node } } // A wrapper around documents that ensures ayout can only ever access safe properties. #[derive(Clone, Copy)] -pub struct ServoLayoutDocument<'ld> { - document: LayoutDom<Document>, - chain: PhantomData<&'ld ()>, +pub struct ServoLayoutDocument<'dom> { + document: LayoutDom<'dom, Document>, } impl<'ld> TDocument for ServoLayoutDocument<'ld> { @@ -412,14 +373,6 @@ impl<'ld> ServoLayoutDocument<'ld> { .next() } - pub fn drain_pending_restyles(&self) -> Vec<(ServoLayoutElement<'ld>, PendingRestyle)> { - let elements = unsafe { self.document.drain_pending_restyles() }; - elements - .into_iter() - .map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)) - .collect() - } - pub fn needs_paint_from_layout(&self) { unsafe { self.document.needs_paint_from_layout() } } @@ -462,19 +415,15 @@ impl<'ld> ServoLayoutDocument<'ld> { } } - pub fn from_layout_js(doc: LayoutDom<Document>) -> ServoLayoutDocument<'ld> { - ServoLayoutDocument { - document: doc, - chain: PhantomData, - } + pub fn from_layout_js(doc: LayoutDom<'ld, Document>) -> Self { + ServoLayoutDocument { document: doc } } } /// A wrapper around elements that ensures layout can only ever access safe properties. #[derive(Clone, Copy)] -pub struct ServoLayoutElement<'le> { - element: LayoutDom<Element>, - chain: PhantomData<&'le ()>, +pub struct ServoLayoutElement<'dom> { + element: LayoutDom<'dom, Element>, } impl<'le> fmt::Debug for ServoLayoutElement<'le> { @@ -755,11 +704,8 @@ impl<'le> Hash for ServoLayoutElement<'le> { impl<'le> Eq for ServoLayoutElement<'le> {} impl<'le> ServoLayoutElement<'le> { - fn from_layout_js(el: LayoutDom<Element>) -> ServoLayoutElement<'le> { - ServoLayoutElement { - element: el, - chain: PhantomData, - } + fn from_layout_js(el: LayoutDom<'le, Element>) -> Self { + ServoLayoutElement { element: el } } #[inline] @@ -805,7 +751,7 @@ impl<'le> ServoLayoutElement<'le> { } } -fn as_element<'le>(node: LayoutDom<Node>) -> Option<ServoLayoutElement<'le>> { +fn as_element<'dom>(node: LayoutDom<'dom, Node>) -> Option<ServoLayoutElement<'dom>> { node.downcast().map(ServoLayoutElement::from_layout_js) } @@ -1056,33 +1002,24 @@ impl<'a> PartialEq for ServoThreadSafeLayoutNode<'a> { } } -impl<'ln> DangerousThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> DangerousThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> { unsafe fn dangerous_first_child(&self) -> Option<Self> { self.get_jsmanaged() .first_child_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(ServoLayoutNode::from_layout_js) + .map(Self::new) } unsafe fn dangerous_next_sibling(&self) -> Option<Self> { self.get_jsmanaged() .next_sibling_ref() - .map(|node| self.new_with_this_lifetime(&node)) + .map(ServoLayoutNode::from_layout_js) + .map(Self::new) } } impl<'ln> ServoThreadSafeLayoutNode<'ln> { - /// Creates a new layout node with the same lifetime as this layout node. - pub unsafe fn new_with_this_lifetime( - &self, - node: &LayoutDom<Node>, - ) -> ServoThreadSafeLayoutNode<'ln> { - ServoThreadSafeLayoutNode { - node: self.node.new_with_this_lifetime(node), - pseudo: PseudoElementType::Normal, - } - } - /// Creates a new `ServoThreadSafeLayoutNode` from the given `ServoLayoutNode`. - pub fn new<'a>(node: &ServoLayoutNode<'a>) -> ServoThreadSafeLayoutNode<'a> { + pub fn new(node: ServoLayoutNode<'ln>) -> Self { ServoThreadSafeLayoutNode { node: node.clone(), pseudo: PseudoElementType::Normal, @@ -1091,7 +1028,7 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> { /// Returns the interior of this node as a `LayoutDom`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. - unsafe fn get_jsmanaged(&self) -> &LayoutDom<Node> { + unsafe fn get_jsmanaged(&self) -> LayoutDom<'ln, Node> { self.node.get_jsmanaged() } } @@ -1106,7 +1043,7 @@ impl<'ln> NodeInfo for ServoThreadSafeLayoutNode<'ln> { } } -impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { +impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> { type ConcreteNode = ServoLayoutNode<'ln>; type ConcreteThreadSafeLayoutElement = ServoThreadSafeLayoutElement<'ln>; type ConcreteElement = ServoLayoutElement<'ln>; @@ -1262,14 +1199,14 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { } } -pub struct ThreadSafeLayoutNodeChildrenIterator<ConcreteNode: ThreadSafeLayoutNode> { +pub struct ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> { current_node: Option<ConcreteNode>, parent_node: ConcreteNode, } -impl<ConcreteNode> ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> +impl<'dom, ConcreteNode> ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> where - ConcreteNode: DangerousThreadSafeLayoutNode, + ConcreteNode: DangerousThreadSafeLayoutNode<'dom>, { pub fn new(parent: ConcreteNode) -> Self { let first_child: Option<ConcreteNode> = match parent.get_pseudo_element_type() { @@ -1289,9 +1226,9 @@ where } } -impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> +impl<'dom, ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNode> where - ConcreteNode: DangerousThreadSafeLayoutNode, + ConcreteNode: DangerousThreadSafeLayoutNode<'dom>, { type Item = ConcreteNode; fn next(&mut self) -> Option<ConcreteNode> { @@ -1373,7 +1310,7 @@ pub struct ServoThreadSafeLayoutElement<'le> { pseudo: PseudoElementType, } -impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> { +impl<'le> ThreadSafeLayoutElement<'le> for ServoThreadSafeLayoutElement<'le> { type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'le>; type ConcreteElement = ServoLayoutElement<'le>; diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs index 5a76997b2ad..05663f7d68b 100644 --- a/components/layout_thread_2020/lib.rs +++ b/components/layout_thread_2020/lib.rs @@ -1096,16 +1096,19 @@ impl LayoutThread { guards.author.clone(), ); - let restyles = document.drain_pending_restyles(); + let restyles = std::mem::take(&mut data.pending_restyles); + debug!("Draining restyles: {}", restyles.len()); let mut map = SnapshotMap::new(); let elements_with_snapshot: Vec<_> = restyles .iter() .filter(|r| r.1.snapshot.is_some()) - .map(|r| r.0) + .map(|r| unsafe { ServoLayoutNode::new(&r.0).as_element().unwrap() }) .collect(); for (el, restyle) in restyles { + let el = unsafe { ServoLayoutNode::new(&el).as_element().unwrap() }; + // Propagate the descendant bit up the ancestors. Do this before // the restyle calculation so that we can also do it for new // unstyled nodes, which the descendants bit helps us find. diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index ed589373e09..a9aefda2d12 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -29,7 +29,7 @@ servo = [ [dependencies] accountable-refcell = { version = "0.2.0", optional = true } app_units = "0.7" -content-security-policy = {version = "0.3.0", features = ["serde"], optional = true} +content-security-policy = {version = "0.4.0", features = ["serde"], optional = true} crossbeam-channel = { version = "0.4", optional = true } cssparser = "0.27" euclid = "0.20" diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index db3b1193374..d1248453c10 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -18,7 +18,7 @@ doctest = false base64 = "0.10.1" brotli = "3" bytes = "0.4" -content-security-policy = {version = "0.3.0", features = ["serde"]} +content-security-policy = {version = "0.4.0", features = ["serde"]} cookie_rs = {package = "cookie", version = "0.11"} crossbeam-channel = "0.4" data-url = "0.1.0" diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 7d641090649..191ea0cb41f 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -203,6 +203,7 @@ pub fn main_fetch( // Step 2.4. if should_request_be_blocked_by_csp(request) == csp::CheckResult::Blocked { + warn!("Request blocked by CSP"); response = Some(Response::network_error(NetworkError::Internal( "Blocked by Content-Security-Policy".into(), ))) diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml index 46def57c7ad..e9eae0b9f35 100644 --- a/components/net_traits/Cargo.toml +++ b/components/net_traits/Cargo.toml @@ -13,7 +13,7 @@ test = false doctest = false [dependencies] -content-security-policy = {version = "0.3.0", features = ["serde"]} +content-security-policy = {version = "0.4.0", features = ["serde"]} cookie = "0.11" embedder_traits = { path = "../embedder_traits" } headers = "0.2" diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index dfcb331fcc5..7cdc2e1809a 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -39,7 +39,7 @@ bitflags = "1.0" bluetooth_traits = {path = "../bluetooth_traits"} canvas_traits = {path = "../canvas_traits"} caseless = "0.2" -content-security-policy = {version = "0.3.0", features = ["serde"]} +content-security-policy = {version = "0.4.0", features = ["serde"]} cookie = "0.11" chrono = "0.4" crossbeam-channel = "0.4" diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 397d3102ff3..d09dd61d9f3 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -6,7 +6,7 @@ use crate::dom::audionode::AudioNode; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AnalyserNodeBinding::{ - self, AnalyserNodeMethods, AnalyserOptions, + AnalyserNodeMethods, AnalyserOptions, }; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, @@ -96,7 +96,7 @@ impl AnalyserNode { options: &AnalyserOptions, ) -> Fallible<DomRoot<AnalyserNode>> { let (node, recv) = AnalyserNode::new_inherited(window, context, options)?; - let object = reflect_dom_object(Box::new(node), window, AnalyserNodeBinding::Wrap); + let object = reflect_dom_object(Box::new(node), window); let (source, canceller) = window .task_manager() .dom_manipulation_task_source_with_canceller(); diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index f81a3cf9817..7dcc76e6caf 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::AttrBinding::{self, AttrMethods}; +use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::DOMString; @@ -70,7 +70,6 @@ impl Attr { document, local_name, value, name, namespace, prefix, owner, )), document, - AttrBinding::Wrap, ) } @@ -242,7 +241,7 @@ pub trait AttrHelpersForLayout { } #[allow(unsafe_code)] -impl AttrHelpersForLayout for LayoutDom<Attr> { +impl AttrHelpersForLayout for LayoutDom<'_, Attr> { #[inline] unsafe fn value_forever(&self) -> &'static AttrValue { // This transmute is used to cheat the lifetime restriction. diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index fb598068998..ade645827a6 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -5,7 +5,7 @@ use crate::dom::audionode::MAX_CHANNEL_COUNT; use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::AudioBufferBinding::{ - self, AudioBufferMethods, AudioBufferOptions, + AudioBufferMethods, AudioBufferOptions, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::num::Finite; @@ -84,7 +84,7 @@ impl AudioBuffer { initial_data: Option<&[Vec<f32>]>, ) -> DomRoot<AudioBuffer> { let buffer = AudioBuffer::new_inherited(number_of_channels, length, sample_rate); - let buffer = reflect_dom_object(Box::new(buffer), global, AudioBufferBinding::Wrap); + let buffer = reflect_dom_object(Box::new(buffer), global); buffer.set_initial_data(initial_data); buffer } diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs index 656cfef9699..683f32f4ec0 100644 --- a/components/script/dom/audiobuffersourcenode.rs +++ b/components/script/dom/audiobuffersourcenode.rs @@ -6,7 +6,6 @@ use crate::dom::audiobuffer::AudioBuffer; use crate::dom::audioparam::AudioParam; use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; -use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding; use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceNodeMethods; use crate::dom::bindings::codegen::Bindings::AudioBufferSourceNodeBinding::AudioBufferSourceOptions; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; @@ -100,11 +99,7 @@ impl AudioBufferSourceNode { options: &AudioBufferSourceOptions, ) -> Fallible<DomRoot<AudioBufferSourceNode>> { let node = AudioBufferSourceNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - AudioBufferSourceNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index b81caed793b..f7fb005f18d 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions}; -use crate::dom::bindings::codegen::Bindings::AudioContextBinding; use crate::dom::bindings::codegen::Bindings::AudioContextBinding::{ AudioContextLatencyCategory, AudioContextMethods, }; @@ -77,7 +76,7 @@ impl AudioContext { pub fn new(window: &Window, options: &AudioContextOptions) -> DomRoot<AudioContext> { let pipeline_id = window.pipeline_id(); let context = AudioContext::new_inherited(options, pipeline_id); - let context = reflect_dom_object(Box::new(context), window, AudioContextBinding::Wrap); + let context = reflect_dom_object(Box::new(context), window); context.resume(); context } diff --git a/components/script/dom/audiodestinationnode.rs b/components/script/dom/audiodestinationnode.rs index c59ec350d0b..7e820240b63 100644 --- a/components/script/dom/audiodestinationnode.rs +++ b/components/script/dom/audiodestinationnode.rs @@ -4,9 +4,7 @@ use crate::dom::audionode::{AudioNode, MAX_CHANNEL_COUNT}; use crate::dom::baseaudiocontext::BaseAudioContext; -use crate::dom::bindings::codegen::Bindings::AudioDestinationNodeBinding::{ - self, AudioDestinationNodeMethods, -}; +use crate::dom::bindings::codegen::Bindings::AudioDestinationNodeBinding::AudioDestinationNodeMethods; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::AudioNodeOptions; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, @@ -46,7 +44,7 @@ impl AudioDestinationNode { options: &AudioNodeOptions, ) -> DomRoot<AudioDestinationNode> { let node = AudioDestinationNode::new_inherited(context, options); - reflect_dom_object(Box::new(node), global, AudioDestinationNodeBinding::Wrap) + reflect_dom_object(Box::new(node), global) } } diff --git a/components/script/dom/audiolistener.rs b/components/script/dom/audiolistener.rs index 79bbe381b07..2256efaf558 100644 --- a/components/script/dom/audiolistener.rs +++ b/components/script/dom/audiolistener.rs @@ -4,7 +4,7 @@ use crate::dom::audioparam::AudioParam; use crate::dom::baseaudiocontext::BaseAudioContext; -use crate::dom::bindings::codegen::Bindings::AudioListenerBinding::{self, AudioListenerMethods}; +use crate::dom::bindings::codegen::Bindings::AudioListenerBinding::AudioListenerMethods; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::num::Finite; @@ -143,7 +143,7 @@ impl AudioListener { #[allow(unrooted_must_root)] pub fn new(window: &Window, context: &BaseAudioContext) -> DomRoot<AudioListener> { let node = AudioListener::new_inherited(window, context); - reflect_dom_object(Box::new(node), window, AudioListenerBinding::Wrap) + reflect_dom_object(Box::new(node), window) } } diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 8d07a0d4bd5..dd0e72f7bcf 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::baseaudiocontext::BaseAudioContext; -use crate::dom::bindings::codegen::Bindings::AudioParamBinding; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::{ AudioParamMethods, AutomationRate, }; @@ -75,7 +74,7 @@ impl AudioParam { min_value, max_value, ); - reflect_dom_object(Box::new(audio_param), window, AudioParamBinding::Wrap) + reflect_dom_object(Box::new(audio_param), window) } fn message_node(&self, message: AudioNodeMessage) { diff --git a/components/script/dom/audiotrack.rs b/components/script/dom/audiotrack.rs index af237bc8b1a..19bc6d0a6cd 100644 --- a/components/script/dom/audiotrack.rs +++ b/components/script/dom/audiotrack.rs @@ -4,7 +4,7 @@ use crate::dom::audiotracklist::AudioTrackList; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::AudioTrackBinding::{self, AudioTrackMethods}; +use crate::dom::bindings::codegen::Bindings::AudioTrackBinding::AudioTrackMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; @@ -55,7 +55,6 @@ impl AudioTrack { id, kind, label, language, track_list, )), window, - AudioTrackBinding::Wrap, ) } diff --git a/components/script/dom/audiotracklist.rs b/components/script/dom/audiotracklist.rs index 5191221b7d9..6a7fd3b4ebb 100644 --- a/components/script/dom/audiotracklist.rs +++ b/components/script/dom/audiotracklist.rs @@ -4,7 +4,7 @@ use crate::dom::audiotrack::AudioTrack; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::AudioTrackListBinding::{self, AudioTrackListMethods}; +use crate::dom::bindings::codegen::Bindings::AudioTrackListBinding::AudioTrackListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -43,7 +43,6 @@ impl AudioTrackList { reflect_dom_object( Box::new(AudioTrackList::new_inherited(tracks, media_element)), window, - AudioTrackListBinding::Wrap, ) } diff --git a/components/script/dom/beforeunloadevent.rs b/components/script/dom/beforeunloadevent.rs index b20f12650d7..d4e27e94b32 100644 --- a/components/script/dom/beforeunloadevent.rs +++ b/components/script/dom/beforeunloadevent.rs @@ -5,7 +5,6 @@ #![allow(dead_code)] use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding; use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::inheritance::Castable; @@ -33,11 +32,7 @@ impl BeforeUnloadEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<BeforeUnloadEvent> { - reflect_dom_object( - Box::new(BeforeUnloadEvent::new_inherited()), - window, - BeforeUnloadEventBinding::Wrap, - ) + reflect_dom_object(Box::new(BeforeUnloadEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index f7ce60cc80c..8f0281be802 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -427,17 +427,6 @@ class CGMethodCall(CGThing): (s[1][distinguishingIndex].type.isSequence() or s[1][distinguishingIndex].type.isObject())) - # Check for Date objects - # XXXbz Do we need to worry about security wrappers around the Date? - pickFirstSignature("%s.get().is_object() && " - "{ rooted!(in(*cx) let obj = %s.get().to_object()); " - "let mut is_date = false; " - "assert!(ObjectIsDate(*cx, obj.handle(), &mut is_date)); " - "is_date }" % - (distinguishingArg, distinguishingArg), - lambda s: (s[1][distinguishingIndex].type.isDate() or - s[1][distinguishingIndex].type.isObject())) - # Check for vanilla JS objects # XXXbz Do we need to worry about security wrappers? pickFirstSignature("%s.get().is_object() && !is_platform_object(%s.get().to_object(), *cx)" % @@ -596,8 +585,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # We should not have a defaultValue if we know we're an object assert not isDefinitelyObject or defaultValue is None - isEnforceRange = type.enforceRange - isClamp = type.clamp + isEnforceRange = type.hasEnforceRange() + isClamp = type.hasClamp() if type.treatNullAsEmpty: treatNullAs = "EmptyString" else: @@ -1665,6 +1654,8 @@ class MethodDefiner(PropertyDefiner): (maplikeOrSetlikeOrIterable and maplikeOrSetlikeOrIterable.isIterable() and maplikeOrSetlikeOrIterable.isValueIterator())): + m = maplikeOrSetlikeOrIterable + # Add our keys/values/entries/forEach self.regular.append({ "name": "keys", @@ -2867,6 +2858,50 @@ impl PartialEq for %(name)s { """ % {'check': check, 'name': name} +class CGDomObjectWrap(CGThing): + """ + Class for codegen of an implementation of the DomObjectWrap trait. + """ + def __init__(self, descriptor): + CGThing.__init__(self) + self.descriptor = descriptor + + def define(self): + name = self.descriptor.concreteType + name = "dom::%s::%s" % (name.lower(), name) + return """\ +impl DomObjectWrap for %s { + const WRAP: unsafe fn( + SafeJSContext, + &GlobalScope, + Box<Self>, + ) -> Root<Dom<Self>> = Wrap; +} +""" % (name) + + +class CGDomObjectIteratorWrap(CGThing): + """ + Class for codegen of an implementation of the DomObjectIteratorWrap trait. + """ + def __init__(self, descriptor): + CGThing.__init__(self) + self.descriptor = descriptor + + def define(self): + assert self.descriptor.interface.isIteratorInterface() + name = self.descriptor.interface.iterableInterface.identifier.name + return """\ +impl DomObjectIteratorWrap for %s { + const ITER_WRAP: unsafe fn( + SafeJSContext, + &GlobalScope, + Box<IterableIterator<Self>>, + ) -> Root<Dom<IterableIterator<Self>>> = Wrap; +} +""" % (name) + + class CGAbstractExternMethod(CGAbstractMethod): """ Abstract base class for codegen of implementation-only (no @@ -4162,8 +4197,6 @@ class CGMemberJITInfo(CGThing): u.flatMemberTypes, "") if t.isDictionary(): return "JSVAL_TYPE_OBJECT" - if t.isDate(): - return "JSVAL_TYPE_OBJECT" if not t.isPrimitive(): raise TypeError("No idea what type " + str(t) + " is.") tag = t.tag() @@ -4233,8 +4266,6 @@ class CGMemberJITInfo(CGThing): u.flatMemberTypes, type) if t.isDictionary(): return "JSJitInfo_ArgType::Object as i32" - if t.isDate(): - return "JSJitInfo_ArgType::Object as i32" if not t.isPrimitive(): raise TypeError("No idea what type " + str(t) + " is.") tag = t.tag() @@ -4540,13 +4571,6 @@ class CGUnionConversionStruct(CGThing): else: arrayObject = None - dateObjectMemberTypes = filter(lambda t: t.isDate(), memberTypes) - if len(dateObjectMemberTypes) > 0: - assert len(dateObjectMemberTypes) == 1 - raise TypeError("Can't handle dates in unions.") - else: - dateObject = None - callbackMemberTypes = filter(lambda t: t.isCallback() or t.isCallbackInterface(), memberTypes) if len(callbackMemberTypes) > 0: assert len(callbackMemberTypes) == 1 @@ -4582,10 +4606,10 @@ class CGUnionConversionStruct(CGThing): else: mozMapObject = None - hasObjectTypes = object or interfaceObject or arrayObject or dateObject or callbackObject or mozMapObject + hasObjectTypes = object or interfaceObject or arrayObject or callbackObject or mozMapObject if hasObjectTypes: # "object" is not distinguishable from other types - assert not object or not (interfaceObject or arrayObject or dateObject or callbackObject or mozMapObject) + assert not object or not (interfaceObject or arrayObject or callbackObject or mozMapObject) templateBody = CGList([], "\n") if object: templateBody.append(object) @@ -6087,6 +6111,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries 'crate::dom::bindings::namespace::create_namespace_object', 'crate::dom::bindings::reflector::MutDomObject', 'crate::dom::bindings::reflector::DomObject', + 'crate::dom::bindings::reflector::DomObjectWrap', + 'crate::dom::bindings::reflector::DomObjectIteratorWrap', 'crate::dom::bindings::root::Dom', 'crate::dom::bindings::root::DomRoot', 'crate::dom::bindings::root::DomSlice', @@ -6306,6 +6332,10 @@ class CGDescriptor(CGThing): cgThings.append(CGWrapGlobalMethod(descriptor, properties)) else: cgThings.append(CGWrapMethod(descriptor)) + if descriptor.interface.isIteratorInterface(): + cgThings.append(CGDomObjectIteratorWrap(descriptor)) + else: + cgThings.append(CGDomObjectWrap(descriptor)) reexports.append('Wrap') haveUnscopables = False @@ -6848,7 +6878,7 @@ def type_needs_tracing(t): def is_typed_array(t): assert isinstance(t, IDLObject), (t, type(t)) - return t.isTypedArray() or t.isArrayBuffer() or t.isArrayBufferView() or t.isSharedArrayBuffer() + return t.isTypedArray() or t.isArrayBuffer() or t.isArrayBufferView() def type_needs_auto_root(t): @@ -7465,9 +7495,7 @@ class CGIterableMethodGenerator(CGGeneric): return CGGeneric.__init__(self, fill( """ - let result = ${iterClass}::new(&*this, - IteratorType::${itrMethod}, - super::${ifaceName}IteratorBinding::Wrap); + let result = ${iterClass}::new(&*this, IteratorType::${itrMethod}); """, iterClass=iteratorNativeType(descriptor, True), ifaceName=descriptor.interface.identifier.name, diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py index b2e56c9deaf..223fd7efbb4 100644 --- a/components/script/dom/bindings/codegen/parser/WebIDL.py +++ b/components/script/dom/bindings/codegen/parser/WebIDL.py @@ -481,9 +481,6 @@ class IDLExposureMixins(): def isExposedInWindow(self): return 'Window' in self.exposureSet - def isExposedOnMainThread(self): - return self.isExposedInWindow() - def isExposedInAnyWorker(self): return len(self.getWorkerExposureSet()) > 0 @@ -2090,9 +2087,9 @@ class IDLType(IDLObject): 'domstring', 'bytestring', 'usvstring', + 'utf8string', 'jsstring', 'object', - 'date', 'void', # Funny stuff 'interface', @@ -2109,15 +2106,17 @@ class IDLType(IDLObject): IDLObject.__init__(self, location) self.name = name self.builtin = False - self.clamp = False self.treatNullAsEmpty = False - self.enforceRange = False + self._clamp = False + self._enforceRange = False + self._allowShared = False self._extendedAttrDict = {} def __eq__(self, other): return (other and self.builtin == other.builtin and self.name == other.name and - self.clamp == other.clamp and self.enforceRange == other.enforceRange and - self.treatNullAsEmpty == other.treatNullAsEmpty) + self._clamp == other.hasClamp() and self._enforceRange == other.hasEnforceRange() and + self.treatNullAsEmpty == other.treatNullAsEmpty and + self._allowShared == other.hasAllowShared()) def __ne__(self, other): return not self == other @@ -2125,6 +2124,14 @@ class IDLType(IDLObject): def __str__(self): return str(self.name) + def prettyName(self): + """ + A name that looks like what this type is named in the IDL spec. By default + this is just our .name, but types that have more interesting spec + representations should override this. + """ + return str(self.name) + def isType(self): return True @@ -2152,6 +2159,9 @@ class IDLType(IDLObject): def isUSVString(self): return False + def isUTF8String(self): + return False + def isJSString(self): return False @@ -2173,12 +2183,12 @@ class IDLType(IDLObject): def isArrayBufferView(self): return False - def isSharedArrayBuffer(self): - return False - def isTypedArray(self): return False + def isBufferSource(self): + return self.isArrayBuffer() or self.isArrayBufferView() or self.isTypedArray() + def isCallbackInterface(self): return False @@ -2195,10 +2205,7 @@ class IDLType(IDLObject): def isSpiderMonkeyInterface(self): """ Returns a boolean indicating whether this type is an 'interface' type that is implemented in SpiderMonkey. """ - return self.isInterface() and (self.isArrayBuffer() or - self.isArrayBufferView() or - self.isSharedArrayBuffer() or - self.isTypedArray() or + return self.isInterface() and (self.isBufferSource() or self.isReadableStream()) def isDictionary(self): @@ -2210,9 +2217,6 @@ class IDLType(IDLObject): def isAny(self): return self.tag() == IDLType.Tags.any - def isDate(self): - return self.tag() == IDLType.Tags.date - def isObject(self): return self.tag() == IDLType.Tags.object @@ -2235,6 +2239,15 @@ class IDLType(IDLObject): def isJSONType(self): return False + def hasClamp(self): + return self._clamp + + def hasEnforceRange(self): + return self._enforceRange + + def hasAllowShared(self): + return self._allowShared + def tag(self): assert False # Override me! @@ -2342,10 +2355,7 @@ class IDLNullableType(IDLParametrizedType): assert not innerType.isVoid() assert not innerType == BuiltinTypes[IDLBuiltinType.Types.any] - name = innerType.name - if innerType.isComplete(): - name += "OrNull" - IDLParametrizedType.__init__(self, location, name, innerType) + IDLParametrizedType.__init__(self, location, None, innerType) def __eq__(self, other): return isinstance(other, IDLNullableType) and self.inner == other.inner @@ -2353,6 +2363,9 @@ class IDLNullableType(IDLParametrizedType): def __str__(self): return self.inner.__str__() + "OrNull" + def prettyName(self): + return self.inner.prettyName() + "?" + def nullable(self): return True @@ -2380,6 +2393,9 @@ class IDLNullableType(IDLParametrizedType): def isUSVString(self): return self.inner.isUSVString() + def isUTF8String(self): + return self.inner.isUTF8String() + def isJSString(self): return self.inner.isJSString() @@ -2410,9 +2426,6 @@ class IDLNullableType(IDLParametrizedType): def isArrayBufferView(self): return self.inner.isArrayBufferView() - def isSharedArrayBuffer(self): - return self.inner.isSharedArrayBuffer() - def isTypedArray(self): return self.inner.isTypedArray() @@ -2442,11 +2455,26 @@ class IDLNullableType(IDLParametrizedType): def isJSONType(self): return self.inner.isJSONType() + def hasClamp(self): + return self.inner.hasClamp() + + def hasEnforceRange(self): + return self.inner.hasEnforceRange() + + def hasAllowShared(self): + return self.inner.hasAllowShared() + + def isComplete(self): + return self.name is not None + def tag(self): return self.inner.tag() def complete(self, scope): - self.inner = self.inner.complete(scope) + if not self.inner.isComplete(): + self.inner = self.inner.complete(scope) + assert self.inner.isComplete() + if self.inner.nullable(): raise WebIDLError("The inner type of a nullable type must not be " "a nullable type", @@ -2456,6 +2484,10 @@ class IDLNullableType(IDLParametrizedType): raise WebIDLError("The inner type of a nullable type must not " "be a union type that itself has a nullable " "type as a member type", [self.location]) + if self.inner.isDOMString(): + if self.inner.treatNullAsEmpty: + raise WebIDLError("[TreatNullAs] not allowed on a nullable DOMString", + [self.location, self.inner.location]) self.name = self.inner.name + "OrNull" return self @@ -2469,6 +2501,13 @@ class IDLNullableType(IDLParametrizedType): return False return self.inner.isDistinguishableFrom(other) + def withExtendedAttributes(self, attrs): + # See https://github.com/heycam/webidl/issues/827#issuecomment-565131350 + # Allowing extended attributes to apply to a nullable type is an intermediate solution. + # A potential longer term solution is to introduce a null type and get rid of nullables. + # For example, we could do `([Clamp] long or null) foo` in the future. + return IDLNullableType(self.location, self.inner.withExtendedAttributes(attrs)) + class IDLSequenceType(IDLParametrizedType): def __init__(self, location, parameterType): @@ -2486,6 +2525,9 @@ class IDLSequenceType(IDLParametrizedType): def __str__(self): return self.inner.__str__() + "Sequence" + def prettyName(self): + return "sequence<%s>" % self.inner.prettyName() + def nullable(self): return False @@ -2504,6 +2546,9 @@ class IDLSequenceType(IDLParametrizedType): def isUSVString(self): return False + def isUTF8String(self): + return False + def isJSString(self): return False @@ -2540,8 +2585,7 @@ class IDLSequenceType(IDLParametrizedType): # Just forward to the union; it'll deal return other.isDistinguishableFrom(self) return (other.isPrimitive() or other.isString() or other.isEnum() or - other.isDate() or other.isInterface() or - other.isDictionary() or + other.isInterface() or other.isDictionary() or other.isCallback() or other.isRecord()) @@ -2565,6 +2609,9 @@ class IDLRecordType(IDLParametrizedType): def __str__(self): return self.keyType.__str__() + self.inner.__str__() + "Record" + def prettyName(self): + return "record<%s, %s>" % (self.keyType.prettyName(), self.inner.prettyName()) + def isRecord(self): return True @@ -2592,7 +2639,7 @@ class IDLRecordType(IDLParametrizedType): # Just forward to the union; it'll deal return other.isDistinguishableFrom(self) return (other.isPrimitive() or other.isString() or other.isEnum() or - other.isDate() or other.isNonCallbackInterface() or other.isSequence()) + other.isNonCallbackInterface() or other.isSequence()) def isExposedInAllOf(self, exposureSet): return self.inner.unroll().isExposedInAllOf(exposureSet) @@ -2614,6 +2661,9 @@ class IDLUnionType(IDLType): assert self.isComplete() return self.name.__hash__() + def prettyName(self): + return "(" + " or ".join(m.prettyName() for m in self.memberTypes) + ")" + def isVoid(self): return False @@ -2645,6 +2695,9 @@ class IDLUnionType(IDLType): return typeName(type._identifier.object()) if isinstance(type, IDLObjectWithIdentifier): return typeName(type.identifier) + if isinstance(type, IDLBuiltinType) and type.hasAllowShared(): + assert type.isBufferSource() + return "MaybeShared" + type.name return type.name for (i, type) in enumerate(self.memberTypes): @@ -2768,6 +2821,9 @@ class IDLTypedefType(IDLType): def isUSVString(self): return self.inner.isUSVString() + def isUTF8String(self): + return self.inner.isUTF8String() + def isJSString(self): return self.inner.isJSString() @@ -2795,9 +2851,6 @@ class IDLTypedefType(IDLType): def isArrayBufferView(self): return self.inner.isArrayBufferView() - def isSharedArrayBuffer(self): - return self.inner.isSharedArrayBuffer() - def isTypedArray(self): return self.inner.isTypedArray() @@ -2901,6 +2954,9 @@ class IDLWrapperType(IDLType): def isUSVString(self): return False + def isUTF8String(self): + return False + def isJSString(self): return False @@ -2976,11 +3032,11 @@ class IDLWrapperType(IDLType): if self.isEnum(): return (other.isPrimitive() or other.isInterface() or other.isObject() or other.isCallback() or other.isDictionary() or - other.isSequence() or other.isRecord() or other.isDate()) + other.isSequence() or other.isRecord()) if self.isDictionary() and other.nullable(): return False if (other.isPrimitive() or other.isString() or other.isEnum() or - other.isDate() or other.isSequence()): + other.isSequence()): return True if self.isDictionary(): return other.isNonCallbackInterface() @@ -3052,6 +3108,9 @@ class IDLPromiseType(IDLParametrizedType): def __str__(self): return self.inner.__str__() + "Promise" + def prettyName(self): + return "Promise<%s>" % self.inner.prettyName() + def isPromise(self): return True @@ -3104,14 +3163,13 @@ class IDLBuiltinType(IDLType): 'domstring', 'bytestring', 'usvstring', + 'utf8string', 'jsstring', 'object', - 'date', 'void', # Funny stuff 'ArrayBuffer', 'ArrayBufferView', - 'SharedArrayBuffer', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', @@ -3142,13 +3200,12 @@ class IDLBuiltinType(IDLType): Types.domstring: IDLType.Tags.domstring, Types.bytestring: IDLType.Tags.bytestring, Types.usvstring: IDLType.Tags.usvstring, + Types.utf8string: IDLType.Tags.utf8string, Types.jsstring: IDLType.Tags.jsstring, Types.object: IDLType.Tags.object, - Types.date: IDLType.Tags.date, Types.void: IDLType.Tags.void, Types.ArrayBuffer: IDLType.Tags.interface, Types.ArrayBufferView: IDLType.Tags.interface, - Types.SharedArrayBuffer: IDLType.Tags.interface, Types.Int8Array: IDLType.Tags.interface, Types.Uint8Array: IDLType.Tags.interface, Types.Uint8ClampedArray: IDLType.Tags.interface, @@ -3161,11 +3218,48 @@ class IDLBuiltinType(IDLType): Types.ReadableStream: IDLType.Tags.interface, } + PrettyNames = { + Types.byte: "byte", + Types.octet: "octet", + Types.short: "short", + Types.unsigned_short: "unsigned short", + Types.long: "long", + Types.unsigned_long: "unsigned long", + Types.long_long: "long long", + Types.unsigned_long_long: "unsigned long long", + Types.boolean: "boolean", + Types.unrestricted_float: "unrestricted float", + Types.float: "float", + Types.unrestricted_double: "unrestricted double", + Types.double: "double", + Types.any: "any", + Types.domstring: "DOMString", + Types.bytestring: "ByteString", + Types.usvstring: "USVString", + Types.utf8string: "USVString", # That's what it is in spec terms + Types.jsstring: "USVString", # Again, that's what it is in spec terms + Types.object: "object", + Types.void: "void", + Types.ArrayBuffer: "ArrayBuffer", + Types.ArrayBufferView: "ArrayBufferView", + Types.Int8Array: "Int8Array", + Types.Uint8Array: "Uint8Array", + Types.Uint8ClampedArray: "Uint8ClampedArray", + Types.Int16Array: "Int16Array", + Types.Uint16Array: "Uint16Array", + Types.Int32Array: "Int32Array", + Types.Uint32Array: "Uint32Array", + Types.Float32Array: "Float32Array", + Types.Float64Array: "Float64Array", + Types.ReadableStream: "ReadableStream", + } + def __init__(self, location, name, type, clamp=False, enforceRange=False, treatNullAsEmpty=False, - attrLocation=[]): + allowShared=False, attrLocation=[]): """ - The mutually exclusive clamp/enforceRange/treatNullAsEmpty arguments are used to create instances - of this type with the appropriate attributes attached. Use .clamped(), .rangeEnforced(), and .treatNullAs(). + The mutually exclusive clamp/enforceRange/treatNullAsEmpty/allowShared arguments are used + to create instances of this type with the appropriate attributes attached. Use .clamped(), + .rangeEnforced(), .withTreatNullAs() and .withAllowShared(). attrLocation is an array of source locations of these attributes for error reporting. """ @@ -3175,24 +3269,40 @@ class IDLBuiltinType(IDLType): self._clamped = None self._rangeEnforced = None self._withTreatNullAs = None - if self.isNumeric(): + self._withAllowShared = None; + if self.isInteger(): if clamp: - self.clamp = True + self._clamp = True self.name = "Clamped" + self.name self._extendedAttrDict["Clamp"] = True elif enforceRange: - self.enforceRange = True + self._enforceRange = True self.name = "RangeEnforced" + self.name self._extendedAttrDict["EnforceRange"] = True elif clamp or enforceRange: - raise WebIDLError("Non-numeric types cannot be [Clamp] or [EnforceRange]", attrLocation) - if self.isDOMString(): + raise WebIDLError("Non-integer types cannot be [Clamp] or [EnforceRange]", attrLocation) + if self.isDOMString() or self.isUTF8String(): if treatNullAsEmpty: self.treatNullAsEmpty = True self.name = "NullIsEmpty" + self.name self._extendedAttrDict["TreatNullAs"] = ["EmptyString"] elif treatNullAsEmpty: raise WebIDLError("Non-string types cannot be [TreatNullAs]", attrLocation) + if self.isBufferSource(): + if allowShared: + self._allowShared = True + self._extendedAttrDict["AllowShared"] = True + elif allowShared: + raise WebIDLError("Types that are not buffer source types cannot be [AllowShared]", attrLocation) + + def __str__(self): + if self._allowShared: + assert self.isBufferSource() + return "MaybeShared" + str(self.name) + return str(self.name) + + def prettyName(self): + return IDLBuiltinType.PrettyNames[self._typeTag] def clamped(self, attrLocation): if not self._clamped: @@ -3215,6 +3325,13 @@ class IDLBuiltinType(IDLType): attrLocation=attrLocation) return self._withTreatNullAs + def withAllowShared(self, attrLocation): + if not self._withAllowShared: + self._withAllowShared = IDLBuiltinType(self.location, self.name, + self._typeTag, allowShared=True, + attrLocation=attrLocation) + return self._withAllowShared + def isPrimitive(self): return self._typeTag <= IDLBuiltinType.Types.double @@ -3228,6 +3345,7 @@ class IDLBuiltinType(IDLType): return (self._typeTag == IDLBuiltinType.Types.domstring or self._typeTag == IDLBuiltinType.Types.bytestring or self._typeTag == IDLBuiltinType.Types.usvstring or + self._typeTag == IDLBuiltinType.Types.utf8string or self._typeTag == IDLBuiltinType.Types.jsstring) def isByteString(self): @@ -3239,6 +3357,9 @@ class IDLBuiltinType(IDLType): def isUSVString(self): return self._typeTag == IDLBuiltinType.Types.usvstring + def isUTF8String(self): + return self._typeTag == IDLBuiltinType.Types.utf8string + def isJSString(self): return self._typeTag == IDLBuiltinType.Types.jsstring @@ -3251,9 +3372,6 @@ class IDLBuiltinType(IDLType): def isArrayBufferView(self): return self._typeTag == IDLBuiltinType.Types.ArrayBufferView - def isSharedArrayBuffer(self): - return self._typeTag == IDLBuiltinType.Types.SharedArrayBuffer - def isTypedArray(self): return (self._typeTag >= IDLBuiltinType.Types.Int8Array and self._typeTag <= IDLBuiltinType.Types.Float64Array) @@ -3267,7 +3385,6 @@ class IDLBuiltinType(IDLType): # all of it internally. return (self.isArrayBuffer() or self.isArrayBufferView() or - self.isSharedArrayBuffer() or self.isTypedArray() or self.isReadableStream()) @@ -3305,27 +3422,22 @@ class IDLBuiltinType(IDLType): return (other.isNumeric() or other.isString() or other.isEnum() or other.isInterface() or other.isObject() or other.isCallback() or other.isDictionary() or - other.isSequence() or other.isRecord() or other.isDate()) + other.isSequence() or other.isRecord()) if self.isNumeric(): return (other.isBoolean() or other.isString() or other.isEnum() or other.isInterface() or other.isObject() or other.isCallback() or other.isDictionary() or - other.isSequence() or other.isRecord() or other.isDate()) + other.isSequence() or other.isRecord()) if self.isString(): return (other.isPrimitive() or other.isInterface() or other.isObject() or other.isCallback() or other.isDictionary() or - other.isSequence() or other.isRecord() or other.isDate()) + other.isSequence() or other.isRecord()) if self.isAny(): # Can't tell "any" apart from anything return False if self.isObject(): return other.isPrimitive() or other.isString() or other.isEnum() - if self.isDate(): - return (other.isPrimitive() or other.isString() or other.isEnum() or - other.isInterface() or other.isCallback() or - other.isDictionary() or other.isSequence() or - other.isRecord()) if self.isVoid(): return not other.isVoid() # Not much else we could be! @@ -3333,12 +3445,11 @@ class IDLBuiltinType(IDLType): # Like interfaces, but we know we're not a callback return (other.isPrimitive() or other.isString() or other.isEnum() or other.isCallback() or other.isDictionary() or - other.isSequence() or other.isRecord() or other.isDate() or + other.isSequence() or other.isRecord() or (other.isInterface() and ( # ArrayBuffer is distinguishable from everything # that's not an ArrayBuffer or a callback interface (self.isArrayBuffer() and not other.isArrayBuffer()) or - (self.isSharedArrayBuffer() and not other.isSharedArrayBuffer()) or (self.isReadableStream() and not other.isReadableStream()) or # ArrayBufferView is distinguishable from everything # that's not an ArrayBufferView or typed array. @@ -3361,7 +3472,7 @@ class IDLBuiltinType(IDLType): if not attribute.noArguments(): raise WebIDLError("[Clamp] must take no arguments", [attribute.location]) - if ret.enforceRange or self.enforceRange: + if ret.hasEnforceRange() or self._enforceRange: raise WebIDLError("[EnforceRange] and [Clamp] are mutually exclusive", [self.location, attribute.location]) ret = self.clamped([self.location, attribute.location]) @@ -3369,17 +3480,17 @@ class IDLBuiltinType(IDLType): if not attribute.noArguments(): raise WebIDLError("[EnforceRange] must take no arguments", [attribute.location]) - if ret.clamp or self.clamp: + if ret.hasClamp() or self._clamp: raise WebIDLError("[EnforceRange] and [Clamp] are mutually exclusive", [self.location, attribute.location]) ret = self.rangeEnforced([self.location, attribute.location]) elif identifier == "TreatNullAs": - if not self.isDOMString(): - raise WebIDLError("[TreatNullAs] only allowed on DOMStrings", + if not (self.isDOMString() or self.isUTF8String()): + raise WebIDLError("[TreatNullAs] only allowed on DOMStrings and UTF8Strings", [self.location, attribute.location]) assert not self.nullable() if not attribute.hasValue(): - raise WebIDLError("[TreatNullAs] must take an identifier argument" + raise WebIDLError("[TreatNullAs] must take an identifier argument", [attribute.location]) value = attribute.value() if value != 'EmptyString': @@ -3387,6 +3498,15 @@ class IDLBuiltinType(IDLType): "'EmptyString', not '%s'" % value, [attribute.location]) ret = self.withTreatNullAs([self.location, attribute.location]) + elif identifier == "AllowShared": + if not attribute.noArguments(): + raise WebIDLError("[AllowShared] must take no arguments", + [attribute.location]) + if not self.isBufferSource(): + raise WebIDLError("[AllowShared] only allowed on buffer source types", + [self.location, attribute.location]) + ret = self.withAllowShared([self.location, attribute.location]) + else: raise WebIDLError("Unhandled extended attribute on type", [self.location, attribute.location]) @@ -3444,15 +3564,15 @@ BuiltinTypes = { IDLBuiltinType.Types.usvstring: IDLBuiltinType(BuiltinLocation("<builtin type>"), "USVString", IDLBuiltinType.Types.usvstring), + IDLBuiltinType.Types.utf8string: + IDLBuiltinType(BuiltinLocation("<builtin type>"), "UTF8String", + IDLBuiltinType.Types.utf8string), IDLBuiltinType.Types.jsstring: IDLBuiltinType(BuiltinLocation("<builtin type>"), "JSString", IDLBuiltinType.Types.jsstring), IDLBuiltinType.Types.object: IDLBuiltinType(BuiltinLocation("<builtin type>"), "Object", IDLBuiltinType.Types.object), - IDLBuiltinType.Types.date: - IDLBuiltinType(BuiltinLocation("<builtin type>"), "Date", - IDLBuiltinType.Types.date), IDLBuiltinType.Types.void: IDLBuiltinType(BuiltinLocation("<builtin type>"), "Void", IDLBuiltinType.Types.void), @@ -3462,9 +3582,6 @@ BuiltinTypes = { IDLBuiltinType.Types.ArrayBufferView: IDLBuiltinType(BuiltinLocation("<builtin type>"), "ArrayBufferView", IDLBuiltinType.Types.ArrayBufferView), - IDLBuiltinType.Types.SharedArrayBuffer: - IDLBuiltinType(BuiltinLocation("<builtin type>"), "SharedArrayBuffer", - IDLBuiltinType.Types.SharedArrayBuffer), IDLBuiltinType.Types.Int8Array: IDLBuiltinType(BuiltinLocation("<builtin type>"), "Int8Array", IDLBuiltinType.Types.Int8Array), @@ -3613,8 +3730,9 @@ class IDLValue(IDLObject): # TreatNullAsEmpty is a different type for resolution reasons, # however once you have a value it doesn't matter return self - elif self.type.isString() and (type.isByteString() or type.isJSString()): - # Allow ByteStrings and JSStrings to use a default value like DOMString. + elif self.type.isString() and (type.isByteString() or type.isJSString() or type.isUTF8String()): + # Allow ByteStrings, UTF8String, and JSStrings to use a default + # value like DOMString. # No coercion is required as Codegen.py will handle the # extra steps. We want to make sure that our string contains # only valid characters, so we check that here. @@ -4307,8 +4425,9 @@ class IDLAttribute(IDLInterfaceMember): assert not isinstance(t.name, IDLUnresolvedIdentifier) self.type = t - if self.readonly and (self.type.clamp or self.type.enforceRange or self.type.treatNullAsEmpty): - raise WebIDLError("A readonly attribute cannot be [Clamp] or [EnforceRange]", + if self.readonly and (self.type.hasClamp() or self.type.hasEnforceRange() or + self.type.hasAllowShared() or self.type.treatNullAsEmpty): + raise WebIDLError("A readonly attribute cannot be [Clamp] or [EnforceRange] or [AllowShared]", [self.location]) if self.type.isDictionary() and not self.getExtendedAttribute("Cached"): raise WebIDLError("An attribute cannot be of a dictionary type", @@ -4709,7 +4828,7 @@ class IDLArgument(IDLObjectWithIdentifier): for attribute in attrs: identifier = attribute.identifier() if self.allowTypeAttributes and (identifier == "EnforceRange" or identifier == "Clamp" or - identifier == "TreatNullAs"): + identifier == "TreatNullAs" or identifier == "AllowShared"): self.type = self.type.withExtendedAttributes([attribute]) elif identifier == "TreatNonCallableAsNull": self._allowTreatNonCallableAsNull = True @@ -4879,8 +4998,7 @@ class IDLCallbackType(IDLType): # Just forward to the union; it'll deal return other.isDistinguishableFrom(self) return (other.isPrimitive() or other.isString() or other.isEnum() or - other.isNonCallbackInterface() or other.isDate() or - other.isSequence()) + other.isNonCallbackInterface() or other.isSequence()) def _getDependentObjects(self): return self.callback._getDependentObjects() @@ -5475,7 +5593,9 @@ class IDLConstructor(IDLMethod): identifier == "ChromeOnly" or identifier == "NewObject" or identifier == "SecureContext" or - identifier == "Throws"): + identifier == "Throws" or + identifier == "Func" or + identifier == "Pref"): IDLMethod.handleExtendedAttribute(self, attr) elif identifier == "HTMLConstructor": if not attr.noArguments(): @@ -5675,11 +5795,11 @@ class Tokenizer(object): "optional": "OPTIONAL", "...": "ELLIPSIS", "::": "SCOPE", - "Date": "DATE", "DOMString": "DOMSTRING", "ByteString": "BYTESTRING", "USVString": "USVSTRING", "JSString": "JSSTRING", + "UTF8String": "UTF8STRING", "any": "ANY", "boolean": "BOOLEAN", "byte": "BYTE", @@ -5709,7 +5829,6 @@ class Tokenizer(object): "<": "LT", ">": "GT", "ArrayBuffer": "ARRAYBUFFER", - "SharedArrayBuffer": "SHAREDARRAYBUFFER", "or": "OR", "maplike": "MAPLIKE", "setlike": "SETLIKE", @@ -6939,10 +7058,10 @@ class Parser(Tokenizer): | EQUALS | GT | QUESTIONMARK - | DATE | DOMSTRING | BYTESTRING | USVSTRING + | UTF8STRING | JSSTRING | PROMISE | ANY @@ -7050,7 +7169,6 @@ class Parser(Tokenizer): """ DistinguishableType : PrimitiveType Null | ARRAYBUFFER Null - | SHAREDARRAYBUFFER Null | READABLESTREAM Null | OBJECT Null """ @@ -7058,8 +7176,6 @@ class Parser(Tokenizer): type = BuiltinTypes[IDLBuiltinType.Types.object] elif p[1] == "ArrayBuffer": type = BuiltinTypes[IDLBuiltinType.Types.ArrayBuffer] - elif p[1] == "SharedArrayBuffer": - type = BuiltinTypes[IDLBuiltinType.Types.SharedArrayBuffer] elif p[1] == "ReadableStream": type = BuiltinTypes[IDLBuiltinType.Types.ReadableStream] else: @@ -7122,13 +7238,6 @@ class Parser(Tokenizer): type = IDLUnresolvedType(self.getLocation(p, 1), p[1]) p[0] = self.handleNullable(type, p[2]) - def p_DistinguishableTypeDate(self, p): - """ - DistinguishableType : DATE Null - """ - p[0] = self.handleNullable(BuiltinTypes[IDLBuiltinType.Types.date], - p[2]) - def p_ConstType(self, p): """ ConstType : PrimitiveType @@ -7215,6 +7324,12 @@ class Parser(Tokenizer): """ p[0] = IDLBuiltinType.Types.usvstring + def p_BuiltinStringTypeUTF8String(self, p): + """ + BuiltinStringType : UTF8STRING + """ + p[0] = IDLBuiltinType.Types.utf8string + def p_BuiltinStringTypeJSString(self, p): """ BuiltinStringType : JSSTRING @@ -7354,7 +7469,13 @@ class Parser(Tokenizer): IdentifierList : IDENTIFIER Identifiers """ idents = list(p[2]) - idents.insert(0, p[1]) + # This is only used for identifier-list-valued extended attributes, and if + # we're going to restrict to IDENTIFIER here we should at least allow + # escaping with leading '_' as usual for identifiers. + ident = p[1] + if ident[0] == '_': + ident = ident[1:] + idents.insert(0, ident) p[0] = idents def p_IdentifiersList(self, p): @@ -7362,7 +7483,13 @@ class Parser(Tokenizer): Identifiers : COMMA IDENTIFIER Identifiers """ idents = list(p[3]) - idents.insert(0, p[2]) + # This is only used for identifier-list-valued extended attributes, and if + # we're going to restrict to IDENTIFIER here we should at least allow + # escaping with leading '_' as usual for identifiers. + ident = p[2] + if ident[0] == '_': + ident = ident[1:] + idents.insert(0, ident) p[0] = idents def p_IdentifiersEmpty(self, p): diff --git a/components/script/dom/bindings/codegen/parser/ext-attribute-no-value-error.patch b/components/script/dom/bindings/codegen/parser/ext-attribute-no-value-error.patch new file mode 100644 index 00000000000..210134d8ca6 --- /dev/null +++ b/components/script/dom/bindings/codegen/parser/ext-attribute-no-value-error.patch @@ -0,0 +1,11 @@ +--- WebIDL.py ++++ WebIDL.py +@@ -3490,7 +3490,7 @@ class IDLBuiltinType(IDLType): + [self.location, attribute.location]) + assert not self.nullable() + if not attribute.hasValue(): +- raise WebIDLError("[TreatNullAs] must take an identifier argument" ++ raise WebIDLError("[TreatNullAs] must take an identifier argument", + [attribute.location]) + value = attribute.value() + if value != 'EmptyString': diff --git a/components/script/dom/bindings/codegen/parser/tests/test_attributes_on_types.py b/components/script/dom/bindings/codegen/parser/tests/test_attributes_on_types.py index 43daca3c453..ff08791d16f 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_attributes_on_types.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_attributes_on_types.py @@ -25,6 +25,12 @@ def WebIDLTest(parser, harness): void method2(optional [EnforceRange] long foo, optional [Clamp] long bar, optional [TreatNullAs=EmptyString] DOMString baz); }; + interface C { + attribute [EnforceRange] long? foo; + attribute [Clamp] long? bar; + void method([EnforceRange] long? foo, [Clamp] long? bar); + void method2(optional [EnforceRange] long? foo, optional [Clamp] long? bar); + }; interface Setlike { setlike<[Clamp] long>; }; @@ -41,29 +47,105 @@ def WebIDLTest(parser, harness): harness.ok(not threw, "Should not have thrown on parsing normal") if not threw: - harness.check(results[0].innerType.enforceRange, True, "Foo is [EnforceRange]") - harness.check(results[1].innerType.clamp, True, "Bar is [Clamp]") + harness.check(results[0].innerType.hasEnforceRange(), True, "Foo is [EnforceRange]") + harness.check(results[1].innerType.hasClamp(), True, "Bar is [Clamp]") harness.check(results[2].innerType.treatNullAsEmpty, True, "Baz is [TreatNullAs=EmptyString]") A = results[3] - harness.check(A.members[0].type.enforceRange, True, "A.a is [EnforceRange]") - harness.check(A.members[1].type.clamp, True, "A.b is [Clamp]") - harness.check(A.members[2].type.enforceRange, True, "A.c is [EnforceRange]") - harness.check(A.members[3].type.enforceRange, True, "A.d is [EnforceRange]") + harness.check(A.members[0].type.hasEnforceRange(), True, "A.a is [EnforceRange]") + harness.check(A.members[1].type.hasClamp(), True, "A.b is [Clamp]") + harness.check(A.members[2].type.hasEnforceRange(), True, "A.c is [EnforceRange]") + harness.check(A.members[3].type.hasEnforceRange(), True, "A.d is [EnforceRange]") B = results[4] - harness.check(B.members[0].type.enforceRange, True, "B.typedefFoo is [EnforceRange]") - harness.check(B.members[1].type.enforceRange, True, "B.foo is [EnforceRange]") - harness.check(B.members[2].type.clamp, True, "B.bar is [Clamp]") + harness.check(B.members[0].type.hasEnforceRange(), True, "B.typedefFoo is [EnforceRange]") + harness.check(B.members[1].type.hasEnforceRange(), True, "B.foo is [EnforceRange]") + harness.check(B.members[2].type.hasClamp(), True, "B.bar is [Clamp]") harness.check(B.members[3].type.treatNullAsEmpty, True, "B.baz is [TreatNullAs=EmptyString]") method = B.members[4].signatures()[0][1] - harness.check(method[0].type.enforceRange, True, "foo argument of method is [EnforceRange]") - harness.check(method[1].type.clamp, True, "bar argument of method is [Clamp]") + harness.check(method[0].type.hasEnforceRange(), True, "foo argument of method is [EnforceRange]") + harness.check(method[1].type.hasClamp(), True, "bar argument of method is [Clamp]") harness.check(method[2].type.treatNullAsEmpty, True, "baz argument of method is [TreatNullAs=EmptyString]") method2 = B.members[5].signatures()[0][1] - harness.check(method[0].type.enforceRange, True, "foo argument of method2 is [EnforceRange]") - harness.check(method[1].type.clamp, True, "bar argument of method2 is [Clamp]") + harness.check(method[0].type.hasEnforceRange(), True, "foo argument of method2 is [EnforceRange]") + harness.check(method[1].type.hasClamp(), True, "bar argument of method2 is [Clamp]") harness.check(method[2].type.treatNullAsEmpty, True, "baz argument of method2 is [TreatNullAs=EmptyString]") + C = results[5] + harness.ok(C.members[0].type.nullable(), "C.foo is nullable") + harness.ok(C.members[0].type.hasEnforceRange(), "C.foo has [EnforceRange]") + harness.ok(C.members[1].type.nullable(), "C.bar is nullable") + harness.ok(C.members[1].type.hasClamp(), "C.bar has [Clamp]") + method = C.members[2].signatures()[0][1] + harness.ok(method[0].type.nullable(), "foo argument of method is nullable") + harness.ok(method[0].type.hasEnforceRange(), "foo argument of method has [EnforceRange]") + harness.ok(method[1].type.nullable(), "bar argument of method is nullable") + harness.ok(method[1].type.hasClamp(), "bar argument of method has [Clamp]") + method2 = C.members[3].signatures()[0][1] + harness.ok(method2[0].type.nullable(), "foo argument of method2 is nullable") + harness.ok(method2[0].type.hasEnforceRange(), "foo argument of method2 has [EnforceRange]") + harness.ok(method2[1].type.nullable(), "bar argument of method2 is nullable") + harness.ok(method2[1].type.hasClamp(), "bar argument of method2 has [Clamp]") + + # Test [AllowShared] + parser = parser.reset() + threw = False + try: + parser.parse(""" + typedef [AllowShared] ArrayBufferView Foo; + dictionary A { + required [AllowShared] ArrayBufferView a; + [ChromeOnly, AllowShared] ArrayBufferView b; + Foo c; + }; + interface B { + attribute Foo typedefFoo; + attribute [AllowShared] ArrayBufferView foo; + void method([AllowShared] ArrayBufferView foo); + void method2(optional [AllowShared] ArrayBufferView foo); + }; + interface C { + attribute [AllowShared] ArrayBufferView? foo; + void method([AllowShared] ArrayBufferView? foo); + void method2(optional [AllowShared] ArrayBufferView? foo); + }; + interface Setlike { + setlike<[AllowShared] ArrayBufferView>; + }; + interface Maplike { + maplike<[Clamp] long, [AllowShared] ArrayBufferView>; + }; + interface Iterable { + iterable<[Clamp] long, [AllowShared] ArrayBufferView>; + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(not threw, "Should not have thrown on parsing normal") + if not threw: + harness.ok(results[0].innerType.hasAllowShared(), "Foo is [AllowShared]") + A = results[1] + harness.ok(A.members[0].type.hasAllowShared(), "A.a is [AllowShared]") + harness.ok(A.members[1].type.hasAllowShared(), "A.b is [AllowShared]") + harness.ok(A.members[2].type.hasAllowShared(), "A.c is [AllowShared]") + B = results[2] + harness.ok(B.members[0].type.hasAllowShared(), "B.typedefFoo is [AllowShared]") + harness.ok(B.members[1].type.hasAllowShared(), "B.foo is [AllowShared]") + method = B.members[2].signatures()[0][1] + harness.ok(method[0].type.hasAllowShared(), "foo argument of method is [AllowShared]") + method2 = B.members[3].signatures()[0][1] + harness.ok(method2[0].type.hasAllowShared(), "foo argument of method2 is [AllowShared]") + C = results[3] + harness.ok(C.members[0].type.nullable(), "C.foo is nullable") + harness.ok(C.members[0].type.hasAllowShared(), "C.foo is [AllowShared]") + method = C.members[1].signatures()[0][1] + harness.ok(method[0].type.nullable(), "foo argument of method is nullable") + harness.ok(method[0].type.hasAllowShared(), "foo argument of method is [AllowShared]") + method2 = C.members[2].signatures()[0][1] + harness.ok(method2[0].type.nullable(), "foo argument of method2 is nullable") + harness.ok(method2[0].type.hasAllowShared(), "foo argument of method2 is [AllowShared]") - ATTRIBUTES = [("[Clamp]", "long"), ("[EnforceRange]", "long"), ("[TreatNullAs=EmptyString]", "DOMString")] + ATTRIBUTES = [("[Clamp]", "long"), ("[EnforceRange]", "long"), + ("[TreatNullAs=EmptyString]", "DOMString"), ("[AllowShared]", "ArrayBufferView")] TEMPLATES = [ ("required dictionary members", """ dictionary Foo { @@ -93,7 +175,54 @@ def WebIDLTest(parser, harness): readonly attribute Bar baz; }; typedef %s %s Bar; - """) + """), + ("method", """ + interface Foo { + %s %s foo(); + }; + """), + ("interface",""" + %s + interface Foo { + attribute %s foo; + }; + """), + ("partial interface",""" + interface Foo { + void foo(); + }; + %s + partial interface Foo { + attribute %s bar; + }; + """), + ("interface mixin",""" + %s + interface mixin Foo { + attribute %s foo; + }; + """), + ("namespace",""" + %s + namespace Foo { + attribute %s foo; + }; + """), + ("partial namespace",""" + namespace Foo { + void foo(); + }; + %s + partial namespace Foo { + attribute %s bar; + }; + """), + ("dictionary",""" + %s + dictionary Foo { + %s foo; + }; + """) ]; for (name, template) in TEMPLATES: @@ -167,55 +296,91 @@ def WebIDLTest(parser, harness): harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs") + TYPES = ["DOMString", "unrestricted float", "float", "unrestricted double", "double"] + + for type in TYPES: + parser = parser.reset() + threw = False + try: + parser.parse(""" + typedef [Clamp] %s Foo; + """ % type) + parser.finish() + except: + threw = True + + harness.ok(threw, "Should not allow [Clamp] on %s" % type) + + parser = parser.reset() + threw = False + try: + parser.parse(""" + typedef [EnforceRange] %s Foo; + """ % type) + parser.finish() + except: + threw = True + + harness.ok(threw, "Should not allow [EnforceRange] on %s" % type) + + parser = parser.reset() threw = False try: parser.parse(""" - typedef [Clamp] DOMString Foo; + typedef [TreatNullAs=EmptyString] long Foo; """) parser.finish() except: threw = True - harness.ok(threw, "Should not allow [Clamp] on DOMString") - + harness.ok(threw, "Should not allow [TreatNullAs] on long") parser = parser.reset() threw = False try: parser.parse(""" - typedef [EnforceRange] DOMString Foo; + typedef [TreatNullAs=EmptyString] JSString Foo; """) parser.finish() except: threw = True - harness.ok(threw, "Should not allow [EnforceRange] on DOMString") - + harness.ok(threw, "Should not allow [TreatNullAs] on JSString") parser = parser.reset() threw = False try: parser.parse(""" - typedef [TreatNullAs=EmptyString] long Foo; + typedef [TreatNullAs=EmptyString] DOMString? Foo; """) parser.finish() except: threw = True - harness.ok(threw, "Should not allow [TreatNullAs] on long") + harness.ok(threw, "Should not allow [TreatNullAs] on nullable DOMString") parser = parser.reset() threw = False try: parser.parse(""" - typedef [TreatNullAs=EmptyString] JSString Foo; + typedef [AllowShared] DOMString Foo; """) - parser.finish() + results = parser.finish() except: threw = True + harness.ok(threw, "[AllowShared] only allowed on buffer source types") - harness.ok(threw, "Should not allow [TreatNullAs] on JSString") + parser = parser.reset() + threw = False + try: + parser.parse(""" + typedef [AllowShared=something] ArrayBufferView Foo; + """) + results = parser.finish() + except: + threw = True + harness.ok(threw, "[AllowShared] must take no arguments") parser = parser.reset() threw = False @@ -230,7 +395,7 @@ def WebIDLTest(parser, harness): except: threw = True harness.ok(not threw, "Should allow type attributes on unresolved types") - harness.check(results[0].members[0].signatures()[0][1][0].type.clamp, True, + harness.check(results[0].members[0].signatures()[0][1][0].type.hasClamp(), True, "Unresolved types with type attributes should correctly resolve with attributes") parser = parser.reset() @@ -246,5 +411,5 @@ def WebIDLTest(parser, harness): except: threw = True harness.ok(not threw, "Should allow type attributes on typedefs") - harness.check(results[0].members[0].signatures()[0][1][0].type.clamp, True, + harness.check(results[0].members[0].signatures()[0][1][0].type.hasClamp(), True, "Unresolved types that resolve to typedefs with attributes should correctly resolve with attributes") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py index 721f9c2089e..83e1f4fc34f 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_constructor.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_constructor.py @@ -11,9 +11,9 @@ def WebIDLTest(parser, harness): harness.check(argument.variadic, variadic, "Argument has the right variadic value") def checkMethod(method, QName, name, signatures, - static=True, getter=False, setter=False, - deleter=False, legacycaller=False, stringifier=False, - chromeOnly=False, htmlConstructor=False): + static=True, getter=False, setter=False, deleter=False, + legacycaller=False, stringifier=False, chromeOnly=False, + htmlConstructor=False, secureContext=False, pref=None, func=None): harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod") harness.ok(method.isMethod(), "Method is a method") @@ -30,6 +30,9 @@ def WebIDLTest(parser, harness): harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly") harness.check(method.isHTMLConstructor(), htmlConstructor, "Method has the correct htmlConstructor value") harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures") + harness.check(method.getExtendedAttribute("Pref"), pref, "Method has the correct pref value") + harness.check(method.getExtendedAttribute("Func"), func, "Method has the correct func value") + harness.check(method.getExtendedAttribute("SecureContext") is not None, secureContext, "Method has the correct SecureContext value") sigpairs = zip(method.signatures(), signatures) for (gotSignature, expectedSignature) in sigpairs: @@ -90,6 +93,21 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" + interface TestPrefConstructor { + [Pref="dom.webidl.test1"] constructor(); + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestPrefConstructor::constructor", + "constructor", [("TestPrefConstructor (Wrapper)", [])], + pref=["dom.webidl.test1"]) + + parser = parser.reset() + parser.parse(""" interface TestChromeOnlyConstructor { [ChromeOnly] constructor(); }; @@ -105,6 +123,53 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" + interface TestSCConstructor { + [SecureContext] constructor(); + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestSCConstructor::constructor", + "constructor", [("TestSCConstructor (Wrapper)", [])], + secureContext=True) + + parser = parser.reset() + parser.parse(""" + interface TestFuncConstructor { + [Func="Document::IsWebAnimationsEnabled"] constructor(); + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestFuncConstructor::constructor", + "constructor", [("TestFuncConstructor (Wrapper)", [])], + func=["Document::IsWebAnimationsEnabled"]) + + parser = parser.reset() + parser.parse(""" + interface TestPrefChromeOnlySCFuncConstructor { + [ChromeOnly, Pref="dom.webidl.test1", SecureContext, Func="Document::IsWebAnimationsEnabled"] + constructor(); + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestPrefChromeOnlySCFuncConstructor::constructor", + "constructor", [("TestPrefChromeOnlySCFuncConstructor (Wrapper)", [])], + func=["Document::IsWebAnimationsEnabled"], pref=["dom.webidl.test1"], + chromeOnly=True, secureContext=True) + + parser = parser.reset() + parser.parse(""" interface TestHTMLConstructor { [HTMLConstructor] constructor(); }; diff --git a/components/script/dom/bindings/codegen/parser/tests/test_date.py b/components/script/dom/bindings/codegen/parser/tests/test_date.py deleted file mode 100644 index 2bdfc95e14f..00000000000 --- a/components/script/dom/bindings/codegen/parser/tests/test_date.py +++ /dev/null @@ -1,15 +0,0 @@ -def WebIDLTest(parser, harness): - parser.parse(""" - interface WithDates { - attribute Date foo; - void bar(Date arg); - void baz(sequence<Date> arg); - }; - """) - - results = parser.finish() - harness.ok(results[0].members[0].type.isDate(), "Should have Date") - harness.ok(results[0].members[1].signatures()[0][1][0].type.isDate(), - "Should have Date argument") - harness.ok(not results[0].members[2].signatures()[0][1][0].type.isDate(), - "Should have non-Date argument") diff --git a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py index bd9996e34c9..505b36468d6 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py @@ -149,7 +149,7 @@ def WebIDLTest(parser, harness): # Now let's test our whole distinguishability table argTypes = [ "long", "short", "long?", "short?", "boolean", - "boolean?", "DOMString", "ByteString", "Enum", "Enum2", + "boolean?", "DOMString", "ByteString", "UTF8String", "Enum", "Enum2", "Interface", "Interface?", "AncestorInterface", "UnrelatedInterface", "CallbackInterface", "CallbackInterface?", "CallbackInterface2", @@ -158,14 +158,12 @@ def WebIDLTest(parser, harness): "record<DOMString, object>", "record<USVString, Dict>", "record<ByteString, long>", - "Date", "Date?", "any", - "Promise<any>", "Promise<any>?", - "USVString", "JSString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer", + "record<UTF8String, long>", + "any", "Promise<any>", "Promise<any>?", + "USVString", "JSString", "ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array", "(long or Callback)", "(long or Dict)", ] - # When we can parse Date, we need to add it here. - # XXXbz we can, and should really do that... # Try to categorize things a bit to keep list lengths down def allBut(list1, list2): @@ -177,26 +175,24 @@ def WebIDLTest(parser, harness): primitives = numerics + booleans nonNumerics = allBut(argTypes, numerics + unions) nonBooleans = allBut(argTypes, booleans) - strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString", "JSString" ] + strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString", "JSString", "UTF8String" ] nonStrings = allBut(argTypes, strings) nonObjects = primitives + strings objects = allBut(argTypes, nonObjects ) bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"] - sharedBufferSourceTypes = ["SharedArrayBuffer"] interfaces = [ "Interface", "Interface?", "AncestorInterface", - "UnrelatedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes + "UnrelatedInterface" ] + bufferSourceTypes nullables = (["long?", "short?", "boolean?", "Interface?", "CallbackInterface?", "Dict", "Dict2", "Date?", "any", "Promise<any>?"] + allBut(unions, [ "(long or Callback)" ])) - dates = [ "Date", "Date?" ] sequences = [ "sequence<long>", "sequence<short>" ] - nonUserObjects = nonObjects + interfaces + dates + sequences + nonUserObjects = nonObjects + interfaces + sequences otherObjects = allBut(argTypes, nonUserObjects + ["object"]) notRelatedInterfaces = (nonObjects + ["UnrelatedInterface"] + - otherObjects + dates + sequences + bufferSourceTypes + sharedBufferSourceTypes) + otherObjects + sequences + bufferSourceTypes) records = [ "record<DOMString, object>", "record<USVString, Dict>", - "record<ByteString, long>" ] # JSString not supported in records + "record<ByteString, long>", "record<UTF8String, long>" ] # JSString not supported in records # Build a representation of the distinguishability table as a dict # of dicts, holding True values where needed, holes elsewhere. @@ -215,6 +211,7 @@ def WebIDLTest(parser, harness): setDistinguishable("boolean?", allBut(nonBooleans, nullables)) setDistinguishable("DOMString", nonStrings) setDistinguishable("ByteString", nonStrings) + setDistinguishable("UTF8String", nonStrings) setDistinguishable("USVString", nonStrings) setDistinguishable("JSString", nonStrings) setDistinguishable("Enum", nonStrings) @@ -240,8 +237,7 @@ def WebIDLTest(parser, harness): setDistinguishable("record<USVString, Dict>", nonUserObjects) # JSString not supported in records setDistinguishable("record<ByteString, long>", nonUserObjects) - setDistinguishable("Date", allBut(argTypes, dates + ["object"])) - setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"])) + setDistinguishable("record<UTF8String, long>", nonUserObjects) setDistinguishable("any", []) setDistinguishable("Promise<any>", []) setDistinguishable("Promise<any>?", []) @@ -249,7 +245,6 @@ def WebIDLTest(parser, harness): setDistinguishable("ArrayBufferView", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "Uint16Array", "object"])) setDistinguishable("Uint8Array", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "object"])) setDistinguishable("Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"])) - setDistinguishable("SharedArrayBuffer", allBut(argTypes, ["SharedArrayBuffer", "object"])) setDistinguishable("(long or Callback)", allBut(nonUserObjects, numerics)) setDistinguishable("(long or Dict)", diff --git a/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py b/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py index 97184ec2478..144c945bc10 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_extended_attributes.py @@ -56,9 +56,9 @@ def WebIDLTest(parser, harness): results = parser.finish() # Pull out the first argument out of the arglist of the first (and # only) signature. - harness.ok(results[0].members[0].signatures()[0][1][0].type.clamp, + harness.ok(results[0].members[0].signatures()[0][1][0].type.hasClamp(), "Should be clamped") - harness.ok(not results[0].members[1].signatures()[0][1][0].type.clamp, + harness.ok(not results[0].members[1].signatures()[0][1][0].type.hasClamp(), "Should not be clamped") parser = parser.reset() @@ -86,9 +86,9 @@ def WebIDLTest(parser, harness): results = parser.finish() # Pull out the first argument out of the arglist of the first (and # only) signature. - harness.ok(results[0].members[0].signatures()[0][1][0].type.enforceRange, + harness.ok(results[0].members[0].signatures()[0][1][0].type.hasEnforceRange(), "Should be enforceRange") - harness.ok(not results[0].members[1].signatures()[0][1][0].type.enforceRange, + harness.ok(not results[0].members[1].signatures()[0][1][0].type.hasEnforceRange(), "Should not be enforceRange") parser = parser.reset() diff --git a/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py b/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py index 2b48b615dd4..8ba6771677a 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_nullable_equivalency.py @@ -80,7 +80,7 @@ def checkEquivalent(iface, harness): for attr in dir(type1): if attr.startswith('_') or \ attr in ['nullable', 'builtin', 'filename', 'location', - 'inner', 'QName', 'getDeps', 'name'] or \ + 'inner', 'QName', 'getDeps', 'name', 'prettyName'] or \ (hasattr(type(type1), attr) and not callable(getattr(type1, attr))): continue diff --git a/components/script/dom/bindings/codegen/parser/tests/test_toJSON.py b/components/script/dom/bindings/codegen/parser/tests/test_toJSON.py index b8b4f796ccb..ad01330e65a 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_toJSON.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_toJSON.py @@ -85,7 +85,7 @@ def WebIDLTest(parser, harness): JsonTypes = [ "byte", "octet", "short", "unsigned short", "long", "unsigned long", "long long", "unsigned long long", "float", "unrestricted float", "double", "unrestricted double", "boolean", - "DOMString", "ByteString", "USVString", "Enum", "InterfaceWithToJSON", "object" ] + "DOMString", "ByteString", "UTF8String", "USVString", "Enum", "InterfaceWithToJSON", "object" ] nonJsonTypes = [ "InterfaceWithoutToJSON", "any", "Int8Array", "Int16Array", "Int32Array","Uint8Array", "Uint16Array", "Uint32Array", "Uint8ClampedArray", "Float32Array", "Float64Array", "ArrayBuffer" ] @@ -129,9 +129,12 @@ def WebIDLTest(parser, harness): doTest("interface Test { record<DOMString, %s> toJSON(); };" % type, False, "record<DOMString, %s> should be a JSON type" % type) - doTest("interface Test { record<ByteString, %s> toJSON(); };" % type, False, + doTest("interface Test { record<ByteString, %s> toJSON(); };" % type, False, "record<ByteString, %s> should be a JSON type" % type) + doTest("interface Test { record<UTF8String, %s> toJSON(); };" % type, False, + "record<UTF8String, %s> should be a JSON type" % type) + doTest("interface Test { record<USVString, %s> toJSON(); };" % type, False, "record<USVString, %s> should be a JSON type" % type) @@ -174,12 +177,12 @@ def WebIDLTest(parser, harness): doTest("interface Test { record<USVString, %s> toJSON(); };" % type, True, "record<USVString, %s> should not be a JSON type" % type) - + if type != "any": doTest("interface Foo { object toJSON(); }; " "interface Test { (Foo or %s) toJSON(); };" % type, True, "union containing a non-JSON type (%s) should not be a JSON type" % type) - + doTest("interface test { %s? toJSON(); };" % type, True, "Nullable type (%s) should not be a JSON type" % type) diff --git a/components/script/dom/bindings/codegen/parser/update.sh b/components/script/dom/bindings/codegen/parser/update.sh index fee9720ab2d..dd7803c940c 100755 --- a/components/script/dom/bindings/codegen/parser/update.sh +++ b/components/script/dom/bindings/codegen/parser/update.sh @@ -5,8 +5,8 @@ patch < callback-location.patch patch < union-typedef.patch patch < inline.patch -wget https://hg.mozilla.org/mozilla-central/archive/tip.tar.gz/dom/bindings/parser/tests/ -O tests.tar.gz +wget https://hg.mozilla.org/mozilla-central/archive/tip.zip/dom/bindings/parser/tests/ -O tests.zip rm -r tests mkdir tests -tar xvpf tests.tar.gz -C tests --strip-components=5 -rm tests.tar.gz WebIDL.py.orig +unzip -d tests -j tests.zip +rm tests.zip WebIDL.py.orig diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index 17c5f2fb1ae..2eac830a4bb 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -9,8 +9,10 @@ use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyAndValueResult; use crate::dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValueResult; use crate::dom::bindings::error::Fallible; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; -use crate::dom::bindings::root::{Dom, DomRoot}; +use crate::dom::bindings::reflector::{ + reflect_dom_object, DomObjectIteratorWrap, DomObjectWrap, Reflector, +}; +use crate::dom::bindings::root::{Dom, DomRoot, Root}; use crate::dom::bindings::trace::{JSTraceable, RootedTraceableBox}; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; @@ -51,27 +53,23 @@ pub trait Iterable { /// An iterator over the iterable entries of a given DOM interface. //FIXME: #12811 prevents dom_struct with type parameters #[dom_struct] -pub struct IterableIterator<T: DomObject + JSTraceable + Iterable> { +pub struct IterableIterator<T: DomObjectIteratorWrap + JSTraceable + Iterable> { reflector: Reflector, iterable: Dom<T>, type_: IteratorType, index: Cell<u32>, } -impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> { +impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> IterableIterator<T> { /// Create a new iterator instance for the provided iterable DOM interface. - pub fn new( - iterable: &T, - type_: IteratorType, - wrap: unsafe fn(JSContext, &GlobalScope, Box<IterableIterator<T>>) -> DomRoot<Self>, - ) -> DomRoot<Self> { + pub fn new(iterable: &T, type_: IteratorType) -> DomRoot<Self> { let iterator = Box::new(IterableIterator { reflector: Reflector::new(), type_: type_, iterable: Dom::from_ref(iterable), index: Cell::new(0), }); - reflect_dom_object(iterator, &*iterable.global(), wrap) + reflect_dom_object(iterator, &*iterable.global()) } /// Return the next value from the iterable object. @@ -119,6 +117,10 @@ impl<T: DomObject + JSTraceable + Iterable> IterableIterator<T> { } } +impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> DomObjectWrap for IterableIterator<T> { + const WRAP: unsafe fn(JSContext, &GlobalScope, Box<Self>) -> Root<Dom<Self>> = T::ITER_WRAP; +} + fn dict_return( cx: JSContext, mut result: MutableHandleObject, diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index 78635b2be31..04bf9fdbbed 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -5,7 +5,8 @@ //! The `Reflector` struct. use crate::dom::bindings::conversions::DerivedFrom; -use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::iterable::{Iterable, IterableIterator}; +use crate::dom::bindings::root::{Dom, DomRoot, Root}; use crate::dom::bindings::trace::JSTraceable; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; @@ -15,17 +16,13 @@ use std::default::Default; /// Create the reflector for a new DOM object and yield ownership to the /// reflector. -pub fn reflect_dom_object<T, U>( - obj: Box<T>, - global: &U, - wrap_fn: unsafe fn(JSContext, &GlobalScope, Box<T>) -> DomRoot<T>, -) -> DomRoot<T> +pub fn reflect_dom_object<T, U>(obj: Box<T>, global: &U) -> DomRoot<T> where - T: DomObject, + T: DomObject + DomObjectWrap, U: DerivedFrom<GlobalScope>, { let global_scope = global.upcast(); - unsafe { wrap_fn(global_scope.get_cx(), global_scope, obj) } + unsafe { T::WRAP(global_scope.get_cx(), global_scope, obj) } } /// A struct to store a reference to the reflector of a DOM object. @@ -106,3 +103,20 @@ impl MutDomObject for Reflector { self.set_jsobject(obj) } } + +/// A trait to provide a function pointer to wrap function for DOM objects. +pub trait DomObjectWrap: Sized + DomObject { + /// Function pointer to the general wrap function type + const WRAP: unsafe fn(JSContext, &GlobalScope, Box<Self>) -> Root<Dom<Self>>; +} + +/// A trait to provide a function pointer to wrap function for +/// DOM iterator interfaces. +pub trait DomObjectIteratorWrap: DomObjectWrap + JSTraceable + Iterable { + /// Function pointer to the wrap function for IterableIterator<T> + const ITER_WRAP: unsafe fn( + JSContext, + &GlobalScope, + Box<IterableIterator<Self>>, + ) -> Root<Dom<IterableIterator<Self>>>; +} diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 0ba69687dba..b1739ac27c3 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -331,6 +331,7 @@ impl<T> Dom<T> { debug_assert!(thread_state::get().is_layout()); LayoutDom { ptr: self.ptr.clone(), + marker: PhantomData, } } } @@ -413,13 +414,17 @@ where /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. #[unrooted_must_root_lint::allow_unrooted_interior] -pub struct LayoutDom<T> { +pub struct LayoutDom<'dom, T> { ptr: ptr::NonNull<T>, + marker: PhantomData<&'dom T>, } -impl<T: Castable> LayoutDom<T> { +impl<'dom, T> LayoutDom<'dom, T> +where + T: Castable, +{ /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast<U>(&self) -> LayoutDom<U> + pub fn upcast<U>(&self) -> LayoutDom<'dom, U> where U: Castable, T: DerivedFrom<U>, @@ -428,11 +433,12 @@ impl<T: Castable> LayoutDom<T> { let ptr: *mut T = self.ptr.as_ptr(); LayoutDom { ptr: unsafe { ptr::NonNull::new_unchecked(ptr as *mut U) }, + marker: PhantomData, } } /// Cast a DOM object downwards to one of the interfaces it might implement. - pub fn downcast<U>(&self) -> Option<LayoutDom<U>> + pub fn downcast<U>(&self) -> Option<LayoutDom<'dom, U>> where U: DerivedFrom<T>, { @@ -442,6 +448,7 @@ impl<T: Castable> LayoutDom<T> { let ptr: *mut T = self.ptr.as_ptr(); Some(LayoutDom { ptr: ptr::NonNull::new_unchecked(ptr as *mut U), + marker: PhantomData, }) } else { None @@ -450,7 +457,10 @@ impl<T: Castable> LayoutDom<T> { } } -impl<T: DomObject> LayoutDom<T> { +impl<T> LayoutDom<'_, T> +where + T: DomObject, +{ /// Get the reflector. pub unsafe fn get_jsobject(&self) -> *mut JSObject { debug_assert!(thread_state::get().is_layout()); @@ -458,7 +468,7 @@ impl<T: DomObject> LayoutDom<T> { } } -impl<T> Copy for LayoutDom<T> {} +impl<T> Copy for LayoutDom<'_, T> {} impl<T> PartialEq for Dom<T> { fn eq(&self, other: &Dom<T>) -> bool { @@ -474,13 +484,13 @@ impl<'a, T: DomObject> PartialEq<&'a T> for Dom<T> { impl<T> Eq for Dom<T> {} -impl<T> PartialEq for LayoutDom<T> { - fn eq(&self, other: &LayoutDom<T>) -> bool { +impl<T> PartialEq for LayoutDom<'_, T> { + fn eq(&self, other: &Self) -> bool { self.ptr.as_ptr() == other.ptr.as_ptr() } } -impl<T> Eq for LayoutDom<T> {} +impl<T> Eq for LayoutDom<'_, T> {} impl<T> Hash for Dom<T> { fn hash<H: Hasher>(&self, state: &mut H) { @@ -488,7 +498,7 @@ impl<T> Hash for Dom<T> { } } -impl<T> Hash for LayoutDom<T> { +impl<T> Hash for LayoutDom<'_, T> { fn hash<H: Hasher>(&self, state: &mut H) { self.ptr.as_ptr().hash(state) } @@ -497,7 +507,7 @@ impl<T> Hash for LayoutDom<T> { impl<T> Clone for Dom<T> { #[inline] #[allow(unrooted_must_root)] - fn clone(&self) -> Dom<T> { + fn clone(&self) -> Self { debug_assert!(thread_state::get().is_script()); Dom { ptr: self.ptr.clone(), @@ -505,24 +515,26 @@ impl<T> Clone for Dom<T> { } } -impl<T> Clone for LayoutDom<T> { +impl<T> Clone for LayoutDom<'_, T> { #[inline] - fn clone(&self) -> LayoutDom<T> { + fn clone(&self) -> Self { debug_assert!(thread_state::get().is_layout()); LayoutDom { ptr: self.ptr.clone(), + marker: PhantomData, } } } -impl LayoutDom<Node> { +impl LayoutDom<'_, Node> { /// Create a new JS-owned value wrapped from an address known to be a /// `Node` pointer. - pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> LayoutDom<Node> { + pub unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> Self { debug_assert!(thread_state::get().is_layout()); let TrustedNodeAddress(addr) = inner; LayoutDom { ptr: ptr::NonNull::new_unchecked(addr as *const Node as *mut Node), + marker: PhantomData, } } } @@ -624,7 +636,7 @@ impl<T: DomObject> MutNullableDom<T> { #[allow(unrooted_must_root)] pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> { debug_assert!(thread_state::get().is_layout()); - ptr::read(self.ptr.get()).map(|js| js.to_layout()) + (*self.ptr.get()).as_ref().map(|js| js.to_layout()) } /// Get a rooted value out of this object @@ -732,7 +744,10 @@ unsafe impl<T: DomObject> JSTraceable for DomOnceCell<T> { } } -impl<T: DomObject> LayoutDom<T> { +impl<'dom, T> LayoutDom<'dom, T> +where + T: 'dom + DomObject, +{ /// Returns an unsafe pointer to the interior of this JS object. This is /// the only method that be safely accessed from layout. (The fact that /// this is unsafe is what necessitates the layout wrappers.) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 2d6b6c04379..c30fced7c4d 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -36,7 +36,6 @@ use crate::dom::bindings::reflector::{DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::bindings::utils::WindowProxyHandler; -use crate::dom::document::PendingRestyle; use crate::dom::gpubuffer::GPUBufferState; use crate::dom::htmlimageelement::SourceSet; use crate::dom::htmlmediaelement::{HTMLMediaElementFetchContext, MediaFrameRenderer}; @@ -96,6 +95,7 @@ use net_traits::storage_thread::StorageType; use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceThreads}; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; +use script_layout_interface::message::PendingRestyle; use script_layout_interface::rpc::LayoutRPC; use script_layout_interface::OpaqueStyleAndLayoutData; use script_traits::serializable::BlobImpl; diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs index 5b3569eeb9b..540f094bfe5 100644 --- a/components/script/dom/biquadfilternode.rs +++ b/components/script/dom/biquadfilternode.rs @@ -9,11 +9,9 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; +use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterNodeMethods; use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterOptions; use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::BiquadFilterType; -use crate::dom::bindings::codegen::Bindings::BiquadFilterNodeBinding::{ - self, BiquadFilterNodeMethods, -}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -113,11 +111,7 @@ impl BiquadFilterNode { options: &BiquadFilterOptions, ) -> Fallible<DomRoot<BiquadFilterNode>> { let node = BiquadFilterNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - BiquadFilterNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index bc8799a3d8d..aba1b99ab5e 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -40,7 +40,6 @@ impl Blob { blob_id: blob_impl.blob_id(), }), global, - BlobBinding::Wrap, ); global.track_blob(&dom_blob, blob_impl); dom_blob diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index c769cfcef94..2bdc636dc7a 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -9,7 +9,7 @@ use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSeque use bluetooth_traits::scanfilter::{RequestDeviceoptions, ServiceUUIDSequence}; use crate::realms::{AlreadyInRealm, InRealm}; use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit}; +use crate::dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothDataFilterInit; use crate::dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions}; use crate::dom::bindings::codegen::Bindings::BluetoothBinding::BluetoothLEScanFilterInit; use crate::dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::BluetoothPermissionDescriptor; @@ -144,11 +144,7 @@ impl Bluetooth { } pub fn new(global: &GlobalScope) -> DomRoot<Bluetooth> { - reflect_dom_object( - Box::new(Bluetooth::new_inherited()), - global, - BluetoothBinding::Wrap, - ) + reflect_dom_object(Box::new(Bluetooth::new_inherited()), global) } fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { diff --git a/components/script/dom/bluetoothadvertisingevent.rs b/components/script/dom/bluetoothadvertisingevent.rs index 7a85acb6e16..7d31fad2dc7 100644 --- a/components/script/dom/bluetoothadvertisingevent.rs +++ b/components/script/dom/bluetoothadvertisingevent.rs @@ -2,10 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::BluetoothAdvertisingEventInit; use crate::dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::BluetoothAdvertisingEventMethods; -use crate::dom::bindings::codegen::Bindings::BluetoothAdvertisingEventBinding::{ - self, BluetoothAdvertisingEventInit, -}; use crate::dom::bindings::codegen::Bindings::EventBinding::EventBinding::EventMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; @@ -65,7 +63,6 @@ impl BluetoothAdvertisingEvent { device, name, appearance, txPower, rssi, )), global, - BluetoothAdvertisingEventBinding::Wrap, ); { let event = ev.upcast::<Event>(); diff --git a/components/script/dom/bluetoothcharacteristicproperties.rs b/components/script/dom/bluetoothcharacteristicproperties.rs index 10dc09b77da..f48eb52772c 100644 --- a/components/script/dom/bluetoothcharacteristicproperties.rs +++ b/components/script/dom/bluetoothcharacteristicproperties.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding; use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -76,7 +75,6 @@ impl BluetoothCharacteristicProperties { writableAuxiliaries, )), global, - BluetoothCharacteristicPropertiesBinding::Wrap, ) } } diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index 3ba192aa36f..bff2e0871ff 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding; use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::error::Error; @@ -77,7 +76,6 @@ impl BluetoothDevice { reflect_dom_object( Box::new(BluetoothDevice::new_inherited(id, name, context)), global, - BluetoothDeviceBinding::Wrap, ) } diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs index 1051ecebb8e..0f7266e0443 100644 --- a/components/script/dom/bluetoothpermissionresult.rs +++ b/components/script/dom/bluetoothpermissionresult.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::{ - self, BluetoothPermissionResultMethods, -}; +use crate::dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::BluetoothPermissionResultMethods; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods; use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusBinding::PermissionStatusMethods; use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{ @@ -51,7 +49,6 @@ impl BluetoothPermissionResult { reflect_dom_object( Box::new(BluetoothPermissionResult::new_inherited(status)), global, - BluetoothPermissionResultBinding::Wrap, ) } diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index d5e700a0949..fd01653c84d 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::BluetoothCharacteristicPropertiesMethods; -use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; @@ -77,7 +76,6 @@ impl BluetoothRemoteGATTCharacteristic { instance_id, )), global, - BluetoothRemoteGATTCharacteristicBinding::Wrap, ) } diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index 9680ea75cd3..39e298f923c 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding::BluetoothRemoteGATTCharacteristicMethods; -use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; @@ -64,7 +63,6 @@ impl BluetoothRemoteGATTDescriptor { instance_id, )), global, - BluetoothRemoteGATTDescriptorBinding::Wrap, ) } diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index 76270373d73..8a4f94fe35c 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; -use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::error::ErrorResult; @@ -45,7 +44,6 @@ impl BluetoothRemoteGATTServer { reflect_dom_object( Box::new(BluetoothRemoteGATTServer::new_inherited(device)), global, - BluetoothRemoteGATTServerBinding::Wrap, ) } diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index e82267a62aa..62b46a8b9bd 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; -use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use crate::dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::reflect_dom_object; @@ -58,7 +57,6 @@ impl BluetoothRemoteGATTService { device, uuid, isPrimary, instanceID, )), global, - BluetoothRemoteGATTServiceBinding::Wrap, ) } diff --git a/components/script/dom/broadcastchannel.rs b/components/script/dom/broadcastchannel.rs index f7d75d8c101..701f71b27cd 100644 --- a/components/script/dom/broadcastchannel.rs +++ b/components/script/dom/broadcastchannel.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::BroadcastChannelBinding::{ - BroadcastChannelMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::BroadcastChannelBinding::BroadcastChannelMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; @@ -35,11 +33,7 @@ impl BroadcastChannel { } pub fn new(global: &GlobalScope, name: DOMString) -> DomRoot<BroadcastChannel> { - let channel = reflect_dom_object( - Box::new(BroadcastChannel::new_inherited(name)), - global, - Wrap, - ); + let channel = reflect_dom_object(Box::new(BroadcastChannel::new_inherited(name)), global); global.track_broadcast_channel(&*channel); channel } diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index f24106d81c2..3671df678af 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding; use crate::dom::bindings::codegen::Bindings::CanvasGradientBinding::CanvasGradientMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::num::Finite; @@ -42,11 +41,7 @@ impl CanvasGradient { } pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot<CanvasGradient> { - reflect_dom_object( - Box::new(CanvasGradient::new_inherited(style)), - global, - CanvasGradientBinding::Wrap, - ) + reflect_dom_object(Box::new(CanvasGradient::new_inherited(style)), global) } } diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs index bce7cd24c54..3557f646ab9 100644 --- a/components/script/dom/canvaspattern.rs +++ b/components/script/dom/canvaspattern.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CanvasPatternBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::canvasgradient::ToFillOrStrokeStyle; @@ -60,7 +59,6 @@ impl CanvasPattern { origin_clean, )), global, - CanvasPatternBinding::Wrap, ) } pub fn origin_is_clean(&self) -> bool { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 5956827d654..d6c01c6a145 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -4,7 +4,6 @@ use crate::canvas_state::{CanvasContextState, CanvasState}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasFillRule; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; @@ -67,7 +66,7 @@ impl CanvasRenderingContext2D { Some(canvas), size, )); - reflect_dom_object(boxed, global, CanvasRenderingContext2DBinding::Wrap) + reflect_dom_object(boxed, global) } // https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions @@ -158,7 +157,7 @@ pub trait LayoutCanvasRenderingContext2DHelpers { unsafe fn get_canvas_id(&self) -> CanvasId; } -impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<CanvasRenderingContext2D> { +impl LayoutCanvasRenderingContext2DHelpers for LayoutDom<'_, CanvasRenderingContext2D> { #[allow(unsafe_code)] unsafe fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> { (*self.unsafe_get()) diff --git a/components/script/dom/cdatasection.rs b/components/script/dom/cdatasection.rs index f4c788fd722..7e026bb7673 100644 --- a/components/script/dom/cdatasection.rs +++ b/components/script/dom/cdatasection.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CDATASectionBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; @@ -26,7 +25,6 @@ impl CDATASection { Node::reflect_node( Box::new(CDATASection::new_inherited(text, document)), document, - CDATASectionBinding::Wrap, ) } } diff --git a/components/script/dom/channelmergernode.rs b/components/script/dom/channelmergernode.rs index 0ebc086626c..7e8bccd885e 100644 --- a/components/script/dom/channelmergernode.rs +++ b/components/script/dom/channelmergernode.rs @@ -7,9 +7,7 @@ use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; -use crate::dom::bindings::codegen::Bindings::ChannelMergerNodeBinding::{ - self, ChannelMergerOptions, -}; +use crate::dom::bindings::codegen::Bindings::ChannelMergerNodeBinding::ChannelMergerOptions; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -61,11 +59,7 @@ impl ChannelMergerNode { options: &ChannelMergerOptions, ) -> Fallible<DomRoot<ChannelMergerNode>> { let node = ChannelMergerNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - ChannelMergerNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/channelsplitternode.rs b/components/script/dom/channelsplitternode.rs index 4ec38609bce..3efd3b2465c 100644 --- a/components/script/dom/channelsplitternode.rs +++ b/components/script/dom/channelsplitternode.rs @@ -7,9 +7,7 @@ use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; -use crate::dom::bindings::codegen::Bindings::ChannelSplitterNodeBinding::{ - self, ChannelSplitterOptions, -}; +use crate::dom::bindings::codegen::Bindings::ChannelSplitterNodeBinding::ChannelSplitterOptions; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -63,11 +61,7 @@ impl ChannelSplitterNode { options: &ChannelSplitterOptions, ) -> Fallible<DomRoot<ChannelSplitterNode>> { let node = ChannelSplitterNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - ChannelSplitterNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index 6baa6a855d9..81456cfb60b 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -286,7 +286,7 @@ pub trait LayoutCharacterDataHelpers { } #[allow(unsafe_code)] -impl LayoutCharacterDataHelpers for LayoutDom<CharacterData> { +impl LayoutCharacterDataHelpers for LayoutDom<'_, CharacterData> { #[inline] unsafe fn data_for_layout(&self) -> &str { &(*self.unsafe_get()).data.borrow_for_layout() diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs index 4a448ea1a5a..53c692d5591 100644 --- a/components/script/dom/client.rs +++ b/components/script/dom/client.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::bindings::codegen::Bindings::ClientBinding::ClientMethods; use crate::dom::bindings::codegen::Bindings::ClientBinding::FrameType; -use crate::dom::bindings::codegen::Bindings::ClientBinding::{ClientMethods, Wrap}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; @@ -36,11 +36,7 @@ impl Client { } pub fn new(window: &Window) -> DomRoot<Client> { - reflect_dom_object( - Box::new(Client::new_inherited(window.get_url())), - window, - Wrap, - ) + reflect_dom_object(Box::new(Client::new_inherited(window.get_url())), window) } pub fn creation_url(&self) -> ServoUrl { diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs index 8bd0446d24e..abc579d8df9 100644 --- a/components/script/dom/closeevent.rs +++ b/components/script/dom/closeevent.rs @@ -44,7 +44,7 @@ impl CloseEvent { reason: DOMString, ) -> DomRoot<CloseEvent> { let event = Box::new(CloseEvent::new_inherited(wasClean, code, reason)); - let ev = reflect_dom_object(event, global, CloseEventBinding::Wrap); + let ev = reflect_dom_object(event, global); { let event = ev.upcast::<Event>(); event.init_event(type_, bool::from(bubbles), bool::from(cancelable)); diff --git a/components/script/dom/comment.rs b/components/script/dom/comment.rs index 06750f4a67f..d87f4d77094 100644 --- a/components/script/dom/comment.rs +++ b/components/script/dom/comment.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CommentBinding; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::root::DomRoot; @@ -27,11 +26,7 @@ impl Comment { } pub fn new(text: DOMString, document: &Document) -> DomRoot<Comment> { - Node::reflect_node( - Box::new(Comment::new_inherited(text, document)), - document, - CommentBinding::Wrap, - ) + Node::reflect_node(Box::new(Comment::new_inherited(text, document)), document) } #[allow(non_snake_case)] diff --git a/components/script/dom/compositionevent.rs b/components/script/dom/compositionevent.rs index 121034f42bc..1cdc1cd8dcc 100644 --- a/components/script/dom/compositionevent.rs +++ b/components/script/dom/compositionevent.rs @@ -29,11 +29,7 @@ impl CompositionEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> { - reflect_dom_object( - Box::new(CompositionEvent::new_inherited()), - window, - CompositionEventBinding::Wrap, - ) + reflect_dom_object(Box::new(CompositionEvent::new_inherited()), window) } pub fn new( @@ -51,7 +47,6 @@ impl CompositionEvent { data: data, }), window, - CompositionEventBinding::Wrap, ); ev.uievent .InitUIEvent(type_, can_bubble, cancelable, view, detail); diff --git a/components/script/dom/constantsourcenode.rs b/components/script/dom/constantsourcenode.rs index ca7b9b382f5..90851da88c2 100644 --- a/components/script/dom/constantsourcenode.rs +++ b/components/script/dom/constantsourcenode.rs @@ -7,9 +7,7 @@ use crate::dom::audioscheduledsourcenode::AudioScheduledSourceNode; use crate::dom::baseaudiocontext::BaseAudioContext; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::ConstantSourceNodeMethods; -use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::{ - self, ConstantSourceOptions, -}; +use crate::dom::bindings::codegen::Bindings::ConstantSourceNodeBinding::ConstantSourceOptions; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -66,11 +64,7 @@ impl ConstantSourceNode { options: &ConstantSourceOptions, ) -> Fallible<DomRoot<ConstantSourceNode>> { let node = ConstantSourceNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - ConstantSourceNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index c0660dd8409..6aec75cbf3f 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CryptoBinding; use crate::dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -37,11 +36,7 @@ impl Crypto { } pub fn new(global: &GlobalScope) -> DomRoot<Crypto> { - reflect_dom_object( - Box::new(Crypto::new_inherited()), - global, - CryptoBinding::Wrap, - ) + reflect_dom_object(Box::new(Crypto::new_inherited()), global) } } diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index bcfbe27b716..8e2349a0429 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSFontFaceRuleBinding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -44,7 +43,6 @@ impl CSSFontFaceRule { fontfacerule, )), window, - CSSFontFaceRuleBinding::Wrap, ) } } diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index 74fca1bc064..52fbe62c2bd 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSImportRuleBinding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -41,7 +40,6 @@ impl CSSImportRule { reflect_dom_object( Box::new(Self::new_inherited(parent_stylesheet, import_rule)), window, - CSSImportRuleBinding::Wrap, ) } } diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index 93ba825441a..281fc4b8e5e 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::{ - self, CSSKeyframeRuleMethods, -}; +use crate::dom::bindings::codegen::Bindings::CSSKeyframeRuleBinding::CSSKeyframeRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -50,7 +48,6 @@ impl CSSKeyframeRule { keyframerule, )), window, - CSSKeyframeRuleBinding::Wrap, ) } } diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index e17632f7672..aa2be337022 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding; use crate::dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods; use crate::dom::bindings::error::ErrorResult; use crate::dom::bindings::inheritance::Castable; @@ -53,7 +52,6 @@ impl CSSKeyframesRule { keyframesrule, )), window, - CSSKeyframesRuleBinding::Wrap, ) } diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 5c5061dee0d..2f54b0a0839 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSMediaRuleBinding; use crate::dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -53,7 +52,6 @@ impl CSSMediaRule { reflect_dom_object( Box::new(CSSMediaRule::new_inherited(parent_stylesheet, mediarule)), window, - CSSMediaRuleBinding::Wrap, ) } diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index 394de07556c..f3ff8df36d9 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding; use crate::dom::bindings::codegen::Bindings::CSSNamespaceRuleBinding::CSSNamespaceRuleMethods; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -45,7 +44,6 @@ impl CSSNamespaceRule { namespacerule, )), window, - CSSNamespaceRuleBinding::Wrap, ) } } diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index b7dc2025343..18a41857923 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding; use crate::dom::bindings::codegen::Bindings::CSSRuleListBinding::CSSRuleListMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -86,7 +85,6 @@ impl CSSRuleList { reflect_dom_object( Box::new(CSSRuleList::new_inherited(parent_stylesheet, rules)), window, - CSSRuleListBinding::Wrap, ) } diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 2ad565f9b45..01e41d3f0ef 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::{ - self, CSSStyleDeclarationMethods, -}; +use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -233,7 +231,6 @@ impl CSSStyleDeclaration { modification_access, )), global, - CSSStyleDeclarationBinding::Wrap, ) } diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index 14d7cdcdbef..30e4e197ce5 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSStyleRuleBinding::{self, CSSStyleRuleMethods}; +use crate::dom::bindings::codegen::Bindings::CSSStyleRuleBinding::CSSStyleRuleMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -51,7 +51,6 @@ impl CSSStyleRule { reflect_dom_object( Box::new(CSSStyleRule::new_inherited(parent_stylesheet, stylerule)), window, - CSSStyleRuleBinding::Wrap, ) } } diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 66d2fd8a339..35277ddc0fc 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding; use crate::dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -61,7 +60,6 @@ impl CSSStyleSheet { owner, type_, href, title, stylesheet, )), window, - CSSStyleSheetBinding::Wrap, ) } diff --git a/components/script/dom/cssstylevalue.rs b/components/script/dom/cssstylevalue.rs index 7bdcd50adc1..f272b34e945 100644 --- a/components/script/dom/cssstylevalue.rs +++ b/components/script/dom/cssstylevalue.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::CSSStyleValueBinding::CSSStyleValueMethods; -use crate::dom::bindings::codegen::Bindings::CSSStyleValueBinding::Wrap; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::DomRoot; @@ -29,7 +28,7 @@ impl CSSStyleValue { } pub fn new(global: &GlobalScope, value: String) -> DomRoot<CSSStyleValue> { - reflect_dom_object(Box::new(CSSStyleValue::new_inherited(value)), global, Wrap) + reflect_dom_object(Box::new(CSSStyleValue::new_inherited(value)), global) } } diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 564abcb0e83..c462faf7eba 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSSupportsRuleBinding; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; @@ -52,7 +51,6 @@ impl CSSSupportsRule { supportsrule, )), window, - CSSSupportsRuleBinding::Wrap, ) } diff --git a/components/script/dom/cssviewportrule.rs b/components/script/dom/cssviewportrule.rs index 1c0a7bf2206..088d1b4a75e 100644 --- a/components/script/dom/cssviewportrule.rs +++ b/components/script/dom/cssviewportrule.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::CSSViewportRuleBinding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -44,7 +43,6 @@ impl CSSViewportRule { viewportrule, )), window, - CSSViewportRuleBinding::Wrap, ) } } diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 3f1346e93a3..b1b8a241b63 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::callback::{CallbackContainer, ExceptionHandling}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding; use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementConstructor; use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::CustomElementRegistryMethods; use crate::dom::bindings::codegen::Bindings::CustomElementRegistryBinding::ElementDefinitionOptions; @@ -96,7 +95,6 @@ impl CustomElementRegistry { reflect_dom_object( Box::new(CustomElementRegistry::new_inherited(window)), window, - CustomElementRegistryBinding::Wrap, ) } diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index 26366f65f5e..7dadacee375 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -37,11 +37,7 @@ impl CustomEvent { } pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<CustomEvent> { - reflect_dom_object( - Box::new(CustomEvent::new_inherited()), - global, - CustomEventBinding::Wrap, - ) + reflect_dom_object(Box::new(CustomEvent::new_inherited()), global) } pub fn new( global: &GlobalScope, diff --git a/components/script/dom/dissimilaroriginlocation.rs b/components/script/dom/dissimilaroriginlocation.rs index f7b978bc185..d1c466bb781 100644 --- a/components/script/dom/dissimilaroriginlocation.rs +++ b/components/script/dom/dissimilaroriginlocation.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding; use crate::dom::bindings::codegen::Bindings::DissimilarOriginLocationBinding::DissimilarOriginLocationMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; @@ -42,7 +41,6 @@ impl DissimilarOriginLocation { reflect_dom_object( Box::new(DissimilarOriginLocation::new_inherited(window)), window, - DissimilarOriginLocationBinding::Wrap, ) } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 303c51660f0..f119429e01f 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -8,7 +8,6 @@ use crate::dom::beforeunloadevent::BeforeUnloadEvent; use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut}; use crate::dom::bindings::codegen::Bindings::BeforeUnloadEventBinding::BeforeUnloadEventBinding::BeforeUnloadEventMethods; -use crate::dom::bindings::codegen::Bindings::DocumentBinding; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ DocumentMethods, DocumentReadyState, }; @@ -72,7 +71,7 @@ use crate::dom::location::Location; use crate::dom::messageevent::MessageEvent; use crate::dom::mouseevent::MouseEvent; use crate::dom::node::{self, document_from_node, window_from_node, CloneChildrenFlag}; -use crate::dom::node::{LayoutNodeHelpers, Node, NodeDamage, NodeFlags, ShadowIncluding}; +use crate::dom::node::{Node, NodeDamage, NodeFlags, ShadowIncluding}; use crate::dom::nodeiterator::NodeIterator; use crate::dom::nodelist::NodeList; use crate::dom::pagetransitionevent::PageTransitionEvent; @@ -134,7 +133,8 @@ use percent_encoding::percent_decode; use profile_traits::ipc as profile_ipc; use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; use ref_slice::ref_slice; -use script_layout_interface::message::{Msg, ReflowGoal}; +use script_layout_interface::message::{Msg, PendingRestyle, ReflowGoal}; +use script_layout_interface::TrustedNodeAddress; use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType}; use script_traits::{ MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta, @@ -158,7 +158,7 @@ use style::attr::AttrValue; use style::context::QuirksMode; use style::invalidation::element::restyle_hints::RestyleHint; use style::media_queries::{Device, MediaType}; -use style::selector_parser::{RestyleDamage, Snapshot}; +use style::selector_parser::Snapshot; use style::shared_lock::SharedRwLock as StyleSharedRwLock; use style::str::{split_html_space_chars, str_join}; use style::stylesheet_set::DocumentStylesheetSet; @@ -202,29 +202,6 @@ pub enum IsHTMLDocument { NonHTMLDocument, } -#[derive(Debug, MallocSizeOf)] -pub struct PendingRestyle { - /// If this element had a state or attribute change since the last restyle, track - /// the original condition of the element. - pub snapshot: Option<Snapshot>, - - /// Any explicit restyles hints that have been accumulated for this element. - pub hint: RestyleHint, - - /// Any explicit restyles damage that have been accumulated for this element. - pub damage: RestyleDamage, -} - -impl PendingRestyle { - pub fn new() -> Self { - PendingRestyle { - snapshot: None, - hint: RestyleHint::empty(), - damage: RestyleDamage::empty(), - } - } -} - /// <https://dom.spec.whatwg.org/#document> #[dom_struct] pub struct Document { @@ -2630,7 +2607,6 @@ pub enum DocumentSource { #[allow(unsafe_code)] pub trait LayoutDocumentHelpers { unsafe fn is_html_document_for_layout(&self) -> bool; - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)>; unsafe fn needs_paint_from_layout(&self); unsafe fn will_paint(&self); unsafe fn quirks_mode(&self) -> QuirksMode; @@ -2641,29 +2617,13 @@ pub trait LayoutDocumentHelpers { } #[allow(unsafe_code)] -impl LayoutDocumentHelpers for LayoutDom<Document> { +impl LayoutDocumentHelpers for LayoutDom<'_, Document> { #[inline] unsafe fn is_html_document_for_layout(&self) -> bool { (*self.unsafe_get()).is_html_document } #[inline] - #[allow(unrooted_must_root)] - unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutDom<Element>, PendingRestyle)> { - let mut elements = (*self.unsafe_get()) - .pending_restyles - .borrow_mut_for_layout(); - // Elements were in a document when they were added to this list, but that - // may no longer be true when the next layout occurs. - let result = elements - .drain() - .map(|(k, v)| (k.to_layout(), v)) - .filter(|&(ref k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_CONNECTED)) - .collect(); - result - } - - #[inline] unsafe fn needs_paint_from_layout(&self) { (*self.unsafe_get()).needs_paint.set(true) } @@ -3044,7 +3004,6 @@ impl Document { canceller, )), window, - DocumentBinding::Wrap, ); { let node = document.upcast::<Node>(); @@ -3604,6 +3563,16 @@ impl Document { (None, None) => ElementLookupResult::None, } } + + #[allow(unrooted_must_root)] + pub fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> { + self.pending_restyles + .borrow_mut() + .drain() + .filter(|(k, _)| k.upcast::<Node>().get_flag(NodeFlags::IS_CONNECTED)) + .map(|(k, v)| (k.upcast::<Node>().to_trusted_node_address(), v)) + .collect() + } } impl Element { @@ -4093,29 +4062,6 @@ impl DocumentMethods for Document { NodeIterator::new(self, root, what_to_show, filter) } - // https://w3c.github.io/touch-events/#idl-def-Document - fn CreateTouch( - &self, - window: &Window, - target: &EventTarget, - identifier: i32, - page_x: Finite<f64>, - page_y: Finite<f64>, - screen_x: Finite<f64>, - screen_y: Finite<f64>, - ) -> DomRoot<Touch> { - let client_x = Finite::wrap(*page_x - window.PageXOffset() as f64); - let client_y = Finite::wrap(*page_y - window.PageYOffset() as f64); - Touch::new( - window, identifier, target, screen_x, screen_y, client_x, client_y, page_x, page_y, - ) - } - - // https://w3c.github.io/touch-events/#idl-def-document-createtouchlist(touch...) - fn CreateTouchList(&self, touches: &[&Touch]) -> DomRoot<TouchList> { - TouchList::new(&self.window, &touches) - } - // https://dom.spec.whatwg.org/#dom-document-createtreewalker fn CreateTreeWalker( &self, diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs index a7da3745ee0..1aea832646a 100644 --- a/components/script/dom/documentfragment.rs +++ b/components/script/dom/documentfragment.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding; use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding::DocumentFragmentMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::UnionTypes::NodeOrString; @@ -42,7 +41,6 @@ impl DocumentFragment { Node::reflect_node( Box::new(DocumentFragment::new_inherited(document)), document, - DocumentFragmentBinding::Wrap, ) } diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index a1f9f07b4ef..f323cd63d63 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding; use crate::dom::bindings::codegen::Bindings::DocumentTypeBinding::DocumentTypeMethods; use crate::dom::bindings::codegen::UnionTypes::NodeOrString; use crate::dom::bindings::error::ErrorResult; @@ -49,7 +48,6 @@ impl DocumentType { name, public_id, system_id, document, )), document, - DocumentTypeBinding::Wrap, ) } diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index e749541eace..c2533cd7932 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding; use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionConstants; use crate::dom::bindings::codegen::Bindings::DOMExceptionBinding::DOMExceptionMethods; use crate::dom::bindings::error::Error; @@ -134,11 +133,7 @@ impl DOMException { pub fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> { let (message, name) = DOMException::get_error_data_by_code(code); - reflect_dom_object( - Box::new(DOMException::new_inherited(message, name)), - global, - DOMExceptionBinding::Wrap, - ) + reflect_dom_object(Box::new(DOMException::new_inherited(message, name)), global) } #[allow(non_snake_case)] @@ -150,7 +145,6 @@ impl DOMException { Ok(reflect_dom_object( Box::new(DOMException::new_inherited(message, name)), global, - DOMExceptionBinding::Wrap, )) } diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index d12b18168f8..d5a3f07bde2 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::document_loader::DocumentLoader; -use crate::dom::bindings::codegen::Bindings::DOMImplementationBinding; use crate::dom::bindings::codegen::Bindings::DOMImplementationBinding::DOMImplementationMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ DocumentMethods, ElementCreationOptions, @@ -46,11 +45,7 @@ impl DOMImplementation { pub fn new(document: &Document) -> DomRoot<DOMImplementation> { let window = document.window(); - reflect_dom_object( - Box::new(DOMImplementation::new_inherited(document)), - window, - DOMImplementationBinding::Wrap, - ) + reflect_dom_object(Box::new(DOMImplementation::new_inherited(document)), window) } } diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index 0f6d2ae2cd2..c5520c7d6a7 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{ - DOMMatrixInit, DOMMatrixMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrUnrestrictedDoubleSequence; use crate::dom::bindings::error; @@ -32,7 +30,7 @@ impl DOMMatrix { #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> { let dommatrix = Self::new_inherited(is2D, matrix); - reflect_dom_object(Box::new(dommatrix), global, Wrap) + reflect_dom_object(Box::new(dommatrix), global) } pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index e7e32318020..ff724524909 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -4,9 +4,7 @@ use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::DOMMatrixBinding::{DOMMatrixInit, DOMMatrixMethods}; -use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::{ - DOMMatrixReadOnlyMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::DOMMatrixReadOnlyBinding::DOMMatrixReadOnlyMethods; use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; use crate::dom::bindings::codegen::UnionTypes::StringOrUnrestrictedDoubleSequence; use crate::dom::bindings::error; @@ -45,7 +43,7 @@ impl DOMMatrixReadOnly { #[allow(unrooted_must_root)] pub fn new(global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>) -> DomRoot<Self> { let dommatrix = Self::new_inherited(is2D, matrix); - reflect_dom_object(Box::new(dommatrix), global, Wrap) + reflect_dom_object(Box::new(dommatrix), global) } pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index d714ba30ed2..6a0328fc438 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -37,11 +37,7 @@ impl DOMParser { } pub fn new(window: &Window) -> DomRoot<DOMParser> { - reflect_dom_object( - Box::new(DOMParser::new_inherited(window)), - window, - DOMParserBinding::Wrap, - ) + reflect_dom_object(Box::new(DOMParser::new_inherited(window)), window) } #[allow(non_snake_case)] diff --git a/components/script/dom/dompoint.rs b/components/script/dom/dompoint.rs index 4c1fde655cc..fe523b8e766 100644 --- a/components/script/dom/dompoint.rs +++ b/components/script/dom/dompoint.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{ - DOMPointInit, DOMPointMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods}; use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object; @@ -28,7 +26,7 @@ impl DOMPoint { } pub fn new(global: &GlobalScope, x: f64, y: f64, z: f64, w: f64) -> DomRoot<DOMPoint> { - reflect_dom_object(Box::new(DOMPoint::new_inherited(x, y, z, w)), global, Wrap) + reflect_dom_object(Box::new(DOMPoint::new_inherited(x, y, z, w)), global) } pub fn Constructor( diff --git a/components/script/dom/dompointreadonly.rs b/components/script/dom/dompointreadonly.rs index d98e9a4bde3..9d093db2b81 100644 --- a/components/script/dom/dompointreadonly.rs +++ b/components/script/dom/dompointreadonly.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; -use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::{ - DOMPointReadOnlyMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -39,7 +37,6 @@ impl DOMPointReadOnly { reflect_dom_object( Box::new(DOMPointReadOnly::new_inherited(x, y, z, w)), global, - Wrap, ) } diff --git a/components/script/dom/domquad.rs b/components/script/dom/domquad.rs index 3101370582a..e6decd7e1b2 100644 --- a/components/script/dom/domquad.rs +++ b/components/script/dom/domquad.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods}; -use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods, Wrap}; +use crate::dom::bindings::codegen::Bindings::DOMQuadBinding::{DOMQuadInit, DOMQuadMethods}; use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectInit; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -42,11 +42,7 @@ impl DOMQuad { p3: &DOMPoint, p4: &DOMPoint, ) -> DomRoot<DOMQuad> { - reflect_dom_object( - Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)), - global, - Wrap, - ) + reflect_dom_object(Box::new(DOMQuad::new_inherited(p1, p2, p3, p4)), global) } pub fn Constructor( diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index 0aab9dc4d61..d925176f96d 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMRectBinding; use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use crate::dom::bindings::error::Fallible; @@ -28,7 +27,6 @@ impl DOMRect { reflect_dom_object( Box::new(DOMRect::new_inherited(x, y, width, height)), global, - DOMRectBinding::Wrap, ) } diff --git a/components/script/dom/domrectreadonly.rs b/components/script/dom/domrectreadonly.rs index 6bdbac9c388..49eed59ac58 100644 --- a/components/script/dom/domrectreadonly.rs +++ b/components/script/dom/domrectreadonly.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::{ - DOMRectReadOnlyMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::DOMRectReadOnlyBinding::DOMRectReadOnlyMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -42,7 +40,6 @@ impl DOMRectReadOnly { reflect_dom_object( Box::new(DOMRectReadOnly::new_inherited(x, y, width, height)), global, - Wrap, ) } diff --git a/components/script/dom/domstringlist.rs b/components/script/dom/domstringlist.rs index f9f55a69f03..a1592faca79 100644 --- a/components/script/dom/domstringlist.rs +++ b/components/script/dom/domstringlist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMStringListBinding; use crate::dom::bindings::codegen::Bindings::DOMStringListBinding::DOMStringListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -27,11 +26,7 @@ impl DOMStringList { #[allow(unused)] pub fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> { - reflect_dom_object( - Box::new(DOMStringList::new_inherited(strings)), - window, - DOMStringListBinding::Wrap, - ) + reflect_dom_object(Box::new(DOMStringList::new_inherited(strings)), window) } } diff --git a/components/script/dom/domstringmap.rs b/components/script/dom/domstringmap.rs index a3603e0ee93..9ff1071e85b 100644 --- a/components/script/dom/domstringmap.rs +++ b/components/script/dom/domstringmap.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::DOMStringMapBinding; use crate::dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods; use crate::dom::bindings::error::ErrorResult; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -28,11 +27,7 @@ impl DOMStringMap { pub fn new(element: &HTMLElement) -> DomRoot<DOMStringMap> { let window = window_from_node(element); - reflect_dom_object( - Box::new(DOMStringMap::new_inherited(element)), - &*window, - DOMStringMapBinding::Wrap, - ) + reflect_dom_object(Box::new(DOMStringMap::new_inherited(element)), &*window) } } diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 7f56f58c502..5c25409971c 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding; use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -37,7 +36,6 @@ impl DOMTokenList { reflect_dom_object( Box::new(DOMTokenList::new_inherited(element, local_name.clone())), &*window, - DOMTokenListBinding::Wrap, ) } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 268b263fc41..70000fd95f7 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -9,7 +9,6 @@ use crate::dom::attr::{Attr, AttrHelpersForLayout}; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref, RefMut}; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; -use crate::dom::bindings::codegen::Bindings::ElementBinding; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; @@ -294,7 +293,6 @@ impl Element { local_name, namespace, prefix, document, )), document, - ElementBinding::Wrap, ) } @@ -569,11 +567,11 @@ pub trait RawLayoutElementHelpers { #[inline] #[allow(unsafe_code)] -pub unsafe fn get_attr_for_layout<'a>( - elem: &'a Element, +pub unsafe fn get_attr_for_layout<'dom>( + elem: &'dom Element, namespace: &Namespace, name: &LocalName, -) -> Option<LayoutDom<Attr>> { +) -> Option<LayoutDom<'dom, Attr>> { // cast to point to T in RefCell<T> directly let attrs = elem.attrs.borrow_for_layout(); attrs @@ -622,7 +620,7 @@ impl RawLayoutElementHelpers for Element { } } -pub trait LayoutElementHelpers { +pub trait LayoutElementHelpers<'dom> { #[allow(unsafe_code)] unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool; #[allow(unsafe_code)] @@ -648,10 +646,10 @@ pub trait LayoutElementHelpers { fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool; /// The shadow root this element is a host of. #[allow(unsafe_code)] - unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>; + unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>; } -impl LayoutElementHelpers for LayoutDom<Element> { +impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> { #[allow(unsafe_code)] #[inline] unsafe fn has_class_for_layout(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { @@ -1097,7 +1095,7 @@ impl LayoutElementHelpers for LayoutDom<Element> { #[inline] #[allow(unsafe_code)] - unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> { + unsafe fn get_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> { (*self.unsafe_get()) .rare_data_for_layout() .as_ref()? diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index 10f3ab5853f..129f96dc910 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -46,11 +46,7 @@ impl ErrorEvent { } pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<ErrorEvent> { - reflect_dom_object( - Box::new(ErrorEvent::new_inherited()), - global, - ErrorEventBinding::Wrap, - ) + reflect_dom_object(Box::new(ErrorEvent::new_inherited()), global) } pub fn new( diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index cc960c7ba1b..aba0179a59b 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -72,7 +72,7 @@ impl Event { } pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> { - reflect_dom_object(Box::new(Event::new_inherited()), global, EventBinding::Wrap) + reflect_dom_object(Box::new(Event::new_inherited()), global) } pub fn new( diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs index 83866370527..101eb851cfb 100644 --- a/components/script/dom/eventsource.rs +++ b/components/script/dom/eventsource.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{ - EventSourceInit, EventSourceMethods, Wrap, + EventSourceInit, EventSourceMethods, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -463,7 +463,6 @@ impl EventSource { reflect_dom_object( Box::new(EventSource::new_inherited(url, with_credentials)), global, - Wrap, ) } diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 90e533c8cc3..bc726d02119 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -15,7 +15,6 @@ use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener use crate::dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; -use crate::dom::bindings::codegen::Bindings::EventTargetBinding::Wrap; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::UnionTypes::AddEventListenerOptionsOrBoolean; use crate::dom::bindings::codegen::UnionTypes::EventListenerOptionsOrBoolean; @@ -340,7 +339,7 @@ impl EventTarget { } fn new(global: &GlobalScope) -> DomRoot<EventTarget> { - reflect_dom_object(Box::new(EventTarget::new_inherited()), global, Wrap) + reflect_dom_object(Box::new(EventTarget::new_inherited()), global) } #[allow(non_snake_case)] diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs index a7b0e2dd581..deb2dce4dfa 100644 --- a/components/script/dom/extendableevent.rs +++ b/components/script/dom/extendableevent.rs @@ -37,11 +37,7 @@ impl ExtendableEvent { bubbles: bool, cancelable: bool, ) -> DomRoot<ExtendableEvent> { - let ev = reflect_dom_object( - Box::new(ExtendableEvent::new_inherited()), - worker, - ExtendableEventBinding::Wrap, - ); + let ev = reflect_dom_object(Box::new(ExtendableEvent::new_inherited()), worker); { let event = ev.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/extendablemessageevent.rs b/components/script/dom/extendablemessageevent.rs index ce9539d091f..8d1a965808b 100644 --- a/components/script/dom/extendablemessageevent.rs +++ b/components/script/dom/extendablemessageevent.rs @@ -73,7 +73,7 @@ impl ExtendableMessageEvent { lastEventId, ports, )); - let ev = reflect_dom_object(ev, global, ExtendableMessageEventBinding::Wrap); + let ev = reflect_dom_object(ev, global); { let event = ev.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/fakexrdevice.rs b/components/script/dom/fakexrdevice.rs index dd599d4a3a4..537251fffed 100644 --- a/components/script/dom/fakexrdevice.rs +++ b/components/script/dom/fakexrdevice.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::{ - self, FakeXRDeviceMethods, FakeXRRigidTransformInit, FakeXRViewInit, + FakeXRDeviceMethods, FakeXRRigidTransformInit, FakeXRViewInit, }; use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputSourceInit; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ @@ -51,11 +51,7 @@ impl FakeXRDevice { } pub fn new(global: &GlobalScope, sender: IpcSender<MockDeviceMsg>) -> DomRoot<FakeXRDevice> { - reflect_dom_object( - Box::new(FakeXRDevice::new_inherited(sender)), - global, - FakeXRDeviceBinding::Wrap, - ) + reflect_dom_object(Box::new(FakeXRDevice::new_inherited(sender)), global) } pub fn disconnect(&self, sender: IpcSender<()>) { diff --git a/components/script/dom/fakexrinputcontroller.rs b/components/script/dom/fakexrinputcontroller.rs index e93d328ff29..5699fa5d747 100644 --- a/components/script/dom/fakexrinputcontroller.rs +++ b/components/script/dom/fakexrinputcontroller.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::FakeXRDeviceBinding::FakeXRRigidTransformInit; -use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::{ - self, FakeXRInputControllerMethods, -}; +use crate::dom::bindings::codegen::Bindings::FakeXRInputControllerBinding::FakeXRInputControllerMethods; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ XRHandedness, XRTargetRayMode, }; @@ -47,7 +45,6 @@ impl FakeXRInputController { reflect_dom_object( Box::new(FakeXRInputController::new_inherited(sender, id)), global, - FakeXRInputControllerBinding::Wrap, ) } diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 9fcd580bbee..cbbc16bd264 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -51,7 +51,6 @@ impl File { let file = reflect_dom_object( Box::new(File::new_inherited(&blob_impl, name, modified)), global, - FileBinding::Wrap, ); global.track_file(&file, blob_impl); file diff --git a/components/script/dom/filelist.rs b/components/script/dom/filelist.rs index a8f7354ad49..de83ccb9db6 100644 --- a/components/script/dom/filelist.rs +++ b/components/script/dom/filelist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::FileListBinding; use crate::dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -34,7 +33,6 @@ impl FileList { files.iter().map(|r| Dom::from_ref(&**r)).collect(), )), window, - FileListBinding::Wrap, ) } diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index 557b2def761..084cecc9577 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -5,7 +5,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::FileReaderBinding::{ - self, FileReaderConstants, FileReaderMethods, + FileReaderConstants, FileReaderMethods, }; use crate::dom::bindings::codegen::UnionTypes::StringOrObject; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -152,11 +152,7 @@ impl FileReader { } pub fn new(global: &GlobalScope) -> DomRoot<FileReader> { - reflect_dom_object( - Box::new(FileReader::new_inherited()), - global, - FileReaderBinding::Wrap, - ) + reflect_dom_object(Box::new(FileReader::new_inherited()), global) } #[allow(non_snake_case)] diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index 5b3ace3863e..044cb48c27d 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; -use crate::dom::bindings::codegen::Bindings::FileReaderSyncBinding::{ - FileReaderSyncBinding, FileReaderSyncMethods, -}; +use crate::dom::bindings::codegen::Bindings::FileReaderSyncBinding::FileReaderSyncMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -33,11 +31,7 @@ impl FileReaderSync { } pub fn new(global: &GlobalScope) -> DomRoot<FileReaderSync> { - reflect_dom_object( - Box::new(FileReaderSync::new_inherited()), - global, - FileReaderSyncBinding::Wrap, - ) + reflect_dom_object(Box::new(FileReaderSync::new_inherited()), global) } #[allow(non_snake_case)] diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 5ff76a0d60e..2d983bcc881 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -32,11 +32,7 @@ impl FocusEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<FocusEvent> { - reflect_dom_object( - Box::new(FocusEvent::new_inherited()), - window, - FocusEventBinding::Wrap, - ) + reflect_dom_object(Box::new(FocusEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 10d1a11f18e..3a8f3ce4b5b 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods; -use crate::dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap; use crate::dom::bindings::codegen::UnionTypes::FileOrUSVString; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -43,11 +42,7 @@ impl FormData { } pub fn new(form_datums: Option<Vec<FormDatum>>, global: &GlobalScope) -> DomRoot<FormData> { - reflect_dom_object( - Box::new(FormData::new_inherited(form_datums)), - global, - FormDataWrap, - ) + reflect_dom_object(Box::new(FormData::new_inherited(form_datums)), global) } // https://xhr.spec.whatwg.org/#dom-formdata diff --git a/components/script/dom/formdataevent.rs b/components/script/dom/formdataevent.rs index 60eb479f7dd..263d176f66f 100644 --- a/components/script/dom/formdataevent.rs +++ b/components/script/dom/formdataevent.rs @@ -38,7 +38,6 @@ impl FormDataEvent { form_data: Dom::from_ref(form_data), }), global, - FormDataEventBinding::Wrap, ); { diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index f91a2ba2591..86a957734dd 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -9,9 +9,7 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelInterpretation, }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; -use crate::dom::bindings::codegen::Bindings::GainNodeBinding::{ - self, GainNodeMethods, GainOptions, -}; +use crate::dom::bindings::codegen::Bindings::GainNodeBinding::{GainNodeMethods, GainOptions}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -69,11 +67,7 @@ impl GainNode { options: &GainOptions, ) -> Fallible<DomRoot<GainNode>> { let node = GainNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - GainNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index 60a73a691fd..7223450c513 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::GamepadBinding; use crate::dom::bindings::codegen::Bindings::GamepadBinding::GamepadMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; @@ -95,7 +94,6 @@ impl Gamepad { data.display_id, )), global, - GamepadBinding::Wrap, ); let cx = global.get_cx(); diff --git a/components/script/dom/gamepadbutton.rs b/components/script/dom/gamepadbutton.rs index 176e5255874..6bcbcc2a724 100644 --- a/components/script/dom/gamepadbutton.rs +++ b/components/script/dom/gamepadbutton.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::GamepadButtonBinding; use crate::dom::bindings::codegen::Bindings::GamepadButtonBinding::GamepadButtonMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -33,7 +32,6 @@ impl GamepadButton { reflect_dom_object( Box::new(GamepadButton::new_inherited(pressed, touched)), global, - GamepadButtonBinding::Wrap, ) } } diff --git a/components/script/dom/gamepadbuttonlist.rs b/components/script/dom/gamepadbuttonlist.rs index e784939c260..496302de9f9 100644 --- a/components/script/dom/gamepadbuttonlist.rs +++ b/components/script/dom/gamepadbuttonlist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::GamepadButtonListBinding; use crate::dom::bindings::codegen::Bindings::GamepadButtonListBinding::GamepadButtonListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, DomSlice}; @@ -34,11 +33,7 @@ impl GamepadButtonList { rooted_vec!(let list <- buttons.iter() .map(|btn| GamepadButton::new(&global, btn.pressed, btn.touched))); - reflect_dom_object( - Box::new(GamepadButtonList::new_inherited(list.r())), - global, - GamepadButtonListBinding::Wrap, - ) + reflect_dom_object(Box::new(GamepadButtonList::new_inherited(list.r())), global) } pub fn sync_from_vr(&self, vr_buttons: &[WebVRGamepadButton]) { diff --git a/components/script/dom/gamepadevent.rs b/components/script/dom/gamepadevent.rs index 3d57645a9be..a6a3ad9e57c 100644 --- a/components/script/dom/gamepadevent.rs +++ b/components/script/dom/gamepadevent.rs @@ -43,11 +43,7 @@ impl GamepadEvent { cancelable: bool, gamepad: &Gamepad, ) -> DomRoot<GamepadEvent> { - let ev = reflect_dom_object( - Box::new(GamepadEvent::new_inherited(&gamepad)), - global, - GamepadEventBinding::Wrap, - ); + let ev = reflect_dom_object(Box::new(GamepadEvent::new_inherited(&gamepad)), global); { let event = ev.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/gamepadlist.rs b/components/script/dom/gamepadlist.rs index 7b81fe7bda7..34479e6bb7c 100644 --- a/components/script/dom/gamepadlist.rs +++ b/components/script/dom/gamepadlist.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GamepadListBinding; use crate::dom::bindings::codegen::Bindings::GamepadListBinding::GamepadListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -27,11 +26,7 @@ impl GamepadList { } pub fn new(global: &GlobalScope, list: &[&Gamepad]) -> DomRoot<GamepadList> { - reflect_dom_object( - Box::new(GamepadList::new_inherited(list)), - global, - GamepadListBinding::Wrap, - ) + reflect_dom_object(Box::new(GamepadList::new_inherited(list)), global) } pub fn add_if_not_exists(&self, gamepads: &[DomRoot<Gamepad>]) { diff --git a/components/script/dom/gpu.rs b/components/script/dom/gpu.rs index e2f7e3e5a82..3980c2a3bd2 100644 --- a/components/script/dom/gpu.rs +++ b/components/script/dom/gpu.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::GPUBinding::GPURequestAdapterOptions; -use crate::dom::bindings::codegen::Bindings::GPUBinding::{self, GPUMethods, GPUPowerPreference}; +use crate::dom::bindings::codegen::Bindings::GPUBinding::{GPUMethods, GPUPowerPreference}; use crate::dom::bindings::error::Error; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -36,7 +36,7 @@ impl GPU { } pub fn new(global: &GlobalScope) -> DomRoot<GPU> { - reflect_dom_object(Box::new(GPU::new_inherited()), global, GPUBinding::Wrap) + reflect_dom_object(Box::new(GPU::new_inherited()), global) } } diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs index 34f040405c1..74a17130c69 100644 --- a/components/script/dom/gpuadapter.rs +++ b/components/script/dom/gpuadapter.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::{ - self, GPUAdapterMethods, GPUDeviceDescriptor, + GPUAdapterMethods, GPUDeviceDescriptor, }; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -61,7 +61,6 @@ impl GPUAdapter { channel, name, extensions, adapter, )), global, - GPUAdapterBinding::Wrap, ) } } diff --git a/components/script/dom/gpubindgroup.rs b/components/script/dom/gpubindgroup.rs index 96f2d8db59b..b7b8cadeacf 100644 --- a/components/script/dom/gpubindgroup.rs +++ b/components/script/dom/gpubindgroup.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::{ - GPUBindGroupBinding, GPUBindGroupMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::GPUBindGroupMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -40,7 +38,6 @@ impl GPUBindGroup { reflect_dom_object( Box::new(GPUBindGroup::new_inherited(bind_group, valid)), global, - GPUBindGroupBinding::Wrap, ) } } diff --git a/components/script/dom/gpubindgrouplayout.rs b/components/script/dom/gpubindgrouplayout.rs index 7651d16b52b..da1e8a19446 100644 --- a/components/script/dom/gpubindgrouplayout.rs +++ b/components/script/dom/gpubindgrouplayout.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{ - self, GPUBindGroupLayoutBindings, GPUBindGroupLayoutMethods, + GPUBindGroupLayoutBindings, GPUBindGroupLayoutMethods, }; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -58,7 +58,6 @@ impl GPUBindGroupLayout { valid, )), global, - GPUBindGroupLayoutBinding::Wrap, ) } } diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs index fc2d17a689e..5da4c445c3e 100644 --- a/components/script/dom/gpubuffer.rs +++ b/components/script/dom/gpubuffer.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{ - self, GPUBufferMethods, GPUBufferSize, -}; +use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{GPUBufferMethods, GPUBufferSize}; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -98,7 +96,6 @@ impl GPUBuffer { channel, buffer, device, state, size, usage, valid, mapping, )), global, - GPUBufferBinding::Wrap, ) } } diff --git a/components/script/dom/gpucommandbuffer.rs b/components/script/dom/gpucommandbuffer.rs index 24cd781c092..b1871051e52 100644 --- a/components/script/dom/gpucommandbuffer.rs +++ b/components/script/dom/gpucommandbuffer.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::GPUCommandBufferBinding::{ - self, GPUCommandBufferMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::Dom; use crate::dom::bindings::root::DomRoot; @@ -62,7 +60,6 @@ impl GPUCommandBuffer { buffers, )), global, - GPUCommandBufferBinding::Wrap, ) } } diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs index 348e77828f1..46d0872643e 100644 --- a/components/script/dom/gpucommandencoder.rs +++ b/components/script/dom/gpucommandencoder.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - self, GPUCommandBufferDescriptor, GPUCommandEncoderMethods, GPUComputePassDescriptor, + GPUCommandBufferDescriptor, GPUCommandEncoderMethods, GPUComputePassDescriptor, }; use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -48,7 +48,6 @@ impl GPUCommandEncoder { reflect_dom_object( Box::new(GPUCommandEncoder::new_inherited(channel, encoder)), global, - GPUCommandEncoderBinding::Wrap, ) } } diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs index a25f47e1330..c7e742cae84 100644 --- a/components/script/dom/gpucomputepassencoder.rs +++ b/components/script/dom/gpucomputepassencoder.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::{ - self, GPUComputePassEncoderMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::GPUComputePassEncoderMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -53,7 +51,6 @@ impl GPUComputePassEncoder { reflect_dom_object( Box::new(GPUComputePassEncoder::new_inherited(channel, parent)), global, - GPUComputePassEncoderBinding::Wrap, ) } } diff --git a/components/script/dom/gpucomputepipeline.rs b/components/script/dom/gpucomputepipeline.rs index 5d7620b4556..a4700db4505 100644 --- a/components/script/dom/gpucomputepipeline.rs +++ b/components/script/dom/gpucomputepipeline.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::{ - GPUComputePipelineBinding, GPUComputePipelineMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineMethods; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::DomRoot; @@ -37,7 +35,6 @@ impl GPUComputePipeline { reflect_dom_object( Box::new(GPUComputePipeline::new_inherited(compute_pipeline)), global, - GPUComputePipelineBinding::Wrap, ) } } diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs index 4a1e4747715..571fde904fd 100644 --- a/components/script/dom/gpudevice.rs +++ b/components/script/dom/gpudevice.rs @@ -13,7 +13,7 @@ use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{ use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUBufferDescriptor; use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineDescriptor; use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::{ - self, GPUCommandEncoderDescriptor, GPUDeviceMethods, + GPUCommandEncoderDescriptor, GPUDeviceMethods, }; use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutDescriptor; use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleDescriptor; @@ -100,7 +100,6 @@ impl GPUDevice { channel, adapter, extensions, limits, device, &queue, )), global, - GPUDeviceBinding::Wrap, ) } } diff --git a/components/script/dom/gpupipelinelayout.rs b/components/script/dom/gpupipelinelayout.rs index 40f5fd9324d..a3f816deb0d 100644 --- a/components/script/dom/gpupipelinelayout.rs +++ b/components/script/dom/gpupipelinelayout.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::{ - self, GPUPipelineLayoutMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -51,7 +49,6 @@ impl GPUPipelineLayout { valid, )), global, - GPUPipelineLayoutBinding::Wrap, ) } } diff --git a/components/script/dom/gpuqueue.rs b/components/script/dom/gpuqueue.rs index c257ec5ef09..1b4ffa590f3 100644 --- a/components/script/dom/gpuqueue.rs +++ b/components/script/dom/gpuqueue.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUQueueBinding::{self, GPUQueueMethods}; +use crate::dom::bindings::codegen::Bindings::GPUQueueBinding::GPUQueueMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -33,11 +33,7 @@ impl GPUQueue { } pub fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<GPUQueue> { - reflect_dom_object( - Box::new(GPUQueue::new_inherited(channel, queue)), - global, - GPUQueueBinding::Wrap, - ) + reflect_dom_object(Box::new(GPUQueue::new_inherited(channel, queue)), global) } } diff --git a/components/script/dom/gpushadermodule.rs b/components/script/dom/gpushadermodule.rs index 241f0650245..07aef69cbcc 100644 --- a/components/script/dom/gpushadermodule.rs +++ b/components/script/dom/gpushadermodule.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::{ - self, GPUShaderModuleMethods, -}; +use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -36,7 +34,6 @@ impl GPUShaderModule { reflect_dom_object( Box::new(GPUShaderModule::new_inherited(shader_module)), global, - GPUShaderModuleBinding::Wrap, ) } } diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index 44a46f162db..046500b9b6d 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -36,7 +36,6 @@ impl HashChangeEvent { reflect_dom_object( Box::new(HashChangeEvent::new_inherited(String::new(), String::new())), window, - HashChangeEventBinding::Wrap, ) } @@ -51,7 +50,6 @@ impl HashChangeEvent { let ev = reflect_dom_object( Box::new(HashChangeEvent::new_inherited(old_url, new_url)), window, - HashChangeEventBinding::Wrap, ); { let event = ev.upcast::<Event>(); diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index f16d24604db..c8d0f79fc82 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HeadersBinding::{ - HeadersInit, HeadersMethods, HeadersWrap, -}; +use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::iterable::Iterable; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -46,7 +44,7 @@ impl Headers { } pub fn new(global: &GlobalScope) -> DomRoot<Headers> { - reflect_dom_object(Box::new(Headers::new_inherited()), global, HeadersWrap) + reflect_dom_object(Box::new(Headers::new_inherited()), global) } // https://fetch.spec.whatwg.org/#dom-headers diff --git a/components/script/dom/history.rs b/components/script/dom/history.rs index ef7a6fbe916..9023a397c66 100644 --- a/components/script/dom/history.rs +++ b/components/script/dom/history.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HistoryBinding; use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods; use crate::dom::bindings::codegen::Bindings::LocationBinding::LocationBinding::LocationMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; @@ -59,11 +58,7 @@ impl History { } pub fn new(window: &Window) -> DomRoot<History> { - reflect_dom_object( - Box::new(History::new_inherited(window)), - window, - HistoryBinding::Wrap, - ) + reflect_dom_object(Box::new(History::new_inherited(window)), window) } } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 00a3fb5a06f..a0f939b93ad 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -5,7 +5,6 @@ use crate::dom::activation::Activatable; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; -use crate::dom::bindings::codegen::Bindings::HTMLAnchorElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLAnchorElementBinding::HTMLAnchorElementMethods; use crate::dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -66,7 +65,6 @@ impl HTMLAnchorElement { local_name, prefix, document, )), document, - HTMLAnchorElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 2e6549f5939..1f25510b819 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::activation::Activatable; -use crate::dom::bindings::codegen::Bindings::HTMLAreaElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLAreaElementBinding::HTMLAreaElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -257,7 +256,6 @@ impl HTMLAreaElement { Node::reflect_node( Box::new(HTMLAreaElement::new_inherited(local_name, prefix, document)), document, - HTMLAreaElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index aa18834e631..db8f1877a6d 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods; -use crate::dom::bindings::codegen::Bindings::HTMLAudioElementBinding; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::inheritance::Castable; @@ -44,7 +43,6 @@ impl HTMLAudioElement { local_name, prefix, document, )), document, - HTMLAudioElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 71aa235df62..e6568716e1f 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLBaseElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLBaseElementBinding::HTMLBaseElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -42,7 +41,6 @@ impl HTMLBaseElement { Node::reflect_node( Box::new(HTMLBaseElement::new_inherited(local_name, prefix, document)), document, - HTMLBaseElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index f59d163d163..0f3a0d51e15 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::{ - self, HTMLBodyElementMethods, -}; +use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; @@ -52,7 +50,6 @@ impl HTMLBodyElement { Node::reflect_node( Box::new(HTMLBodyElement::new_inherited(local_name, prefix, document)), document, - HTMLBodyElementBinding::Wrap, ) } @@ -102,7 +99,7 @@ pub trait HTMLBodyElementLayoutHelpers { fn get_background(&self) -> Option<ServoUrl>; } -impl HTMLBodyElementLayoutHelpers for LayoutDom<HTMLBodyElement> { +impl HTMLBodyElementLayoutHelpers for LayoutDom<'_, HTMLBodyElement> { #[allow(unsafe_code)] fn get_background_color(&self) -> Option<RGBA> { unsafe { diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs index 0a5a5e16566..d087dfffb02 100644 --- a/components/script/dom/htmlbrelement.rs +++ b/components/script/dom/htmlbrelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLBRElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -35,7 +34,6 @@ impl HTMLBRElement { Node::reflect_node( Box::new(HTMLBRElement::new_inherited(local_name, prefix, document)), document, - HTMLBRElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index db5df824fe9..45d1630e6d4 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -4,7 +4,6 @@ use crate::dom::activation::Activatable; use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLButtonElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -74,7 +73,6 @@ impl HTMLButtonElement { local_name, prefix, document, )), document, - HTMLButtonElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index e56ca4a8266..208ee2d2bfa 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::{ HTMLCanvasElementMethods, RenderingContext, }; @@ -86,7 +85,6 @@ impl HTMLCanvasElement { local_name, prefix, document, )), document, - HTMLCanvasElementBinding::Wrap, ) } @@ -122,7 +120,7 @@ pub trait LayoutHTMLCanvasElementHelpers { fn get_canvas_id_for_layout(&self) -> CanvasId; } -impl LayoutHTMLCanvasElementHelpers for LayoutDom<HTMLCanvasElement> { +impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> { #[allow(unsafe_code)] fn data(&self) -> HTMLCanvasData { unsafe { diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 7196e144add..d5198b94986 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -107,7 +106,6 @@ impl HTMLCollection { reflect_dom_object( Box::new(HTMLCollection::new_inherited(root, filter)), window, - HTMLCollectionBinding::Wrap, ) } diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs index 2506d6e7fb4..93594ec8816 100644 --- a/components/script/dom/htmldataelement.rs +++ b/components/script/dom/htmldataelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLDataElementBinding::HTMLDataElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -37,7 +36,6 @@ impl HTMLDataElement { Node::reflect_node( Box::new(HTMLDataElement::new_inherited(local_name, prefix, document)), document, - HTMLDataElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index f5ad519380f..6bddb2800e4 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLDataListElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLDataListElementBinding::HTMLDataListElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -42,7 +41,6 @@ impl HTMLDataListElement { local_name, prefix, document, )), document, - HTMLDataListElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 05742dfe777..314611707ea 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLDetailsElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -48,7 +47,6 @@ impl HTMLDetailsElement { local_name, prefix, document, )), document, - HTMLDetailsElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index d26865bc78a..135f7afe035 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLDialogElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLDialogElementBinding::HTMLDialogElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -45,7 +44,6 @@ impl HTMLDialogElement { local_name, prefix, document, )), document, - HTMLDialogElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs index cc4611b3c40..ce2472be3d3 100644 --- a/components/script/dom/htmldirectoryelement.rs +++ b/components/script/dom/htmldirectoryelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLDirectoryElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLDirectoryElement { local_name, prefix, document, )), document, - HTMLDirectoryElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs index 3c8bc187614..0bd558210a0 100644 --- a/components/script/dom/htmldivelement.rs +++ b/components/script/dom/htmldivelement.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLDivElementBinding::{self, HTMLDivElementMethods}; +use crate::dom::bindings::codegen::Bindings::HTMLDivElementBinding::HTMLDivElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; @@ -36,7 +36,6 @@ impl HTMLDivElement { Node::reflect_node( Box::new(HTMLDivElement::new_inherited(local_name, prefix, document)), document, - HTMLDivElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs index 46a5c3e32fd..356c30c8c94 100644 --- a/components/script/dom/htmldlistelement.rs +++ b/components/script/dom/htmldlistelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLDListElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLDListElement { local_name, prefix, document, )), document, - HTMLDListElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 00d7a64ed32..695cdbe6a49 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -5,7 +5,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull; -use crate::dom::bindings::codegen::Bindings::HTMLElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; @@ -85,7 +84,6 @@ impl HTMLElement { Node::reflect_node( Box::new(HTMLElement::new_inherited(local_name, prefix, document)), document, - HTMLElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs index 729421057f7..e21b8f5ce35 100644 --- a/components/script/dom/htmlembedelement.rs +++ b/components/script/dom/htmlembedelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLEmbedElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLEmbedElement { local_name, prefix, document, )), document, - HTMLEmbedElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index a95d8a8120a..a277cf8e2ec 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods; use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -56,7 +55,6 @@ impl HTMLFieldSetElement { local_name, prefix, document, )), document, - HTMLFieldSetElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index dfdc6b862fb..cb130530703 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLFontElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; @@ -45,7 +44,6 @@ impl HTMLFontElement { Node::reflect_node( Box::new(HTMLFontElement::new_inherited(local_name, prefix, document)), document, - HTMLFontElementBinding::Wrap, ) } } @@ -108,7 +106,7 @@ pub trait HTMLFontElementLayoutHelpers { fn get_size(&self) -> Option<u32>; } -impl HTMLFontElementLayoutHelpers for LayoutDom<HTMLFontElement> { +impl HTMLFontElementLayoutHelpers for LayoutDom<'_, HTMLFontElement> { #[allow(unsafe_code)] fn get_color(&self) -> Option<RGBA> { unsafe { diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs index 59d6b923616..f687870b058 100644 --- a/components/script/dom/htmlformcontrolscollection.rs +++ b/components/script/dom/htmlformcontrolscollection.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; -use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding; use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; use crate::dom::bindings::codegen::UnionTypes::RadioNodeListOrElement; @@ -48,7 +47,6 @@ impl HTMLFormControlsCollection { reflect_dom_object( Box::new(HTMLFormControlsCollection::new_inherited(form, filter)), window, - HTMLFormControlsCollectionBinding::Wrap, ) } diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 30d1857de9d..08f2cf0499c 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -9,7 +9,6 @@ use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLFormControlsCollectionBinding::HTMLFormControlsCollectionMethods; -use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; @@ -115,7 +114,6 @@ impl HTMLFormElement { Node::reflect_node( Box::new(HTMLFormElement::new_inherited(local_name, prefix, document)), document, - HTMLFormElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs index 4afd3bff574..fa3ad51393e 100644 --- a/components/script/dom/htmlframeelement.rs +++ b/components/script/dom/htmlframeelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLFrameElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLFrameElement { local_name, prefix, document, )), document, - HTMLFrameElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs index 66bc28bb4a3..2c7260ee2c1 100644 --- a/components/script/dom/htmlframesetelement.rs +++ b/components/script/dom/htmlframesetelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLFrameSetElementBinding::HTMLFrameSetElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::root::DomRoot; @@ -39,7 +38,6 @@ impl HTMLFrameSetElement { local_name, prefix, document, )), document, - HTMLFrameSetElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index 9bf288639bc..efa0bc7d515 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; -use crate::dom::bindings::codegen::Bindings::HTMLHeadElementBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::{determine_policy_for_token, Document}; @@ -41,7 +40,6 @@ impl HTMLHeadElement { Node::reflect_node( Box::new(HTMLHeadElement::new_inherited(local_name, prefix, document)), document, - HTMLHeadElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index bf6cdc9caea..659cf14f4d2 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLHeadingElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -51,7 +50,6 @@ impl HTMLHeadingElement { local_name, prefix, document, level, )), document, - HTMLHeadingElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 22c58a7e44a..a53d30e700b 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::{self, HTMLHRElementMethods}; +use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; use crate::dom::bindings::str::DOMString; @@ -41,7 +41,6 @@ impl HTMLHRElement { Node::reflect_node( Box::new(HTMLHRElement::new_inherited(local_name, prefix, document)), document, - HTMLHRElementBinding::Wrap, ) } } @@ -71,7 +70,7 @@ pub trait HTMLHRLayoutHelpers { fn get_width(&self) -> LengthOrPercentageOrAuto; } -impl HTMLHRLayoutHelpers for LayoutDom<HTMLHRElement> { +impl HTMLHRLayoutHelpers for LayoutDom<'_, HTMLHRElement> { #[allow(unsafe_code)] fn get_color(&self) -> Option<RGBA> { unsafe { diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs index b95f79e5ac0..05b34dec3dc 100644 --- a/components/script/dom/htmlhtmlelement.rs +++ b/components/script/dom/htmlhtmlelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLHtmlElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -36,7 +35,6 @@ impl HTMLHtmlElement { Node::reflect_node( Box::new(HTMLHtmlElement::new_inherited(localName, prefix, document)), document, - HTMLHtmlElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 94835030c08..16c5c1433b6 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -5,7 +5,6 @@ use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::inheritance::Castable; @@ -429,7 +428,6 @@ impl HTMLIFrameElement { local_name, prefix, document, )), document, - HTMLIFrameElementBinding::Wrap, ) } @@ -488,7 +486,7 @@ pub trait HTMLIFrameElementLayoutMethods { fn get_height(&self) -> LengthOrPercentageOrAuto; } -impl HTMLIFrameElementLayoutMethods for LayoutDom<HTMLIFrameElement> { +impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> { #[inline] #[allow(unsafe_code)] fn pipeline_id(&self) -> Option<PipelineId> { diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 95e5c43af66..386a77041ac 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -8,7 +8,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::{DomRefCell, RefMut}; use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementBinding::ElementMethods; -use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; use crate::dom::bindings::codegen::Bindings::MouseEventBinding::MouseEventMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; @@ -1261,7 +1260,6 @@ impl HTMLImageElement { local_name, prefix, document, )), document, - HTMLImageElementBinding::Wrap, ) } @@ -1384,7 +1382,7 @@ pub trait LayoutHTMLImageElementHelpers { fn get_height(&self) -> LengthOrPercentageOrAuto; } -impl LayoutHTMLImageElementHelpers for LayoutDom<HTMLImageElement> { +impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> { #[allow(unsafe_code)] unsafe fn image(&self) -> Option<Arc<Image>> { (*self.unsafe_get()) diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index c27d5b2f9b5..05eca7b35eb 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -9,7 +9,6 @@ use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::FileListBinding::FileListMethods; use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::SelectionMode; -use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; use crate::dom::bindings::error::{Error, ErrorResult}; @@ -324,7 +323,6 @@ impl HTMLInputElement { local_name, prefix, document, )), document, - HTMLInputElementBinding::Wrap, ) } @@ -728,11 +726,14 @@ unsafe fn get_raw_textinput_value(input: LayoutDom<HTMLInputElement>) -> DOMStri .get_content() } -impl LayoutHTMLInputElementHelpers for LayoutDom<HTMLInputElement> { +impl LayoutHTMLInputElementHelpers for LayoutDom<'_, HTMLInputElement> { #[allow(unsafe_code)] unsafe fn value_for_layout(self) -> String { #[allow(unsafe_code)] - unsafe fn get_raw_attr_value(input: LayoutDom<HTMLInputElement>, default: &str) -> String { + unsafe fn get_raw_attr_value( + input: LayoutDom<'_, HTMLInputElement>, + default: &str, + ) -> String { let elem = input.upcast::<Element>(); let value = (*elem.unsafe_get()) .get_attr_val_for_layout(&ns!(), &local_name!("value")) diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index 3953ed585f7..970f4a97b7a 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -7,7 +7,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::AttrBinding::AttrMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; -use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; use crate::dom::bindings::inheritance::Castable; @@ -52,7 +51,6 @@ impl HTMLLabelElement { local_name, prefix, document, )), document, - HTMLLabelElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index 41cf7d3d8ff..bfb0f0701c8 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -2,7 +2,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -use crate::dom::bindings::codegen::Bindings::HTMLLegendElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLLegendElementBinding::HTMLLegendElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -46,7 +45,6 @@ impl HTMLLegendElement { local_name, prefix, document, )), document, - HTMLLegendElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index 3468fa9ee80..2697f6643e8 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLLIElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLLIElementBinding::HTMLLIElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -40,7 +39,6 @@ impl HTMLLIElement { Node::reflect_node( Box::new(HTMLLIElement::new_inherited(local_name, prefix, document)), document, - HTMLLIElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 8dd50c11441..167420be382 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -5,7 +5,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::DOMTokenListBinding::DOMTokenListBinding::DOMTokenListMethods; -use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -100,7 +99,6 @@ impl HTMLLinkElement { local_name, prefix, document, creator, )), document, - HTMLLinkElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs index 0b6acb3ba31..d3024bb6e95 100644 --- a/components/script/dom/htmlmapelement.rs +++ b/components/script/dom/htmlmapelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLMapElementBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; @@ -37,7 +36,6 @@ impl HTMLMapElement { Node::reflect_node( Box::new(HTMLMapElement::new_inherited(local_name, prefix, document)), document, - HTMLMapElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index f8c686d34f2..f4833de4e51 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -2447,7 +2447,7 @@ pub trait LayoutHTMLMediaElementHelpers { fn data(&self) -> HTMLMediaData; } -impl LayoutHTMLMediaElementHelpers for LayoutDom<HTMLMediaElement> { +impl LayoutHTMLMediaElementHelpers for LayoutDom<'_, HTMLMediaElement> { #[allow(unsafe_code)] fn data(&self) -> HTMLMediaData { let media = unsafe { &*self.unsafe_get() }; diff --git a/components/script/dom/htmlmenuelement.rs b/components/script/dom/htmlmenuelement.rs index b1b9955130c..43e0ff07ed9 100644 --- a/components/script/dom/htmlmenuelement.rs +++ b/components/script/dom/htmlmenuelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLMenuElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLMenuElementBinding::HTMLMenuElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; @@ -36,7 +35,6 @@ impl HTMLMenuElement { Node::reflect_node( Box::new(HTMLMenuElement::new_inherited(local_name, prefix, document)), document, - HTMLMenuElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 3f1876c2923..f91e4339f1d 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -60,7 +59,6 @@ impl HTMLMetaElement { Node::reflect_node( Box::new(HTMLMetaElement::new_inherited(local_name, prefix, document)), document, - HTMLMetaElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs index 780080a6a65..01f3b0dc94c 100644 --- a/components/script/dom/htmlmeterelement.rs +++ b/components/script/dom/htmlmeterelement.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLMeterElementBinding::{ - self, HTMLMeterElementMethods, -}; +use crate::dom::bindings::codegen::Bindings::HTMLMeterElementBinding::HTMLMeterElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::document::Document; @@ -43,7 +41,6 @@ impl HTMLMeterElement { local_name, prefix, document, )), document, - HTMLMeterElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs index 0bfbc4ae652..d54156bbbc8 100644 --- a/components/script/dom/htmlmodelement.rs +++ b/components/script/dom/htmlmodelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLModElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -35,7 +34,6 @@ impl HTMLModElement { Node::reflect_node( Box::new(HTMLModElement::new_inherited(local_name, prefix, document)), document, - HTMLModElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 002b0aa3913..a218259e8cb 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLObjectElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -55,7 +54,6 @@ impl HTMLObjectElement { local_name, prefix, document, )), document, - HTMLObjectElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs index a99120692c1..456625d6447 100644 --- a/components/script/dom/htmlolistelement.rs +++ b/components/script/dom/htmlolistelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLOListElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLOListElement { local_name, prefix, document, )), document, - HTMLOListElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index f8588acc17d..4ee3263c9ac 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::DomRoot; @@ -49,7 +48,6 @@ impl HTMLOptGroupElement { local_name, prefix, document, )), document, - HTMLOptGroupElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index ca95400dc80..0ba7eadcf11 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; -use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementBinding::HTMLSelectElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; @@ -72,7 +71,6 @@ impl HTMLOptionElement { local_name, prefix, document, )), document, - HTMLOptionElementBinding::Wrap, ) } diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 8eb0c4e284b..2a79c83d55e 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; -use crate::dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding; use crate::dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; @@ -47,7 +46,6 @@ impl HTMLOptionsCollection { reflect_dom_object( Box::new(HTMLOptionsCollection::new_inherited(select, filter)), window, - HTMLOptionsCollectionBinding::Wrap, ) } diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 12d2e415ae1..ac21b2e97a0 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLOutputElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLOutputElementBinding::HTMLOutputElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -53,7 +52,6 @@ impl HTMLOutputElement { local_name, prefix, document, )), document, - HTMLOutputElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index 5a796c29340..101f7058138 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLParagraphElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLParagraphElement { local_name, prefix, document, )), document, - HTMLParagraphElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs index de00254124b..fd1a139a84d 100644 --- a/components/script/dom/htmlparamelement.rs +++ b/components/script/dom/htmlparamelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLParamElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLParamElement { local_name, prefix, document, )), document, - HTMLParamElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlpictureelement.rs b/components/script/dom/htmlpictureelement.rs index 7d6782a539a..726f7afd5f8 100644 --- a/components/script/dom/htmlpictureelement.rs +++ b/components/script/dom/htmlpictureelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLPictureElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLPictureElement { local_name, prefix, document, )), document, - HTMLPictureElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs index bd0ca058e22..36e2706e168 100644 --- a/components/script/dom/htmlpreelement.rs +++ b/components/script/dom/htmlpreelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLPreElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -35,7 +34,6 @@ impl HTMLPreElement { Node::reflect_node( Box::new(HTMLPreElement::new_inherited(local_name, prefix, document)), document, - HTMLPreElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs index 0c4789fdc14..dcd2f018734 100644 --- a/components/script/dom/htmlprogresselement.rs +++ b/components/script/dom/htmlprogresselement.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLProgressElementBinding::{ - self, HTMLProgressElementMethods, -}; +use crate::dom::bindings::codegen::Bindings::HTMLProgressElementBinding::HTMLProgressElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::document::Document; @@ -43,7 +41,6 @@ impl HTMLProgressElement { local_name, prefix, document, )), document, - HTMLProgressElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs index 69816ea13e6..4ad38f78338 100644 --- a/components/script/dom/htmlquoteelement.rs +++ b/components/script/dom/htmlquoteelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLQuoteElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLQuoteElement { local_name, prefix, document, )), document, - HTMLQuoteElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 66a2cddc777..03bb0d73a07 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -5,7 +5,6 @@ use crate::document_loader::LoadType; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; -use crate::dom::bindings::codegen::Bindings::HTMLScriptElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLScriptElementBinding::HTMLScriptElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -114,7 +113,6 @@ impl HTMLScriptElement { local_name, prefix, document, creator, )), document, - HTMLScriptElementBinding::Wrap, ) } @@ -460,6 +458,7 @@ impl HTMLScriptElement { &text, ) == csp::CheckResult::Blocked { + warn!("Blocking inline script due to CSP"); return; } diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 78a26ca4311..97474969ab2 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -7,7 +7,6 @@ use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; use crate::dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLOptionsCollectionBinding::HTMLOptionsCollectionMethods; -use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::UnionTypes::HTMLElementOrLong; @@ -97,7 +96,6 @@ impl HTMLSelectElement { local_name, prefix, document, )), document, - HTMLSelectElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index f93de93599d..5b581e466b5 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLSourceElementBinding::HTMLSourceElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -47,7 +46,6 @@ impl HTMLSourceElement { local_name, prefix, document, )), document, - HTMLSourceElementBinding::Wrap, ) } diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs index 3cf2846f725..e8a374f5f9b 100644 --- a/components/script/dom/htmlspanelement.rs +++ b/components/script/dom/htmlspanelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLSpanElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -35,7 +34,6 @@ impl HTMLSpanElement { Node::reflect_node( Box::new(HTMLSpanElement::new_inherited(local_name, prefix, document)), document, - HTMLSpanElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index e483453252a..afa99d8d86b 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLStyleElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLStyleElementBinding::HTMLStyleElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -75,7 +74,6 @@ impl HTMLStyleElement { local_name, prefix, document, creator, )), document, - HTMLStyleElementBinding::Wrap, ) } diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs index fe66d4f23d4..e6ff3da673e 100644 --- a/components/script/dom/htmltablecaptionelement.rs +++ b/components/script/dom/htmltablecaptionelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTableCaptionElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLTableCaptionElement { local_name, prefix, document, )), document, - HTMLTableCaptionElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index a69565d03f6..aa3db5733bc 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -51,7 +50,6 @@ impl HTMLTableCellElement { local_name, prefix, document, )), document, - HTMLTableCellElementBinding::Wrap, ) } } @@ -107,7 +105,7 @@ pub trait HTMLTableCellElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableCellElementLayoutHelpers for LayoutDom<HTMLTableCellElement> { +impl HTMLTableCellElementLayoutHelpers for LayoutDom<'_, HTMLTableCellElement> { fn get_background_color(&self) -> Option<RGBA> { unsafe { (&*self.upcast::<Element>().unsafe_get()) diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs index e4cfa4a5afe..7dcd27d953d 100644 --- a/components/script/dom/htmltablecolelement.rs +++ b/components/script/dom/htmltablecolelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTableColElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLTableColElement { local_name, prefix, document, )), document, - HTMLTableColElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index bc4724493c4..5bdb7f75281 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods; -use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -76,7 +75,6 @@ impl HTMLTableElement { local_name, prefix, document, )), document, - HTMLTableElementBinding::Wrap, ) } @@ -414,7 +412,7 @@ pub trait HTMLTableElementLayoutHelpers { fn get_width(&self) -> LengthOrPercentageOrAuto; } -impl HTMLTableElementLayoutHelpers for LayoutDom<HTMLTableElement> { +impl HTMLTableElementLayoutHelpers for LayoutDom<'_, HTMLTableElement> { #[allow(unsafe_code)] fn get_background_color(&self) -> Option<RGBA> { unsafe { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index fbe7ef0cfc8..9a6b5b875cc 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods; -use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::{ - self, HTMLTableRowElementMethods, -}; +use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::HTMLTableRowElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::error::{ErrorResult, Fallible}; @@ -64,7 +62,6 @@ impl HTMLTableRowElement { local_name, prefix, document, )), document, - HTMLTableRowElementBinding::Wrap, ) } @@ -153,7 +150,7 @@ pub trait HTMLTableRowElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableRowElementLayoutHelpers for LayoutDom<HTMLTableRowElement> { +impl HTMLTableRowElementLayoutHelpers for LayoutDom<'_, HTMLTableRowElement> { fn get_background_color(&self) -> Option<RGBA> { unsafe { (&*self.upcast::<Element>().unsafe_get()) diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 6d31e1ad0c6..c680da2ad23 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{ - self, HTMLTableSectionElementMethods, -}; +use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::error::{ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -49,7 +47,6 @@ impl HTMLTableSectionElement { local_name, prefix, document, )), document, - HTMLTableSectionElementBinding::Wrap, ) } } @@ -91,7 +88,7 @@ pub trait HTMLTableSectionElementLayoutHelpers { } #[allow(unsafe_code)] -impl HTMLTableSectionElementLayoutHelpers for LayoutDom<HTMLTableSectionElement> { +impl HTMLTableSectionElementLayoutHelpers for LayoutDom<'_, HTMLTableSectionElement> { fn get_background_color(&self) -> Option<RGBA> { unsafe { (&*self.upcast::<Element>().unsafe_get()) diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 8874c94bdb8..87f2063f5e3 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; -use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -47,7 +46,6 @@ impl HTMLTemplateElement { local_name, prefix, document, )), document, - HTMLTemplateElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index d077d9eec8f..8ee42bc2c86 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -6,7 +6,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; use crate::dom::bindings::codegen::Bindings::HTMLFormElementBinding::SelectionMode; -use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::error::ErrorResult; @@ -67,7 +66,7 @@ pub trait LayoutHTMLTextAreaElementHelpers { fn get_rows(self) -> u32; } -impl LayoutHTMLTextAreaElementHelpers for LayoutDom<HTMLTextAreaElement> { +impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> { #[allow(unrooted_must_root)] #[allow(unsafe_code)] unsafe fn value_for_layout(self) -> String { @@ -170,7 +169,6 @@ impl HTMLTextAreaElement { local_name, prefix, document, )), document, - HTMLTextAreaElementBinding::Wrap, ) } diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs index 803920c9d5a..2b0974dd76c 100644 --- a/components/script/dom/htmltimeelement.rs +++ b/components/script/dom/htmltimeelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTimeElementBinding::HTMLTimeElementMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -37,7 +36,6 @@ impl HTMLTimeElement { Node::reflect_node( Box::new(HTMLTimeElement::new_inherited(local_name, prefix, document)), document, - HTMLTimeElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index a1e543d34e2..7fce947e626 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLTitleElementBinding::HTMLTitleElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::inheritance::Castable; @@ -42,7 +41,6 @@ impl HTMLTitleElement { local_name, prefix, document, )), document, - HTMLTitleElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs index c67701b3894..c068bd88295 100644 --- a/components/script/dom/htmltrackelement.rs +++ b/components/script/dom/htmltrackelement.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::HTMLTrackElementBinding::{ - self, HTMLTrackElementConstants, HTMLTrackElementMethods, + HTMLTrackElementConstants, HTMLTrackElementMethods, }; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -66,7 +66,6 @@ impl HTMLTrackElement { local_name, prefix, document, &track, )), document, - HTMLTrackElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs index 891f1a69ceb..aab11124365 100644 --- a/components/script/dom/htmlulistelement.rs +++ b/components/script/dom/htmlulistelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLUListElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLUListElement { local_name, prefix, document, )), document, - HTMLUListElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs index 4213daeceee..27fa932e936 100644 --- a/components/script/dom/htmlunknownelement.rs +++ b/components/script/dom/htmlunknownelement.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::HTMLUnknownElementBinding; use crate::dom::bindings::root::DomRoot; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; @@ -37,7 +36,6 @@ impl HTMLUnknownElement { local_name, prefix, document, )), document, - HTMLUnknownElementBinding::Wrap, ) } } diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index 69f8b9a85e6..f83c05bbe0a 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -5,7 +5,6 @@ use crate::document_loader::{LoadBlocker, LoadType}; use crate::dom::attr::Attr; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::HTMLVideoElementBinding; use crate::dom::bindings::codegen::Bindings::HTMLVideoElementBinding::HTMLVideoElementMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -90,7 +89,6 @@ impl HTMLVideoElement { local_name, prefix, document, )), document, - HTMLVideoElementBinding::Wrap, ) } diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index e17c82fffd4..bc605b5f029 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::ImageDataBinding; use crate::dom::bindings::codegen::Bindings::ImageDataBinding::ImageDataMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -91,11 +90,7 @@ impl ImageData { (*imagedata).data.set(jsobject); - Ok(reflect_dom_object( - imagedata, - global, - ImageDataBinding::Wrap, - )) + Ok(reflect_dom_object(imagedata, global)) } #[allow(unsafe_code)] @@ -121,11 +116,7 @@ impl ImageData { Uint8ClampedArray::create(*cx, CreateWith::Length(len), array.handle_mut()).unwrap(); (*imagedata).data.set(array.get()); - Ok(reflect_dom_object( - imagedata, - global, - ImageDataBinding::Wrap, - )) + Ok(reflect_dom_object(imagedata, global)) } // https://html.spec.whatwg.org/multipage/#pixel-manipulation:dom-imagedata-3 #[allow(unsafe_code, non_snake_case)] diff --git a/components/script/dom/inputevent.rs b/components/script/dom/inputevent.rs index 7ef60327fcb..33a4ed3bbdb 100644 --- a/components/script/dom/inputevent.rs +++ b/components/script/dom/inputevent.rs @@ -37,7 +37,6 @@ impl InputEvent { is_composing: is_composing, }), window, - InputEventBinding::Wrap, ); ev.uievent .InitUIEvent(type_, can_bubble, cancelable, view, detail); diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index d2fdda5fcef..12668a6c214 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -52,11 +52,7 @@ impl KeyboardEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<KeyboardEvent> { - reflect_dom_object( - Box::new(KeyboardEvent::new_inherited()), - window, - KeyboardEventBinding::Wrap, - ) + reflect_dom_object(Box::new(KeyboardEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index df7f475b2d8..aac4cc30b97 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::LocationBinding; use crate::dom::bindings::codegen::Bindings::LocationBinding::LocationMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -33,11 +32,7 @@ impl Location { } pub fn new(window: &Window) -> DomRoot<Location> { - reflect_dom_object( - Box::new(Location::new_inherited(window)), - window, - LocationBinding::Wrap, - ) + reflect_dom_object(Box::new(Location::new_inherited(window)), window) } /// https://html.spec.whatwg.org/multipage/#location-object-navigate diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 1abf3056e95..1a2a17d652c 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -601,7 +601,6 @@ macro_rules! rooted_vec { /// DOM struct implementation for simple interfaces inheriting from PerformanceEntry. macro_rules! impl_performance_entry_struct( ($binding:ident, $struct:ident, $type:expr) => ( - use crate::dom::bindings::codegen::Bindings::$binding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -631,7 +630,7 @@ macro_rules! impl_performance_entry_struct( start_time: f64, duration: f64) -> DomRoot<$struct> { let entry = $struct::new_inherited(name, start_time, duration); - reflect_dom_object(Box::new(entry), global, $binding::Wrap) + reflect_dom_object(Box::new(entry), global) } } ); diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs index c1d45e36d30..1352cf4b128 100644 --- a/components/script/dom/mediadevices.rs +++ b/components/script/dom/mediadevices.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaDevicesMethods; use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::MediaStreamConstraints; -use crate::dom::bindings::codegen::Bindings::MediaDevicesBinding::{self, MediaDevicesMethods}; use crate::dom::bindings::codegen::UnionTypes::BooleanOrMediaTrackConstraints; use crate::dom::bindings::codegen::UnionTypes::ClampedUnsignedLongOrConstrainULongRange as ConstrainULong; use crate::dom::bindings::codegen::UnionTypes::DoubleOrConstrainDoubleRange as ConstrainDouble; @@ -35,11 +35,7 @@ impl MediaDevices { } pub fn new(global: &GlobalScope) -> DomRoot<MediaDevices> { - reflect_dom_object( - Box::new(MediaDevices::new_inherited()), - global, - MediaDevicesBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaDevices::new_inherited()), global) } } diff --git a/components/script/dom/mediaelementaudiosourcenode.rs b/components/script/dom/mediaelementaudiosourcenode.rs index f748ac0251d..29737fc3bc0 100644 --- a/components/script/dom/mediaelementaudiosourcenode.rs +++ b/components/script/dom/mediaelementaudiosourcenode.rs @@ -4,7 +4,6 @@ use crate::dom::audiocontext::AudioContext; use crate::dom::audionode::AudioNode; -use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding; use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding::MediaElementAudioSourceNodeMethods; use crate::dom::bindings::codegen::Bindings::MediaElementAudioSourceNodeBinding::MediaElementAudioSourceOptions; use crate::dom::bindings::error::Fallible; @@ -56,11 +55,7 @@ impl MediaElementAudioSourceNode { media_element: &HTMLMediaElement, ) -> Fallible<DomRoot<MediaElementAudioSourceNode>> { let node = MediaElementAudioSourceNode::new_inherited(context, media_element)?; - Ok(reflect_dom_object( - Box::new(node), - window, - MediaElementAudioSourceNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/mediaerror.rs b/components/script/dom/mediaerror.rs index 19a87d648da..ace68e43583 100644 --- a/components/script/dom/mediaerror.rs +++ b/components/script/dom/mediaerror.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::{self, MediaErrorMethods}; +use crate::dom::bindings::codegen::Bindings::MediaErrorBinding::MediaErrorMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -24,11 +24,7 @@ impl MediaError { } pub fn new(window: &Window, code: u16) -> DomRoot<MediaError> { - reflect_dom_object( - Box::new(MediaError::new_inherited(code)), - window, - MediaErrorBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaError::new_inherited(code)), window) } } diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index e09ed4cdf0a..de0f61d0c00 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MediaListBinding; use crate::dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -50,7 +49,6 @@ impl MediaList { reflect_dom_object( Box::new(MediaList::new_inherited(parent_stylesheet, media_queries)), window, - MediaListBinding::Wrap, ) } diff --git a/components/script/dom/mediametadata.rs b/components/script/dom/mediametadata.rs index 53346eba167..3abe0a1a20c 100644 --- a/components/script/dom/mediametadata.rs +++ b/components/script/dom/mediametadata.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding; use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataInit; use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataMethods; use crate::dom::bindings::error::Fallible; @@ -35,11 +34,7 @@ impl MediaMetadata { } pub fn new(global: &Window, init: &MediaMetadataInit) -> DomRoot<MediaMetadata> { - reflect_dom_object( - Box::new(MediaMetadata::new_inherited(init)), - global, - MediaMetadataBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaMetadata::new_inherited(init)), global) } /// https://w3c.github.io/mediasession/#dom-mediametadata-mediametadata diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index 45797e0090f..48080f95adf 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -5,7 +5,7 @@ use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions; -use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::{self, MediaQueryListMethods}; +use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -45,7 +45,6 @@ impl MediaQueryList { reflect_dom_object( Box::new(MediaQueryList::new_inherited(document, media_query_list)), document.window(), - MediaQueryListBinding::Wrap, ) } } diff --git a/components/script/dom/mediaquerylistevent.rs b/components/script/dom/mediaquerylistevent.rs index 6e05b50998a..c34c3d5116f 100644 --- a/components/script/dom/mediaquerylistevent.rs +++ b/components/script/dom/mediaquerylistevent.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding; use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryListEventInit; use crate::dom::bindings::codegen::Bindings::MediaQueryListEventBinding::MediaQueryListEventMethods; use crate::dom::bindings::error::Fallible; @@ -37,7 +36,7 @@ impl MediaQueryListEvent { media: media, matches: Cell::new(matches), }); - reflect_dom_object(ev, global, MediaQueryListEventBinding::Wrap) + reflect_dom_object(ev, global) } pub fn new( diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs index 54a6d2d3660..f77efe3f54f 100644 --- a/components/script/dom/mediasession.rs +++ b/components/script/dom/mediasession.rs @@ -7,7 +7,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::HTMLMediaElementBinding::HTMLMediaElementMethods; use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataInit; use crate::dom::bindings::codegen::Bindings::MediaMetadataBinding::MediaMetadataMethods; -use crate::dom::bindings::codegen::Bindings::MediaSessionBinding; use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaPositionState; use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionAction; use crate::dom::bindings::codegen::Bindings::MediaSessionBinding::MediaSessionActionHandler; @@ -60,11 +59,7 @@ impl MediaSession { } pub fn new(window: &Window) -> DomRoot<MediaSession> { - reflect_dom_object( - Box::new(MediaSession::new_inherited()), - window, - MediaSessionBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaSession::new_inherited()), window) } pub fn register_media_instance(&self, media_instance: &HTMLMediaElement) { diff --git a/components/script/dom/mediastream.rs b/components/script/dom/mediastream.rs index 553177ce964..1c9c7646939 100644 --- a/components/script/dom/mediastream.rs +++ b/components/script/dom/mediastream.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::{self, MediaStreamMethods}; +use crate::dom::bindings::codegen::Bindings::MediaStreamBinding::MediaStreamMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -31,11 +31,7 @@ impl MediaStream { } pub fn new(global: &GlobalScope) -> DomRoot<MediaStream> { - reflect_dom_object( - Box::new(MediaStream::new_inherited()), - global, - MediaStreamBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaStream::new_inherited()), global) } pub fn Constructor(global: &Window) -> Fallible<DomRoot<MediaStream>> { diff --git a/components/script/dom/mediastreamtrack.rs b/components/script/dom/mediastreamtrack.rs index 2cc0bde7442..c5178b3682b 100644 --- a/components/script/dom/mediastreamtrack.rs +++ b/components/script/dom/mediastreamtrack.rs @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MediaStreamTrackBinding::{ - self, MediaStreamTrackMethods, -}; +use crate::dom::bindings::codegen::Bindings::MediaStreamTrackBinding::MediaStreamTrackMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -37,11 +35,7 @@ impl MediaStreamTrack { id: MediaStreamId, ty: MediaStreamType, ) -> DomRoot<MediaStreamTrack> { - reflect_dom_object( - Box::new(MediaStreamTrack::new_inherited(id, ty)), - global, - MediaStreamTrackBinding::Wrap, - ) + reflect_dom_object(Box::new(MediaStreamTrack::new_inherited(id, ty)), global) } pub fn id(&self) -> MediaStreamId { diff --git a/components/script/dom/messagechannel.rs b/components/script/dom/messagechannel.rs index 20a8b19a745..3075dac3088 100644 --- a/components/script/dom/messagechannel.rs +++ b/components/script/dom/messagechannel.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MessageChannelBinding::{MessageChannelMethods, Wrap}; +use crate::dom::bindings::codegen::Bindings::MessageChannelBinding::MessageChannelMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::globalscope::GlobalScope; @@ -44,7 +44,6 @@ impl MessageChannel { reflect_dom_object( Box::new(MessageChannel::new_inherited(&*port1, &*port2)), incumbent, - Wrap, ) } diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index 447c2f3ccd1..c00e2bc5dec 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -115,7 +115,7 @@ impl MessageEvent { lastEventId, ports, )); - let ev = reflect_dom_object(ev, global, MessageEventBinding::Wrap); + let ev = reflect_dom_object(ev, global); ev.data.set(data.get()); ev diff --git a/components/script/dom/messageport.rs b/components/script/dom/messageport.rs index ee2f54323a6..fee7c75a9eb 100644 --- a/components/script/dom/messageport.rs +++ b/components/script/dom/messageport.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::{ - MessagePortMethods, PostMessageOptions, Wrap, + MessagePortMethods, PostMessageOptions, }; use crate::dom::bindings::conversions::root_from_object; use crate::dom::bindings::error::{Error, ErrorResult}; @@ -51,7 +51,7 @@ impl MessagePort { /// <https://html.spec.whatwg.org/multipage/#create-a-new-messageport-object> pub fn new(owner: &GlobalScope) -> DomRoot<MessagePort> { let port_id = MessagePortId::new(); - reflect_dom_object(Box::new(MessagePort::new_inherited(port_id)), owner, Wrap) + reflect_dom_object(Box::new(MessagePort::new_inherited(port_id)), owner) } /// Create a new port for an incoming transfer-received one. @@ -68,7 +68,6 @@ impl MessagePort { entangled_port: RefCell::new(entangled_port), }), owner, - Wrap, ) } diff --git a/components/script/dom/mimetypearray.rs b/components/script/dom/mimetypearray.rs index 3bfdf4129be..9bbda92e231 100644 --- a/components/script/dom/mimetypearray.rs +++ b/components/script/dom/mimetypearray.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MimeTypeArrayBinding; use crate::dom::bindings::codegen::Bindings::MimeTypeArrayBinding::MimeTypeArrayMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -24,11 +23,7 @@ impl MimeTypeArray { } pub fn new(global: &GlobalScope) -> DomRoot<MimeTypeArray> { - reflect_dom_object( - Box::new(MimeTypeArray::new_inherited()), - global, - MimeTypeArrayBinding::Wrap, - ) + reflect_dom_object(Box::new(MimeTypeArray::new_inherited()), global) } } diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 3975f57ace0..d5fbe6b15e8 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -71,11 +71,7 @@ impl MouseEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<MouseEvent> { - reflect_dom_object( - Box::new(MouseEvent::new_inherited()), - window, - MouseEventBinding::Wrap, - ) + reflect_dom_object(Box::new(MouseEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/mutationobserver.rs b/components/script/dom/mutationobserver.rs index 111fc00f795..e4141af14a6 100644 --- a/components/script/dom/mutationobserver.rs +++ b/components/script/dom/mutationobserver.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::MutationObserverBinding; use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationCallback; use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverBinding::MutationObserverMethods; use crate::dom::bindings::codegen::Bindings::MutationObserverBinding::MutationObserverInit; @@ -67,7 +66,7 @@ pub struct ObserverOptions { impl MutationObserver { fn new(global: &Window, callback: Rc<MutationCallback>) -> DomRoot<MutationObserver> { let boxed_observer = Box::new(MutationObserver::new_inherited(callback)); - reflect_dom_object(boxed_observer, global, MutationObserverBinding::Wrap) + reflect_dom_object(boxed_observer, global) } fn new_inherited(callback: Rc<MutationCallback>) -> MutationObserver { diff --git a/components/script/dom/mutationrecord.rs b/components/script/dom/mutationrecord.rs index 793ef7f52cf..d880f44a8ae 100644 --- a/components/script/dom/mutationrecord.rs +++ b/components/script/dom/mutationrecord.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding; use crate::dom::bindings::codegen::Bindings::MutationRecordBinding::MutationRecordBinding::MutationRecordMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -45,11 +44,7 @@ impl MutationRecord { None, None, )); - reflect_dom_object( - record, - &*window_from_node(target), - MutationRecordBinding::Wrap, - ) + reflect_dom_object(record, &*window_from_node(target)) } pub fn character_data_mutated( @@ -69,7 +64,6 @@ impl MutationRecord { None, )), &*window_from_node(target), - MutationRecordBinding::Wrap, ) } @@ -98,7 +92,6 @@ impl MutationRecord { prev_sibling, )), &*window, - MutationRecordBinding::Wrap, ) } diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs index 3fd9ed3e30c..a7c3e4fef86 100644 --- a/components/script/dom/namednodemap.rs +++ b/components/script/dom/namednodemap.rs @@ -4,7 +4,6 @@ use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; -use crate::dom::bindings::codegen::Bindings::NamedNodeMapBinding; use crate::dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -31,11 +30,7 @@ impl NamedNodeMap { } pub fn new(window: &Window, elem: &Element) -> DomRoot<NamedNodeMap> { - reflect_dom_object( - Box::new(NamedNodeMap::new_inherited(elem)), - window, - NamedNodeMapBinding::Wrap, - ) + reflect_dom_object(Box::new(NamedNodeMap::new_inherited(elem)), window) } } diff --git a/components/script/dom/navigationpreloadmanager.rs b/components/script/dom/navigationpreloadmanager.rs index 78104ec7c45..7586f0a040f 100644 --- a/components/script/dom/navigationpreloadmanager.rs +++ b/components/script/dom/navigationpreloadmanager.rs @@ -2,10 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::NavigationPreloadManagerMethods; use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::NavigationPreloadState; -use crate::dom::bindings::codegen::Bindings::NavigationPreloadManagerBinding::{ - NavigationPreloadManagerMethods, Wrap, -}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::ByteString; @@ -38,7 +36,7 @@ impl NavigationPreloadManager { registration: &ServiceWorkerRegistration, ) -> DomRoot<NavigationPreloadManager> { let manager = NavigationPreloadManager::new_inherited(&*registration); - reflect_dom_object(Box::new(manager), global, Wrap) + reflect_dom_object(Box::new(manager), global) } } diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index b297b02bc69..7d120ba2eba 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::NavigatorBinding; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -58,11 +57,7 @@ impl Navigator { } pub fn new(window: &Window) -> DomRoot<Navigator> { - reflect_dom_object( - Box::new(Navigator::new_inherited()), - window, - NavigatorBinding::Wrap, - ) + reflect_dom_object(Box::new(Navigator::new_inherited()), window) } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 05b81a84d5d..08fe3282be1 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -26,7 +26,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::{Castable, CharacterDataTypeId, ElementTypeId}; use crate::dom::bindings::inheritance::{EventTargetTypeId, HTMLElementTypeId, NodeTypeId}; use crate::dom::bindings::inheritance::{SVGElementTypeId, SVGGraphicsElementTypeId, TextTypeId}; -use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; +use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, DomObjectWrap}; use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom}; use crate::dom::bindings::str::{DOMString, USVString}; use crate::dom::bindings::xmlname::namespace_from_domstring; @@ -39,7 +39,6 @@ use crate::dom::documenttype::DocumentType; use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator}; use crate::dom::event::{Event, EventBubbles, EventCancelable}; use crate::dom::eventtarget::EventTarget; -use crate::dom::globalscope::GlobalScope; use crate::dom::htmlbodyelement::HTMLBodyElement; use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutHTMLCanvasElementHelpers}; use crate::dom::htmlcollection::HTMLCollection; @@ -64,7 +63,6 @@ use crate::dom::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement}; use crate::dom::text::Text; use crate::dom::virtualmethods::{vtable_for, VirtualMethods}; use crate::dom::window::Window; -use crate::script_runtime::JSContext; use crate::script_thread::ScriptThread; use app_units::Au; use crossbeam_channel::Sender; @@ -1306,17 +1304,17 @@ pub unsafe fn from_untrusted_node_address( } #[allow(unsafe_code)] -pub trait LayoutNodeHelpers { +pub trait LayoutNodeHelpers<'dom> { unsafe fn type_id_for_layout(&self) -> NodeTypeId; - unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>>; - unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>>; - unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>>; - unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>>; - unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>>; + unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>>; + unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>>; + unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>>; + unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>; + unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>>; - unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document>; - unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>>; + unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document>; + unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>>; unsafe fn is_element_for_layout(&self) -> bool; unsafe fn get_flag(&self, flag: NodeFlags) -> bool; @@ -1341,7 +1339,7 @@ pub trait LayoutNodeHelpers { fn opaque(&self) -> OpaqueNode; } -impl LayoutNodeHelpers for LayoutDom<Node> { +impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> { #[inline] #[allow(unsafe_code)] unsafe fn type_id_for_layout(&self) -> NodeTypeId { @@ -1356,7 +1354,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> { #[inline] #[allow(unsafe_code)] - unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<Node>> { + unsafe fn composed_parent_node_ref(&self) -> Option<LayoutDom<'dom, Node>> { let parent = (*self.unsafe_get()).parent_node.get_inner_as_layout(); if let Some(ref parent) = parent { if let Some(shadow_root) = parent.downcast::<ShadowRoot>() { @@ -1368,31 +1366,31 @@ impl LayoutNodeHelpers for LayoutDom<Node> { #[inline] #[allow(unsafe_code)] - unsafe fn first_child_ref(&self) -> Option<LayoutDom<Node>> { + unsafe fn first_child_ref(&self) -> Option<LayoutDom<'dom, Node>> { (*self.unsafe_get()).first_child.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn last_child_ref(&self) -> Option<LayoutDom<Node>> { + unsafe fn last_child_ref(&self) -> Option<LayoutDom<'dom, Node>> { (*self.unsafe_get()).last_child.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<Node>> { + unsafe fn prev_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> { (*self.unsafe_get()).prev_sibling.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<Node>> { + unsafe fn next_sibling_ref(&self) -> Option<LayoutDom<'dom, Node>> { (*self.unsafe_get()).next_sibling.get_inner_as_layout() } #[inline] #[allow(unsafe_code)] - unsafe fn owner_doc_for_layout(&self) -> LayoutDom<Document> { + unsafe fn owner_doc_for_layout(&self) -> LayoutDom<'dom, Document> { (*self.unsafe_get()) .owner_doc .get_inner_as_layout() @@ -1401,7 +1399,7 @@ impl LayoutNodeHelpers for LayoutDom<Node> { #[inline] #[allow(unsafe_code)] - unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<ShadowRoot>> { + unsafe fn containing_shadow_root_for_layout(&self) -> Option<LayoutDom<'dom, ShadowRoot>> { (*self.unsafe_get()) .rare_data_for_layout() .as_ref()? @@ -1741,16 +1739,12 @@ fn as_uintptr<T>(t: &T) -> uintptr_t { } impl Node { - pub fn reflect_node<N>( - node: Box<N>, - document: &Document, - wrap_fn: unsafe fn(JSContext, &GlobalScope, Box<N>) -> DomRoot<N>, - ) -> DomRoot<N> + pub fn reflect_node<N>(node: Box<N>, document: &Document) -> DomRoot<N> where - N: DerivedFrom<Node> + DomObject, + N: DerivedFrom<Node> + DomObject + DomObjectWrap, { let window = document.window(); - reflect_dom_object(node, window, wrap_fn) + reflect_dom_object(node, window) } pub fn new_inherited(doc: &Document) -> Node { diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index 8fb659d6b81..a141785a85d 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -6,7 +6,6 @@ use crate::dom::bindings::callback::ExceptionHandling::Rethrow; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; -use crate::dom::bindings::codegen::Bindings::NodeIteratorBinding; use crate::dom::bindings::codegen::Bindings::NodeIteratorBinding::NodeIteratorMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -52,7 +51,6 @@ impl NodeIterator { reflect_dom_object( Box::new(NodeIterator::new_inherited(root_node, what_to_show, filter)), document.window(), - NodeIteratorBinding::Wrap, ) } diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 5218d1b3026..d7ec1808323 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::Bindings::NodeListBinding; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -45,11 +44,7 @@ impl NodeList { #[allow(unrooted_must_root)] pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<NodeList> { - reflect_dom_object( - Box::new(NodeList::new_inherited(list_type)), - window, - NodeListBinding::Wrap, - ) + reflect_dom_object(Box::new(NodeList::new_inherited(list_type)), window) } pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<NodeList> diff --git a/components/script/dom/offlineaudiocompletionevent.rs b/components/script/dom/offlineaudiocompletionevent.rs index f093f583608..5162f4e9671 100644 --- a/components/script/dom/offlineaudiocompletionevent.rs +++ b/components/script/dom/offlineaudiocompletionevent.rs @@ -4,7 +4,6 @@ use crate::dom::audiobuffer::AudioBuffer; use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding; use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding::OfflineAudioCompletionEventInit; use crate::dom::bindings::codegen::Bindings::OfflineAudioCompletionEventBinding::OfflineAudioCompletionEventMethods; use crate::dom::bindings::error::Fallible; @@ -39,7 +38,7 @@ impl OfflineAudioCompletionEvent { rendered_buffer: &AudioBuffer, ) -> DomRoot<OfflineAudioCompletionEvent> { let event = Box::new(OfflineAudioCompletionEvent::new_inherited(rendered_buffer)); - let ev = reflect_dom_object(event, window, OfflineAudioCompletionEventBinding::Wrap); + let ev = reflect_dom_object(event, window); { let event = ev.upcast::<Event>(); event.init_event(type_, bool::from(bubbles), bool::from(cancelable)); diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 7b8d3f52111..bbdf9e1a79f 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -7,7 +7,6 @@ use crate::dom::audionode::MAX_CHANNEL_COUNT; use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions}; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BaseAudioContextBinding::BaseAudioContextBinding::BaseAudioContextMethods; -use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding; use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding::OfflineAudioContextMethods; use crate::dom::bindings::codegen::Bindings::OfflineAudioContextBinding::OfflineAudioContextOptions; use crate::dom::bindings::error::{Error, Fallible}; @@ -86,11 +85,7 @@ impl OfflineAudioContext { let pipeline_id = window.pipeline_id(); let context = OfflineAudioContext::new_inherited(channel_count, length, sample_rate, pipeline_id); - Ok(reflect_dom_object( - Box::new(context), - window, - OfflineAudioContextBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(context), window)) } pub fn Constructor( diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs index 130d2b7c49a..b381c245cfa 100644 --- a/components/script/dom/offscreencanvas.rs +++ b/components/script/dom/offscreencanvas.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{ - OffscreenCanvasMethods, OffscreenRenderingContext, Wrap as OffscreenCanvasWrap, + OffscreenCanvasMethods, OffscreenRenderingContext, }; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::reflect_dom_object; @@ -65,7 +65,6 @@ impl OffscreenCanvas { reflect_dom_object( Box::new(OffscreenCanvas::new_inherited(width, height, placeholder)), global, - OffscreenCanvasWrap, ) } diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 228a4dd44d7..5646cf112d9 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -8,7 +8,6 @@ use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::Ca use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasImageSource; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; -use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding; use crate::dom::bindings::codegen::Bindings::OffscreenCanvasRenderingContext2DBinding::OffscreenCanvasRenderingContext2DMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use crate::dom::bindings::error::ErrorResult; @@ -60,11 +59,7 @@ impl OffscreenCanvasRenderingContext2D { let boxed = Box::new(OffscreenCanvasRenderingContext2D::new_inherited( global, canvas, htmlcanvas, )); - reflect_dom_object( - boxed, - global, - OffscreenCanvasRenderingContext2DBinding::Wrap, - ) + reflect_dom_object(boxed, global) } /* pub fn get_canvas_state(&self) -> Ref<CanvasState> { diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index 2a5f6615db6..948603ca6e2 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use crate::dom::bindings::codegen::Bindings::OscillatorNodeBinding::OscillatorNodeMethods; use crate::dom::bindings::codegen::Bindings::OscillatorNodeBinding::{ - self, OscillatorOptions, OscillatorType, + OscillatorOptions, OscillatorType, }; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; @@ -88,11 +88,7 @@ impl OscillatorNode { options: &OscillatorOptions, ) -> Fallible<DomRoot<OscillatorNode>> { let node = OscillatorNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - OscillatorNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs index 41be9fd2488..5d11fb62540 100644 --- a/components/script/dom/pagetransitionevent.rs +++ b/components/script/dom/pagetransitionevent.rs @@ -32,11 +32,7 @@ impl PageTransitionEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<PageTransitionEvent> { - reflect_dom_object( - Box::new(PageTransitionEvent::new_inherited()), - window, - PageTransitionEventBinding::Wrap, - ) + reflect_dom_object(Box::new(PageTransitionEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index 7b44bbc4a71..3bcda664280 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -7,7 +7,6 @@ use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::Ca use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineCap; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasLineJoin; use crate::dom::bindings::codegen::Bindings::CanvasRenderingContext2DBinding::CanvasRenderingContext2DMethods; -use crate::dom::bindings::codegen::Bindings::PaintRenderingContext2DBinding; use crate::dom::bindings::codegen::Bindings::PaintRenderingContext2DBinding::PaintRenderingContext2DMethods; use crate::dom::bindings::codegen::UnionTypes::StringOrCanvasGradientOrCanvasPattern; use crate::dom::bindings::error::ErrorResult; @@ -53,7 +52,6 @@ impl PaintRenderingContext2D { reflect_dom_object( Box::new(PaintRenderingContext2D::new_inherited(global)), global, - PaintRenderingContext2DBinding::Wrap, ) } diff --git a/components/script/dom/paintsize.rs b/components/script/dom/paintsize.rs index 7f7fa61346b..5f6d0260096 100644 --- a/components/script/dom/paintsize.rs +++ b/components/script/dom/paintsize.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::PaintSizeBinding; use crate::dom::bindings::codegen::Bindings::PaintSizeBinding::PaintSizeMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; @@ -33,11 +32,7 @@ impl PaintSize { global: &PaintWorkletGlobalScope, size: Size2D<f32, CSSPixel>, ) -> DomRoot<PaintSize> { - reflect_dom_object( - Box::new(PaintSize::new_inherited(size)), - global, - PaintSizeBinding::Wrap, - ) + reflect_dom_object(Box::new(PaintSize::new_inherited(size)), global) } } diff --git a/components/script/dom/pannernode.rs b/components/script/dom/pannernode.rs index ae36a9cc701..98b9226287b 100644 --- a/components/script/dom/pannernode.rs +++ b/components/script/dom/pannernode.rs @@ -12,10 +12,10 @@ use crate::dom::bindings::codegen::Bindings::AudioParamBinding::{ AudioParamMethods, AutomationRate, }; use crate::dom::bindings::codegen::Bindings::PannerNodeBinding::{ - self, PannerNodeMethods, PannerOptions, + DistanceModelType, PanningModelType, }; use crate::dom::bindings::codegen::Bindings::PannerNodeBinding::{ - DistanceModelType, PanningModelType, + PannerNodeMethods, PannerOptions, }; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -177,11 +177,7 @@ impl PannerNode { options: &PannerOptions, ) -> Fallible<DomRoot<PannerNode>> { let node = PannerNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - PannerNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 9de98852df7..c707160f66a 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::PerformanceBinding; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::{ DOMHighResTimeStamp, PerformanceMethods, @@ -170,7 +169,6 @@ impl Performance { reflect_dom_object( Box::new(Performance::new_inherited(navigation_start_precise)), global, - PerformanceBinding::Wrap, ) } diff --git a/components/script/dom/performanceentry.rs b/components/script/dom/performanceentry.rs index e41cbc81667..8197deb8976 100644 --- a/components/script/dom/performanceentry.rs +++ b/components/script/dom/performanceentry.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; -use crate::dom::bindings::codegen::Bindings::PerformanceEntryBinding; use crate::dom::bindings::codegen::Bindings::PerformanceEntryBinding::PerformanceEntryMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -46,7 +45,7 @@ impl PerformanceEntry { duration: f64, ) -> DomRoot<PerformanceEntry> { let entry = PerformanceEntry::new_inherited(name, entry_type, start_time, duration); - reflect_dom_object(Box::new(entry), global, PerformanceEntryBinding::Wrap) + reflect_dom_object(Box::new(entry), global) } pub fn entry_type(&self) -> &DOMString { diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs index db93441480f..f52250b815c 100644 --- a/components/script/dom/performancenavigation.rs +++ b/components/script/dom/performancenavigation.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PerformanceNavigationBinding::{ - self, PerformanceNavigationConstants, PerformanceNavigationMethods, + PerformanceNavigationConstants, PerformanceNavigationMethods, }; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -24,11 +24,7 @@ impl PerformanceNavigation { } pub fn new(global: &GlobalScope) -> DomRoot<PerformanceNavigation> { - reflect_dom_object( - Box::new(PerformanceNavigation::new_inherited()), - global, - PerformanceNavigationBinding::Wrap, - ) + reflect_dom_object(Box::new(PerformanceNavigation::new_inherited()), global) } } diff --git a/components/script/dom/performancenavigationtiming.rs b/components/script/dom/performancenavigationtiming.rs index e10fa831070..5562427f1c9 100644 --- a/components/script/dom/performancenavigationtiming.rs +++ b/components/script/dom/performancenavigationtiming.rs @@ -3,10 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; +use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::NavigationType; use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::PerformanceNavigationTimingMethods; -use crate::dom::bindings::codegen::Bindings::PerformanceNavigationTimingBinding::{ - self, NavigationType, -}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -61,7 +59,6 @@ impl PerformanceNavigationTiming { document, )), global, - PerformanceNavigationTimingBinding::Wrap, ) } } diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index 2b52c86e4f2..8d689a35785 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -5,7 +5,6 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceEntryList as DOMPerformanceEntryList; -use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding; use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverCallback; use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverInit; use crate::dom::bindings::codegen::Bindings::PerformanceObserverBinding::PerformanceObserverMethods; @@ -71,7 +70,7 @@ impl PerformanceObserver { entries: DOMPerformanceEntryList, ) -> DomRoot<PerformanceObserver> { let observer = PerformanceObserver::new_inherited(callback, DomRefCell::new(entries)); - reflect_dom_object(Box::new(observer), global, PerformanceObserverBinding::Wrap) + reflect_dom_object(Box::new(observer), global) } #[allow(non_snake_case)] diff --git a/components/script/dom/performanceobserverentrylist.rs b/components/script/dom/performanceobserverentrylist.rs index e33b6b1b26e..f96e063153e 100644 --- a/components/script/dom/performanceobserverentrylist.rs +++ b/components/script/dom/performanceobserverentrylist.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding; use crate::dom::bindings::codegen::Bindings::PerformanceObserverEntryListBinding::PerformanceObserverEntryListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -33,11 +32,7 @@ impl PerformanceObserverEntryList { entries: PerformanceEntryList, ) -> DomRoot<PerformanceObserverEntryList> { let observer_entry_list = PerformanceObserverEntryList::new_inherited(entries); - reflect_dom_object( - Box::new(observer_entry_list), - global, - PerformanceObserverEntryListBinding::Wrap, - ) + reflect_dom_object(Box::new(observer_entry_list), global) } } diff --git a/components/script/dom/performancepainttiming.rs b/components/script/dom/performancepainttiming.rs index 7ee496917ae..2dd3c27f1f1 100644 --- a/components/script/dom/performancepainttiming.rs +++ b/components/script/dom/performancepainttiming.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::PerformancePaintTimingBinding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -46,6 +45,6 @@ impl PerformancePaintTiming { start_time: u64, ) -> DomRoot<PerformancePaintTiming> { let entry = PerformancePaintTiming::new_inherited(metric_type, start_time); - reflect_dom_object(Box::new(entry), global, PerformancePaintTimingBinding::Wrap) + reflect_dom_object(Box::new(entry), global) } } diff --git a/components/script/dom/performanceresourcetiming.rs b/components/script/dom/performanceresourcetiming.rs index 574016adc88..c98b5140f60 100644 --- a/components/script/dom/performanceresourcetiming.rs +++ b/components/script/dom/performanceresourcetiming.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; -use crate::dom::bindings::codegen::Bindings::PerformanceResourceTimingBinding::{ - self, PerformanceResourceTimingMethods, -}; +use crate::dom::bindings::codegen::Bindings::PerformanceResourceTimingBinding::PerformanceResourceTimingMethods; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -152,7 +150,6 @@ impl PerformanceResourceTiming { resource_timing, )), global, - PerformanceResourceTimingBinding::Wrap, ) } } diff --git a/components/script/dom/performancetiming.rs b/components/script/dom/performancetiming.rs index 1ee366d8a98..9f8a3a8b5f2 100644 --- a/components/script/dom/performancetiming.rs +++ b/components/script/dom/performancetiming.rs @@ -44,7 +44,7 @@ impl PerformanceTiming { navigation_start_precise, &window.Document(), ); - reflect_dom_object(Box::new(timing), window, PerformanceTimingBinding::Wrap) + reflect_dom_object(Box::new(timing), window) } } diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs index 37887f60773..b4e6bf8f5de 100644 --- a/components/script/dom/permissions.rs +++ b/components/script/dom/permissions.rs @@ -7,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::Permission use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{ PermissionName, PermissionState, }; -use crate::dom::bindings::codegen::Bindings::PermissionsBinding::{self, PermissionsMethods}; +use crate::dom::bindings::codegen::Bindings::PermissionsBinding::PermissionsMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -69,11 +69,7 @@ impl Permissions { } pub fn new(global: &GlobalScope) -> DomRoot<Permissions> { - reflect_dom_object( - Box::new(Permissions::new_inherited()), - global, - PermissionsBinding::Wrap, - ) + reflect_dom_object(Box::new(Permissions::new_inherited()), global) } // https://w3c.github.io/permissions/#dom-permissions-query diff --git a/components/script/dom/permissionstatus.rs b/components/script/dom/permissionstatus.rs index 80a6e347bd2..8f8b96f23de 100644 --- a/components/script/dom/permissionstatus.rs +++ b/components/script/dom/permissionstatus.rs @@ -5,7 +5,7 @@ use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState; use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionStatusMethods; use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::{ - self, PermissionDescriptor, PermissionName, + PermissionDescriptor, PermissionName, }; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -36,7 +36,6 @@ impl PermissionStatus { reflect_dom_object( Box::new(PermissionStatus::new_inherited(query.name)), global, - PermissionStatusBinding::Wrap, ) } diff --git a/components/script/dom/pluginarray.rs b/components/script/dom/pluginarray.rs index 46605b09d04..b063d55fb02 100644 --- a/components/script/dom/pluginarray.rs +++ b/components/script/dom/pluginarray.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::PluginArrayBinding; use crate::dom::bindings::codegen::Bindings::PluginArrayBinding::PluginArrayMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -24,11 +23,7 @@ impl PluginArray { } pub fn new(global: &GlobalScope) -> DomRoot<PluginArray> { - reflect_dom_object( - Box::new(PluginArray::new_inherited()), - global, - PluginArrayBinding::Wrap, - ) + reflect_dom_object(Box::new(PluginArray::new_inherited()), global) } } diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index 9c4ba63cb93..851064df389 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -38,11 +38,7 @@ impl PopStateEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<PopStateEvent> { - reflect_dom_object( - Box::new(PopStateEvent::new_inherited()), - window, - PopStateEventBinding::Wrap, - ) + reflect_dom_object(Box::new(PopStateEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/processinginstruction.rs b/components/script/dom/processinginstruction.rs index 3b01f71c0e0..9edbf1a0a29 100644 --- a/components/script/dom/processinginstruction.rs +++ b/components/script/dom/processinginstruction.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding; use crate::dom::bindings::codegen::Bindings::ProcessingInstructionBinding::ProcessingInstructionMethods; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; @@ -38,7 +37,6 @@ impl ProcessingInstruction { Node::reflect_node( Box::new(ProcessingInstruction::new_inherited(target, data, document)), document, - ProcessingInstructionBinding::Wrap, ) } } diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index 325e247bc52..32e6917a15d 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -48,7 +48,6 @@ impl ProgressEvent { total, )), global, - ProgressEventBinding::Wrap, ); { let event = ev.upcast::<Event>(); diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 5e60507f8fc..fae6421f622 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -19,19 +19,21 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::promisenativehandler::PromiseNativeHandler; use crate::realms::{enter_realm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; +use crate::script_thread::ScriptThread; use dom_struct::dom_struct; use js::conversions::ToJSValConvertible; use js::jsapi::{AddRawValueRoot, CallArgs, GetFunctionNativeReserved}; use js::jsapi::{Heap, JS_ClearPendingException}; use js::jsapi::{JSAutoRealm, JSContext, JSObject, JS_GetFunctionObject}; -use js::jsapi::{JS_NewFunction, NewFunctionWithReserved, PromiseState}; +use js::jsapi::{JS_NewFunction, NewFunctionWithReserved}; +use js::jsapi::{PromiseState, PromiseUserInputEventHandlingState}; use js::jsapi::{RemoveRawValueRoot, SetFunctionNativeReserved}; use js::jsval::{Int32Value, JSVal, ObjectValue, UndefinedValue}; use js::rust::wrappers::{ AddPromiseReactions, CallOriginalPromiseReject, CallOriginalPromiseResolve, }; -use js::rust::wrappers::{GetPromiseState, IsPromiseObject}; -use js::rust::wrappers::{NewPromiseObject, RejectPromise, ResolvePromise}; +use js::rust::wrappers::{GetPromiseState, IsPromiseObject, NewPromiseObject, RejectPromise}; +use js::rust::wrappers::{ResolvePromise, SetPromiseUserInputEventHandlingState}; use js::rust::{HandleObject, HandleValue, MutableHandleObject, Runtime}; use std::ptr; use std::rc::Rc; @@ -131,6 +133,12 @@ impl Promise { assert!(!do_nothing_obj.is_null()); obj.set(NewPromiseObject(*cx, do_nothing_obj.handle())); assert!(!obj.is_null()); + let is_user_interacting = if ScriptThread::is_user_interacting() { + PromiseUserInputEventHandlingState::HadUserInteractionAtCreation + } else { + PromiseUserInputEventHandlingState::DidntHaveUserInteractionAtCreation + }; + SetPromiseUserInputEventHandlingState(obj.handle(), is_user_interacting); } } diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index 147aad57fd5..c7e0ded5b4d 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::PromiseNativeHandlerBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::trace::JSTraceable; @@ -36,7 +35,6 @@ impl PromiseNativeHandler { reject: reject, }), global, - PromiseNativeHandlerBinding::Wrap, ) } diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs index 8e1e62bc18d..92d67725ca0 100644 --- a/components/script/dom/promiserejectionevent.rs +++ b/components/script/dom/promiserejectionevent.rs @@ -53,7 +53,6 @@ impl PromiseRejectionEvent { let ev = reflect_dom_object( Box::new(PromiseRejectionEvent::new_inherited(promise)), global, - PromiseRejectionEventBinding::Wrap, ); { diff --git a/components/script/dom/radionodelist.rs b/components/script/dom/radionodelist.rs index 56069375b27..958652da9f7 100644 --- a/components/script/dom/radionodelist.rs +++ b/components/script/dom/radionodelist.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; -use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding; use crate::dom::bindings::codegen::Bindings::RadioNodeListBinding::RadioNodeListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; @@ -33,11 +32,7 @@ impl RadioNodeList { #[allow(unrooted_must_root)] pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> { - reflect_dom_object( - Box::new(RadioNodeList::new_inherited(list_type)), - window, - RadioNodeListBinding::Wrap, - ) + reflect_dom_object(Box::new(RadioNodeList::new_inherited(list_type)), window) } pub fn new_controls_except_image_inputs( diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 1aabc0fc540..0b1c8f16de1 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -7,8 +7,8 @@ use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterData use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeConstants; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; +use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeConstants; use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeMethods; -use crate::dom::bindings::codegen::Bindings::RangeBinding::{self, RangeConstants}; use crate::dom::bindings::codegen::Bindings::TextBinding::TextMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; @@ -86,7 +86,6 @@ impl Range { end_offset, )), document.window(), - RangeBinding::Wrap, ); start_container.ranges().push(WeakRef::new(&range)); if start_container != end_container { diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index d75c452c7b9..6dbe810b81a 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -5,7 +5,6 @@ use crate::body::{consume_body, BodyOperations, BodyType}; use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::HeadersBinding::{HeadersInit, HeadersMethods}; -use crate::dom::bindings::codegen::Bindings::RequestBinding; use crate::dom::bindings::codegen::Bindings::RequestBinding::ReferrerPolicy; use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCache; use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials; @@ -66,11 +65,7 @@ impl Request { } pub fn new(global: &GlobalScope, url: ServoUrl) -> DomRoot<Request> { - reflect_dom_object( - Box::new(Request::new_inherited(global, url)), - global, - RequestBinding::Wrap, - ) + reflect_dom_object(Box::new(Request::new_inherited(global, url)), global) } // https://fetch.spec.whatwg.org/#dom-request @@ -848,6 +843,7 @@ impl Into<MsgReferrerPolicy> for ReferrerPolicy { ReferrerPolicy::Origin => MsgReferrerPolicy::Origin, ReferrerPolicy::Origin_when_cross_origin => MsgReferrerPolicy::OriginWhenCrossOrigin, ReferrerPolicy::Unsafe_url => MsgReferrerPolicy::UnsafeUrl, + ReferrerPolicy::Same_origin => MsgReferrerPolicy::SameOrigin, ReferrerPolicy::Strict_origin => MsgReferrerPolicy::StrictOrigin, ReferrerPolicy::Strict_origin_when_cross_origin => { MsgReferrerPolicy::StrictOriginWhenCrossOrigin @@ -864,9 +860,9 @@ impl Into<ReferrerPolicy> for MsgReferrerPolicy { ReferrerPolicy::No_referrer_when_downgrade }, MsgReferrerPolicy::Origin => ReferrerPolicy::Origin, - MsgReferrerPolicy::SameOrigin => ReferrerPolicy::Origin, MsgReferrerPolicy::OriginWhenCrossOrigin => ReferrerPolicy::Origin_when_cross_origin, MsgReferrerPolicy::UnsafeUrl => ReferrerPolicy::Unsafe_url, + MsgReferrerPolicy::SameOrigin => ReferrerPolicy::Same_origin, MsgReferrerPolicy::StrictOrigin => ReferrerPolicy::Strict_origin, MsgReferrerPolicy::StrictOriginWhenCrossOrigin => { ReferrerPolicy::Strict_origin_when_cross_origin diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index f329b16c3c5..636acc05ff5 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -74,11 +74,7 @@ impl Response { // https://fetch.spec.whatwg.org/#dom-response pub fn new(global: &GlobalScope) -> DomRoot<Response> { - reflect_dom_object( - Box::new(Response::new_inherited()), - global, - ResponseBinding::Wrap, - ) + reflect_dom_object(Box::new(Response::new_inherited()), global) } pub fn Constructor( diff --git a/components/script/dom/rtcicecandidate.rs b/components/script/dom/rtcicecandidate.rs index a432010b858..371f3d7693a 100644 --- a/components/script/dom/rtcicecandidate.rs +++ b/components/script/dom/rtcicecandidate.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit; -use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::{ - self, RTCIceCandidateMethods, -}; +use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::reflector::{DomObject, Reflector}; @@ -55,7 +53,6 @@ impl RTCIceCandidate { username_fragment, )), global, - RTCIceCandidateBinding::Wrap, ) } diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index e6b45d93676..fa8c5dda800 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::RTCIceCandidateBinding::RTCIceCandidateInit; -use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding; use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::RTCPeerConnectionMethods; use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionBinding::{ RTCAnswerOptions, RTCBundlePolicy, RTCConfiguration, RTCIceConnectionState, @@ -166,11 +165,7 @@ impl RTCPeerConnection { } pub fn new(global: &GlobalScope, config: &RTCConfiguration) -> DomRoot<RTCPeerConnection> { - let this = reflect_dom_object( - Box::new(RTCPeerConnection::new_inherited()), - global, - RTCPeerConnectionBinding::Wrap, - ); + let this = reflect_dom_object(Box::new(RTCPeerConnection::new_inherited()), global); let signaller = this.make_signaller(); *this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller)); if let Some(ref servers) = config.iceServers { diff --git a/components/script/dom/rtcpeerconnectioniceevent.rs b/components/script/dom/rtcpeerconnectioniceevent.rs index 795cb330829..e88222e34ad 100644 --- a/components/script/dom/rtcpeerconnectioniceevent.rs +++ b/components/script/dom/rtcpeerconnectioniceevent.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding; use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding::RTCPeerConnectionIceEventInit; use crate::dom::bindings::codegen::Bindings::RTCPeerConnectionIceEventBinding::RTCPeerConnectionIceEventMethods; use crate::dom::bindings::error::Fallible; @@ -48,7 +47,6 @@ impl RTCPeerConnectionIceEvent { let e = reflect_dom_object( Box::new(RTCPeerConnectionIceEvent::new_inherited(candidate, url)), global, - RTCPeerConnectionIceEventBinding::Wrap, ); let evt = e.upcast::<Event>(); evt.init_event(ty, false, false); // XXXManishearth bubbles/cancelable? diff --git a/components/script/dom/rtcsessiondescription.rs b/components/script/dom/rtcsessiondescription.rs index 68be62e577b..2ff7157e5d4 100644 --- a/components/script/dom/rtcsessiondescription.rs +++ b/components/script/dom/rtcsessiondescription.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding; use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::RTCSessionDescriptionMethods; use crate::dom::bindings::codegen::Bindings::RTCSessionDescriptionBinding::{ RTCSdpType, RTCSessionDescriptionInit, @@ -40,7 +39,6 @@ impl RTCSessionDescription { reflect_dom_object( Box::new(RTCSessionDescription::new_inherited(ty, sdp)), global, - RTCSessionDescriptionBinding::Wrap, ) } diff --git a/components/script/dom/rtctrackevent.rs b/components/script/dom/rtctrackevent.rs index 386349bcaa1..0cf8605170b 100644 --- a/components/script/dom/rtctrackevent.rs +++ b/components/script/dom/rtctrackevent.rs @@ -38,11 +38,7 @@ impl RTCTrackEvent { cancelable: bool, track: &MediaStreamTrack, ) -> DomRoot<RTCTrackEvent> { - let trackevent = reflect_dom_object( - Box::new(RTCTrackEvent::new_inherited(&track)), - global, - RTCTrackEventBinding::Wrap, - ); + let trackevent = reflect_dom_object(Box::new(RTCTrackEvent::new_inherited(&track)), global); { let event = trackevent.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/screen.rs b/components/script/dom/screen.rs index cf5d6785405..18e137346e5 100644 --- a/components/script/dom/screen.rs +++ b/components/script/dom/screen.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::ScreenBinding; use crate::dom::bindings::codegen::Bindings::ScreenBinding::ScreenMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; @@ -33,11 +32,7 @@ impl Screen { } pub fn new(window: &Window) -> DomRoot<Screen> { - reflect_dom_object( - Box::new(Screen::new_inherited(window)), - window, - ScreenBinding::Wrap, - ) + reflect_dom_object(Box::new(Screen::new_inherited(window)), window) } fn screen_size(&self) -> Size2D<u32, CSSPixel> { diff --git a/components/script/dom/selection.rs b/components/script/dom/selection.rs index e86c366d49c..75348556ba0 100644 --- a/components/script/dom/selection.rs +++ b/components/script/dom/selection.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::codegen::Bindings::NodeBinding::{GetRootNodeOptions, NodeMethods}; use crate::dom::bindings::codegen::Bindings::RangeBinding::RangeMethods; -use crate::dom::bindings::codegen::Bindings::SelectionBinding::{SelectionMethods, Wrap}; +use crate::dom::bindings::codegen::Bindings::SelectionBinding::SelectionMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -50,7 +50,6 @@ impl Selection { reflect_dom_object( Box::new(Selection::new_inherited(document)), &*document.global(), - Wrap, ) } diff --git a/components/script/dom/serviceworker.rs b/components/script/dom/serviceworker.rs index 43e7245f3c5..fce07ab0809 100644 --- a/components/script/dom/serviceworker.rs +++ b/components/script/dom/serviceworker.rs @@ -6,7 +6,7 @@ use crate::dom::abstractworker::SimpleWorkerErrorHandler; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::{ - ServiceWorkerMethods, ServiceWorkerState, Wrap, + ServiceWorkerMethods, ServiceWorkerState, }; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::inheritance::Castable; @@ -62,7 +62,6 @@ impl ServiceWorker { scope_url, )), global, - Wrap, ) } diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index 66ff8e738f7..8145729d857 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::RegistrationOptions; -use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::{ - ServiceWorkerContainerMethods, Wrap, -}; +use crate::dom::bindings::codegen::Bindings::ServiceWorkerContainerBinding::ServiceWorkerContainerMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -42,7 +40,7 @@ impl ServiceWorkerContainer { pub fn new(global: &GlobalScope) -> DomRoot<ServiceWorkerContainer> { let client = Client::new(&global.as_window()); let container = ServiceWorkerContainer::new_inherited(&*client); - reflect_dom_object(Box::new(container), global, Wrap) + reflect_dom_object(Box::new(container), global) } } diff --git a/components/script/dom/serviceworkerregistration.rs b/components/script/dom/serviceworkerregistration.rs index 647fb9518c5..f242da12404 100644 --- a/components/script/dom/serviceworkerregistration.rs +++ b/components/script/dom/serviceworkerregistration.rs @@ -4,10 +4,8 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ServiceWorkerBinding::ServiceWorkerState; +use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::ServiceWorkerRegistrationMethods; use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::ServiceWorkerUpdateViaCache; -use crate::dom::bindings::codegen::Bindings::ServiceWorkerRegistrationBinding::{ - ServiceWorkerRegistrationMethods, Wrap, -}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; use crate::dom::bindings::str::{ByteString, USVString}; @@ -69,7 +67,6 @@ impl ServiceWorkerRegistration { scope, )), global, - Wrap, ) } diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 505c699cb6c..d1a4a18df18 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -10,7 +10,6 @@ use crate::dom::bindings::codegen::Bindings::DocumentBinding::{ use crate::dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::Bindings::ServoParserBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -432,7 +431,6 @@ impl ServoParser { kind, )), document.window(), - ServoParserBinding::Wrap, ) } diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index 0b791476f7c..71db09f4671 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootBinding::ShadowRootMethods; -use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::{self, ShadowRootMode}; +use crate::dom::bindings::codegen::Bindings::ShadowRootBinding::ShadowRootMode; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; @@ -73,7 +73,6 @@ impl ShadowRoot { reflect_dom_object( Box::new(ShadowRoot::new_inherited(host, document)), document.window(), - ShadowRootBinding::Wrap, ) } @@ -240,8 +239,8 @@ impl ShadowRootMethods for ShadowRoot { } #[allow(unsafe_code)] -pub trait LayoutShadowRootHelpers { - unsafe fn get_host_for_layout(&self) -> LayoutDom<Element>; +pub trait LayoutShadowRootHelpers<'dom> { + unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element>; unsafe fn get_style_data_for_layout<'a, E: TElement>( &self, ) -> &'a AuthorStyles<StyleSheetInDocument>; @@ -253,10 +252,10 @@ pub trait LayoutShadowRootHelpers { ); } -impl LayoutShadowRootHelpers for LayoutDom<ShadowRoot> { +impl<'dom> LayoutShadowRootHelpers<'dom> for LayoutDom<'dom, ShadowRoot> { #[inline] #[allow(unsafe_code)] - unsafe fn get_host_for_layout(&self) -> LayoutDom<Element> { + unsafe fn get_host_for_layout(&self) -> LayoutDom<'dom, Element> { (*self.unsafe_get()) .host .get_inner_as_layout() diff --git a/components/script/dom/stereopannernode.rs b/components/script/dom/stereopannernode.rs index 66383352086..cc71c69593b 100644 --- a/components/script/dom/stereopannernode.rs +++ b/components/script/dom/stereopannernode.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ }; use crate::dom::bindings::codegen::Bindings::AudioParamBinding::AutomationRate; use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::StereoPannerNodeMethods; -use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::{self, StereoPannerOptions}; +use crate::dom::bindings::codegen::Bindings::StereoPannerNodeBinding::StereoPannerOptions; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -76,11 +76,7 @@ impl StereoPannerNode { options: &StereoPannerOptions, ) -> Fallible<DomRoot<StereoPannerNode>> { let node = StereoPannerNode::new_inherited(window, context, options)?; - Ok(reflect_dom_object( - Box::new(node), - window, - StereoPannerNodeBinding::Wrap, - )) + Ok(reflect_dom_object(Box::new(node), window)) } #[allow(non_snake_case)] diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index 74624ba45b4..8d8ad0dc7ba 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::StorageBinding; use crate::dom::bindings::codegen::Bindings::StorageBinding::StorageMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::inheritance::Castable; @@ -37,11 +36,7 @@ impl Storage { } pub fn new(global: &Window, storage_type: StorageType) -> DomRoot<Storage> { - reflect_dom_object( - Box::new(Storage::new_inherited(storage_type)), - global, - StorageBinding::Wrap, - ) + reflect_dom_object(Box::new(Storage::new_inherited(storage_type)), global) } fn get_url(&self) -> ServoUrl { diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index c2ecaf59611..a50c1267585 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -50,7 +50,6 @@ impl StorageEvent { reflect_dom_object( Box::new(StorageEvent::new_inherited(None, None, None, url, None)), window, - StorageEventBinding::Wrap, ) } @@ -74,7 +73,6 @@ impl StorageEvent { storageArea, )), global, - StorageEventBinding::Wrap, ); { let event = ev.upcast::<Event>(); diff --git a/components/script/dom/stylepropertymapreadonly.rs b/components/script/dom/stylepropertymapreadonly.rs index 7ef177eb71a..3881bfcdd87 100644 --- a/components/script/dom/stylepropertymapreadonly.rs +++ b/components/script/dom/stylepropertymapreadonly.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::StylePropertyMapReadOnlyMethods; -use crate::dom::bindings::codegen::Bindings::StylePropertyMapReadOnlyBinding::Wrap; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -56,7 +55,6 @@ impl StylePropertyMapReadOnly { reflect_dom_object( Box::new(StylePropertyMapReadOnly::new_inherited(iter)), global, - Wrap, ) } } diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs index 391ac55ed91..7bd115f5084 100644 --- a/components/script/dom/stylesheetlist.rs +++ b/components/script/dom/stylesheetlist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::StyleSheetListBinding; use crate::dom::bindings::codegen::Bindings::StyleSheetListBinding::StyleSheetListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -83,11 +82,7 @@ impl StyleSheetList { #[allow(unrooted_must_root)] pub fn new(window: &Window, doc_or_sr: StyleSheetListOwner) -> DomRoot<StyleSheetList> { - reflect_dom_object( - Box::new(StyleSheetList::new_inherited(doc_or_sr)), - window, - StyleSheetListBinding::Wrap, - ) + reflect_dom_object(Box::new(StyleSheetList::new_inherited(doc_or_sr)), window) } } diff --git a/components/script/dom/submitevent.rs b/components/script/dom/submitevent.rs index 17f8e7fd003..c9965b762b1 100644 --- a/components/script/dom/submitevent.rs +++ b/components/script/dom/submitevent.rs @@ -38,11 +38,7 @@ impl SubmitEvent { cancelable: bool, submitter: Option<DomRoot<HTMLElement>>, ) -> DomRoot<SubmitEvent> { - let ev = reflect_dom_object( - Box::new(SubmitEvent::new_inherited(submitter)), - global, - SubmitEventBinding::Wrap, - ); + let ev = reflect_dom_object(Box::new(SubmitEvent::new_inherited(submitter)), global); { let event = ev.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 57f88db6f5b..8c8c1dbb834 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::attr::Attr; -use crate::dom::bindings::codegen::Bindings::SVGSVGElementBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{DomRoot, LayoutDom}; use crate::dom::bindings::str::DOMString; @@ -45,7 +44,6 @@ impl SVGSVGElement { Node::reflect_node( Box::new(SVGSVGElement::new_inherited(local_name, prefix, document)), document, - SVGSVGElementBinding::Wrap, ) } } @@ -54,7 +52,7 @@ pub trait LayoutSVGSVGElementHelpers { fn data(&self) -> SVGSVGData; } -impl LayoutSVGSVGElementHelpers for LayoutDom<SVGSVGElement> { +impl LayoutSVGSVGElementHelpers for LayoutDom<'_, SVGSVGElement> { #[allow(unsafe_code, non_snake_case)] fn data(&self) -> SVGSVGData { unsafe { diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index f0dcd1b26c7..b14fb16fe4f 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -7,7 +7,7 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; -use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{self, SimpleCallback}; +use crate::dom::bindings::codegen::Bindings::TestBindingBinding::SimpleCallback; use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{ TestBindingMethods, TestDictionary, }; @@ -82,11 +82,7 @@ impl TestBinding { } pub fn new(global: &GlobalScope) -> DomRoot<TestBinding> { - reflect_dom_object( - Box::new(TestBinding::new_inherited()), - global, - TestBindingBinding::Wrap, - ) + reflect_dom_object(Box::new(TestBinding::new_inherited()), global) } pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<TestBinding>> { diff --git a/components/script/dom/testbindingiterable.rs b/components/script/dom/testbindingiterable.rs index d2ee66521ff..5befaaa2c59 100644 --- a/components/script/dom/testbindingiterable.rs +++ b/components/script/dom/testbindingiterable.rs @@ -5,9 +5,7 @@ // check-tidy: no specs after this line use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::TestBindingIterableBinding::{ - self, TestBindingIterableMethods, -}; +use crate::dom::bindings::codegen::Bindings::TestBindingIterableBinding::TestBindingIterableMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -29,7 +27,6 @@ impl TestBindingIterable { vals: DomRefCell::new(vec![]), }), global, - TestBindingIterableBinding::Wrap, ) } diff --git a/components/script/dom/testbindingpairiterable.rs b/components/script/dom/testbindingpairiterable.rs index 8c85de40f0c..e8775af5ce7 100644 --- a/components/script/dom/testbindingpairiterable.rs +++ b/components/script/dom/testbindingpairiterable.rs @@ -5,7 +5,6 @@ // check-tidy: no specs after this line use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::TestBindingPairIterableBinding; use crate::dom::bindings::codegen::Bindings::TestBindingPairIterableBinding::TestBindingPairIterableMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::iterable::Iterable; @@ -55,7 +54,6 @@ impl TestBindingPairIterable { map: DomRefCell::new(vec![]), }), global, - TestBindingPairIterableBinding::TestBindingPairIterableWrap, ) } diff --git a/components/script/dom/testrunner.rs b/components/script/dom/testrunner.rs index 5adc77e0d0c..ac354905d25 100644 --- a/components/script/dom/testrunner.rs +++ b/components/script/dom/testrunner.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TestRunnerBinding; use crate::dom::bindings::codegen::Bindings::TestRunnerBinding::TestRunnerMethods; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -28,11 +27,7 @@ impl TestRunner { } pub fn new(global: &GlobalScope) -> DomRoot<TestRunner> { - reflect_dom_object( - Box::new(TestRunner::new_inherited()), - global, - TestRunnerBinding::Wrap, - ) + reflect_dom_object(Box::new(TestRunner::new_inherited()), global) } fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { diff --git a/components/script/dom/testworklet.rs b/components/script/dom/testworklet.rs index 74c4a0fb156..16e49b55493 100644 --- a/components/script/dom/testworklet.rs +++ b/components/script/dom/testworklet.rs @@ -4,7 +4,6 @@ // check-tidy: no specs after this line use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::TestWorkletMethods; -use crate::dom::bindings::codegen::Bindings::TestWorkletBinding::Wrap; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletBinding::WorkletMethods; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; use crate::dom::bindings::error::Fallible; @@ -38,11 +37,7 @@ impl TestWorklet { fn new(window: &Window) -> DomRoot<TestWorklet> { let worklet = Worklet::new(window, WorkletGlobalScopeType::Test); - reflect_dom_object( - Box::new(TestWorklet::new_inherited(&*worklet)), - window, - Wrap, - ) + reflect_dom_object(Box::new(TestWorklet::new_inherited(&*worklet)), window) } #[allow(non_snake_case)] diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs index 36273f933a2..64fae977556 100644 --- a/components/script/dom/text.rs +++ b/components/script/dom/text.rs @@ -5,7 +5,7 @@ use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use crate::dom::bindings::codegen::Bindings::TextBinding::{self, TextMethods}; +use crate::dom::bindings::codegen::Bindings::TextBinding::TextMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -31,11 +31,7 @@ impl Text { } pub fn new(text: DOMString, document: &Document) -> DomRoot<Text> { - Node::reflect_node( - Box::new(Text::new_inherited(text, document)), - document, - TextBinding::Wrap, - ) + Node::reflect_node(Box::new(Text::new_inherited(text, document)), document) } #[allow(non_snake_case)] diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs index 484ac269ec6..7d664242467 100644 --- a/components/script/dom/textdecoder.rs +++ b/components/script/dom/textdecoder.rs @@ -63,7 +63,6 @@ impl TextDecoder { reflect_dom_object( Box::new(TextDecoder::new_inherited(encoding, fatal, ignoreBOM)), global, - TextDecoderBinding::Wrap, ) } diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 65d41c1c88e..4df1143531f 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TextEncoderBinding; use crate::dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -29,11 +28,7 @@ impl TextEncoder { } pub fn new(global: &GlobalScope) -> DomRoot<TextEncoder> { - reflect_dom_object( - Box::new(TextEncoder::new_inherited()), - global, - TextEncoderBinding::Wrap, - ) + reflect_dom_object(Box::new(TextEncoder::new_inherited()), global) } // https://encoding.spec.whatwg.org/#dom-textencoder diff --git a/components/script/dom/textmetrics.rs b/components/script/dom/textmetrics.rs index eca24e19452..675fcf1aa1d 100644 --- a/components/script/dom/textmetrics.rs +++ b/components/script/dom/textmetrics.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TextMetricsBinding; use crate::dom::bindings::codegen::Bindings::TextMetricsBinding::TextMetricsMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -92,7 +91,6 @@ impl TextMetrics { ideographicBaseline, )), global, - TextMetricsBinding::Wrap, ) } } diff --git a/components/script/dom/texttrack.rs b/components/script/dom/texttrack.rs index 7c2b54adcd9..0e6cd2e48c7 100644 --- a/components/script/dom/texttrack.rs +++ b/components/script/dom/texttrack.rs @@ -4,7 +4,7 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::TextTrackBinding::{ - self, TextTrackKind, TextTrackMethods, TextTrackMode, + TextTrackKind, TextTrackMethods, TextTrackMode, }; use crate::dom::bindings::error::{Error, ErrorResult}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -65,7 +65,6 @@ impl TextTrack { id, kind, label, language, mode, track_list, )), window, - TextTrackBinding::Wrap, ) } diff --git a/components/script/dom/texttrackcue.rs b/components/script/dom/texttrackcue.rs index 61a07d2cb3c..7a219f0f417 100644 --- a/components/script/dom/texttrackcue.rs +++ b/components/script/dom/texttrackcue.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::TextTrackCueBinding::{self, TextTrackCueMethods}; +use crate::dom::bindings::codegen::Bindings::TextTrackCueBinding::TextTrackCueMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -52,7 +52,6 @@ impl TextTrackCue { reflect_dom_object( Box::new(TextTrackCue::new_inherited(id, start_time, end_time, track)), window, - TextTrackCueBinding::Wrap, ) } diff --git a/components/script/dom/texttrackcuelist.rs b/components/script/dom/texttrackcuelist.rs index bd66027bb07..a51b95a965f 100644 --- a/components/script/dom/texttrackcuelist.rs +++ b/components/script/dom/texttrackcuelist.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::TextTrackCueListBinding::{ - self, TextTrackCueListMethods, -}; +use crate::dom::bindings::codegen::Bindings::TextTrackCueListBinding::TextTrackCueListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; @@ -28,11 +26,7 @@ impl TextTrackCueList { } pub fn new(window: &Window, cues: &[&TextTrackCue]) -> DomRoot<TextTrackCueList> { - reflect_dom_object( - Box::new(TextTrackCueList::new_inherited(cues)), - window, - TextTrackCueListBinding::Wrap, - ) + reflect_dom_object(Box::new(TextTrackCueList::new_inherited(cues)), window) } pub fn item(&self, idx: usize) -> Option<DomRoot<TextTrackCue>> { diff --git a/components/script/dom/texttracklist.rs b/components/script/dom/texttracklist.rs index 0e978972d69..faeb9f0cd6d 100644 --- a/components/script/dom/texttracklist.rs +++ b/components/script/dom/texttracklist.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::TextTrackListBinding::{self, TextTrackListMethods}; +use crate::dom::bindings::codegen::Bindings::TextTrackListBinding::TextTrackListMethods; use crate::dom::bindings::codegen::UnionTypes::VideoTrackOrAudioTrackOrTextTrack; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; @@ -33,11 +33,7 @@ impl TextTrackList { } pub fn new(window: &Window, tracks: &[&TextTrack]) -> DomRoot<TextTrackList> { - reflect_dom_object( - Box::new(TextTrackList::new_inherited(tracks)), - window, - TextTrackListBinding::Wrap, - ) + reflect_dom_object(Box::new(TextTrackList::new_inherited(tracks)), window) } pub fn item(&self, idx: usize) -> Option<DomRoot<TextTrack>> { diff --git a/components/script/dom/timeranges.rs b/components/script/dom/timeranges.rs index 7b4d1978a60..7a60210b0e0 100644 --- a/components/script/dom/timeranges.rs +++ b/components/script/dom/timeranges.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TimeRangesBinding; use crate::dom::bindings::codegen::Bindings::TimeRangesBinding::TimeRangesMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::num::Finite; @@ -138,11 +137,7 @@ impl TimeRanges { } pub fn new(window: &Window, ranges: TimeRangesContainer) -> DomRoot<TimeRanges> { - reflect_dom_object( - Box::new(TimeRanges::new_inherited(ranges)), - window, - TimeRangesBinding::Wrap, - ) + reflect_dom_object(Box::new(TimeRanges::new_inherited(ranges)), window) } } diff --git a/components/script/dom/touch.rs b/components/script/dom/touch.rs index 139f1206a04..60e69a48ca3 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TouchBinding; use crate::dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -64,7 +63,6 @@ impl Touch { identifier, target, screen_x, screen_y, client_x, client_y, page_x, page_y, )), window, - TouchBinding::Wrap, ) } } diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs index b903386ea72..4dfbed55147 100644 --- a/components/script/dom/touchevent.rs +++ b/components/script/dom/touchevent.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TouchEventBinding; use crate::dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods; use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods; use crate::dom::bindings::inheritance::Castable; @@ -59,7 +58,6 @@ impl TouchEvent { target_touches, )), window, - TouchEventBinding::Wrap, ) } diff --git a/components/script/dom/touchlist.rs b/components/script/dom/touchlist.rs index d0bc0bd32e4..46400df8ca1 100644 --- a/components/script/dom/touchlist.rs +++ b/components/script/dom/touchlist.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::TouchListBinding; use crate::dom::bindings::codegen::Bindings::TouchListBinding::TouchListMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -25,11 +24,7 @@ impl TouchList { } pub fn new(window: &Window, touches: &[&Touch]) -> DomRoot<TouchList> { - reflect_dom_object( - Box::new(TouchList::new_inherited(touches)), - window, - TouchListBinding::Wrap, - ) + reflect_dom_object(Box::new(TouchList::new_inherited(touches)), window) } } diff --git a/components/script/dom/trackevent.rs b/components/script/dom/trackevent.rs index 634548eb351..34148f26527 100644 --- a/components/script/dom/trackevent.rs +++ b/components/script/dom/trackevent.rs @@ -64,11 +64,7 @@ impl TrackEvent { cancelable: bool, track: &Option<VideoTrackOrAudioTrackOrTextTrack>, ) -> DomRoot<TrackEvent> { - let te = reflect_dom_object( - Box::new(TrackEvent::new_inherited(&track)), - global, - TrackEventBinding::Wrap, - ); + let te = reflect_dom_object(Box::new(TrackEvent::new_inherited(&track)), global); { let event = te.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/transitionevent.rs b/components/script/dom/transitionevent.rs index 5f4d5aa7088..2305a9489ff 100644 --- a/components/script/dom/transitionevent.rs +++ b/components/script/dom/transitionevent.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::TransitionEventBinding; use crate::dom::bindings::codegen::Bindings::TransitionEventBinding::{ TransitionEventInit, TransitionEventMethods, }; @@ -41,11 +40,7 @@ impl TransitionEvent { type_: Atom, init: &TransitionEventInit, ) -> DomRoot<TransitionEvent> { - let ev = reflect_dom_object( - Box::new(TransitionEvent::new_inherited(init)), - window, - TransitionEventBinding::Wrap, - ); + let ev = reflect_dom_object(Box::new(TransitionEvent::new_inherited(init)), window); { let event = ev.upcast::<Event>(); event.init_event(type_, init.parent.bubbles, init.parent.cancelable); diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 6b11c410bf8..7d23d81bcf0 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -6,7 +6,6 @@ use crate::dom::bindings::callback::ExceptionHandling::Rethrow; use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter; use crate::dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilterConstants; -use crate::dom::bindings::codegen::Bindings::TreeWalkerBinding; use crate::dom::bindings::codegen::Bindings::TreeWalkerBinding::TreeWalkerMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -50,7 +49,6 @@ impl TreeWalker { reflect_dom_object( Box::new(TreeWalker::new_inherited(root_node, what_to_show, filter)), document.window(), - TreeWalkerBinding::Wrap, ) } diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 45bdda0ccc6..c54265f4fb5 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -35,11 +35,7 @@ impl UIEvent { } pub fn new_uninitialized(window: &Window) -> DomRoot<UIEvent> { - reflect_dom_object( - Box::new(UIEvent::new_inherited()), - window, - UIEventBinding::Wrap, - ) + reflect_dom_object(Box::new(UIEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 715d1ededd7..b1ceef7cfa3 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::URLBinding::{self, URLMethods}; +use crate::dom::bindings::codegen::Bindings::URLBinding::URLMethods; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -43,7 +43,7 @@ impl URL { } pub fn new(global: &GlobalScope, url: ServoUrl) -> DomRoot<URL> { - reflect_dom_object(Box::new(URL::new_inherited(url)), global, URLBinding::Wrap) + reflect_dom_object(Box::new(URL::new_inherited(url)), global) } pub fn query_pairs(&self) -> Vec<(String, String)> { diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index 670304a75a1..ef27b969990 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods; -use crate::dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsWrap; use crate::dom::bindings::codegen::UnionTypes::USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::iterable::Iterable; @@ -37,11 +36,7 @@ impl URLSearchParams { } pub fn new(global: &GlobalScope, url: Option<&URL>) -> DomRoot<URLSearchParams> { - reflect_dom_object( - Box::new(URLSearchParams::new_inherited(url)), - global, - URLSearchParamsWrap, - ) + reflect_dom_object(Box::new(URLSearchParams::new_inherited(url)), global) } // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index f41dee046be..7237ca391e0 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::ValidityStateBinding; use crate::dom::bindings::codegen::Bindings::ValidityStateBinding::ValidityStateMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -60,11 +59,7 @@ impl ValidityState { } pub fn new(window: &Window, element: &Element) -> DomRoot<ValidityState> { - reflect_dom_object( - Box::new(ValidityState::new_inherited(element)), - window, - ValidityStateBinding::Wrap, - ) + reflect_dom_object(Box::new(ValidityState::new_inherited(element)), window) } } diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index 025cff9194a..2dab37b7348 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.rs @@ -59,11 +59,11 @@ impl VertexArrayObject { for attrib_data in &**self.vertex_attribs.borrow() { if let Some(buffer) = attrib_data.buffer() { - buffer.decrement_attached_counter(); + buffer.decrement_attached_counter(fallible); } } if let Some(buffer) = self.element_array_buffer.get() { - buffer.decrement_attached_counter(); + buffer.decrement_attached_counter(fallible); } } @@ -136,7 +136,7 @@ impl VertexArrayObject { offset as u32, )); if let Some(old) = data.buffer() { - old.decrement_attached_counter(); + old.decrement_attached_counter(false); } *data = VertexAttribData { @@ -168,7 +168,7 @@ impl VertexArrayObject { if b.id() != buffer.id() { continue; } - b.decrement_attached_counter(); + b.decrement_attached_counter(false); } attrib.buffer = None; } @@ -177,7 +177,7 @@ impl VertexArrayObject { .get() .map_or(false, |b| buffer == &*b) { - buffer.decrement_attached_counter(); + buffer.decrement_attached_counter(false); self.element_array_buffer.set(None); } } diff --git a/components/script/dom/videotrack.rs b/components/script/dom/videotrack.rs index 18a383ab816..8f904284fd9 100644 --- a/components/script/dom/videotrack.rs +++ b/components/script/dom/videotrack.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VideoTrackBinding::{self, VideoTrackMethods}; +use crate::dom::bindings::codegen::Bindings::VideoTrackBinding::VideoTrackMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::DOMString; @@ -55,7 +55,6 @@ impl VideoTrack { id, kind, label, language, track_list, )), window, - VideoTrackBinding::Wrap, ) } diff --git a/components/script/dom/videotracklist.rs b/components/script/dom/videotracklist.rs index 98fa495bfdd..a56e29d1470 100644 --- a/components/script/dom/videotracklist.rs +++ b/components/script/dom/videotracklist.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VideoTrackListBinding::{self, VideoTrackListMethods}; +use crate::dom::bindings::codegen::Bindings::VideoTrackListBinding::VideoTrackListMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -44,7 +44,6 @@ impl VideoTrackList { reflect_dom_object( Box::new(VideoTrackList::new_inherited(tracks, media_element)), window, - VideoTrackListBinding::Wrap, ) } diff --git a/components/script/dom/vrdisplay.rs b/components/script/dom/vrdisplay.rs index 4b3f7426dda..2d59aa6a844 100644 --- a/components/script/dom/vrdisplay.rs +++ b/components/script/dom/vrdisplay.rs @@ -6,7 +6,6 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorMethods; use crate::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceMethods; -use crate::dom::bindings::codegen::Bindings::VRDisplayBinding; use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods; use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VREye; use crate::dom::bindings::codegen::Bindings::VRLayerBinding::VRLayer; @@ -162,11 +161,7 @@ impl VRDisplay { } pub fn new(global: &Window, display: WebVRDisplayData) -> DomRoot<VRDisplay> { - reflect_dom_object( - Box::new(VRDisplay::new_inherited(&global, display)), - global, - VRDisplayBinding::Wrap, - ) + reflect_dom_object(Box::new(VRDisplay::new_inherited(&global, display)), global) } } diff --git a/components/script/dom/vrdisplaycapabilities.rs b/components/script/dom/vrdisplaycapabilities.rs index 214ee617e1c..d4908b88eb1 100644 --- a/components/script/dom/vrdisplaycapabilities.rs +++ b/components/script/dom/vrdisplaycapabilities.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding; use crate::dom::bindings::codegen::Bindings::VRDisplayCapabilitiesBinding::VRDisplayCapabilitiesMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -35,7 +34,6 @@ impl VRDisplayCapabilities { reflect_dom_object( Box::new(VRDisplayCapabilities::new_inherited(capabilities)), global, - VRDisplayCapabilitiesBinding::Wrap, ) } } diff --git a/components/script/dom/vrdisplayevent.rs b/components/script/dom/vrdisplayevent.rs index 711349b4496..00a7ab4012e 100644 --- a/components/script/dom/vrdisplayevent.rs +++ b/components/script/dom/vrdisplayevent.rs @@ -46,7 +46,6 @@ impl VRDisplayEvent { let ev = reflect_dom_object( Box::new(VRDisplayEvent::new_inherited(&display, reason)), global, - VRDisplayEventBinding::Wrap, ); { let event = ev.upcast::<Event>(); diff --git a/components/script/dom/vreyeparameters.rs b/components/script/dom/vreyeparameters.rs index c908b23540d..ae18fbb5416 100644 --- a/components/script/dom/vreyeparameters.rs +++ b/components/script/dom/vreyeparameters.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VREyeParametersBinding; use crate::dom::bindings::codegen::Bindings::VREyeParametersBinding::VREyeParametersMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -57,7 +56,6 @@ impl VREyeParameters { let eye_parameters = reflect_dom_object( Box::new(VREyeParameters::new_inherited(parameters, &fov)), global, - VREyeParametersBinding::Wrap, ); eye_parameters.offset.set(array.get()); diff --git a/components/script/dom/vrfieldofview.rs b/components/script/dom/vrfieldofview.rs index 8009f6a2461..5a82c2aedf2 100644 --- a/components/script/dom/vrfieldofview.rs +++ b/components/script/dom/vrfieldofview.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VRFieldOfViewBinding; use crate::dom::bindings::codegen::Bindings::VRFieldOfViewBinding::VRFieldOfViewMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -30,11 +29,7 @@ impl VRFieldOfView { } pub fn new(global: &Window, fov: WebVRFieldOfView) -> DomRoot<VRFieldOfView> { - reflect_dom_object( - Box::new(VRFieldOfView::new_inherited(fov)), - global, - VRFieldOfViewBinding::Wrap, - ) + reflect_dom_object(Box::new(VRFieldOfView::new_inherited(fov)), global) } } diff --git a/components/script/dom/vrframedata.rs b/components/script/dom/vrframedata.rs index 32af3b394ef..bd81d0a41bf 100644 --- a/components/script/dom/vrframedata.rs +++ b/components/script/dom/vrframedata.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::PerformanceBinding::DOMHighResTimeStamp; -use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding; use crate::dom::bindings::codegen::Bindings::VRFrameDataBinding::VRFrameDataMethods; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -58,11 +57,7 @@ impl VRFrameData { ]; let pose = VRPose::new(&global, &Default::default()); - let root = reflect_dom_object( - Box::new(VRFrameData::new_inherited(&pose)), - global, - VRFrameDataBinding::Wrap, - ); + let root = reflect_dom_object(Box::new(VRFrameData::new_inherited(&pose)), global); let cx = global.get_cx(); create_typed_array(cx, &matrix, &root.left_proj); create_typed_array(cx, &matrix, &root.left_view); diff --git a/components/script/dom/vrpose.rs b/components/script/dom/vrpose.rs index 2303641d6eb..209e02fde81 100644 --- a/components/script/dom/vrpose.rs +++ b/components/script/dom/vrpose.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::VRPoseBinding; use crate::dom::bindings::codegen::Bindings::VRPoseBinding::VRPoseMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -82,11 +81,7 @@ impl VRPose { } pub fn new(global: &GlobalScope, pose: &webvr::VRPose) -> DomRoot<VRPose> { - let root = reflect_dom_object( - Box::new(VRPose::new_inherited()), - global, - VRPoseBinding::Wrap, - ); + let root = reflect_dom_object(Box::new(VRPose::new_inherited()), global); root.update(&pose); root } diff --git a/components/script/dom/vrstageparameters.rs b/components/script/dom/vrstageparameters.rs index e9df89364c4..4cc3ac4ed7c 100644 --- a/components/script/dom/vrstageparameters.rs +++ b/components/script/dom/vrstageparameters.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VRStageParametersBinding; use crate::dom::bindings::codegen::Bindings::VRStageParametersBinding::VRStageParametersMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -52,7 +51,6 @@ impl VRStageParameters { let stage_parameters = reflect_dom_object( Box::new(VRStageParameters::new_inherited(parameters)), global, - VRStageParametersBinding::Wrap, ); stage_parameters.transform.set(array.get()); diff --git a/components/script/dom/vttcue.rs b/components/script/dom/vttcue.rs index 82ffb36c473..28c9cd22e33 100644 --- a/components/script/dom/vttcue.rs +++ b/components/script/dom/vttcue.rs @@ -66,7 +66,6 @@ impl VTTCue { reflect_dom_object( Box::new(Self::new_inherited(start_time, end_time, text)), global, - VTTCueBinding::Wrap, ) } diff --git a/components/script/dom/vttregion.rs b/components/script/dom/vttregion.rs index 167e9fa37bf..987af730f14 100644 --- a/components/script/dom/vttregion.rs +++ b/components/script/dom/vttregion.rs @@ -3,9 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::VTTRegionBinding::{ - self, ScrollSetting, VTTRegionMethods, -}; +use crate::dom::bindings::codegen::Bindings::VTTRegionBinding::{ScrollSetting, VTTRegionMethods}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -45,11 +43,7 @@ impl VTTRegion { } pub fn new(global: &GlobalScope) -> DomRoot<Self> { - reflect_dom_object( - Box::new(Self::new_inherited()), - global, - VTTRegionBinding::Wrap, - ) + reflect_dom_object(Box::new(Self::new_inherited()), global) } #[allow(non_snake_case)] diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index c0c3aab5ad6..03eb5e7abc2 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextMethods; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; @@ -176,9 +175,8 @@ impl WebGL2RenderingContext { size: Size2D<u32>, attrs: GLContextAttributes, ) -> Option<DomRoot<WebGL2RenderingContext>> { - WebGL2RenderingContext::new_inherited(window, canvas, size, attrs).map(|ctx| { - reflect_dom_object(Box::new(ctx), window, WebGL2RenderingContextBinding::Wrap) - }) + WebGL2RenderingContext::new_inherited(window, canvas, size, attrs) + .map(|ctx| reflect_dom_object(Box::new(ctx), window)) } } @@ -222,7 +220,7 @@ impl WebGL2RenderingContext { fn unbind_from(&self, slot: &MutNullableDom<WebGLBuffer>, buffer: &WebGLBuffer) { if slot.get().map_or(false, |b| buffer == &*b) { - buffer.decrement_attached_counter(); + buffer.decrement_attached_counter(false); slot.set(None); } } @@ -349,7 +347,11 @@ impl WebGL2RenderingContext { } let fb_slot = self.base.get_draw_framebuffer_slot(); - if fb_slot.get().is_none() && self.default_fb_readbuffer.get() == constants::NONE { + let fb_readbuffer_valid = match fb_slot.get() { + Some(fb) => fb.attachment(fb.read_buffer()).is_some(), + None => self.default_fb_readbuffer.get() != constants::NONE, + }; + if !fb_readbuffer_valid { return self.base.webgl_error(InvalidOperation); } @@ -3401,7 +3403,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { for slot in &[&generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { - old.decrement_attached_counter(); + old.decrement_attached_counter(false); } slot.set(buffer); } @@ -3479,7 +3481,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { for slot in &[&generic_slot, &indexed_binding.buffer] { if let Some(old) = slot.get() { - old.decrement_attached_counter(); + old.decrement_attached_counter(false); } slot.set(buffer); } @@ -3882,7 +3884,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext { } } -impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> { +impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGL2RenderingContext> { #[allow(unsafe_code)] unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource { let this = &*self.unsafe_get(); diff --git a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs index ddea5daa043..4d03f25781b 100644 --- a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs +++ b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -34,7 +33,6 @@ impl WebGLExtension for ANGLEInstancedArrays { reflect_dom_object( Box::new(ANGLEInstancedArrays::new_inherited(ctx)), &*ctx.global(), - ANGLEInstancedArraysBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/extblendminmax.rs b/components/script/dom/webgl_extensions/ext/extblendminmax.rs index 149ef10b2dc..122aac6c861 100644 --- a/components/script/dom/webgl_extensions/ext/extblendminmax.rs +++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -27,11 +26,7 @@ impl WebGLExtension for EXTBlendMinmax { type Extension = Self; fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> { - reflect_dom_object( - Box::new(Self::new_inherited()), - &*ctx.global(), - EXTBlendMinmaxBinding::Wrap, - ) + reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global()) } fn spec() -> WebGLExtensionSpec { diff --git a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs index 2785fcac2d1..bb4a630d537 100644 --- a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webgl_extensions::ext::oestexturehalffloat::OESTextureHalfFloat; @@ -30,7 +29,6 @@ impl WebGLExtension for EXTColorBufferHalfFloat { reflect_dom_object( Box::new(EXTColorBufferHalfFloat::new_inherited()), &*ctx.global(), - EXTColorBufferHalfFloatBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs index 3ace3673499..ea68b518dac 100644 --- a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs +++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::EXTShaderTextureLodBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -27,11 +26,7 @@ impl WebGLExtension for EXTShaderTextureLod { type Extension = Self; fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> { - reflect_dom_object( - Box::new(Self::new_inherited()), - &*ctx.global(), - EXTShaderTextureLodBinding::Wrap, - ) + reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global()) } fn spec() -> WebGLExtensionSpec { diff --git a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs index b8d987c2839..89a4d3ed6a4 100644 --- a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs +++ b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -28,11 +27,7 @@ impl WebGLExtension for EXTTextureFilterAnisotropic { type Extension = EXTTextureFilterAnisotropic; fn new(ctx: &WebGLRenderingContext) -> DomRoot<Self> { - reflect_dom_object( - Box::new(Self::new_inherited()), - &*ctx.global(), - EXTTextureFilterAnisotropicBinding::Wrap, - ) + reflect_dom_object(Box::new(Self::new_inherited()), &*ctx.global()) } fn spec() -> WebGLExtensionSpec { diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs index 6d6112529b9..096c22d3dc5 100644 --- a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs +++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::OESElementIndexUintBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -30,7 +29,6 @@ impl WebGLExtension for OESElementIndexUint { reflect_dom_object( Box::new(OESElementIndexUint::new_inherited()), &*ctx.global(), - OESElementIndexUintBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index b6945123a12..dfafa7051a5 100644 --- a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding; use crate::dom::bindings::codegen::Bindings::OESStandardDerivativesBinding::OESStandardDerivativesConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -30,7 +29,6 @@ impl WebGLExtension for OESStandardDerivatives { reflect_dom_object( Box::new(OESStandardDerivatives::new_inherited()), &*ctx.global(), - OESStandardDerivativesBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index b3461f9876c..fbcfcdeafeb 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -5,7 +5,6 @@ use super::{ constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, }; -use crate::dom::bindings::codegen::Bindings::OESTextureFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -28,11 +27,7 @@ impl OESTextureFloat { impl WebGLExtension for OESTextureFloat { type Extension = OESTextureFloat; fn new(ctx: &WebGLRenderingContext) -> DomRoot<OESTextureFloat> { - reflect_dom_object( - Box::new(OESTextureFloat::new_inherited()), - &*ctx.global(), - OESTextureFloatBinding::Wrap, - ) + reflect_dom_object(Box::new(OESTextureFloat::new_inherited()), &*ctx.global()) } fn spec() -> WebGLExtensionSpec { diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs index 47b538eb8e0..9e5c021f0ef 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{constants as webgl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::OESTextureFloatLinearBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -28,7 +27,6 @@ impl WebGLExtension for OESTextureFloatLinear { reflect_dom_object( Box::new(OESTextureFloatLinear::new_inherited()), &*ctx.global(), - OESTextureFloatLinearBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs index bff4f76294d..734aedf535c 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs @@ -5,9 +5,7 @@ use super::{ constants as webgl, ext_constants as gl, WebGLExtension, WebGLExtensionSpec, WebGLExtensions, }; -use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::{ - self, OESTextureHalfFloatConstants, -}; +use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -33,7 +31,6 @@ impl WebGLExtension for OESTextureHalfFloat { reflect_dom_object( Box::new(OESTextureHalfFloat::new_inherited()), &*ctx.global(), - OESTextureHalfFloatBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs index 80e03381950..a1e5f3bf15d 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs @@ -4,7 +4,6 @@ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatBinding::OESTextureHalfFloatConstants; -use crate::dom::bindings::codegen::Bindings::OESTextureHalfFloatLinearBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -29,7 +28,6 @@ impl WebGLExtension for OESTextureHalfFloatLinear { reflect_dom_object( Box::new(OESTextureHalfFloatLinear::new_inherited()), &*ctx.global(), - OESTextureHalfFloatLinearBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs index d4f2dda95cb..57a68142609 100644 --- a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs +++ b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs @@ -4,9 +4,7 @@ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; -use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::{ - self, OESVertexArrayObjectMethods, -}; +use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -57,7 +55,6 @@ impl WebGLExtension for OESVertexArrayObject { reflect_dom_object( Box::new(OESVertexArrayObject::new_inherited(ctx)), &*ctx.global(), - OESVertexArrayObjectBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs index 0ac480e9344..c0d8dc13776 100644 --- a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs +++ b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webgl_extensions::ext::oestexturefloat::OESTextureFloat; @@ -30,7 +29,6 @@ impl WebGLExtension for WEBGLColorBufferFloat { reflect_dom_object( Box::new(WEBGLColorBufferFloat::new_inherited()), &*ctx.global(), - WEBGLColorBufferFloatBinding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs index 29805fd4bdd..749c38abd82 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::WEBGLCompressedTextureETC1Binding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -30,7 +29,6 @@ impl WebGLExtension for WEBGLCompressedTextureETC1 { reflect_dom_object( Box::new(WEBGLCompressedTextureETC1::new_inherited()), &*ctx.global(), - WEBGLCompressedTextureETC1Binding::Wrap, ) } diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs index 0e4385abd6b..362dbe67117 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; -use crate::dom::bindings::codegen::Bindings::WEBGLCompressedTextureS3TCBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::webglrenderingcontext::WebGLRenderingContext; @@ -30,7 +29,6 @@ impl WebGLExtension for WEBGLCompressedTextureS3TC { reflect_dom_object( Box::new(WEBGLCompressedTextureS3TC::new_inherited()), &*ctx.global(), - WEBGLCompressedTextureS3TCBinding::Wrap, ) } diff --git a/components/script/dom/webglactiveinfo.rs b/components/script/dom/webglactiveinfo.rs index 79fec919971..93cc0274f35 100644 --- a/components/script/dom/webglactiveinfo.rs +++ b/components/script/dom/webglactiveinfo.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use crate::dom::bindings::codegen::Bindings::WebGLActiveInfoBinding; use crate::dom::bindings::codegen::Bindings::WebGLActiveInfoBinding::WebGLActiveInfoMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -34,7 +33,6 @@ impl WebGLActiveInfo { reflect_dom_object( Box::new(WebGLActiveInfo::new_inherited(size, ty, name)), window, - WebGLActiveInfoBinding::Wrap, ) } } diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index 6e951f3f53e..5ee1e7e1373 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -4,7 +4,6 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants; -use crate::dom::bindings::codegen::Bindings::WebGLBufferBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -61,7 +60,6 @@ impl WebGLBuffer { reflect_dom_object( Box::new(WebGLBuffer::new_inherited(context, id)), &*context.global(), - WebGLBufferBinding::Wrap, ) } } @@ -166,7 +164,7 @@ impl WebGLBuffer { ); } - pub fn decrement_attached_counter(&self) { + pub fn decrement_attached_counter(&self, fallible: bool) { self.attached_counter.set( self.attached_counter .get() @@ -174,7 +172,7 @@ impl WebGLBuffer { .expect("refcount underflowed"), ); if self.is_deleted() { - self.delete(false); + self.delete(fallible); } } diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs index f9714fc37e9..95e83cbf3a5 100644 --- a/components/script/dom/webglcontextevent.rs +++ b/components/script/dom/webglcontextevent.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods; -use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding; use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventInit; use crate::dom::bindings::codegen::Bindings::WebGLContextEventBinding::WebGLContextEventMethods; use crate::dom::bindings::error::Fallible; @@ -52,7 +51,6 @@ impl WebGLContextEvent { let event = reflect_dom_object( Box::new(WebGLContextEvent::new_inherited(status_message)), window, - WebGLContextEventBinding::Wrap, ); { diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index f3f6e939f4f..1e4b75ac86d 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -5,7 +5,6 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLFramebufferBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -165,7 +164,6 @@ impl WebGLFramebuffer { reflect_dom_object( Box::new(WebGLFramebuffer::new_inherited(context, id)), &*context.global(), - WebGLFramebufferBinding::Wrap, ) } } diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 4bb59fb1428..d3a726c1e11 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -5,7 +5,6 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::cell::{DomRefCell, Ref}; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants2; -use crate::dom::bindings::codegen::Bindings::WebGLProgramBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -75,7 +74,6 @@ impl WebGLProgram { reflect_dom_object( Box::new(WebGLProgram::new_inherited(context, id)), &*context.global(), - WebGLProgramBinding::Wrap, ) } } diff --git a/components/script/dom/webglquery.rs b/components/script/dom/webglquery.rs index c3cd4e9e08c..d7418471936 100644 --- a/components/script/dom/webglquery.rs +++ b/components/script/dom/webglquery.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLQueryBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -46,7 +45,6 @@ impl WebGLQuery { reflect_dom_object( Box::new(Self::new_inherited(context, id)), &*context.global(), - WebGLQueryBinding::Wrap, ) } diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 71e56bac1d3..51f1bdbad4e 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -6,7 +6,6 @@ use crate::dom::bindings::codegen::Bindings::EXTColorBufferHalfFloatBinding::EXTColorBufferHalfFloatConstants; use crate::dom::bindings::codegen::Bindings::WEBGLColorBufferFloatBinding::WEBGLColorBufferFloatConstants; use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -59,7 +58,6 @@ impl WebGLRenderbuffer { reflect_dom_object( Box::new(WebGLRenderbuffer::new_inherited(context, id)), &*context.global(), - WebGLRenderbufferBinding::Wrap, ) } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 25e5bf4baa1..8e76eb552a3 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -6,7 +6,6 @@ use crate::dom::bindings::cell::Ref; use crate::dom::bindings::codegen::Bindings::ANGLEInstancedArraysBinding::ANGLEInstancedArraysConstants; use crate::dom::bindings::codegen::Bindings::EXTBlendMinmaxBinding::EXTBlendMinmaxConstants; use crate::dom::bindings::codegen::Bindings::OESVertexArrayObjectBinding::OESVertexArrayObjectConstants; -use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::TexImageSource; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLContextAttributes; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; @@ -264,11 +263,7 @@ impl WebGLRenderingContext { attrs: GLContextAttributes, ) -> Option<DomRoot<WebGLRenderingContext>> { match WebGLRenderingContext::new_inherited(window, canvas, webgl_version, size, attrs) { - Ok(ctx) => Some(reflect_dom_object( - Box::new(ctx), - window, - WebGLRenderingContextBinding::Wrap, - )), + Ok(ctx) => Some(reflect_dom_object(Box::new(ctx), window)), Err(msg) => { error!("Couldn't create WebGLRenderingContext: {}", msg); let event = WebGLContextEvent::new( @@ -1317,7 +1312,7 @@ impl WebGLRenderingContext { self.send_command(WebGLCommand::BindBuffer(target, buffer.map(|b| b.id()))); if let Some(old) = slot.get() { - old.decrement_attached_counter(); + old.decrement_attached_counter(false); } slot.set(buffer); @@ -2565,7 +2560,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext { .map_or(false, |b| buffer == &*b) { self.bound_buffer_array.set(None); - buffer.decrement_attached_counter(); + buffer.decrement_attached_counter(false); } buffer.mark_for_deletion(false); } @@ -4455,7 +4450,7 @@ pub trait LayoutCanvasWebGLRenderingContextHelpers { unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource; } -impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGLRenderingContext> { +impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<'_, WebGLRenderingContext> { #[allow(unsafe_code)] unsafe fn canvas_data_source(&self) -> HTMLCanvasDataSource { (*self.unsafe_get()).layout_handle() diff --git a/components/script/dom/webglsampler.rs b/components/script/dom/webglsampler.rs index 4689677c9bd..c80e2a6a508 100644 --- a/components/script/dom/webglsampler.rs +++ b/components/script/dom/webglsampler.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLSamplerBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; @@ -88,7 +87,6 @@ impl WebGLSampler { reflect_dom_object( Box::new(Self::new_inherited(context, id)), &*context.global(), - WebGLSamplerBinding::Wrap, ) } diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index d8278b1ee5a..5302c6c78ad 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -4,7 +4,6 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::WebGLShaderBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; @@ -76,7 +75,6 @@ impl WebGLShader { reflect_dom_object( Box::new(WebGLShader::new_inherited(context, id, shader_type)), &*context.global(), - WebGLShaderBinding::Wrap, ) } } diff --git a/components/script/dom/webglshaderprecisionformat.rs b/components/script/dom/webglshaderprecisionformat.rs index f40e6edfeb9..e1a7202ff8d 100644 --- a/components/script/dom/webglshaderprecisionformat.rs +++ b/components/script/dom/webglshaderprecisionformat.rs @@ -5,7 +5,6 @@ #![allow(dead_code)] // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use crate::dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding; use crate::dom::bindings::codegen::Bindings::WebGLShaderPrecisionFormatBinding::WebGLShaderPrecisionFormatMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -41,7 +40,6 @@ impl WebGLShaderPrecisionFormat { range_min, range_max, precision, )), window, - WebGLShaderPrecisionFormatBinding::Wrap, ) } } diff --git a/components/script/dom/webglsync.rs b/components/script/dom/webglsync.rs index 7f1fec355f9..dd6acb5be9a 100644 --- a/components/script/dom/webglsync.rs +++ b/components/script/dom/webglsync.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::WebGL2RenderingContextBinding::WebGL2RenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLSyncBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; @@ -43,7 +42,6 @@ impl WebGLSync { reflect_dom_object( Box::new(WebGLSync::new_inherited(context, sync_id)), &*context.global(), - WebGLSyncBinding::Wrap, ) } } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 682f04f0bd8..682920df96e 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -7,7 +7,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EXTTextureFilterAnisotropicBinding::EXTTextureFilterAnisotropicConstants; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -use crate::dom::bindings::codegen::Bindings::WebGLTextureBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -83,7 +82,6 @@ impl WebGLTexture { reflect_dom_object( Box::new(WebGLTexture::new_inherited(context, id)), &*context.global(), - WebGLTextureBinding::Wrap, ) } } diff --git a/components/script/dom/webgltransformfeedback.rs b/components/script/dom/webgltransformfeedback.rs index a58a8e43577..fe4b0753843 100644 --- a/components/script/dom/webgltransformfeedback.rs +++ b/components/script/dom/webgltransformfeedback.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::WebGLTransformFeedbackBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::DomRoot; @@ -42,7 +41,6 @@ impl WebGLTransformFeedback { reflect_dom_object( Box::new(WebGLTransformFeedback::new_inherited(context, id)), &*context.global(), - WebGLTransformFeedbackBinding::Wrap, ) } } diff --git a/components/script/dom/webgluniformlocation.rs b/components/script/dom/webgluniformlocation.rs index 5bdc661f17a..153b2e651ba 100644 --- a/components/script/dom/webgluniformlocation.rs +++ b/components/script/dom/webgluniformlocation.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl -use crate::dom::bindings::codegen::Bindings::WebGLUniformLocationBinding; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::window::Window; @@ -61,7 +60,6 @@ impl WebGLUniformLocation { type_, )), window, - WebGLUniformLocationBinding::Wrap, ) } diff --git a/components/script/dom/webglvertexarrayobject.rs b/components/script/dom/webglvertexarrayobject.rs index 48355d05557..098423d860a 100644 --- a/components/script/dom/webglvertexarrayobject.rs +++ b/components/script/dom/webglvertexarrayobject.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::Ref; -use crate::dom::bindings::codegen::Bindings::WebGLVertexArrayObjectBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; @@ -31,7 +30,6 @@ impl WebGLVertexArrayObject { reflect_dom_object( Box::new(WebGLVertexArrayObject::new_inherited(context, id)), &*context.global(), - WebGLVertexArrayObjectBinding::Wrap, ) } diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index 2c03f084031..a3861c50110 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::Ref; -use crate::dom::bindings::codegen::Bindings::WebGLVertexArrayObjectOESBinding; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; use crate::dom::vertexarrayobject::{VertexArrayObject, VertexAttribData}; @@ -31,7 +30,6 @@ impl WebGLVertexArrayObjectOES { reflect_dom_object( Box::new(WebGLVertexArrayObjectOES::new_inherited(context, id)), &*context.global(), - WebGLVertexArrayObjectOESBinding::Wrap, ) } diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 3ca1905de90..a9fe7fc982b 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -187,19 +187,6 @@ partial interface Document { // readonly attribute HTMLAllCollection all; }; -// http://w3c.github.io/touch-events/#idl-def-Document -partial interface Document { - Touch createTouch(Window/*Proxy*/ view, - EventTarget target, - long identifier, - double pageX, - double pageY, - double screenX, - double screenY); - - TouchList createTouchList(Touch... touches); -}; - // https://fullscreen.spec.whatwg.org/#api partial interface Document { [LenientSetter] readonly attribute boolean fullscreenEnabled; diff --git a/components/script/dom/webidls/Request.webidl b/components/script/dom/webidls/Request.webidl index b185014c606..048636c1e8b 100644 --- a/components/script/dom/webidls/Request.webidl +++ b/components/script/dom/webidls/Request.webidl @@ -95,6 +95,7 @@ enum ReferrerPolicy { "origin", "origin-when-cross-origin", "unsafe-url", + "same-origin", "strict-origin", "strict-origin-when-cross-origin" }; diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 2354bdef91f..89aeda77ebd 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobMethods; -use crate::dom::bindings::codegen::Bindings::WebSocketBinding; use crate::dom::bindings::codegen::Bindings::WebSocketBinding::{BinaryType, WebSocketMethods}; use crate::dom::bindings::codegen::UnionTypes::StringOrStringSequence; use crate::dom::bindings::conversions::ToJSValConvertible; @@ -135,11 +134,7 @@ impl WebSocket { url: ServoUrl, sender: IpcSender<WebSocketDomAction>, ) -> DomRoot<WebSocket> { - reflect_dom_object( - Box::new(WebSocket::new_inherited(url, sender)), - global, - WebSocketBinding::Wrap, - ) + reflect_dom_object(Box::new(WebSocket::new_inherited(url, sender)), global) } /// <https://html.spec.whatwg.org/multipage/#dom-websocket> diff --git a/components/script/dom/wheelevent.rs b/components/script/dom/wheelevent.rs index 8b8ef288282..d7e33b84633 100644 --- a/components/script/dom/wheelevent.rs +++ b/components/script/dom/wheelevent.rs @@ -38,11 +38,7 @@ impl WheelEvent { } pub fn new_unintialized(window: &Window) -> DomRoot<WheelEvent> { - reflect_dom_object( - Box::new(WheelEvent::new_inherited()), - window, - WheelEventBinding::Wrap, - ) + reflect_dom_object(Box::new(WheelEvent::new_inherited()), window) } pub fn new( diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 6b3b51f9a79..688ced4fda7 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -615,7 +615,7 @@ impl WindowMethods for Window { let mut stderr = stderr.lock(); let stdout = stdout(); let mut stdout = stdout.lock(); - writeln!(&mut stdout, "ALERT: {}", s).unwrap(); + writeln!(&mut stdout, "\nALERT: {}", s).unwrap(); stdout.flush().unwrap(); stderr.flush().unwrap(); } @@ -1617,13 +1617,14 @@ impl Window { reflow_info: Reflow { page_clip_rect: self.page_clip_rect.get(), }, - document: self.Document().upcast::<Node>().to_trusted_node_address(), + document: document.upcast::<Node>().to_trusted_node_address(), stylesheets_changed, window_size: self.window_size.get(), origin: self.origin().immutable().clone(), reflow_goal, script_join_chan: join_chan, - dom_count: self.Document().dom_count(), + dom_count: document.dom_count(), + pending_restyles: document.drain_pending_restyles(), }; self.layout_chan diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 86fb9e57b40..d040d7d7468 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -5,7 +5,6 @@ use crate::dom::abstractworker::SimpleWorkerErrorHandler; use crate::dom::abstractworker::WorkerScriptMsg; use crate::dom::bindings::codegen::Bindings::MessagePortBinding::PostMessageOptions; -use crate::dom::bindings::codegen::Bindings::WorkerBinding; use crate::dom::bindings::codegen::Bindings::WorkerBinding::{WorkerMethods, WorkerOptions}; use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::inheritance::Castable; @@ -68,11 +67,7 @@ impl Worker { sender: Sender<DedicatedWorkerScriptMsg>, closing: Arc<AtomicBool>, ) -> DomRoot<Worker> { - reflect_dom_object( - Box::new(Worker::new_inherited(sender, closing)), - global, - WorkerBinding::Wrap, - ) + reflect_dom_object(Box::new(Worker::new_inherited(sender, closing)), global) } // https://html.spec.whatwg.org/multipage/#dom-worker diff --git a/components/script/dom/workerlocation.rs b/components/script/dom/workerlocation.rs index d96aea8011c..c3974e3e1ce 100644 --- a/components/script/dom/workerlocation.rs +++ b/components/script/dom/workerlocation.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding; use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -28,11 +27,7 @@ impl WorkerLocation { } pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> DomRoot<WorkerLocation> { - reflect_dom_object( - Box::new(WorkerLocation::new_inherited(url)), - global, - WorkerLocationBinding::Wrap, - ) + reflect_dom_object(Box::new(WorkerLocation::new_inherited(url)), global) } // https://html.spec.whatwg.org/multipage/#dom-workerlocation-origin diff --git a/components/script/dom/workernavigator.rs b/components/script/dom/workernavigator.rs index cc1dfee13bd..2ff09c48807 100644 --- a/components/script/dom/workernavigator.rs +++ b/components/script/dom/workernavigator.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding; use crate::dom::bindings::codegen::Bindings::WorkerNavigatorBinding::WorkerNavigatorMethods; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -31,11 +30,7 @@ impl WorkerNavigator { } pub fn new(global: &WorkerGlobalScope) -> DomRoot<WorkerNavigator> { - reflect_dom_object( - Box::new(WorkerNavigator::new_inherited()), - global, - WorkerNavigatorBinding::Wrap, - ) + reflect_dom_object(Box::new(WorkerNavigator::new_inherited()), global) } } diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index 227d9d97c81..3e92e09257d 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -14,7 +14,6 @@ use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestCredentials; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletMethods; use crate::dom::bindings::codegen::Bindings::WorkletBinding::WorkletOptions; -use crate::dom::bindings::codegen::Bindings::WorkletBinding::Wrap; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::refcounted::TrustedPromise; @@ -95,7 +94,6 @@ impl Worklet { reflect_dom_object( Box::new(Worklet::new_inherited(window, global_type)), window, - Wrap, ) } diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs index 73d7eee89c5..f4908922ec3 100644 --- a/components/script/dom/xmldocument.rs +++ b/components/script/dom/xmldocument.rs @@ -4,7 +4,7 @@ use crate::document_loader::DocumentLoader; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; -use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods}; +use crate::dom::bindings::codegen::Bindings::XMLDocumentBinding::XMLDocumentMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -85,7 +85,6 @@ impl XMLDocument { doc_loader, )), window, - XMLDocumentBinding::Wrap, ); { let node = doc.upcast::<Node>(); diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 6c531e5b4d6..5ab370feca8 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -6,7 +6,6 @@ use crate::document_loader::DocumentLoader; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::BlobBinding::BlobBinding::BlobMethods; use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods; -use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding; use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::BodyInit; use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestMethods; use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestResponseType; @@ -216,11 +215,7 @@ impl XMLHttpRequest { } } pub fn new(global: &GlobalScope) -> DomRoot<XMLHttpRequest> { - reflect_dom_object( - Box::new(XMLHttpRequest::new_inherited(global)), - global, - XMLHttpRequestBinding::Wrap, - ) + reflect_dom_object(Box::new(XMLHttpRequest::new_inherited(global)), global) } // https://xhr.spec.whatwg.org/#constructors diff --git a/components/script/dom/xmlhttprequestupload.rs b/components/script/dom/xmlhttprequestupload.rs index dba70490d21..7e7b5893395 100644 --- a/components/script/dom/xmlhttprequestupload.rs +++ b/components/script/dom/xmlhttprequestupload.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XMLHttpRequestUploadBinding; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; @@ -21,10 +20,6 @@ impl XMLHttpRequestUpload { } } pub fn new(global: &GlobalScope) -> DomRoot<XMLHttpRequestUpload> { - reflect_dom_object( - Box::new(XMLHttpRequestUpload::new_inherited()), - global, - XMLHttpRequestUploadBinding::Wrap, - ) + reflect_dom_object(Box::new(XMLHttpRequestUpload::new_inherited()), global) } } diff --git a/components/script/dom/xmlserializer.rs b/components/script/dom/xmlserializer.rs index bb5085b1738..2b65d061fa6 100644 --- a/components/script/dom/xmlserializer.rs +++ b/components/script/dom/xmlserializer.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding; use crate::dom::bindings::codegen::Bindings::XMLSerializerBinding::XMLSerializerMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; @@ -28,11 +27,7 @@ impl XMLSerializer { } pub fn new(window: &Window) -> DomRoot<XMLSerializer> { - reflect_dom_object( - Box::new(XMLSerializer::new_inherited(window)), - window, - XMLSerializerBinding::Wrap, - ) + reflect_dom_object(Box::new(XMLSerializer::new_inherited(window)), window) } #[allow(non_snake_case)] diff --git a/components/script/dom/xrframe.rs b/components/script/dom/xrframe.rs index 9a752abf759..6de10312ec3 100644 --- a/components/script/dom/xrframe.rs +++ b/components/script/dom/xrframe.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRFrameBinding; use crate::dom::bindings::codegen::Bindings::XRFrameBinding::XRFrameMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::inheritance::Castable; @@ -40,11 +39,7 @@ impl XRFrame { } pub fn new(global: &GlobalScope, session: &XRSession, data: Frame) -> DomRoot<XRFrame> { - reflect_dom_object( - Box::new(XRFrame::new_inherited(session, data)), - global, - XRFrameBinding::Wrap, - ) + reflect_dom_object(Box::new(XRFrame::new_inherited(session, data)), global) } /// https://immersive-web.github.io/webxr/#xrframe-active diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs index d67945040b1..ed8a3e6f1a5 100644 --- a/components/script/dom/xrinputsource.rs +++ b/components/script/dom/xrinputsource.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ XRHandedness, XRInputSourceMethods, XRTargetRayMode, }; @@ -54,7 +53,6 @@ impl XRInputSource { let source = reflect_dom_object( Box::new(XRInputSource::new_inherited(session, info)), global, - XRInputSourceBinding::Wrap, ); let _ac = enter_realm(&*global); diff --git a/components/script/dom/xrinputsourcearray.rs b/components/script/dom/xrinputsourcearray.rs index 99db386050b..b26f7bd3da7 100644 --- a/components/script/dom/xrinputsourcearray.rs +++ b/components/script/dom/xrinputsourcearray.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::XRInputSourceArrayBinding; use crate::dom::bindings::codegen::Bindings::XRInputSourceArrayBinding::XRInputSourceArrayMethods; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; @@ -31,11 +30,7 @@ impl XRInputSourceArray { } pub fn new(global: &GlobalScope) -> DomRoot<XRInputSourceArray> { - reflect_dom_object( - Box::new(XRInputSourceArray::new_inherited()), - global, - XRInputSourceArrayBinding::Wrap, - ) + reflect_dom_object(Box::new(XRInputSourceArray::new_inherited()), global) } pub fn add_input_sources(&self, session: &XRSession, inputs: &[InputSource]) { diff --git a/components/script/dom/xrinputsourceevent.rs b/components/script/dom/xrinputsourceevent.rs index 445ad84f59a..47ed6d90626 100644 --- a/components/script/dom/xrinputsourceevent.rs +++ b/components/script/dom/xrinputsourceevent.rs @@ -47,7 +47,6 @@ impl XRInputSourceEvent { let trackevent = reflect_dom_object( Box::new(XRInputSourceEvent::new_inherited(frame, source)), global, - XRInputSourceEventBinding::Wrap, ); { let event = trackevent.upcast::<Event>(); diff --git a/components/script/dom/xrinputsourceschangeevent.rs b/components/script/dom/xrinputsourceschangeevent.rs index d05f359dc4d..d23c5ea4157 100644 --- a/components/script/dom/xrinputsourceschangeevent.rs +++ b/components/script/dom/xrinputsourceschangeevent.rs @@ -57,7 +57,6 @@ impl XRInputSourcesChangeEvent { let changeevent = reflect_dom_object( Box::new(XRInputSourcesChangeEvent::new_inherited(session)), global, - XRInputSourcesChangeEventBinding::Wrap, ); { let event = changeevent.upcast::<Event>(); diff --git a/components/script/dom/xrpose.rs b/components/script/dom/xrpose.rs index a9d24f5a0d3..bc9fb3a4be5 100644 --- a/components/script/dom/xrpose.rs +++ b/components/script/dom/xrpose.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRPoseBinding; use crate::dom::bindings::codegen::Bindings::XRPoseBinding::XRPoseMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -28,11 +27,7 @@ impl XRPose { #[allow(unused)] pub fn new(global: &GlobalScope, transform: ApiRigidTransform) -> DomRoot<XRPose> { let transform = XRRigidTransform::new(global, transform); - reflect_dom_object( - Box::new(XRPose::new_inherited(&transform)), - global, - XRPoseBinding::Wrap, - ) + reflect_dom_object(Box::new(XRPose::new_inherited(&transform)), global) } } diff --git a/components/script/dom/xrreferencespace.rs b/components/script/dom/xrreferencespace.rs index 1116407cf46..4565b7681f0 100644 --- a/components/script/dom/xrreferencespace.rs +++ b/components/script/dom/xrreferencespace.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding; use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceMethods; use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType; use crate::dom::bindings::inheritance::Castable; @@ -56,7 +55,6 @@ impl XRReferenceSpace { reflect_dom_object( Box::new(XRReferenceSpace::new_inherited(session, &offset, ty)), global, - XRReferenceSpaceBinding::Wrap, ) } } diff --git a/components/script/dom/xrrenderstate.rs b/components/script/dom/xrrenderstate.rs index bebcfd7de61..199e029ee7d 100644 --- a/components/script/dom/xrrenderstate.rs +++ b/components/script/dom/xrrenderstate.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::{self, XRRenderStateMethods}; +use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, MutNullableDom}; @@ -52,7 +52,6 @@ impl XRRenderState { layer, )), global, - XRRenderStateBinding::Wrap, ) } diff --git a/components/script/dom/xrrigidtransform.rs b/components/script/dom/xrrigidtransform.rs index 86593ae6b97..fad59c0aa11 100644 --- a/components/script/dom/xrrigidtransform.rs +++ b/components/script/dom/xrrigidtransform.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::DOMPointBinding::DOMPointInit; -use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding; use crate::dom::bindings::codegen::Bindings::XRRigidTransformBinding::XRRigidTransformMethods; use crate::dom::bindings::error::Error; use crate::dom::bindings::error::Fallible; @@ -46,11 +45,7 @@ impl XRRigidTransform { } pub fn new(global: &GlobalScope, transform: ApiRigidTransform) -> DomRoot<XRRigidTransform> { - reflect_dom_object( - Box::new(XRRigidTransform::new_inherited(transform)), - global, - XRRigidTransformBinding::Wrap, - ) + reflect_dom_object(Box::new(XRRigidTransform::new_inherited(transform)), global) } pub fn identity(window: &GlobalScope) -> DomRoot<XRRigidTransform> { diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index ed111fb3c02..3396ca669c1 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -9,7 +9,6 @@ use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::Windo use crate::dom::bindings::codegen::Bindings::XRReferenceSpaceBinding::XRReferenceSpaceType; use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateInit; use crate::dom::bindings::codegen::Bindings::XRRenderStateBinding::XRRenderStateMethods; -use crate::dom::bindings::codegen::Bindings::XRSessionBinding; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XREnvironmentBlendMode; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRFrameRequestCallback; use crate::dom::bindings::codegen::Bindings::XRSessionBinding::XRSessionMethods; @@ -130,7 +129,6 @@ impl XRSession { mode, )), global, - XRSessionBinding::Wrap, ); ret.attach_event_handler(); ret.setup_raf_loop(frame_receiver); diff --git a/components/script/dom/xrsessionevent.rs b/components/script/dom/xrsessionevent.rs index 18a8b83a8c3..95005d4e397 100644 --- a/components/script/dom/xrsessionevent.rs +++ b/components/script/dom/xrsessionevent.rs @@ -38,11 +38,8 @@ impl XRSessionEvent { cancelable: bool, session: &XRSession, ) -> DomRoot<XRSessionEvent> { - let trackevent = reflect_dom_object( - Box::new(XRSessionEvent::new_inherited(&session)), - global, - XRSessionEventBinding::Wrap, - ); + let trackevent = + reflect_dom_object(Box::new(XRSessionEvent::new_inherited(&session)), global); { let event = trackevent.upcast::<Event>(); event.init_event(type_, bubbles, cancelable); diff --git a/components/script/dom/xrspace.rs b/components/script/dom/xrspace.rs index 652a4345ce2..80752be3e35 100644 --- a/components/script/dom/xrspace.rs +++ b/components/script/dom/xrspace.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRSpaceBinding; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom}; @@ -55,7 +54,6 @@ impl XRSpace { reflect_dom_object( Box::new(XRSpace::new_inputspace_inner(session, input, is_grip_space)), global, - XRSpaceBinding::Wrap, ) } } diff --git a/components/script/dom/xrsystem.rs b/components/script/dom/xrsystem.rs index 8a8f109722b..78d4a5e89a0 100644 --- a/components/script/dom/xrsystem.rs +++ b/components/script/dom/xrsystem.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::VRDisplayBinding::VRDisplayMethods; -use crate::dom::bindings::codegen::Bindings::XRSystemBinding; use crate::dom::bindings::codegen::Bindings::XRSystemBinding::XRSessionInit; use crate::dom::bindings::codegen::Bindings::XRSystemBinding::{XRSessionMode, XRSystemMethods}; use crate::dom::bindings::conversions::{ConversionResult, FromJSValConvertible}; @@ -74,7 +73,6 @@ impl XRSystem { window.webvr_thread(), )), window, - XRSystemBinding::Wrap, ); root.register(); root diff --git a/components/script/dom/xrtest.rs b/components/script/dom/xrtest.rs index 4c6852fc121..32adb628c11 100644 --- a/components/script/dom/xrtest.rs +++ b/components/script/dom/xrtest.rs @@ -9,9 +9,7 @@ use crate::dom::bindings::callback::ExceptionHandling; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function; -use crate::dom::bindings::codegen::Bindings::XRTestBinding::{ - self, FakeXRDeviceInit, XRTestMethods, -}; +use crate::dom::bindings::codegen::Bindings::XRTestBinding::{FakeXRDeviceInit, XRTestMethods}; use crate::dom::bindings::refcounted::{Trusted, TrustedPromise}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -42,11 +40,7 @@ impl XRTest { } pub fn new(global: &GlobalScope) -> DomRoot<XRTest> { - reflect_dom_object( - Box::new(XRTest::new_inherited()), - global, - XRTestBinding::Wrap, - ) + reflect_dom_object(Box::new(XRTest::new_inherited()), global) } fn device_obtained( diff --git a/components/script/dom/xrview.rs b/components/script/dom/xrview.rs index 04a4a2b66c8..38fc3e82f24 100644 --- a/components/script/dom/xrview.rs +++ b/components/script/dom/xrview.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRViewBinding; use crate::dom::bindings::codegen::Bindings::XRViewBinding::{XREye, XRViewMethods}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; @@ -59,7 +58,6 @@ impl XRView { let ret = reflect_dom_object( Box::new(XRView::new_inherited(session, &transform, eye)), global, - XRViewBinding::Wrap, ); // row_major since euclid uses row vectors diff --git a/components/script/dom/xrviewerpose.rs b/components/script/dom/xrviewerpose.rs index 4391b677130..7aa4bdcb1c1 100644 --- a/components/script/dom/xrviewerpose.rs +++ b/components/script/dom/xrviewerpose.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye; -use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding; use crate::dom::bindings::codegen::Bindings::XRViewerPoseBinding::XRViewerPoseMethods; use crate::dom::bindings::reflector::reflect_dom_object; use crate::dom::bindings::root::DomRoot; @@ -60,11 +59,7 @@ impl XRViewerPose { }, }); let transform = XRRigidTransform::new(global, cast_transform(pose)); - let pose = reflect_dom_object( - Box::new(XRViewerPose::new_inherited(&transform)), - global, - XRViewerPoseBinding::Wrap, - ); + let pose = reflect_dom_object(Box::new(XRViewerPose::new_inherited(&transform)), global); let cx = global.get_cx(); unsafe { diff --git a/components/script/dom/xrviewport.rs b/components/script/dom/xrviewport.rs index 80b8c27fbaa..30872bae0c4 100644 --- a/components/script/dom/xrviewport.rs +++ b/components/script/dom/xrviewport.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::dom::bindings::codegen::Bindings::XRViewportBinding; use crate::dom::bindings::codegen::Bindings::XRViewportBinding::XRViewportMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; @@ -26,11 +25,7 @@ impl XRViewport { } pub fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> { - reflect_dom_object( - Box::new(XRViewport::new_inherited(viewport)), - global, - XRViewportBinding::Wrap, - ) + reflect_dom_object(Box::new(XRViewport::new_inherited(viewport)), global) } } diff --git a/components/script/dom/xrwebgllayer.rs b/components/script/dom/xrwebgllayer.rs index f6e05844dd8..c55115ed6db 100644 --- a/components/script/dom/xrwebgllayer.rs +++ b/components/script/dom/xrwebgllayer.rs @@ -4,7 +4,6 @@ use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods; use crate::dom::bindings::codegen::Bindings::XRViewBinding::{XREye, XRViewMethods}; -use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding; use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerInit; use crate::dom::bindings::codegen::Bindings::XRWebGLLayerBinding::XRWebGLLayerMethods; use crate::dom::bindings::error::Error; @@ -78,7 +77,6 @@ impl XRWebGLLayer { framebuffer, )), global, - XRWebGLLayerBinding::Wrap, ) } diff --git a/components/script/lib.rs b/components/script/lib.rs index 1962e9602d6..0df29eb6359 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -130,7 +130,7 @@ pub mod layout_exports { pub use crate::dom::bindings::inheritance::{HTMLElementTypeId, NodeTypeId, TextTypeId}; pub use crate::dom::bindings::root::LayoutDom; pub use crate::dom::characterdata::LayoutCharacterDataHelpers; - pub use crate::dom::document::{Document, LayoutDocumentHelpers, PendingRestyle}; + pub use crate::dom::document::{Document, LayoutDocumentHelpers}; pub use crate::dom::element::{Element, LayoutElementHelpers, RawLayoutElementHelpers}; pub use crate::dom::node::NodeFlags; pub use crate::dom::node::{LayoutNodeHelpers, Node}; diff --git a/components/script/microtask.rs b/components/script/microtask.rs index 6241b6f63a0..ae4d3c6944e 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -52,6 +52,7 @@ pub struct EnqueuedPromiseCallback { #[ignore_malloc_size_of = "Rc has unclear ownership"] pub callback: Rc<PromiseJobCallback>, pub pipeline: PipelineId, + pub is_user_interacting: bool, } /// A microtask that comes from a queueMicrotask() Javascript call, @@ -105,7 +106,10 @@ impl MicrotaskQueue { match *job { Microtask::Promise(ref job) => { if let Some(target) = target_provider(job.pipeline) { + let was_interacting = ScriptThread::is_user_interacting(); + ScriptThread::set_user_interacting(job.is_user_interacting); let _ = job.callback.Call_(&*target, ExceptionHandling::Report); + ScriptThread::set_user_interacting(was_interacting); } }, Microtask::User(ref job) => { diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 3cce6291d63..abe411521af 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -42,9 +42,11 @@ use js::glue::{ StreamConsumerNoteResponseURLs, StreamConsumerStreamEnd, StreamConsumerStreamError, }; use js::jsapi::ContextOptionsRef; +use js::jsapi::GetPromiseUserInputEventHandlingState; use js::jsapi::InitConsumeStreamCallback; use js::jsapi::InitDispatchToEventLoop; use js::jsapi::MimeType; +use js::jsapi::PromiseUserInputEventHandlingState; use js::jsapi::StreamConsumer as JSStreamConsumer; use js::jsapi::{BuildIdCharVector, DisableIncrementalGC, GCDescription, GCProgress}; use js::jsapi::{Dispatchable as JSRunnable, Dispatchable_MaybeShuttingDown}; @@ -197,7 +199,7 @@ unsafe extern "C" fn empty(extra: *const c_void) -> bool { unsafe extern "C" fn enqueue_promise_job( extra: *const c_void, cx: *mut RawJSContext, - _promise: HandleObject, + promise: HandleObject, job: HandleObject, _allocation_site: HandleObject, incumbent_global: HandleObject, @@ -208,10 +210,18 @@ unsafe extern "C" fn enqueue_promise_job( let microtask_queue = &*(extra as *const MicrotaskQueue); let global = GlobalScope::from_object(incumbent_global.get()); let pipeline = global.pipeline_id(); + let interaction = if promise.get().is_null() { + PromiseUserInputEventHandlingState::DontCare + } else { + GetPromiseUserInputEventHandlingState(promise) + }; + let is_user_interacting = + interaction == PromiseUserInputEventHandlingState::HadUserInteractionAtCreation; microtask_queue.enqueue( Microtask::Promise(EnqueuedPromiseCallback { callback: PromiseJobCallback::new(cx, job.get()), pipeline, + is_user_interacting, }), cx, ); diff --git a/components/script/timers.rs b/components/script/timers.rs index 4be6f822263..5d8893c3055 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -12,6 +12,7 @@ use crate::dom::eventsource::EventSourceTimeoutCallback; use crate::dom::globalscope::GlobalScope; use crate::dom::testbinding::TestBindingCallback; use crate::dom::xmlhttprequest::XHRTimeoutCallback; +use crate::script_thread::ScriptThread; use euclid::Length; use ipc_channel::ipc::IpcSender; use js::jsapi::Heap; @@ -367,6 +368,7 @@ pub struct JsTimerTask { is_interval: IsInterval, nesting_level: u32, duration: MsDuration, + is_user_interacting: bool, } // Enum allowing more descriptive values for the is_interval field @@ -444,6 +446,7 @@ impl JsTimers { source: source, callback: callback, is_interval: is_interval, + is_user_interacting: ScriptThread::is_user_interacting(), nesting_level: 0, duration: Length::new(0), }; @@ -524,12 +527,13 @@ impl JsTimerTask { timers.nesting_level.set(self.nesting_level); // step 4.2 + let was_user_interacting = ScriptThread::is_user_interacting(); + ScriptThread::set_user_interacting(self.is_user_interacting); match self.callback { InternalTimerCallback::StringTimerCallback(ref code_str) => { let global = this.global(); let cx = global.get_cx(); rooted!(in(*cx) let mut rval = UndefinedValue()); - global.evaluate_js_on_global_with_result(code_str, rval.handle_mut()); }, InternalTimerCallback::FunctionTimerCallback(ref function, ref arguments) => { @@ -537,6 +541,7 @@ impl JsTimerTask { let _ = function.Call_(this, arguments, Report); }, }; + ScriptThread::set_user_interacting(was_user_interacting); // reset nesting level (see above) timers.nesting_level.set(0); diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index e48ac42f509..96c4a132368 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -23,8 +23,9 @@ use std::sync::atomic::AtomicBool; use std::sync::Arc; use style::context::QuirksMode; use style::dom::OpaqueNode; +use style::invalidation::element::restyle_hints::RestyleHint; use style::properties::PropertyId; -use style::selector_parser::PseudoElement; +use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot}; use style::stylesheets::Stylesheet; /// Asynchronous messages that script can send to layout. @@ -218,6 +219,8 @@ pub struct ScriptReflow { pub dom_count: u32, /// The current window origin pub origin: ImmutableOrigin, + /// Restyle snapshot map. + pub pending_restyles: Vec<(TrustedNodeAddress, PendingRestyle)>, } pub struct LayoutThreadInit { @@ -234,3 +237,29 @@ pub struct LayoutThreadInit { pub layout_is_busy: Arc<AtomicBool>, pub window_size: WindowSizeData, } + +/// A pending restyle. +#[derive(Debug, MallocSizeOf)] +pub struct PendingRestyle { + /// If this element had a state or attribute change since the last restyle, track + /// the original condition of the element. + pub snapshot: Option<Snapshot>, + + /// Any explicit restyles hints that have been accumulated for this element. + pub hint: RestyleHint, + + /// Any explicit restyles damage that have been accumulated for this element. + pub damage: RestyleDamage, +} + +impl PendingRestyle { + /// Creates a new empty pending restyle. + #[inline] + pub fn new() -> Self { + PendingRestyle { + snapshot: None, + hint: RestyleHint::empty(), + damage: RestyleDamage::empty(), + } + } +} diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index f5801649810..67b107a86d7 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -78,14 +78,14 @@ impl PseudoElementType { } /// Trait to abstract access to layout data across various data structures. -pub trait GetLayoutData { +pub trait GetLayoutData<'dom> { fn get_style_and_layout_data(&self) -> Option<OpaqueStyleAndLayoutData>; } /// A wrapper so that layout can access only the methods that it should have access to. Layout must /// only ever see these and must never see instances of `LayoutDom`. -pub trait LayoutNode: Debug + GetLayoutData + TNode { - type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode; +pub trait LayoutNode<'dom>: Debug + GetLayoutData<'dom> + TNode { + type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>; fn to_threadsafe(&self) -> Self::ConcreteThreadSafeLayoutNode; /// Returns the type ID of this node. @@ -109,16 +109,13 @@ pub trait LayoutNode: Debug + GetLayoutData + TNode { fn is_connected(&self) -> bool; } -pub struct ReverseChildrenIterator<ConcreteNode> -where - ConcreteNode: LayoutNode, -{ +pub struct ReverseChildrenIterator<ConcreteNode> { current: Option<ConcreteNode>, } -impl<ConcreteNode> Iterator for ReverseChildrenIterator<ConcreteNode> +impl<'dom, ConcreteNode> Iterator for ReverseChildrenIterator<ConcreteNode> where - ConcreteNode: LayoutNode, + ConcreteNode: LayoutNode<'dom>, { type Item = ConcreteNode; fn next(&mut self) -> Option<ConcreteNode> { @@ -128,16 +125,13 @@ where } } -pub struct TreeIterator<ConcreteNode> -where - ConcreteNode: LayoutNode, -{ +pub struct TreeIterator<ConcreteNode> { stack: Vec<ConcreteNode>, } -impl<ConcreteNode> TreeIterator<ConcreteNode> +impl<'dom, ConcreteNode> TreeIterator<ConcreteNode> where - ConcreteNode: LayoutNode, + ConcreteNode: LayoutNode<'dom>, { fn new(root: ConcreteNode) -> TreeIterator<ConcreteNode> { let mut stack = vec![]; @@ -150,9 +144,9 @@ where } } -impl<ConcreteNode> Iterator for TreeIterator<ConcreteNode> +impl<'dom, ConcreteNode> Iterator for TreeIterator<ConcreteNode> where - ConcreteNode: LayoutNode, + ConcreteNode: LayoutNode<'dom>, { type Item = ConcreteNode; fn next(&mut self) -> Option<ConcreteNode> { @@ -164,13 +158,13 @@ where /// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout /// node does not allow any parents or siblings of nodes to be accessed, to avoid races. -pub trait ThreadSafeLayoutNode: - Clone + Copy + Debug + GetLayoutData + NodeInfo + PartialEq + Sized +pub trait ThreadSafeLayoutNode<'dom>: + Clone + Copy + Debug + GetLayoutData<'dom> + NodeInfo + PartialEq + Sized { - type ConcreteNode: LayoutNode<ConcreteThreadSafeLayoutNode = Self>; + type ConcreteNode: LayoutNode<'dom, ConcreteThreadSafeLayoutNode = Self>; type ConcreteElement: TElement; - type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<ConcreteThreadSafeLayoutNode = Self> + type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'dom, ConcreteThreadSafeLayoutNode = Self> + ::selectors::Element<Impl = SelectorImpl>; type ChildrenIterator: Iterator<Item = Self> + Sized; @@ -313,15 +307,18 @@ pub trait ThreadSafeLayoutNode: // This trait is only public so that it can be implemented by the gecko wrapper. // It can be used to violate thread-safety, so don't use it elsewhere in layout! #[allow(unsafe_code)] -pub trait DangerousThreadSafeLayoutNode: ThreadSafeLayoutNode { +pub trait DangerousThreadSafeLayoutNode<'dom>: ThreadSafeLayoutNode<'dom> { unsafe fn dangerous_first_child(&self) -> Option<Self>; unsafe fn dangerous_next_sibling(&self) -> Option<Self>; } -pub trait ThreadSafeLayoutElement: - Clone + Copy + Sized + Debug + ::selectors::Element<Impl = SelectorImpl> + GetLayoutData +pub trait ThreadSafeLayoutElement<'dom>: + Clone + Copy + Sized + Debug + ::selectors::Element<Impl = SelectorImpl> + GetLayoutData<'dom> { - type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<ConcreteThreadSafeLayoutElement = Self>; + type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode< + 'dom, + ConcreteThreadSafeLayoutElement = Self, + >; /// This type alias is just a work-around to avoid writing /// diff --git a/components/style/properties/longhands/text.mako.rs b/components/style/properties/longhands/text.mako.rs index b77e17dd6b7..1912bc28e3b 100644 --- a/components/style/properties/longhands/text.mako.rs +++ b/components/style/properties/longhands/text.mako.rs @@ -32,7 +32,6 @@ ${helpers.predefined_type( "TextDecorationLine", "specified::TextDecorationLine::none()", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_specified_value="specified::TextDecorationLine::none()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line", @@ -42,7 +41,7 @@ ${helpers.predefined_type( ${helpers.single_keyword( "text-decoration-style", "solid double dotted dashed wavy -moz-none", - engines="gecko", + engines="gecko servo-2020", animation_value_type="discrete", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-style", )} @@ -51,7 +50,7 @@ ${helpers.predefined_type( "text-decoration-color", "Color", "computed_value::T::currentcolor()", - engines="gecko", + engines="gecko servo-2020", initial_specified_value="specified::Color::currentcolor()", animation_value_type="AnimatedColor", ignored_when_colors_disabled=True, diff --git a/components/style/properties/shorthands/text.mako.rs b/components/style/properties/shorthands/text.mako.rs index 79f7f33d850..defbfaaf3c0 100644 --- a/components/style/properties/shorthands/text.mako.rs +++ b/components/style/properties/shorthands/text.mako.rs @@ -5,7 +5,7 @@ <%namespace name="helpers" file="/helpers.mako.rs" /> <%helpers:shorthand name="text-decoration" - engines="gecko servo-2013" + engines="gecko servo-2013 servo-2020" flags="SHORTHAND_IN_GETCS" sub_properties="text-decoration-line ${' text-decoration-style text-decoration-color text-decoration-thickness' if engine == 'gecko' else ''}" diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 438b926802f..0228d5123ce 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -217,7 +217,7 @@ impl ToComputedValue for TextOverflow { } bitflags! { - #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] + #[derive(MallocSizeOf, Serialize, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[value_info(other_values = "none,underline,overline,line-through,blink")] #[repr(C)] /// Specified keyword values for the text-decoration-line property. @@ -244,6 +244,12 @@ bitflags! { } } +impl Default for TextDecorationLine { + fn default() -> Self { + TextDecorationLine::NONE + } +} + impl Parse for TextDecorationLine { /// none | [ underline || overline || line-through || blink ] fn parse<'i, 't>( |