diff options
author | Josh Matthews <josh@joshmatthews.net> | 2025-01-10 03:19:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 08:19:19 +0000 |
commit | c94d909a8688589209cdf0c7ae58e40f9b8c411e (patch) | |
tree | 12febf23eed4438249fd4d276c4d8b35dee22a97 /components/script | |
parent | f220d6d3a52296794cd19935e9e59cc75a179a44 (diff) | |
download | servo-c94d909a8688589209cdf0c7ae58e40f9b8c411e.tar.gz servo-c94d909a8688589209cdf0c7ae58e40f9b8c411e.zip |
script: Limit public exports. (#34915)
* script: Restrict reexport visibility of DOM types.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Mass pub->pub(crate) conversion.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* script: Hide existing dead code warnings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix clippy warnings.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix unit tests.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Fix clippy.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* More formatting.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
---------
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Diffstat (limited to 'components/script')
583 files changed, 5404 insertions, 5001 deletions
diff --git a/components/script/animation_timeline.rs b/components/script/animation_timeline.rs index 6cae2640cfa..108a90e85e4 100644 --- a/components/script/animation_timeline.rs +++ b/components/script/animation_timeline.rs @@ -21,7 +21,7 @@ pub(crate) struct AnimationTimeline { impl AnimationTimeline { /// Creates a new "normal" timeline, i.e., a "Current" mode timer. #[inline] - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self { current_value: SystemTime::now() .duration_since(UNIX_EPOCH) @@ -32,17 +32,17 @@ impl AnimationTimeline { /// Creates a new "test mode" timeline, with initial time 0. #[inline] - pub fn new_for_testing() -> Self { + pub(crate) fn new_for_testing() -> Self { Self { current_value: 0. } } /// Returns the current value of the timeline in seconds. - pub fn current_value(&self) -> f64 { + pub(crate) fn current_value(&self) -> f64 { self.current_value } /// Updates the value of the `AnimationTimeline` to the current clock time. - pub fn update(&mut self) { + pub(crate) fn update(&mut self) { self.current_value = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap_or_default() @@ -51,7 +51,7 @@ impl AnimationTimeline { /// Increments the current value of the timeline by a specific number of seconds. /// This is used for testing. - pub fn advance_specific(&mut self, by: f64) { + pub(crate) fn advance_specific(&mut self, by: f64) { self.current_value += by; } } diff --git a/components/script/animations.rs b/components/script/animations.rs index 380333bf251..09a0eb4b8eb 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -41,7 +41,7 @@ use crate::script_runtime::CanGc; pub(crate) struct Animations { /// The map of nodes to their animation states. #[no_trace] - pub sets: DocumentAnimationSet, + pub(crate) sets: DocumentAnimationSet, /// Whether or not we have animations that are running. has_running_animations: Cell<bool>, @@ -550,7 +550,7 @@ impl Animations { /// The type of transition event to trigger. These are defined by /// CSS Transitions § 6.1 and CSS Animations § 4.2 #[derive(Clone, Debug, Deserialize, JSTraceable, MallocSizeOf, Serialize)] -pub enum TransitionOrAnimationEventType { +pub(crate) enum TransitionOrAnimationEventType { /// "The transitionrun event occurs when a transition is created (i.e., when it /// is added to the set of running transitions)." TransitionRun, @@ -577,7 +577,7 @@ pub enum TransitionOrAnimationEventType { impl TransitionOrAnimationEventType { /// Whether or not this event is a transition-related event. - pub fn is_transition_event(&self) -> bool { + pub(crate) fn is_transition_event(&self) -> bool { match *self { Self::TransitionRun | Self::TransitionEnd | @@ -593,21 +593,21 @@ impl TransitionOrAnimationEventType { #[derive(Deserialize, JSTraceable, MallocSizeOf, Serialize)] /// A transition or animation event. -pub struct TransitionOrAnimationEvent { +pub(crate) struct TransitionOrAnimationEvent { /// The pipeline id of the layout task that sent this message. #[no_trace] - pub pipeline_id: PipelineId, + pub(crate) pipeline_id: PipelineId, /// The type of transition event this should trigger. - pub event_type: TransitionOrAnimationEventType, + pub(crate) event_type: TransitionOrAnimationEventType, /// The address of the node which owns this transition. #[no_trace] - pub node: OpaqueNode, + pub(crate) node: OpaqueNode, /// The pseudo element for this transition or animation, if applicable. #[no_trace] - pub pseudo_element: Option<PseudoElement>, + pub(crate) pseudo_element: Option<PseudoElement>, /// The name of the property that is transitioning (in the case of a transition) /// or the name of the animation (in the case of an animation). - pub property_or_animation_name: String, + pub(crate) property_or_animation_name: String, /// The elapsed time property to send with this transition event. - pub elapsed_time: f64, + pub(crate) elapsed_time: f64, } diff --git a/components/script/body.rs b/components/script/body.rs index 5ce1a9294f0..5f02a599e77 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -45,7 +45,7 @@ use crate::task_source::SendableTaskSource; /// The Dom object, or ReadableStream, that is the source of a body. /// <https://fetch.spec.whatwg.org/#concept-body-source> #[derive(Clone, PartialEq)] -pub enum BodySource { +pub(crate) enum BodySource { /// A ReadableStream comes with a null-source. Null, /// Another Dom object as source, @@ -79,7 +79,7 @@ struct TransmitBodyConnectHandler { } impl TransmitBodyConnectHandler { - pub fn new( + pub(crate) fn new( stream: Trusted<ReadableStream>, task_source: SendableTaskSource, control_sender: IpcSender<BodyChunkRequest>, @@ -99,7 +99,7 @@ impl TransmitBodyConnectHandler { /// Reset `in_memory_done`, called when a stream is /// re-extracted from the source to support a re-direct. - pub fn reset_in_memory_done(&mut self) { + pub(crate) fn reset_in_memory_done(&mut self) { self.in_memory_done = false; } @@ -337,11 +337,11 @@ impl Callback for TransmitBodyPromiseRejectionHandler { } /// The result of <https://fetch.spec.whatwg.org/#concept-bodyinit-extract> -pub struct ExtractedBody { - pub stream: DomRoot<ReadableStream>, - pub source: BodySource, - pub total_bytes: Option<usize>, - pub content_type: Option<DOMString>, +pub(crate) struct ExtractedBody { + pub(crate) stream: DomRoot<ReadableStream>, + pub(crate) source: BodySource, + pub(crate) total_bytes: Option<usize>, + pub(crate) content_type: Option<DOMString>, } impl ExtractedBody { @@ -356,7 +356,7 @@ impl ExtractedBody { /// /// Transmitting a body over fetch, and consuming it in script, /// are mutually exclusive operations, since each will lock the stream to a reader. - pub fn into_net_request_body(self) -> (RequestBody, DomRoot<ReadableStream>) { + pub(crate) fn into_net_request_body(self) -> (RequestBody, DomRoot<ReadableStream>) { let ExtractedBody { stream, total_bytes, @@ -423,13 +423,13 @@ impl ExtractedBody { } /// Is the data of the stream of this extracted body available in memory? - pub fn in_memory(&self) -> bool { + pub(crate) fn in_memory(&self) -> bool { self.stream.in_memory() } } /// <https://fetch.spec.whatwg.org/#concept-bodyinit-extract> -pub trait Extractable { +pub(crate) trait Extractable { fn extract(&self, global: &GlobalScope, can_gc: CanGc) -> Fallible<ExtractedBody>; } @@ -570,7 +570,7 @@ impl Extractable for URLSearchParams { } #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] -pub enum BodyType { +pub(crate) enum BodyType { Blob, FormData, Json, @@ -578,7 +578,7 @@ pub enum BodyType { ArrayBuffer, } -pub enum FetchedData { +pub(crate) enum FetchedData { Text(String), Json(RootedTraceableBox<Heap<JSValue>>), BlobData(DomRoot<Blob>), @@ -712,7 +712,7 @@ impl Callback for ConsumeBodyPromiseHandler { // https://fetch.spec.whatwg.org/#concept-body-consume-body #[allow(crown::unrooted_must_root)] -pub fn consume_body<T: BodyMixin + DomObject>( +pub(crate) fn consume_body<T: BodyMixin + DomObject>( object: &T, body_type: BodyType, can_gc: CanGc, @@ -889,7 +889,10 @@ fn run_form_data_algorithm( } #[allow(unsafe_code)] -pub fn run_array_buffer_data_algorithm(cx: JSContext, bytes: Vec<u8>) -> Fallible<FetchedData> { +pub(crate) fn run_array_buffer_data_algorithm( + cx: JSContext, + bytes: Vec<u8>, +) -> Fallible<FetchedData> { rooted!(in(*cx) let mut array_buffer_ptr = ptr::null_mut::<JSObject>()); let arraybuffer = unsafe { ArrayBuffer::create( @@ -906,7 +909,7 @@ pub fn run_array_buffer_data_algorithm(cx: JSContext, bytes: Vec<u8>) -> Fallibl } /// <https://fetch.spec.whatwg.org/#body> -pub trait BodyMixin { +pub(crate) trait BodyMixin { /// <https://fetch.spec.whatwg.org/#concept-body-disturbed> fn is_disturbed(&self) -> bool; /// <https://fetch.spec.whatwg.org/#dom-body-body> diff --git a/components/script/build.rs b/components/script/build.rs index e6962d6b3ac..c7a905fa832 100644 --- a/components/script/build.rs +++ b/components/script/build.rs @@ -47,7 +47,7 @@ fn main() { let mut phf = File::create(phf).unwrap(); writeln!( &mut phf, - "pub static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = {};", + "pub(crate) static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = {};", map.build(), ) .unwrap(); diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs index 0641a108244..6a7a6283bf4 100644 --- a/components/script/canvas_state.rs +++ b/components/script/canvas_state.rs @@ -196,40 +196,40 @@ impl CanvasState { } } - pub fn get_ipc_renderer(&self) -> &IpcSender<CanvasMsg> { + pub(crate) fn get_ipc_renderer(&self) -> &IpcSender<CanvasMsg> { &self.ipc_renderer } - pub fn get_missing_image_urls(&self) -> &DomRefCell<Vec<ServoUrl>> { + pub(crate) fn get_missing_image_urls(&self) -> &DomRefCell<Vec<ServoUrl>> { &self.missing_image_urls } - pub fn get_canvas_id(&self) -> CanvasId { + pub(crate) fn get_canvas_id(&self) -> CanvasId { self.canvas_id } - pub fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { + pub(crate) fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { self.ipc_renderer .send(CanvasMsg::Canvas2d(msg, self.get_canvas_id())) .unwrap() } // https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions - pub fn set_bitmap_dimensions(&self, size: Size2D<u64>) { + pub(crate) fn set_bitmap_dimensions(&self, size: Size2D<u64>) { self.reset_to_initial_state(); self.ipc_renderer .send(CanvasMsg::Recreate(Some(size), self.get_canvas_id())) .unwrap(); } - pub fn reset(&self) { + pub(crate) fn reset(&self) { self.reset_to_initial_state(); self.ipc_renderer .send(CanvasMsg::Recreate(None, self.get_canvas_id())) .unwrap(); } - pub fn reset_to_initial_state(&self) { + pub(crate) fn reset_to_initial_state(&self) { self.saved_states.borrow_mut().clear(); *self.state.borrow_mut() = CanvasContextState::new(); } @@ -249,7 +249,7 @@ impl CanvasState { )) } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { self.origin_clean.get() } @@ -311,7 +311,7 @@ impl CanvasState { } } - pub fn get_rect(&self, canvas_size: Size2D<u64>, rect: Rect<u64>) -> Vec<u8> { + pub(crate) fn get_rect(&self, canvas_size: Size2D<u64>, rect: Rect<u64>) -> Vec<u8> { assert!(self.origin_is_clean()); assert!(Rect::from_size(canvas_size).contains_rect(&rect)); @@ -589,7 +589,7 @@ impl CanvasState { Ok(()) } - pub fn mark_as_dirty(&self, canvas: Option<&HTMLCanvasElement>) { + pub(crate) fn mark_as_dirty(&self, canvas: Option<&HTMLCanvasElement>) { if let Some(canvas) = canvas { canvas.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } @@ -665,7 +665,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-fillrect - pub fn fill_rect(&self, x: f64, y: f64, width: f64, height: f64) { + pub(crate) fn fill_rect(&self, x: f64, y: f64, width: f64, height: f64) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) { let style = self.state.borrow().fill_style.to_fill_or_stroke_style(); self.send_canvas_2d_msg(Canvas2dMsg::FillRect(rect, style)); @@ -673,14 +673,14 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-clearrect - pub fn clear_rect(&self, x: f64, y: f64, width: f64, height: f64) { + pub(crate) fn clear_rect(&self, x: f64, y: f64, width: f64, height: f64) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) { self.send_canvas_2d_msg(Canvas2dMsg::ClearRect(rect)); } } // https://html.spec.whatwg.org/multipage/#dom-context-2d-strokerect - pub fn stroke_rect(&self, x: f64, y: f64, width: f64, height: f64) { + pub(crate) fn stroke_rect(&self, x: f64, y: f64, width: f64, height: f64) { if let Some(rect) = self.create_drawable_rect(x, y, width, height) { let style = self.state.borrow().stroke_style.to_fill_or_stroke_style(); self.send_canvas_2d_msg(Canvas2dMsg::StrokeRect(rect, style)); @@ -688,12 +688,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx - pub fn shadow_offset_x(&self) -> f64 { + pub(crate) fn shadow_offset_x(&self) -> f64 { self.state.borrow().shadow_offset_x } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsetx - pub fn set_shadow_offset_x(&self, value: f64) { + pub(crate) fn set_shadow_offset_x(&self, value: f64) { if !value.is_finite() || value == self.state.borrow().shadow_offset_x { return; } @@ -702,12 +702,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety - pub fn shadow_offset_y(&self) -> f64 { + pub(crate) fn shadow_offset_y(&self) -> f64 { self.state.borrow().shadow_offset_y } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowoffsety - pub fn set_shadow_offset_y(&self, value: f64) { + pub(crate) fn set_shadow_offset_y(&self, value: f64) { if !value.is_finite() || value == self.state.borrow().shadow_offset_y { return; } @@ -716,12 +716,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur - pub fn shadow_blur(&self) -> f64 { + pub(crate) fn shadow_blur(&self) -> f64 { self.state.borrow().shadow_blur } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowblur - pub fn set_shadow_blur(&self, value: f64) { + pub(crate) fn set_shadow_blur(&self, value: f64) { if !value.is_finite() || value < 0f64 || value == self.state.borrow().shadow_blur { return; } @@ -730,14 +730,14 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor - pub fn shadow_color(&self) -> DOMString { + pub(crate) fn shadow_color(&self) -> DOMString { let mut result = String::new(); serialize(&self.state.borrow().shadow_color, &mut result).unwrap(); DOMString::from(result) } // https://html.spec.whatwg.org/multipage/#dom-context-2d-shadowcolor - pub fn set_shadow_color( + pub(crate) fn set_shadow_color( &self, canvas: Option<&HTMLCanvasElement>, value: DOMString, @@ -750,7 +750,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle - pub fn stroke_style(&self) -> StringOrCanvasGradientOrCanvasPattern { + pub(crate) fn stroke_style(&self) -> StringOrCanvasGradientOrCanvasPattern { match self.state.borrow().stroke_style { CanvasFillOrStrokeStyle::Color(ref rgba) => { let mut result = String::new(); @@ -767,7 +767,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle - pub fn set_stroke_style( + pub(crate) fn set_stroke_style( &self, canvas: Option<&HTMLCanvasElement>, value: StringOrCanvasGradientOrCanvasPattern, @@ -794,7 +794,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle - pub fn fill_style(&self) -> StringOrCanvasGradientOrCanvasPattern { + pub(crate) fn fill_style(&self) -> StringOrCanvasGradientOrCanvasPattern { match self.state.borrow().fill_style { CanvasFillOrStrokeStyle::Color(ref rgba) => { let mut result = String::new(); @@ -811,7 +811,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-strokestyle - pub fn set_fill_style( + pub(crate) fn set_fill_style( &self, canvas: Option<&HTMLCanvasElement>, value: StringOrCanvasGradientOrCanvasPattern, @@ -838,7 +838,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createlineargradient - pub fn create_linear_gradient( + pub(crate) fn create_linear_gradient( &self, global: &GlobalScope, x0: Finite<f64>, @@ -854,7 +854,7 @@ impl CanvasState { /// <https://html.spec.whatwg.org/multipage/#dom-context-2d-createradialgradient> #[allow(clippy::too_many_arguments)] - pub fn create_radial_gradient( + pub(crate) fn create_radial_gradient( &self, global: &GlobalScope, x0: Finite<f64>, @@ -883,7 +883,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern - pub fn create_pattern( + pub(crate) fn create_pattern( &self, global: &GlobalScope, image: CanvasImageSource, @@ -943,7 +943,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-save - pub fn save(&self) { + pub(crate) fn save(&self) { self.saved_states .borrow_mut() .push(self.state.borrow().clone()); @@ -952,7 +952,7 @@ impl CanvasState { #[allow(crown::unrooted_must_root)] // https://html.spec.whatwg.org/multipage/#dom-context-2d-restore - pub fn restore(&self) { + pub(crate) fn restore(&self) { let mut saved_states = self.saved_states.borrow_mut(); if let Some(state) = saved_states.pop() { self.state.borrow_mut().clone_from(&state); @@ -961,12 +961,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha - pub fn global_alpha(&self) -> f64 { + pub(crate) fn global_alpha(&self) -> f64 { self.state.borrow().global_alpha } // https://html.spec.whatwg.org/multipage/#dom-context-2d-globalalpha - pub fn set_global_alpha(&self, alpha: f64) { + pub(crate) fn set_global_alpha(&self, alpha: f64) { if !alpha.is_finite() || !(0.0..=1.0).contains(&alpha) { return; } @@ -976,7 +976,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation - pub fn global_composite_operation(&self) -> DOMString { + pub(crate) fn global_composite_operation(&self) -> DOMString { match self.state.borrow().global_composition { CompositionOrBlending::Composition(op) => DOMString::from(op.to_str()), CompositionOrBlending::Blending(op) => DOMString::from(op.to_str()), @@ -984,7 +984,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-globalcompositeoperation - pub fn set_global_composite_operation(&self, op_str: DOMString) { + pub(crate) fn set_global_composite_operation(&self, op_str: DOMString) { if let Ok(op) = CompositionOrBlending::from_str(&op_str) { self.state.borrow_mut().global_composition = op; self.send_canvas_2d_msg(Canvas2dMsg::SetGlobalComposition(op)) @@ -992,17 +992,17 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-imagesmoothingenabled - pub fn image_smoothing_enabled(&self) -> bool { + pub(crate) fn image_smoothing_enabled(&self) -> bool { self.state.borrow().image_smoothing_enabled } // https://html.spec.whatwg.org/multipage/#dom-context-2d-imagesmoothingenabled - pub fn set_image_smoothing_enabled(&self, value: bool) { + pub(crate) fn set_image_smoothing_enabled(&self, value: bool) { self.state.borrow_mut().image_smoothing_enabled = value; } // https://html.spec.whatwg.org/multipage/#dom-context-2d-filltext - pub fn fill_text( + pub(crate) fn fill_text( &self, canvas: Option<&HTMLCanvasElement>, text: DOMString, @@ -1043,7 +1043,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#textmetrics - pub fn measure_text( + pub(crate) fn measure_text( &self, global: &GlobalScope, canvas: Option<&HTMLCanvasElement>, @@ -1080,7 +1080,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-font - pub fn set_font(&self, canvas: Option<&HTMLCanvasElement>, value: DOMString, can_gc: CanGc) { + pub(crate) fn set_font( + &self, + canvas: Option<&HTMLCanvasElement>, + value: DOMString, + can_gc: CanGc, + ) { let canvas = match canvas { Some(element) => element, None => return, // offscreen canvas doesn't have a placeholder canvas @@ -1097,7 +1102,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-font - pub fn font(&self) -> DOMString { + pub(crate) fn font(&self) -> DOMString { self.state.borrow().font_style.as_ref().map_or_else( || CanvasContextState::DEFAULT_FONT_STYLE.into(), |style| { @@ -1109,7 +1114,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign - pub fn text_align(&self) -> CanvasTextAlign { + pub(crate) fn text_align(&self) -> CanvasTextAlign { match self.state.borrow().text_align { TextAlign::Start => CanvasTextAlign::Start, TextAlign::End => CanvasTextAlign::End, @@ -1120,7 +1125,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-textalign - pub fn set_text_align(&self, value: CanvasTextAlign) { + pub(crate) fn set_text_align(&self, value: CanvasTextAlign) { let text_align = match value { CanvasTextAlign::Start => TextAlign::Start, CanvasTextAlign::End => TextAlign::End, @@ -1132,7 +1137,7 @@ impl CanvasState { self.send_canvas_2d_msg(Canvas2dMsg::SetTextAlign(text_align)); } - pub fn text_baseline(&self) -> CanvasTextBaseline { + pub(crate) fn text_baseline(&self) -> CanvasTextBaseline { match self.state.borrow().text_baseline { TextBaseline::Top => CanvasTextBaseline::Top, TextBaseline::Hanging => CanvasTextBaseline::Hanging, @@ -1143,7 +1148,7 @@ impl CanvasState { } } - pub fn set_text_baseline(&self, value: CanvasTextBaseline) { + pub(crate) fn set_text_baseline(&self, value: CanvasTextBaseline) { let text_baseline = match value { CanvasTextBaseline::Top => TextBaseline::Top, CanvasTextBaseline::Hanging => TextBaseline::Hanging, @@ -1157,7 +1162,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-direction - pub fn direction(&self) -> CanvasDirection { + pub(crate) fn direction(&self) -> CanvasDirection { match self.state.borrow().direction { Direction::Ltr => CanvasDirection::Ltr, Direction::Rtl => CanvasDirection::Rtl, @@ -1166,7 +1171,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-direction - pub fn set_direction(&self, value: CanvasDirection) { + pub(crate) fn set_direction(&self, value: CanvasDirection) { let direction = match value { CanvasDirection::Ltr => Direction::Ltr, CanvasDirection::Rtl => Direction::Rtl, @@ -1176,12 +1181,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth - pub fn line_width(&self) -> f64 { + pub(crate) fn line_width(&self) -> f64 { self.state.borrow().line_width } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linewidth - pub fn set_line_width(&self, width: f64) { + pub(crate) fn set_line_width(&self, width: f64) { if !width.is_finite() || width <= 0.0 { return; } @@ -1191,7 +1196,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap - pub fn line_cap(&self) -> CanvasLineCap { + pub(crate) fn line_cap(&self) -> CanvasLineCap { match self.state.borrow().line_cap { LineCapStyle::Butt => CanvasLineCap::Butt, LineCapStyle::Round => CanvasLineCap::Round, @@ -1200,7 +1205,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linecap - pub fn set_line_cap(&self, cap: CanvasLineCap) { + pub(crate) fn set_line_cap(&self, cap: CanvasLineCap) { let line_cap = match cap { CanvasLineCap::Butt => LineCapStyle::Butt, CanvasLineCap::Round => LineCapStyle::Round, @@ -1211,7 +1216,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin - pub fn line_join(&self) -> CanvasLineJoin { + pub(crate) fn line_join(&self) -> CanvasLineJoin { match self.state.borrow().line_join { LineJoinStyle::Round => CanvasLineJoin::Round, LineJoinStyle::Bevel => CanvasLineJoin::Bevel, @@ -1220,7 +1225,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-linejoin - pub fn set_line_join(&self, join: CanvasLineJoin) { + pub(crate) fn set_line_join(&self, join: CanvasLineJoin) { let line_join = match join { CanvasLineJoin::Round => LineJoinStyle::Round, CanvasLineJoin::Bevel => LineJoinStyle::Bevel, @@ -1231,12 +1236,12 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit - pub fn miter_limit(&self) -> f64 { + pub(crate) fn miter_limit(&self) -> f64 { self.state.borrow().miter_limit } // https://html.spec.whatwg.org/multipage/#dom-context-2d-miterlimit - pub fn set_miter_limit(&self, limit: f64) { + pub(crate) fn set_miter_limit(&self, limit: f64) { if !limit.is_finite() || limit <= 0.0 { return; } @@ -1246,7 +1251,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata - pub fn create_image_data( + pub(crate) fn create_image_data( &self, global: &GlobalScope, sw: i32, @@ -1260,7 +1265,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-createimagedata - pub fn create_image_data_( + pub(crate) fn create_image_data_( &self, global: &GlobalScope, imagedata: &ImageData, @@ -1271,7 +1276,7 @@ impl CanvasState { // https://html.spec.whatwg.org/multipage/#dom-context-2d-getimagedata #[allow(clippy::too_many_arguments)] - pub fn get_image_data( + pub(crate) fn get_image_data( &self, canvas_size: Size2D<u64>, global: &GlobalScope, @@ -1311,7 +1316,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata - pub fn put_image_data( + pub(crate) fn put_image_data( &self, canvas_size: Size2D<u64>, imagedata: &ImageData, @@ -1332,7 +1337,7 @@ impl CanvasState { /// <https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata> #[allow(unsafe_code, clippy::too_many_arguments)] - pub fn put_image_data_( + pub(crate) fn put_image_data_( &self, canvas_size: Size2D<u64>, imagedata: &ImageData, @@ -1385,7 +1390,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage - pub fn draw_image( + pub(crate) fn draw_image( &self, canvas: Option<&HTMLCanvasElement>, image: CanvasImageSource, @@ -1400,7 +1405,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage - pub fn draw_image_( + pub(crate) fn draw_image_( &self, canvas: Option<&HTMLCanvasElement>, image: CanvasImageSource, @@ -1429,7 +1434,7 @@ impl CanvasState { /// <https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage> #[allow(clippy::too_many_arguments)] - pub fn draw_image__( + pub(crate) fn draw_image__( &self, canvas: Option<&HTMLCanvasElement>, image: CanvasImageSource, @@ -1469,31 +1474,31 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-beginpath - pub fn begin_path(&self) { + pub(crate) fn begin_path(&self) { self.send_canvas_2d_msg(Canvas2dMsg::BeginPath); } // https://html.spec.whatwg.org/multipage/#dom-context-2d-fill - pub fn fill(&self, _fill_rule: CanvasFillRule) { + pub(crate) fn fill(&self, _fill_rule: CanvasFillRule) { // TODO: Process fill rule let style = self.state.borrow().fill_style.to_fill_or_stroke_style(); self.send_canvas_2d_msg(Canvas2dMsg::Fill(style)); } // https://html.spec.whatwg.org/multipage/#dom-context-2d-stroke - pub fn stroke(&self) { + pub(crate) fn stroke(&self) { let style = self.state.borrow().stroke_style.to_fill_or_stroke_style(); self.send_canvas_2d_msg(Canvas2dMsg::Stroke(style)); } // https://html.spec.whatwg.org/multipage/#dom-context-2d-clip - pub fn clip(&self, _fill_rule: CanvasFillRule) { + pub(crate) fn clip(&self, _fill_rule: CanvasFillRule) { // TODO: Process fill rule self.send_canvas_2d_msg(Canvas2dMsg::Clip); } // https://html.spec.whatwg.org/multipage/#dom-context-2d-ispointinpath - pub fn is_point_in_path( + pub(crate) fn is_point_in_path( &self, global: &GlobalScope, x: f64, @@ -1515,7 +1520,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-scale - pub fn scale(&self, x: f64, y: f64) { + pub(crate) fn scale(&self, x: f64, y: f64) { if !(x.is_finite() && y.is_finite()) { return; } @@ -1526,7 +1531,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-rotate - pub fn rotate(&self, angle: f64) { + pub(crate) fn rotate(&self, angle: f64) { if angle == 0.0 || !angle.is_finite() { return; } @@ -1540,7 +1545,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-translate - pub fn translate(&self, x: f64, y: f64) { + pub(crate) fn translate(&self, x: f64, y: f64) { if !(x.is_finite() && y.is_finite()) { return; } @@ -1551,7 +1556,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-transform - pub fn transform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { + pub(crate) fn transform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { if !(a.is_finite() && b.is_finite() && c.is_finite() && @@ -1570,7 +1575,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-gettransform - pub fn get_transform(&self, global: &GlobalScope, can_gc: CanGc) -> DomRoot<DOMMatrix> { + pub(crate) fn get_transform(&self, global: &GlobalScope, can_gc: CanGc) -> DomRoot<DOMMatrix> { let (sender, receiver) = ipc::channel::<Transform2D<f32>>().unwrap(); self.send_canvas_2d_msg(Canvas2dMsg::GetTransform(sender)); let transform = receiver.recv().unwrap(); @@ -1579,7 +1584,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-settransform - pub fn set_transform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { + pub(crate) fn set_transform(&self, a: f64, b: f64, c: f64, d: f64, e: f64, f: f64) { if !(a.is_finite() && b.is_finite() && c.is_finite() && @@ -1596,18 +1601,18 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-resettransform - pub fn reset_transform(&self) { + pub(crate) fn reset_transform(&self) { self.state.borrow_mut().transform = Transform2D::identity(); self.update_transform() } // https://html.spec.whatwg.org/multipage/#dom-context-2d-closepath - pub fn close_path(&self) { + pub(crate) fn close_path(&self) { self.send_canvas_2d_msg(Canvas2dMsg::ClosePath); } // https://html.spec.whatwg.org/multipage/#dom-context-2d-moveto - pub fn move_to(&self, x: f64, y: f64) { + pub(crate) fn move_to(&self, x: f64, y: f64) { if !(x.is_finite() && y.is_finite()) { return; } @@ -1615,7 +1620,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-lineto - pub fn line_to(&self, x: f64, y: f64) { + pub(crate) fn line_to(&self, x: f64, y: f64) { if !(x.is_finite() && y.is_finite()) { return; } @@ -1623,7 +1628,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-rect - pub fn rect(&self, x: f64, y: f64, width: f64, height: f64) { + pub(crate) fn rect(&self, x: f64, y: f64, width: f64, height: f64) { if [x, y, width, height].iter().all(|val| val.is_finite()) { let rect = Rect::new( Point2D::new(x as f32, y as f32), @@ -1634,7 +1639,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-quadraticcurveto - pub fn quadratic_curve_to(&self, cpx: f64, cpy: f64, x: f64, y: f64) { + pub(crate) fn quadratic_curve_to(&self, cpx: f64, cpy: f64, x: f64, y: f64) { if !(cpx.is_finite() && cpy.is_finite() && x.is_finite() && y.is_finite()) { return; } @@ -1645,7 +1650,15 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-beziercurveto - pub fn bezier_curve_to(&self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, x: f64, y: f64) { + pub(crate) fn bezier_curve_to( + &self, + cp1x: f64, + cp1y: f64, + cp2x: f64, + cp2y: f64, + x: f64, + y: f64, + ) { if !(cp1x.is_finite() && cp1y.is_finite() && cp2x.is_finite() && @@ -1663,7 +1676,15 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-arc - pub fn arc(&self, x: f64, y: f64, r: f64, start: f64, end: f64, ccw: bool) -> ErrorResult { + pub(crate) fn arc( + &self, + x: f64, + y: f64, + r: f64, + start: f64, + end: f64, + ccw: bool, + ) -> ErrorResult { if !([x, y, r, start, end].iter().all(|x| x.is_finite())) { return Ok(()); } @@ -1683,7 +1704,7 @@ impl CanvasState { } // https://html.spec.whatwg.org/multipage/#dom-context-2d-arcto - pub fn arc_to(&self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> ErrorResult { + pub(crate) fn arc_to(&self, cp1x: f64, cp1y: f64, cp2x: f64, cp2y: f64, r: f64) -> ErrorResult { if !([cp1x, cp1y, cp2x, cp2y, r].iter().all(|x| x.is_finite())) { return Ok(()); } @@ -1701,7 +1722,7 @@ impl CanvasState { /// <https://html.spec.whatwg.org/multipage/#dom-context-2d-ellipse> #[allow(clippy::too_many_arguments)] - pub fn ellipse( + pub(crate) fn ellipse( &self, x: f64, y: f64, @@ -1735,7 +1756,7 @@ impl CanvasState { } } -pub fn parse_color( +pub(crate) fn parse_color( canvas: Option<&HTMLCanvasElement>, string: &str, can_gc: CanGc, @@ -1784,12 +1805,12 @@ pub fn parse_color( // Used by drawImage to determine if a source or destination rectangle is valid // Origin coordinates and size cannot be negative. Size has to be greater than zero -pub fn is_rect_valid(rect: Rect<f64>) -> bool { +pub(crate) fn is_rect_valid(rect: Rect<f64>) -> bool { rect.size.width > 0.0 && rect.size.height > 0.0 } // https://html.spec.whatwg.org/multipage/#serialisation-of-a-color -pub fn serialize<W>(color: &AbsoluteColor, dest: &mut W) -> fmt::Result +pub(crate) fn serialize<W>(color: &AbsoluteColor, dest: &mut W) -> fmt::Result where W: fmt::Write, { @@ -1819,7 +1840,7 @@ where } } -pub fn adjust_size_sign( +pub(crate) fn adjust_size_sign( mut origin: Point2D<i32>, mut size: Size2D<i32>, ) -> (Point2D<i32>, Size2D<u32>) { diff --git a/components/script/conversions.rs b/components/script/conversions.rs index c9cd43f5e58..7bb5059831b 100644 --- a/components/script/conversions.rs +++ b/components/script/conversions.rs @@ -6,7 +6,7 @@ /// to convert between two types that are not defined in the script crate. /// This is intended to be used on dict/enum types generated from WebIDL once /// those types are moved out of the script crate. -pub trait Convert<T> { +pub(crate) trait Convert<T> { fn convert(self) -> T; } @@ -14,7 +14,7 @@ pub trait Convert<T> { /// to convert between two types that are not defined in the script crate. /// This is intended to be used on dict/enum types generated from WebIDL once /// those types are moved out of the script crate. -pub trait TryConvert<T> { +pub(crate) trait TryConvert<T> { type Error; fn try_convert(self) -> Result<T, Self::Error>; diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 00b6f767a24..5635cbcfd0d 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -44,7 +44,7 @@ use crate::script_module::ScriptFetchOptions; use crate::script_runtime::CanGc; #[allow(unsafe_code)] -pub fn handle_evaluate_js( +pub(crate) fn handle_evaluate_js( global: &GlobalScope, eval: String, reply: IpcSender<EvaluateJSReply>, @@ -97,7 +97,7 @@ pub fn handle_evaluate_js( reply.send(result).unwrap(); } -pub fn handle_get_root_node( +pub(crate) fn handle_get_root_node( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Option<NodeInfo>>, @@ -108,7 +108,7 @@ pub fn handle_get_root_node( reply.send(info).unwrap(); } -pub fn handle_get_document_element( +pub(crate) fn handle_get_document_element( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Option<NodeInfo>>, @@ -133,7 +133,7 @@ fn find_node_by_unique_id( }) } -pub fn handle_get_children( +pub(crate) fn handle_get_children( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -185,7 +185,7 @@ pub fn handle_get_children( }; } -pub fn handle_get_attribute_style( +pub(crate) fn handle_get_attribute_style( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -217,7 +217,7 @@ pub fn handle_get_attribute_style( } #[allow(crown::unrooted_must_root)] -pub fn handle_get_stylesheet_style( +pub(crate) fn handle_get_stylesheet_style( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -264,7 +264,7 @@ pub fn handle_get_stylesheet_style( } #[allow(crown::unrooted_must_root)] -pub fn handle_get_selectors( +pub(crate) fn handle_get_selectors( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -300,7 +300,7 @@ pub fn handle_get_selectors( reply.send(msg).unwrap(); } -pub fn handle_get_computed_style( +pub(crate) fn handle_get_computed_style( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -334,7 +334,7 @@ pub fn handle_get_computed_style( reply.send(Some(msg)).unwrap(); } -pub fn handle_get_layout( +pub(crate) fn handle_get_layout( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -395,7 +395,7 @@ fn determine_auto_margins(node: &Node, can_gc: CanGc) -> AutoMargins { } } -pub fn handle_modify_attribute( +pub(crate) fn handle_modify_attribute( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -435,7 +435,7 @@ pub fn handle_modify_attribute( } } -pub fn handle_modify_rule( +pub(crate) fn handle_modify_rule( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -469,11 +469,11 @@ pub fn handle_modify_rule( } } -pub fn handle_wants_live_notifications(global: &GlobalScope, send_notifications: bool) { +pub(crate) fn handle_wants_live_notifications(global: &GlobalScope, send_notifications: bool) { global.set_devtools_wants_updates(send_notifications); } -pub fn handle_set_timeline_markers( +pub(crate) fn handle_set_timeline_markers( documents: &DocumentCollection, pipeline: PipelineId, marker_types: Vec<TimelineMarkerType>, @@ -485,7 +485,7 @@ pub fn handle_set_timeline_markers( } } -pub fn handle_drop_timeline_markers( +pub(crate) fn handle_drop_timeline_markers( documents: &DocumentCollection, pipeline: PipelineId, marker_types: Vec<TimelineMarkerType>, @@ -495,7 +495,7 @@ pub fn handle_drop_timeline_markers( } } -pub fn handle_request_animation_frame( +pub(crate) fn handle_request_animation_frame( documents: &DocumentCollection, id: PipelineId, actor_name: String, @@ -505,13 +505,13 @@ pub fn handle_request_animation_frame( } } -pub fn handle_reload(documents: &DocumentCollection, id: PipelineId, can_gc: CanGc) { +pub(crate) fn handle_reload(documents: &DocumentCollection, id: PipelineId, can_gc: CanGc) { if let Some(win) = documents.find_window(id) { win.Location().reload_without_origin_check(can_gc); } } -pub fn handle_get_css_database(reply: IpcSender<HashMap<String, CssDatabaseProperty>>) { +pub(crate) fn handle_get_css_database(reply: IpcSender<HashMap<String, CssDatabaseProperty>>) { let database: HashMap<_, _> = ENABLED_LONGHAND_PROPERTIES .iter() .map(|l| { diff --git a/components/script/document_collection.rs b/components/script/document_collection.rs index bcff897910e..66563b55513 100644 --- a/components/script/document_collection.rs +++ b/components/script/document_collection.rs @@ -24,33 +24,33 @@ pub(crate) struct DocumentCollection { } impl DocumentCollection { - pub fn insert(&mut self, pipeline_id: PipelineId, doc: &Document) { + pub(crate) fn insert(&mut self, pipeline_id: PipelineId, doc: &Document) { self.map.insert(pipeline_id, Dom::from_ref(doc)); } - pub fn remove(&mut self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> { + pub(crate) fn remove(&mut self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> { self.map .remove(&pipeline_id) .map(|ref doc| DomRoot::from_ref(&**doc)) } - pub fn find_document(&self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> { + pub(crate) fn find_document(&self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> { self.map .get(&pipeline_id) .map(|doc| DomRoot::from_ref(&**doc)) } - pub fn find_window(&self, pipeline_id: PipelineId) -> Option<DomRoot<Window>> { + pub(crate) fn find_window(&self, pipeline_id: PipelineId) -> Option<DomRoot<Window>> { self.find_document(pipeline_id) .map(|doc| DomRoot::from_ref(doc.window())) } - pub fn find_global(&self, pipeline_id: PipelineId) -> Option<DomRoot<GlobalScope>> { + pub(crate) fn find_global(&self, pipeline_id: PipelineId) -> Option<DomRoot<GlobalScope>> { self.find_window(pipeline_id) .map(|window| DomRoot::from_ref(window.upcast())) } - pub fn find_iframe( + pub(crate) fn find_iframe( &self, pipeline_id: PipelineId, browsing_context_id: BrowsingContextId, @@ -63,7 +63,7 @@ impl DocumentCollection { }) } - pub fn iter(&self) -> DocumentsIter<'_> { + pub(crate) fn iter(&self) -> DocumentsIter<'_> { DocumentsIter { iter: self.map.iter(), } @@ -101,7 +101,7 @@ impl Default for DocumentCollection { } #[allow(crown::unrooted_must_root)] -pub struct DocumentsIter<'a> { +pub(crate) struct DocumentsIter<'a> { iter: hash_map::Iter<'a, PipelineId, Dom<Document>>, } diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index 5d07cea0930..25624c62c1e 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -18,7 +18,7 @@ use crate::fetch::FetchCanceller; use crate::script_runtime::CanGc; #[derive(Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum LoadType { +pub(crate) enum LoadType { Image(#[no_trace] ServoUrl), Script(#[no_trace] ServoUrl), Subframe(#[no_trace] ServoUrl), @@ -32,7 +32,7 @@ pub enum LoadType { /// that the owner is destroyed. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct LoadBlocker { +pub(crate) struct LoadBlocker { /// The document whose load event is blocked by this object existing. doc: Dom<Document>, /// The load that is blocking the document's load event. @@ -41,7 +41,7 @@ pub struct LoadBlocker { impl LoadBlocker { /// Mark the document's load event as blocked on this new load. - pub fn new(doc: &Document, load: LoadType) -> LoadBlocker { + pub(crate) fn new(doc: &Document, load: LoadType) -> LoadBlocker { doc.loader_mut().add_blocking_load(load.clone()); LoadBlocker { doc: Dom::from_ref(doc), @@ -50,7 +50,7 @@ impl LoadBlocker { } /// Remove this load from the associated document's list of blocking loads. - pub fn terminate(blocker: &DomRefCell<Option<LoadBlocker>>, can_gc: CanGc) { + pub(crate) fn terminate(blocker: &DomRefCell<Option<LoadBlocker>>, can_gc: CanGc) { if let Some(this) = blocker.borrow().as_ref() { let load_data = this.load.clone().unwrap(); this.doc.finish_load(load_data, can_gc); @@ -68,7 +68,7 @@ impl Drop for LoadBlocker { } #[derive(JSTraceable, MallocSizeOf)] -pub struct DocumentLoader { +pub(crate) struct DocumentLoader { #[no_trace] resource_threads: ResourceThreads, blocking_loads: Vec<LoadType>, @@ -77,11 +77,11 @@ pub struct DocumentLoader { } impl DocumentLoader { - pub fn new(existing: &DocumentLoader) -> DocumentLoader { + pub(crate) fn new(existing: &DocumentLoader) -> DocumentLoader { DocumentLoader::new_with_threads(existing.resource_threads.clone(), None) } - pub fn new_with_threads( + pub(crate) fn new_with_threads( resource_threads: ResourceThreads, initial_load: Option<ServoUrl>, ) -> DocumentLoader { @@ -96,7 +96,7 @@ impl DocumentLoader { } } - pub fn cancel_all_loads(&mut self) -> bool { + pub(crate) fn cancel_all_loads(&mut self) -> bool { let canceled_any = !self.cancellers.is_empty(); // Associated fetches will be canceled when dropping the canceller. self.cancellers.clear(); @@ -114,7 +114,7 @@ impl DocumentLoader { } /// Initiate a new fetch given a response callback. - pub fn fetch_async_with_callback( + pub(crate) fn fetch_async_with_callback( &mut self, load: LoadType, request: RequestBuilder, @@ -125,7 +125,7 @@ impl DocumentLoader { } /// Initiate a new fetch that does not block the document load event. - pub fn fetch_async_background( + pub(crate) fn fetch_async_background( &mut self, request: RequestBuilder, callback: BoxedFetchCallback, @@ -147,7 +147,7 @@ impl DocumentLoader { } /// Mark an in-progress network request complete. - pub fn finish_load(&mut self, load: &LoadType) { + pub(crate) fn finish_load(&mut self, load: &LoadType) { debug!( "Removing blocking load {:?} ({}).", load, @@ -165,26 +165,26 @@ impl DocumentLoader { } } - pub fn is_blocked(&self) -> bool { + pub(crate) fn is_blocked(&self) -> bool { // TODO: Ensure that we report blocked if parsing is still ongoing. !self.blocking_loads.is_empty() } - pub fn is_only_blocked_by_iframes(&self) -> bool { + pub(crate) fn is_only_blocked_by_iframes(&self) -> bool { self.blocking_loads .iter() .all(|load| matches!(*load, LoadType::Subframe(_))) } - pub fn inhibit_events(&mut self) { + pub(crate) fn inhibit_events(&mut self) { self.events_inhibited = true; } - pub fn events_inhibited(&self) -> bool { + pub(crate) fn events_inhibited(&self) -> bool { self.events_inhibited } - pub fn resource_threads(&self) -> &ResourceThreads { + pub(crate) fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } } diff --git a/components/script/dom/abortcontroller.rs b/components/script/dom/abortcontroller.rs index a7282ca7f4d..448e1654158 100644 --- a/components/script/dom/abortcontroller.rs +++ b/components/script/dom/abortcontroller.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct AbortController { +pub(crate) struct AbortController { reflector_: Reflector, } diff --git a/components/script/dom/abstractrange.rs b/components/script/dom/abstractrange.rs index c16a6434d5b..80cd64a0df5 100644 --- a/components/script/dom/abstractrange.rs +++ b/components/script/dom/abstractrange.rs @@ -17,14 +17,14 @@ use crate::dom::node::{Node, ShadowIncluding}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AbstractRange { +pub(crate) struct AbstractRange { reflector_: Reflector, start: BoundaryPoint, end: BoundaryPoint, } impl AbstractRange { - pub fn new_inherited( + pub(crate) fn new_inherited( start_container: &Node, start_offset: u32, end_container: &Node, @@ -37,7 +37,7 @@ impl AbstractRange { } } - pub fn new( + pub(crate) fn new( document: &Document, start_container: &Node, start_offset: u32, @@ -57,11 +57,11 @@ impl AbstractRange { abstractrange } - pub fn start(&self) -> &BoundaryPoint { + pub(crate) fn start(&self) -> &BoundaryPoint { &self.start } - pub fn end(&self) -> &BoundaryPoint { + pub(crate) fn end(&self) -> &BoundaryPoint { &self.end } } @@ -95,7 +95,7 @@ impl AbstractRangeMethods<crate::DomTypeHolder> for AbstractRange { #[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct BoundaryPoint { +pub(crate) struct BoundaryPoint { node: MutDom<Node>, offset: Cell<u32>, } @@ -109,16 +109,16 @@ impl BoundaryPoint { } } - pub fn set(&self, node: &Node, offset: u32) { + pub(crate) fn set(&self, node: &Node, offset: u32) { self.node.set(node); self.set_offset(offset); } - pub fn set_offset(&self, offset: u32) { + pub(crate) fn set_offset(&self, offset: u32) { self.offset.set(offset); } - pub fn node(&self) -> &MutDom<Node> { + pub(crate) fn node(&self) -> &MutDom<Node> { &self.node } } @@ -143,7 +143,12 @@ impl PartialEq for BoundaryPoint { } /// <https://dom.spec.whatwg.org/#concept-range-bp-position> -pub fn bp_position(a_node: &Node, a_offset: u32, b_node: &Node, b_offset: u32) -> Option<Ordering> { +pub(crate) fn bp_position( + a_node: &Node, + a_offset: u32, + b_node: &Node, + b_offset: u32, +) -> Option<Ordering> { if std::ptr::eq(a_node, b_node) { // Step 1. return Some(a_offset.cmp(&b_offset)); diff --git a/components/script/dom/abstractworker.rs b/components/script/dom/abstractworker.rs index 3803089b0b3..887457e9a3b 100644 --- a/components/script/dom/abstractworker.rs +++ b/components/script/dom/abstractworker.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::reflector::DomObject; use crate::messaging::CommonScriptMsg; /// Messages used to control the worker event loops -pub enum WorkerScriptMsg { +pub(crate) enum WorkerScriptMsg { /// Common variants associated with the script messages Common(CommonScriptMsg), /// Message sent through Worker.postMessage @@ -20,12 +20,12 @@ pub enum WorkerScriptMsg { }, } -pub struct SimpleWorkerErrorHandler<T: DomObject> { - pub addr: Trusted<T>, +pub(crate) struct SimpleWorkerErrorHandler<T: DomObject> { + pub(crate) addr: Trusted<T>, } impl<T: DomObject> SimpleWorkerErrorHandler<T> { - pub fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> { + pub(crate) fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> { SimpleWorkerErrorHandler { addr } } } diff --git a/components/script/dom/abstractworkerglobalscope.rs b/components/script/dom/abstractworkerglobalscope.rs index 383df363ebf..c5c5f3b6b0e 100644 --- a/components/script/dom/abstractworkerglobalscope.rs +++ b/components/script/dom/abstractworkerglobalscope.rs @@ -15,7 +15,7 @@ use crate::realms::enter_realm; use crate::script_runtime::CanGc; use crate::task_queue::{QueuedTaskConversion, TaskQueue}; -pub trait WorkerEventLoopMethods { +pub(crate) trait WorkerEventLoopMethods { type WorkerMsg: QueuedTaskConversion + Send; type ControlMsg; type Event; @@ -30,7 +30,7 @@ pub trait WorkerEventLoopMethods { } // https://html.spec.whatwg.org/multipage/#worker-event-loop -pub fn run_worker_event_loop<T, WorkerMsg, Event>( +pub(crate) fn run_worker_event_loop<T, WorkerMsg, Event>( worker_scope: &T, worker: Option<&TrustedWorkerAddress>, can_gc: CanGc, diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs index 2d78f505214..25f67397cc9 100644 --- a/components/script/dom/activation.rs +++ b/components/script/dom/activation.rs @@ -9,7 +9,7 @@ use crate::dom::htmlinputelement::InputActivationState; use crate::script_runtime::CanGc; /// Trait for elements with defined activation behavior -pub trait Activatable { +pub(crate) trait Activatable { fn as_element(&self) -> ∈ // Is this particular instance of the element activatable? diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 9b8d6457959..6d447e0a9f6 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -29,7 +29,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AnalyserNode { +pub(crate) struct AnalyserNode { node: AudioNode, #[ignore_malloc_size_of = "Defined in servo-media"] #[no_trace] @@ -38,7 +38,7 @@ pub struct AnalyserNode { impl AnalyserNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, options: &AnalyserOptions, @@ -91,7 +91,7 @@ impl AnalyserNode { )) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &AnalyserOptions, @@ -101,7 +101,7 @@ impl AnalyserNode { } #[allow(crown::unrooted_must_root)] - pub fn new_with_proto( + pub(crate) fn new_with_proto( window: &Window, proto: Option<HandleObject>, context: &BaseAudioContext, @@ -130,7 +130,7 @@ impl AnalyserNode { Ok(object) } - pub fn push_block(&self, block: Block) { + pub(crate) fn push_block(&self, block: Block) { self.engine.borrow_mut().push(block) } } diff --git a/components/script/dom/animationevent.rs b/components/script/dom/animationevent.rs index 673db954bb0..10902a9e012 100644 --- a/components/script/dom/animationevent.rs +++ b/components/script/dom/animationevent.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AnimationEvent { +pub(crate) struct AnimationEvent { event: Event, #[no_trace] animation_name: Atom, @@ -38,7 +38,7 @@ impl AnimationEvent { } } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, init: &AnimationEventInit, diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 701175b0fac..63c1e635dad 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -28,7 +28,7 @@ use crate::script_thread::ScriptThread; // https://dom.spec.whatwg.org/#interface-attr #[dom_struct] -pub struct Attr { +pub(crate) struct Attr { node_: Node, #[no_trace] identifier: AttrIdentifier, @@ -62,7 +62,7 @@ impl Attr { } } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( document: &Document, local_name: LocalName, value: AttrValue, @@ -82,17 +82,17 @@ impl Attr { } #[inline] - pub fn name(&self) -> &LocalName { + pub(crate) fn name(&self) -> &LocalName { &self.identifier.name.0 } #[inline] - pub fn namespace(&self) -> &Namespace { + pub(crate) fn namespace(&self) -> &Namespace { &self.identifier.namespace.0 } #[inline] - pub fn prefix(&self) -> Option<&Prefix> { + pub(crate) fn prefix(&self) -> Option<&Prefix> { Some(&self.identifier.prefix.as_ref()?.0) } } @@ -152,7 +152,7 @@ impl AttrMethods<crate::DomTypeHolder> for Attr { } impl Attr { - pub fn set_value(&self, mut value: AttrValue, owner: &Element) { + pub(crate) fn set_value(&self, mut value: AttrValue, owner: &Element) { let name = self.local_name().clone(); let namespace = self.namespace().clone(); let old_value = DOMString::from(&**self.value()); @@ -185,25 +185,25 @@ impl Attr { } /// Used to swap the attribute's value without triggering mutation events - pub fn swap_value(&self, value: &mut AttrValue) { + pub(crate) fn swap_value(&self, value: &mut AttrValue) { mem::swap(&mut *self.value.borrow_mut(), value); } - pub fn identifier(&self) -> &AttrIdentifier { + pub(crate) fn identifier(&self) -> &AttrIdentifier { &self.identifier } - pub fn value(&self) -> Ref<AttrValue> { + pub(crate) fn value(&self) -> Ref<AttrValue> { self.value.borrow() } - pub fn local_name(&self) -> &LocalName { + pub(crate) fn local_name(&self) -> &LocalName { &self.identifier.local_name } /// Sets the owner element. Should be called after the attribute is added /// or removed from its older parent. - pub fn set_owner(&self, owner: Option<&Element>) { + pub(crate) fn set_owner(&self, owner: Option<&Element>) { let ns = self.namespace(); match (self.owner(), owner) { (Some(old), None) => { @@ -220,11 +220,11 @@ impl Attr { self.owner.set(owner); } - pub fn owner(&self) -> Option<DomRoot<Element>> { + pub(crate) fn owner(&self) -> Option<DomRoot<Element>> { self.owner.get() } - pub fn summarize(&self) -> AttrInfo { + pub(crate) fn summarize(&self) -> AttrInfo { AttrInfo { namespace: (**self.namespace()).to_owned(), name: String::from(self.Name()), @@ -232,7 +232,7 @@ impl Attr { } } - pub fn qualified_name(&self) -> DOMString { + pub(crate) fn qualified_name(&self) -> DOMString { match self.prefix() { Some(ref prefix) => DOMString::from(format!("{}:{}", prefix, &**self.local_name())), None => DOMString::from(&**self.local_name()), @@ -241,7 +241,7 @@ impl Attr { } #[allow(unsafe_code)] -pub trait AttrHelpersForLayout<'dom> { +pub(crate) trait AttrHelpersForLayout<'dom> { fn value(self) -> &'dom AttrValue; fn as_str(&self) -> &'dom str; fn to_tokens(self) -> Option<&'dom [Atom]>; diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index 5fc2acdbf4d..1fbdc771f2e 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -26,8 +26,8 @@ use crate::script_runtime::{CanGc, JSContext}; // Spec mandates at least [8000, 96000], we use [8000, 192000] to match Firefox // https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-createbuffer -pub const MIN_SAMPLE_RATE: f32 = 8000.; -pub const MAX_SAMPLE_RATE: f32 = 192000.; +pub(crate) const MIN_SAMPLE_RATE: f32 = 8000.; +pub(crate) const MAX_SAMPLE_RATE: f32 = 192000.; /// The AudioBuffer keeps its data either in js_channels /// or in shared_channels if js_channels buffers are detached. @@ -38,7 +38,7 @@ pub const MAX_SAMPLE_RATE: f32 = 192000.; /// to know in which situations js_channels buffers must be detached. /// #[dom_struct] -pub struct AudioBuffer { +pub(crate) struct AudioBuffer { reflector_: Reflector, /// Float32Arrays returned by calls to GetChannelData. #[ignore_malloc_size_of = "mozjs"] @@ -60,7 +60,11 @@ pub struct AudioBuffer { impl AudioBuffer { #[allow(crown::unrooted_must_root)] - pub fn new_inherited(number_of_channels: u32, length: u32, sample_rate: f32) -> AudioBuffer { + pub(crate) fn new_inherited( + number_of_channels: u32, + length: u32, + sample_rate: f32, + ) -> AudioBuffer { let vec = (0..number_of_channels) .map(|_| HeapBufferSource::default()) .collect(); @@ -75,7 +79,7 @@ impl AudioBuffer { } } - pub fn new( + pub(crate) fn new( global: &Window, number_of_channels: u32, length: u32, @@ -172,7 +176,7 @@ impl AudioBuffer { Some(result) } - pub fn get_channels(&self) -> Ref<Option<ServoMediaAudioBuffer>> { + pub(crate) fn get_channels(&self) -> Ref<Option<ServoMediaAudioBuffer>> { if self.shared_channels.borrow().is_none() { let channels = self.acquire_contents(); if channels.is_some() { diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs index 3f559457b7c..72b857a727f 100644 --- a/components/script/dom/audiobuffersourcenode.rs +++ b/components/script/dom/audiobuffersourcenode.rs @@ -31,7 +31,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioBufferSourceNode { +pub(crate) struct AudioBufferSourceNode { source_node: AudioScheduledSourceNode, buffer: MutNullableDom<AudioBuffer>, buffer_set: Cell<bool>, @@ -96,7 +96,7 @@ impl AudioBufferSourceNode { Ok(node) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &AudioBufferSourceOptions, diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index 247a88a31b9..20987944d8e 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -37,7 +37,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioContext { +pub(crate) struct AudioContext { context: BaseAudioContext, latency_hint: AudioContextLatencyCategory, /// <https://webaudio.github.io/web-audio-api/#dom-audiocontext-baselatency> @@ -104,7 +104,7 @@ impl AudioContext { } } - pub fn base(&self) -> DomRoot<BaseAudioContext> { + pub(crate) fn base(&self) -> DomRoot<BaseAudioContext> { DomRoot::from_ref(&self.context) } } diff --git a/components/script/dom/audiodestinationnode.rs b/components/script/dom/audiodestinationnode.rs index 34f29a8fec3..908303085a5 100644 --- a/components/script/dom/audiodestinationnode.rs +++ b/components/script/dom/audiodestinationnode.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioDestinationNode { +pub(crate) struct AudioDestinationNode { node: AudioNode, } @@ -39,7 +39,7 @@ impl AudioDestinationNode { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, context: &BaseAudioContext, options: &AudioNodeOptions, diff --git a/components/script/dom/audiolistener.rs b/components/script/dom/audiolistener.rs index 27382b80757..2baf410d6c0 100644 --- a/components/script/dom/audiolistener.rs +++ b/components/script/dom/audiolistener.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioListener { +pub(crate) struct AudioListener { reflector_: Reflector, position_x: Dom<AudioParam>, position_y: Dom<AudioParam>, @@ -154,7 +154,7 @@ impl AudioListener { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, can_gc: CanGc, diff --git a/components/script/dom/audionode.rs b/components/script/dom/audionode.rs index 65823798e5d..7a4d13c04d6 100644 --- a/components/script/dom/audionode.rs +++ b/components/script/dom/audionode.rs @@ -28,10 +28,10 @@ use crate::dom::eventtarget::EventTarget; // 32 is the minimum required by the spec for createBuffer() and the deprecated // createScriptProcessor() and matches what is used by Blink and Gecko. // The limit protects against large memory allocations. -pub const MAX_CHANNEL_COUNT: u32 = 32; +pub(crate) const MAX_CHANNEL_COUNT: u32 = 32; #[dom_struct] -pub struct AudioNode { +pub(crate) struct AudioNode { eventtarget: EventTarget, #[ignore_malloc_size_of = "servo_media"] #[no_trace] @@ -45,7 +45,7 @@ pub struct AudioNode { } impl AudioNode { - pub fn new_inherited( + pub(crate) fn new_inherited( node_type: AudioNodeInit, context: &BaseAudioContext, options: UnwrappedAudioNodeOptions, @@ -75,7 +75,7 @@ impl AudioNode { )) } - pub fn new_inherited_for_id( + pub(crate) fn new_inherited_for_id( node_id: NodeId, context: &BaseAudioContext, options: UnwrappedAudioNodeOptions, @@ -94,7 +94,7 @@ impl AudioNode { } } - pub fn message(&self, message: AudioNodeMessage) { + pub(crate) fn message(&self, message: AudioNodeMessage) { self.context .audio_context_impl() .lock() @@ -102,7 +102,7 @@ impl AudioNode { .message_node(self.node_id, message); } - pub fn node_id(&self) -> NodeId { + pub(crate) fn node_id(&self) -> NodeId { self.node_id } } @@ -388,7 +388,7 @@ impl Convert<ServoMediaChannelInterpretation> for ChannelInterpretation { } impl AudioNodeOptions { - pub fn unwrap_or( + pub(crate) fn unwrap_or( &self, count: u32, mode: ChannelCountMode, @@ -404,10 +404,10 @@ impl AudioNodeOptions { /// Each node has a set of defaults, so this lets us work with them /// easily without having to deal with the Options -pub struct UnwrappedAudioNodeOptions { - pub count: u32, - pub mode: ChannelCountMode, - pub interpretation: ChannelInterpretation, +pub(crate) struct UnwrappedAudioNodeOptions { + pub(crate) count: u32, + pub(crate) mode: ChannelCountMode, + pub(crate) interpretation: ChannelInterpretation, } impl Default for UnwrappedAudioNodeOptions { diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 44925883b20..3b3b65d55ee 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -23,7 +23,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioParam { +pub(crate) struct AudioParam { reflector_: Reflector, context: Dom<BaseAudioContext>, #[ignore_malloc_size_of = "servo_media"] @@ -43,7 +43,7 @@ pub struct AudioParam { impl AudioParam { #[allow(clippy::too_many_arguments)] - pub fn new_inherited( + pub(crate) fn new_inherited( context: &BaseAudioContext, node: NodeId, node_type: AudioNodeType, @@ -67,7 +67,7 @@ impl AudioParam { } #[allow(crown::unrooted_must_root, clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, node: NodeId, @@ -99,15 +99,15 @@ impl AudioParam { .message_node(self.node, message); } - pub fn context(&self) -> &BaseAudioContext { + pub(crate) fn context(&self) -> &BaseAudioContext { &self.context } - pub fn node_id(&self) -> NodeId { + pub(crate) fn node_id(&self) -> NodeId { self.node } - pub fn param_type(&self) -> ParamType { + pub(crate) fn param_type(&self) -> ParamType { self.param } } diff --git a/components/script/dom/audioscheduledsourcenode.rs b/components/script/dom/audioscheduledsourcenode.rs index 24f76b274ad..d29c188c476 100644 --- a/components/script/dom/audioscheduledsourcenode.rs +++ b/components/script/dom/audioscheduledsourcenode.rs @@ -19,7 +19,7 @@ use crate::dom::bindings::refcounted::Trusted; use crate::dom::bindings::reflector::DomObject; #[dom_struct] -pub struct AudioScheduledSourceNode { +pub(crate) struct AudioScheduledSourceNode { node: AudioNode, has_start: Cell<bool>, has_stop: Cell<bool>, @@ -27,7 +27,7 @@ pub struct AudioScheduledSourceNode { impl AudioScheduledSourceNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( node_type: AudioNodeInit, context: &BaseAudioContext, options: UnwrappedAudioNodeOptions, @@ -47,11 +47,11 @@ impl AudioScheduledSourceNode { }) } - pub fn node(&self) -> &AudioNode { + pub(crate) fn node(&self) -> &AudioNode { &self.node } - pub fn has_start(&self) -> bool { + pub(crate) fn has_start(&self) -> bool { self.has_start.get() } } diff --git a/components/script/dom/audiotrack.rs b/components/script/dom/audiotrack.rs index 56a2fc15251..1b3960c444f 100644 --- a/components/script/dom/audiotrack.rs +++ b/components/script/dom/audiotrack.rs @@ -16,7 +16,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioTrack { +pub(crate) struct AudioTrack { reflector_: Reflector, id: DOMString, kind: DOMString, @@ -27,7 +27,7 @@ pub struct AudioTrack { } impl AudioTrack { - pub fn new_inherited( + pub(crate) fn new_inherited( id: DOMString, kind: DOMString, label: DOMString, @@ -45,7 +45,7 @@ impl AudioTrack { } } - pub fn new( + pub(crate) fn new( window: &Window, id: DOMString, kind: DOMString, @@ -62,27 +62,27 @@ impl AudioTrack { ) } - pub fn id(&self) -> DOMString { + pub(crate) fn id(&self) -> DOMString { self.id.clone() } - pub fn kind(&self) -> DOMString { + pub(crate) fn kind(&self) -> DOMString { self.kind.clone() } - pub fn enabled(&self) -> bool { + pub(crate) fn enabled(&self) -> bool { self.enabled.get() } - pub fn set_enabled(&self, value: bool) { + pub(crate) fn set_enabled(&self, value: bool) { self.enabled.set(value); } - pub fn add_track_list(&self, track_list: &AudioTrackList) { + pub(crate) fn add_track_list(&self, track_list: &AudioTrackList) { *self.track_list.borrow_mut() = Some(Dom::from_ref(track_list)); } - pub fn remove_track_list(&self) { + pub(crate) fn remove_track_list(&self) { *self.track_list.borrow_mut() = None; } } diff --git a/components/script/dom/audiotracklist.rs b/components/script/dom/audiotracklist.rs index 405c687fb2a..a34efd60cf2 100644 --- a/components/script/dom/audiotracklist.rs +++ b/components/script/dom/audiotracklist.rs @@ -18,14 +18,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct AudioTrackList { +pub(crate) struct AudioTrackList { eventtarget: EventTarget, tracks: DomRefCell<Vec<Dom<AudioTrack>>>, media_element: Option<Dom<HTMLMediaElement>>, } impl AudioTrackList { - pub fn new_inherited( + pub(crate) fn new_inherited( tracks: &[&AudioTrack], media_element: Option<&HTMLMediaElement>, ) -> AudioTrackList { @@ -36,7 +36,7 @@ impl AudioTrackList { } } - pub fn new( + pub(crate) fn new( window: &Window, tracks: &[&AudioTrack], media_element: Option<&HTMLMediaElement>, @@ -48,29 +48,29 @@ impl AudioTrackList { ) } - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.tracks.borrow().len() } - pub fn find(&self, track: &AudioTrack) -> Option<usize> { + pub(crate) fn find(&self, track: &AudioTrack) -> Option<usize> { self.tracks.borrow().iter().position(|t| &**t == track) } - pub fn item(&self, idx: usize) -> Option<DomRoot<AudioTrack>> { + pub(crate) fn item(&self, idx: usize) -> Option<DomRoot<AudioTrack>> { self.tracks .borrow() .get(idx) .map(|track| DomRoot::from_ref(&**track)) } - pub fn enabled_index(&self) -> Option<usize> { + pub(crate) fn enabled_index(&self) -> Option<usize> { self.tracks .borrow() .iter() .position(|track| track.enabled()) } - pub fn set_enabled(&self, idx: usize, value: bool) { + pub(crate) fn set_enabled(&self, idx: usize, value: bool) { let track = match self.item(idx) { Some(t) => t, None => return, @@ -96,12 +96,12 @@ impl AudioTrackList { })); } - pub fn add(&self, track: &AudioTrack) { + pub(crate) fn add(&self, track: &AudioTrack) { self.tracks.borrow_mut().push(Dom::from_ref(track)); track.add_track_list(self); } - pub fn clear(&self) { + pub(crate) fn clear(&self) { self.tracks .borrow() .iter() diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index 16d975134fb..3c9e36a4ec3 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -69,22 +69,22 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[allow(dead_code)] -pub enum BaseAudioContextOptions { +pub(crate) enum BaseAudioContextOptions { AudioContext(RealTimeAudioContextOptions), OfflineAudioContext(OfflineAudioContextOptions), } #[derive(JSTraceable)] struct DecodeResolver { - pub promise: Rc<Promise>, - pub success_callback: Option<Rc<DecodeSuccessCallback>>, - pub error_callback: Option<Rc<DecodeErrorCallback>>, + pub(crate) promise: Rc<Promise>, + pub(crate) success_callback: Option<Rc<DecodeSuccessCallback>>, + pub(crate) error_callback: Option<Rc<DecodeErrorCallback>>, } type BoxedSliceOfPromises = Box<[Rc<Promise>]>; #[dom_struct] -pub struct BaseAudioContext { +pub(crate) struct BaseAudioContext { eventtarget: EventTarget, #[ignore_malloc_size_of = "servo_media"] #[no_trace] @@ -113,7 +113,7 @@ pub struct BaseAudioContext { impl BaseAudioContext { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( options: BaseAudioContextOptions, pipeline_id: PipelineId, ) -> Fallible<BaseAudioContext> { @@ -146,24 +146,24 @@ impl BaseAudioContext { } /// Tells whether this is an OfflineAudioContext or not. - pub fn is_offline(&self) -> bool { + pub(crate) fn is_offline(&self) -> bool { false } - pub fn audio_context_impl(&self) -> Arc<Mutex<AudioContext>> { + pub(crate) fn audio_context_impl(&self) -> Arc<Mutex<AudioContext>> { self.audio_context_impl.clone() } - pub fn destination_node(&self) -> NodeId { + pub(crate) fn destination_node(&self) -> NodeId { self.audio_context_impl.lock().unwrap().dest_node() } - pub fn listener(&self) -> NodeId { + pub(crate) fn listener(&self) -> NodeId { self.audio_context_impl.lock().unwrap().listener() } // https://webaudio.github.io/web-audio-api/#allowed-to-start - pub fn is_allowed_to_start(&self) -> bool { + pub(crate) fn is_allowed_to_start(&self) -> bool { self.state.get() == AudioContextState::Suspended } @@ -219,16 +219,16 @@ impl BaseAudioContext { } /// Control thread processing state - pub fn control_thread_state(&self) -> ProcessingState { + pub(crate) fn control_thread_state(&self) -> ProcessingState { self.audio_context_impl.lock().unwrap().state() } /// Set audio context state - pub fn set_state_attribute(&self, state: AudioContextState) { + pub(crate) fn set_state_attribute(&self, state: AudioContextState) { self.state.set(state); } - pub fn resume(&self) { + pub(crate) fn resume(&self) { let this = Trusted::new(self); // Set the rendering thread state to 'running' and start // rendering the audio graph. @@ -264,7 +264,7 @@ impl BaseAudioContext { } } - pub fn channel_count(&self) -> u32 { + pub(crate) fn channel_count(&self) -> u32 { self.channel_count } } diff --git a/components/script/dom/beforeunloadevent.rs b/components/script/dom/beforeunloadevent.rs index 7e020752a23..de4bd8703b3 100644 --- a/components/script/dom/beforeunloadevent.rs +++ b/components/script/dom/beforeunloadevent.rs @@ -20,7 +20,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#beforeunloadevent #[dom_struct] -pub struct BeforeUnloadEvent { +pub(crate) struct BeforeUnloadEvent { event: Event, return_value: DomRefCell<DOMString>, } @@ -33,7 +33,7 @@ impl BeforeUnloadEvent { } } - pub fn new_uninitialized(window: &Window) -> DomRoot<BeforeUnloadEvent> { + pub(crate) fn new_uninitialized(window: &Window) -> DomRoot<BeforeUnloadEvent> { reflect_dom_object( Box::new(BeforeUnloadEvent::new_inherited()), window, @@ -41,7 +41,7 @@ impl BeforeUnloadEvent { ) } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/bindings/buffer_source.rs b/components/script/dom/bindings/buffer_source.rs index 5af00da3a45..3e095a1e617 100644 --- a/components/script/dom/bindings/buffer_source.rs +++ b/components/script/dom/bindings/buffer_source.rs @@ -25,7 +25,7 @@ use crate::script_runtime::JSContext; /// <https://webidl.spec.whatwg.org/#BufferSource> #[allow(dead_code)] -pub enum BufferSource { +pub(crate) enum BufferSource { Int8Array(Box<Heap<*mut JSObject>>), Int16Array(Box<Heap<*mut JSObject>>), Int32Array(Box<Heap<*mut JSObject>>), @@ -42,7 +42,7 @@ pub enum BufferSource { Default(Box<Heap<*mut JSObject>>), } -pub struct HeapBufferSource<T> { +pub(crate) struct HeapBufferSource<T> { buffer_source: BufferSource, phantom: PhantomData<T>, } @@ -71,7 +71,7 @@ unsafe impl<T> crate::dom::bindings::trace::JSTraceable for HeapBufferSource<T> } } -pub fn new_initialized_heap_buffer_source<T>( +pub(crate) fn new_initialized_heap_buffer_source<T>( init: HeapTypedArrayInit, ) -> Result<HeapBufferSource<T>, ()> where @@ -116,7 +116,7 @@ where Ok(heap_buffer_source) } -pub enum HeapTypedArrayInit { +pub(crate) enum HeapTypedArrayInit { Buffer(BufferSource), Info { len: u32, cx: JSContext }, } @@ -126,14 +126,14 @@ where T: TypedArrayElement + TypedArrayElementCreator, T::Element: Clone + Copy, { - pub fn default() -> HeapBufferSource<T> { + pub(crate) fn default() -> HeapBufferSource<T> { HeapBufferSource { buffer_source: BufferSource::Default(Box::default()), phantom: PhantomData, } } - pub fn set_data(&self, cx: JSContext, data: &[T::Element]) -> Result<(), ()> { + pub(crate) fn set_data(&self, cx: JSContext, data: &[T::Element]) -> Result<(), ()> { rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>()); let _: TypedArray<T, *mut JSObject> = create_buffer_source(cx, data, array.handle_mut())?; @@ -158,7 +158,7 @@ where Ok(()) } - pub fn acquire_data(&self, cx: JSContext) -> Result<Vec<T::Element>, ()> { + pub(crate) fn acquire_data(&self, cx: JSContext) -> Result<Vec<T::Element>, ()> { assert!(self.is_initialized()); typedarray!(in(*cx) let array: TypedArray = match &self.buffer_source { @@ -211,7 +211,7 @@ where } /// <https://tc39.es/ecma262/#sec-detacharraybuffer> - pub fn detach_buffer(&self, cx: JSContext) -> bool { + pub(crate) fn detach_buffer(&self, cx: JSContext) -> bool { match &self.buffer_source { BufferSource::Int8Array(buffer) | BufferSource::Int16Array(buffer) | @@ -247,7 +247,7 @@ where } } - pub fn copy_data_to( + pub(crate) fn copy_data_to( &self, cx: JSContext, dest: &mut [T::Element], @@ -285,7 +285,7 @@ where Ok(()) } - pub fn copy_data_from( + pub(crate) fn copy_data_from( &self, cx: JSContext, source: CustomAutoRooterGuard<TypedArray<T, *mut JSObject>>, @@ -324,7 +324,7 @@ where Ok(()) } - pub fn is_initialized(&self) -> bool { + pub(crate) fn is_initialized(&self) -> bool { match &self.buffer_source { BufferSource::Int8Array(buffer) | BufferSource::Int16Array(buffer) | @@ -343,7 +343,7 @@ where } } - pub fn get_buffer(&self) -> Result<TypedArray<T, *mut JSObject>, ()> { + pub(crate) fn get_buffer(&self) -> Result<TypedArray<T, *mut JSObject>, ()> { TypedArray::from(match &self.buffer_source { BufferSource::Int8Array(buffer) | BufferSource::Int16Array(buffer) | @@ -362,7 +362,7 @@ where }) } - pub fn buffer_to_option(&self) -> Option<TypedArray<T, *mut JSObject>> { + pub(crate) fn buffer_to_option(&self) -> Option<TypedArray<T, *mut JSObject>> { if self.is_initialized() { Some(self.get_buffer().expect("Failed to get buffer.")) } else { @@ -373,7 +373,7 @@ where } /// <https://webidl.spec.whatwg.org/#arraybufferview-create> -pub fn create_buffer_source<T>( +pub(crate) fn create_buffer_source<T>( cx: JSContext, data: &[T::Element], dest: MutableHandleObject, @@ -408,7 +408,7 @@ where } #[derive(JSTraceable, MallocSizeOf)] -pub struct DataBlock { +pub(crate) struct DataBlock { #[ignore_malloc_size_of = "Arc"] data: Arc<Box<[u8]>>, /// Data views (mutable subslices of data) @@ -422,7 +422,7 @@ fn range_overlap<T: std::cmp::PartialOrd>(range1: &Range<T>, range2: &Range<T>) } impl DataBlock { - pub fn new_zeroed(size: usize) -> Self { + pub(crate) fn new_zeroed(size: usize) -> Self { let data = vec![0; size]; Self { data: Arc::new(data.into_boxed_slice()), @@ -431,23 +431,23 @@ impl DataBlock { } /// Panics if there is any active view or src data is not same length - pub fn load(&mut self, src: &[u8]) { + pub(crate) fn load(&mut self, src: &[u8]) { // `Arc::get_mut` ensures there are no views Arc::get_mut(&mut self.data).unwrap().clone_from_slice(src) } /// Panics if there is any active view - pub fn data(&mut self) -> &mut [u8] { + pub(crate) fn data(&mut self) -> &mut [u8] { // `Arc::get_mut` ensures there are no views Arc::get_mut(&mut self.data).unwrap() } - pub fn clear_views(&mut self) { + pub(crate) fn clear_views(&mut self) { self.data_views.clear() } /// Returns error if requested range is already mapped - pub fn view(&mut self, range: Range<usize>) -> Result<&DataView, ()> { + pub(crate) fn view(&mut self, range: Range<usize>) -> Result<&DataView, ()> { if self .data_views .iter() @@ -485,7 +485,7 @@ impl DataBlock { } #[derive(JSTraceable, MallocSizeOf)] -pub struct DataView { +pub(crate) struct DataView { #[no_trace] range: Range<usize>, #[ignore_malloc_size_of = "defined in mozjs"] @@ -493,7 +493,7 @@ pub struct DataView { } impl DataView { - pub fn array_buffer(&self) -> ArrayBuffer { + pub(crate) fn array_buffer(&self) -> ArrayBuffer { unsafe { ArrayBuffer::from(self.buffer.underlying_object().get()).unwrap() } } } diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index b59db051de5..22aa6ea3e9c 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -31,7 +31,7 @@ use crate::script_runtime::{CanGc, JSContext}; /// The exception handling used for a call. #[derive(Clone, Copy, PartialEq)] -pub enum ExceptionHandling { +pub(crate) enum ExceptionHandling { /// Report any exception and don't throw it to the caller code. Report, /// Throw any exception to the caller code. @@ -42,7 +42,7 @@ pub enum ExceptionHandling { /// callback interface types. #[derive(JSTraceable)] #[crown::unrooted_must_root_lint::must_root] -pub struct CallbackObject { +pub(crate) struct CallbackObject { /// The underlying `JSObject`. callback: Heap<*mut JSObject>, permanent_js_root: Heap<JSVal>, @@ -73,7 +73,7 @@ impl CallbackObject { } } - pub fn get(&self) -> *mut JSObject { + pub(crate) fn get(&self) -> *mut JSObject { self.callback.get() } @@ -108,7 +108,7 @@ impl PartialEq for CallbackObject { /// A trait to be implemented by concrete IDL callback function and /// callback interface types. -pub trait CallbackContainer { +pub(crate) trait CallbackContainer { /// Create a new CallbackContainer object for the given `JSObject`. unsafe fn new(cx: JSContext, callback: *mut JSObject) -> Rc<Self>; /// Returns the underlying `CallbackObject`. @@ -129,7 +129,7 @@ pub trait CallbackContainer { /// A common base class for representing IDL callback function types. #[derive(JSTraceable, PartialEq)] #[crown::unrooted_must_root_lint::must_root] -pub struct CallbackFunction { +pub(crate) struct CallbackFunction { object: CallbackObject, } @@ -138,20 +138,20 @@ impl CallbackFunction { #[allow(crown::unrooted_must_root)] // These are used by the bindings and do not need `default()` functions. #[allow(clippy::new_without_default)] - pub fn new() -> CallbackFunction { + pub(crate) fn new() -> CallbackFunction { CallbackFunction { object: CallbackObject::new(), } } /// Returns the underlying `CallbackObject`. - pub fn callback_holder(&self) -> &CallbackObject { + pub(crate) fn callback_holder(&self) -> &CallbackObject { &self.object } /// Initialize the callback function with a value. /// Should be called once this object is done moving. - pub unsafe fn init(&mut self, cx: JSContext, callback: *mut JSObject) { + pub(crate) unsafe fn init(&mut self, cx: JSContext, callback: *mut JSObject) { self.object.init(cx, callback); } } @@ -159,7 +159,7 @@ impl CallbackFunction { /// A common base class for representing IDL callback interface types. #[derive(JSTraceable, PartialEq)] #[crown::unrooted_must_root_lint::must_root] -pub struct CallbackInterface { +pub(crate) struct CallbackInterface { object: CallbackObject, } @@ -167,26 +167,26 @@ impl CallbackInterface { /// Create a new CallbackInterface object for the given `JSObject`. // These are used by the bindings and do not need `default()` functions. #[allow(clippy::new_without_default)] - pub fn new() -> CallbackInterface { + pub(crate) fn new() -> CallbackInterface { CallbackInterface { object: CallbackObject::new(), } } /// Returns the underlying `CallbackObject`. - pub fn callback_holder(&self) -> &CallbackObject { + pub(crate) fn callback_holder(&self) -> &CallbackObject { &self.object } /// Initialize the callback function with a value. /// Should be called once this object is done moving. - pub unsafe fn init(&mut self, cx: JSContext, callback: *mut JSObject) { + pub(crate) unsafe fn init(&mut self, cx: JSContext, callback: *mut JSObject) { self.object.init(cx, callback); } /// Returns the property with the given `name`, if it is a callable object, /// or an error otherwise. - pub fn get_callable_property(&self, cx: JSContext, name: &str) -> Fallible<JSVal> { + pub(crate) fn get_callable_property(&self, cx: JSContext, name: &str) -> Fallible<JSVal> { rooted!(in(*cx) let mut callable = UndefinedValue()); rooted!(in(*cx) let obj = self.callback_holder().get()); unsafe { @@ -206,7 +206,7 @@ impl CallbackInterface { } } -pub trait ThisReflector { +pub(crate) trait ThisReflector { fn jsobject(&self) -> *mut JSObject; } @@ -223,7 +223,7 @@ impl ThisReflector for HandleObject<'_> { } /// Wraps the reflector for `p` into the realm of `cx`. -pub fn wrap_call_this_object<T: ThisReflector>( +pub(crate) fn wrap_call_this_object<T: ThisReflector>( cx: JSContext, p: &T, mut rval: MutableHandleObject, @@ -240,7 +240,7 @@ pub fn wrap_call_this_object<T: ThisReflector>( /// A class that performs whatever setup we need to safely make a call while /// this class is on the stack. After `new` returns, the call is safe to make. -pub struct CallSetup { +pub(crate) struct CallSetup { /// The global for reporting exceptions. This is the global object of the /// (possibly wrapped) callback object. exception_global: DomRoot<GlobalScope>, @@ -261,7 +261,10 @@ pub struct CallSetup { impl CallSetup { /// Performs the setup needed to make a call. #[allow(crown::unrooted_must_root)] - pub fn new<T: CallbackContainer>(callback: &T, handling: ExceptionHandling) -> CallSetup { + pub(crate) fn new<T: CallbackContainer>( + callback: &T, + handling: ExceptionHandling, + ) -> CallSetup { let global = unsafe { GlobalScope::from_object(callback.callback()) }; if let Some(window) = global.downcast::<Window>() { window.Document().ensure_safe_to_run_script_or_layout(); @@ -281,7 +284,7 @@ impl CallSetup { } /// Returns the `JSContext` used for the call. - pub fn get_context(&self) -> JSContext { + pub(crate) fn get_context(&self) -> JSContext { self.cx } } diff --git a/components/script/dom/bindings/cell.rs b/components/script/dom/bindings/cell.rs index 60f3225eee3..df0ca84b060 100644 --- a/components/script/dom/bindings/cell.rs +++ b/components/script/dom/bindings/cell.rs @@ -6,12 +6,12 @@ use std::cell::{BorrowError, BorrowMutError}; #[cfg(not(feature = "refcell_backtrace"))] -pub use std::cell::{Ref, RefCell, RefMut}; +pub(crate) use std::cell::{Ref, RefCell, RefMut}; #[cfg(feature = "refcell_backtrace")] -pub use accountable_refcell::{ref_filter_map, Ref, RefCell, RefMut}; +pub(crate) use accountable_refcell::{ref_filter_map, Ref, RefCell, RefMut}; #[cfg(not(feature = "refcell_backtrace"))] -pub use ref_filter_map::ref_filter_map; +pub(crate) use ref_filter_map::ref_filter_map; use crate::dom::bindings::root::{assert_in_layout, assert_in_script}; @@ -20,7 +20,7 @@ use crate::dom::bindings::root::{assert_in_layout, assert_in_script}; /// This extends the API of `std::cell::RefCell` to allow unsafe access in /// certain situations, with dynamic checking in debug builds. #[derive(Clone, Debug, Default, MallocSizeOf, PartialEq)] -pub struct DomRefCell<T> { +pub(crate) struct DomRefCell<T> { value: RefCell<T>, } @@ -42,7 +42,7 @@ impl<T> DomRefCell<T> { /// /// Panics if the value is currently mutably borrowed. #[allow(unsafe_code)] - pub unsafe fn borrow_for_layout(&self) -> &T { + pub(crate) unsafe fn borrow_for_layout(&self) -> &T { assert_in_layout(); self.value .try_borrow_unguarded() @@ -61,7 +61,7 @@ impl<T> DomRefCell<T> { /// /// Panics if this is called from anywhere other than the script thread. #[allow(unsafe_code, clippy::mut_from_ref)] - pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T { + pub(crate) unsafe fn borrow_for_script_deallocation(&self) -> &mut T { assert_in_script(); &mut *self.value.as_ptr() } @@ -79,7 +79,7 @@ impl<T> DomRefCell<T> { /// /// Panics if this is called from anywhere other than the layout thread. #[allow(unsafe_code, clippy::mut_from_ref)] - pub unsafe fn borrow_mut_for_layout(&self) -> &mut T { + pub(crate) unsafe fn borrow_mut_for_layout(&self) -> &mut T { assert_in_layout(); &mut *self.value.as_ptr() } @@ -89,7 +89,7 @@ impl<T> DomRefCell<T> { // =================================================== impl<T> DomRefCell<T> { /// Create a new `DomRefCell` containing `value`. - pub fn new(value: T) -> DomRefCell<T> { + pub(crate) fn new(value: T) -> DomRefCell<T> { DomRefCell { value: RefCell::new(value), } @@ -104,7 +104,7 @@ impl<T> DomRefCell<T> { /// /// Panics if the value is currently mutably borrowed. #[track_caller] - pub fn borrow(&self) -> Ref<T> { + pub(crate) fn borrow(&self) -> Ref<T> { self.value.borrow() } @@ -117,7 +117,7 @@ impl<T> DomRefCell<T> { /// /// Panics if the value is currently borrowed. #[track_caller] - pub fn borrow_mut(&self) -> RefMut<T> { + pub(crate) fn borrow_mut(&self) -> RefMut<T> { self.value.borrow_mut() } @@ -131,7 +131,7 @@ impl<T> DomRefCell<T> { /// # Panics /// /// Panics if this is called off the script thread. - pub fn try_borrow(&self) -> Result<Ref<T>, BorrowError> { + pub(crate) fn try_borrow(&self) -> Result<Ref<T>, BorrowError> { assert_in_script(); self.value.try_borrow() } @@ -146,7 +146,7 @@ impl<T> DomRefCell<T> { /// # Panics /// /// Panics if this is called off the script thread. - pub fn try_borrow_mut(&self) -> Result<RefMut<T>, BorrowMutError> { + pub(crate) fn try_borrow_mut(&self) -> Result<RefMut<T>, BorrowMutError> { assert_in_script(); self.value.try_borrow_mut() } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 5236a8529a2..e9ee8617187 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2281,7 +2281,7 @@ class CGTemplatedType(CGWrapper): class CGNamespace(CGWrapper): def __init__(self, namespace, child, public=False): - pub = "pub " if public else "" + pub = "pub(crate) " if public else "" pre = f"{pub}mod {namespace} {{\n" post = f"}} // mod {namespace}" CGWrapper.__init__(self, child, pre=pre, post=post) @@ -2656,7 +2656,7 @@ def DomTypes(descriptors, descriptorProvider, dictionaries, callbacks, typedefs, "Sized", ] joinedTraits = ' + '.join(traits) - elements = [CGGeneric(f"pub trait DomTypes: {joinedTraits} where Self: 'static {{\n")] + elements = [CGGeneric(f"pub(crate) trait DomTypes: {joinedTraits} where Self: 'static {{\n")] for descriptor in descriptors: iface_name = descriptor.interface.identifier.name traits = [] @@ -2737,7 +2737,7 @@ def DomTypeHolder(descriptors, descriptorProvider, dictionaries, callbacks, type elements = [ CGGeneric( "#[derive(JSTraceable, MallocSizeOf, PartialEq)]\n" - "pub struct DomTypeHolder;\n" + "pub(crate) struct DomTypeHolder;\n" "impl crate::DomTypes for DomTypeHolder {\n" ), ] @@ -4882,7 +4882,7 @@ class CGEnum(CGThing): decl = f""" #[repr(usize)] #[derive({derives})] -pub enum {ident} {{ +pub(crate) enum {ident} {{ {enums} }} """ @@ -4900,12 +4900,12 @@ use js::rust::HandleValue; use js::rust::MutableHandleValue; use js::jsval::JSVal; -pub const pairs: &[(&str, super::{ident})] = &[ +pub(crate) const pairs: &[(&str, super::{ident})] = &[ {pairs}, ]; impl super::{ident} {{ - pub fn as_str(&self) -> &'static str {{ + pub(crate) fn as_str(&self) -> &'static str {{ pairs[*self as usize].0 }} }} @@ -4994,7 +4994,7 @@ class CGConstant(CGThing): elif tag == IDLType.Tags.double: const_type = "f64" - return f"pub const {name}: {const_type} = {value};\n" + return f"pub(crate) const {name}: {const_type} = {value};\n" def getUnionTypeTemplateVars(type, descriptorProvider): @@ -5093,7 +5093,7 @@ class CGUnionStruct(CGThing): derives = ["JSTraceable"] + self.derives return f""" #[derive({", ".join(derives)})] -pub enum {self.type} {{ +pub(crate) enum {self.type} {{ {joinedEnumValues} }} @@ -5468,7 +5468,7 @@ class ClassConstructor(ClassItem): body = f' {{\n{body}}}' return f""" -pub unsafe fn {self.getDecorators(True)}new({args}) -> Rc<{cgClass.getNameString()}>{body} +pub(crate) unsafe fn {self.getDecorators(True)}new({args}) -> Rc<{cgClass.getNameString()}>{body} """ def define(self, cgClass): @@ -5560,7 +5560,7 @@ class CGClass(CGThing): myself = '' if self.decorators != '': myself += f'{self.decorators}\n' - myself += f'{self.indent}pub struct {self.name}{specialization}' + myself += f'{self.indent}pub(crate) struct {self.name}{specialization}' result += myself assert len(self.bases) == 1 # XXjdm Can we support multiple inheritance? @@ -5568,7 +5568,7 @@ class CGClass(CGThing): result += ' {\n' if self.bases: - self.members = [ClassMember("parent", self.bases[0].name, "pub")] + self.members + self.members = [ClassMember("parent", self.bases[0].name, "pub(crate)")] + self.members result += CGIndenter(CGGeneric(self.extradeclarations), len(self.indent)).define() @@ -6628,8 +6628,9 @@ class CGInterfaceTrait(CGThing): methods.append(CGGeneric("fn Length(&self) -> u32;\n")) if methods: + name = descriptor.interface.identifier.name self.cgRoot = CGWrapper(CGIndenter(CGList(methods, "")), - pre=f"pub trait {descriptor.interface.identifier.name}Methods<D: DomTypes> {{\n", + pre=f"pub(crate) trait {name}Methods<D: DomTypes> {{\n", post="}") else: self.cgRoot = CGGeneric("") @@ -6950,7 +6951,8 @@ class CGDescriptor(CGThing): if reexports: reexports = ', '.join([reexportedName(name) for name in reexports]) - cgThings = CGList([CGGeneric(f'pub use self::{toBindingNamespace(descriptor.name)}::{{{reexports}}};'), + namespace = toBindingNamespace(descriptor.name) + cgThings = CGList([CGGeneric(f'pub(crate) use self::{namespace}::{{{reexports}}};'), cgThings], '\n') self.cgRoot = cgThings @@ -6972,7 +6974,7 @@ class CGNonNamespacedEnum(CGThing): # Build the enum body. joinedEntries = ',\n'.join(entries) - enumstr = f"{comment}pub enum {enumName} {{\n{joinedEntries}\n}}\n" + enumstr = f"{comment}pub(crate) enum {enumName} {{\n{joinedEntries}\n}}\n" if repr: enumstr = f"#[repr({repr})]\n{enumstr}" if deriving: @@ -7025,10 +7027,10 @@ class CGDictionary(CGThing): typeName = f"{self.makeModuleName(d.parent)}::{self.makeClassName(d.parent)}" if type_needs_tracing(d.parent): typeName = f"RootedTraceableBox<{typeName}>" - inheritance = f" pub parent: {typeName},\n" + inheritance = f" pub(crate) parent: {typeName},\n" else: inheritance = "" - memberDecls = [f" pub {self.makeMemberName(m[0].identifier.name)}: {self.getMemberType(m)}," + memberDecls = [f" pub(crate) {self.makeMemberName(m[0].identifier.name)}: {self.getMemberType(m)}," for m in self.memberInfo] derive = ["JSTraceable"] + self.derives @@ -7069,7 +7071,7 @@ class CGDictionary(CGThing): return ( f"#[derive({', '.join(derive)})]\n" f"{mustRoot}" - f"pub struct {self.makeClassName(d)} {{\n" + f"pub(crate) struct {self.makeClassName(d)} {{\n" f"{inheritance}" f"{joinedMemberDecls}\n" "}\n" @@ -7142,7 +7144,7 @@ class CGDictionary(CGThing): return ( f"impl {selfName} {{\n" f"{CGIndenter(CGGeneric(self.makeEmpty()), indentLevel=4).define()}\n" - " pub fn new(cx: SafeJSContext, val: HandleValue) \n" + " pub(crate) fn new(cx: SafeJSContext, val: HandleValue) \n" f" -> Result<ConversionResult<{actualType}>, ()> {{\n" f" {unsafe_if_necessary} {{\n" " let object = if val.get().is_null_or_undefined() {\n" @@ -7246,7 +7248,7 @@ class CGDictionary(CGThing): parentTemplate = "parent: %s::%s::empty(),\n" fieldTemplate = "%s: %s,\n" functionTemplate = ( - "pub fn empty() -> Self {\n" + "pub(crate) fn empty() -> Self {\n" " Self {\n" "%s" " }\n" @@ -7256,7 +7258,7 @@ class CGDictionary(CGThing): parentTemplate = "dictionary.parent = %s::%s::empty();\n" fieldTemplate = "dictionary.%s = %s;\n" functionTemplate = ( - "pub fn empty() -> RootedTraceableBox<Self> {\n" + "pub(crate) fn empty() -> RootedTraceableBox<Self> {\n" " let mut dictionary = RootedTraceableBox::new(Self::default());\n" "%s" " dictionary\n" @@ -7341,14 +7343,14 @@ class CGRegisterProxyHandlers(CGThing): def __init__(self, config): descriptors = config.getDescriptors(proxy=True) body = "".join( - f" pub static {desc.name}: std::sync::atomic::AtomicPtr<libc::c_void> =\n" + f" pub(crate) static {desc.name}: std::sync::atomic::AtomicPtr<libc::c_void> =\n" " std::sync::atomic::AtomicPtr::new(std::ptr::null_mut());\n" for desc in descriptors ) self.root = CGList([ CGGeneric( "#[allow(non_upper_case_globals)]\n" - "pub mod proxy_handlers {\n" + "pub(crate) mod proxy_handlers {\n" f"{body}}}\n" ), CGRegisterProxyHandlersMethod(descriptors), @@ -7400,9 +7402,9 @@ class CGBindingRoot(CGThing): if t.innerType.isUnion() and not t.innerType.nullable(): # Allow using the typedef's name for accessing variants. - typeDefinition = f"pub use self::{type} as {name};" + typeDefinition = f"pub(crate) use self::{type} as {name};" else: - typeDefinition = f"pub type {name} = {type};" + typeDefinition = f"pub(crate) type {name} = {type};" cgthings.append(CGGeneric(typeDefinition)) @@ -8207,7 +8209,6 @@ class GlobalGenRoots(): "crate::dom::bindings::codegen", "crate::script_runtime::JSContext", "js::rust::HandleObject", - "phf", ] imports = CGList([CGGeneric(f"use {mod};") for mod in mods], "\n") @@ -8220,7 +8221,7 @@ class GlobalGenRoots(): global_flags = CGWrapper(CGIndenter(CGList([ CGGeneric(f"const {args[0]} = {args[1]};") for args in flags - ], "\n")), pre="#[derive(Clone, Copy)]\npub struct Globals: u8 {\n", post="\n}") + ], "\n")), pre="#[derive(Clone, Copy)]\npub(crate) struct Globals: u8 {\n", post="\n}") globals_ = CGWrapper(CGIndenter(global_flags), pre="bitflags::bitflags! {\n", post="\n}") phf = CGGeneric("include!(concat!(env!(\"OUT_DIR\"), \"/InterfaceObjectMapPhf.rs\"));") @@ -8262,9 +8263,9 @@ class GlobalGenRoots(): return CGList([ CGGeneric(AUTOGENERATED_WARNING_COMMENT), - CGGeneric(f"pub const PROTO_OR_IFACE_LENGTH: usize = {len(protos) + len(constructors)};\n"), - CGGeneric(f"pub const MAX_PROTO_CHAIN_LENGTH: usize = {config.maxProtoChainLength};\n\n"), - CGGeneric("#[allow(clippy::enum_variant_names)]"), + CGGeneric(f"pub(crate) const PROTO_OR_IFACE_LENGTH: usize = {len(protos) + len(constructors)};\n"), + CGGeneric(f"pub(crate) const MAX_PROTO_CHAIN_LENGTH: usize = {config.maxProtoChainLength};\n\n"), + CGGeneric("#[allow(clippy::enum_variant_names, dead_code)]"), CGNonNamespacedEnum('ID', protos, 0, deriving="PartialEq, Copy, Clone", repr="u16"), CGNonNamespacedEnum('Constructor', constructors, len(protos), deriving="PartialEq, Copy, Clone", repr="u16"), @@ -8273,7 +8274,7 @@ class GlobalGenRoots(): indentLevel=4), pre=f"static INTERFACES: [&str; {len(protos)}] = [\n", post="\n];\n\n"), - CGGeneric("pub fn proto_id_to_name(proto_id: u16) -> &'static str {\n" + CGGeneric("pub(crate) fn proto_id_to_name(proto_id: u16) -> &'static str {\n" " debug_assert!(proto_id < ID::Last as u16);\n" " INTERFACES[proto_id as usize]\n" "}\n\n"), @@ -8296,7 +8297,7 @@ class GlobalGenRoots(): for d in config.getDescriptors(register=True, isCallback=False, isIteratorInterface=False)]) - curr = CGList([CGGeneric(f"pub use crate::dom::{name.lower()}::{MakeNativeName(name)};\n") + curr = CGList([CGGeneric(f"pub(crate) use crate::dom::{name.lower()}::{MakeNativeName(name)};\n") for name in descriptors]) curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) return curr @@ -8313,7 +8314,7 @@ class GlobalGenRoots(): | set(leafModule(d) for d in config.getDictionaries())) curr = CGList([CGGeneric( "#[allow(clippy::derivable_impls)]\n" - f"pub mod {name};\n" + f"pub(crate) mod {name};\n" ) for name in sorted(descriptors)]) curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT) return curr @@ -8360,17 +8361,17 @@ class GlobalGenRoots(): typeIdCode = [] topTypeVariants = [ - ("ID used by abstract interfaces.", "pub abstract_: ()"), - ("ID used by interfaces that are not castable.", "pub alone: ()"), + ("ID used by abstract interfaces.", "pub(crate) abstract_: ()"), + ("ID used by interfaces that are not castable.", "pub(crate) alone: ()"), ] topTypeVariants += [ (f"ID used by interfaces that derive from {typeName}.", - f"pub {typeName.lower()}: {typeName}TypeId") + f"pub(crate) {typeName.lower()}: {typeName}TypeId") for typeName in topTypes ] topTypeVariantsAsStrings = [CGGeneric(f"/// {variant[0]}\n{variant[1]},") for variant in topTypeVariants] typeIdCode.append(CGWrapper(CGIndenter(CGList(topTypeVariantsAsStrings, "\n"), 4), - pre="#[derive(Copy)]\npub union TopTypeId {\n", + pre="#[derive(Copy)]\npub(crate) union TopTypeId {\n", post="\n}\n\n")) typeIdCode.append(CGGeneric("""\ @@ -8393,12 +8394,12 @@ impl Clone for TopTypeId { variants += [CGGeneric(type_id_variant(derivedName)) for derivedName in derived] derives = "Clone, Copy, Debug, PartialEq" typeIdCode.append(CGWrapper(CGIndenter(CGList(variants, ",\n"), 4), - pre=f"#[derive({derives})]\npub enum {base}TypeId {{\n", + pre=f"#[derive({derives})]\npub(crate) enum {base}TypeId {{\n", post="\n}\n\n")) if base in topTypes: typeIdCode.append(CGGeneric(f""" impl {base} {{ - pub fn type_id(&self) -> &'static {base}TypeId {{ + pub(crate) fn type_id(&self) -> &'static {base}TypeId {{ unsafe {{ &get_dom_class(self.reflector().get_jsobject().get()) .unwrap() diff --git a/components/script/dom/bindings/constant.rs b/components/script/dom/bindings/constant.rs index ced01176aea..7364ee2086d 100644 --- a/components/script/dom/bindings/constant.rs +++ b/components/script/dom/bindings/constant.rs @@ -15,17 +15,17 @@ use crate::script_runtime::JSContext; /// Representation of an IDL constant. #[derive(Clone)] -pub struct ConstantSpec { +pub(crate) struct ConstantSpec { /// name of the constant. - pub name: &'static CStr, + pub(crate) name: &'static CStr, /// value of the constant. - pub value: ConstantVal, + pub(crate) value: ConstantVal, } /// Representation of an IDL constant value. #[derive(Clone)] #[allow(dead_code)] -pub enum ConstantVal { +pub(crate) enum ConstantVal { /// `long` constant. Int(i32), /// `unsigned long` constant. @@ -40,7 +40,7 @@ pub enum ConstantVal { impl ConstantSpec { /// Returns a `JSVal` that represents the value of this `ConstantSpec`. - pub fn get_value(&self) -> JSVal { + pub(crate) fn get_value(&self) -> JSVal { match self.value { ConstantVal::Null => NullValue(), ConstantVal::Int(i) => Int32Value(i), @@ -53,7 +53,7 @@ impl ConstantSpec { /// Defines constants on `obj`. /// Fails on JSAPI failure. -pub fn define_constants(cx: JSContext, obj: HandleObject, constants: &[ConstantSpec]) { +pub(crate) fn define_constants(cx: JSContext, obj: HandleObject, constants: &[ConstantSpec]) { for spec in constants { rooted!(in(*cx) let value = spec.get_value()); unsafe { diff --git a/components/script/dom/bindings/constructor.rs b/components/script/dom/bindings/constructor.rs index f5ba6b8c2c7..891145a342f 100644 --- a/components/script/dom/bindings/constructor.rs +++ b/components/script/dom/bindings/constructor.rs @@ -226,7 +226,7 @@ unsafe fn html_constructor( /// given local name. This list should only include elements marked with the /// [HTMLConstructor](https://html.spec.whatwg.org/multipage/#htmlconstructor) /// extended attribute. -pub fn get_constructor_object_from_local_name( +pub(crate) fn get_constructor_object_from_local_name( name: LocalName, cx: JSContext, global: HandleObject, @@ -370,15 +370,15 @@ pub fn get_constructor_object_from_local_name( } } -pub fn pop_current_element_queue(can_gc: CanGc) { +pub(crate) fn pop_current_element_queue(can_gc: CanGc) { ScriptThread::pop_current_element_queue(can_gc); } -pub fn push_new_element_queue() { +pub(crate) fn push_new_element_queue() { ScriptThread::push_new_element_queue(); } -pub unsafe fn call_html_constructor<T: DerivedFrom<Element> + DomObject>( +pub(crate) unsafe fn call_html_constructor<T: DerivedFrom<Element> + DomObject>( cx: JSContext, args: &CallArgs, global: &GlobalScope, @@ -402,7 +402,7 @@ pub unsafe fn call_html_constructor<T: DerivedFrom<Element> + DomObject>( .is_ok() } -pub unsafe fn call_default_constructor( +pub(crate) unsafe fn call_default_constructor( cx: JSContext, args: &CallArgs, global: &GlobalScope, diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index df29575b2e6..33707ae75fb 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -35,7 +35,7 @@ use std::{char, ffi, ptr, slice}; use js::conversions::latin1_to_string; -pub use js::conversions::{ +pub(crate) use js::conversions::{ ConversionBehavior, ConversionResult, FromJSValConvertible, ToJSValConvertible, }; use js::error::throw_type_error; @@ -70,13 +70,13 @@ use crate::dom::nodelist::NodeList; use crate::dom::windowproxy::WindowProxy; /// A trait to check whether a given `JSObject` implements an IDL interface. -pub trait IDLInterface { +pub(crate) trait IDLInterface { /// Returns whether the given DOM class derives that interface. fn derives(_: &'static DOMClass) -> bool; } /// A trait to mark an IDL interface as deriving from another one. -pub trait DerivedFrom<T: Castable>: Castable {} +pub(crate) trait DerivedFrom<T: Castable>: Castable {} impl<T: Float + ToJSValConvertible> ToJSValConvertible for Finite<T> { #[inline] @@ -160,7 +160,7 @@ where /// integer. /// /// Handling of invalid UTF-16 in strings depends on the relevant option. -pub unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> { +pub(crate) unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> { let id_raw = *id; if id_raw.is_string() { let jsstr = std::ptr::NonNull::new(id_raw.to_string()).unwrap(); @@ -221,7 +221,7 @@ impl FromJSValConvertible for DOMString { /// Convert the given `JSString` to a `DOMString`. Fails if the string does not /// contain valid UTF-16. -pub unsafe fn jsstring_to_str(cx: *mut JSContext, s: ptr::NonNull<JSString>) -> DOMString { +pub(crate) unsafe fn jsstring_to_str(cx: *mut JSContext, s: ptr::NonNull<JSString>) -> DOMString { let latin1 = JS_DeprecatedStringHasLatin1Chars(s.as_ptr()); DOMString::from_string(if latin1 { latin1_to_string(cx, s.as_ptr()) @@ -355,7 +355,7 @@ impl ToJSValConvertible for Reflector { } /// Returns whether `obj` is a DOM object implemented as a proxy. -pub fn is_dom_proxy(obj: *mut JSObject) -> bool { +pub(crate) fn is_dom_proxy(obj: *mut JSObject) -> bool { use js::glue::IsProxyHandlerFamily; unsafe { let clasp = get_object_class(obj); @@ -367,10 +367,10 @@ pub fn is_dom_proxy(obj: *mut JSObject) -> bool { /// stored for non-proxy bindings. // We use slot 0 for holding the raw object. This is safe for both // globals and non-globals. -pub const DOM_OBJECT_SLOT: u32 = 0; +pub(crate) const DOM_OBJECT_SLOT: u32 = 0; /// Get the private pointer of a DOM object from a given reflector. -pub unsafe fn private_from_object(obj: *mut JSObject) -> *const libc::c_void { +pub(crate) unsafe fn private_from_object(obj: *mut JSObject) -> *const libc::c_void { let mut value = UndefinedValue(); if is_dom_object(obj) { JS_GetReservedSlot(obj, DOM_OBJECT_SLOT, &mut value); @@ -386,7 +386,7 @@ pub unsafe fn private_from_object(obj: *mut JSObject) -> *const libc::c_void { } /// Get the `DOMClass` from `obj`, or `Err(())` if `obj` is not a DOM object. -pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<&'static DOMClass, ()> { +pub(crate) unsafe fn get_dom_class(obj: *mut JSObject) -> Result<&'static DOMClass, ()> { use js::glue::GetProxyHandlerExtra; use crate::dom::bindings::utils::DOMJSClass; @@ -478,7 +478,7 @@ unsafe fn private_from_proto_check_static( } /// Get a `*const T` for a DOM object accessible from a `JSObject`. -pub fn native_from_object<T>(obj: *mut JSObject, cx: *mut JSContext) -> Result<*const T, ()> +pub(crate) fn native_from_object<T>(obj: *mut JSObject, cx: *mut JSContext) -> Result<*const T, ()> where T: DomObject + IDLInterface, { @@ -490,7 +490,7 @@ where /// Get a `*const T` for a DOM object accessible from a `JSObject`, where the DOM object /// is guaranteed not to be a wrapper. -pub fn native_from_object_static<T>(obj: *mut JSObject) -> Result<*const T, ()> +pub(crate) fn native_from_object_static<T>(obj: *mut JSObject) -> Result<*const T, ()> where T: DomObject + IDLInterface, { @@ -503,7 +503,7 @@ where /// Returns Err(()) if `obj` is an opaque security wrapper or if the object is /// not a reflector for a DOM object of the given type (as defined by the /// proto_id and proto_depth). -pub fn root_from_object<T>(obj: *mut JSObject, cx: *mut JSContext) -> Result<DomRoot<T>, ()> +pub(crate) fn root_from_object<T>(obj: *mut JSObject, cx: *mut JSContext) -> Result<DomRoot<T>, ()> where T: DomObject + IDLInterface, { @@ -516,7 +516,7 @@ where /// Returns Err(()) if `obj` is an opaque security wrapper or if the object is /// not a reflector for a DOM object of the given type (as defined by the /// proto_id and proto_depth). -pub fn root_from_object_static<T>(obj: *mut JSObject) -> Result<DomRoot<T>, ()> +pub(crate) fn root_from_object_static<T>(obj: *mut JSObject) -> Result<DomRoot<T>, ()> where T: DomObject + IDLInterface, { @@ -525,7 +525,7 @@ where /// Get a `*const T` for a DOM object accessible from a `HandleValue`. /// Caller is responsible for throwing a JS exception if needed in case of error. -pub fn native_from_handlevalue<T>(v: HandleValue, cx: *mut JSContext) -> Result<*const T, ()> +pub(crate) fn native_from_handlevalue<T>(v: HandleValue, cx: *mut JSContext) -> Result<*const T, ()> where T: DomObject + IDLInterface, { @@ -537,7 +537,7 @@ where /// Get a `DomRoot<T>` for a DOM object accessible from a `HandleValue`. /// Caller is responsible for throwing a JS exception if needed in case of error. -pub fn root_from_handlevalue<T>(v: HandleValue, cx: *mut JSContext) -> Result<DomRoot<T>, ()> +pub(crate) fn root_from_handlevalue<T>(v: HandleValue, cx: *mut JSContext) -> Result<DomRoot<T>, ()> where T: DomObject + IDLInterface, { @@ -548,7 +548,10 @@ where } /// Get a `DomRoot<T>` for a DOM object accessible from a `HandleObject`. -pub fn root_from_handleobject<T>(obj: HandleObject, cx: *mut JSContext) -> Result<DomRoot<T>, ()> +pub(crate) fn root_from_handleobject<T>( + obj: HandleObject, + cx: *mut JSContext, +) -> Result<DomRoot<T>, ()> where T: DomObject + IDLInterface, { @@ -564,7 +567,7 @@ impl<T: DomObject> ToJSValConvertible for DomRoot<T> { /// Returns whether `value` is an array-like object (Array, FileList, /// HTMLCollection, HTMLFormControlsCollection, HTMLOptionsCollection, /// NodeList). -pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool { +pub(crate) unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool { let mut is_array = false; assert!(IsArrayObject(cx, value, &mut is_array)); if is_array { @@ -596,7 +599,7 @@ pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool { } /// Get a property from a JS object. -pub unsafe fn get_property_jsval( +pub(crate) unsafe fn get_property_jsval( cx: *mut JSContext, object: HandleObject, name: &str, @@ -622,7 +625,7 @@ pub unsafe fn get_property_jsval( } /// Get a property from a JS object, and convert it to a Rust value. -pub unsafe fn get_property<T>( +pub(crate) unsafe fn get_property<T>( cx: *mut JSContext, object: HandleObject, name: &str, @@ -648,7 +651,7 @@ where /// Get a `DomRoot<T>` for a WindowProxy accessible from a `HandleValue`. /// Caller is responsible for throwing a JS exception if needed in case of error. -pub unsafe fn windowproxy_from_handlevalue( +pub(crate) unsafe fn windowproxy_from_handlevalue( v: HandleValue, _cx: *mut JSContext, ) -> Result<DomRoot<WindowProxy>, ()> { diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index d2c0b534f3b..f7efb14b694 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -40,7 +40,7 @@ thread_local! { /// DOM exceptions that can be thrown by a native DOM method. #[derive(Clone, Debug, MallocSizeOf)] -pub enum Error { +pub(crate) enum Error { /// IndexSizeError DOMException IndexSize, /// NotFoundError DOMException @@ -100,14 +100,14 @@ pub enum Error { } /// The return type for IDL operations that can throw DOM exceptions. -pub type Fallible<T> = Result<T, Error>; +pub(crate) type Fallible<T> = Result<T, Error>; /// The return type for IDL operations that can throw DOM exceptions and /// return `()`. -pub type ErrorResult = Fallible<()>; +pub(crate) type ErrorResult = Fallible<()>; /// Set a pending exception for the given `result` on `cx`. -pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) { +pub(crate) fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) { #[cfg(feature = "js_backtrace")] unsafe { capture_stack!(in(*cx) let stack); @@ -170,15 +170,15 @@ pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Erro /// A struct encapsulating information about a runtime script error. #[derive(Default)] -pub struct ErrorInfo { +pub(crate) struct ErrorInfo { /// The error message. - pub message: String, + pub(crate) message: String, /// The file name. - pub filename: String, + pub(crate) filename: String, /// The line number. - pub lineno: c_uint, + pub(crate) lineno: c_uint, /// The column number. - pub column: c_uint, + pub(crate) column: c_uint, } impl ErrorInfo { @@ -267,7 +267,7 @@ impl ErrorInfo { /// /// The `dispatch_event` argument is temporary and non-standard; passing false /// prevents dispatching the `error` event. -pub unsafe fn report_pending_exception( +pub(crate) unsafe fn report_pending_exception( cx: *mut JSContext, dispatch_event: bool, realm: InRealm, @@ -310,7 +310,7 @@ pub unsafe fn report_pending_exception( /// Throw an exception to signal that a `JSObject` can not be converted to a /// given DOM type. -pub unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) { +pub(crate) unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) { debug_assert!(!JS_IsExceptionPending(cx)); let error = format!( "\"this\" object does not implement interface {}.", @@ -319,7 +319,7 @@ pub unsafe fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) { throw_type_error(cx, &error); } -pub unsafe fn throw_constructor_without_new(cx: *mut JSContext, name: &str) { +pub(crate) unsafe fn throw_constructor_without_new(cx: *mut JSContext, name: &str) { debug_assert!(!JS_IsExceptionPending(cx)); let error = format!("{} constructor: 'new' is required", name); throw_type_error(cx, &error); @@ -328,7 +328,7 @@ pub unsafe fn throw_constructor_without_new(cx: *mut JSContext, name: &str) { impl Error { /// Convert this error value to a JS value, consuming it in the process. #[allow(clippy::wrong_self_convention)] - pub unsafe fn to_jsval( + pub(crate) unsafe fn to_jsval( self, cx: *mut JSContext, global: &GlobalScope, diff --git a/components/script/dom/bindings/finalize.rs b/components/script/dom/bindings/finalize.rs index 2a1ff930fac..dd379431af3 100644 --- a/components/script/dom/bindings/finalize.rs +++ b/components/script/dom/bindings/finalize.rs @@ -14,7 +14,7 @@ use js::jsval::UndefinedValue; use crate::dom::bindings::utils::finalize_global as do_finalize_global; use crate::dom::bindings::weakref::{WeakBox, WeakReferenceable, DOM_WEAK_SLOT}; -pub unsafe fn finalize_common<T>(this: *const T) { +pub(crate) unsafe fn finalize_common<T>(this: *const T) { if !this.is_null() { // The pointer can be null if the object is the unforgeable holder of that interface. let _ = Box::from_raw(this as *mut T); @@ -22,12 +22,12 @@ pub unsafe fn finalize_common<T>(this: *const T) { debug!("{} finalize: {:p}", type_name::<T>(), this); } -pub unsafe fn finalize_global<T>(obj: *mut JSObject, this: *const T) { +pub(crate) unsafe fn finalize_global<T>(obj: *mut JSObject, this: *const T) { do_finalize_global(obj); finalize_common::<T>(this); } -pub unsafe fn finalize_weak_referenceable<T: WeakReferenceable>( +pub(crate) unsafe fn finalize_weak_referenceable<T: WeakReferenceable>( obj: *mut JSObject, this: *const T, ) { diff --git a/components/script/dom/bindings/frozenarray.rs b/components/script/dom/bindings/frozenarray.rs index 5f2e6e395ad..44cc0bd4085 100644 --- a/components/script/dom/bindings/frozenarray.rs +++ b/components/script/dom/bindings/frozenarray.rs @@ -12,18 +12,18 @@ use crate::dom::bindings::utils::to_frozen_array; use crate::script_runtime::JSContext; #[derive(JSTraceable)] -pub struct CachedFrozenArray { +pub(crate) struct CachedFrozenArray { frozen_value: DomRefCell<Option<Heap<JSVal>>>, } impl CachedFrozenArray { - pub fn new() -> CachedFrozenArray { + pub(crate) fn new() -> CachedFrozenArray { CachedFrozenArray { frozen_value: DomRefCell::new(None), } } - pub fn get_or_init<F: FnOnce() -> Vec<T>, T: ToJSValConvertible>( + pub(crate) fn get_or_init<F: FnOnce() -> Vec<T>, T: ToJSValConvertible>( &self, f: F, cx: JSContext, @@ -46,7 +46,7 @@ impl CachedFrozenArray { .set(retval.get()); } - pub fn clear(&self) { + pub(crate) fn clear(&self) { *self.frozen_value.borrow_mut() = None; } } diff --git a/components/script/dom/bindings/guard.rs b/components/script/dom/bindings/guard.rs index 883d3067214..45e4473d821 100644 --- a/components/script/dom/bindings/guard.rs +++ b/components/script/dom/bindings/guard.rs @@ -14,21 +14,26 @@ use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext; /// A container with a list of conditions. -pub struct Guard<T: Clone + Copy> { +pub(crate) struct Guard<T: Clone + Copy> { conditions: &'static [Condition], value: T, } impl<T: Clone + Copy> Guard<T> { /// Construct a new guarded value. - pub const fn new(conditions: &'static [Condition], value: T) -> Self { + pub(crate) const fn new(conditions: &'static [Condition], value: T) -> Self { Guard { conditions, value } } /// Expose the value if the conditions are satisfied. /// /// The passed handle is the object on which the value may be exposed. - pub fn expose(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> Option<T> { + pub(crate) fn expose( + &self, + cx: JSContext, + obj: HandleObject, + global: HandleObject, + ) -> Option<T> { let mut exposed_on_global = false; let conditions_satisfied = self.conditions.iter().all(|c| match c { Condition::Satisfied => { @@ -53,7 +58,7 @@ impl<T: Clone + Copy> Guard<T> { /// A condition to expose things. #[derive(Clone, Copy)] -pub enum Condition { +pub(crate) enum Condition { /// The condition is satisfied if the function returns true. Func(fn(JSContext, HandleObject) -> bool), /// The condition is satisfied if the preference is set. @@ -73,7 +78,12 @@ fn is_secure_context(cx: JSContext) -> bool { } impl Condition { - pub fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool { + pub(crate) fn is_satisfied( + &self, + cx: JSContext, + obj: HandleObject, + global: HandleObject, + ) -> bool { match *self { Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false), Condition::Func(f) => f(cx, obj), diff --git a/components/script/dom/bindings/import.rs b/components/script/dom/bindings/import.rs index c4586b43905..b4337419a6e 100644 --- a/components/script/dom/bindings/import.rs +++ b/components/script/dom/bindings/import.rs @@ -3,60 +3,60 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #[allow(unused_imports)] -pub mod base { - pub use std::ptr; - pub use std::rc::Rc; +pub(crate) mod base { + pub(crate) use std::ptr; + pub(crate) use std::rc::Rc; - pub use js::error::throw_type_error; - pub use js::jsapi::{ + pub(crate) use js::error::throw_type_error; + pub(crate) use js::jsapi::{ CurrentGlobalOrNull, HandleValue as RawHandleValue, HandleValueArray, Heap, IsCallable, JSContext, JSObject, JS_NewObject, }; - pub use js::jsval::{JSVal, NullValue, ObjectOrNullValue, ObjectValue, UndefinedValue}; - pub use js::panic::maybe_resume_unwind; - pub use js::rust::wrappers::{JS_CallFunctionValue, JS_WrapValue}; - pub use js::rust::{HandleObject, HandleValue, MutableHandleObject, MutableHandleValue}; + pub(crate) use js::jsval::{JSVal, NullValue, ObjectOrNullValue, ObjectValue, UndefinedValue}; + pub(crate) use js::panic::maybe_resume_unwind; + pub(crate) use js::rust::wrappers::{JS_CallFunctionValue, JS_WrapValue}; + pub(crate) use js::rust::{HandleObject, HandleValue, MutableHandleObject, MutableHandleValue}; - pub use crate::dom::bindings::callback::{ + pub(crate) use crate::dom::bindings::callback::{ wrap_call_this_object, CallSetup, CallbackContainer, CallbackFunction, CallbackInterface, CallbackObject, ExceptionHandling, ThisReflector, }; - pub use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ + pub(crate) use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ ChannelCountMode, ChannelCountModeValues, ChannelInterpretation, ChannelInterpretationValues, }; - pub use crate::dom::bindings::codegen::DomTypes::DomTypes; - pub use crate::dom::bindings::codegen::UnionTypes; - pub use crate::dom::bindings::conversions::{ + pub(crate) use crate::dom::bindings::codegen::DomTypes::DomTypes; + pub(crate) use crate::dom::bindings::codegen::UnionTypes; + pub(crate) use crate::dom::bindings::conversions::{ root_from_handlevalue, ConversionBehavior, ConversionResult, FromJSValConvertible, StringificationBehavior, ToJSValConvertible, }; - pub use crate::dom::bindings::error::Error::JSFailed; - pub use crate::dom::bindings::error::{throw_dom_exception, Fallible}; - pub use crate::dom::bindings::num::Finite; - pub use crate::dom::bindings::proxyhandler::CrossOriginProperties; - pub use crate::dom::bindings::reflector::DomObject; - pub use crate::dom::bindings::root::DomRoot; - pub use crate::dom::bindings::str::{ByteString, DOMString, USVString}; - pub use crate::dom::bindings::trace::RootedTraceableBox; - pub use crate::dom::bindings::utils::{ + pub(crate) use crate::dom::bindings::error::Error::JSFailed; + pub(crate) use crate::dom::bindings::error::{throw_dom_exception, Fallible}; + pub(crate) use crate::dom::bindings::num::Finite; + pub(crate) use crate::dom::bindings::proxyhandler::CrossOriginProperties; + pub(crate) use crate::dom::bindings::reflector::DomObject; + pub(crate) use crate::dom::bindings::root::DomRoot; + pub(crate) use crate::dom::bindings::str::{ByteString, DOMString, USVString}; + pub(crate) use crate::dom::bindings::trace::RootedTraceableBox; + pub(crate) use crate::dom::bindings::utils::{ get_dictionary_property, set_dictionary_property, ThreadUnsafeOnceLock, }; - pub use crate::dom::globalscope::GlobalScope; - pub use crate::script_runtime::JSContext as SafeJSContext; + pub(crate) use crate::dom::globalscope::GlobalScope; + pub(crate) use crate::script_runtime::JSContext as SafeJSContext; } #[allow(unused_imports)] -pub mod module { - pub use std::cmp; - pub use std::ffi::CString; - pub use std::ptr::NonNull; +pub(crate) mod module { + pub(crate) use std::cmp; + pub(crate) use std::ffi::CString; + pub(crate) use std::ptr::NonNull; - pub use js::glue::{ + pub(crate) use js::glue::{ CreateProxyHandler, GetProxyReservedSlot, JS_GetReservedSlot, ProxyTraps, SetProxyReservedSlot, }; - pub use js::jsapi::{ + pub(crate) use js::jsapi::{ JSJitInfo_OpType, JSJitInfo__bindgen_ty_1, JSJitInfo__bindgen_ty_2, JSJitInfo__bindgen_ty_3, JSJitMethodCallArgs, JSJitSetterCallArgs, JSNativeWrapper, JSPropertySpec, JSPropertySpec_Accessor, JSPropertySpec_AccessorsOrValue, @@ -76,79 +76,87 @@ pub mod module { JSCLASS_FOREGROUND_FINALIZE, JSCLASS_RESERVED_SLOTS_SHIFT, JSITER_HIDDEN, JSITER_OWNONLY, JSITER_SYMBOLS, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY, }; - pub use js::jsval::PrivateValue; - pub use js::panic::wrap_panic; - pub use js::rust::wrappers::{ + pub(crate) use js::jsval::PrivateValue; + pub(crate) use js::panic::wrap_panic; + pub(crate) use js::rust::wrappers::{ int_to_jsid, AppendToIdVector, Call, GetPropertyKeys, JS_CopyOwnPropertiesAndPrivateFields, JS_DefineProperty, JS_DefinePropertyById2, JS_GetProperty, JS_InitializePropertiesFromCompatibleNativeObject, JS_NewObjectWithGivenProto, JS_NewObjectWithoutMetadata, JS_SetImmutablePrototype, JS_SetProperty, JS_SetPrototype, JS_WrapObject, NewProxyObject, RUST_INTERNED_STRING_TO_JSID, RUST_SYMBOL_TO_JSID, }; - pub use js::rust::{ + pub(crate) use js::rust::{ get_context_realm, get_object_class, get_object_realm, CustomAutoRooterGuard, GCMethods, Handle, MutableHandle, }; - pub use js::typedarray::{ + pub(crate) use js::typedarray::{ ArrayBuffer, ArrayBufferView, Float32Array, Float64Array, Uint8Array, Uint8ClampedArray, }; - pub use js::{ + pub(crate) use js::{ jsapi, typedarray, JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_MASK, JS_CALLEE, }; - pub use servo_config::pref; + pub(crate) use servo_config::pref; - pub use super::base::*; - pub use crate::dom::bindings::codegen::Bindings::AnalyserNodeBinding::AnalyserOptions; - pub use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ + pub(crate) use super::base::*; + pub(crate) use crate::dom::bindings::codegen::Bindings::AnalyserNodeBinding::AnalyserOptions; + pub(crate) use crate::dom::bindings::codegen::Bindings::AudioNodeBinding::{ AudioNode_Binding, ChannelCountMode, ChannelCountModeValues, ChannelInterpretation, ChannelInterpretationValues, }; - pub use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTarget_Binding; - pub use crate::dom::bindings::codegen::{InterfaceObjectMap, PrototypeList, RegisterBindings}; - pub use crate::dom::bindings::constant::{ConstantSpec, ConstantVal}; - pub use crate::dom::bindings::constructor::{ + pub(crate) use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTarget_Binding; + pub(crate) use crate::dom::bindings::codegen::{ + InterfaceObjectMap, PrototypeList, RegisterBindings, + }; + pub(crate) use crate::dom::bindings::constant::{ConstantSpec, ConstantVal}; + pub(crate) use crate::dom::bindings::constructor::{ call_default_constructor, call_html_constructor, pop_current_element_queue, push_new_element_queue, }; - pub use crate::dom::bindings::conversions::{ + pub(crate) use crate::dom::bindings::conversions::{ is_array_like, jsid_to_string, native_from_handlevalue, native_from_object_static, IDLInterface, StringificationBehavior, ToJSValConvertible, DOM_OBJECT_SLOT, }; - pub use crate::dom::bindings::error::{throw_constructor_without_new, Error, ErrorResult}; - pub use crate::dom::bindings::finalize::{ + pub(crate) use crate::dom::bindings::error::{ + throw_constructor_without_new, Error, ErrorResult, + }; + pub(crate) use crate::dom::bindings::finalize::{ finalize_common, finalize_global, finalize_weak_referenceable, }; - pub use crate::dom::bindings::guard::{Condition, Guard}; - pub use crate::dom::bindings::inheritance::Castable; - pub use crate::dom::bindings::interface::{ + pub(crate) use crate::dom::bindings::guard::{Condition, Guard}; + pub(crate) use crate::dom::bindings::inheritance::Castable; + pub(crate) use crate::dom::bindings::interface::{ create_callback_interface_object, create_global_object, create_interface_prototype_object, create_named_constructors, create_noncallback_interface_object, define_dom_interface, define_guarded_methods, define_guarded_properties, get_desired_proto, get_per_interface_object_handle, is_exposed_in, ConstructorClassHook, InterfaceConstructorBehavior, NonCallbackInterfaceObjectClass, ProtoOrIfaceIndex, }; - pub use crate::dom::bindings::iterable::{Iterable, IteratorType}; - pub use crate::dom::bindings::like::{Maplike, Setlike}; - pub use crate::dom::bindings::namespace::{create_namespace_object, NamespaceObjectClass}; - pub use crate::dom::bindings::proxyhandler; - pub use crate::dom::bindings::proxyhandler::{ + pub(crate) use crate::dom::bindings::iterable::{Iterable, IteratorType}; + pub(crate) use crate::dom::bindings::like::{Maplike, Setlike}; + pub(crate) use crate::dom::bindings::namespace::{ + create_namespace_object, NamespaceObjectClass, + }; + pub(crate) use crate::dom::bindings::proxyhandler; + pub(crate) use crate::dom::bindings::proxyhandler::{ ensure_expando_object, get_expando_object, set_property_descriptor, }; - pub use crate::dom::bindings::record::Record; - pub use crate::dom::bindings::reflector::{DomObjectIteratorWrap, DomObjectWrap, Reflector}; - pub use crate::dom::bindings::root::{Dom, DomSlice, MaybeUnreflectedDom, Root}; - pub use crate::dom::bindings::trace::JSTraceable; - pub use crate::dom::bindings::utils::{ + pub(crate) use crate::dom::bindings::record::Record; + pub(crate) use crate::dom::bindings::reflector::{ + DomObjectIteratorWrap, DomObjectWrap, Reflector, + }; + pub(crate) use crate::dom::bindings::root::{Dom, DomSlice, MaybeUnreflectedDom, Root}; + pub(crate) use crate::dom::bindings::trace::JSTraceable; + pub(crate) use crate::dom::bindings::utils::{ enumerate_global, exception_to_promise, generic_getter, generic_lenient_getter, generic_lenient_setter, generic_method, generic_setter, generic_static_promise_method, get_array_index_from_id, get_property_on_prototype, has_property_on_prototype, resolve_global, trace_global, AsVoidPtr, DOMClass, DOMJSClass, ProtoOrIfaceArray, DOM_PROTO_UNFORGEABLE_HOLDER_SLOT, JSCLASS_DOM_GLOBAL, }; - pub use crate::dom::bindings::weakref::{WeakReferenceable, DOM_WEAK_SLOT}; - pub use crate::dom::types::{AnalyserNode, AudioNode, BaseAudioContext, EventTarget}; - pub use crate::mem::malloc_size_of_including_raw_self; - pub use crate::realms::{AlreadyInRealm, InRealm}; - pub use crate::script_runtime::CanGc; + pub(crate) use crate::dom::bindings::weakref::{WeakReferenceable, DOM_WEAK_SLOT}; + pub(crate) use crate::dom::types::{AnalyserNode, AudioNode, BaseAudioContext, EventTarget}; + pub(crate) use crate::mem::malloc_size_of_including_raw_self; + pub(crate) use crate::realms::{AlreadyInRealm, InRealm}; + pub(crate) use crate::script_runtime::CanGc; } diff --git a/components/script/dom/bindings/inheritance.rs b/components/script/dom/bindings/inheritance.rs index f580aaf61b5..7c5ca4f7a27 100644 --- a/components/script/dom/bindings/inheritance.rs +++ b/components/script/dom/bindings/inheritance.rs @@ -6,14 +6,14 @@ use std::mem; -pub use crate::dom::bindings::codegen::InheritTypes::*; +pub(crate) use crate::dom::bindings::codegen::InheritTypes::*; use crate::dom::bindings::conversions::{get_dom_class, DerivedFrom, IDLInterface}; use crate::dom::bindings::reflector::DomObject; use crate::script_runtime::runtime_is_alive; /// A trait to hold the cast functions of IDL interfaces that either derive /// or are derived from other interfaces. -pub trait Castable: IDLInterface + DomObject + Sized { +pub(crate) trait Castable: IDLInterface + DomObject + Sized { /// Check whether a DOM object implements one of its deriving interfaces. fn is<T>(&self) -> bool where @@ -54,7 +54,7 @@ pub trait Castable: IDLInterface + DomObject + Sized { } #[allow(missing_docs)] -pub trait HasParent { +pub(crate) trait HasParent { #[crown::unrooted_must_root_lint::must_root] type Parent; fn as_parent(&self) -> &Self::Parent; diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs index bf2fc6faa87..168abfc1503 100644 --- a/components/script/dom/bindings/interface.rs +++ b/components/script/dom/bindings/interface.rs @@ -46,22 +46,22 @@ use crate::script_runtime::JSContext as SafeJSContext; /// The class of a non-callback interface object. #[derive(Clone, Copy)] -pub struct NonCallbackInterfaceObjectClass { +pub(crate) struct NonCallbackInterfaceObjectClass { /// The SpiderMonkey class structure. - pub _class: JSClass, + pub(crate) _class: JSClass, /// The prototype id of that interface, used in the hasInstance hook. - pub _proto_id: PrototypeList::ID, + pub(crate) _proto_id: PrototypeList::ID, /// The prototype depth of that interface, used in the hasInstance hook. - pub _proto_depth: u16, + pub(crate) _proto_depth: u16, /// The string representation of the object. - pub representation: &'static [u8], + pub(crate) representation: &'static [u8], } unsafe impl Sync for NonCallbackInterfaceObjectClass {} impl NonCallbackInterfaceObjectClass { /// Create a new `NonCallbackInterfaceObjectClass` structure. - pub const fn new( + pub(crate) const fn new( constructor_behavior: &'static InterfaceConstructorBehavior, string_rep: &'static [u8], proto_id: PrototypeList::ID, @@ -83,21 +83,21 @@ impl NonCallbackInterfaceObjectClass { } /// cast own reference to `JSClass` reference - pub fn as_jsclass(&self) -> &JSClass { + pub(crate) fn as_jsclass(&self) -> &JSClass { unsafe { &*(self as *const _ as *const JSClass) } } } /// A constructor class hook. -pub type ConstructorClassHook = +pub(crate) type ConstructorClassHook = unsafe extern "C" fn(cx: *mut JSContext, argc: u32, vp: *mut Value) -> bool; /// The constructor behavior of a non-callback interface object. -pub struct InterfaceConstructorBehavior(JSClassOps); +pub(crate) struct InterfaceConstructorBehavior(JSClassOps); impl InterfaceConstructorBehavior { /// An interface constructor that unconditionally throws a type error. - pub const fn throw() -> Self { + pub(crate) const fn throw() -> Self { InterfaceConstructorBehavior(JSClassOps { addProperty: None, delProperty: None, @@ -113,7 +113,7 @@ impl InterfaceConstructorBehavior { } /// An interface constructor that calls a native Rust function. - pub const fn call(hook: ConstructorClassHook) -> Self { + pub(crate) const fn call(hook: ConstructorClassHook) -> Self { InterfaceConstructorBehavior(JSClassOps { addProperty: None, delProperty: None, @@ -130,10 +130,10 @@ impl InterfaceConstructorBehavior { } /// A trace hook. -pub type TraceHook = unsafe extern "C" fn(trc: *mut JSTracer, obj: *mut JSObject); +pub(crate) type TraceHook = unsafe extern "C" fn(trc: *mut JSTracer, obj: *mut JSObject); /// Create a global object with the given class. -pub unsafe fn create_global_object( +pub(crate) unsafe fn create_global_object( cx: SafeJSContext, class: &'static JSClass, private: *const libc::c_void, @@ -210,7 +210,7 @@ fn select_compartment(cx: SafeJSContext, options: &mut RealmOptions) { } /// Create and define the interface object of a callback interface. -pub fn create_callback_interface_object( +pub(crate) fn create_callback_interface_object( cx: SafeJSContext, global: HandleObject, constants: &[Guard<&[ConstantSpec]>], @@ -229,7 +229,7 @@ pub fn create_callback_interface_object( /// Create the interface prototype object of a non-callback interface. #[allow(clippy::too_many_arguments)] -pub fn create_interface_prototype_object( +pub(crate) fn create_interface_prototype_object( cx: SafeJSContext, global: HandleObject, proto: HandleObject, @@ -274,7 +274,7 @@ pub fn create_interface_prototype_object( /// Create and define the interface object of a non-callback interface. #[allow(clippy::too_many_arguments)] -pub fn create_noncallback_interface_object( +pub(crate) fn create_noncallback_interface_object( cx: SafeJSContext, global: HandleObject, proto: HandleObject, @@ -317,7 +317,7 @@ pub fn create_noncallback_interface_object( } /// Create and define the named constructors of a non-callback interface. -pub fn create_named_constructors( +pub(crate) fn create_named_constructors( cx: SafeJSContext, global: HandleObject, named_constructors: &[(ConstructorClassHook, &CStr, u32)], @@ -347,7 +347,7 @@ pub fn create_named_constructors( /// Create a new object with a unique type. #[allow(clippy::too_many_arguments)] -pub fn create_object( +pub(crate) fn create_object( cx: SafeJSContext, global: HandleObject, proto: HandleObject, @@ -367,7 +367,7 @@ pub fn create_object( } /// Conditionally define constants on an object. -pub fn define_guarded_constants( +pub(crate) fn define_guarded_constants( cx: SafeJSContext, obj: HandleObject, constants: &[Guard<&[ConstantSpec]>], @@ -381,7 +381,7 @@ pub fn define_guarded_constants( } /// Conditionally define methods on an object. -pub fn define_guarded_methods( +pub(crate) fn define_guarded_methods( cx: SafeJSContext, obj: HandleObject, methods: &[Guard<&'static [JSFunctionSpec]>], @@ -397,7 +397,7 @@ pub fn define_guarded_methods( } /// Conditionally define properties on an object. -pub fn define_guarded_properties( +pub(crate) fn define_guarded_properties( cx: SafeJSContext, obj: HandleObject, properties: &[Guard<&'static [JSPropertySpec]>], @@ -414,7 +414,7 @@ pub fn define_guarded_properties( /// Returns whether an interface with exposure set given by `globals` should /// be exposed in the global object `obj`. -pub fn is_exposed_in(object: HandleObject, globals: Globals) -> bool { +pub(crate) fn is_exposed_in(object: HandleObject, globals: Globals) -> bool { unsafe { let unwrapped = UncheckedUnwrapObject(object.get(), /* stopAtWindowProxy = */ false); let dom_class = get_dom_class(unwrapped).unwrap(); @@ -424,7 +424,7 @@ pub fn is_exposed_in(object: HandleObject, globals: Globals) -> bool { /// Define a property with a given name on the global object. Should be called /// through the resolve hook. -pub fn define_on_global_object( +pub(crate) fn define_on_global_object( cx: SafeJSContext, global: HandleObject, name: &CStr, @@ -529,7 +529,7 @@ unsafe extern "C" fn non_new_constructor( false } -pub enum ProtoOrIfaceIndex { +pub(crate) enum ProtoOrIfaceIndex { ID(PrototypeList::ID), Constructor(PrototypeList::Constructor), } @@ -543,7 +543,7 @@ impl From<ProtoOrIfaceIndex> for usize { } } -pub fn get_per_interface_object_handle( +pub(crate) fn get_per_interface_object_handle( cx: SafeJSContext, global: HandleObject, id: ProtoOrIfaceIndex, @@ -567,7 +567,7 @@ pub fn get_per_interface_object_handle( } } -pub fn define_dom_interface( +pub(crate) fn define_dom_interface( cx: SafeJSContext, global: HandleObject, id: ProtoOrIfaceIndex, @@ -597,7 +597,7 @@ fn get_proto_id_for_new_target(new_target: HandleObject) -> Option<PrototypeList } } -pub fn get_desired_proto( +pub(crate) fn get_desired_proto( cx: SafeJSContext, args: &CallArgs, proto_id: PrototypeList::ID, diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index afde8c83111..b07c4687db7 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -30,7 +30,7 @@ use crate::script_runtime::{CanGc, JSContext}; /// The values that an iterator will iterate over. #[derive(JSTraceable, MallocSizeOf)] -pub enum IteratorType { +pub(crate) enum IteratorType { /// The keys of the iterable object. Keys, /// The values of the iterable object. @@ -40,7 +40,7 @@ pub enum IteratorType { } /// A DOM object that can be iterated over using a pair value iterator. -pub trait Iterable { +pub(crate) trait Iterable { /// The type of the key of the iterator pair. type Key: ToJSValConvertible; /// The type of the value of the iterator pair. @@ -56,7 +56,7 @@ 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: DomObjectIteratorWrap + JSTraceable + Iterable> { +pub(crate) struct IterableIterator<T: DomObjectIteratorWrap + JSTraceable + Iterable> { reflector: Reflector, iterable: Dom<T>, type_: IteratorType, @@ -65,7 +65,7 @@ pub struct IterableIterator<T: DomObjectIteratorWrap + JSTraceable + Iterable> { 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) -> DomRoot<Self> { + pub(crate) fn new(iterable: &T, type_: IteratorType) -> DomRoot<Self> { let iterator = Box::new(IterableIterator { reflector: Reflector::new(), type_, @@ -77,7 +77,7 @@ impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> IterableIterator<T> { /// Return the next value from the iterable object. #[allow(non_snake_case)] - pub fn Next(&self, cx: JSContext) -> Fallible<NonNull<JSObject>> { + pub(crate) fn Next(&self, cx: JSContext) -> Fallible<NonNull<JSObject>> { let index = self.index.get(); rooted!(in(*cx) let mut value = UndefinedValue()); rooted!(in(*cx) let mut rval = ptr::null_mut::<JSObject>()); diff --git a/components/script/dom/bindings/like.rs b/components/script/dom/bindings/like.rs index 9aaefd48a53..23e075629b8 100644 --- a/components/script/dom/bindings/like.rs +++ b/components/script/dom/bindings/like.rs @@ -20,7 +20,7 @@ use crate::dom::bindings::cell::DomRefCell; /// /// In case you use a type that implements Setlike as underlying storage it's recommended to use `setlike` macro. // In webidl: `setlike<Key>` -pub trait Setlike { +pub(crate) trait Setlike { /// The type of the key of the set. type Key: ToJSValConvertible + Clone; // clone is for impl<T: Setlike> Maplike for T @@ -111,7 +111,7 @@ where /// Usage: /// ```rust -/// pub struct TestBindingSetlike { +/// pub(crate) struct TestBindingSetlike { /// // setlike<DOMString> /// internal: DomRefCell<IndexSet<DOMString>>, /// } @@ -161,7 +161,7 @@ macro_rules! setlike { /// /// In case you use a type that implements Maplike as underlying storage it's recommended to use `maplike` macro. // In webidl: `maplike<Key, Value>` -pub trait Maplike { +pub(crate) trait Maplike { /// The type of the key of the map. type Key: ToJSValConvertible; /// The type of the value of the map. @@ -248,7 +248,7 @@ where /// Usage: /// ```rust -/// pub struct TestBindingMaplike { +/// pub(crate) struct TestBindingMaplike { /// // maplike<DOMString, long> /// internal: DomRefCell<IndexMap<DOMString, i32>>, /// } diff --git a/components/script/dom/bindings/mod.rs b/components/script/dom/bindings/mod.rs index 633763f1ba6..62d99487bbd 100644 --- a/components/script/dom/bindings/mod.rs +++ b/components/script/dom/bindings/mod.rs @@ -134,65 +134,67 @@ #![deny(missing_docs)] #![deny(non_snake_case)] -pub mod buffer_source; -pub mod callback; -pub mod cell; -pub mod constant; -pub mod constructor; -pub mod conversions; -pub mod error; -pub mod finalize; -pub mod frozenarray; -pub mod function; -pub mod guard; -pub mod import; -pub mod inheritance; -pub mod interface; -pub mod iterable; -pub mod like; -pub mod namespace; -pub mod num; -pub mod principals; -pub mod proxyhandler; -pub mod record; -pub mod refcounted; -pub mod reflector; -pub mod root; -pub mod serializable; -pub mod settings_stack; -pub mod str; -pub mod structuredclone; -pub mod trace; -pub mod transferable; -pub mod utils; -pub mod weakref; -pub mod xmlname; +pub(crate) mod buffer_source; +pub(crate) mod callback; +#[allow(dead_code)] +pub(crate) mod cell; +pub(crate) mod constant; +pub(crate) mod constructor; +pub(crate) mod conversions; +pub(crate) mod error; +pub(crate) mod finalize; +pub(crate) mod frozenarray; +pub(crate) mod function; +pub(crate) mod guard; +pub(crate) mod import; +pub(crate) mod inheritance; +pub(crate) mod interface; +pub(crate) mod iterable; +pub(crate) mod like; +pub(crate) mod namespace; +pub(crate) mod num; +pub(crate) mod principals; +pub(crate) mod proxyhandler; +pub(crate) mod record; +pub(crate) mod refcounted; +pub(crate) mod reflector; +pub(crate) mod root; +pub(crate) mod serializable; +pub(crate) mod settings_stack; +#[allow(dead_code)] +pub(crate) mod str; +pub(crate) mod structuredclone; +pub(crate) mod trace; +pub(crate) mod transferable; +pub(crate) mod utils; +pub(crate) mod weakref; +pub(crate) mod xmlname; /// Generated JS-Rust bindings. #[allow(missing_docs, non_snake_case)] -pub mod codegen { - pub mod DomTypeHolder { +pub(crate) mod codegen { + pub(crate) mod DomTypeHolder { include!(concat!(env!("OUT_DIR"), "/DomTypeHolder.rs")); } - pub mod DomTypes { + pub(crate) mod DomTypes { include!(concat!(env!("OUT_DIR"), "/DomTypes.rs")); } #[allow(dead_code)] - pub mod Bindings { + pub(crate) mod Bindings { include!(concat!(env!("OUT_DIR"), "/Bindings/mod.rs")); } - pub mod InterfaceObjectMap { + pub(crate) mod InterfaceObjectMap { include!(concat!(env!("OUT_DIR"), "/InterfaceObjectMap.rs")); } #[allow(dead_code, unused_imports, clippy::enum_variant_names)] - pub mod InheritTypes { + pub(crate) mod InheritTypes { include!(concat!(env!("OUT_DIR"), "/InheritTypes.rs")); } #[allow(clippy::upper_case_acronyms)] - pub mod PrototypeList { + pub(crate) mod PrototypeList { include!(concat!(env!("OUT_DIR"), "/PrototypeList.rs")); } - pub mod RegisterBindings { + pub(crate) mod RegisterBindings { include!(concat!(env!("OUT_DIR"), "/RegisterBindings.rs")); } #[allow( @@ -203,7 +205,7 @@ pub mod codegen { clippy::upper_case_acronyms, clippy::enum_variant_names )] - pub mod UnionTypes { + pub(crate) mod UnionTypes { include!(concat!(env!("OUT_DIR"), "/UnionTypes.rs")); } } diff --git a/components/script/dom/bindings/namespace.rs b/components/script/dom/bindings/namespace.rs index 1afd62b4978..3f5e9d846d5 100644 --- a/components/script/dom/bindings/namespace.rs +++ b/components/script/dom/bindings/namespace.rs @@ -17,13 +17,13 @@ use crate::script_runtime::JSContext; /// The class of a namespace object. #[derive(Clone, Copy)] -pub struct NamespaceObjectClass(JSClass); +pub(crate) struct NamespaceObjectClass(JSClass); unsafe impl Sync for NamespaceObjectClass {} impl NamespaceObjectClass { /// Create a new `NamespaceObjectClass` structure. - pub const unsafe fn new(name: &'static CStr) -> Self { + pub(crate) const unsafe fn new(name: &'static CStr) -> Self { NamespaceObjectClass(JSClass { name: name.as_ptr(), flags: 0, @@ -37,7 +37,7 @@ impl NamespaceObjectClass { /// Create a new namespace object. #[allow(clippy::too_many_arguments)] -pub fn create_namespace_object( +pub(crate) fn create_namespace_object( cx: JSContext, global: HandleObject, proto: HandleObject, diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs index 58b12f6cb7f..59b89a29e3e 100644 --- a/components/script/dom/bindings/num.rs +++ b/components/script/dom/bindings/num.rs @@ -12,11 +12,11 @@ use num_traits::Float; /// Encapsulates the IDL restricted float type. #[derive(Clone, Copy, Eq, JSTraceable, PartialEq)] -pub struct Finite<T: Float>(T); +pub(crate) struct Finite<T: Float>(T); impl<T: Float> Finite<T> { /// Create a new `Finite<T: Float>` safely. - pub fn new(value: T) -> Option<Finite<T>> { + pub(crate) fn new(value: T) -> Option<Finite<T>> { if value.is_finite() { Some(Finite(value)) } else { @@ -26,7 +26,7 @@ impl<T: Float> Finite<T> { /// Create a new `Finite<T: Float>`. #[inline] - pub fn wrap(value: T) -> Finite<T> { + pub(crate) fn wrap(value: T) -> Finite<T> { assert!( value.is_finite(), "Finite<T> doesn't encapsulate unrestricted value." diff --git a/components/script/dom/bindings/principals.rs b/components/script/dom/bindings/principals.rs index 30d309a6e37..d6f3e10981c 100644 --- a/components/script/dom/bindings/principals.rs +++ b/components/script/dom/bindings/principals.rs @@ -22,10 +22,10 @@ use super::structuredclone::StructuredCloneTags; /// An owned reference to Servo's `JSPrincipals` instance. #[repr(transparent)] -pub struct ServoJSPrincipals(NonNull<JSPrincipals>); +pub(crate) struct ServoJSPrincipals(NonNull<JSPrincipals>); impl ServoJSPrincipals { - pub fn new(origin: &MutableOrigin) -> Self { + pub(crate) fn new(origin: &MutableOrigin) -> Self { unsafe { let private: Box<MutableOrigin> = Box::new(origin.clone()); let raw = CreateRustJSPrincipals(&PRINCIPALS_CALLBACKS, Box::into_raw(private) as _); @@ -38,24 +38,24 @@ impl ServoJSPrincipals { /// Construct `Self` from a raw `*mut JSPrincipals`, incrementing its /// reference count. #[inline] - pub unsafe fn from_raw_nonnull(raw: NonNull<JSPrincipals>) -> Self { + pub(crate) unsafe fn from_raw_nonnull(raw: NonNull<JSPrincipals>) -> Self { JS_HoldPrincipals(raw.as_ptr()); Self(raw) } #[inline] - pub unsafe fn origin(&self) -> MutableOrigin { + pub(crate) unsafe fn origin(&self) -> MutableOrigin { let origin = GetRustJSPrincipalsPrivate(self.0.as_ptr()) as *mut MutableOrigin; (*origin).clone() } #[inline] - pub fn as_raw_nonnull(&self) -> NonNull<JSPrincipals> { + pub(crate) fn as_raw_nonnull(&self) -> NonNull<JSPrincipals> { self.0 } #[inline] - pub fn as_raw(&self) -> *mut JSPrincipals { + pub(crate) fn as_raw(&self) -> *mut JSPrincipals { self.0.as_ptr() } } @@ -78,7 +78,7 @@ impl Drop for ServoJSPrincipals { /// A borrowed reference to Servo's `JSPrincipals` instance. Does not update the /// reference count on creation and deletion. -pub struct ServoJSPrincipalsRef<'a>(ManuallyDrop<ServoJSPrincipals>, PhantomData<&'a ()>); +pub(crate) struct ServoJSPrincipalsRef<'a>(ManuallyDrop<ServoJSPrincipals>, PhantomData<&'a ()>); impl ServoJSPrincipalsRef<'_> { /// Construct `Self` from a raw `NonNull<JSPrincipals>`. @@ -90,7 +90,7 @@ impl ServoJSPrincipalsRef<'_> { /// returned `ServoJSPrincipalsRef` object or any clones are not used past /// the lifetime of the wrapped object. #[inline] - pub unsafe fn from_raw_nonnull(raw: NonNull<JSPrincipals>) -> Self { + pub(crate) unsafe fn from_raw_nonnull(raw: NonNull<JSPrincipals>) -> Self { // Don't use `ServoJSPrincipals::from_raw_nonnull`; we don't want to // update the reference count Self(ManuallyDrop::new(ServoJSPrincipals(raw)), PhantomData) @@ -103,7 +103,7 @@ impl ServoJSPrincipalsRef<'_> { /// The behavior is undefined if `raw` is null. See also /// [`Self::from_raw_nonnull`]. #[inline] - pub unsafe fn from_raw_unchecked(raw: *mut JSPrincipals) -> Self { + pub(crate) unsafe fn from_raw_unchecked(raw: *mut JSPrincipals) -> Self { Self::from_raw_nonnull(NonNull::new_unchecked(raw)) } } @@ -125,12 +125,12 @@ impl Deref for ServoJSPrincipalsRef<'_> { } #[allow(unused)] -pub unsafe extern "C" fn destroy_servo_jsprincipal(principals: *mut JSPrincipals) { +pub(crate) unsafe extern "C" fn destroy_servo_jsprincipal(principals: *mut JSPrincipals) { Box::from_raw(GetRustJSPrincipalsPrivate(principals) as *mut MutableOrigin); DestroyRustJSPrincipals(principals); } -pub unsafe extern "C" fn write_jsprincipal( +pub(crate) unsafe extern "C" fn write_jsprincipal( principal: *mut JSPrincipals, _cx: *mut JSContext, writer: *mut JSStructuredCloneWriter, @@ -155,7 +155,7 @@ pub unsafe extern "C" fn write_jsprincipal( true } -pub unsafe extern "C" fn read_jsprincipal( +pub(crate) unsafe extern "C" fn read_jsprincipal( _cx: *mut JSContext, reader: *mut JSStructuredCloneReader, principals: *mut *mut JSPrincipals, @@ -192,7 +192,7 @@ unsafe extern "C" fn principals_is_system_or_addon_principal(_: *mut JSPrincipal } //TODO is same_origin_domain equivalent to subsumes for our purposes -pub unsafe extern "C" fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipals) -> bool { +pub(crate) unsafe extern "C" fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipals) -> bool { match (NonNull::new(obj), NonNull::new(other)) { (Some(obj), Some(other)) => { let obj = ServoJSPrincipalsRef::from_raw_nonnull(obj); diff --git a/components/script/dom/bindings/proxyhandler.rs b/components/script/dom/bindings/proxyhandler.rs index c3520c6d8ca..0111dc27509 100644 --- a/components/script/dom/bindings/proxyhandler.rs +++ b/components/script/dom/bindings/proxyhandler.rs @@ -47,7 +47,7 @@ use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::JSContext as SafeJSContext; /// Determine if this id shadows any existing properties for this proxy. -pub unsafe extern "C" fn shadow_check_callback( +pub(crate) unsafe extern "C" fn shadow_check_callback( cx: *mut JSContext, object: RawHandleObject, id: RawHandleId, @@ -74,7 +74,7 @@ pub unsafe extern "C" fn shadow_check_callback( } /// Initialize the infrastructure for DOM proxy objects. -pub unsafe fn init() { +pub(crate) unsafe fn init() { SetDOMProxyInformation( GetProxyHandlerFamily(), Some(shadow_check_callback), @@ -83,7 +83,7 @@ pub unsafe fn init() { } /// Defines an expando on the given `proxy`. -pub unsafe extern "C" fn define_property( +pub(crate) unsafe extern "C" fn define_property( cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, @@ -96,7 +96,7 @@ pub unsafe extern "C" fn define_property( } /// Deletes an expando off the given `proxy`. -pub unsafe extern "C" fn delete( +pub(crate) unsafe extern "C" fn delete( cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, @@ -113,7 +113,7 @@ pub unsafe extern "C" fn delete( } /// Controls whether the Extensible bit can be changed -pub unsafe extern "C" fn prevent_extensions( +pub(crate) unsafe extern "C" fn prevent_extensions( _cx: *mut JSContext, _proxy: RawHandleObject, result: *mut ObjectOpResult, @@ -123,7 +123,7 @@ pub unsafe extern "C" fn prevent_extensions( } /// Reports whether the object is Extensible -pub unsafe extern "C" fn is_extensible( +pub(crate) unsafe extern "C" fn is_extensible( _cx: *mut JSContext, _proxy: RawHandleObject, succeeded: *mut bool, @@ -141,7 +141,7 @@ pub unsafe extern "C" fn is_extensible( /// This implementation always handles the case of the ordinary /// `[[GetPrototypeOf]]` behavior. An alternative implementation will be /// necessary for maybe-cross-origin objects. -pub unsafe extern "C" fn get_prototype_if_ordinary( +pub(crate) unsafe extern "C" fn get_prototype_if_ordinary( _: *mut JSContext, proxy: RawHandleObject, is_ordinary: *mut bool, @@ -153,7 +153,7 @@ pub unsafe extern "C" fn get_prototype_if_ordinary( } /// Get the expando object, or null if there is none. -pub unsafe fn get_expando_object(obj: RawHandleObject, mut expando: MutableHandleObject) { +pub(crate) unsafe fn get_expando_object(obj: RawHandleObject, mut expando: MutableHandleObject) { assert!(is_dom_proxy(obj.get())); let val = &mut UndefinedValue(); GetProxyPrivate(obj.get(), val); @@ -166,7 +166,7 @@ pub unsafe fn get_expando_object(obj: RawHandleObject, mut expando: MutableHandl /// Get the expando object, or create it if it doesn't exist yet. /// Fails on JSAPI failure. -pub unsafe fn ensure_expando_object( +pub(crate) unsafe fn ensure_expando_object( cx: *mut JSContext, obj: RawHandleObject, mut expando: MutableHandleObject, @@ -187,7 +187,7 @@ pub unsafe fn ensure_expando_object( /// Set the property descriptor's object to `obj` and set it to enumerable, /// and writable if `readonly` is true. -pub fn set_property_descriptor( +pub(crate) fn set_property_descriptor( desc: MutableHandle<PropertyDescriptor>, value: HandleValue, attrs: u32, @@ -200,7 +200,10 @@ pub fn set_property_descriptor( } /// <https://html.spec.whatwg.org/multipage/#isplatformobjectsameorigin-(-o-)> -pub unsafe fn is_platform_object_same_origin(cx: SafeJSContext, obj: RawHandleObject) -> bool { +pub(crate) unsafe fn is_platform_object_same_origin( + cx: SafeJSContext, + obj: RawHandleObject, +) -> bool { let subject_realm = get_context_realm(*cx); let obj_realm = GetObjectRealmOrNull(*obj); assert!(!obj_realm.is_null()); @@ -236,7 +239,11 @@ pub unsafe fn is_platform_object_same_origin(cx: SafeJSContext, obj: RawHandleOb /// What this function does corresponds to the operations in /// <https://html.spec.whatwg.org/multipage/#the-location-interface> denoted as /// "Throw a `SecurityError` DOMException". -pub unsafe fn report_cross_origin_denial(cx: SafeJSContext, id: RawHandleId, access: &str) -> bool { +pub(crate) unsafe fn report_cross_origin_denial( + cx: SafeJSContext, + id: RawHandleId, + access: &str, +) -> bool { debug!( "permission denied to {} property {} on cross-origin object", access, @@ -267,9 +274,9 @@ unsafe fn id_to_source(cx: SafeJSContext, id: RawHandleId) -> Option<DOMString> /// [`CrossOriginProperties(O)`]. /// /// [`CrossOriginProperties(O)`]: https://html.spec.whatwg.org/multipage/#crossoriginproperties-(-o-) -pub struct CrossOriginProperties { - pub attributes: &'static [JSPropertySpec], - pub methods: &'static [JSFunctionSpec], +pub(crate) struct CrossOriginProperties { + pub(crate) attributes: &'static [JSPropertySpec], + pub(crate) methods: &'static [JSFunctionSpec], } impl CrossOriginProperties { @@ -287,7 +294,7 @@ impl CrossOriginProperties { /// Implementation of [`CrossOriginOwnPropertyKeys`]. /// /// [`CrossOriginOwnPropertyKeys`]: https://html.spec.whatwg.org/multipage/#crossoriginownpropertykeys-(-o-) -pub unsafe fn cross_origin_own_property_keys( +pub(crate) unsafe fn cross_origin_own_property_keys( cx: SafeJSContext, _proxy: RawHandleObject, cross_origin_properties: &'static CrossOriginProperties, @@ -312,7 +319,7 @@ pub unsafe fn cross_origin_own_property_keys( /// Implementation of `[[Set]]` for [`Location`]. /// /// [`Location`]: https://html.spec.whatwg.org/multipage/#location-set -pub unsafe extern "C" fn maybe_cross_origin_set_rawcx( +pub(crate) unsafe extern "C" fn maybe_cross_origin_set_rawcx( cx: *mut JSContext, proxy: RawHandleObject, id: RawHandleId, @@ -355,7 +362,7 @@ pub unsafe extern "C" fn maybe_cross_origin_set_rawcx( ) } -pub unsafe extern "C" fn maybe_cross_origin_get_prototype_if_ordinary_rawcx( +pub(crate) unsafe extern "C" fn maybe_cross_origin_get_prototype_if_ordinary_rawcx( _: *mut JSContext, _proxy: RawHandleObject, is_ordinary: *mut bool, @@ -369,7 +376,7 @@ pub unsafe extern "C" fn maybe_cross_origin_get_prototype_if_ordinary_rawcx( /// Implementation of `[[GetPrototypeOf]]` for [`Location`]. /// /// [`Location`]: https://html.spec.whatwg.org/multipage/#location-getprototypeof -pub unsafe fn maybe_cross_origin_get_prototype( +pub(crate) unsafe fn maybe_cross_origin_get_prototype( cx: SafeJSContext, proxy: RawHandleObject, get_proto_object: unsafe fn(cx: SafeJSContext, global: HandleObject, rval: MutableHandleObject), @@ -396,7 +403,7 @@ pub unsafe fn maybe_cross_origin_get_prototype( /// /// [`Location`]: https://html.spec.whatwg.org/multipage/#location-setprototypeof /// [`WindowProxy`]: https://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof -pub unsafe extern "C" fn maybe_cross_origin_set_prototype_rawcx( +pub(crate) unsafe extern "C" fn maybe_cross_origin_set_prototype_rawcx( cx: *mut JSContext, proxy: RawHandleObject, proto: RawHandleObject, @@ -431,7 +438,7 @@ pub unsafe extern "C" fn maybe_cross_origin_set_prototype_rawcx( /// for a maybe-cross-origin object. /// /// [`CrossOriginGet`]: https://html.spec.whatwg.org/multipage/#crossoriginget-(-o,-p,-receiver-) -pub unsafe fn cross_origin_get( +pub(crate) unsafe fn cross_origin_get( cx: SafeJSContext, proxy: RawHandleObject, receiver: RawHandleValue, @@ -497,7 +504,7 @@ pub unsafe fn cross_origin_get( /// for a maybe-cross-origin object. /// /// [`CrossOriginSet`]: https://html.spec.whatwg.org/multipage/#crossoriginset-(-o,-p,-v,-receiver-) -pub unsafe fn cross_origin_set( +pub(crate) unsafe fn cross_origin_set( cx: SafeJSContext, proxy: RawHandleObject, id: RawHandleId, @@ -588,7 +595,7 @@ fn is_data_descriptor(d: &PropertyDescriptor) -> bool { /// /// `cx` and `proxy` are expected to be different-Realm here. `proxy` is a proxy /// for a maybe-cross-origin object. -pub unsafe fn cross_origin_has_own( +pub(crate) unsafe fn cross_origin_has_own( cx: SafeJSContext, _proxy: RawHandleObject, cross_origin_properties: &'static CrossOriginProperties, @@ -614,7 +621,7 @@ pub unsafe fn cross_origin_has_own( /// for a maybe-cross-origin object. /// /// [`CrossOriginGetOwnPropertyHelper`]: https://html.spec.whatwg.org/multipage/#crossorigingetownpropertyhelper-(-o,-p-) -pub unsafe fn cross_origin_get_own_property_helper( +pub(crate) unsafe fn cross_origin_get_own_property_helper( cx: SafeJSContext, proxy: RawHandleObject, cross_origin_properties: &'static CrossOriginProperties, @@ -640,7 +647,7 @@ pub unsafe fn cross_origin_get_own_property_helper( /// for a maybe-cross-origin object. /// /// [`CrossOriginPropertyFallback`]: https://html.spec.whatwg.org/multipage/#crossoriginpropertyfallback-(-p-) -pub unsafe fn cross_origin_property_fallback( +pub(crate) unsafe fn cross_origin_property_fallback( cx: SafeJSContext, _proxy: RawHandleObject, id: RawHandleId, diff --git a/components/script/dom/bindings/record.rs b/components/script/dom/bindings/record.rs index c437b8955f7..32388c9e187 100644 --- a/components/script/dom/bindings/record.rs +++ b/components/script/dom/bindings/record.rs @@ -23,7 +23,7 @@ use js::rust::{HandleId, HandleValue, IdVector, MutableHandleValue}; use crate::dom::bindings::conversions::jsid_to_string; use crate::dom::bindings::str::{ByteString, DOMString, USVString}; -pub trait RecordKey: Eq + Hash + Sized { +pub(crate) trait RecordKey: Eq + Hash + Sized { fn to_utf16_vec(&self) -> Vec<u16>; unsafe fn from_id(cx: *mut JSContext, id: HandleId) -> Result<ConversionResult<Self>, ()>; } @@ -71,14 +71,14 @@ impl RecordKey for ByteString { /// The `Record` (open-ended dictionary) type. #[derive(Clone, JSTraceable)] -pub struct Record<K: RecordKey, V> { +pub(crate) struct Record<K: RecordKey, V> { #[custom_trace] map: IndexMap<K, V>, } impl<K: RecordKey, V> Record<K, V> { /// Create an empty `Record`. - pub fn new() -> Self { + pub(crate) fn new() -> Self { Record { map: IndexMap::new(), } diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 97a181f1c2f..d3f55012534 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -47,10 +47,10 @@ mod dummy { use std::rc::Rc; use super::LiveDOMReferences; - thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = + thread_local!(pub(crate) static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None))); } -pub use self::dummy::LIVE_REFERENCES; +pub(crate) use self::dummy::LIVE_REFERENCES; /// A pointer to a Rust DOM object that needs to be destroyed. #[derive(MallocSizeOf)] @@ -84,7 +84,7 @@ impl TrustedPromise { /// be prevented from being GCed for the duration of the resulting `TrustedPromise` object's /// lifetime. #[allow(crown::unrooted_must_root)] - pub fn new(promise: Rc<Promise>) -> TrustedPromise { + pub(crate) fn new(promise: Rc<Promise>) -> TrustedPromise { LIVE_REFERENCES.with(|r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); @@ -100,7 +100,7 @@ impl TrustedPromise { /// Obtain a usable DOM Promise from a pinned `TrustedPromise` value. Fails if used on /// a different thread than the original value from which this `TrustedPromise` was /// obtained. - pub fn root(self) -> Rc<Promise> { + pub(crate) fn root(self) -> Rc<Promise> { LIVE_REFERENCES.with(|r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); @@ -134,7 +134,7 @@ impl TrustedPromise { /// A task which will reject the promise. #[allow(crown::unrooted_must_root)] - pub fn reject_task(self, error: Error) -> impl TaskOnce { + pub(crate) fn reject_task(self, error: Error) -> impl TaskOnce { let this = self; task!(reject_promise: move || { debug!("Rejecting promise."); @@ -144,7 +144,7 @@ impl TrustedPromise { /// A task which will resolve the promise. #[allow(crown::unrooted_must_root)] - pub fn resolve_task<T>(self, value: T) -> impl TaskOnce + pub(crate) fn resolve_task<T>(self, value: T) -> impl TaskOnce where T: ToJSValConvertible + Send, { @@ -162,7 +162,7 @@ impl TrustedPromise { /// `Trusted<T>` instance. #[crown::unrooted_must_root_lint::allow_unrooted_interior] #[derive(MallocSizeOf)] -pub struct Trusted<T: DomObject> { +pub(crate) struct Trusted<T: DomObject> { /// A pointer to the Rust DOM object of type T, but void to allow /// sending `Trusted<T>` between threads, regardless of T's sendability. #[conditional_malloc_size_of] @@ -178,7 +178,7 @@ impl<T: DomObject> Trusted<T> { /// Create a new `Trusted<T>` instance from an existing DOM pointer. The DOM object will /// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's /// lifetime. - pub fn new(ptr: &T) -> Trusted<T> { + pub(crate) fn new(ptr: &T) -> Trusted<T> { fn add_live_reference( ptr: *const libc::c_void, ) -> (Arc<TrustedReference>, *const LiveDOMReferences) { @@ -201,7 +201,7 @@ impl<T: DomObject> Trusted<T> { /// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on /// a different thread than the original value from which this `Trusted<T>` was /// obtained. - pub fn root(&self) -> DomRoot<T> { + pub(crate) fn root(&self) -> DomRoot<T> { fn validate(owner_thread: *const LiveDOMReferences) { assert!(LIVE_REFERENCES.with(|r| { let r = r.borrow(); @@ -227,7 +227,7 @@ impl<T: DomObject> Clone for Trusted<T> { /// The set of live, pinned DOM objects that are currently prevented /// from being garbage collected due to outstanding references. #[allow(crown::unrooted_must_root)] -pub struct LiveDOMReferences { +pub(crate) struct LiveDOMReferences { // keyed on pointer to Rust DOM object reflectable_table: RefCell<HashMap<*const libc::c_void, Weak<TrustedReference>>>, promise_table: RefCell<HashMap<*const Promise, Vec<Rc<Promise>>>>, @@ -235,7 +235,7 @@ pub struct LiveDOMReferences { impl LiveDOMReferences { /// Set up the thread-local data required for storing the outstanding DOM references. - pub fn initialize() { + pub(crate) fn initialize() { LIVE_REFERENCES.with(|r| { *r.borrow_mut() = Some(LiveDOMReferences { reflectable_table: RefCell::new(HashMap::new()), @@ -244,7 +244,7 @@ impl LiveDOMReferences { }); } - pub fn destruct() { + pub(crate) fn destruct() { LIVE_REFERENCES.with(|r| { *r.borrow_mut() = None; }); @@ -302,7 +302,7 @@ fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) { /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES #[allow(crown::unrooted_must_root)] -pub unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) { +pub(crate) unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) { trace!("tracing live refcounted references"); LIVE_REFERENCES.with(|r| { let r = r.borrow(); diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index 3a3743a07c0..eb15172aaaa 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -19,7 +19,7 @@ use crate::script_runtime::{CanGc, JSContext}; /// 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, can_gc: CanGc) -> DomRoot<T> +pub(crate) fn reflect_dom_object<T, U>(obj: Box<T>, global: &U, can_gc: CanGc) -> DomRoot<T> where T: DomObject + DomObjectWrap, U: DerivedFrom<GlobalScope>, @@ -28,7 +28,7 @@ where unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, None, obj, can_gc) } } -pub fn reflect_dom_object_with_proto<T, U>( +pub(crate) fn reflect_dom_object_with_proto<T, U>( obj: Box<T>, global: &U, proto: Option<HandleObject>, @@ -47,7 +47,7 @@ where #[derive(MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] // If you're renaming or moving this field, update the path in plugins::reflector as well -pub struct Reflector { +pub(crate) struct Reflector { #[ignore_malloc_size_of = "defined and measured in rust-mozjs"] object: Heap<*mut JSObject>, } @@ -62,7 +62,7 @@ impl PartialEq for Reflector { impl Reflector { /// Get the reflector. #[inline] - pub fn get_jsobject(&self) -> HandleObject { + pub(crate) fn get_jsobject(&self) -> HandleObject { // We're rooted, so it's safe to hand out a handle to object in Heap unsafe { HandleObject::from_raw(self.object.handle()) } } @@ -72,7 +72,7 @@ impl Reflector { /// # Safety /// /// The provided [`JSObject`] pointer must point to a valid [`JSObject`]. - pub unsafe fn set_jsobject(&self, object: *mut JSObject) { + pub(crate) unsafe fn set_jsobject(&self, object: *mut JSObject) { assert!(self.object.get().is_null()); assert!(!object.is_null()); self.object.set(object); @@ -81,14 +81,14 @@ impl Reflector { /// Return a pointer to the memory location at which the JS reflector /// object is stored. Used to root the reflector, as /// required by the JSAPI rooting APIs. - pub fn rootable(&self) -> &Heap<*mut JSObject> { + pub(crate) fn rootable(&self) -> &Heap<*mut JSObject> { &self.object } /// Create an uninitialized `Reflector`. // These are used by the bindings and do not need `default()` functions. #[allow(clippy::new_without_default)] - pub fn new() -> Reflector { + pub(crate) fn new() -> Reflector { Reflector { object: Heap::default(), } @@ -96,7 +96,7 @@ impl Reflector { } /// A trait to provide access to the `Reflector` for a DOM object. -pub trait DomObject: JSTraceable + 'static { +pub(crate) trait DomObject: JSTraceable + 'static { /// Returns the receiver's reflector. fn reflector(&self) -> &Reflector; @@ -119,7 +119,7 @@ impl DomObject for Reflector { } /// A trait to initialize the `Reflector` for a DOM object. -pub trait MutDomObject: DomObject { +pub(crate) trait MutDomObject: DomObject { /// Initializes the Reflector /// /// # Safety @@ -135,7 +135,7 @@ impl MutDomObject for Reflector { } /// A trait to provide a function pointer to wrap function for DOM objects. -pub trait DomObjectWrap: Sized + DomObject { +pub(crate) trait DomObjectWrap: Sized + DomObject { /// Function pointer to the general wrap function type #[allow(clippy::type_complexity)] const WRAP: unsafe fn( @@ -149,7 +149,7 @@ pub trait DomObjectWrap: Sized + DomObject { /// A trait to provide a function pointer to wrap function for /// DOM iterator interfaces. -pub trait DomObjectIteratorWrap: DomObjectWrap + JSTraceable + Iterable { +pub(crate) trait DomObjectIteratorWrap: DomObjectWrap + JSTraceable + Iterable { /// Function pointer to the wrap function for `IterableIterator<T>` #[allow(clippy::type_complexity)] const ITER_WRAP: unsafe fn( diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index c934dae7fbf..b182c917b98 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -45,7 +45,7 @@ use crate::dom::node::Node; /// A rooted value. #[allow(crown::unrooted_must_root)] #[crown::unrooted_must_root_lint::allow_unrooted_interior] -pub struct Root<T: StableTraceObject> { +pub(crate) struct Root<T: StableTraceObject> { /// The value to root. value: T, /// List that ensures correct dynamic root ordering @@ -60,7 +60,7 @@ where /// It cannot outlive its associated `RootCollection`, and it gives /// out references which cannot outlive this new `Root`. #[allow(crown::unrooted_must_root)] - pub unsafe fn new(value: T) -> Self { + pub(crate) unsafe fn new(value: T) -> Self { unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection { assert_in_script(); STACK_ROOTS.with(|root_list| { @@ -85,7 +85,7 @@ where /// owned and referenced objects, so that the garbage collector can accurately determine which /// objects are still in use. Failing to adhere to this contract may result in undefined behavior, /// such as use-after-free errors. -pub unsafe trait StableTraceObject { +pub(crate) unsafe trait StableTraceObject { /// Returns a stable trace object which address won't change for the whole /// lifetime of the value. fn stable_trace_object(&self) -> *const dyn JSTraceable; @@ -160,11 +160,11 @@ where } /// A rooted reference to a DOM object. -pub type DomRoot<T> = Root<Dom<T>>; +pub(crate) type DomRoot<T> = Root<Dom<T>>; impl<T: Castable> DomRoot<T> { /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast<U>(root: DomRoot<T>) -> DomRoot<U> + pub(crate) fn upcast<U>(root: DomRoot<T>) -> DomRoot<U> where U: Castable, T: DerivedFrom<U>, @@ -173,7 +173,7 @@ impl<T: Castable> DomRoot<T> { } /// Cast a DOM object root downwards to one of the interfaces it might implement. - pub fn downcast<U>(root: DomRoot<T>) -> Option<DomRoot<U>> + pub(crate) fn downcast<U>(root: DomRoot<T>) -> Option<DomRoot<U>> where U: DerivedFrom<T>, { @@ -187,7 +187,7 @@ impl<T: Castable> DomRoot<T> { impl<T: DomObject> DomRoot<T> { /// Generate a new root from a reference - pub fn from_ref(unrooted: &T) -> DomRoot<T> { + pub(crate) fn from_ref(unrooted: &T) -> DomRoot<T> { unsafe { DomRoot::new(Dom::from_ref(unrooted)) } } @@ -245,16 +245,16 @@ where /// See also [*Exact Stack Rooting - Storing a GCPointer on the CStack*][cstack]. /// /// [cstack]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/GC/Exact_Stack_Rooting -pub struct RootCollection { +pub(crate) struct RootCollection { roots: UnsafeCell<Vec<*const dyn JSTraceable>>, } thread_local!(static STACK_ROOTS: Cell<Option<*const RootCollection>> = const { Cell::new(None) }); -pub struct ThreadLocalStackRoots<'a>(PhantomData<&'a u32>); +pub(crate) struct ThreadLocalStackRoots<'a>(PhantomData<&'a u32>); impl<'a> ThreadLocalStackRoots<'a> { - pub fn new(roots: &'a RootCollection) -> Self { + pub(crate) fn new(roots: &'a RootCollection) -> Self { STACK_ROOTS.with(|r| r.set(Some(roots))); ThreadLocalStackRoots(PhantomData) } @@ -268,7 +268,7 @@ impl Drop for ThreadLocalStackRoots<'_> { impl RootCollection { /// Create an empty collection of roots - pub fn new() -> RootCollection { + pub(crate) fn new() -> RootCollection { assert_in_script(); RootCollection { roots: UnsafeCell::new(vec![]), @@ -298,7 +298,7 @@ impl RootCollection { } /// SM Callback that traces the rooted reflectors -pub unsafe fn trace_roots(tracer: *mut JSTracer) { +pub(crate) unsafe fn trace_roots(tracer: *mut JSTracer) { trace!("tracing stack roots"); STACK_ROOTS.with(|collection| { let collection = &*(*collection.get().unwrap()).roots.get(); @@ -309,7 +309,7 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) { } /// Get a slice of references to DOM objects. -pub trait DomSlice<T> +pub(crate) trait DomSlice<T> where T: JSTraceable + DomObject, { @@ -336,7 +336,7 @@ where /// /// This should only be used as a field in other DOM objects. #[crown::unrooted_must_root_lint::must_root] -pub struct Dom<T> { +pub(crate) struct Dom<T> { ptr: ptr::NonNull<T>, } @@ -354,7 +354,7 @@ impl<T> Dom<T> { /// # Safety /// /// The `self` parameter to this method must meet all the requirements of [`ptr::NonNull::as_ref`]. - pub unsafe fn to_layout(&self) -> LayoutDom<T> { + pub(crate) unsafe fn to_layout(&self) -> LayoutDom<T> { assert_in_layout(); LayoutDom { value: self.ptr.as_ref(), @@ -365,7 +365,7 @@ impl<T> Dom<T> { impl<T: DomObject> Dom<T> { /// Create a `Dom<T>` from a `&T` #[allow(crown::unrooted_must_root)] - pub fn from_ref(obj: &T) -> Dom<T> { + pub(crate) fn from_ref(obj: &T) -> Dom<T> { assert_in_script(); Dom { ptr: ptr::NonNull::from(obj), @@ -404,7 +404,7 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> { /// A traced reference to a DOM object that may not be reflected yet. #[crown::unrooted_must_root_lint::must_root] -pub struct MaybeUnreflectedDom<T> { +pub(crate) struct MaybeUnreflectedDom<T> { ptr: ptr::NonNull<T>, } @@ -413,7 +413,7 @@ where T: DomObject, { #[allow(crown::unrooted_must_root)] - pub unsafe fn from_box(value: Box<T>) -> Self { + pub(crate) unsafe fn from_box(value: Box<T>) -> Self { Self { ptr: Box::leak(value).into(), } @@ -424,7 +424,7 @@ impl<T> Root<MaybeUnreflectedDom<T>> where T: DomObject, { - pub fn as_ptr(&self) -> *const T { + pub(crate) fn as_ptr(&self) -> *const T { self.value.ptr.as_ptr() } } @@ -433,7 +433,7 @@ impl<T> Root<MaybeUnreflectedDom<T>> where T: MutDomObject, { - pub unsafe fn reflect_with(self, obj: *mut JSObject) -> DomRoot<T> { + pub(crate) unsafe fn reflect_with(self, obj: *mut JSObject) -> DomRoot<T> { let ptr = self.as_ptr(); drop(self); let root = DomRoot::from_ref(&*ptr); @@ -445,7 +445,7 @@ where /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. #[crown::unrooted_must_root_lint::allow_unrooted_interior] -pub struct LayoutDom<'dom, T> { +pub(crate) struct LayoutDom<'dom, T> { value: &'dom T, } @@ -454,7 +454,7 @@ where T: Castable, { /// Cast a DOM object root upwards to one of the interfaces it derives from. - pub fn upcast<U>(&self) -> LayoutDom<'dom, U> + pub(crate) fn upcast<U>(&self) -> LayoutDom<'dom, U> where U: Castable, T: DerivedFrom<U>, @@ -466,7 +466,7 @@ where } /// Cast a DOM object downwards to one of the interfaces it might implement. - pub fn downcast<U>(&self) -> Option<LayoutDom<'dom, U>> + pub(crate) fn downcast<U>(&self) -> Option<LayoutDom<'dom, U>> where U: DerivedFrom<T>, { @@ -475,7 +475,7 @@ where } /// Returns whether this inner object is a U. - pub fn is<U>(&self) -> bool + pub(crate) fn is<U>(&self) -> bool where U: DerivedFrom<T>, { @@ -489,7 +489,7 @@ where T: DomObject, { /// Get the reflector. - pub unsafe fn get_jsobject(&self) -> *mut JSObject { + pub(crate) unsafe fn get_jsobject(&self) -> *mut JSObject { assert_in_layout(); self.value.reflector().get_jsobject().get() } @@ -552,7 +552,7 @@ impl<T> Clone for LayoutDom<'_, T> { 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) -> Self { + pub(crate) unsafe fn from_trusted_node_address(inner: TrustedNodeAddress) -> Self { assert_in_layout(); let TrustedNodeAddress(addr) = inner; LayoutDom { @@ -568,13 +568,13 @@ impl LayoutDom<'_, Node> { /// on `Dom<T>`. #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable)] -pub struct MutDom<T: DomObject> { +pub(crate) struct MutDom<T: DomObject> { val: UnsafeCell<Dom<T>>, } impl<T: DomObject> MutDom<T> { /// Create a new `MutDom`. - pub fn new(initial: &T) -> MutDom<T> { + pub(crate) fn new(initial: &T) -> MutDom<T> { assert_in_script(); MutDom { val: UnsafeCell::new(Dom::from_ref(initial)), @@ -582,7 +582,7 @@ impl<T: DomObject> MutDom<T> { } /// Set this `MutDom` to the given value. - pub fn set(&self, val: &T) { + pub(crate) fn set(&self, val: &T) { assert_in_script(); unsafe { *self.val.get() = Dom::from_ref(val); @@ -590,7 +590,7 @@ impl<T: DomObject> MutDom<T> { } /// Get the value in this `MutDom`. - pub fn get(&self) -> DomRoot<T> { + pub(crate) fn get(&self) -> DomRoot<T> { assert_in_script(); unsafe { DomRoot::from_ref(&*ptr::read(self.val.get())) } } @@ -631,13 +631,13 @@ pub(crate) fn assert_in_layout() { /// on `Dom<T>`. #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable)] -pub struct MutNullableDom<T: DomObject> { +pub(crate) struct MutNullableDom<T: DomObject> { ptr: UnsafeCell<Option<Dom<T>>>, } impl<T: DomObject> MutNullableDom<T> { /// Create a new `MutNullableDom`. - pub fn new(initial: Option<&T>) -> MutNullableDom<T> { + pub(crate) fn new(initial: Option<&T>) -> MutNullableDom<T> { assert_in_script(); MutNullableDom { ptr: UnsafeCell::new(initial.map(Dom::from_ref)), @@ -646,7 +646,7 @@ impl<T: DomObject> MutNullableDom<T> { /// Retrieve a copy of the current inner value. If it is `None`, it is /// initialized with the result of `cb` first. - pub fn or_init<F>(&self, cb: F) -> DomRoot<T> + pub(crate) fn or_init<F>(&self, cb: F) -> DomRoot<T> where F: FnOnce() -> DomRoot<T>, { @@ -664,20 +664,20 @@ impl<T: DomObject> MutNullableDom<T> { /// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`. /// For use by layout, which can't use safe types like Temporary. #[allow(crown::unrooted_must_root)] - pub unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> { + pub(crate) unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> { assert_in_layout(); (*self.ptr.get()).as_ref().map(|js| js.to_layout()) } /// Get a rooted value out of this object #[allow(crown::unrooted_must_root)] - pub fn get(&self) -> Option<DomRoot<T>> { + pub(crate) fn get(&self) -> Option<DomRoot<T>> { assert_in_script(); unsafe { ptr::read(self.ptr.get()).map(|o| DomRoot::from_ref(&*o)) } } /// Set this `MutNullableDom` to the given value. - pub fn set(&self, val: Option<&T>) { + pub(crate) fn set(&self, val: Option<&T>) { assert_in_script(); unsafe { *self.ptr.get() = val.map(|p| Dom::from_ref(p)); @@ -685,7 +685,7 @@ impl<T: DomObject> MutNullableDom<T> { } /// Gets the current value out of this object and sets it to `None`. - pub fn take(&self) -> Option<DomRoot<T>> { + pub(crate) fn take(&self) -> Option<DomRoot<T>> { let value = self.get(); self.set(None); value @@ -728,7 +728,7 @@ impl<T: DomObject> MallocSizeOf for MutNullableDom<T> { /// This should only be used as a field in other DOM objects; see warning /// on `Dom<T>`. #[crown::unrooted_must_root_lint::must_root] -pub struct DomOnceCell<T: DomObject> { +pub(crate) struct DomOnceCell<T: DomObject> { ptr: OnceCell<Dom<T>>, } @@ -739,7 +739,7 @@ where /// Retrieve a copy of the current inner value. If it is `None`, it is /// initialized with the result of `cb` first. #[allow(crown::unrooted_must_root)] - pub fn init_once<F>(&self, cb: F) -> &T + pub(crate) fn init_once<F>(&self, cb: F) -> &T where F: FnOnce() -> DomRoot<T>, { @@ -780,14 +780,14 @@ where { /// Returns a reference to the interior of this JS object. The fact /// that this is unsafe is what necessitates the layout wrappers. - pub fn unsafe_get(self) -> &'dom T { + pub(crate) fn unsafe_get(self) -> &'dom T { assert_in_layout(); self.value } /// Transforms a slice of `Dom<T>` into a slice of `LayoutDom<T>`. // FIXME(nox): This should probably be done through a ToLayout trait. - pub unsafe fn to_layout_slice(slice: &'dom [Dom<T>]) -> &'dom [LayoutDom<'dom, T>] { + pub(crate) unsafe fn to_layout_slice(slice: &'dom [Dom<T>]) -> &'dom [LayoutDom<'dom, T>] { // This doesn't compile if Dom and LayoutDom don't have the same // representation. let _ = mem::transmute::<Dom<T>, LayoutDom<T>>; diff --git a/components/script/dom/bindings/serializable.rs b/components/script/dom/bindings/serializable.rs index 46c6a7b5b5b..edc3b07652c 100644 --- a/components/script/dom/bindings/serializable.rs +++ b/components/script/dom/bindings/serializable.rs @@ -13,14 +13,14 @@ use crate::script_runtime::CanGc; /// The key corresponding to the storage location /// of a serialized platform object stored in a StructuredDataHolder. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -pub struct StorageKey { - pub index: u32, - pub name_space: u32, +pub(crate) struct StorageKey { + pub(crate) index: u32, + pub(crate) name_space: u32, } /// Interface for serializable platform objects. /// <https://html.spec.whatwg.org/multipage/#serializable> -pub trait Serializable: DomObject { +pub(crate) trait Serializable: DomObject { /// <https://html.spec.whatwg.org/multipage/#serialization-steps> fn serialize(&self, sc_writer: &mut StructuredDataWriter) -> Result<StorageKey, ()>; /// <https://html.spec.whatwg.org/multipage/#deserialization-steps> diff --git a/components/script/dom/bindings/settings_stack.rs b/components/script/dom/bindings/settings_stack.rs index 3c9f57b7458..c12c48f3c35 100644 --- a/components/script/dom/bindings/settings_stack.rs +++ b/components/script/dom/bindings/settings_stack.rs @@ -29,18 +29,18 @@ struct StackEntry { } /// Traces the script settings stack. -pub unsafe fn trace(tracer: *mut JSTracer) { +pub(crate) unsafe fn trace(tracer: *mut JSTracer) { STACK.with(|stack| { stack.borrow().trace(tracer); }) } -pub fn is_execution_stack_empty() -> bool { +pub(crate) fn is_execution_stack_empty() -> bool { STACK.with(|stack| stack.borrow().is_empty()) } /// RAII struct that pushes and pops entries from the script settings stack. -pub struct AutoEntryScript { +pub(crate) struct AutoEntryScript { global: DomRoot<GlobalScope>, #[cfg(feature = "tracing")] span: tracing::span::EnteredSpan, @@ -48,7 +48,7 @@ pub struct AutoEntryScript { impl AutoEntryScript { /// <https://html.spec.whatwg.org/multipage/#prepare-to-run-script> - pub fn new(global: &GlobalScope) -> Self { + pub(crate) fn new(global: &GlobalScope) -> Self { STACK.with(|stack| { trace!("Prepare to run script with {:p}", global); let mut stack = stack.borrow_mut(); @@ -94,7 +94,7 @@ impl Drop for AutoEntryScript { /// Returns the ["entry"] global object. /// /// ["entry"]: https://html.spec.whatwg.org/multipage/#entry -pub fn entry_global() -> DomRoot<GlobalScope> { +pub(crate) fn entry_global() -> DomRoot<GlobalScope> { STACK .with(|stack| { stack @@ -108,13 +108,13 @@ pub fn entry_global() -> DomRoot<GlobalScope> { } /// RAII struct that pushes and pops entries from the script settings stack. -pub struct AutoIncumbentScript { +pub(crate) struct AutoIncumbentScript { global: usize, } impl AutoIncumbentScript { /// <https://html.spec.whatwg.org/multipage/#prepare-to-run-a-callback> - pub fn new(global: &GlobalScope) -> Self { + pub(crate) fn new(global: &GlobalScope) -> Self { // Step 2-3. unsafe { let cx = @@ -166,7 +166,7 @@ impl Drop for AutoIncumbentScript { /// Returns the ["incumbent"] global object. /// /// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent -pub fn incumbent_global() -> Option<DomRoot<GlobalScope>> { +pub(crate) fn incumbent_global() -> Option<DomRoot<GlobalScope>> { // https://html.spec.whatwg.org/multipage/#incumbent-settings-object // Step 1, 3: See what the JS engine has to say. If we've got a scripted diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index 44e8466adda..64f180951cf 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -31,22 +31,22 @@ impl ByteString { /// Returns `self` as a string, if it encodes valid UTF-8, and `None` /// otherwise. - pub fn as_str(&self) -> Option<&str> { + pub(crate) fn as_str(&self) -> Option<&str> { str::from_utf8(&self.0).ok() } /// Returns the length. - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.0.len() } /// Checks if the ByteString is empty. - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.0.is_empty() } /// Returns `self` with A–Z replaced by a–z. - pub fn to_lower(&self) -> ByteString { + pub(crate) fn to_lower(&self) -> ByteString { ByteString::new(self.0.to_ascii_lowercase()) } } @@ -80,7 +80,7 @@ impl ops::Deref for ByteString { /// A string that is constructed from a UCS-2 buffer by replacing invalid code /// points with the replacement character. #[derive(Clone, Default, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub struct USVString(pub String); +pub(crate) struct USVString(pub(crate) String); impl Borrow<str> for USVString { #[inline] @@ -138,7 +138,7 @@ impl From<String> for USVString { /// Returns whether `s` is a `token`, as defined by /// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17). -pub fn is_token(s: &[u8]) -> bool { +pub(crate) fn is_token(s: &[u8]) -> bool { if s.is_empty() { return false; // A token must be at least a single character } @@ -195,43 +195,43 @@ pub struct DOMString(String, PhantomData<*const ()>); impl DOMString { /// Creates a new `DOMString`. - pub fn new() -> DOMString { + pub(crate) fn new() -> DOMString { DOMString(String::new(), PhantomData) } /// Creates a new `DOMString` from a `String`. - pub fn from_string(s: String) -> DOMString { + pub(crate) fn from_string(s: String) -> DOMString { DOMString(s, PhantomData) } /// Get the internal `&str` value of this [`DOMString`]. - pub fn str(&self) -> &str { + pub(crate) fn str(&self) -> &str { &self.0 } /// Appends a given string slice onto the end of this String. - pub fn push_str(&mut self, string: &str) { + pub(crate) fn push_str(&mut self, string: &str) { self.0.push_str(string) } /// Clears this `DOMString`, removing all contents. - pub fn clear(&mut self) { + pub(crate) fn clear(&mut self) { self.0.clear() } /// Shortens this String to the specified length. - pub fn truncate(&mut self, new_len: usize) { + pub(crate) fn truncate(&mut self, new_len: usize) { self.0.truncate(new_len); } /// Removes newline characters according to <https://infra.spec.whatwg.org/#strip-newlines>. - pub fn strip_newlines(&mut self) { + pub(crate) fn strip_newlines(&mut self) { self.0.retain(|c| c != '\r' && c != '\n'); } /// Removes leading and trailing ASCII whitespaces according to /// <https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace>. - pub fn strip_leading_and_trailing_ascii_whitespace(&mut self) { + pub(crate) fn strip_leading_and_trailing_ascii_whitespace(&mut self) { if self.0.is_empty() { return; } @@ -250,7 +250,7 @@ impl DOMString { } /// <https://html.spec.whatwg.org/multipage/#valid-floating-point-number> - pub fn is_valid_floating_point_number_string(&self) -> bool { + pub(crate) fn is_valid_floating_point_number_string(&self) -> bool { static RE: LazyLock<Regex> = LazyLock::new(|| { Regex::new(r"^-?(?:\d+\.\d+|\d+|\.\d+)(?:(e|E)(\+|\-)?\d+)?$").unwrap() }); @@ -259,7 +259,7 @@ impl DOMString { } /// <https://html.spec.whatwg.org/multipage/#rules-for-parsing-floating-point-number-values> - pub fn parse_floating_point_number(&self) -> Option<f64> { + pub(crate) fn parse_floating_point_number(&self) -> Option<f64> { // Steps 15-16 are telling us things about IEEE rounding modes // for floating-point significands; this code assumes the Rust // compiler already matches them in any cases where @@ -286,7 +286,7 @@ impl DOMString { /// /// <https://html.spec.whatwg.org/multipage/#best-representation-of-the-number-as-a-floating-point-number> /// <https://tc39.es/ecma262/#sec-numeric-types-number-tostring> - pub fn set_best_representation_of_the_floating_point_number(&mut self) { + pub(crate) fn set_best_representation_of_the_floating_point_number(&mut self) { if let Some(val) = self.parse_floating_point_number() { // [tc39] Step 2: If x is either +0 or -0, return "0". let parsed_value = if val.is_zero() { 0.0_f64 } else { val }; diff --git a/components/script/dom/bindings/structuredclone.rs b/components/script/dom/bindings/structuredclone.rs index 39ba918e383..b05abf2b9e9 100644 --- a/components/script/dom/bindings/structuredclone.rs +++ b/components/script/dom/bindings/structuredclone.rs @@ -255,32 +255,32 @@ static STRUCTURED_CLONE_CALLBACKS: JSStructuredCloneCallbacks = JSStructuredClon /// Reader and writer structs for results from, and inputs to, structured-data read/write operations. /// <https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data> -pub struct StructuredDataReader { +pub(crate) struct StructuredDataReader { /// A map of deserialized blobs, stored temporarily here to keep them rooted. - pub blobs: Option<HashMap<StorageKey, DomRoot<Blob>>>, + pub(crate) blobs: Option<HashMap<StorageKey, DomRoot<Blob>>>, /// A vec of transfer-received DOM ports, /// to be made available to script through a message event. - pub message_ports: Option<Vec<DomRoot<MessagePort>>>, + pub(crate) message_ports: Option<Vec<DomRoot<MessagePort>>>, /// A map of port implementations, /// used as part of the "transfer-receiving" steps of ports, /// to produce the DOM ports stored in `message_ports` above. - pub port_impls: Option<HashMap<MessagePortId, MessagePortImpl>>, + pub(crate) port_impls: Option<HashMap<MessagePortId, MessagePortImpl>>, /// A map of blob implementations, /// used as part of the "deserialize" steps of blobs, /// to produce the DOM blobs stored in `blobs` above. - pub blob_impls: Option<HashMap<BlobId, BlobImpl>>, + pub(crate) blob_impls: Option<HashMap<BlobId, BlobImpl>>, } /// A data holder for transferred and serialized objects. -pub struct StructuredDataWriter { +pub(crate) struct StructuredDataWriter { /// Transferred ports. - pub ports: Option<HashMap<MessagePortId, MessagePortImpl>>, + pub(crate) ports: Option<HashMap<MessagePortId, MessagePortImpl>>, /// Serialized blobs. - pub blobs: Option<HashMap<BlobId, BlobImpl>>, + pub(crate) blobs: Option<HashMap<BlobId, BlobImpl>>, } /// Writes a structured clone. Returns a `DataClone` error if that fails. -pub fn write( +pub(crate) fn write( cx: SafeJSContext, message: HandleValue, transfer: Option<CustomAutoRooterGuard<Vec<*mut JSObject>>>, @@ -339,7 +339,7 @@ pub fn write( /// Read structured serialized data, possibly containing transferred objects. /// Returns a vec of rooted transfer-received ports, or an error. -pub fn read( +pub(crate) fn read( global: &GlobalScope, mut data: StructuredSerializedData, rval: MutableHandleValue, diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 0132a688085..b94dba3fc7d 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -40,8 +40,8 @@ use std::ops::{Deref, DerefMut}; use crossbeam_channel::Sender; use indexmap::IndexMap; /// A trait to allow tracing (only) DOM objects. -pub use js::gc::Traceable as JSTraceable; -pub use js::gc::{RootableVec, RootedVec}; +pub(crate) use js::gc::Traceable as JSTraceable; +pub(crate) use js::gc::{RootableVec, RootedVec}; use js::glue::{CallObjectTracer, CallScriptTracer, CallStringTracer, CallValueTracer}; use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSScript, JSString, JSTracer, TraceKind}; use js::jsval::JSVal; @@ -76,7 +76,7 @@ use crate::task::TaskBox; /// /// This trait is unsafe; if it is implemented incorrectly, the GC may end up collecting objects /// that are still reachable. -pub unsafe trait CustomTraceable { +pub(crate) unsafe trait CustomTraceable { /// Trace `self`. /// /// # Safety @@ -117,7 +117,7 @@ unsafe impl<T> CustomTraceable for Sender<T> { /// SAFETY: Inner type must not impl JSTraceable #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] #[crown::trace_in_no_trace_lint::must_not_have_traceable] -pub struct NoTrace<T>(pub T); +pub(crate) struct NoTrace<T>(pub(crate) T); impl<T: Display> Display for NoTrace<T> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -148,7 +148,7 @@ impl<T: MallocSizeOf> MallocSizeOf for NoTrace<T> { /// Not all methods are reexposed, but you can access inner type via .0 #[crown::trace_in_no_trace_lint::must_not_have_traceable(0)] #[derive(Clone, Debug)] -pub struct HashMapTracedValues<K, V, S = RandomState>(pub HashMap<K, V, S>); +pub(crate) struct HashMapTracedValues<K, V, S = RandomState>(pub(crate) HashMap<K, V, S>); impl<K, V, S: Default> Default for HashMapTracedValues<K, V, S> { fn default() -> Self { @@ -160,24 +160,24 @@ impl<K, V> HashMapTracedValues<K, V, RandomState> { /// Wrapper for HashMap::new() #[inline] #[must_use] - pub fn new() -> HashMapTracedValues<K, V, RandomState> { + pub(crate) fn new() -> HashMapTracedValues<K, V, RandomState> { Self(HashMap::new()) } } impl<K, V, S> HashMapTracedValues<K, V, S> { #[inline] - pub fn iter(&self) -> std::collections::hash_map::Iter<'_, K, V> { + pub(crate) fn iter(&self) -> std::collections::hash_map::Iter<'_, K, V> { self.0.iter() } #[inline] - pub fn drain(&mut self) -> std::collections::hash_map::Drain<'_, K, V> { + pub(crate) fn drain(&mut self) -> std::collections::hash_map::Drain<'_, K, V> { self.0.drain() } #[inline] - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.0.is_empty() } } @@ -188,12 +188,12 @@ where S: BuildHasher, { #[inline] - pub fn insert(&mut self, k: K, v: V) -> Option<V> { + pub(crate) fn insert(&mut self, k: K, v: V) -> Option<V> { self.0.insert(k, v) } #[inline] - pub fn get<Q>(&self, k: &Q) -> Option<&V> + pub(crate) fn get<Q>(&self, k: &Q) -> Option<&V> where K: std::borrow::Borrow<Q>, Q: Hash + Eq + ?Sized, @@ -202,7 +202,7 @@ where } #[inline] - pub fn get_mut<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<&mut V> + pub(crate) fn get_mut<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<&mut V> where K: std::borrow::Borrow<Q>, { @@ -210,7 +210,7 @@ where } #[inline] - pub fn contains_key<Q: Hash + Eq + ?Sized>(&self, k: &Q) -> bool + pub(crate) fn contains_key<Q: Hash + Eq + ?Sized>(&self, k: &Q) -> bool where K: std::borrow::Borrow<Q>, { @@ -218,7 +218,7 @@ where } #[inline] - pub fn remove<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<V> + pub(crate) fn remove<Q: Hash + Eq + ?Sized>(&mut self, k: &Q) -> Option<V> where K: std::borrow::Borrow<Q>, { @@ -226,7 +226,7 @@ where } #[inline] - pub fn entry(&mut self, key: K) -> std::collections::hash_map::Entry<'_, K, V> { + pub(crate) fn entry(&mut self, key: K) -> std::collections::hash_map::Entry<'_, K, V> { self.0.entry(key) } } @@ -260,7 +260,7 @@ unsafe_no_jsmanaged_fields!(Reflector); #[allow(dead_code)] /// Trace a `JSScript`. -pub fn trace_script(tracer: *mut JSTracer, description: &str, script: &Heap<*mut JSScript>) { +pub(crate) fn trace_script(tracer: *mut JSTracer, description: &str, script: &Heap<*mut JSScript>) { unsafe { trace!("tracing {}", description); CallScriptTracer( @@ -273,7 +273,7 @@ pub fn trace_script(tracer: *mut JSTracer, description: &str, script: &Heap<*mut #[allow(dead_code)] /// Trace a `JSVal`. -pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) { +pub(crate) fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) { unsafe { if !val.get().is_markable() { return; @@ -290,13 +290,13 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>) /// Trace the `JSObject` held by `reflector`. #[allow(crown::unrooted_must_root)] -pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) { +pub(crate) fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) { trace!("tracing reflector {}", description); trace_object(tracer, description, reflector.rootable()) } /// Trace a `JSObject`. -pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JSObject>) { +pub(crate) fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JSObject>) { unsafe { trace!("tracing {}", description); CallObjectTracer( @@ -309,7 +309,7 @@ pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JS #[allow(dead_code)] /// Trace a `JSString`. -pub fn trace_string(tracer: *mut JSTracer, description: &str, s: &Heap<*mut JSString>) { +pub(crate) fn trace_string(tracer: *mut JSTracer, description: &str, s: &Heap<*mut JSString>) { unsafe { trace!("tracing {}", description); CallStringTracer( @@ -491,7 +491,7 @@ where /// If you have an arbitrary number of DomObjects to root, use rooted_vec!. /// If you know what you're doing, use this. #[crown::unrooted_must_root_lint::allow_unrooted_interior] -pub struct RootedTraceableBox<T: JSTraceable + 'static>(js::gc::RootedTraceableBox<T>); +pub(crate) struct RootedTraceableBox<T: JSTraceable + 'static>(js::gc::RootedTraceableBox<T>); unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> { unsafe fn trace(&self, tracer: *mut JSTracer) { @@ -501,12 +501,12 @@ unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> { impl<T: JSTraceable + 'static> RootedTraceableBox<T> { /// DomRoot a JSTraceable thing for the life of this RootedTraceableBox - pub fn new(traceable: T) -> RootedTraceableBox<T> { + pub(crate) fn new(traceable: T) -> RootedTraceableBox<T> { Self(js::gc::RootedTraceableBox::new(traceable)) } /// Consumes a boxed JSTraceable and roots it for the life of this RootedTraceableBox. - pub fn from_box(boxed_traceable: Box<T>) -> RootedTraceableBox<T> { + pub(crate) fn from_box(boxed_traceable: Box<T>) -> RootedTraceableBox<T> { Self(js::gc::RootedTraceableBox::from_box(boxed_traceable)) } } @@ -516,7 +516,7 @@ where Heap<T>: JSTraceable + 'static, T: GCMethods + Copy, { - pub fn handle(&self) -> Handle<T> { + pub(crate) fn handle(&self) -> Handle<T> { self.0.handle() } } diff --git a/components/script/dom/bindings/transferable.rs b/components/script/dom/bindings/transferable.rs index d97fc28eb52..674d652119b 100644 --- a/components/script/dom/bindings/transferable.rs +++ b/components/script/dom/bindings/transferable.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::reflector::DomObject; use crate::dom::bindings::structuredclone::{StructuredDataReader, StructuredDataWriter}; use crate::dom::globalscope::GlobalScope; -pub trait Transferable: DomObject { +pub(crate) trait Transferable: DomObject { fn transfer(&self, sc_writer: &mut StructuredDataWriter) -> Result<u64, ()>; fn transfer_receive( owner: &GlobalScope, diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 2817803504b..da583b2881b 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -55,15 +55,15 @@ use crate::script_runtime::JSContext as SafeJSContext; /// This is needed to allow using JS API types (which usually involve raw pointers) in static initializers, /// when Servo guarantees through the use of OnceLock that only one thread will ever initialize /// the value. -pub struct ThreadUnsafeOnceLock<T>(OnceLock<T>); +pub(crate) struct ThreadUnsafeOnceLock<T>(OnceLock<T>); impl<T> ThreadUnsafeOnceLock<T> { - pub const fn new() -> Self { + pub(crate) const fn new() -> Self { Self(OnceLock::new()) } /// Initialize the value inside this lock. Panics if the lock has been previously initialized. - pub fn set(&self, val: T) { + pub(crate) fn set(&self, val: T) { assert!(self.0.set(val).is_ok()); } @@ -72,7 +72,7 @@ impl<T> ThreadUnsafeOnceLock<T> { /// SAFETY: /// The caller must ensure that it does not mutate value contained inside this lock /// (using interior mutability). - pub unsafe fn get(&self) -> &T { + pub(crate) unsafe fn get(&self) -> &T { self.0.get().unwrap() } } @@ -82,15 +82,15 @@ unsafe impl<T> Send for ThreadUnsafeOnceLock<T> {} #[derive(JSTraceable, MallocSizeOf)] /// Static data associated with a global object. -pub struct GlobalStaticData { +pub(crate) struct GlobalStaticData { #[ignore_malloc_size_of = "WindowProxyHandler does not properly implement it anyway"] /// The WindowProxy proxy handler for this global. - pub windowproxy_handler: &'static WindowProxyHandler, + pub(crate) windowproxy_handler: &'static WindowProxyHandler, } impl GlobalStaticData { /// Creates a new GlobalStaticData. - pub fn new() -> GlobalStaticData { + pub(crate) fn new() -> GlobalStaticData { GlobalStaticData { windowproxy_handler: WindowProxyHandler::proxy_handler(), } @@ -99,47 +99,47 @@ impl GlobalStaticData { /// The index of the slot where the object holder of that interface's /// unforgeable members are defined. -pub const DOM_PROTO_UNFORGEABLE_HOLDER_SLOT: u32 = 0; +pub(crate) const DOM_PROTO_UNFORGEABLE_HOLDER_SLOT: u32 = 0; /// The index of the slot that contains a reference to the ProtoOrIfaceArray. // All DOM globals must have a slot at DOM_PROTOTYPE_SLOT. -pub const DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT; +pub(crate) const DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT; /// The flag set on the `JSClass`es for DOM global objects. // NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and // LSetDOMProperty. Those constants need to be changed accordingly if this value // changes. -pub const JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1; +pub(crate) const JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1; /// The struct that holds inheritance information for DOM object reflectors. #[derive(Clone, Copy)] -pub struct DOMClass { +pub(crate) struct DOMClass { /// A list of interfaces that this object implements, in order of decreasing /// derivedness. - pub interface_chain: [PrototypeList::ID; MAX_PROTO_CHAIN_LENGTH], + pub(crate) interface_chain: [PrototypeList::ID; MAX_PROTO_CHAIN_LENGTH], /// The last valid index of `interface_chain`. - pub depth: u8, + pub(crate) depth: u8, /// The type ID of that interface. - pub type_id: TopTypeId, + pub(crate) type_id: TopTypeId, /// The MallocSizeOf function wrapper for that interface. - pub malloc_size_of: unsafe fn(ops: &mut MallocSizeOfOps, *const c_void) -> usize, + pub(crate) malloc_size_of: unsafe fn(ops: &mut MallocSizeOfOps, *const c_void) -> usize, /// The `Globals` flag for this global interface, if any. - pub global: InterfaceObjectMap::Globals, + pub(crate) global: InterfaceObjectMap::Globals, } unsafe impl Sync for DOMClass {} /// The JSClass used for DOM object reflectors. #[derive(Copy)] #[repr(C)] -pub struct DOMJSClass { +pub(crate) struct DOMJSClass { /// The actual JSClass. - pub base: js::jsapi::JSClass, + pub(crate) base: js::jsapi::JSClass, /// Associated data for DOM object reflectors. - pub dom_class: DOMClass, + pub(crate) dom_class: DOMClass, } impl Clone for DOMJSClass { fn clone(&self) -> DOMJSClass { @@ -149,7 +149,7 @@ impl Clone for DOMJSClass { unsafe impl Sync for DOMJSClass {} /// Returns a JSVal representing the frozen JavaScript array -pub fn to_frozen_array<T: ToJSValConvertible>( +pub(crate) fn to_frozen_array<T: ToJSValConvertible>( convertibles: &[T], cx: SafeJSContext, rval: MutableHandleValue, @@ -162,7 +162,7 @@ pub fn to_frozen_array<T: ToJSValConvertible>( /// Returns the ProtoOrIfaceArray for the given global object. /// Fails if `global` is not a DOM global object. -pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray { +pub(crate) fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray { unsafe { assert_ne!(((*get_object_class(global)).flags & JSCLASS_DOM_GLOBAL), 0); let mut slot = UndefinedValue(); @@ -172,13 +172,13 @@ pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray } /// An array of *mut JSObject of size PROTO_OR_IFACE_LENGTH. -pub type ProtoOrIfaceArray = [*mut JSObject; PROTO_OR_IFACE_LENGTH]; +pub(crate) type ProtoOrIfaceArray = [*mut JSObject; PROTO_OR_IFACE_LENGTH]; /// Gets the property `id` on `proxy`'s prototype. If it exists, `*found` is /// set to true and `*vp` to the value, otherwise `*found` is set to false. /// /// Returns false on JSAPI failure. -pub unsafe fn get_property_on_prototype( +pub(crate) unsafe fn get_property_on_prototype( cx: *mut JSContext, proxy: HandleObject, receiver: HandleValue, @@ -205,7 +205,7 @@ pub unsafe fn get_property_on_prototype( /// Get an array index from the given `jsid`. Returns `None` if the given /// `jsid` is not an integer. -pub unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32> { +pub(crate) unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32> { let raw_id = *id; if raw_id.is_int() { return Some(raw_id.to_int() as u32); @@ -266,7 +266,7 @@ pub unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Opti /// Find the enum equivelent of a string given by `v` in `pairs`. /// Returns `Err(())` on JSAPI failure (there is a pending exception), and /// `Ok((None, value))` if there was no matching string. -pub unsafe fn find_enum_value<'a, T>( +pub(crate) unsafe fn find_enum_value<'a, T>( cx: *mut JSContext, v: HandleValue, pairs: &'a [(&'static str, T)], @@ -289,7 +289,7 @@ pub unsafe fn find_enum_value<'a, T>( /// Returns wether `obj` is a platform object using dynamic unwrap /// <https://heycam.github.io/webidl/#dfn-platform-object> #[allow(dead_code)] -pub fn is_platform_object_dynamic(obj: *mut JSObject, cx: *mut JSContext) -> bool { +pub(crate) fn is_platform_object_dynamic(obj: *mut JSObject, cx: *mut JSContext) -> bool { is_platform_object(obj, &|o| unsafe { UnwrapObjectDynamic(o, cx, /* stopAtWindowProxy = */ false) }) @@ -297,7 +297,7 @@ pub fn is_platform_object_dynamic(obj: *mut JSObject, cx: *mut JSContext) -> boo /// Returns wether `obj` is a platform object using static unwrap /// <https://heycam.github.io/webidl/#dfn-platform-object> -pub fn is_platform_object_static(obj: *mut JSObject) -> bool { +pub(crate) fn is_platform_object_static(obj: *mut JSObject) -> bool { is_platform_object(obj, &|o| unsafe { UnwrapObjectStatic(o) }) } @@ -327,7 +327,7 @@ fn is_platform_object( /// Get the property with name `property` from `object`. /// Returns `Err(())` on JSAPI failure (there is a pending exception), and /// `Ok(false)` if there was no property with the given name. -pub fn get_dictionary_property( +pub(crate) fn get_dictionary_property( cx: *mut JSContext, object: HandleObject, property: &str, @@ -374,7 +374,7 @@ pub fn get_dictionary_property( /// Set the property with name `property` from `object`. /// Returns `Err(())` on JSAPI failure, or null object, /// and Ok(()) otherwise -pub fn set_dictionary_property( +pub(crate) fn set_dictionary_property( cx: *mut JSContext, object: HandleObject, property: &str, @@ -395,7 +395,7 @@ pub fn set_dictionary_property( } /// Returns whether `proxy` has a property `id` on its prototype. -pub unsafe fn has_property_on_prototype( +pub(crate) unsafe fn has_property_on_prototype( cx: *mut JSContext, proxy: HandleObject, id: HandleId, @@ -410,7 +410,7 @@ pub unsafe fn has_property_on_prototype( } /// Drop the resources held by reserved slots of a global object -pub unsafe fn finalize_global(obj: *mut JSObject) { +pub(crate) unsafe fn finalize_global(obj: *mut JSObject) { let protolist = get_proto_or_iface_array(obj); let list = (*protolist).as_mut_ptr(); for idx in 0..PROTO_OR_IFACE_LENGTH as isize { @@ -422,7 +422,7 @@ pub unsafe fn finalize_global(obj: *mut JSObject) { } /// Trace the resources held by reserved slots of a global object -pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) { +pub(crate) unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) { let array = get_proto_or_iface_array(obj); for proto in (*array).iter() { if !proto.is_null() { @@ -436,7 +436,7 @@ pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) { } /// Enumerate lazy properties of a global object. -pub unsafe extern "C" fn enumerate_global( +pub(crate) unsafe extern "C" fn enumerate_global( cx: *mut JSContext, obj: RawHandleObject, _props: RawMutableHandleIdVector, @@ -453,7 +453,7 @@ pub unsafe extern "C" fn enumerate_global( } /// Resolve a lazy global property, for interface objects and named constructors. -pub unsafe extern "C" fn resolve_global( +pub(crate) unsafe extern "C" fn resolve_global( cx: *mut JSContext, obj: RawHandleObject, id: RawHandleId, @@ -491,7 +491,7 @@ pub unsafe extern "C" fn resolve_global( } /// Deletes the property `id` from `object`. -pub unsafe fn delete_property_by_id( +pub(crate) unsafe fn delete_property_by_id( cx: *mut JSContext, object: HandleObject, id: HandleId, @@ -564,7 +564,7 @@ unsafe fn generic_call<const EXCEPTION_TO_REJECTION: bool>( } /// Generic method of IDL interface. -pub unsafe extern "C" fn generic_method<const EXCEPTION_TO_REJECTION: bool>( +pub(crate) unsafe extern "C" fn generic_method<const EXCEPTION_TO_REJECTION: bool>( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -573,7 +573,7 @@ pub unsafe extern "C" fn generic_method<const EXCEPTION_TO_REJECTION: bool>( } /// Generic getter of IDL interface. -pub unsafe extern "C" fn generic_getter<const EXCEPTION_TO_REJECTION: bool>( +pub(crate) unsafe extern "C" fn generic_getter<const EXCEPTION_TO_REJECTION: bool>( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -582,7 +582,7 @@ pub unsafe extern "C" fn generic_getter<const EXCEPTION_TO_REJECTION: bool>( } /// Generic lenient getter of IDL interface. -pub unsafe extern "C" fn generic_lenient_getter<const EXCEPTION_TO_REJECTION: bool>( +pub(crate) unsafe extern "C" fn generic_lenient_getter<const EXCEPTION_TO_REJECTION: bool>( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -606,7 +606,7 @@ unsafe extern "C" fn call_setter( } /// Generic setter of IDL interface. -pub unsafe extern "C" fn generic_setter( +pub(crate) unsafe extern "C" fn generic_setter( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -615,7 +615,7 @@ pub unsafe extern "C" fn generic_setter( } /// Generic lenient setter of IDL interface. -pub unsafe extern "C" fn generic_lenient_setter( +pub(crate) unsafe extern "C" fn generic_lenient_setter( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -634,12 +634,12 @@ unsafe extern "C" fn instance_class_has_proto_at_depth( } #[allow(missing_docs)] // FIXME -pub const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks { +pub(crate) const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks { instanceClassMatchesProto: Some(instance_class_has_proto_at_depth), }; // Generic method for returning libc::c_void from caller -pub trait AsVoidPtr { +pub(crate) trait AsVoidPtr { fn as_void_ptr(&self) -> *const libc::c_void; } impl<T> AsVoidPtr for T { @@ -649,7 +649,7 @@ impl<T> AsVoidPtr for T { } // Generic method for returning c_char from caller -pub trait AsCCharPtrPtr { +pub(crate) trait AsCCharPtrPtr { fn as_c_char_ptr(&self) -> *const c_char; } @@ -660,7 +660,7 @@ impl AsCCharPtrPtr for [u8] { } /// <https://searchfox.org/mozilla-central/rev/7279a1df13a819be254fd4649e07c4ff93e4bd45/dom/bindings/BindingUtils.cpp#3300> -pub unsafe extern "C" fn generic_static_promise_method( +pub(crate) unsafe extern "C" fn generic_static_promise_method( cx: *mut JSContext, argc: libc::c_uint, vp: *mut JSVal, @@ -681,7 +681,7 @@ pub unsafe extern "C" fn generic_static_promise_method( /// Coverts exception to promise rejection /// /// <https://searchfox.org/mozilla-central/rev/b220e40ff2ee3d10ce68e07d8a8a577d5558e2a2/dom/bindings/BindingUtils.cpp#3315> -pub unsafe fn exception_to_promise(cx: *mut JSContext, rval: RawMutableHandleValue) -> bool { +pub(crate) unsafe fn exception_to_promise(cx: *mut JSContext, rval: RawMutableHandleValue) -> bool { rooted!(in(cx) let mut exception = UndefinedValue()); if !JS_GetPendingException(cx, exception.handle_mut()) { return false; diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs index 57bf219de4f..949da64b987 100644 --- a/components/script/dom/bindings/weakref.rs +++ b/components/script/dom/bindings/weakref.rs @@ -30,27 +30,27 @@ use crate::dom::bindings::trace::JSTraceable; /// stored for weak-referenceable bindings. We use slot 1 for holding it, /// this is unsafe for globals, we disallow weak-referenceable globals /// directly in codegen. -pub const DOM_WEAK_SLOT: u32 = 1; +pub(crate) const DOM_WEAK_SLOT: u32 = 1; /// A weak reference to a JS-managed DOM object. #[allow(crown::unrooted_must_root)] #[crown::unrooted_must_root_lint::allow_unrooted_interior] -pub struct WeakRef<T: WeakReferenceable> { +pub(crate) struct WeakRef<T: WeakReferenceable> { ptr: ptr::NonNull<WeakBox<T>>, } /// The inner box of weak references, public for the finalization in codegen. #[crown::unrooted_must_root_lint::must_root] -pub struct WeakBox<T: WeakReferenceable> { +pub(crate) struct WeakBox<T: WeakReferenceable> { /// The reference count. When it reaches zero, the `value` field should /// have already been set to `None`. The pointee contributes one to the count. - pub count: Cell<usize>, + pub(crate) count: Cell<usize>, /// The pointer to the JS-managed object, set to None when it is collected. - pub value: Cell<Option<ptr::NonNull<T>>>, + pub(crate) value: Cell<Option<ptr::NonNull<T>>>, } /// Trait implemented by weak-referenceable interfaces. -pub trait WeakReferenceable: DomObject + Sized { +pub(crate) trait WeakReferenceable: DomObject + Sized { /// Downgrade a DOM object reference to a weak one. fn downgrade(&self) -> WeakRef<Self> { unsafe { @@ -87,12 +87,12 @@ impl<T: WeakReferenceable> WeakRef<T> { /// Create a new weak reference from a `WeakReferenceable` interface instance. /// This is just a convenience wrapper around `<T as WeakReferenceable>::downgrade` /// to not have to import `WeakReferenceable`. - pub fn new(value: &T) -> Self { + pub(crate) fn new(value: &T) -> Self { value.downgrade() } /// DomRoot a weak reference. Returns `None` if the object was already collected. - pub fn root(&self) -> Option<DomRoot<T>> { + pub(crate) fn root(&self) -> Option<DomRoot<T>> { unsafe { &*self.ptr.as_ptr() } .value .get() @@ -100,7 +100,7 @@ impl<T: WeakReferenceable> WeakRef<T> { } /// Return whether the weakly-referenced object is still alive. - pub fn is_alive(&self) -> bool { + pub(crate) fn is_alive(&self) -> bool { unsafe { &*self.ptr.as_ptr() }.value.get().is_some() } } @@ -169,20 +169,20 @@ impl<T: WeakReferenceable> Drop for WeakRef<T> { /// A mutable weak reference to a JS-managed DOM object. On tracing, /// the contained weak reference is dropped if the pointee was already /// collected. -pub struct MutableWeakRef<T: WeakReferenceable> { +pub(crate) struct MutableWeakRef<T: WeakReferenceable> { cell: UnsafeCell<Option<WeakRef<T>>>, } impl<T: WeakReferenceable> MutableWeakRef<T> { /// Create a new mutable weak reference. - pub fn new(value: Option<&T>) -> MutableWeakRef<T> { + pub(crate) fn new(value: Option<&T>) -> MutableWeakRef<T> { MutableWeakRef { cell: UnsafeCell::new(value.map(WeakRef::new)), } } /// Set the pointee of a mutable weak reference. - pub fn set(&self, value: Option<&T>) { + pub(crate) fn set(&self, value: Option<&T>) { unsafe { *self.cell.get() = value.map(WeakRef::new); } @@ -190,7 +190,7 @@ impl<T: WeakReferenceable> MutableWeakRef<T> { /// DomRoot a mutable weak reference. Returns `None` if the object /// was already collected. - pub fn root(&self) -> Option<DomRoot<T>> { + pub(crate) fn root(&self) -> Option<DomRoot<T>> { unsafe { &*self.cell.get() } .as_ref() .and_then(WeakRef::root) @@ -220,19 +220,19 @@ unsafe impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> { /// only references which still point to live objects. #[crown::unrooted_must_root_lint::allow_unrooted_interior] #[derive(MallocSizeOf)] -pub struct WeakRefVec<T: WeakReferenceable> { +pub(crate) struct WeakRefVec<T: WeakReferenceable> { vec: Vec<WeakRef<T>>, } impl<T: WeakReferenceable> WeakRefVec<T> { /// Create a new vector of weak references. - pub fn new() -> Self { + pub(crate) fn new() -> Self { WeakRefVec { vec: vec![] } } /// Calls a function on each reference which still points to a /// live object. The order of the references isn't preserved. - pub fn update<F: FnMut(WeakRefEntry<T>)>(&mut self, mut f: F) { + pub(crate) fn update<F: FnMut(WeakRefEntry<T>)>(&mut self, mut f: F) { let mut i = 0; while i < self.vec.len() { if self.vec[i].is_alive() { @@ -247,7 +247,7 @@ impl<T: WeakReferenceable> WeakRefVec<T> { } /// Clears the vector of its dead references. - pub fn retain_alive(&mut self) { + pub(crate) fn retain_alive(&mut self) { self.update(|_| ()); } } @@ -269,14 +269,14 @@ impl<T: WeakReferenceable> DerefMut for WeakRefVec<T> { /// An entry of a vector of weak references. Passed to the closure /// given to `WeakRefVec::update`. #[crown::unrooted_must_root_lint::allow_unrooted_interior] -pub struct WeakRefEntry<'a, T: WeakReferenceable> { +pub(crate) struct WeakRefEntry<'a, T: WeakReferenceable> { vec: &'a mut WeakRefVec<T>, index: &'a mut usize, } impl<'a, T: WeakReferenceable + 'a> WeakRefEntry<'a, T> { /// Remove the entry from the underlying vector of weak references. - pub fn remove(self) -> WeakRef<T> { + pub(crate) fn remove(self) -> WeakRef<T> { let ref_ = self.vec.swap_remove(*self.index); mem::forget(self); ref_ @@ -298,22 +298,22 @@ impl<'a, T: WeakReferenceable + 'a> Drop for WeakRefEntry<'a, T> { } #[derive(MallocSizeOf)] -pub struct DOMTracker<T: WeakReferenceable> { +pub(crate) struct DOMTracker<T: WeakReferenceable> { dom_objects: DomRefCell<WeakRefVec<T>>, } impl<T: WeakReferenceable> DOMTracker<T> { - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self { dom_objects: DomRefCell::new(WeakRefVec::new()), } } - pub fn track(&self, dom_object: &T) { + pub(crate) fn track(&self, dom_object: &T) { self.dom_objects.borrow_mut().push(WeakRef::new(dom_object)); } - pub fn for_each<F: FnMut(DomRoot<T>)>(&self, mut f: F) { + pub(crate) fn for_each<F: FnMut(DomRoot<T>)>(&self, mut f: F) { self.dom_objects.borrow_mut().update(|weak_ref| { let root = weak_ref.root().unwrap(); f(root); diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs index 5c938690904..6a859f2e5eb 100644 --- a/components/script/dom/bindings/xmlname.rs +++ b/components/script/dom/bindings/xmlname.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::error::{Error, ErrorResult, Fallible}; use crate::dom::bindings::str::DOMString; /// Validate a qualified name. See <https://dom.spec.whatwg.org/#validate> for details. -pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult { +pub(crate) fn validate_qualified_name(qualified_name: &str) -> ErrorResult { // Step 2. match xml_name_type(qualified_name) { XMLName::Invalid => Err(Error::InvalidCharacter), @@ -21,7 +21,7 @@ pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult { /// Validate a namespace and qualified name and extract their parts. /// See <https://dom.spec.whatwg.org/#validate-and-extract> for details. -pub fn validate_and_extract( +pub(crate) fn validate_and_extract( namespace: Option<DOMString>, qualified_name: &str, ) -> Fallible<(Namespace, Option<Prefix>, LocalName)> { @@ -80,7 +80,7 @@ pub fn validate_and_extract( /// Results of `xml_name_type`. #[derive(PartialEq)] #[allow(missing_docs)] -pub enum XMLName { +pub(crate) enum XMLName { QName, Name, Invalid, @@ -88,7 +88,7 @@ pub enum XMLName { /// Check if an element name is valid. See <http://www.w3.org/TR/xml/#NT-Name> /// for details. -pub fn xml_name_type(name: &str) -> XMLName { +pub(crate) fn xml_name_type(name: &str) -> XMLName { fn is_valid_start(c: char) -> bool { matches!(c, ':' | 'A'..='Z' | @@ -163,7 +163,7 @@ pub fn xml_name_type(name: &str) -> XMLName { /// Convert a possibly-null URL to a namespace. /// /// If the URL is None, returns the empty namespace. -pub fn namespace_from_domstring(url: Option<DOMString>) -> Namespace { +pub(crate) fn namespace_from_domstring(url: Option<DOMString>) -> Namespace { match url { None => ns!(), Some(s) => Namespace::from(s), diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs index 4734e2921fa..160c7279cae 100644 --- a/components/script/dom/biquadfilternode.rs +++ b/components/script/dom/biquadfilternode.rs @@ -31,7 +31,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct BiquadFilterNode { +pub(crate) struct BiquadFilterNode { node: AudioNode, gain: Dom<AudioParam>, frequency: Dom<AudioParam>, @@ -42,7 +42,7 @@ pub struct BiquadFilterNode { impl BiquadFilterNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, options: &BiquadFilterOptions, @@ -114,7 +114,7 @@ impl BiquadFilterNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &BiquadFilterOptions, diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 5ab139f3528..d57772a523b 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -32,14 +32,14 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/FileAPI/#blob #[dom_struct] -pub struct Blob { +pub(crate) struct Blob { reflector_: Reflector, #[no_trace] blob_id: BlobId, } impl Blob { - pub fn new(global: &GlobalScope, blob_impl: BlobImpl, can_gc: CanGc) -> DomRoot<Blob> { + pub(crate) fn new(global: &GlobalScope, blob_impl: BlobImpl, can_gc: CanGc) -> DomRoot<Blob> { Self::new_with_proto(global, None, blob_impl, can_gc) } @@ -60,7 +60,7 @@ impl Blob { } #[allow(crown::unrooted_must_root)] - pub fn new_inherited(blob_impl: &BlobImpl) -> Blob { + pub(crate) fn new_inherited(blob_impl: &BlobImpl) -> Blob { Blob { reflector_: Reflector::new(), blob_id: blob_impl.blob_id(), @@ -68,23 +68,23 @@ impl Blob { } /// Get a slice to inner data, this might incur synchronous read and caching - pub fn get_bytes(&self) -> Result<Vec<u8>, ()> { + pub(crate) fn get_bytes(&self) -> Result<Vec<u8>, ()> { self.global().get_blob_bytes(&self.blob_id) } /// Get a copy of the type_string - pub fn type_string(&self) -> String { + pub(crate) fn type_string(&self) -> String { self.global().get_blob_type_string(&self.blob_id) } /// Get a FileID representing the Blob content, /// used by URL.createObjectURL - pub fn get_blob_url_id(&self) -> Uuid { + pub(crate) fn get_blob_url_id(&self) -> Uuid { self.global().get_blob_url_id(&self.blob_id) } /// <https://w3c.github.io/FileAPI/#blob-get-stream> - pub fn get_stream(&self, can_gc: CanGc) -> Fallible<DomRoot<ReadableStream>> { + pub(crate) fn get_stream(&self, can_gc: CanGc) -> Fallible<DomRoot<ReadableStream>> { self.global().get_blob_stream(&self.blob_id, can_gc) } } @@ -162,7 +162,7 @@ impl Serializable for Blob { /// Extract bytes from BlobParts, used by Blob and File constructor /// <https://w3c.github.io/FileAPI/#constructorBlob> #[allow(unsafe_code)] -pub fn blob_parts_to_bytes( +pub(crate) fn blob_parts_to_bytes( mut blobparts: Vec<ArrayBufferOrArrayBufferViewOrBlobOrString>, ) -> Result<Vec<u8>, ()> { let mut ret = vec![]; @@ -302,7 +302,7 @@ impl BlobMethods<crate::DomTypeHolder> for Blob { /// XXX: We will relax the restriction here, /// since the spec has some problem over this part. /// see <https://github.com/w3c/FileAPI/issues/43> -pub fn normalize_type_string(s: &str) -> String { +pub(crate) fn normalize_type_string(s: &str) -> String { if is_ascii_printable(s) { s.to_ascii_lowercase() // match s_lower.parse() as Result<Mime, ()> { diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index 539e800814c..bcffa8493d2 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -66,24 +66,24 @@ const BT_DESC_CONVERSION_ERROR: &str = #[derive(JSTraceable, MallocSizeOf)] #[allow(non_snake_case)] -pub struct AllowedBluetoothDevice { - pub deviceId: DOMString, - pub mayUseGATT: bool, +pub(crate) struct AllowedBluetoothDevice { + pub(crate) deviceId: DOMString, + pub(crate) mayUseGATT: bool, } #[derive(JSTraceable, MallocSizeOf)] -pub struct BluetoothExtraPermissionData { +pub(crate) struct BluetoothExtraPermissionData { allowed_devices: DomRefCell<Vec<AllowedBluetoothDevice>>, } impl BluetoothExtraPermissionData { - pub fn new() -> BluetoothExtraPermissionData { + pub(crate) fn new() -> BluetoothExtraPermissionData { BluetoothExtraPermissionData { allowed_devices: DomRefCell::new(Vec::new()), } } - pub fn add_new_allowed_device(&self, allowed_device: AllowedBluetoothDevice) { + pub(crate) fn add_new_allowed_device(&self, allowed_device: AllowedBluetoothDevice) { self.allowed_devices.borrow_mut().push(allowed_device); } @@ -91,7 +91,7 @@ impl BluetoothExtraPermissionData { self.allowed_devices.borrow() } - pub fn allowed_devices_contains_id(&self, id: DOMString) -> bool { + pub(crate) fn allowed_devices_contains_id(&self, id: DOMString) -> bool { self.allowed_devices .borrow() .iter() @@ -110,7 +110,7 @@ struct BluetoothContext<T: AsyncBluetoothListener + DomObject> { receiver: Trusted<T>, } -pub trait AsyncBluetoothListener { +pub(crate) trait AsyncBluetoothListener { fn handle_response(&self, result: BluetoothResponse, promise: &Rc<Promise>, can_gc: CanGc); } @@ -138,20 +138,20 @@ where // https://webbluetoothcg.github.io/web-bluetooth/#bluetooth #[dom_struct] -pub struct Bluetooth { +pub(crate) struct Bluetooth { eventtarget: EventTarget, device_instance_map: DomRefCell<HashMap<String, Dom<BluetoothDevice>>>, } impl Bluetooth { - pub fn new_inherited() -> Bluetooth { + pub(crate) fn new_inherited() -> Bluetooth { Bluetooth { eventtarget: EventTarget::new_inherited(), device_instance_map: DomRefCell::new(HashMap::new()), } } - pub fn new(global: &GlobalScope) -> DomRoot<Bluetooth> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<Bluetooth> { reflect_dom_object(Box::new(Bluetooth::new_inherited()), global, CanGc::note()) } @@ -159,7 +159,7 @@ impl Bluetooth { self.global().as_window().bluetooth_thread() } - pub fn get_device_map(&self) -> &DomRefCell<HashMap<String, Dom<BluetoothDevice>>> { + pub(crate) fn get_device_map(&self) -> &DomRefCell<HashMap<String, Dom<BluetoothDevice>>> { &self.device_instance_map } @@ -239,7 +239,7 @@ impl Bluetooth { } } -pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>( +pub(crate) fn response_async<T: AsyncBluetoothListener + DomObject + 'static>( promise: &Rc<Promise>, receiver: &T, ) -> IpcSender<BluetoothResponseResult> { @@ -284,7 +284,7 @@ pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>( // https://webbluetoothcg.github.io/web-bluetooth/#getgattchildren #[allow(clippy::too_many_arguments)] -pub fn get_gatt_children<T, F>( +pub(crate) fn get_gatt_children<T, F>( attribute: &T, single: bool, uuid_canonicalizer: F, diff --git a/components/script/dom/bluetoothadvertisingevent.rs b/components/script/dom/bluetoothadvertisingevent.rs index a8287fef086..b33f1e17323 100644 --- a/components/script/dom/bluetoothadvertisingevent.rs +++ b/components/script/dom/bluetoothadvertisingevent.rs @@ -23,7 +23,7 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothadvertisingevent #[dom_struct] -pub struct BluetoothAdvertisingEvent { +pub(crate) struct BluetoothAdvertisingEvent { event: Event, device: Dom<BluetoothDevice>, name: Option<DOMString>, @@ -34,7 +34,7 @@ pub struct BluetoothAdvertisingEvent { #[allow(non_snake_case)] impl BluetoothAdvertisingEvent { - pub fn new_inherited( + pub(crate) fn new_inherited( device: &BluetoothDevice, name: Option<DOMString>, appearance: Option<u16>, diff --git a/components/script/dom/bluetoothcharacteristicproperties.rs b/components/script/dom/bluetoothcharacteristicproperties.rs index dd7be6e2beb..992bdac6a9f 100644 --- a/components/script/dom/bluetoothcharacteristicproperties.rs +++ b/components/script/dom/bluetoothcharacteristicproperties.rs @@ -12,7 +12,7 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties #[dom_struct] -pub struct BluetoothCharacteristicProperties { +pub(crate) struct BluetoothCharacteristicProperties { reflector_: Reflector, broadcast: bool, read: bool, @@ -28,7 +28,7 @@ pub struct BluetoothCharacteristicProperties { #[allow(non_snake_case)] impl BluetoothCharacteristicProperties { #[allow(clippy::too_many_arguments)] - pub fn new_inherited( + pub(crate) fn new_inherited( broadcast: bool, read: bool, write_without_response: bool, @@ -54,7 +54,7 @@ impl BluetoothCharacteristicProperties { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, broadcast: bool, read: bool, diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index 2848a57dd84..2906260f93f 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -45,7 +45,7 @@ struct AttributeInstanceMap { // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdevice #[dom_struct] -pub struct BluetoothDevice { +pub(crate) struct BluetoothDevice { eventtarget: EventTarget, id: DOMString, name: Option<DOMString>, @@ -56,7 +56,7 @@ pub struct BluetoothDevice { } impl BluetoothDevice { - pub fn new_inherited( + pub(crate) fn new_inherited( id: DOMString, name: Option<DOMString>, context: &Bluetooth, @@ -76,7 +76,7 @@ impl BluetoothDevice { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, id: DOMString, name: Option<DOMString>, @@ -89,7 +89,7 @@ impl BluetoothDevice { ) } - pub fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> { + pub(crate) fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> { self.gatt .or_init(|| BluetoothRemoteGATTServer::new(&self.global(), self)) } @@ -98,7 +98,7 @@ impl BluetoothDevice { DomRoot::from_ref(&self.context) } - pub fn get_or_create_service( + pub(crate) fn get_or_create_service( &self, service: &BluetoothServiceMsg, server: &BluetoothRemoteGATTServer, @@ -119,7 +119,7 @@ impl BluetoothDevice { bt_service } - pub fn get_or_create_characteristic( + pub(crate) fn get_or_create_characteristic( &self, characteristic: &BluetoothCharacteristicMsg, service: &BluetoothRemoteGATTService, @@ -155,7 +155,7 @@ impl BluetoothDevice { bt_characteristic } - pub fn is_represented_device_null(&self) -> bool { + pub(crate) fn is_represented_device_null(&self) -> bool { let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap(); self.get_bluetooth_thread() .send(BluetoothRequest::IsRepresentedDeviceNull( @@ -166,7 +166,7 @@ impl BluetoothDevice { receiver.recv().unwrap() } - pub fn get_or_create_descriptor( + pub(crate) fn get_or_create_descriptor( &self, descriptor: &BluetoothDescriptorMsg, characteristic: &BluetoothRemoteGATTCharacteristic, @@ -195,7 +195,7 @@ impl BluetoothDevice { // https://webbluetoothcg.github.io/web-bluetooth/#clean-up-the-disconnected-device #[allow(crown::unrooted_must_root)] - pub fn clean_up_disconnected_device(&self, can_gc: CanGc) { + pub(crate) fn clean_up_disconnected_device(&self, can_gc: CanGc) { // Step 1. self.get_gatt().set_connected(false); @@ -231,7 +231,7 @@ impl BluetoothDevice { // https://webbluetoothcg.github.io/web-bluetooth/#garbage-collect-the-connection #[allow(crown::unrooted_must_root)] - pub fn garbage_collect_the_connection(&self) -> ErrorResult { + pub(crate) fn garbage_collect_the_connection(&self) -> ErrorResult { // Step 1: TODO: Check if other systems using this device. // Step 2. diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs index d4ee404fea1..d5817e7c901 100644 --- a/components/script/dom/bluetoothpermissionresult.rs +++ b/components/script/dom/bluetoothpermissionresult.rs @@ -29,7 +29,7 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothpermissionresult #[dom_struct] -pub struct BluetoothPermissionResult { +pub(crate) struct BluetoothPermissionResult { status: PermissionStatus, devices: DomRefCell<Vec<Dom<BluetoothDevice>>>, } @@ -45,7 +45,7 @@ impl BluetoothPermissionResult { result } - pub fn new( + pub(crate) fn new( global: &GlobalScope, status: &PermissionStatus, ) -> DomRoot<BluetoothPermissionResult> { @@ -56,28 +56,28 @@ impl BluetoothPermissionResult { ) } - pub fn get_bluetooth(&self) -> DomRoot<Bluetooth> { + pub(crate) fn get_bluetooth(&self) -> DomRoot<Bluetooth> { self.global().as_window().Navigator().Bluetooth() } - pub fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { + pub(crate) fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { self.global().as_window().bluetooth_thread() } - pub fn get_query(&self) -> PermissionName { + pub(crate) fn get_query(&self) -> PermissionName { self.status.get_query() } - pub fn set_state(&self, state: PermissionState) { + pub(crate) fn set_state(&self, state: PermissionState) { self.status.set_state(state) } - pub fn get_state(&self) -> PermissionState { + pub(crate) fn get_state(&self) -> PermissionState { self.status.State() } #[allow(crown::unrooted_must_root)] - pub fn set_devices(&self, devices: Vec<Dom<BluetoothDevice>>) { + pub(crate) fn set_devices(&self, devices: Vec<Dom<BluetoothDevice>>) { *self.devices.borrow_mut() = devices; } } diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 86f50eb464a..9792cd446f4 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -34,11 +34,11 @@ use crate::script_runtime::CanGc; // Maximum length of an attribute value. // https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 2169) -pub const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512; +pub(crate) const MAXIMUM_ATTRIBUTE_LENGTH: usize = 512; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic #[dom_struct] -pub struct BluetoothRemoteGATTCharacteristic { +pub(crate) struct BluetoothRemoteGATTCharacteristic { eventtarget: EventTarget, service: Dom<BluetoothRemoteGATTService>, uuid: DOMString, @@ -48,7 +48,7 @@ pub struct BluetoothRemoteGATTCharacteristic { } impl BluetoothRemoteGATTCharacteristic { - pub fn new_inherited( + pub(crate) fn new_inherited( service: &BluetoothRemoteGATTService, uuid: DOMString, properties: &BluetoothCharacteristicProperties, @@ -64,7 +64,7 @@ impl BluetoothRemoteGATTCharacteristic { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, service: &BluetoothRemoteGATTService, uuid: DOMString, diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index d0b810fd1e4..ffdaa22ad19 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -30,7 +30,7 @@ use crate::script_runtime::CanGc; // http://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattdescriptor #[dom_struct] -pub struct BluetoothRemoteGATTDescriptor { +pub(crate) struct BluetoothRemoteGATTDescriptor { reflector_: Reflector, characteristic: Dom<BluetoothRemoteGATTCharacteristic>, uuid: DOMString, @@ -39,7 +39,7 @@ pub struct BluetoothRemoteGATTDescriptor { } impl BluetoothRemoteGATTDescriptor { - pub fn new_inherited( + pub(crate) fn new_inherited( characteristic: &BluetoothRemoteGATTCharacteristic, uuid: DOMString, instance_id: String, @@ -53,7 +53,7 @@ impl BluetoothRemoteGATTDescriptor { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, characteristic: &BluetoothRemoteGATTCharacteristic, uuid: DOMString, diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index bbcead3cbe1..ac08035fe91 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -24,14 +24,14 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver #[dom_struct] -pub struct BluetoothRemoteGATTServer { +pub(crate) struct BluetoothRemoteGATTServer { reflector_: Reflector, device: Dom<BluetoothDevice>, connected: Cell<bool>, } impl BluetoothRemoteGATTServer { - pub fn new_inherited(device: &BluetoothDevice) -> BluetoothRemoteGATTServer { + pub(crate) fn new_inherited(device: &BluetoothDevice) -> BluetoothRemoteGATTServer { BluetoothRemoteGATTServer { reflector_: Reflector::new(), device: Dom::from_ref(device), @@ -39,7 +39,7 @@ impl BluetoothRemoteGATTServer { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, device: &BluetoothDevice, ) -> DomRoot<BluetoothRemoteGATTServer> { @@ -54,7 +54,7 @@ impl BluetoothRemoteGATTServer { self.global().as_window().bluetooth_thread() } - pub fn set_connected(&self, connected: bool) { + pub(crate) fn set_connected(&self, connected: bool) { self.connected.set(connected); } } diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index 223aaf0c0fe..014f78d2669 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -23,7 +23,7 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice #[dom_struct] -pub struct BluetoothRemoteGATTService { +pub(crate) struct BluetoothRemoteGATTService { eventtarget: EventTarget, device: Dom<BluetoothDevice>, uuid: DOMString, @@ -32,7 +32,7 @@ pub struct BluetoothRemoteGATTService { } impl BluetoothRemoteGATTService { - pub fn new_inherited( + pub(crate) fn new_inherited( device: &BluetoothDevice, uuid: DOMString, is_primary: bool, @@ -48,7 +48,7 @@ impl BluetoothRemoteGATTService { } #[allow(non_snake_case)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, device: &BluetoothDevice, uuid: DOMString, diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index e39937d3b3d..719625eb659 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -14,14 +14,14 @@ use crate::dom::bindings::str::DOMString; use crate::dom::window::Window; #[allow(clippy::upper_case_acronyms)] -pub type UUID = DOMString; -pub type BluetoothServiceUUID = StringOrUnsignedLong; -pub type BluetoothCharacteristicUUID = StringOrUnsignedLong; -pub type BluetoothDescriptorUUID = StringOrUnsignedLong; +pub(crate) type UUID = DOMString; +pub(crate) type BluetoothServiceUUID = StringOrUnsignedLong; +pub(crate) type BluetoothCharacteristicUUID = StringOrUnsignedLong; +pub(crate) type BluetoothDescriptorUUID = StringOrUnsignedLong; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid #[dom_struct] -pub struct BluetoothUUID { +pub(crate) struct BluetoothUUID { reflector_: Reflector, } @@ -607,11 +607,11 @@ impl BluetoothUUIDMethods<crate::DomTypeHolder> for BluetoothUUID { } impl BluetoothUUID { - pub fn service(name: BluetoothServiceUUID) -> Fallible<UUID> { + pub(crate) fn service(name: BluetoothServiceUUID) -> Fallible<UUID> { resolve_uuid_name(name, BLUETOOTH_ASSIGNED_SERVICES, SERVICE_PREFIX) } - pub fn characteristic(name: BluetoothCharacteristicUUID) -> Fallible<UUID> { + pub(crate) fn characteristic(name: BluetoothCharacteristicUUID) -> Fallible<UUID> { resolve_uuid_name( name, BLUETOOTH_ASSIGNED_CHARCTERISTICS, @@ -619,7 +619,7 @@ impl BluetoothUUID { ) } - pub fn descriptor(name: BluetoothDescriptorUUID) -> Fallible<UUID> { + pub(crate) fn descriptor(name: BluetoothDescriptorUUID) -> Fallible<UUID> { resolve_uuid_name(name, BLUETOOTH_ASSIGNED_DESCRIPTORS, DESCRIPTOR_PREFIX) } } diff --git a/components/script/dom/broadcastchannel.rs b/components/script/dom/broadcastchannel.rs index dd0699ff895..632825b1412 100644 --- a/components/script/dom/broadcastchannel.rs +++ b/components/script/dom/broadcastchannel.rs @@ -20,7 +20,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; #[dom_struct] -pub struct BroadcastChannel { +pub(crate) struct BroadcastChannel { eventtarget: EventTarget, name: DOMString, closed: Cell<bool>, @@ -45,7 +45,7 @@ impl BroadcastChannel { channel } - pub fn new_inherited(name: DOMString) -> BroadcastChannel { + pub(crate) fn new_inherited(name: DOMString) -> BroadcastChannel { BroadcastChannel { eventtarget: EventTarget::new_inherited(), name, @@ -56,12 +56,12 @@ impl BroadcastChannel { /// The unique Id of this channel. /// Used for filtering out the sender from the local broadcast. - pub fn id(&self) -> &Uuid { + pub(crate) fn id(&self) -> &Uuid { &self.id } /// Is this channel closed? - pub fn closed(&self) -> bool { + pub(crate) fn closed(&self) -> bool { self.closed.get() } } diff --git a/components/script/dom/bytelengthqueuingstrategy.rs b/components/script/dom/bytelengthqueuingstrategy.rs index 55b8e4e8815..ad4375edc35 100644 --- a/components/script/dom/bytelengthqueuingstrategy.rs +++ b/components/script/dom/bytelengthqueuingstrategy.rs @@ -22,20 +22,20 @@ use crate::native_fn; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ByteLengthQueuingStrategy { +pub(crate) struct ByteLengthQueuingStrategy { reflector_: Reflector, high_water_mark: f64, } impl ByteLengthQueuingStrategy { - pub fn new_inherited(init: f64) -> Self { + pub(crate) fn new_inherited(init: f64) -> Self { Self { reflector_: Reflector::new(), high_water_mark: init, } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, proto: Option<HandleObject>, init: f64, @@ -85,7 +85,7 @@ impl ByteLengthQueuingStrategyMethods<crate::DomTypeHolder> for ByteLengthQueuin /// <https://streams.spec.whatwg.org/#byte-length-queuing-strategy-size-function> #[allow(unsafe_code)] -pub unsafe fn byte_length_queuing_strategy_size( +pub(crate) unsafe fn byte_length_queuing_strategy_size( cx: *mut JSContext, argc: u32, vp: *mut JSVal, diff --git a/components/script/dom/canvasgradient.rs b/components/script/dom/canvasgradient.rs index 2d7d1789026..690ac2fcc2c 100644 --- a/components/script/dom/canvasgradient.rs +++ b/components/script/dom/canvasgradient.rs @@ -20,7 +20,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#canvasgradient #[dom_struct] -pub struct CanvasGradient { +pub(crate) struct CanvasGradient { reflector_: Reflector, style: CanvasGradientStyle, #[no_trace] @@ -28,7 +28,7 @@ pub struct CanvasGradient { } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum CanvasGradientStyle { +pub(crate) enum CanvasGradientStyle { Linear(#[no_trace] LinearGradientStyle), Radial(#[no_trace] RadialGradientStyle), } @@ -42,7 +42,7 @@ impl CanvasGradient { } } - pub fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot<CanvasGradient> { + pub(crate) fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot<CanvasGradient> { reflect_dom_object( Box::new(CanvasGradient::new_inherited(style)), global, @@ -71,7 +71,7 @@ impl CanvasGradientMethods<crate::DomTypeHolder> for CanvasGradient { } } -pub trait ToFillOrStrokeStyle { +pub(crate) trait ToFillOrStrokeStyle { fn to_fill_or_stroke_style(self) -> FillOrStrokeStyle; } diff --git a/components/script/dom/canvaspattern.rs b/components/script/dom/canvaspattern.rs index 238c561e880..d8e59a2d7eb 100644 --- a/components/script/dom/canvaspattern.rs +++ b/components/script/dom/canvaspattern.rs @@ -14,7 +14,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#canvaspattern #[dom_struct] -pub struct CanvasPattern { +pub(crate) struct CanvasPattern { reflector_: Reflector, surface_data: Vec<u8>, #[no_trace] @@ -47,7 +47,7 @@ impl CanvasPattern { origin_clean, } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, surface_data: Vec<u8>, surface_size: Size2D<u32>, @@ -65,7 +65,7 @@ impl CanvasPattern { CanGc::note(), ) } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { self.origin_clean } } diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 889068dff96..b91680545df 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -30,7 +30,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#canvasrenderingcontext2d #[dom_struct] -pub struct CanvasRenderingContext2D { +pub(crate) struct CanvasRenderingContext2D { reflector_: Reflector, /// For rendering contexts created by an HTML canvas element, this is Some, /// for ones created by a paint worklet, this is None. @@ -39,7 +39,7 @@ pub struct CanvasRenderingContext2D { } impl CanvasRenderingContext2D { - pub fn new_inherited( + pub(crate) fn new_inherited( global: &GlobalScope, canvas: Option<&HTMLCanvasElement>, size: Size2D<u32>, @@ -54,7 +54,7 @@ impl CanvasRenderingContext2D { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, canvas: &HTMLCanvasElement, size: Size2D<u32>, @@ -68,7 +68,7 @@ impl CanvasRenderingContext2D { } // https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions - pub fn set_bitmap_dimensions(&self, size: Size2D<u32>) { + pub(crate) fn set_bitmap_dimensions(&self, size: Size2D<u32>) { self.reset_to_initial_state(); self.canvas_state .get_ipc_renderer() @@ -84,36 +84,36 @@ impl CanvasRenderingContext2D { self.canvas_state.reset_to_initial_state(); } - pub fn set_canvas_bitmap_dimensions(&self, size: Size2D<u64>) { + pub(crate) fn set_canvas_bitmap_dimensions(&self, size: Size2D<u64>) { self.canvas_state.set_bitmap_dimensions(size); } - pub fn mark_as_dirty(&self) { + pub(crate) fn mark_as_dirty(&self) { self.canvas_state.mark_as_dirty(self.canvas.as_deref()) } - pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> { + pub(crate) fn take_missing_image_urls(&self) -> Vec<ServoUrl> { std::mem::take(&mut self.canvas_state.get_missing_image_urls().borrow_mut()) } - pub fn get_canvas_id(&self) -> CanvasId { + pub(crate) fn get_canvas_id(&self) -> CanvasId { self.canvas_state.get_canvas_id() } - pub fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { + pub(crate) fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { self.canvas_state.send_canvas_2d_msg(msg) } // TODO: Remove this - pub fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> { + pub(crate) fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> { self.canvas_state.get_ipc_renderer().clone() } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { self.canvas_state.origin_is_clean() } - pub fn get_rect(&self, rect: Rect<u32>) -> Vec<u8> { + pub(crate) fn get_rect(&self, rect: Rect<u32>) -> Vec<u8> { let rect = Rect::new( Point2D::new(rect.origin.x as u64, rect.origin.y as u64), Size2D::new(rect.size.width as u64, rect.size.height as u64), @@ -127,7 +127,7 @@ impl CanvasRenderingContext2D { } } -pub trait LayoutCanvasRenderingContext2DHelpers { +pub(crate) trait LayoutCanvasRenderingContext2DHelpers { fn get_ipc_renderer(self) -> IpcSender<CanvasMsg>; fn get_canvas_id(self) -> CanvasId; } diff --git a/components/script/dom/cdatasection.rs b/components/script/dom/cdatasection.rs index 29151354044..1250eb939fc 100644 --- a/components/script/dom/cdatasection.rs +++ b/components/script/dom/cdatasection.rs @@ -12,7 +12,7 @@ use crate::dom::text::Text; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CDATASection { +pub(crate) struct CDATASection { text: Text, } @@ -23,7 +23,11 @@ impl CDATASection { } } - pub fn new(text: DOMString, document: &Document, can_gc: CanGc) -> DomRoot<CDATASection> { + pub(crate) fn new( + text: DOMString, + document: &Document, + can_gc: CanGc, + ) -> DomRoot<CDATASection> { Node::reflect_node( Box::new(CDATASection::new_inherited(text, document)), document, diff --git a/components/script/dom/channelmergernode.rs b/components/script/dom/channelmergernode.rs index db9cb5c7e55..a22d36eae91 100644 --- a/components/script/dom/channelmergernode.rs +++ b/components/script/dom/channelmergernode.rs @@ -22,13 +22,13 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ChannelMergerNode { +pub(crate) struct ChannelMergerNode { node: AudioNode, } impl ChannelMergerNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, options: &ChannelMergerOptions, @@ -57,7 +57,7 @@ impl ChannelMergerNode { Ok(ChannelMergerNode { node }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &ChannelMergerOptions, diff --git a/components/script/dom/channelsplitternode.rs b/components/script/dom/channelsplitternode.rs index a058a898c85..97f881113d9 100644 --- a/components/script/dom/channelsplitternode.rs +++ b/components/script/dom/channelsplitternode.rs @@ -21,13 +21,13 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ChannelSplitterNode { +pub(crate) struct ChannelSplitterNode { node: AudioNode, } impl ChannelSplitterNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, options: &ChannelSplitterOptions, @@ -59,7 +59,7 @@ impl ChannelSplitterNode { Ok(ChannelSplitterNode { node }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &ChannelSplitterOptions, diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index cc523e13964..381f7e4e59b 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -29,20 +29,20 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#characterdata #[dom_struct] -pub struct CharacterData { +pub(crate) struct CharacterData { node: Node, data: DomRefCell<DOMString>, } impl CharacterData { - pub fn new_inherited(data: DOMString, document: &Document) -> CharacterData { + pub(crate) fn new_inherited(data: DOMString, document: &Document) -> CharacterData { CharacterData { node: Node::new_inherited(document), data: DomRefCell::new(data), } } - pub fn clone_with_data( + pub(crate) fn clone_with_data( &self, data: DOMString, document: &Document, @@ -72,12 +72,12 @@ impl CharacterData { } #[inline] - pub fn data(&self) -> Ref<DOMString> { + pub(crate) fn data(&self) -> Ref<DOMString> { self.data.borrow() } #[inline] - pub fn append_data(&self, data: &str) { + pub(crate) fn append_data(&self, data: &str) { self.queue_mutation_record(); self.data.borrow_mut().push_str(data); self.content_changed(); @@ -291,7 +291,7 @@ impl CharacterDataMethods<crate::DomTypeHolder> for CharacterData { } } -pub trait LayoutCharacterDataHelpers<'dom> { +pub(crate) trait LayoutCharacterDataHelpers<'dom> { fn data_for_layout(self) -> &'dom str; } diff --git a/components/script/dom/client.rs b/components/script/dom/client.rs index b0bdd872722..8fefc650325 100644 --- a/components/script/dom/client.rs +++ b/components/script/dom/client.rs @@ -17,7 +17,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Client { +pub(crate) struct Client { reflector_: Reflector, active_worker: MutNullableDom<ServiceWorker>, #[no_trace] @@ -39,7 +39,7 @@ impl Client { } } - pub fn new(window: &Window) -> DomRoot<Client> { + pub(crate) fn new(window: &Window) -> DomRoot<Client> { reflect_dom_object( Box::new(Client::new_inherited(window.get_url())), window, @@ -47,16 +47,16 @@ impl Client { ) } - pub fn creation_url(&self) -> ServoUrl { + pub(crate) fn creation_url(&self) -> ServoUrl { self.url.clone() } - pub fn get_controller(&self) -> Option<DomRoot<ServiceWorker>> { + pub(crate) fn get_controller(&self) -> Option<DomRoot<ServiceWorker>> { self.active_worker.get() } #[allow(dead_code)] - pub fn set_controller(&self, worker: &ServiceWorker) { + pub(crate) fn set_controller(&self, worker: &ServiceWorker) { self.active_worker.set(Some(worker)); } } diff --git a/components/script/dom/closeevent.rs b/components/script/dom/closeevent.rs index 3b7faf97356..3237f953f69 100644 --- a/components/script/dom/closeevent.rs +++ b/components/script/dom/closeevent.rs @@ -19,7 +19,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CloseEvent { +pub(crate) struct CloseEvent { event: Event, was_clean: bool, code: u16, @@ -28,7 +28,7 @@ pub struct CloseEvent { #[allow(non_snake_case)] impl CloseEvent { - pub fn new_inherited(was_clean: bool, code: u16, reason: DOMString) -> CloseEvent { + pub(crate) fn new_inherited(was_clean: bool, code: u16, reason: DOMString) -> CloseEvent { CloseEvent { event: Event::new_inherited(), was_clean, @@ -38,7 +38,7 @@ impl CloseEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/comment.rs b/components/script/dom/comment.rs index a5b9fd4c43a..cfd75e08ae4 100644 --- a/components/script/dom/comment.rs +++ b/components/script/dom/comment.rs @@ -18,7 +18,7 @@ use crate::script_runtime::CanGc; /// An HTML comment. #[dom_struct] -pub struct Comment { +pub(crate) struct Comment { characterdata: CharacterData, } @@ -29,7 +29,7 @@ impl Comment { } } - pub fn new( + pub(crate) fn new( text: DOMString, document: &Document, proto: Option<HandleObject>, diff --git a/components/script/dom/compositionevent.rs b/components/script/dom/compositionevent.rs index 067b23ec529..65c3c0da0c2 100644 --- a/components/script/dom/compositionevent.rs +++ b/components/script/dom/compositionevent.rs @@ -18,20 +18,20 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CompositionEvent { +pub(crate) struct CompositionEvent { uievent: UIEvent, data: DOMString, } impl CompositionEvent { - pub fn new_inherited() -> CompositionEvent { + pub(crate) fn new_inherited() -> CompositionEvent { CompositionEvent { uievent: UIEvent::new_inherited(), data: DOMString::new(), } } - pub fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> { + pub(crate) fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> { reflect_dom_object( Box::new(CompositionEvent::new_inherited()), window, @@ -40,7 +40,7 @@ impl CompositionEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: bool, @@ -81,7 +81,7 @@ impl CompositionEvent { ev } - pub fn data(&self) -> &str { + pub(crate) fn data(&self) -> &str { &self.data } } diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index b45d65d210d..ae9ac12af3f 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -31,7 +31,7 @@ const MAX_LOG_DEPTH: usize = 10; const MAX_LOG_CHILDREN: usize = 15; /// <https://developer.mozilla.org/en-US/docs/Web/API/Console> -pub struct Console; +pub(crate) struct Console; impl Console { #[allow(unsafe_code)] @@ -86,7 +86,7 @@ impl Console { } // Directly logs a DOMString, without processing the message - pub fn internal_warn(global: &GlobalScope, message: DOMString) { + pub(crate) fn internal_warn(global: &GlobalScope, message: DOMString) { Console::send_string_message(global, LogLevel::Warn, String::from(message.clone())); console_message(global, message); } diff --git a/components/script/dom/constantsourcenode.rs b/components/script/dom/constantsourcenode.rs index 76735093d39..63ee0ac5dcb 100644 --- a/components/script/dom/constantsourcenode.rs +++ b/components/script/dom/constantsourcenode.rs @@ -24,7 +24,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ConstantSourceNode { +pub(crate) struct ConstantSourceNode { source_node: AudioScheduledSourceNode, offset: Dom<AudioParam>, } @@ -63,7 +63,7 @@ impl ConstantSourceNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &ConstantSourceOptions, diff --git a/components/script/dom/countqueuingstrategy.rs b/components/script/dom/countqueuingstrategy.rs index 73552c57b5b..474a17d93c3 100644 --- a/components/script/dom/countqueuingstrategy.rs +++ b/components/script/dom/countqueuingstrategy.rs @@ -20,20 +20,20 @@ use crate::script_runtime::CanGc; use crate::{native_fn, native_raw_obj_fn}; #[dom_struct] -pub struct CountQueuingStrategy { +pub(crate) struct CountQueuingStrategy { reflector_: Reflector, high_water_mark: f64, } impl CountQueuingStrategy { - pub fn new_inherited(init: f64) -> Self { + pub(crate) fn new_inherited(init: f64) -> Self { Self { reflector_: Reflector::new(), high_water_mark: init, } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, proto: Option<HandleObject>, init: f64, @@ -84,7 +84,11 @@ impl CountQueuingStrategyMethods<crate::DomTypeHolder> for CountQueuingStrategy /// <https://streams.spec.whatwg.org/#count-queuing-strategy-size-function> #[allow(unsafe_code)] -pub unsafe fn count_queuing_strategy_size(_cx: *mut JSContext, argc: u32, vp: *mut JSVal) -> bool { +pub(crate) unsafe fn count_queuing_strategy_size( + _cx: *mut JSContext, + argc: u32, + vp: *mut JSVal, +) -> bool { let args = CallArgs::from_vp(vp, argc); // Step 1.1. Return 1. args.rval().set(Int32Value(1)); @@ -95,7 +99,10 @@ pub unsafe fn count_queuing_strategy_size(_cx: *mut JSContext, argc: u32, vp: *m /// If the high water mark is not set, return the default value. /// /// <https://streams.spec.whatwg.org/#validate-and-normalize-high-water-mark> -pub fn extract_high_water_mark(strategy: &QueuingStrategy, default_hwm: f64) -> Result<f64, Error> { +pub(crate) fn extract_high_water_mark( + strategy: &QueuingStrategy, + default_hwm: f64, +) -> Result<f64, Error> { if strategy.highWaterMark.is_none() { return Ok(default_hwm); } @@ -114,7 +121,7 @@ pub fn extract_high_water_mark(strategy: &QueuingStrategy, default_hwm: f64) -> /// If the size algorithm is not set, return a fallback function which always returns 1. /// /// <https://streams.spec.whatwg.org/#make-size-algorithm-from-size-function> -pub fn extract_size_algorithm(strategy: &QueuingStrategy) -> Rc<QueuingStrategySize> { +pub(crate) fn extract_size_algorithm(strategy: &QueuingStrategy) -> Rc<QueuingStrategySize> { if strategy.size.is_none() { let cx = GlobalScope::get_cx(); let fun_obj = native_raw_obj_fn!(cx, count_queuing_strategy_size, c"size", 0, 0); diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs index df04898908f..7f3dfdac540 100644 --- a/components/script/dom/create.rs +++ b/components/script/dom/create.rs @@ -221,7 +221,7 @@ fn create_html_element( result } -pub fn create_native_html_element( +pub(crate) fn create_native_html_element( name: QualName, prefix: Option<Prefix>, document: &Document, @@ -394,7 +394,7 @@ pub fn create_native_html_element( } } -pub fn create_element( +pub(crate) fn create_element( name: QualName, is: Option<LocalName>, document: &Document, diff --git a/components/script/dom/crypto.rs b/components/script/dom/crypto.rs index f15146aaec5..fa758c06efa 100644 --- a/components/script/dom/crypto.rs +++ b/components/script/dom/crypto.rs @@ -21,7 +21,7 @@ use crate::script_runtime::{CanGc, JSContext}; // https://developer.mozilla.org/en-US/docs/Web/API/Crypto #[dom_struct] -pub struct Crypto { +pub(crate) struct Crypto { reflector_: Reflector, #[no_trace] rng: DomRefCell<ServoRng>, @@ -37,7 +37,7 @@ impl Crypto { } } - pub fn new(global: &GlobalScope) -> DomRoot<Crypto> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<Crypto> { reflect_dom_object(Box::new(Crypto::new_inherited()), global, CanGc::note()) } } diff --git a/components/script/dom/cryptokey.rs b/components/script/dom/cryptokey.rs index 45fc70814bd..1e149c6773e 100644 --- a/components/script/dom/cryptokey.rs +++ b/components/script/dom/cryptokey.rs @@ -22,7 +22,7 @@ use crate::script_runtime::{CanGc, JSContext}; /// The underlying cryptographic data this key represents #[allow(dead_code)] #[derive(MallocSizeOf)] -pub enum Handle { +pub(crate) enum Handle { Aes128(Vec<u8>), Aes192(Vec<u8>), Aes256(Vec<u8>), @@ -33,7 +33,7 @@ pub enum Handle { /// <https://w3c.github.io/webcrypto/#cryptokey-interface> #[dom_struct] -pub struct CryptoKey { +pub(crate) struct CryptoKey { reflector_: Reflector, /// <https://w3c.github.io/webcrypto/#dom-cryptokey-type> @@ -78,7 +78,7 @@ impl CryptoKey { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, key_type: KeyType, extractable: bool, @@ -104,15 +104,15 @@ impl CryptoKey { object } - pub fn algorithm(&self) -> String { + pub(crate) fn algorithm(&self) -> String { self.algorithm.to_string() } - pub fn usages(&self) -> &[KeyUsage] { + pub(crate) fn usages(&self) -> &[KeyUsage] { &self.usages } - pub fn handle(&self) -> &Handle { + pub(crate) fn handle(&self) -> &Handle { &self.handle } } @@ -145,7 +145,7 @@ impl CryptoKeyMethods<crate::DomTypeHolder> for CryptoKey { } impl Handle { - pub fn as_bytes(&self) -> &[u8] { + pub(crate) fn as_bytes(&self) -> &[u8] { match self { Self::Aes128(bytes) => bytes, Self::Aes192(bytes) => bytes, diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 6105ce80629..f7fdee79350 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -21,7 +21,7 @@ use crate::dom::worklet::Worklet; #[dom_struct] #[allow(clippy::upper_case_acronyms)] -pub struct CSS { +pub(crate) struct CSS { reflector_: Reflector, } diff --git a/components/script/dom/cssconditionrule.rs b/components/script/dom/cssconditionrule.rs index 78d7cfa2524..ce1e652aa1a 100644 --- a/components/script/dom/cssconditionrule.rs +++ b/components/script/dom/cssconditionrule.rs @@ -16,12 +16,12 @@ use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::csssupportsrule::CSSSupportsRule; #[dom_struct] -pub struct CSSConditionRule { +pub(crate) struct CSSConditionRule { cssgroupingrule: CSSGroupingRule, } impl CSSConditionRule { - pub fn new_inherited( + pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, rules: Arc<Locked<StyleCssRules>>, ) -> CSSConditionRule { @@ -30,11 +30,11 @@ impl CSSConditionRule { } } - pub fn parent_stylesheet(&self) -> &CSSStyleSheet { + pub(crate) fn parent_stylesheet(&self) -> &CSSStyleSheet { self.cssgroupingrule.parent_stylesheet() } - pub fn shared_lock(&self) -> &SharedRwLock { + pub(crate) fn shared_lock(&self) -> &SharedRwLock { self.cssgroupingrule.shared_lock() } } diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index d0eee47ea91..da63e604e60 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -16,7 +16,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSFontFaceRule { +pub(crate) struct CSSFontFaceRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -35,7 +35,7 @@ impl CSSFontFaceRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, fontfacerule: Arc<Locked<FontFaceRule>>, diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs index 8dbfd4ac7cc..1c357121e85 100644 --- a/components/script/dom/cssgroupingrule.rs +++ b/components/script/dom/cssgroupingrule.rs @@ -18,7 +18,7 @@ use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::cssstylesheet::CSSStyleSheet; #[dom_struct] -pub struct CSSGroupingRule { +pub(crate) struct CSSGroupingRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -27,7 +27,7 @@ pub struct CSSGroupingRule { } impl CSSGroupingRule { - pub fn new_inherited( + pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, rules: Arc<Locked<StyleCssRules>>, ) -> CSSGroupingRule { @@ -49,11 +49,11 @@ impl CSSGroupingRule { }) } - pub fn parent_stylesheet(&self) -> &CSSStyleSheet { + pub(crate) fn parent_stylesheet(&self) -> &CSSStyleSheet { self.cssrule.parent_stylesheet() } - pub fn shared_lock(&self) -> &SharedRwLock { + pub(crate) fn shared_lock(&self) -> &SharedRwLock { self.cssrule.shared_lock() } } diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index da63ab7df0e..f70e6182fd1 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -19,7 +19,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSImportRule { +pub(crate) struct CSSImportRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -38,7 +38,7 @@ impl CSSImportRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, import_rule: Arc<Locked<ImportRule>>, diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index ae0097ab7a9..36b14e96df6 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSKeyframeRule { +pub(crate) struct CSSKeyframeRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -41,7 +41,7 @@ impl CSSKeyframeRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, keyframerule: Arc<Locked<Keyframe>>, diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 1312dfe4eaa..f7fa24940f7 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -24,7 +24,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSKeyframesRule { +pub(crate) struct CSSKeyframesRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -45,7 +45,7 @@ impl CSSKeyframesRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, keyframesrule: Arc<Locked<KeyframesRule>>, diff --git a/components/script/dom/csslayerblockrule.rs b/components/script/dom/csslayerblockrule.rs index a3d691c563e..b9db7dbd406 100644 --- a/components/script/dom/csslayerblockrule.rs +++ b/components/script/dom/csslayerblockrule.rs @@ -19,7 +19,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSLayerBlockRule { +pub(crate) struct CSSLayerBlockRule { cssgroupingrule: CSSGroupingRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -27,7 +27,7 @@ pub struct CSSLayerBlockRule { } impl CSSLayerBlockRule { - pub fn new_inherited( + pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, layerblockrule: Arc<LayerBlockRule>, ) -> CSSLayerBlockRule { @@ -41,7 +41,7 @@ impl CSSLayerBlockRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, layerblockrule: Arc<LayerBlockRule>, diff --git a/components/script/dom/csslayerstatementrule.rs b/components/script/dom/csslayerstatementrule.rs index b4859a49b83..df14579ee61 100644 --- a/components/script/dom/csslayerstatementrule.rs +++ b/components/script/dom/csslayerstatementrule.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; #[dom_struct] -pub struct CSSLayerStatementRule { +pub(crate) struct CSSLayerStatementRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -28,7 +28,7 @@ pub struct CSSLayerStatementRule { } impl CSSLayerStatementRule { - pub fn new_inherited( + pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, layerstatementrule: Arc<LayerStatementRule>, ) -> CSSLayerStatementRule { @@ -39,7 +39,7 @@ impl CSSLayerStatementRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, layerstatementrule: Arc<LayerStatementRule>, diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 02753bf3b60..a4f48554cdd 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSMediaRule { +pub(crate) struct CSSMediaRule { cssconditionrule: CSSConditionRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -39,7 +39,7 @@ impl CSSMediaRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, mediarule: Arc<MediaRule>, @@ -62,7 +62,7 @@ impl CSSMediaRule { } /// <https://drafts.csswg.org/css-conditional-3/#the-cssmediarule-interface> - pub fn get_condition_text(&self) -> DOMString { + pub(crate) fn get_condition_text(&self) -> DOMString { let guard = self.cssconditionrule.shared_lock().read(); let list = self.mediarule.media_queries.read_with(&guard); list.to_css_string().into() diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index df4fcce690b..4285df722f3 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -17,7 +17,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSNamespaceRule { +pub(crate) struct CSSNamespaceRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -36,7 +36,7 @@ impl CSSNamespaceRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, namespacerule: Arc<NamespaceRule>, diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs index 6f688d5363e..5cbc002114d 100644 --- a/components/script/dom/cssrule.rs +++ b/components/script/dom/cssrule.rs @@ -27,7 +27,7 @@ use crate::dom::csssupportsrule::CSSSupportsRule; use crate::dom::window::Window; #[dom_struct] -pub struct CSSRule { +pub(crate) struct CSSRule { reflector_: Reflector, parent_stylesheet: Dom<CSSStyleSheet>, @@ -39,7 +39,7 @@ pub struct CSSRule { impl CSSRule { #[allow(crown::unrooted_must_root)] - pub fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule { + pub(crate) fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule { CSSRule { reflector_: Reflector::new(), parent_stylesheet: Dom::from_ref(parent_stylesheet), @@ -47,7 +47,7 @@ impl CSSRule { } } - pub fn as_specific(&self) -> &dyn SpecificCSSRule { + pub(crate) fn as_specific(&self) -> &dyn SpecificCSSRule { if let Some(rule) = self.downcast::<CSSStyleRule>() { rule as &dyn SpecificCSSRule } else if let Some(rule) = self.downcast::<CSSFontFaceRule>() { @@ -75,7 +75,7 @@ impl CSSRule { // Given a StyleCssRule, create a new instance of a derived class of // CSSRule based on which rule it is - pub fn new_specific( + pub(crate) fn new_specific( window: &Window, parent_stylesheet: &CSSStyleSheet, rule: StyleCssRule, @@ -125,13 +125,13 @@ impl CSSRule { } /// Sets owner sheet/rule to null - pub fn detach(&self) { + pub(crate) fn detach(&self) { self.deparent(); // should set parent rule to None when we add parent rule support } /// Sets owner sheet to null (and does the same for all children) - pub fn deparent(&self) { + pub(crate) fn deparent(&self) { self.parent_stylesheet_removed.set(true); // https://github.com/w3c/csswg-drafts/issues/722 // Spec doesn't ask us to do this, but it makes sense @@ -139,11 +139,11 @@ impl CSSRule { self.as_specific().deparent_children(); } - pub fn parent_stylesheet(&self) -> &CSSStyleSheet { + pub(crate) fn parent_stylesheet(&self) -> &CSSStyleSheet { &self.parent_stylesheet } - pub fn shared_lock(&self) -> &SharedRwLock { + pub(crate) fn shared_lock(&self) -> &SharedRwLock { &self.parent_stylesheet.style_stylesheet().shared_lock } } @@ -181,7 +181,7 @@ impl CSSRuleMethods<crate::DomTypeHolder> for CSSRule { } } -pub trait SpecificCSSRule { +pub(crate) trait SpecificCSSRule { fn ty(&self) -> CssRuleType; fn get_css(&self) -> DOMString; /// Remove parentStylesheet from all transitive children diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 92cfead1c53..6420982973c 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -39,7 +39,7 @@ impl From<RulesMutateError> for Error { } #[dom_struct] -pub struct CSSRuleList { +pub(crate) struct CSSRuleList { reflector_: Reflector, parent_stylesheet: Dom<CSSStyleSheet>, #[ignore_malloc_size_of = "Arc"] @@ -47,14 +47,17 @@ pub struct CSSRuleList { dom_rules: DomRefCell<Vec<MutNullableDom<CSSRule>>>, } -pub enum RulesSource { +pub(crate) enum RulesSource { Rules(Arc<Locked<CssRules>>), Keyframes(Arc<Locked<KeyframesRule>>), } impl CSSRuleList { #[allow(crown::unrooted_must_root)] - pub fn new_inherited(parent_stylesheet: &CSSStyleSheet, rules: RulesSource) -> CSSRuleList { + pub(crate) fn new_inherited( + parent_stylesheet: &CSSStyleSheet, + rules: RulesSource, + ) -> CSSRuleList { let guard = parent_stylesheet.shared_lock().read(); let dom_rules = match rules { RulesSource::Rules(ref rules) => rules @@ -80,7 +83,7 @@ impl CSSRuleList { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, rules: RulesSource, @@ -94,7 +97,7 @@ impl CSSRuleList { /// Should only be called for CssRules-backed rules. Use append_lazy_rule /// for keyframes-backed rules. - pub fn insert_rule( + pub(crate) fn insert_rule( &self, rule: &str, idx: u32, @@ -139,7 +142,7 @@ impl CSSRuleList { } /// In case of a keyframe rule, index must be valid. - pub fn remove_rule(&self, index: u32) -> ErrorResult { + pub(crate) fn remove_rule(&self, index: u32) -> ErrorResult { let index = index as usize; let mut guard = self.parent_stylesheet.shared_lock().write(); @@ -167,7 +170,7 @@ impl CSSRuleList { } /// Remove parent stylesheets from all children - pub fn deparent_all(&self) { + pub(crate) fn deparent_all(&self) { for rule in self.dom_rules.borrow().iter() { if let Some(r) = rule.get() { DomRoot::upcast(r).deparent() @@ -175,7 +178,7 @@ impl CSSRuleList { } } - pub fn item(&self, idx: u32) -> Option<DomRoot<CSSRule>> { + pub(crate) fn item(&self, idx: u32) -> Option<DomRoot<CSSRule>> { self.dom_rules.borrow().get(idx as usize).map(|rule| { rule.or_init(|| { let parent_stylesheet = &self.parent_stylesheet; @@ -201,7 +204,7 @@ impl CSSRuleList { /// /// Should only be called for keyframes-backed rules, use insert_rule /// for CssRules-backed rules - pub fn append_lazy_dom_rule(&self) { + pub(crate) fn append_lazy_dom_rule(&self) { if let RulesSource::Rules(..) = self.rules { panic!("Can only call append_lazy_rule with keyframes-backed CSSRules"); } diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 464938aa9da..c91ec72da68 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -34,7 +34,7 @@ use crate::script_runtime::CanGc; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface #[dom_struct] -pub struct CSSStyleDeclaration { +pub(crate) struct CSSStyleDeclaration { reflector_: Reflector, owner: CSSStyleOwner, readonly: bool, @@ -44,7 +44,7 @@ pub struct CSSStyleDeclaration { #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum CSSStyleOwner { +pub(crate) enum CSSStyleOwner { Element(Dom<Element>), CSSRule( Dom<CSSRule>, @@ -178,7 +178,7 @@ impl CSSStyleOwner { } #[derive(MallocSizeOf, PartialEq)] -pub enum CSSModificationAccess { +pub(crate) enum CSSModificationAccess { ReadWrite, Readonly, } @@ -216,7 +216,7 @@ fn remove_property(decls: &mut PropertyDeclarationBlock, id: &PropertyId) -> boo impl CSSStyleDeclaration { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( owner: CSSStyleOwner, pseudo: Option<PseudoElement>, modification_access: CSSModificationAccess, @@ -230,7 +230,7 @@ impl CSSStyleDeclaration { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &Window, owner: CSSStyleOwner, pseudo: Option<PseudoElement>, @@ -356,7 +356,7 @@ impl CSSStyleDeclaration { } } -pub static ENABLED_LONGHAND_PROPERTIES: LazyLock<Vec<LonghandId>> = LazyLock::new(|| { +pub(crate) static ENABLED_LONGHAND_PROPERTIES: LazyLock<Vec<LonghandId>> = LazyLock::new(|| { // The 'all' shorthand contains all the enabled longhands with 2 exceptions: // 'direction' and 'unicode-bidi', so these must be added afterward. let mut enabled_longhands: Vec<LonghandId> = ShorthandId::All.longhands().collect(); diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index 669c1c6779e..f0052fda1ef 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -25,7 +25,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSStyleRule { +pub(crate) struct CSSStyleRule { cssrule: CSSRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -46,7 +46,7 @@ impl CSSStyleRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, stylerule: Arc<Locked<StyleRule>>, diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 4b32453f73b..0212ea16e99 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -23,7 +23,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSStyleSheet { +pub(crate) struct CSSStyleSheet { stylesheet: StyleSheet, owner: MutNullableDom<Element>, rulelist: MutNullableDom<CSSRuleList>, @@ -51,7 +51,7 @@ impl CSSStyleSheet { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, owner: &Element, type_: DOMString, @@ -75,15 +75,15 @@ impl CSSStyleSheet { }) } - pub fn disabled(&self) -> bool { + pub(crate) fn disabled(&self) -> bool { self.style_stylesheet.disabled() } - pub fn get_owner(&self) -> Option<DomRoot<Element>> { + pub(crate) fn get_owner(&self) -> Option<DomRoot<Element>> { self.owner.get() } - pub fn set_disabled(&self, disabled: bool) { + pub(crate) fn set_disabled(&self, disabled: bool) { if self.style_stylesheet.set_disabled(disabled) && self.get_owner().is_some() { self.get_owner() .unwrap() @@ -92,23 +92,23 @@ impl CSSStyleSheet { } } - pub fn set_owner(&self, value: Option<&Element>) { + pub(crate) fn set_owner(&self, value: Option<&Element>) { self.owner.set(value); } - pub fn shared_lock(&self) -> &SharedRwLock { + pub(crate) fn shared_lock(&self) -> &SharedRwLock { &self.style_stylesheet.shared_lock } - pub fn style_stylesheet(&self) -> &StyleStyleSheet { + pub(crate) fn style_stylesheet(&self) -> &StyleStyleSheet { &self.style_stylesheet } - pub fn set_origin_clean(&self, origin_clean: bool) { + pub(crate) fn set_origin_clean(&self, origin_clean: bool) { self.origin_clean.set(origin_clean); } - pub fn medialist(&self) -> DomRoot<MediaList> { + pub(crate) fn medialist(&self) -> DomRoot<MediaList> { MediaList::new( self.global().as_window(), self, diff --git a/components/script/dom/cssstylevalue.rs b/components/script/dom/cssstylevalue.rs index 1a303634ec6..7068a33642e 100644 --- a/components/script/dom/cssstylevalue.rs +++ b/components/script/dom/cssstylevalue.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSStyleValue { +pub(crate) struct CSSStyleValue { reflector: Reflector, value: String, } @@ -27,7 +27,7 @@ impl CSSStyleValue { } } - pub fn new(global: &GlobalScope, value: String) -> DomRoot<CSSStyleValue> { + pub(crate) fn new(global: &GlobalScope, value: String) -> DomRoot<CSSStyleValue> { reflect_dom_object( Box::new(CSSStyleValue::new_inherited(value)), global, @@ -48,7 +48,7 @@ impl CSSStyleValue { /// TODO: This should really always be an absolute URL, but we currently /// return relative URLs for computed values, so we pass in a base. /// <https://github.com/servo/servo/issues/17625> - pub fn get_url(&self, base_url: ServoUrl) -> Option<ServoUrl> { + pub(crate) fn get_url(&self, base_url: ServoUrl) -> Option<ServoUrl> { let mut input = ParserInput::new(&self.value); let mut parser = Parser::new(&mut input); parser diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index ea7d734ea1f..f387daba95e 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -18,7 +18,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct CSSSupportsRule { +pub(crate) struct CSSSupportsRule { cssconditionrule: CSSConditionRule, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -38,7 +38,7 @@ impl CSSSupportsRule { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, supportsrule: Arc<SupportsRule>, @@ -54,7 +54,7 @@ impl CSSSupportsRule { } /// <https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface> - pub fn get_condition_text(&self) -> DOMString { + pub(crate) fn get_condition_text(&self) -> DOMString { self.supportsrule.condition.to_css_string().into() } } diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 0ef3ac99598..9ca7b756e06 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -53,7 +53,7 @@ use crate::script_thread::ScriptThread; /// <https://dom.spec.whatwg.org/#concept-element-custom-element-state> #[derive(Clone, Copy, Default, Eq, JSTraceable, MallocSizeOf, PartialEq)] -pub enum CustomElementState { +pub(crate) enum CustomElementState { Undefined, Failed, #[default] @@ -63,7 +63,7 @@ pub enum CustomElementState { /// <https://html.spec.whatwg.org/multipage/#customelementregistry> #[dom_struct] -pub struct CustomElementRegistry { +pub(crate) struct CustomElementRegistry { reflector_: Reflector, window: Dom<Window>, @@ -88,7 +88,7 @@ impl CustomElementRegistry { } } - pub fn new(window: &Window) -> DomRoot<CustomElementRegistry> { + pub(crate) fn new(window: &Window) -> DomRoot<CustomElementRegistry> { reflect_dom_object( Box::new(CustomElementRegistry::new_inherited(window)), window, @@ -98,12 +98,12 @@ impl CustomElementRegistry { /// Cleans up any active promises /// <https://github.com/servo/servo/issues/15318> - pub fn teardown(&self) { + pub(crate) fn teardown(&self) { self.when_defined.borrow_mut().0.clear() } /// <https://html.spec.whatwg.org/multipage/#look-up-a-custom-element-definition> - pub fn lookup_definition( + pub(crate) fn lookup_definition( &self, local_name: &LocalName, is: Option<&LocalName>, @@ -120,7 +120,7 @@ impl CustomElementRegistry { .cloned() } - pub fn lookup_definition_by_constructor( + pub(crate) fn lookup_definition_by_constructor( &self, constructor: HandleObject, ) -> Option<Rc<CustomElementDefinition>> { @@ -622,7 +622,7 @@ impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistr } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct LifecycleCallbacks { +pub(crate) struct LifecycleCallbacks { #[ignore_malloc_size_of = "Rc"] connected_callback: Option<Rc<Function>>, @@ -649,34 +649,34 @@ pub struct LifecycleCallbacks { } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum ConstructionStackEntry { +pub(crate) enum ConstructionStackEntry { Element(DomRoot<Element>), AlreadyConstructedMarker, } /// <https://html.spec.whatwg.org/multipage/#custom-element-definition> #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct CustomElementDefinition { +pub(crate) struct CustomElementDefinition { #[no_trace] - pub name: LocalName, + pub(crate) name: LocalName, #[no_trace] - pub local_name: LocalName, + pub(crate) local_name: LocalName, #[ignore_malloc_size_of = "Rc"] - pub constructor: Rc<CustomElementConstructor>, + pub(crate) constructor: Rc<CustomElementConstructor>, - pub observed_attributes: Vec<DOMString>, + pub(crate) observed_attributes: Vec<DOMString>, - pub callbacks: LifecycleCallbacks, + pub(crate) callbacks: LifecycleCallbacks, - pub construction_stack: DomRefCell<Vec<ConstructionStackEntry>>, + pub(crate) construction_stack: DomRefCell<Vec<ConstructionStackEntry>>, - pub form_associated: bool, + pub(crate) form_associated: bool, - pub disable_internals: bool, + pub(crate) disable_internals: bool, - pub disable_shadow: bool, + pub(crate) disable_shadow: bool, } impl CustomElementDefinition { @@ -705,13 +705,13 @@ impl CustomElementDefinition { } /// <https://html.spec.whatwg.org/multipage/#autonomous-custom-element> - pub fn is_autonomous(&self) -> bool { + pub(crate) fn is_autonomous(&self) -> bool { self.name == self.local_name } /// <https://dom.spec.whatwg.org/#concept-create-element> Step 6.1 #[allow(unsafe_code)] - pub fn create_element( + pub(crate) fn create_element( &self, document: &Document, prefix: Option<Prefix>, @@ -781,7 +781,11 @@ impl CustomElementDefinition { /// <https://html.spec.whatwg.org/multipage/#concept-upgrade-an-element> #[allow(unsafe_code)] -pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Element, can_gc: CanGc) { +pub(crate) fn upgrade_element( + definition: Rc<CustomElementDefinition>, + element: &Element, + can_gc: CanGc, +) { // Step 1 let state = element.get_custom_element_state(); if state != CustomElementState::Undefined && state != CustomElementState::Uncustomized { @@ -954,7 +958,7 @@ fn run_upgrade_constructor( } /// <https://html.spec.whatwg.org/multipage/#concept-try-upgrade> -pub fn try_upgrade_element(element: &Element) { +pub(crate) fn try_upgrade_element(element: &Element) { // Step 1 let document = element.owner_document(); let namespace = element.namespace(); @@ -970,7 +974,7 @@ pub fn try_upgrade_element(element: &Element) { #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum CustomElementReaction { +pub(crate) enum CustomElementReaction { Upgrade(#[ignore_malloc_size_of = "Rc"] Rc<CustomElementDefinition>), Callback( #[ignore_malloc_size_of = "Rc"] Rc<Function>, @@ -981,7 +985,7 @@ pub enum CustomElementReaction { impl CustomElementReaction { /// <https://html.spec.whatwg.org/multipage/#invoke-custom-element-reactions> #[allow(unsafe_code)] - pub fn invoke(&self, element: &Element, can_gc: CanGc) { + pub(crate) fn invoke(&self, element: &Element, can_gc: CanGc) { // Step 2.1 match *self { CustomElementReaction::Upgrade(ref definition) => { @@ -1005,7 +1009,7 @@ impl CustomElementReaction { } } -pub enum CallbackReaction { +pub(crate) enum CallbackReaction { Connected, Disconnected, Adopted(DomRoot<Document>, DomRoot<Document>), @@ -1025,14 +1029,14 @@ enum BackupElementQueueFlag { /// <https://html.spec.whatwg.org/multipage/#custom-element-reactions-stack> #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct CustomElementReactionStack { +pub(crate) struct CustomElementReactionStack { stack: DomRefCell<Vec<ElementQueue>>, backup_queue: ElementQueue, processing_backup_element_queue: Cell<BackupElementQueueFlag>, } impl CustomElementReactionStack { - pub fn new() -> CustomElementReactionStack { + pub(crate) fn new() -> CustomElementReactionStack { CustomElementReactionStack { stack: DomRefCell::new(Vec::new()), backup_queue: ElementQueue::new(), @@ -1040,11 +1044,11 @@ impl CustomElementReactionStack { } } - pub fn push_new_element_queue(&self) { + pub(crate) fn push_new_element_queue(&self) { self.stack.borrow_mut().push(ElementQueue::new()); } - pub fn pop_current_element_queue(&self, can_gc: CanGc) { + pub(crate) fn pop_current_element_queue(&self, can_gc: CanGc) { rooted_vec!(let mut stack); mem::swap(&mut *stack, &mut *self.stack.borrow_mut()); @@ -1059,7 +1063,7 @@ impl CustomElementReactionStack { /// <https://html.spec.whatwg.org/multipage/#enqueue-an-element-on-the-appropriate-element-queue> /// Step 4 - pub fn invoke_backup_element_queue(&self, can_gc: CanGc) { + pub(crate) fn invoke_backup_element_queue(&self, can_gc: CanGc) { // Step 4.1 self.backup_queue.invoke_reactions(can_gc); @@ -1069,7 +1073,7 @@ impl CustomElementReactionStack { } /// <https://html.spec.whatwg.org/multipage/#enqueue-an-element-on-the-appropriate-element-queue> - pub fn enqueue_element(&self, element: &Element) { + pub(crate) fn enqueue_element(&self, element: &Element) { if let Some(current_queue) = self.stack.borrow().last() { // Step 2 current_queue.append_element(element); @@ -1093,7 +1097,7 @@ impl CustomElementReactionStack { /// <https://html.spec.whatwg.org/multipage/#enqueue-a-custom-element-callback-reaction> #[allow(unsafe_code)] - pub fn enqueue_callback_reaction( + pub(crate) fn enqueue_callback_reaction( &self, element: &Element, reaction: CallbackReaction, @@ -1215,7 +1219,7 @@ impl CustomElementReactionStack { } /// <https://html.spec.whatwg.org/multipage/#enqueue-a-custom-element-upgrade-reaction> - pub fn enqueue_upgrade_reaction( + pub(crate) fn enqueue_upgrade_reaction( &self, element: &Element, definition: Rc<CustomElementDefinition>, @@ -1264,7 +1268,7 @@ impl ElementQueue { } /// <https://html.spec.whatwg.org/multipage/#valid-custom-element-name> -pub fn is_valid_custom_element_name(name: &str) -> bool { +pub(crate) fn is_valid_custom_element_name(name: &str) -> bool { // Custom elment names must match: // PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)* diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index 4b82f335643..c64ff183c87 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -22,7 +22,7 @@ use crate::script_runtime::{CanGc, JSContext}; // https://dom.spec.whatwg.org/#interface-customevent #[dom_struct] -pub struct CustomEvent { +pub(crate) struct CustomEvent { event: Event, #[ignore_malloc_size_of = "Defined in rust-mozjs"] detail: Heap<JSVal>, @@ -36,7 +36,7 @@ impl CustomEvent { } } - pub fn new_uninitialized(global: &GlobalScope, can_gc: CanGc) -> DomRoot<CustomEvent> { + pub(crate) fn new_uninitialized(global: &GlobalScope, can_gc: CanGc) -> DomRoot<CustomEvent> { Self::new_uninitialized_with_proto(global, None, can_gc) } diff --git a/components/script/dom/datatransfer.rs b/components/script/dom/datatransfer.rs index f28d538ebd1..001d036919b 100644 --- a/components/script/dom/datatransfer.rs +++ b/components/script/dom/datatransfer.rs @@ -36,7 +36,7 @@ const VALID_EFFECTS_ALLOWED: [&str; 9] = [ ]; #[dom_struct] -pub struct DataTransfer { +pub(crate) struct DataTransfer { reflector_: Reflector, drop_effect: DomRefCell<DOMString>, effect_allowed: DomRefCell<DOMString>, @@ -60,7 +60,7 @@ impl DataTransfer { } } - pub fn new_with_proto( + pub(crate) fn new_with_proto( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, diff --git a/components/script/dom/datatransferitem.rs b/components/script/dom/datatransferitem.rs index b1d5e1d4480..c498d1f145b 100644 --- a/components/script/dom/datatransferitem.rs +++ b/components/script/dom/datatransferitem.rs @@ -19,7 +19,7 @@ use crate::drag_data_store::Kind; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DataTransferItem { +pub(crate) struct DataTransferItem { reflector_: Reflector, #[ignore_malloc_size_of = "TODO"] #[no_trace] @@ -34,7 +34,7 @@ impl DataTransferItem { } } - pub fn new(global: &GlobalScope, item: Kind) -> DomRoot<DataTransferItem> { + pub(crate) fn new(global: &GlobalScope, item: Kind) -> DomRoot<DataTransferItem> { reflect_dom_object( Box::new(DataTransferItem::new_inherited(item)), global, diff --git a/components/script/dom/datatransferitemlist.rs b/components/script/dom/datatransferitemlist.rs index 0a0c44c5e04..a52ecae3b65 100644 --- a/components/script/dom/datatransferitemlist.rs +++ b/components/script/dom/datatransferitemlist.rs @@ -21,7 +21,7 @@ use crate::drag_data_store::{Binary, DragDataStore, Kind, Mode, PlainString}; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct DataTransferItemList { +pub(crate) struct DataTransferItemList { reflector_: Reflector, #[ignore_malloc_size_of = "Rc"] #[no_trace] @@ -39,7 +39,7 @@ impl DataTransferItemList { } } - pub fn new( + pub(crate) fn new( window: &Window, data_store: Rc<RefCell<Option<DragDataStore>>>, ) -> DomRoot<DataTransferItemList> { @@ -50,7 +50,7 @@ impl DataTransferItemList { ) } - pub fn frozen_types(&self, cx: JSContext, retval: MutableHandleValue) { + pub(crate) fn frozen_types(&self, cx: JSContext, retval: MutableHandleValue) { self.frozen_types.get_or_init( || { self.data_store @@ -63,7 +63,7 @@ impl DataTransferItemList { ); } - pub fn invalidate_frozen_types(&self) { + pub(crate) fn invalidate_frozen_types(&self) { self.frozen_types.clear(); } } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 6981b806d8f..f170f8fb82c 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -61,7 +61,7 @@ use crate::task_source::{SendableTaskSource, TaskSourceName}; /// value for the duration of this object's lifetime. This ensures that the related Worker /// object only lives as long as necessary (ie. while events are being executed), while /// providing a reference that can be cloned freely. -pub struct AutoWorkerReset<'a> { +pub(crate) struct AutoWorkerReset<'a> { workerscope: &'a DedicatedWorkerGlobalScope, old_worker: Option<TrustedWorkerAddress>, } @@ -87,19 +87,19 @@ impl Drop for AutoWorkerReset<'_> { } /// Messages sent from the owning global. -pub enum DedicatedWorkerControlMsg { +pub(crate) enum DedicatedWorkerControlMsg { /// Shutdown the worker. Exit, } -pub enum DedicatedWorkerScriptMsg { +pub(crate) enum DedicatedWorkerScriptMsg { /// Standard message from a worker. CommonWorker(TrustedWorkerAddress, WorkerScriptMsg), /// Wake-up call from the task queue. WakeUp, } -pub enum MixedMessage { +pub(crate) enum MixedMessage { Worker(DedicatedWorkerScriptMsg), Devtools(DevtoolScriptControlMsg), Control(DedicatedWorkerControlMsg), @@ -174,7 +174,7 @@ unsafe_no_jsmanaged_fields!(TaskQueue<DedicatedWorkerScriptMsg>); // https://html.spec.whatwg.org/multipage/#dedicatedworkerglobalscope #[dom_struct] -pub struct DedicatedWorkerGlobalScope { +pub(crate) struct DedicatedWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, #[ignore_malloc_size_of = "Defined in std"] task_queue: TaskQueue<DedicatedWorkerScriptMsg>, @@ -516,7 +516,7 @@ impl DedicatedWorkerGlobalScope { old_worker } - pub fn image_cache(&self) -> Arc<dyn ImageCache> { + pub(crate) fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } @@ -594,7 +594,7 @@ impl DedicatedWorkerGlobalScope { // https://html.spec.whatwg.org/multipage/#runtime-script-errors-2 #[allow(unsafe_code)] - pub fn forward_error_to_worker_object(&self, error_info: ErrorInfo) { + pub(crate) fn forward_error_to_worker_object(&self, error_info: ErrorInfo) { let worker = self.worker.borrow().as_ref().unwrap().clone(); let pipeline_id = self.upcast::<GlobalScope>().pipeline_id(); let task = Box::new(task!(forward_error_to_worker_object: move || { diff --git a/components/script/dom/defaultteereadrequest.rs b/components/script/dom/defaultteereadrequest.rs index dfe5b22d045..93667b44f30 100644 --- a/components/script/dom/defaultteereadrequest.rs +++ b/components/script/dom/defaultteereadrequest.rs @@ -25,21 +25,21 @@ use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] #[allow(crown::unrooted_must_root)] -pub struct DefaultTeeReadRequestMicrotask { +pub(crate) struct DefaultTeeReadRequestMicrotask { #[ignore_malloc_size_of = "mozjs"] chunk: Box<Heap<JSVal>>, tee_read_request: Dom<DefaultTeeReadRequest>, } impl DefaultTeeReadRequestMicrotask { - pub fn microtask_chunk_steps(&self, can_gc: CanGc) { + pub(crate) fn microtask_chunk_steps(&self, can_gc: CanGc) { self.tee_read_request.chunk_steps(&self.chunk, can_gc) } } #[dom_struct] /// <https://streams.spec.whatwg.org/#ref-for-read-request%E2%91%A2> -pub struct DefaultTeeReadRequest { +pub(crate) struct DefaultTeeReadRequest { reflector_: Reflector, stream: Dom<ReadableStream>, branch_1: Dom<ReadableStream>, @@ -61,7 +61,7 @@ pub struct DefaultTeeReadRequest { impl DefaultTeeReadRequest { #[allow(clippy::too_many_arguments)] #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( stream: &ReadableStream, branch_1: &ReadableStream, branch_2: &ReadableStream, @@ -94,12 +94,12 @@ impl DefaultTeeReadRequest { } /// Call into cancel of the stream, /// <https://streams.spec.whatwg.org/#readable-stream-cancel> - pub fn stream_cancel(&self, reason: SafeHandleValue, can_gc: CanGc) { + pub(crate) fn stream_cancel(&self, reason: SafeHandleValue, can_gc: CanGc) { self.stream.cancel(reason, can_gc); } /// Enqueue a microtask to perform the chunk steps /// <https://streams.spec.whatwg.org/#ref-for-read-request-chunk-steps%E2%91%A2> - pub fn enqueue_chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) { + pub(crate) fn enqueue_chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) { // Queue a microtask to perform the following steps: let tee_read_request_chunk = DefaultTeeReadRequestMicrotask { chunk: Heap::boxed(*chunk.handle()), @@ -116,7 +116,7 @@ impl DefaultTeeReadRequest { /// <https://streams.spec.whatwg.org/#ref-for-read-request-chunk-steps%E2%91%A2> #[allow(unsafe_code)] #[allow(clippy::borrowed_box)] - pub fn chunk_steps(&self, chunk: &Box<Heap<JSVal>>, can_gc: CanGc) { + pub(crate) fn chunk_steps(&self, chunk: &Box<Heap<JSVal>>, can_gc: CanGc) { // Set readAgain to false. self.read_again.set(false); // Let chunk1 and chunk2 be chunk. @@ -181,7 +181,7 @@ impl DefaultTeeReadRequest { } } /// <https://streams.spec.whatwg.org/#read-request-close-steps> - pub fn close_steps(&self) { + pub(crate) fn close_steps(&self) { // Set reading to false. self.reading.set(false); // If canceled_1 is false, perform ! ReadableStreamDefaultControllerClose(branch_1.[[controller]]). @@ -198,7 +198,7 @@ impl DefaultTeeReadRequest { } } /// <https://streams.spec.whatwg.org/#read-request-error-steps> - pub fn error_steps(&self) { + pub(crate) fn error_steps(&self) { // Set reading to false. self.reading.set(false); } @@ -232,7 +232,7 @@ impl DefaultTeeReadRequest { stream.get_default_controller().error(error); } - pub fn pull_algorithm(&self, can_gc: CanGc) { + pub(crate) fn pull_algorithm(&self, can_gc: CanGc) { self.tee_underlying_source.pull_algorithm(can_gc); } } diff --git a/components/script/dom/defaultteeunderlyingsource.rs b/components/script/dom/defaultteeunderlyingsource.rs index 902f0986eb8..565659d7bae 100644 --- a/components/script/dom/defaultteeunderlyingsource.rs +++ b/components/script/dom/defaultteeunderlyingsource.rs @@ -22,14 +22,14 @@ use crate::dom::readablestreamdefaultreader::ReadRequest; use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] -pub enum TeeCancelAlgorithm { +pub(crate) enum TeeCancelAlgorithm { Cancel1Algorithm, Cancel2Algorithm, } #[dom_struct] /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaulttee> -pub struct DefaultTeeUnderlyingSource { +pub(crate) struct DefaultTeeUnderlyingSource { reflector_: Reflector, reader: Dom<ReadableStreamDefaultReader>, stream: Dom<ReadableStream>, @@ -60,7 +60,7 @@ impl DefaultTeeUnderlyingSource { #[allow(clippy::too_many_arguments)] #[allow(clippy::redundant_allocation)] #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( reader: &ReadableStreamDefaultReader, stream: &ReadableStream, reading: Rc<Cell<bool>>, @@ -96,18 +96,18 @@ impl DefaultTeeUnderlyingSource { ) } - pub fn set_branch_1(&self, stream: &ReadableStream) { + pub(crate) fn set_branch_1(&self, stream: &ReadableStream) { self.branch_1.set(Some(stream)); } - pub fn set_branch_2(&self, stream: &ReadableStream) { + pub(crate) fn set_branch_2(&self, stream: &ReadableStream) { self.branch_2.set(Some(stream)); } /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaulttee> /// Let pullAlgorithm be the following steps: #[allow(crown::unrooted_must_root)] - pub fn pull_algorithm(&self, can_gc: CanGc) -> Option<Result<Rc<Promise>, Error>> { + pub(crate) fn pull_algorithm(&self, can_gc: CanGc) -> Option<Result<Rc<Promise>, Error>> { // If reading is true, if self.reading.get() { // Set readAgain to true. @@ -163,7 +163,7 @@ impl DefaultTeeUnderlyingSource { /// and /// Let cancel2Algorithm be the following steps, taking a reason argument #[allow(unsafe_code)] - pub fn cancel_algorithm( + pub(crate) fn cancel_algorithm( &self, reason: SafeHandleValue, can_gc: CanGc, diff --git a/components/script/dom/dissimilaroriginlocation.rs b/components/script/dom/dissimilaroriginlocation.rs index 12b309d140c..dd108e5b2ad 100644 --- a/components/script/dom/dissimilaroriginlocation.rs +++ b/components/script/dom/dissimilaroriginlocation.rs @@ -19,7 +19,7 @@ use crate::script_runtime::CanGc; /// still need to function. #[dom_struct] -pub struct DissimilarOriginLocation { +pub(crate) struct DissimilarOriginLocation { /// The reflector. Once we have XOWs, this will have a cross-origin /// wrapper placed around it. reflector: Reflector, @@ -37,7 +37,7 @@ impl DissimilarOriginLocation { } } - pub fn new(window: &DissimilarOriginWindow) -> DomRoot<DissimilarOriginLocation> { + pub(crate) fn new(window: &DissimilarOriginWindow) -> DomRoot<DissimilarOriginLocation> { reflect_dom_object( Box::new(DissimilarOriginLocation::new_inherited(window)), window, diff --git a/components/script/dom/dissimilaroriginwindow.rs b/components/script/dom/dissimilaroriginwindow.rs index 6ec1956cc2b..bb1dd317978 100644 --- a/components/script/dom/dissimilaroriginwindow.rs +++ b/components/script/dom/dissimilaroriginwindow.rs @@ -33,7 +33,7 @@ use crate::script_runtime::JSContext; /// that throws security exceptions for most accessors. This is not a replacement /// for XOWs, but provides belt-and-braces security. #[dom_struct] -pub struct DissimilarOriginWindow { +pub(crate) struct DissimilarOriginWindow { /// The global for this window. globalscope: GlobalScope, @@ -46,7 +46,10 @@ pub struct DissimilarOriginWindow { impl DissimilarOriginWindow { #[allow(unsafe_code)] - pub fn new(global_to_clone_from: &GlobalScope, window_proxy: &WindowProxy) -> DomRoot<Self> { + pub(crate) fn new( + global_to_clone_from: &GlobalScope, + window_proxy: &WindowProxy, + ) -> DomRoot<Self> { let cx = GlobalScope::get_cx(); let win = Box::new(Self { globalscope: GlobalScope::new_inherited( @@ -74,7 +77,7 @@ impl DissimilarOriginWindow { unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) } } - pub fn window_proxy(&self) -> DomRoot<WindowProxy> { + pub(crate) fn window_proxy(&self) -> DomRoot<WindowProxy> { DomRoot::from_ref(&*self.window_proxy) } } @@ -211,7 +214,7 @@ impl DissimilarOriginWindow { } /// <https://html.spec.whatwg.org/multipage/#window-post-message-steps> - pub fn post_message( + pub(crate) fn post_message( &self, target_origin: &USVString, data: StructuredSerializedData, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index a8a5bef65b5..fa0eaf7053e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -203,13 +203,13 @@ const SPURIOUS_ANIMATION_FRAME_THRESHOLD: u8 = 5; /// The amount of time between fake `requestAnimationFrame()`s. const FAKE_REQUEST_ANIMATION_FRAME_DELAY: u64 = 16; -pub enum TouchEventResult { +pub(crate) enum TouchEventResult { Processed(bool), Forwarded, } #[derive(Clone, Copy, PartialEq)] -pub enum FireMouseEventType { +pub(crate) enum FireMouseEventType { Move, Over, Out, @@ -218,7 +218,7 @@ pub enum FireMouseEventType { } impl FireMouseEventType { - pub fn as_str(&self) -> &str { + pub(crate) fn as_str(&self) -> &str { match *self { FireMouseEventType::Move => "mousemove", FireMouseEventType::Over => "mouseover", @@ -230,7 +230,7 @@ impl FireMouseEventType { } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum IsHTMLDocument { +pub(crate) enum IsHTMLDocument { HTMLDocument, NonHTMLDocument, } @@ -247,7 +247,7 @@ enum FocusTransaction { /// Information about a declarative refresh #[derive(JSTraceable, MallocSizeOf)] -pub enum DeclarativeRefresh { +pub(crate) enum DeclarativeRefresh { PendingLoad { #[no_trace] url: ServoUrl, @@ -261,7 +261,7 @@ pub(crate) type WebGPUContextsMap = /// <https://dom.spec.whatwg.org/#document> #[dom_struct] -pub struct Document { +pub(crate) struct Document { node: Node, document_or_shadow_root: DocumentOrShadowRoot, window: Dom<Window>, @@ -503,7 +503,7 @@ pub struct Document { #[allow(non_snake_case)] impl Document { - pub fn note_node_with_dirty_descendants(&self, node: &Node) { + pub(crate) fn note_node_with_dirty_descendants(&self, node: &Node) { debug_assert!(*node.owner_doc() == *self); if !node.is_connected() { return; @@ -606,28 +606,28 @@ impl Document { .set(Some(new_dirty_root.downcast::<Element>().unwrap())); } - pub fn take_dirty_root(&self) -> Option<DomRoot<Element>> { + pub(crate) fn take_dirty_root(&self) -> Option<DomRoot<Element>> { self.dirty_root.take() } #[inline] - pub fn loader(&self) -> Ref<DocumentLoader> { + pub(crate) fn loader(&self) -> Ref<DocumentLoader> { self.loader.borrow() } #[inline] - pub fn loader_mut(&self) -> RefMut<DocumentLoader> { + pub(crate) fn loader_mut(&self) -> RefMut<DocumentLoader> { self.loader.borrow_mut() } #[inline] - pub fn has_browsing_context(&self) -> bool { + pub(crate) fn has_browsing_context(&self) -> bool { self.has_browsing_context } /// <https://html.spec.whatwg.org/multipage/#concept-document-bc> #[inline] - pub fn browsing_context(&self) -> Option<DomRoot<WindowProxy>> { + pub(crate) fn browsing_context(&self) -> Option<DomRoot<WindowProxy>> { if self.has_browsing_context { self.window.undiscarded_window_proxy() } else { @@ -636,34 +636,34 @@ impl Document { } #[inline] - pub fn window(&self) -> &Window { + pub(crate) fn window(&self) -> &Window { &self.window } #[inline] - pub fn is_html_document(&self) -> bool { + pub(crate) fn is_html_document(&self) -> bool { self.is_html_document } - pub fn is_xhtml_document(&self) -> bool { + pub(crate) fn is_xhtml_document(&self) -> bool { self.content_type.type_() == mime::APPLICATION && self.content_type.subtype().as_str() == "xhtml" && self.content_type.suffix() == Some(mime::XML) } - pub fn set_https_state(&self, https_state: HttpsState) { + pub(crate) fn set_https_state(&self, https_state: HttpsState) { self.https_state.set(https_state); } - pub fn is_fully_active(&self) -> bool { + pub(crate) fn is_fully_active(&self) -> bool { self.activity.get() == DocumentActivity::FullyActive } - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.activity.get() != DocumentActivity::Inactive } - pub fn set_activity(&self, activity: DocumentActivity) { + pub(crate) fn set_activity(&self, activity: DocumentActivity) { // This function should only be called on documents with a browsing context assert!(self.has_browsing_context); if activity == self.activity.get() { @@ -726,21 +726,21 @@ impl Document { })) } - pub fn origin(&self) -> &MutableOrigin { + pub(crate) fn origin(&self) -> &MutableOrigin { &self.origin } /// <https://dom.spec.whatwg.org/#concept-document-url> - pub fn url(&self) -> ServoUrl { + pub(crate) fn url(&self) -> ServoUrl { self.url.borrow().clone() } - pub fn set_url(&self, url: ServoUrl) { + pub(crate) fn set_url(&self, url: ServoUrl) { *self.url.borrow_mut() = url; } /// <https://html.spec.whatwg.org/multipage/#fallback-base-url> - pub fn fallback_base_url(&self) -> ServoUrl { + pub(crate) fn fallback_base_url(&self) -> ServoUrl { let document_url = self.url(); if let Some(browsing_context) = self.browsing_context() { // Step 1: If document is an iframe srcdoc document, then return the @@ -765,7 +765,7 @@ impl Document { } /// <https://html.spec.whatwg.org/multipage/#document-base-url> - pub fn base_url(&self) -> ServoUrl { + pub(crate) fn base_url(&self) -> ServoUrl { match self.base_element() { // Step 1. None => self.fallback_base_url(), @@ -778,7 +778,7 @@ impl Document { self.needs_paint.set(value) } - pub fn needs_reflow(&self) -> Option<ReflowTriggerCondition> { + pub(crate) fn needs_reflow(&self) -> Option<ReflowTriggerCondition> { // FIXME: This should check the dirty bit on the document, // not the document element. Needs some layout changes to make // that workable. @@ -803,13 +803,13 @@ impl Document { } /// Returns the first `base` element in the DOM that has an `href` attribute. - pub fn base_element(&self) -> Option<DomRoot<HTMLBaseElement>> { + pub(crate) fn base_element(&self) -> Option<DomRoot<HTMLBaseElement>> { self.base_element.get() } /// Refresh the cached first base element in the DOM. /// <https://github.com/w3c/web-platform-tests/issues/2122> - pub fn refresh_base_element(&self) { + pub(crate) fn refresh_base_element(&self) { let base = self .upcast::<Node>() .traverse_preorder(ShadowIncluding::No) @@ -822,27 +822,27 @@ impl Document { self.base_element.set(base.as_deref()); } - pub fn dom_count(&self) -> u32 { + pub(crate) fn dom_count(&self) -> u32 { self.dom_count.get() } /// This is called by `bind_to_tree` when a node is added to the DOM. /// The internal count is used by layout to determine whether to be sequential or parallel. /// (it's sequential for small DOMs) - pub fn increment_dom_count(&self) { + pub(crate) fn increment_dom_count(&self) { self.dom_count.set(self.dom_count.get() + 1); } /// This is called by `unbind_from_tree` when a node is removed from the DOM. - pub fn decrement_dom_count(&self) { + pub(crate) fn decrement_dom_count(&self) { self.dom_count.set(self.dom_count.get() - 1); } - pub fn quirks_mode(&self) -> QuirksMode { + pub(crate) fn quirks_mode(&self) -> QuirksMode { self.quirks_mode.get() } - pub fn set_quirks_mode(&self, new_mode: QuirksMode) { + pub(crate) fn set_quirks_mode(&self, new_mode: QuirksMode) { let old_mode = self.quirks_mode.replace(new_mode); if old_mode != new_mode { @@ -850,15 +850,15 @@ impl Document { } } - pub fn encoding(&self) -> &'static Encoding { + pub(crate) fn encoding(&self) -> &'static Encoding { self.encoding.get() } - pub fn set_encoding(&self, encoding: &'static Encoding) { + pub(crate) fn set_encoding(&self, encoding: &'static Encoding) { self.encoding.set(encoding); } - pub fn content_and_heritage_changed(&self, node: &Node) { + pub(crate) fn content_and_heritage_changed(&self, node: &Node) { if node.is_connected() { node.note_dirty_descendants(); } @@ -869,14 +869,14 @@ impl Document { } /// Remove any existing association between the provided id and any elements in this document. - pub fn unregister_element_id(&self, to_unregister: &Element, id: Atom) { + pub(crate) fn unregister_element_id(&self, to_unregister: &Element, id: Atom) { self.document_or_shadow_root .unregister_named_element(&self.id_map, to_unregister, &id); self.reset_form_owner_for_listeners(&id); } /// Associate an element present in this document with the provided id. - pub fn register_element_id(&self, element: &Element, id: Atom) { + pub(crate) fn register_element_id(&self, element: &Element, id: Atom) { let root = self.GetDocumentElement().expect( "The element is in the document, so there must be a document \ element.", @@ -891,13 +891,13 @@ impl Document { } /// Remove any existing association between the provided name and any elements in this document. - pub fn unregister_element_name(&self, to_unregister: &Element, name: Atom) { + pub(crate) fn unregister_element_name(&self, to_unregister: &Element, name: Atom) { self.document_or_shadow_root .unregister_named_element(&self.name_map, to_unregister, &name); } /// Associate an element present in this document with the provided name. - pub fn register_element_name(&self, element: &Element, name: Atom) { + pub(crate) fn register_element_name(&self, element: &Element, name: Atom) { let root = self.GetDocumentElement().expect( "The element is in the document, so there must be a document \ element.", @@ -910,14 +910,18 @@ impl Document { ); } - pub fn register_form_id_listener<T: ?Sized + FormControl>(&self, id: DOMString, listener: &T) { + pub(crate) fn register_form_id_listener<T: ?Sized + FormControl>( + &self, + id: DOMString, + listener: &T, + ) { let mut map = self.form_id_listener_map.borrow_mut(); let listener = listener.to_element(); let set = map.entry(Atom::from(id)).or_default(); set.insert(Dom::from_ref(listener)); } - pub fn unregister_form_id_listener<T: ?Sized + FormControl>( + pub(crate) fn unregister_form_id_listener<T: ?Sized + FormControl>( &self, id: DOMString, listener: &T, @@ -935,7 +939,7 @@ impl Document { /// Attempt to find a named element in this page's document. /// <https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document> - pub fn find_fragment_node(&self, fragid: &str) -> Option<DomRoot<Element>> { + pub(crate) fn find_fragment_node(&self, fragid: &str) -> Option<DomRoot<Element>> { // Step 1 is not handled here; the fragid is already obtained by the calling function // Step 2: Simply use None to indicate the top of the document. // Step 3 & 4 @@ -952,7 +956,7 @@ impl Document { /// Scroll to the target element, and when we do not find a target /// and the fragment is empty or "top", scroll to the top. /// <https://html.spec.whatwg.org/multipage/#scroll-to-the-fragment-identifier> - pub fn check_and_scroll_fragment(&self, fragment: &str, can_gc: CanGc) { + pub(crate) fn check_and_scroll_fragment(&self, fragment: &str, can_gc: CanGc) { let target = self.find_fragment_node(fragment); // Step 1 @@ -1006,7 +1010,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#current-document-readiness - pub fn set_ready_state(&self, state: DocumentReadyState, can_gc: CanGc) { + pub(crate) fn set_ready_state(&self, state: DocumentReadyState, can_gc: CanGc) { match state { DocumentReadyState::Loading => { if self.window().is_top_level() { @@ -1030,13 +1034,13 @@ impl Document { } /// Return whether scripting is enabled or not - pub fn is_scripting_enabled(&self) -> bool { + pub(crate) fn is_scripting_enabled(&self) -> bool { self.scripting_enabled } /// Return the element that currently has focus. // https://w3c.github.io/uievents/#events-focusevent-doc-focus - pub fn get_focused_element(&self) -> Option<DomRoot<Element>> { + pub(crate) fn get_focused_element(&self) -> Option<DomRoot<Element>> { self.focused.get() } @@ -1158,7 +1162,7 @@ impl Document { } /// Handles any updates when the document's title has changed. - pub fn title_changed(&self) { + pub(crate) fn title_changed(&self) { if self.browsing_context().is_some() { self.send_title_to_embedder(); let title = String::from(self.Title()); @@ -1204,7 +1208,7 @@ impl Document { } /// Sends this document's title to the constellation. - pub fn send_title_to_embedder(&self) { + pub(crate) fn send_title_to_embedder(&self) { let window = self.window(); if window.is_top_level() { let title = self.title().map(String::from); @@ -1217,7 +1221,7 @@ impl Document { window.send_to_embedder(msg); } - pub fn dirty_all_nodes(&self) { + pub(crate) fn dirty_all_nodes(&self) { let root = match self.GetDocumentElement() { Some(root) => root, None => return, @@ -1232,7 +1236,7 @@ impl Document { #[allow(unsafe_code)] #[allow(clippy::too_many_arguments)] - pub unsafe fn handle_mouse_button_event( + pub(crate) unsafe fn handle_mouse_button_event( &self, button: MouseButton, client_point: Point2D<f32>, @@ -1401,7 +1405,7 @@ impl Document { } #[allow(clippy::too_many_arguments)] - pub fn fire_mouse_event( + pub(crate) fn fire_mouse_event( &self, client_point: Point2D<f32>, target: &EventTarget, @@ -1440,7 +1444,7 @@ impl Document { } #[allow(unsafe_code)] - pub unsafe fn handle_mouse_move_event( + pub(crate) unsafe fn handle_mouse_move_event( &self, client_point: Point2D<f32>, prev_mouse_over_target: &MutNullableDom<Element>, @@ -1618,7 +1622,7 @@ impl Document { } #[allow(unsafe_code)] - pub unsafe fn handle_wheel_event( + pub(crate) unsafe fn handle_wheel_event( &self, delta: WheelDelta, client_point: Point2D<f32>, @@ -1666,7 +1670,7 @@ impl Document { } #[allow(unsafe_code)] - pub unsafe fn handle_touch_event( + pub(crate) unsafe fn handle_touch_event( &self, event_type: TouchEventType, touch_id: TouchId, @@ -1774,7 +1778,7 @@ impl Document { } /// The entry point for all key processing for web content - pub fn dispatch_key_event( + pub(crate) fn dispatch_key_event( &self, keyboard_event: ::keyboard_types::KeyboardEvent, can_gc: CanGc, @@ -1858,7 +1862,7 @@ impl Document { } } - pub fn ime_dismissed(&self, can_gc: CanGc) { + pub(crate) fn ime_dismissed(&self, can_gc: CanGc) { self.request_focus( self.GetBody().as_ref().map(|e| e.upcast()), FocusType::Element, @@ -1866,7 +1870,7 @@ impl Document { ) } - pub fn dispatch_composition_event( + pub(crate) fn dispatch_composition_event( &self, composition_event: ::keyboard_types::CompositionEvent, can_gc: CanGc, @@ -1900,7 +1904,7 @@ impl Document { } // https://dom.spec.whatwg.org/#converting-nodes-into-a-node - pub fn node_from_nodes_and_strings( + pub(crate) fn node_from_nodes_and_strings( &self, mut nodes: Vec<NodeOrString>, can_gc: CanGc, @@ -1931,7 +1935,7 @@ impl Document { } } - pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString { + pub(crate) fn get_body_attribute(&self, local_name: &LocalName) -> DOMString { match self .GetBody() .and_then(DomRoot::downcast::<HTMLBodyElement>) @@ -1941,7 +1945,12 @@ impl Document { } } - pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString, can_gc: CanGc) { + pub(crate) fn set_body_attribute( + &self, + local_name: &LocalName, + value: DOMString, + can_gc: CanGc, + ) { if let Some(ref body) = self .GetBody() .and_then(DomRoot::downcast::<HTMLBodyElement>) @@ -1952,26 +1961,26 @@ impl Document { } } - pub fn set_current_script(&self, script: Option<&HTMLScriptElement>) { + pub(crate) fn set_current_script(&self, script: Option<&HTMLScriptElement>) { self.current_script.set(script); } - pub fn get_script_blocking_stylesheets_count(&self) -> u32 { + pub(crate) fn get_script_blocking_stylesheets_count(&self) -> u32 { self.script_blocking_stylesheets_count.get() } - pub fn increment_script_blocking_stylesheet_count(&self) { + pub(crate) fn increment_script_blocking_stylesheet_count(&self) { let count_cell = &self.script_blocking_stylesheets_count; count_cell.set(count_cell.get() + 1); } - pub fn decrement_script_blocking_stylesheet_count(&self) { + pub(crate) fn decrement_script_blocking_stylesheet_count(&self) { let count_cell = &self.script_blocking_stylesheets_count; assert!(count_cell.get() > 0); count_cell.set(count_cell.get() - 1); } - pub fn invalidate_stylesheets(&self) { + pub(crate) fn invalidate_stylesheets(&self) { self.stylesheets.borrow_mut().force_dirty(OriginSet::all()); // Mark the document element dirty so a reflow will be performed. @@ -2105,7 +2114,7 @@ impl Document { } } - pub fn policy_container(&self) -> Ref<PolicyContainer> { + pub(crate) fn policy_container(&self) -> Ref<PolicyContainer> { self.policy_container.borrow() } @@ -2158,7 +2167,7 @@ impl Document { // https://html.spec.whatwg.org/multipage/#the-end // https://html.spec.whatwg.org/multipage/#delay-the-load-event - pub fn finish_load(&self, load: LoadType, can_gc: CanGc) { + pub(crate) fn finish_load(&self, load: LoadType, can_gc: CanGc) { // This does not delay the load event anymore. debug!("Document got finish_load: {:?}", load); self.loader.borrow_mut().finish_load(&load); @@ -2210,7 +2219,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#prompt-to-unload-a-document - pub fn prompt_to_unload(&self, recursive_flag: bool, can_gc: CanGc) -> bool { + pub(crate) fn prompt_to_unload(&self, recursive_flag: bool, can_gc: CanGc) -> bool { // TODO: Step 1, increase the event loop's termination nesting level by 1. // Step 2 self.incr_ignore_opens_during_unload_counter(); @@ -2269,7 +2278,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#unload-a-document - pub fn unload(&self, recursive_flag: bool, can_gc: CanGc) { + pub(crate) fn unload(&self, recursive_flag: bool, can_gc: CanGc) { // TODO: Step 1, increase the event loop's termination nesting level by 1. // Step 2 self.incr_ignore_opens_during_unload_counter(); @@ -2350,7 +2359,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#the-end - pub fn maybe_queue_document_completion(&self) { + pub(crate) fn maybe_queue_document_completion(&self) { // https://html.spec.whatwg.org/multipage/#delaying-load-events-mode let is_in_delaying_load_events_mode = match self.window.undiscarded_window_proxy() { Some(window_proxy) => window_proxy.is_delaying_load_events_mode(), @@ -2497,12 +2506,12 @@ impl Document { } } - pub fn completely_loaded(&self) -> bool { + pub(crate) fn completely_loaded(&self) -> bool { self.completely_loaded.get() } // https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script - pub fn set_pending_parsing_blocking_script( + pub(crate) fn set_pending_parsing_blocking_script( &self, script: &HTMLScriptElement, load: Option<ScriptResult>, @@ -2513,12 +2522,12 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#pending-parsing-blocking-script - pub fn has_pending_parsing_blocking_script(&self) -> bool { + pub(crate) fn has_pending_parsing_blocking_script(&self) -> bool { self.pending_parsing_blocking_script.borrow().is_some() } /// <https://html.spec.whatwg.org/multipage/#prepare-a-script> step 22.d. - pub fn pending_parsing_blocking_script_loaded( + pub(crate) fn pending_parsing_blocking_script_loaded( &self, element: &HTMLScriptElement, result: ScriptResult, @@ -2551,7 +2560,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#set-of-scripts-that-will-execute-as-soon-as-possible - pub fn add_asap_script(&self, script: &HTMLScriptElement) { + pub(crate) fn add_asap_script(&self, script: &HTMLScriptElement) { self.asap_scripts_set .borrow_mut() .push(Dom::from_ref(script)); @@ -2559,7 +2568,7 @@ impl Document { /// <https://html.spec.whatwg.org/multipage/#the-end> step 5. /// <https://html.spec.whatwg.org/multipage/#prepare-a-script> step 22.d. - pub fn asap_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { + pub(crate) fn asap_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { { let mut scripts = self.asap_scripts_set.borrow_mut(); let idx = scripts @@ -2572,13 +2581,17 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible - pub fn push_asap_in_order_script(&self, script: &HTMLScriptElement) { + pub(crate) fn push_asap_in_order_script(&self, script: &HTMLScriptElement) { self.asap_in_order_scripts_list.push(script); } /// <https://html.spec.whatwg.org/multipage/#the-end> step 5. /// <https://html.spec.whatwg.org/multipage/#prepare-a-script> step> 22.c. - pub fn asap_in_order_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { + pub(crate) fn asap_in_order_script_loaded( + &self, + element: &HTMLScriptElement, + result: ScriptResult, + ) { self.asap_in_order_scripts_list.loaded(element, result); while let Some((element, result)) = self .asap_in_order_scripts_list @@ -2589,13 +2602,13 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing - pub fn add_deferred_script(&self, script: &HTMLScriptElement) { + pub(crate) fn add_deferred_script(&self, script: &HTMLScriptElement) { self.deferred_scripts.push(script); } /// <https://html.spec.whatwg.org/multipage/#the-end> step 3. /// <https://html.spec.whatwg.org/multipage/#prepare-a-script> step 22.d. - pub fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { + pub(crate) fn deferred_script_loaded(&self, element: &HTMLScriptElement, result: ScriptResult) { self.deferred_scripts.loaded(element, result); self.process_deferred_scripts(); } @@ -2624,7 +2637,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#the-end step 4. - pub fn maybe_dispatch_dom_content_loaded(&self) { + pub(crate) fn maybe_dispatch_dom_content_loaded(&self) { if self.domcontentloaded_dispatched.get() { return; } @@ -2660,7 +2673,7 @@ impl Document { } // https://html.spec.whatwg.org/multipage/#abort-a-document - pub fn abort(&self, can_gc: CanGc) { + pub(crate) fn abort(&self, can_gc: CanGc) { // We need to inhibit the loader before anything else. self.loader.borrow_mut().inhibit_events(); @@ -2702,15 +2715,15 @@ impl Document { } } - pub fn notify_constellation_load(&self) { + pub(crate) fn notify_constellation_load(&self) { self.window().send_to_constellation(ScriptMsg::LoadComplete); } - pub fn set_current_parser(&self, script: Option<&ServoParser>) { + pub(crate) fn set_current_parser(&self, script: Option<&ServoParser>) { self.current_parser.set(script); } - pub fn get_current_parser(&self) -> Option<DomRoot<ServoParser>> { + pub(crate) fn get_current_parser(&self) -> Option<DomRoot<ServoParser>> { self.current_parser.get() } @@ -2728,57 +2741,57 @@ impl Document { self.iframes.borrow_mut() } - pub fn get_dom_interactive(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_dom_interactive(&self) -> Option<CrossProcessInstant> { self.dom_interactive.get() } - pub fn set_navigation_start(&self, navigation_start: CrossProcessInstant) { + pub(crate) fn set_navigation_start(&self, navigation_start: CrossProcessInstant) { self.interactive_time .borrow_mut() .set_navigation_start(navigation_start); } - pub fn get_interactive_metrics(&self) -> Ref<InteractiveMetrics> { + pub(crate) fn get_interactive_metrics(&self) -> Ref<InteractiveMetrics> { self.interactive_time.borrow() } - pub fn has_recorded_tti_metric(&self) -> bool { + pub(crate) fn has_recorded_tti_metric(&self) -> bool { self.get_interactive_metrics().get_tti().is_some() } - pub fn get_dom_content_loaded_event_start(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_dom_content_loaded_event_start(&self) -> Option<CrossProcessInstant> { self.dom_content_loaded_event_start.get() } - pub fn get_dom_content_loaded_event_end(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_dom_content_loaded_event_end(&self) -> Option<CrossProcessInstant> { self.dom_content_loaded_event_end.get() } - pub fn get_dom_complete(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_dom_complete(&self) -> Option<CrossProcessInstant> { self.dom_complete.get() } - pub fn get_top_level_dom_complete(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_top_level_dom_complete(&self) -> Option<CrossProcessInstant> { self.top_level_dom_complete.get() } - pub fn get_load_event_start(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_load_event_start(&self) -> Option<CrossProcessInstant> { self.load_event_start.get() } - pub fn get_load_event_end(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_load_event_end(&self) -> Option<CrossProcessInstant> { self.load_event_end.get() } - pub fn get_unload_event_start(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_unload_event_start(&self) -> Option<CrossProcessInstant> { self.unload_event_start.get() } - pub fn get_unload_event_end(&self) -> Option<CrossProcessInstant> { + pub(crate) fn get_unload_event_end(&self) -> Option<CrossProcessInstant> { self.unload_event_end.get() } - pub fn start_tti(&self) { + pub(crate) fn start_tti(&self) { if self.get_interactive_metrics().needs_tti() { self.tti_window.borrow_mut().start_window(); } @@ -2787,7 +2800,7 @@ impl Document { /// check tti for this document /// if it's been 10s since this doc encountered a task over 50ms, then we consider the /// main thread available and try to set tti - pub fn record_tti_if_necessary(&self) { + pub(crate) fn record_tti_if_necessary(&self) { if self.has_recorded_tti_metric() { return; } @@ -2828,12 +2841,12 @@ impl Document { } /// <https://html.spec.whatwg.org/multipage/#cookie-averse-document-object> - pub fn is_cookie_averse(&self) -> bool { + pub(crate) fn is_cookie_averse(&self) -> bool { !self.has_browsing_context || !url_has_network_scheme(&self.url()) } /// <https://html.spec.whatwg.org/multipage/#look-up-a-custom-element-definition> - pub fn lookup_custom_element_definition( + pub(crate) fn lookup_custom_element_definition( &self, namespace: &Namespace, local_name: &LocalName, @@ -2859,29 +2872,29 @@ impl Document { registry.lookup_definition(local_name, is) } - pub fn increment_throw_on_dynamic_markup_insertion_counter(&self) { + pub(crate) fn increment_throw_on_dynamic_markup_insertion_counter(&self) { let counter = self.throw_on_dynamic_markup_insertion_counter.get(); self.throw_on_dynamic_markup_insertion_counter .set(counter + 1); } - pub fn decrement_throw_on_dynamic_markup_insertion_counter(&self) { + pub(crate) fn decrement_throw_on_dynamic_markup_insertion_counter(&self) { let counter = self.throw_on_dynamic_markup_insertion_counter.get(); self.throw_on_dynamic_markup_insertion_counter .set(counter - 1); } - pub fn react_to_environment_changes(&self) { + pub(crate) fn react_to_environment_changes(&self) { for image in self.responsive_images.borrow().iter() { image.react_to_environment_changes(); } } - pub fn register_responsive_image(&self, img: &HTMLImageElement) { + pub(crate) fn register_responsive_image(&self, img: &HTMLImageElement) { self.responsive_images.borrow_mut().push(Dom::from_ref(img)); } - pub fn unregister_responsive_image(&self, img: &HTMLImageElement) { + pub(crate) fn unregister_responsive_image(&self, img: &HTMLImageElement) { let index = self .responsive_images .borrow() @@ -2892,7 +2905,7 @@ impl Document { } } - pub fn register_media_controls(&self, controls: &ShadowRoot) -> String { + pub(crate) fn register_media_controls(&self, controls: &ShadowRoot) -> String { let id = Uuid::new_v4().to_string(); self.media_controls .borrow_mut() @@ -2900,7 +2913,7 @@ impl Document { id } - pub fn unregister_media_controls(&self, id: &str) { + pub(crate) fn unregister_media_controls(&self, id: &str) { if let Some(ref media_controls) = self.media_controls.borrow_mut().remove(id) { let media_controls = DomRoot::from_ref(&**media_controls); media_controls.Host().detach_shadow(); @@ -2909,14 +2922,14 @@ impl Document { } } - pub fn add_dirty_webgl_canvas(&self, context: &WebGLRenderingContext) { + pub(crate) fn add_dirty_webgl_canvas(&self, context: &WebGLRenderingContext) { self.dirty_webgl_contexts .borrow_mut() .entry(context.context_id()) .or_insert_with(|| Dom::from_ref(context)); } - pub fn flush_dirty_webgl_canvases(&self) { + pub(crate) fn flush_dirty_webgl_canvases(&self) { let dirty_context_ids: Vec<_> = self .dirty_webgl_contexts .borrow_mut() @@ -2941,13 +2954,13 @@ impl Document { } #[cfg(feature = "webgpu")] - pub fn webgpu_contexts(&self) -> WebGPUContextsMap { + pub(crate) fn webgpu_contexts(&self) -> WebGPUContextsMap { self.webgpu_contexts.clone() } #[allow(crown::unrooted_must_root)] #[cfg(feature = "webgpu")] - pub fn update_rendering_of_webgpu_canvases(&self) { + pub(crate) fn update_rendering_of_webgpu_canvases(&self) { self.webgpu_contexts .borrow_mut() .iter() @@ -2956,11 +2969,11 @@ impl Document { .for_each(|context| context.update_rendering_of_webgpu_canvas()); } - pub fn id_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { + pub(crate) fn id_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { self.id_map.borrow() } - pub fn name_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { + pub(crate) fn name_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { self.name_map.borrow() } @@ -3033,7 +3046,7 @@ impl Document { } /// <https://html.spec.whatwg.org/multipage/#encoding-parsing-a-url> - pub fn encoding_parse_a_url(&self, url: &str) -> Result<ServoUrl, url::ParseError> { + pub(crate) fn encoding_parse_a_url(&self, url: &str) -> Result<ServoUrl, url::ParseError> { // NOTE: This algorithm is defined for both Document and environment settings objects. // This implementation is only for documents. @@ -3062,13 +3075,13 @@ fn is_character_value_key(key: &Key) -> bool { } #[derive(MallocSizeOf, PartialEq)] -pub enum DocumentSource { +pub(crate) enum DocumentSource { FromParser, NotFromParser, } #[allow(unsafe_code)] -pub trait LayoutDocumentHelpers<'dom> { +pub(crate) trait LayoutDocumentHelpers<'dom> { fn is_html_document_for_layout(&self) -> bool; fn quirks_mode(self) -> QuirksMode; fn style_shared_lock(self) -> &'dom StyleSharedRwLock; @@ -3178,14 +3191,14 @@ fn url_has_network_scheme(url: &ServoUrl) -> bool { } #[derive(Clone, Copy, Eq, JSTraceable, MallocSizeOf, PartialEq)] -pub enum HasBrowsingContext { +pub(crate) enum HasBrowsingContext { No, Yes, } impl Document { #[allow(clippy::too_many_arguments)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, @@ -3353,7 +3366,7 @@ impl Document { } /// Note a pending compositor event, to be processed at the next `update_the_rendering` task. - pub fn note_pending_compositor_event(&self, event: CompositorEvent) { + pub(crate) fn note_pending_compositor_event(&self, event: CompositorEvent) { let mut pending_compositor_events = self.pending_compositor_events.borrow_mut(); if matches!(event, CompositorEvent::MouseMoveEvent { .. }) { // First try to replace any existing mouse move event. @@ -3373,22 +3386,22 @@ impl Document { } /// Get pending compositor events, for processing within an `update_the_rendering` task. - pub fn take_pending_compositor_events(&self) -> Vec<CompositorEvent> { + pub(crate) fn take_pending_compositor_events(&self) -> Vec<CompositorEvent> { // Reset the mouse event index. *self.mouse_move_event_index.borrow_mut() = None; mem::take(&mut *self.pending_compositor_events.borrow_mut()) } - pub fn set_csp_list(&self, csp_list: Option<CspList>) { + pub(crate) fn set_csp_list(&self, csp_list: Option<CspList>) { self.policy_container.borrow_mut().set_csp_list(csp_list); } - pub fn get_csp_list(&self) -> Option<CspList> { + pub(crate) fn get_csp_list(&self) -> Option<CspList> { self.policy_container.borrow().csp_list.clone() } /// <https://www.w3.org/TR/CSP/#should-block-inline> - pub fn should_elements_inline_type_behavior_be_blocked( + pub(crate) fn should_elements_inline_type_behavior_be_blocked( &self, el: &Element, type_: csp::InlineCheckType, @@ -3414,7 +3427,7 @@ impl Document { /// web content. Any attempts to invoke content JS or query layout during /// that time will trigger a panic. `add_delayed_task` will cause the /// provided task to be executed as soon as the last blocker is removed. - pub fn add_script_and_layout_blocker(&self) { + pub(crate) fn add_script_and_layout_blocker(&self) { self.script_and_layout_blockers .set(self.script_and_layout_blockers.get() + 1); } @@ -3422,7 +3435,7 @@ impl Document { /// Terminate the period in which JS or layout is disallowed from running. /// If no further blockers remain, any delayed tasks in the queue will /// be executed in queue order until the queue is empty. - pub fn remove_script_and_layout_blocker(&self) { + pub(crate) fn remove_script_and_layout_blocker(&self) { assert!(self.script_and_layout_blockers.get() > 0); self.script_and_layout_blockers .set(self.script_and_layout_blockers.get() - 1); @@ -3434,13 +3447,13 @@ impl Document { } /// Enqueue a task to run as soon as any JS and layout blockers are removed. - pub fn add_delayed_task<T: 'static + TaskBox>(&self, task: T) { + pub(crate) fn add_delayed_task<T: 'static + TaskBox>(&self, task: T) { self.delayed_tasks.borrow_mut().push(Box::new(task)); } /// Assert that the DOM is in a state that will allow running content JS or /// performing a layout operation. - pub fn ensure_safe_to_run_script_or_layout(&self) { + pub(crate) fn ensure_safe_to_run_script_or_layout(&self) { assert_eq!( self.script_and_layout_blockers.get(), 0, @@ -3449,7 +3462,7 @@ impl Document { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, @@ -3533,22 +3546,26 @@ impl Document { document } - pub fn get_redirect_count(&self) -> u16 { + pub(crate) fn get_redirect_count(&self) -> u16 { self.redirect_count.get() } - pub fn set_redirect_count(&self, count: u16) { + pub(crate) fn set_redirect_count(&self, count: u16) { self.redirect_count.set(count) } - pub fn elements_by_name_count(&self, name: &DOMString) -> u32 { + pub(crate) fn elements_by_name_count(&self, name: &DOMString) -> u32 { if name.is_empty() { return 0; } self.count_node_list(|n| Document::is_element_in_get_by_name(n, name)) } - pub fn nth_element_by_name(&self, index: u32, name: &DOMString) -> Option<DomRoot<Node>> { + pub(crate) fn nth_element_by_name( + &self, + index: u32, + name: &DOMString, + ) -> Option<DomRoot<Node>> { if name.is_empty() { return None; } @@ -3598,12 +3615,12 @@ impl Document { } /// Return a reference to the per-document shared lock used in stylesheets. - pub fn style_shared_lock(&self) -> &StyleSharedRwLock { + pub(crate) fn style_shared_lock(&self) -> &StyleSharedRwLock { &self.style_shared_lock } /// Flushes the stylesheet list, and returns whether any stylesheet changed. - pub fn flush_stylesheets_for_reflow(&self) -> bool { + pub(crate) fn flush_stylesheets_for_reflow(&self) -> bool { // NOTE(emilio): The invalidation machinery is used on the replicated // list in layout. // @@ -3616,12 +3633,15 @@ impl Document { have_changed } - pub fn salvageable(&self) -> bool { + pub(crate) fn salvageable(&self) -> bool { self.salvageable.get() } /// <https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document> - pub fn appropriate_template_contents_owner_document(&self, can_gc: CanGc) -> DomRoot<Document> { + pub(crate) fn appropriate_template_contents_owner_document( + &self, + can_gc: CanGc, + ) -> DomRoot<Document> { self.appropriate_template_contents_owner_document .or_init(|| { let doctype = if self.is_html_document { @@ -3654,14 +3674,14 @@ impl Document { }) } - pub fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> { + pub(crate) fn get_element_by_id(&self, id: &Atom) -> Option<DomRoot<Element>> { self.id_map .borrow() .get(id) .map(|elements| DomRoot::from_ref(&*elements[0])) } - pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> { + pub(crate) fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> { let map = self.pending_restyles.borrow_mut(); RefMut::map(map, |m| { &mut m @@ -3671,7 +3691,7 @@ impl Document { }) } - pub fn element_state_will_change(&self, el: &Element) { + pub(crate) fn element_state_will_change(&self, el: &Element) { let mut entry = self.ensure_pending_restyle(el); if entry.snapshot.is_none() { entry.snapshot = Some(Snapshot::new()); @@ -3682,7 +3702,7 @@ impl Document { } } - pub fn element_attr_will_change(&self, el: &Element, attr: &Attr) { + pub(crate) fn element_attr_will_change(&self, el: &Element, attr: &Attr) { // FIXME(emilio): Kind of a shame we have to duplicate this. // // I'm getting rid of the whole hashtable soon anyway, since all it does @@ -3728,17 +3748,17 @@ impl Document { } } - pub fn set_referrer_policy(&self, policy: ReferrerPolicy) { + pub(crate) fn set_referrer_policy(&self, policy: ReferrerPolicy) { self.policy_container .borrow_mut() .set_referrer_policy(policy); } - pub fn get_referrer_policy(&self) -> ReferrerPolicy { + pub(crate) fn get_referrer_policy(&self) -> ReferrerPolicy { self.policy_container.borrow().get_referrer_policy() } - pub fn set_target_element(&self, node: Option<&Element>) { + pub(crate) fn set_target_element(&self, node: Option<&Element>) { if let Some(ref element) = self.target_element.get() { element.set_target_state(false); } @@ -3750,17 +3770,17 @@ impl Document { } } - pub fn incr_ignore_destructive_writes_counter(&self) { + pub(crate) fn incr_ignore_destructive_writes_counter(&self) { self.ignore_destructive_writes_counter .set(self.ignore_destructive_writes_counter.get() + 1); } - pub fn decr_ignore_destructive_writes_counter(&self) { + pub(crate) fn decr_ignore_destructive_writes_counter(&self) { self.ignore_destructive_writes_counter .set(self.ignore_destructive_writes_counter.get() - 1); } - pub fn is_prompting_or_unloading(&self) -> bool { + pub(crate) fn is_prompting_or_unloading(&self) -> bool { self.ignore_opens_during_unload_counter.get() > 0 } @@ -3781,7 +3801,7 @@ impl Document { } // https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen - pub fn enter_fullscreen(&self, pending: &Element, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn enter_fullscreen(&self, pending: &Element, can_gc: CanGc) -> Rc<Promise> { // Step 1 let in_realm_proof = AlreadyInRealm::assert(); let promise = Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), can_gc); @@ -3848,7 +3868,7 @@ impl Document { } // https://fullscreen.spec.whatwg.org/#exit-fullscreen - pub fn exit_fullscreen(&self, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn exit_fullscreen(&self, can_gc: CanGc) -> Rc<Promise> { let global = self.global(); // Step 1 let in_realm_proof = AlreadyInRealm::assert(); @@ -3887,11 +3907,11 @@ impl Document { promise } - pub fn set_fullscreen_element(&self, element: Option<&Element>) { + pub(crate) fn set_fullscreen_element(&self, element: Option<&Element>) { self.fullscreen_element.set(element); } - pub fn get_allow_fullscreen(&self) -> bool { + pub(crate) fn get_allow_fullscreen(&self) -> bool { // https://html.spec.whatwg.org/multipage/#allowed-to-use match self.browsing_context() { // Step 1 @@ -3923,38 +3943,38 @@ impl Document { } } - pub fn register_shadow_root(&self, shadow_root: &ShadowRoot) { + pub(crate) fn register_shadow_root(&self, shadow_root: &ShadowRoot) { self.shadow_roots .borrow_mut() .insert(Dom::from_ref(shadow_root)); self.invalidate_shadow_roots_stylesheets(); } - pub fn unregister_shadow_root(&self, shadow_root: &ShadowRoot) { + pub(crate) fn unregister_shadow_root(&self, shadow_root: &ShadowRoot) { let mut shadow_roots = self.shadow_roots.borrow_mut(); shadow_roots.remove(&Dom::from_ref(shadow_root)); } - pub fn invalidate_shadow_roots_stylesheets(&self) { + pub(crate) fn invalidate_shadow_roots_stylesheets(&self) { self.shadow_roots_styles_changed.set(true); } - pub fn shadow_roots_styles_changed(&self) -> bool { + pub(crate) fn shadow_roots_styles_changed(&self) -> bool { self.shadow_roots_styles_changed.get() } - pub fn flush_shadow_roots_stylesheets(&self) { + pub(crate) fn flush_shadow_roots_stylesheets(&self) { if !self.shadow_roots_styles_changed.get() { return; } self.shadow_roots_styles_changed.set(false); } - pub fn stylesheet_count(&self) -> usize { + pub(crate) fn stylesheet_count(&self) -> usize { self.stylesheets.borrow().len() } - pub fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { let stylesheets = self.stylesheets.borrow(); stylesheets @@ -3965,7 +3985,7 @@ impl Document { /// Add a stylesheet owned by `owner` to the list of document sheets, in the /// correct tree position. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { + pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { let stylesheets = &mut *self.stylesheets.borrow_mut(); let insertion_point = stylesheets .iter() @@ -3994,7 +4014,7 @@ impl Document { } /// Given a stylesheet, load all web fonts from it in Layout. - pub fn load_web_fonts_from_stylesheet(&self, stylesheet: Arc<Stylesheet>) { + pub(crate) fn load_web_fonts_from_stylesheet(&self, stylesheet: Arc<Stylesheet>) { self.window .layout() .load_web_fonts_from_stylesheet(stylesheet); @@ -4002,7 +4022,7 @@ impl Document { /// Remove a stylesheet owned by `owner` from the list of document sheets. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc<Stylesheet>) { + pub(crate) fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc<Stylesheet>) { let cloned_stylesheet = stylesheet.clone(); self.window .layout_mut() @@ -4015,20 +4035,20 @@ impl Document { ) } - pub fn get_elements_with_id(&self, id: &Atom) -> Ref<[Dom<Element>]> { + pub(crate) fn get_elements_with_id(&self, id: &Atom) -> Ref<[Dom<Element>]> { Ref::map(self.id_map.borrow(), |map| { map.get(id).map(|vec| &**vec).unwrap_or_default() }) } - pub fn get_elements_with_name(&self, name: &Atom) -> Ref<[Dom<Element>]> { + pub(crate) fn get_elements_with_name(&self, name: &Atom) -> Ref<[Dom<Element>]> { Ref::map(self.name_map.borrow(), |map| { map.get(name).map(|vec| &**vec).unwrap_or_default() }) } #[allow(crown::unrooted_must_root)] - pub fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> { + pub(crate) fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> { self.pending_restyles .borrow_mut() .drain() @@ -4168,7 +4188,7 @@ impl Document { } /// <https://html.spec.whatwg.org/multipage/#is-initial-about:blank> - pub fn is_initial_about_blank(&self) -> bool { + pub(crate) fn is_initial_about_blank(&self) -> bool { self.is_initial_about_blank.get() } } @@ -5584,7 +5604,7 @@ fn update_with_current_instant(marker: &Cell<Option<CrossProcessInstant>>) { } /// <https://w3c.github.io/webappsec-referrer-policy/#determine-policy-for-token> -pub fn determine_policy_for_token(token: &str) -> ReferrerPolicy { +pub(crate) fn determine_policy_for_token(token: &str) -> ReferrerPolicy { match_ignore_ascii_case! { token, "never" | "no-referrer" => ReferrerPolicy::NoReferrer, "no-referrer-when-downgrade" => ReferrerPolicy::NoReferrerWhenDowngrade, @@ -5600,13 +5620,13 @@ pub fn determine_policy_for_token(token: &str) -> ReferrerPolicy { /// Specifies the type of focus event that is sent to a pipeline #[derive(Clone, Copy, PartialEq)] -pub enum FocusType { +pub(crate) enum FocusType { Element, // The first focus message - focus the element itself Parent, // Focusing a parent element (an iframe) } /// Focus events -pub enum FocusEventType { +pub(crate) enum FocusEventType { Focus, // Element gained focus. Doesn't bubble. Blur, // Element lost focus. Doesn't bubble. } @@ -5618,14 +5638,14 @@ pub enum FocusEventType { /// without mutating the DOM), then we fall back to simple timeouts to save energy over video /// refresh. #[derive(JSTraceable, MallocSizeOf)] -pub struct FakeRequestAnimationFrameCallback { +pub(crate) struct FakeRequestAnimationFrameCallback { /// The document. #[ignore_malloc_size_of = "non-owning"] document: Trusted<Document>, } impl FakeRequestAnimationFrameCallback { - pub fn invoke(self, can_gc: CanGc) { + pub(crate) fn invoke(self, can_gc: CanGc) { // TODO: Once there is a more generic mechanism to trigger `update_the_rendering` when // not driven by the compositor, it should be used here. self.document @@ -5636,7 +5656,7 @@ impl FakeRequestAnimationFrameCallback { } #[derive(JSTraceable, MallocSizeOf)] -pub enum AnimationFrameCallback { +pub(crate) enum AnimationFrameCallback { DevtoolsFramerateTick { actor_name: String, }, @@ -5737,7 +5757,7 @@ impl PendingScript { } #[derive(Clone, Copy, Debug, PartialEq)] -pub enum ReflowTriggerCondition { +pub(crate) enum ReflowTriggerCondition { StylesheetsChanged, DirtyDescendants, PendingRestyles, diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs index 0dc7eb53227..b418d095b91 100644 --- a/components/script/dom/documentfragment.rs +++ b/components/script/dom/documentfragment.rs @@ -26,7 +26,7 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#documentfragment #[dom_struct] -pub struct DocumentFragment { +pub(crate) struct DocumentFragment { node: Node, /// Caches for the getElement methods id_map: DomRefCell<HashMapTracedValues<Atom, Vec<Dom<Element>>>>, @@ -34,14 +34,14 @@ pub struct DocumentFragment { impl DocumentFragment { /// Creates a new DocumentFragment. - pub fn new_inherited(document: &Document) -> DocumentFragment { + pub(crate) fn new_inherited(document: &Document) -> DocumentFragment { DocumentFragment { node: Node::new_inherited(document), id_map: DomRefCell::new(HashMapTracedValues::new()), } } - pub fn new(document: &Document, can_gc: CanGc) -> DomRoot<DocumentFragment> { + pub(crate) fn new(document: &Document, can_gc: CanGc) -> DomRoot<DocumentFragment> { Self::new_with_proto(document, None, can_gc) } @@ -58,7 +58,7 @@ impl DocumentFragment { ) } - pub fn id_map(&self) -> &DomRefCell<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { + pub(crate) fn id_map(&self) -> &DomRefCell<HashMapTracedValues<Atom, Vec<Dom<Element>>>> { &self.id_map } } diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 37464a2f1d4..29713ee0d50 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -30,11 +30,11 @@ use crate::stylesheet_set::StylesheetSetRef; #[derive(Clone, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct StyleSheetInDocument { +pub(crate) struct StyleSheetInDocument { #[ignore_malloc_size_of = "Arc"] #[no_trace] - pub sheet: Arc<Stylesheet>, - pub owner: Dom<Element>, + pub(crate) sheet: Arc<Stylesheet>, + pub(crate) owner: Dom<Element>, } // This is necessary because this type is contained within a Stylo type which needs @@ -84,18 +84,18 @@ impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument { // https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-the-documentorshadowroot-mixin #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] -pub struct DocumentOrShadowRoot { +pub(crate) struct DocumentOrShadowRoot { window: Dom<Window>, } impl DocumentOrShadowRoot { - pub fn new(window: &Window) -> Self { + pub(crate) fn new(window: &Window) -> Self { Self { window: Dom::from_ref(window), } } - pub fn nodes_from_point( + pub(crate) fn nodes_from_point( &self, client_point: &Point2D<f32>, query_type: NodesFromPointQueryType, @@ -115,7 +115,7 @@ impl DocumentOrShadowRoot { #[allow(unsafe_code)] // https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint - pub fn element_from_point( + pub(crate) fn element_from_point( &self, x: Finite<f64>, y: Finite<f64>, @@ -155,7 +155,7 @@ impl DocumentOrShadowRoot { #[allow(unsafe_code)] // https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint - pub fn elements_from_point( + pub(crate) fn elements_from_point( &self, x: Finite<f64>, y: Finite<f64>, @@ -199,7 +199,7 @@ impl DocumentOrShadowRoot { } // https://html.spec.whatwg.org/multipage/#dom-document-activeelement - pub fn get_active_element( + pub(crate) fn get_active_element( &self, focused_element: Option<DomRoot<Element>>, body: Option<DomRoot<HTMLElement>>, @@ -219,7 +219,7 @@ impl DocumentOrShadowRoot { /// Remove a stylesheet owned by `owner` from the list of document sheets. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn remove_stylesheet( + pub(crate) fn remove_stylesheet( owner: &Element, s: &Arc<Stylesheet>, mut stylesheets: StylesheetSetRef<StyleSheetInDocument>, @@ -240,7 +240,7 @@ impl DocumentOrShadowRoot { /// Add a stylesheet owned by `owner` to the list of document sheets, in the /// correct tree position. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn add_stylesheet( + pub(crate) fn add_stylesheet( owner: &Element, mut stylesheets: StylesheetSetRef<StyleSheetInDocument>, sheet: Arc<Stylesheet>, @@ -267,7 +267,7 @@ impl DocumentOrShadowRoot { } /// Remove any existing association between the provided id/name and any elements in this document. - pub fn unregister_named_element( + pub(crate) fn unregister_named_element( &self, id_map: &DomRefCell<HashMapTracedValues<Atom, Vec<Dom<Element>>>>, to_unregister: &Element, @@ -295,7 +295,7 @@ impl DocumentOrShadowRoot { } /// Associate an element present in this document with the provided id/name. - pub fn register_named_element( + pub(crate) fn register_named_element( &self, id_map: &DomRefCell<HashMapTracedValues<Atom, Vec<Dom<Element>>>>, element: &Element, diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index a9b6d696f97..7499d7fbaae 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -17,7 +17,7 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#documenttype /// The `DOCTYPE` tag. #[dom_struct] -pub struct DocumentType { +pub(crate) struct DocumentType { node: Node, name: DOMString, public_id: DOMString, @@ -39,7 +39,7 @@ impl DocumentType { } } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( name: DOMString, public_id: Option<DOMString>, system_id: Option<DOMString>, @@ -56,17 +56,17 @@ impl DocumentType { } #[inline] - pub fn name(&self) -> &DOMString { + pub(crate) fn name(&self) -> &DOMString { &self.name } #[inline] - pub fn public_id(&self) -> &DOMString { + pub(crate) fn public_id(&self) -> &DOMString { &self.public_id } #[inline] - pub fn system_id(&self) -> &DOMString { + pub(crate) fn system_id(&self) -> &DOMString { &self.system_id } } diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 925b35e30db..454f3a75637 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -20,7 +20,7 @@ use crate::script_runtime::CanGc; #[repr(u16)] #[allow(clippy::enum_variant_names)] #[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub enum DOMErrorName { +pub(crate) enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR, HierarchyRequestError = DOMExceptionConstants::HIERARCHY_REQUEST_ERR, WrongDocumentError = DOMExceptionConstants::WRONG_DOCUMENT_ERR, @@ -50,7 +50,7 @@ pub enum DOMErrorName { } impl DOMErrorName { - pub fn from(s: &DOMString) -> Option<DOMErrorName> { + pub(crate) fn from(s: &DOMString) -> Option<DOMErrorName> { match s.as_ref() { "IndexSizeError" => Some(DOMErrorName::IndexSizeError), "HierarchyRequestError" => Some(DOMErrorName::HierarchyRequestError), @@ -84,7 +84,7 @@ impl DOMErrorName { } #[dom_struct] -pub struct DOMException { +pub(crate) struct DOMException { reflector_: Reflector, message: DOMString, name: DOMString, @@ -137,7 +137,7 @@ impl DOMException { ) } - pub fn new_inherited(message: DOMString, name: DOMString) -> DOMException { + pub(crate) fn new_inherited(message: DOMString, name: DOMString) -> DOMException { DOMException { reflector_: Reflector::new(), message, @@ -145,7 +145,7 @@ impl DOMException { } } - pub fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> { + pub(crate) fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> { let (message, name) = DOMException::get_error_data_by_code(code); reflect_dom_object( @@ -156,7 +156,7 @@ impl DOMException { } // not an IDL stringifier, used internally - pub fn stringifier(&self) -> DOMString { + pub(crate) fn stringifier(&self) -> DOMString { DOMString::from(format!("{}: {}", self.name, self.message)) } } diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index 513b784a475..b9f0a2c29a9 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -32,7 +32,7 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#domimplementation #[dom_struct] -pub struct DOMImplementation { +pub(crate) struct DOMImplementation { reflector_: Reflector, document: Dom<Document>, } @@ -45,7 +45,7 @@ impl DOMImplementation { } } - pub fn new(document: &Document) -> DomRoot<DOMImplementation> { + pub(crate) fn new(document: &Document) -> DomRoot<DOMImplementation> { let window = document.window(); reflect_dom_object( Box::new(DOMImplementation::new_inherited(document)), diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index b4a6f72b6d1..f84f3b500d4 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -23,13 +23,13 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMMatrix { +pub(crate) struct DOMMatrix { parent: DOMMatrixReadOnly, } #[allow(non_snake_case)] impl DOMMatrix { - pub fn new( + pub(crate) fn new( global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>, @@ -50,13 +50,13 @@ impl DOMMatrix { reflect_dom_object_with_proto(Box::new(dommatrix), global, proto, can_gc) } - pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { + pub(crate) fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { DOMMatrix { parent: DOMMatrixReadOnly::new_inherited(is2D, matrix), } } - pub fn from_readonly( + pub(crate) fn from_readonly( global: &GlobalScope, ro: &DOMMatrixReadOnly, can_gc: CanGc, diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index f5d5ea4b2d9..fb6e6fbf48b 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -37,7 +37,7 @@ use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] #[allow(non_snake_case)] -pub struct DOMMatrixReadOnly { +pub(crate) struct DOMMatrixReadOnly { reflector_: Reflector, #[no_trace] matrix: DomRefCell<Transform3D<f64>>, @@ -46,7 +46,7 @@ pub struct DOMMatrixReadOnly { #[allow(non_snake_case)] impl DOMMatrixReadOnly { - pub fn new( + pub(crate) fn new( global: &GlobalScope, is2D: bool, matrix: Transform3D<f64>, @@ -67,7 +67,7 @@ impl DOMMatrixReadOnly { reflect_dom_object_with_proto(Box::new(dommatrix), global, proto, can_gc) } - pub fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { + pub(crate) fn new_inherited(is2D: bool, matrix: Transform3D<f64>) -> Self { DOMMatrixReadOnly { reflector_: Reflector::new(), matrix: DomRefCell::new(matrix), @@ -75,26 +75,26 @@ impl DOMMatrixReadOnly { } } - pub fn matrix(&self) -> Ref<Transform3D<f64>> { + pub(crate) fn matrix(&self) -> Ref<Transform3D<f64>> { self.matrix.borrow() } - pub fn is2D(&self) -> bool { + pub(crate) fn is2D(&self) -> bool { self.is2D.get() } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m11 - pub fn set_m11(&self, value: f64) { + pub(crate) fn set_m11(&self, value: f64) { self.matrix.borrow_mut().m11 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m12 - pub fn set_m12(&self, value: f64) { + pub(crate) fn set_m12(&self, value: f64) { self.matrix.borrow_mut().m12 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m13 - pub fn set_m13(&self, value: f64) { + pub(crate) fn set_m13(&self, value: f64) { // For the DOMMatrix interface, setting the m13 attribute must set the // m13 element to the new value and, if the new value is not 0 or -0, set is 2D to false. @@ -105,7 +105,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m14 - pub fn set_m14(&self, value: f64) { + pub(crate) fn set_m14(&self, value: f64) { // For the DOMMatrix interface, setting the m14 attribute must set the // m14 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m14 = value; @@ -116,17 +116,17 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m21 - pub fn set_m21(&self, value: f64) { + pub(crate) fn set_m21(&self, value: f64) { self.matrix.borrow_mut().m21 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m22 - pub fn set_m22(&self, value: f64) { + pub(crate) fn set_m22(&self, value: f64) { self.matrix.borrow_mut().m22 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m23 - pub fn set_m23(&self, value: f64) { + pub(crate) fn set_m23(&self, value: f64) { // For the DOMMatrix interface, setting the m23 attribute must set the // m23 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m23 = value; @@ -137,7 +137,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m24 - pub fn set_m24(&self, value: f64) { + pub(crate) fn set_m24(&self, value: f64) { // For the DOMMatrix interface, setting the m24 attribute must set the // m24 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m24 = value; @@ -148,7 +148,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m31 - pub fn set_m31(&self, value: f64) { + pub(crate) fn set_m31(&self, value: f64) { // For the DOMMatrix interface, setting the m31 attribute must set the // m31 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m31 = value; @@ -159,7 +159,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m32 - pub fn set_m32(&self, value: f64) { + pub(crate) fn set_m32(&self, value: f64) { // For the DOMMatrix interface, setting the m32 attribute must set the // m32 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m32 = value; @@ -170,7 +170,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m33 - pub fn set_m33(&self, value: f64) { + pub(crate) fn set_m33(&self, value: f64) { // For the DOMMatrix interface, setting the m33 attribute must set the // m33 element to the new value and, if the new value is not 1, set is 2D to false. self.matrix.borrow_mut().m33 = value; @@ -181,7 +181,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m34 - pub fn set_m34(&self, value: f64) { + pub(crate) fn set_m34(&self, value: f64) { // For the DOMMatrix interface, setting the m34 attribute must set the // m34 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m34 = value; @@ -192,17 +192,17 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m41 - pub fn set_m41(&self, value: f64) { + pub(crate) fn set_m41(&self, value: f64) { self.matrix.borrow_mut().m41 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m42 - pub fn set_m42(&self, value: f64) { + pub(crate) fn set_m42(&self, value: f64) { self.matrix.borrow_mut().m42 = value; } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m43 - pub fn set_m43(&self, value: f64) { + pub(crate) fn set_m43(&self, value: f64) { // For the DOMMatrix interface, setting the m43 attribute must set the // m43 element to the new value and, if the new value is not 0 or -0, set is 2D to false. self.matrix.borrow_mut().m43 = value; @@ -213,7 +213,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-m44 - pub fn set_m44(&self, value: f64) { + pub(crate) fn set_m44(&self, value: f64) { // For the DOMMatrix interface, setting the m44 attribute must set the // m44 element to the new value and, if the new value is not 1, set is 2D to false. self.matrix.borrow_mut().m44 = value; @@ -224,7 +224,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-multiplyself - pub fn multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { + pub(crate) fn multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { // Step 1. dommatrixinit_to_matrix(other).map(|(is2D, other_matrix)| { // Step 2. @@ -239,7 +239,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-premultiplyself - pub fn pre_multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { + pub(crate) fn pre_multiply_self(&self, other: &DOMMatrixInit) -> Fallible<()> { // Step 1. dommatrixinit_to_matrix(other).map(|(is2D, other_matrix)| { // Step 2. @@ -254,7 +254,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-translateself - pub fn translate_self(&self, tx: f64, ty: f64, tz: f64) { + pub(crate) fn translate_self(&self, tx: f64, ty: f64, tz: f64) { // Step 1. let translation = Transform3D::translation(tx, ty, tz); let mut matrix = self.matrix.borrow_mut(); @@ -267,7 +267,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scaleself - pub fn scale_self( + pub(crate) fn scale_self( &self, scaleX: f64, scaleY: Option<f64>, @@ -300,7 +300,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-scale3dself - pub fn scale_3d_self(&self, scale: f64, originX: f64, originY: f64, originZ: f64) { + pub(crate) fn scale_3d_self(&self, scale: f64, originX: f64, originY: f64, originZ: f64) { // Step 1. self.translate_self(originX, originY, originZ); // Step 2. @@ -319,7 +319,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateself - pub fn rotate_self(&self, mut rotX: f64, mut rotY: Option<f64>, mut rotZ: Option<f64>) { + pub(crate) fn rotate_self(&self, mut rotX: f64, mut rotY: Option<f64>, mut rotZ: Option<f64>) { // Step 1. if rotY.is_none() && rotZ.is_none() { rotZ = Some(rotX); @@ -356,7 +356,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotatefromvectorself - pub fn rotate_from_vector_self(&self, x: f64, y: f64) { + pub(crate) fn rotate_from_vector_self(&self, x: f64, y: f64) { // don't do anything when the rotation angle is zero or undefined if y != 0.0 || x < 0.0 { // Step 1. @@ -369,7 +369,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-rotateaxisangleself - pub fn rotate_axis_angle_self(&self, x: f64, y: f64, z: f64, angle: f64) { + pub(crate) fn rotate_axis_angle_self(&self, x: f64, y: f64, z: f64, angle: f64) { // Step 1. let (norm_x, norm_y, norm_z) = normalize_point(x, y, z); // Beware: pass negated value until https://github.com/servo/euclid/issues/354 @@ -385,7 +385,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewxself - pub fn skew_x_self(&self, sx: f64) { + pub(crate) fn skew_x_self(&self, sx: f64) { // Step 1. let skew = Transform3D::skew(Angle::radians(sx.to_radians()), Angle::radians(0.0)); let mut matrix = self.matrix.borrow_mut(); @@ -394,7 +394,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-skewyself - pub fn skew_y_self(&self, sy: f64) { + pub(crate) fn skew_y_self(&self, sy: f64) { // Step 1. let skew = Transform3D::skew(Angle::radians(0.0), Angle::radians(sy.to_radians())); let mut matrix = self.matrix.borrow_mut(); @@ -403,7 +403,7 @@ impl DOMMatrixReadOnly { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself - pub fn invert_self(&self) { + pub(crate) fn invert_self(&self) { let mut matrix = self.matrix.borrow_mut(); // Step 1. *matrix = matrix.inverse().unwrap_or_else(|| { @@ -950,7 +950,7 @@ fn create_3d_matrix(entries: &[f64]) -> Transform3D<f64> { } // https://drafts.fxtf.org/geometry-1/#dom-dommatrixreadonly-dommatrixreadonly-numbersequence -pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> { +pub(crate) fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> { if entries.len() == 6 { Ok((true, create_2d_matrix(entries))) } else if entries.len() == 16 { @@ -962,7 +962,7 @@ pub fn entries_to_matrix(entries: &[f64]) -> Fallible<(bool, Transform3D<f64>)> } // https://drafts.fxtf.org/geometry-1/#validate-and-fixup -pub fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transform3D<f64>)> { +pub(crate) fn dommatrixinit_to_matrix(dict: &DOMMatrixInit) -> Fallible<(bool, Transform3D<f64>)> { // Step 1. if dict.parent.a.is_some() && dict.parent.m11.is_some() && @@ -1047,7 +1047,7 @@ fn normalize_point(x: f64, y: f64, z: f64) -> (f64, f64, f64) { } } -pub fn transform_to_matrix(value: String) -> Fallible<(bool, Transform3D<f64>)> { +pub(crate) fn transform_to_matrix(value: String) -> Fallible<(bool, Transform3D<f64>)> { use style::properties::longhands::transform; let mut input = ParserInput::new(&value); diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index 38b44bfdde7..ece1360d466 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -24,7 +24,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMParser { +pub(crate) struct DOMParser { reflector_: Reflector, window: Dom<Window>, // XXXjdm Document instead? } diff --git a/components/script/dom/dompoint.rs b/components/script/dom/dompoint.rs index 4be2c2cdf8b..4e90ffa3db6 100644 --- a/components/script/dom/dompoint.rs +++ b/components/script/dom/dompoint.rs @@ -16,7 +16,7 @@ use crate::script_runtime::CanGc; // http://dev.w3.org/fxtf/geometry/Overview.html#dompoint #[dom_struct] -pub struct DOMPoint { +pub(crate) struct DOMPoint { point: DOMPointReadOnly, } @@ -28,7 +28,7 @@ impl DOMPoint { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, x: f64, y: f64, @@ -56,7 +56,7 @@ impl DOMPoint { ) } - pub fn new_from_init( + pub(crate) fn new_from_init( global: &GlobalScope, p: &DOMPointInit, can_gc: CanGc, diff --git a/components/script/dom/dompointreadonly.rs b/components/script/dom/dompointreadonly.rs index bb926511b96..ed29b9f7513 100644 --- a/components/script/dom/dompointreadonly.rs +++ b/components/script/dom/dompointreadonly.rs @@ -17,7 +17,7 @@ use crate::script_runtime::CanGc; // http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly #[dom_struct] -pub struct DOMPointReadOnly { +pub(crate) struct DOMPointReadOnly { reflector_: Reflector, x: Cell<f64>, y: Cell<f64>, @@ -27,7 +27,7 @@ pub struct DOMPointReadOnly { #[allow(non_snake_case)] impl DOMPointReadOnly { - pub fn new_inherited(x: f64, y: f64, z: f64, w: f64) -> DOMPointReadOnly { + pub(crate) fn new_inherited(x: f64, y: f64, z: f64, w: f64) -> DOMPointReadOnly { DOMPointReadOnly { x: Cell::new(x), y: Cell::new(y), @@ -37,7 +37,7 @@ impl DOMPointReadOnly { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, x: f64, y: f64, @@ -110,7 +110,7 @@ impl DOMPointReadOnlyMethods<crate::DomTypeHolder> for DOMPointReadOnly { } #[allow(non_snake_case)] -pub trait DOMPointWriteMethods { +pub(crate) trait DOMPointWriteMethods { fn SetX(&self, value: f64); fn SetY(&self, value: f64); fn SetZ(&self, value: f64); diff --git a/components/script/dom/domquad.rs b/components/script/dom/domquad.rs index 86888845485..cdbe99842bb 100644 --- a/components/script/dom/domquad.rs +++ b/components/script/dom/domquad.rs @@ -18,7 +18,7 @@ use crate::script_runtime::CanGc; /// <https://drafts.fxtf.org/geometry/#DOMQuad> #[dom_struct] -pub struct DOMQuad { +pub(crate) struct DOMQuad { reflector_: Reflector, p1: Dom<DOMPoint>, p2: Dom<DOMPoint>, @@ -37,7 +37,7 @@ impl DOMQuad { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, p1: &DOMPoint, p2: &DOMPoint, diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index e78b9fdfcbd..40ebd42f036 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -17,7 +17,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMRect { +pub(crate) struct DOMRect { rect: DOMRectReadOnly, } @@ -28,7 +28,7 @@ impl DOMRect { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, x: f64, y: f64, diff --git a/components/script/dom/domrectlist.rs b/components/script/dom/domrectlist.rs index 94e00c2c0c4..93427bceac7 100644 --- a/components/script/dom/domrectlist.rs +++ b/components/script/dom/domrectlist.rs @@ -12,7 +12,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMRectList { +pub(crate) struct DOMRectList { reflector_: Reflector, rects: DomRefCell<Vec<Dom<DOMRect>>>, } @@ -30,7 +30,7 @@ impl DOMRectList { } } - pub fn new( + pub(crate) fn new( window: &Window, rects: Vec<DomRoot<DOMRect>>, can_gc: CanGc, @@ -43,7 +43,7 @@ impl DOMRectList { ) } - pub fn first(&self) -> Option<DomRoot<DOMRect>> { + pub(crate) fn first(&self) -> Option<DomRoot<DOMRect>> { self.rects.borrow().first().map(Dom::as_rooted) } } diff --git a/components/script/dom/domrectreadonly.rs b/components/script/dom/domrectreadonly.rs index 2a04bd3596e..f9e71db51ba 100644 --- a/components/script/dom/domrectreadonly.rs +++ b/components/script/dom/domrectreadonly.rs @@ -19,7 +19,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMRectReadOnly { +pub(crate) struct DOMRectReadOnly { reflector_: Reflector, x: Cell<f64>, y: Cell<f64>, @@ -28,7 +28,7 @@ pub struct DOMRectReadOnly { } impl DOMRectReadOnly { - pub fn new_inherited(x: f64, y: f64, width: f64, height: f64) -> DOMRectReadOnly { + pub(crate) fn new_inherited(x: f64, y: f64, width: f64, height: f64) -> DOMRectReadOnly { DOMRectReadOnly { x: Cell::new(x), y: Cell::new(y), @@ -38,7 +38,7 @@ impl DOMRectReadOnly { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, proto: Option<HandleObject>, x: f64, @@ -55,19 +55,19 @@ impl DOMRectReadOnly { ) } - pub fn set_x(&self, value: f64) { + pub(crate) fn set_x(&self, value: f64) { self.x.set(value); } - pub fn set_y(&self, value: f64) { + pub(crate) fn set_y(&self, value: f64) { self.y.set(value); } - pub fn set_width(&self, value: f64) { + pub(crate) fn set_width(&self, value: f64) { self.width.set(value); } - pub fn set_height(&self, value: f64) { + pub(crate) fn set_height(&self, value: f64) { self.height.set(value); } } diff --git a/components/script/dom/domstringlist.rs b/components/script/dom/domstringlist.rs index aa83e81db93..ec6b7225d34 100644 --- a/components/script/dom/domstringlist.rs +++ b/components/script/dom/domstringlist.rs @@ -12,14 +12,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMStringList { +pub(crate) struct DOMStringList { reflector_: Reflector, strings: Vec<DOMString>, } impl DOMStringList { #[allow(unused)] - pub fn new_inherited(strings: Vec<DOMString>) -> DOMStringList { + pub(crate) fn new_inherited(strings: Vec<DOMString>) -> DOMStringList { DOMStringList { reflector_: Reflector::new(), strings, @@ -27,7 +27,7 @@ impl DOMStringList { } #[allow(unused)] - pub fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> { + pub(crate) fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> { 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 2d72a9d4597..7e7a7ca596a 100644 --- a/components/script/dom/domstringmap.rs +++ b/components/script/dom/domstringmap.rs @@ -14,7 +14,7 @@ use crate::dom::node::NodeTraits; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMStringMap { +pub(crate) struct DOMStringMap { reflector_: Reflector, element: Dom<HTMLElement>, } @@ -27,7 +27,7 @@ impl DOMStringMap { } } - pub fn new(element: &HTMLElement) -> DomRoot<DOMStringMap> { + pub(crate) fn new(element: &HTMLElement) -> DomRoot<DOMStringMap> { reflect_dom_object( Box::new(DOMStringMap::new_inherited(element)), &*element.owner_window(), diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 7465649b056..e0762c41f53 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -18,7 +18,7 @@ use crate::dom::node::NodeTraits; use crate::script_runtime::CanGc; #[dom_struct] -pub struct DOMTokenList { +pub(crate) struct DOMTokenList { reflector_: Reflector, element: Dom<Element>, #[no_trace] @@ -28,7 +28,7 @@ pub struct DOMTokenList { } impl DOMTokenList { - pub fn new_inherited( + pub(crate) fn new_inherited( element: &Element, local_name: LocalName, supported_tokens: Option<Vec<Atom>>, @@ -41,7 +41,7 @@ impl DOMTokenList { } } - pub fn new( + pub(crate) fn new( element: &Element, local_name: &LocalName, supported_tokens: Option<Vec<Atom>>, diff --git a/components/script/dom/dynamicmoduleowner.rs b/components/script/dom/dynamicmoduleowner.rs index 1a0f3fdb8bf..1ad75a2323f 100644 --- a/components/script/dom/dynamicmoduleowner.rs +++ b/components/script/dom/dynamicmoduleowner.rs @@ -16,10 +16,10 @@ use crate::script_runtime::CanGc; /// An unique id for dynamic module #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] -pub struct DynamicModuleId(#[no_trace] pub Uuid); +pub(crate) struct DynamicModuleId(#[no_trace] pub(crate) Uuid); #[dom_struct] -pub struct DynamicModuleOwner { +pub(crate) struct DynamicModuleOwner { reflector_: Reflector, #[ignore_malloc_size_of = "Rc"] @@ -41,7 +41,11 @@ impl DynamicModuleOwner { } #[allow(crown::unrooted_must_root)] - pub fn new(global: &GlobalScope, promise: Rc<Promise>, id: DynamicModuleId) -> DomRoot<Self> { + pub(crate) fn new( + global: &GlobalScope, + promise: Rc<Promise>, + id: DynamicModuleId, + ) -> DomRoot<Self> { reflect_dom_object( Box::new(DynamicModuleOwner::new_inherited(promise, id)), global, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index daae203bd52..df22722e1d5 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -159,7 +159,7 @@ use crate::task::TaskOnce; // https://html.spec.whatwg.org/multipage/#selector-focus #[dom_struct] -pub struct Element { +pub(crate) struct Element { node: Node, #[no_trace] local_name: LocalName, @@ -207,24 +207,24 @@ impl fmt::Debug for DomRoot<Element> { } #[derive(MallocSizeOf, PartialEq)] -pub enum ElementCreator { +pub(crate) enum ElementCreator { ParserCreated(u64), ScriptCreated, } -pub enum CustomElementCreationMode { +pub(crate) enum CustomElementCreationMode { Synchronous, Asynchronous, } impl ElementCreator { - pub fn is_parser_created(&self) -> bool { + pub(crate) fn is_parser_created(&self) -> bool { match *self { ElementCreator::ParserCreated(_) => true, ElementCreator::ScriptCreated => false, } } - pub fn return_line_number(&self) -> u64 { + pub(crate) fn return_line_number(&self) -> u64 { match *self { ElementCreator::ParserCreated(l) => l, ElementCreator::ScriptCreated => 1, @@ -232,7 +232,7 @@ impl ElementCreator { } } -pub enum AdjacentPosition { +pub(crate) enum AdjacentPosition { BeforeBegin, AfterEnd, AfterBegin, @@ -257,7 +257,7 @@ impl FromStr for AdjacentPosition { // Element methods // impl Element { - pub fn create( + pub(crate) fn create( name: QualName, is: Option<LocalName>, document: &Document, @@ -269,7 +269,7 @@ impl Element { create_element(name, is, document, creator, mode, proto, can_gc) } - pub fn new_inherited( + pub(crate) fn new_inherited( local_name: LocalName, namespace: Namespace, prefix: Option<Prefix>, @@ -284,7 +284,7 @@ impl Element { ) } - pub fn new_inherited_with_state( + pub(crate) fn new_inherited_with_state( state: ElementState, local_name: LocalName, namespace: Namespace, @@ -309,7 +309,7 @@ impl Element { } } - pub fn new( + pub(crate) fn new( local_name: LocalName, namespace: Namespace, prefix: Option<Prefix>, @@ -329,7 +329,7 @@ impl Element { impl_rare_data!(ElementRareData); - pub fn restyle(&self, damage: NodeDamage) { + pub(crate) fn restyle(&self, damage: NodeDamage) { let doc = self.node.owner_doc(); let mut restyle = doc.ensure_pending_restyle(self); @@ -343,16 +343,16 @@ impl Element { } } - pub fn set_is(&self, is: LocalName) { + pub(crate) fn set_is(&self, is: LocalName) { *self.is.borrow_mut() = Some(is); } - pub fn get_is(&self) -> Option<LocalName> { + pub(crate) fn get_is(&self) -> Option<LocalName> { self.is.borrow().clone() } /// <https://dom.spec.whatwg.org/#concept-element-custom-element-state> - pub fn set_custom_element_state(&self, state: CustomElementState) { + pub(crate) fn set_custom_element_state(&self, state: CustomElementState) { // no need to inflate rare data for uncustomized if state != CustomElementState::Uncustomized || self.rare_data().is_some() { self.ensure_rare_data().custom_element_state = state; @@ -365,44 +365,44 @@ impl Element { self.set_state(ElementState::DEFINED, in_defined_state) } - pub fn get_custom_element_state(&self) -> CustomElementState { + pub(crate) fn get_custom_element_state(&self) -> CustomElementState { if let Some(rare_data) = self.rare_data().as_ref() { return rare_data.custom_element_state; } CustomElementState::Uncustomized } - pub fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) { + pub(crate) fn set_custom_element_definition(&self, definition: Rc<CustomElementDefinition>) { self.ensure_rare_data().custom_element_definition = Some(definition); } - pub fn get_custom_element_definition(&self) -> Option<Rc<CustomElementDefinition>> { + pub(crate) fn get_custom_element_definition(&self) -> Option<Rc<CustomElementDefinition>> { self.rare_data().as_ref()?.custom_element_definition.clone() } - pub fn clear_custom_element_definition(&self) { + pub(crate) fn clear_custom_element_definition(&self) { self.ensure_rare_data().custom_element_definition = None; } - pub fn push_callback_reaction(&self, function: Rc<Function>, args: Box<[Heap<JSVal>]>) { + pub(crate) fn push_callback_reaction(&self, function: Rc<Function>, args: Box<[Heap<JSVal>]>) { self.ensure_rare_data() .custom_element_reaction_queue .push(CustomElementReaction::Callback(function, args)); } - pub fn push_upgrade_reaction(&self, definition: Rc<CustomElementDefinition>) { + pub(crate) fn push_upgrade_reaction(&self, definition: Rc<CustomElementDefinition>) { self.ensure_rare_data() .custom_element_reaction_queue .push(CustomElementReaction::Upgrade(definition)); } - pub fn clear_reaction_queue(&self) { + pub(crate) fn clear_reaction_queue(&self) { if let Some(ref mut rare_data) = *self.rare_data_mut() { rare_data.custom_element_reaction_queue.clear(); } } - pub fn invoke_reactions(&self, can_gc: CanGc) { + pub(crate) fn invoke_reactions(&self, can_gc: CanGc) { loop { rooted_vec!(let mut reactions); match *self.rare_data_mut() { @@ -426,12 +426,12 @@ impl Element { /// style will be `None` for elements in a `display: none` subtree. otherwise, the element has a /// layout box iff it doesn't have `display: none`. - pub fn style(&self, can_gc: CanGc) -> Option<Arc<ComputedValues>> { + pub(crate) fn style(&self, can_gc: CanGc) -> Option<Arc<ComputedValues>> { self.upcast::<Node>().style(can_gc) } // https://drafts.csswg.org/cssom-view/#css-layout-box - pub fn has_css_layout_box(&self, can_gc: CanGc) -> bool { + pub(crate) fn has_css_layout_box(&self, can_gc: CanGc) -> bool { self.style(can_gc) .is_some_and(|s| !s.get_box().clone_display().is_none()) } @@ -499,12 +499,12 @@ impl Element { .map(|sr| DomRoot::from_ref(&**sr)) } - pub fn is_shadow_host(&self) -> bool { + pub(crate) fn is_shadow_host(&self) -> bool { self.shadow_root().is_some() } /// <https://dom.spec.whatwg.org/#dom-element-attachshadow> - pub fn attach_shadow( + pub(crate) fn attach_shadow( &self, // TODO: remove is_ua_widget argument is_ua_widget: IsUserAgentWidget, @@ -556,7 +556,7 @@ impl Element { Ok(shadow_root) } - pub fn detach_shadow(&self) { + pub(crate) fn detach_shadow(&self) { let Some(ref shadow_root) = self.shadow_root() else { unreachable!("Trying to detach a non-attached shadow root"); }; @@ -570,7 +570,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#translation-mode - pub fn is_translate_enabled(&self) -> bool { + pub(crate) fn is_translate_enabled(&self) -> bool { let name = &html5ever::local_name!("translate"); if self.has_attribute(name) { match_ignore_ascii_case! { &*self.get_string_attribute(name), @@ -588,7 +588,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#the-directionality - pub fn directionality(&self) -> String { + pub(crate) fn directionality(&self) -> String { self.downcast::<HTMLElement>() .and_then(|html_element| html_element.directionality()) .unwrap_or_else(|| { @@ -607,7 +607,7 @@ impl Element { /// <https://dom.spec.whatwg.org/#valid-shadow-host-name> #[inline] -pub fn is_valid_shadow_host_name(name: &LocalName) -> bool { +pub(crate) fn is_valid_shadow_host_name(name: &LocalName) -> bool { // > A valid shadow host name is: // > - a valid custom element name if is_valid_custom_element_name(name) { @@ -640,7 +640,7 @@ pub fn is_valid_shadow_host_name(name: &LocalName) -> bool { } #[inline] -pub fn get_attr_for_layout<'dom>( +pub(crate) fn get_attr_for_layout<'dom>( elem: LayoutDom<'dom, Element>, namespace: &Namespace, name: &LocalName, @@ -651,7 +651,7 @@ pub fn get_attr_for_layout<'dom>( .cloned() } -pub trait LayoutElementHelpers<'dom> { +pub(crate) trait LayoutElementHelpers<'dom> { fn attrs(self) -> &'dom [LayoutDom<'dom, Attr>]; fn has_class_for_layout(self, name: &AtomIdent, case_sensitivity: CaseSensitivity) -> bool; fn get_classes_for_layout(self) -> Option<&'dom [Atom]>; @@ -1216,43 +1216,43 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> { } impl Element { - pub fn is_html_element(&self) -> bool { + pub(crate) fn is_html_element(&self) -> bool { self.namespace == ns!(html) } - pub fn html_element_in_html_document(&self) -> bool { + pub(crate) fn html_element_in_html_document(&self) -> bool { self.is_html_element() && self.upcast::<Node>().is_in_html_doc() } - pub fn local_name(&self) -> &LocalName { + pub(crate) fn local_name(&self) -> &LocalName { &self.local_name } - pub fn parsed_name(&self, mut name: DOMString) -> LocalName { + pub(crate) fn parsed_name(&self, mut name: DOMString) -> LocalName { if self.html_element_in_html_document() { name.make_ascii_lowercase(); } LocalName::from(name) } - pub fn namespace(&self) -> &Namespace { + pub(crate) fn namespace(&self) -> &Namespace { &self.namespace } - pub fn prefix(&self) -> Ref<Option<Prefix>> { + pub(crate) fn prefix(&self) -> Ref<Option<Prefix>> { self.prefix.borrow() } - pub fn set_prefix(&self, prefix: Option<Prefix>) { + pub(crate) fn set_prefix(&self, prefix: Option<Prefix>) { *self.prefix.borrow_mut() = prefix; } - pub fn attrs(&self) -> Ref<[Dom<Attr>]> { + pub(crate) fn attrs(&self) -> Ref<[Dom<Attr>]> { Ref::map(self.attrs.borrow(), |attrs| &**attrs) } // Element branch of https://dom.spec.whatwg.org/#locate-a-namespace - pub fn locate_namespace(&self, prefix: Option<DOMString>) -> Namespace { + pub(crate) fn locate_namespace(&self, prefix: Option<DOMString>) -> Namespace { let namespace_prefix = prefix.clone().map(|s| Prefix::from(&*s)); // "1. If prefix is "xml", then return the XML namespace." @@ -1310,15 +1310,17 @@ impl Element { ns!() } - pub fn name_attribute(&self) -> Option<Atom> { + pub(crate) fn name_attribute(&self) -> Option<Atom> { self.rare_data().as_ref()?.name_attribute.clone() } - pub fn style_attribute(&self) -> &DomRefCell<Option<Arc<Locked<PropertyDeclarationBlock>>>> { + pub(crate) fn style_attribute( + &self, + ) -> &DomRefCell<Option<Arc<Locked<PropertyDeclarationBlock>>>> { &self.style_attribute } - pub fn summarize(&self) -> Vec<AttrInfo> { + pub(crate) fn summarize(&self) -> Vec<AttrInfo> { self.attrs .borrow() .iter() @@ -1326,7 +1328,7 @@ impl Element { .collect() } - pub fn is_void(&self) -> bool { + pub(crate) fn is_void(&self) -> bool { if self.namespace != ns!(html) { return false; } @@ -1355,7 +1357,7 @@ impl Element { } } - pub fn root_element(&self) -> DomRoot<Element> { + pub(crate) fn root_element(&self) -> DomRoot<Element> { if self.node.is_in_a_document_tree() { self.upcast::<Node>() .owner_doc() @@ -1371,7 +1373,7 @@ impl Element { } // https://dom.spec.whatwg.org/#locate-a-namespace-prefix - pub fn lookup_prefix(&self, namespace: Namespace) -> Option<DOMString> { + pub(crate) fn lookup_prefix(&self, namespace: Namespace) -> Option<DOMString> { for node in self .upcast::<Node>() .inclusive_ancestors(ShadowIncluding::No) @@ -1397,7 +1399,7 @@ impl Element { } // Returns the kind of IME control needed for a focusable element, if any. - pub fn input_method_type(&self) -> Option<InputMethodType> { + pub(crate) fn input_method_type(&self) -> Option<InputMethodType> { if !self.is_focusable_area() { return None; } @@ -1412,7 +1414,7 @@ impl Element { } } - pub fn is_focusable_area(&self) -> bool { + pub(crate) fn is_focusable_area(&self) -> bool { if self.is_actually_disabled() { return false; } @@ -1436,7 +1438,7 @@ impl Element { ) } - pub fn is_actually_disabled(&self) -> bool { + pub(crate) fn is_actually_disabled(&self) -> bool { let node = self.upcast::<Node>(); match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( @@ -1468,7 +1470,7 @@ impl Element { } } - pub fn push_new_attribute( + pub(crate) fn push_new_attribute( &self, local_name: LocalName, value: AttrValue, @@ -1490,7 +1492,7 @@ impl Element { self.push_attribute(&attr); } - pub fn push_attribute(&self, attr: &Attr) { + pub(crate) fn push_attribute(&self, attr: &Attr) { let name = attr.local_name().clone(); let namespace = attr.namespace().clone(); let mutation = Mutation::Attribute { @@ -1515,7 +1517,7 @@ impl Element { } } - pub fn get_attribute( + pub(crate) fn get_attribute( &self, namespace: &Namespace, local_name: &LocalName, @@ -1528,7 +1530,7 @@ impl Element { } /// <https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name> - pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> { + pub(crate) fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> { let name = &self.parsed_name(name); let maybe_attribute = self .attrs @@ -1550,7 +1552,7 @@ impl Element { maybe_attribute } - pub fn set_attribute_from_parser( + pub(crate) fn set_attribute_from_parser( &self, qname: QualName, value: DOMString, @@ -1578,7 +1580,7 @@ impl Element { self.push_new_attribute(qname.local, value, name, qname.ns, prefix, can_gc); } - pub fn set_attribute(&self, name: &LocalName, value: AttrValue, can_gc: CanGc) { + pub(crate) fn set_attribute(&self, name: &LocalName, value: AttrValue, can_gc: CanGc) { assert!(name == &name.to_ascii_lowercase()); assert!(!name.contains(':')); @@ -1594,7 +1596,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#attr-data-* - pub fn set_custom_attribute( + pub(crate) fn set_custom_attribute( &self, name: DOMString, value: DOMString, @@ -1646,7 +1648,7 @@ impl Element { }; } - pub fn parse_attribute( + pub(crate) fn parse_attribute( &self, namespace: &Namespace, local_name: &LocalName, @@ -1659,7 +1661,7 @@ impl Element { } } - pub fn remove_attribute( + pub(crate) fn remove_attribute( &self, namespace: &Namespace, local_name: &LocalName, @@ -1669,7 +1671,7 @@ impl Element { }) } - pub fn remove_attribute_by_name(&self, name: &LocalName) -> Option<DomRoot<Attr>> { + pub(crate) fn remove_attribute_by_name(&self, name: &LocalName) -> Option<DomRoot<Attr>> { self.remove_first_matching_attribute(|attr| attr.name() == name) } @@ -1706,7 +1708,7 @@ impl Element { }) } - pub fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { + pub(crate) fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { self.get_attribute(&ns!(), &local_name!("class")) .is_some_and(|attr| { attr.value() @@ -1716,13 +1718,18 @@ impl Element { }) } - pub fn set_atomic_attribute(&self, local_name: &LocalName, value: DOMString, can_gc: CanGc) { + pub(crate) fn set_atomic_attribute( + &self, + local_name: &LocalName, + value: DOMString, + can_gc: CanGc, + ) { assert!(*local_name == local_name.to_ascii_lowercase()); let value = AttrValue::from_atomic(value.into()); self.set_attribute(local_name, value, can_gc); } - pub fn has_attribute(&self, local_name: &LocalName) -> bool { + pub(crate) fn has_attribute(&self, local_name: &LocalName) -> bool { assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b)); self.attrs .borrow() @@ -1730,7 +1737,7 @@ impl Element { .any(|attr| attr.local_name() == local_name && attr.namespace() == &ns!()) } - pub fn set_bool_attribute(&self, local_name: &LocalName, value: bool, can_gc: CanGc) { + pub(crate) fn set_bool_attribute(&self, local_name: &LocalName, value: bool, can_gc: CanGc) { if self.has_attribute(local_name) == value { return; } @@ -1741,7 +1748,7 @@ impl Element { } } - pub fn get_url_attribute(&self, local_name: &LocalName) -> USVString { + pub(crate) fn get_url_attribute(&self, local_name: &LocalName) -> USVString { assert!(*local_name == local_name.to_ascii_lowercase()); let attr = match self.get_attribute(&ns!(), local_name) { Some(attr) => attr, @@ -1756,19 +1763,29 @@ impl Element { .unwrap_or_else(|_| USVString(value.to_owned())) } - pub fn set_url_attribute(&self, local_name: &LocalName, value: USVString, can_gc: CanGc) { + pub(crate) fn set_url_attribute( + &self, + local_name: &LocalName, + value: USVString, + can_gc: CanGc, + ) { assert!(*local_name == local_name.to_ascii_lowercase()); self.set_attribute(local_name, AttrValue::String(value.to_string()), can_gc); } - pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString { + pub(crate) fn get_string_attribute(&self, local_name: &LocalName) -> DOMString { match self.get_attribute(&ns!(), local_name) { Some(x) => x.Value(), None => DOMString::new(), } } - pub fn set_string_attribute(&self, local_name: &LocalName, value: DOMString, can_gc: CanGc) { + pub(crate) fn set_string_attribute( + &self, + local_name: &LocalName, + value: DOMString, + can_gc: CanGc, + ) { assert!(*local_name == local_name.to_ascii_lowercase()); self.set_attribute(local_name, AttrValue::String(value.into()), can_gc); } @@ -1801,13 +1818,18 @@ impl Element { } } - pub fn get_tokenlist_attribute(&self, local_name: &LocalName) -> Vec<Atom> { + pub(crate) fn get_tokenlist_attribute(&self, local_name: &LocalName) -> Vec<Atom> { self.get_attribute(&ns!(), local_name) .map(|attr| attr.value().as_tokens().to_vec()) .unwrap_or_default() } - pub fn set_tokenlist_attribute(&self, local_name: &LocalName, value: DOMString, can_gc: CanGc) { + pub(crate) fn set_tokenlist_attribute( + &self, + local_name: &LocalName, + value: DOMString, + can_gc: CanGc, + ) { assert!(*local_name == local_name.to_ascii_lowercase()); self.set_attribute( local_name, @@ -1816,7 +1838,7 @@ impl Element { ); } - pub fn set_atomic_tokenlist_attribute( + pub(crate) fn set_atomic_tokenlist_attribute( &self, local_name: &LocalName, tokens: Vec<Atom>, @@ -1826,7 +1848,7 @@ impl Element { self.set_attribute(local_name, AttrValue::from_atomic_tokens(tokens), can_gc); } - pub fn get_int_attribute(&self, local_name: &LocalName, default: i32) -> i32 { + pub(crate) fn get_int_attribute(&self, local_name: &LocalName, default: i32) -> i32 { // TODO: Is this assert necessary? assert!(local_name .chars() @@ -1845,12 +1867,12 @@ impl Element { } } - pub fn set_int_attribute(&self, local_name: &LocalName, value: i32, can_gc: CanGc) { + pub(crate) fn set_int_attribute(&self, local_name: &LocalName, value: i32, can_gc: CanGc) { assert!(*local_name == local_name.to_ascii_lowercase()); self.set_attribute(local_name, AttrValue::Int(value.to_string(), value), can_gc); } - pub fn get_uint_attribute(&self, local_name: &LocalName, default: u32) -> u32 { + pub(crate) fn get_uint_attribute(&self, local_name: &LocalName, default: u32) -> u32 { assert!(local_name .chars() .all(|ch| !ch.is_ascii() || ch.to_ascii_lowercase() == ch)); @@ -1863,7 +1885,7 @@ impl Element { None => default, } } - pub fn set_uint_attribute(&self, local_name: &LocalName, value: u32, can_gc: CanGc) { + pub(crate) fn set_uint_attribute(&self, local_name: &LocalName, value: u32, can_gc: CanGc) { assert!(*local_name == local_name.to_ascii_lowercase()); self.set_attribute( local_name, @@ -1872,13 +1894,13 @@ impl Element { ); } - pub fn will_mutate_attr(&self, attr: &Attr) { + pub(crate) fn will_mutate_attr(&self, attr: &Attr) { let node = self.upcast::<Node>(); node.owner_doc().element_attr_will_change(self, attr); } // https://dom.spec.whatwg.org/#insert-adjacent - pub fn insert_adjacent( + pub(crate) fn insert_adjacent( &self, where_: AdjacentPosition, node: &Node, @@ -1907,7 +1929,7 @@ impl Element { } // https://drafts.csswg.org/cssom-view/#dom-element-scroll - pub fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior, can_gc: CanGc) { + pub(crate) fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior, can_gc: CanGc) { // Step 1.2 or 2.3 let x = if x_.is_finite() { x_ } else { 0.0f64 }; let y = if y_.is_finite() { y_ } else { 0.0f64 }; @@ -1959,7 +1981,7 @@ impl Element { } /// <https://html.spec.whatwg.org/multipage/#fragment-parsing-algorithm-steps> - pub fn parse_fragment( + pub(crate) fn parse_fragment( &self, markup: DOMString, can_gc: CanGc, @@ -1985,7 +2007,7 @@ impl Element { Ok(fragment) } - pub fn fragment_parsing_context( + pub(crate) fn fragment_parsing_context( owner_doc: &Document, element: Option<&Self>, can_gc: CanGc, @@ -2008,7 +2030,7 @@ impl Element { } // https://fullscreen.spec.whatwg.org/#fullscreen-element-ready-check - pub fn fullscreen_element_ready_check(&self) -> bool { + pub(crate) fn fullscreen_element_ready_check(&self) -> bool { if !self.is_connected() { return false; } @@ -2016,7 +2038,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#home-subtree - pub fn is_in_same_home_subtree<T>(&self, other: &T) -> bool + pub(crate) fn is_in_same_home_subtree<T>(&self, other: &T) -> bool where T: DerivedFrom<Element> + DomObject, { @@ -2024,11 +2046,11 @@ impl Element { self.root_element() == other.root_element() } - pub fn get_id(&self) -> Option<Atom> { + pub(crate) fn get_id(&self) -> Option<Atom> { self.id_attribute.borrow().clone() } - pub fn get_name(&self) -> Option<Atom> { + pub(crate) fn get_name(&self) -> Option<Atom> { self.rare_data().as_ref()?.name_attribute.clone() } @@ -2092,7 +2114,7 @@ impl Element { } } - pub fn get_element_internals(&self) -> Option<DomRoot<ElementInternals>> { + pub(crate) fn get_element_internals(&self) -> Option<DomRoot<ElementInternals>> { self.rare_data() .as_ref()? .element_internals @@ -2100,7 +2122,7 @@ impl Element { .map(|sr| DomRoot::from_ref(&**sr)) } - pub fn ensure_element_internals(&self) -> DomRoot<ElementInternals> { + pub(crate) fn ensure_element_internals(&self) -> DomRoot<ElementInternals> { let mut rare_data = self.ensure_rare_data(); DomRoot::from_ref(rare_data.element_internals.get_or_insert_with(|| { let elem = self @@ -4011,7 +4033,7 @@ impl Element { rect } - pub fn as_maybe_activatable(&self) -> Option<&dyn Activatable> { + pub(crate) fn as_maybe_activatable(&self) -> Option<&dyn Activatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, @@ -4052,7 +4074,7 @@ impl Element { }) } - pub fn as_stylesheet_owner(&self) -> Option<&dyn StylesheetOwner> { + pub(crate) fn as_stylesheet_owner(&self) -> Option<&dyn StylesheetOwner> { if let Some(s) = self.downcast::<HTMLStyleElement>() { return Some(s as &dyn StylesheetOwner); } @@ -4065,7 +4087,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#category-submit - pub fn as_maybe_validatable(&self) -> Option<&dyn Validatable> { + pub(crate) fn as_maybe_validatable(&self) -> Option<&dyn Validatable> { let element = match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLInputElement, @@ -4114,7 +4136,7 @@ impl Element { element } - pub fn is_invalid(&self, needs_update: bool) -> bool { + pub(crate) fn is_invalid(&self, needs_update: bool) -> bool { if let Some(validatable) = self.as_maybe_validatable() { if needs_update { validatable @@ -4130,7 +4152,7 @@ impl Element { false } - pub fn is_instance_validatable(&self) -> bool { + pub(crate) fn is_instance_validatable(&self) -> bool { if let Some(validatable) = self.as_maybe_validatable() { return validatable.is_instance_validatable(); } @@ -4140,23 +4162,23 @@ impl Element { false } - pub fn init_state_for_internals(&self) { + pub(crate) fn init_state_for_internals(&self) { self.set_enabled_state(true); self.set_state(ElementState::VALID, true); self.set_state(ElementState::INVALID, false); } - pub fn click_in_progress(&self) -> bool { + pub(crate) fn click_in_progress(&self) -> bool { self.upcast::<Node>().get_flag(NodeFlags::CLICK_IN_PROGRESS) } - pub fn set_click_in_progress(&self, click: bool) { + pub(crate) fn set_click_in_progress(&self, click: bool) { self.upcast::<Node>() .set_flag(NodeFlags::CLICK_IN_PROGRESS, click) } // https://html.spec.whatwg.org/multipage/#nearest-activatable-element - pub fn nearest_activable_element(&self) -> Option<DomRoot<Element>> { + pub(crate) fn nearest_activable_element(&self) -> Option<DomRoot<Element>> { match self.as_maybe_activatable() { Some(el) => Some(DomRoot::from_ref(el.as_element())), None => { @@ -4174,7 +4196,7 @@ impl Element { } // https://html.spec.whatwg.org/multipage/#language - pub fn get_lang(&self) -> String { + pub(crate) fn get_lang(&self) -> String { self.upcast::<Node>() .inclusive_ancestors(ShadowIncluding::Yes) .filter_map(|node| { @@ -4190,11 +4212,11 @@ impl Element { .unwrap_or(String::new()) } - pub fn state(&self) -> ElementState { + pub(crate) fn state(&self) -> ElementState { self.state.get() } - pub fn set_state(&self, which: ElementState, value: bool) { + pub(crate) fn set_state(&self, which: ElementState, value: bool) { let mut state = self.state.get(); if state.contains(which) == value { return; @@ -4210,7 +4232,7 @@ impl Element { } /// <https://html.spec.whatwg.org/multipage/#concept-selector-active> - pub fn set_active_state(&self, value: bool) { + pub(crate) fn set_active_state(&self, value: bool) { self.set_state(ElementState::ACTIVE, value); if let Some(parent) = self.upcast::<Node>().GetParentElement() { @@ -4218,73 +4240,73 @@ impl Element { } } - pub fn focus_state(&self) -> bool { + pub(crate) fn focus_state(&self) -> bool { self.state.get().contains(ElementState::FOCUS) } - pub fn set_focus_state(&self, value: bool) { + pub(crate) fn set_focus_state(&self, value: bool) { self.set_state(ElementState::FOCUS, value); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } - pub fn hover_state(&self) -> bool { + pub(crate) fn hover_state(&self) -> bool { self.state.get().contains(ElementState::HOVER) } - pub fn set_hover_state(&self, value: bool) { + pub(crate) fn set_hover_state(&self, value: bool) { self.set_state(ElementState::HOVER, value) } - pub fn enabled_state(&self) -> bool { + pub(crate) fn enabled_state(&self) -> bool { self.state.get().contains(ElementState::ENABLED) } - pub fn set_enabled_state(&self, value: bool) { + pub(crate) fn set_enabled_state(&self, value: bool) { self.set_state(ElementState::ENABLED, value) } - pub fn disabled_state(&self) -> bool { + pub(crate) fn disabled_state(&self) -> bool { self.state.get().contains(ElementState::DISABLED) } - pub fn set_disabled_state(&self, value: bool) { + pub(crate) fn set_disabled_state(&self, value: bool) { self.set_state(ElementState::DISABLED, value) } - pub fn read_write_state(&self) -> bool { + pub(crate) fn read_write_state(&self) -> bool { self.state.get().contains(ElementState::READWRITE) } - pub fn set_read_write_state(&self, value: bool) { + pub(crate) fn set_read_write_state(&self, value: bool) { self.set_state(ElementState::READWRITE, value) } - pub fn placeholder_shown_state(&self) -> bool { + pub(crate) fn placeholder_shown_state(&self) -> bool { self.state.get().contains(ElementState::PLACEHOLDER_SHOWN) } - pub fn set_placeholder_shown_state(&self, value: bool) { + pub(crate) fn set_placeholder_shown_state(&self, value: bool) { if self.placeholder_shown_state() != value { self.set_state(ElementState::PLACEHOLDER_SHOWN, value); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); } } - pub fn set_target_state(&self, value: bool) { + pub(crate) fn set_target_state(&self, value: bool) { self.set_state(ElementState::URLTARGET, value) } - pub fn set_fullscreen_state(&self, value: bool) { + pub(crate) fn set_fullscreen_state(&self, value: bool) { self.set_state(ElementState::FULLSCREEN, value) } /// <https://dom.spec.whatwg.org/#connected> - pub fn is_connected(&self) -> bool { + pub(crate) fn is_connected(&self) -> bool { self.upcast::<Node>().is_connected() } // https://html.spec.whatwg.org/multipage/#cannot-navigate - pub fn cannot_navigate(&self) -> bool { + pub(crate) fn cannot_navigate(&self) -> bool { let document = self.owner_document(); // Step 1. @@ -4297,7 +4319,7 @@ impl Element { } impl Element { - pub fn check_ancestors_disabled_state_for_form_control(&self) { + pub(crate) fn check_ancestors_disabled_state_for_form_control(&self) { let node = self.upcast::<Node>(); if self.disabled_state() { return; @@ -4326,7 +4348,7 @@ impl Element { } } - pub fn check_parent_disabled_state_for_option(&self) { + pub(crate) fn check_parent_disabled_state_for_option(&self) { if self.disabled_state() { return; } @@ -4341,20 +4363,20 @@ impl Element { } } - pub fn check_disabled_attribute(&self) { + pub(crate) fn check_disabled_attribute(&self) { let has_disabled_attrib = self.has_attribute(&local_name!("disabled")); self.set_disabled_state(has_disabled_attrib); self.set_enabled_state(!has_disabled_attrib); } - pub fn update_read_write_state_from_readonly_attribute(&self) { + pub(crate) fn update_read_write_state_from_readonly_attribute(&self) { let has_readonly_attribute = self.has_attribute(&local_name!("readonly")); self.set_read_write_state(has_readonly_attribute); } } #[derive(Clone, Copy)] -pub enum AttributeMutation<'a> { +pub(crate) enum AttributeMutation<'a> { /// The attribute is set, keep track of old value. /// <https://dom.spec.whatwg.org/#attribute-is-set> Set(Option<&'a AttrValue>), @@ -4365,14 +4387,14 @@ pub enum AttributeMutation<'a> { } impl AttributeMutation<'_> { - pub fn is_removal(&self) -> bool { + pub(crate) fn is_removal(&self) -> bool { match *self { AttributeMutation::Removed => true, AttributeMutation::Set(..) => false, } } - pub fn new_value<'b>(&self, attr: &'b Attr) -> Option<Ref<'b, AttrValue>> { + pub(crate) fn new_value<'b>(&self, attr: &'b Attr) -> Option<Ref<'b, AttrValue>> { match *self { AttributeMutation::Set(_) => Some(attr.value()), AttributeMutation::Removed => None, @@ -4419,14 +4441,14 @@ impl TagName { } } -pub struct ElementPerformFullscreenEnter { +pub(crate) struct ElementPerformFullscreenEnter { element: Trusted<Element>, promise: TrustedPromise, error: bool, } impl ElementPerformFullscreenEnter { - pub fn new( + pub(crate) fn new( element: Trusted<Element>, promise: TrustedPromise, error: bool, @@ -4470,13 +4492,13 @@ impl TaskOnce for ElementPerformFullscreenEnter { } } -pub struct ElementPerformFullscreenExit { +pub(crate) struct ElementPerformFullscreenExit { element: Trusted<Element>, promise: TrustedPromise, } impl ElementPerformFullscreenExit { - pub fn new( + pub(crate) fn new( element: Trusted<Element>, promise: TrustedPromise, ) -> Box<ElementPerformFullscreenExit> { @@ -4504,7 +4526,7 @@ impl TaskOnce for ElementPerformFullscreenExit { } } -pub fn reflect_cross_origin_attribute(element: &Element) -> Option<DOMString> { +pub(crate) fn reflect_cross_origin_attribute(element: &Element) -> Option<DOMString> { let attr = element.get_attribute(&ns!(), &local_name!("crossorigin")); if let Some(mut val) = attr.map(|v| v.Value()) { @@ -4517,7 +4539,11 @@ pub fn reflect_cross_origin_attribute(element: &Element) -> Option<DOMString> { None } -pub fn set_cross_origin_attribute(element: &Element, value: Option<DOMString>, can_gc: CanGc) { +pub(crate) fn set_cross_origin_attribute( + element: &Element, + value: Option<DOMString>, + can_gc: CanGc, +) { match value { Some(val) => element.set_string_attribute(&local_name!("crossorigin"), val, can_gc), None => { @@ -4526,7 +4552,7 @@ pub fn set_cross_origin_attribute(element: &Element, value: Option<DOMString>, c } } -pub fn reflect_referrer_policy_attribute(element: &Element) -> DOMString { +pub(crate) fn reflect_referrer_policy_attribute(element: &Element) -> DOMString { let attr = element.get_attribute_by_name(DOMString::from_string(String::from("referrerpolicy"))); diff --git a/components/script/dom/elementinternals.rs b/components/script/dom/elementinternals.rs index bb717e9e419..4156a5a725b 100644 --- a/components/script/dom/elementinternals.rs +++ b/components/script/dom/elementinternals.rs @@ -53,7 +53,7 @@ impl From<Option<&FileOrUSVStringOrFormData>> for SubmissionValue { } #[dom_struct] -pub struct ElementInternals { +pub(crate) struct ElementInternals { reflector_: Reflector, /// If `attached` is false, we're using this to hold form-related state /// on an element for which `attachInternals()` wasn't called yet; this is @@ -87,7 +87,7 @@ impl ElementInternals { } } - pub fn new(element: &HTMLElement) -> DomRoot<ElementInternals> { + pub(crate) fn new(element: &HTMLElement) -> DomRoot<ElementInternals> { let global = element.owner_window(); reflect_dom_object( Box::new(ElementInternals::new_inherited(element)), @@ -116,23 +116,23 @@ impl ElementInternals { *self.state.borrow_mut() = value; } - pub fn set_form_owner(&self, form: Option<&HTMLFormElement>) { + pub(crate) fn set_form_owner(&self, form: Option<&HTMLFormElement>) { self.form_owner.set(form); } - pub fn form_owner(&self) -> Option<DomRoot<HTMLFormElement>> { + pub(crate) fn form_owner(&self) -> Option<DomRoot<HTMLFormElement>> { self.form_owner.get() } - pub fn set_attached(&self) { + pub(crate) fn set_attached(&self) { self.attached.set(true); } - pub fn attached(&self) -> bool { + pub(crate) fn attached(&self) -> bool { self.attached.get() } - pub fn perform_entry_construction(&self, entry_list: &mut Vec<FormDatum>) { + pub(crate) fn perform_entry_construction(&self, entry_list: &mut Vec<FormDatum>) { if self .target_element .upcast::<Element>() @@ -180,7 +180,7 @@ impl ElementInternals { } } - pub fn is_invalid(&self) -> bool { + pub(crate) fn is_invalid(&self) -> bool { self.is_target_form_associated() && self.is_instance_validatable() && !self.satisfies_constraints() diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index f2075f90708..eb81c6a630f 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -25,7 +25,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct ErrorEvent { +pub(crate) struct ErrorEvent { event: Event, message: DomRefCell<DOMString>, filename: DomRefCell<DOMString>, @@ -56,7 +56,7 @@ impl ErrorEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 5db7ee679d9..05a58274414 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -42,7 +42,7 @@ use crate::task::TaskOnce; /// <https://dom.spec.whatwg.org/#concept-event> #[dom_struct] -pub struct Event { +pub(crate) struct Event { reflector_: Reflector, /// <https://dom.spec.whatwg.org/#dom-event-currenttarget> @@ -96,7 +96,7 @@ pub struct Event { /// An element on an [event path](https://dom.spec.whatwg.org/#event-path) #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct EventPathSegment { +pub(crate) struct EventPathSegment { /// <https://dom.spec.whatwg.org/#event-path-invocation-target> invocation_target: Dom<EventTarget>, @@ -876,7 +876,7 @@ impl EventMethods<crate::DomTypeHolder> for Event { } #[derive(Clone, Copy, MallocSizeOf, PartialEq)] -pub enum EventBubbles { +pub(crate) enum EventBubbles { Bubbles, DoesNotBubble, } @@ -901,7 +901,7 @@ impl From<EventBubbles> for bool { } #[derive(Clone, Copy, MallocSizeOf, PartialEq)] -pub enum EventCancelable { +pub(crate) enum EventCancelable { Cancelable, NotCancelable, } @@ -928,7 +928,7 @@ impl From<EventCancelable> for bool { #[derive(Clone, Copy, Debug, Eq, JSTraceable, PartialEq)] #[repr(u16)] #[derive(MallocSizeOf)] -pub enum EventPhase { +pub(crate) enum EventPhase { None = EventConstants::NONE, Capturing = EventConstants::CAPTURING_PHASE, AtTarget = EventConstants::AT_TARGET, @@ -947,7 +947,7 @@ pub enum EventPhase { /// [msg]: https://doc.servo.org/compositing/enum.ConstellationMsg.html#variant.KeyEvent /// #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum EventDefault { +pub(crate) enum EventDefault { /// The default action of the event is allowed (constructor's default) Allowed, /// The default action has been prevented by calling `PreventDefault` @@ -958,17 +958,17 @@ pub enum EventDefault { } #[derive(PartialEq)] -pub enum EventStatus { +pub(crate) enum EventStatus { Canceled, NotCanceled, } /// <https://dom.spec.whatwg.org/#concept-event-fire> -pub struct EventTask { - pub target: Trusted<EventTarget>, - pub name: Atom, - pub bubbles: EventBubbles, - pub cancelable: EventCancelable, +pub(crate) struct EventTask { + pub(crate) target: Trusted<EventTarget>, + pub(crate) name: Atom, + pub(crate) bubbles: EventBubbles, + pub(crate) cancelable: EventCancelable, } impl TaskOnce for EventTask { @@ -981,9 +981,9 @@ impl TaskOnce for EventTask { } /// <https://html.spec.whatwg.org/multipage/#fire-a-simple-event> -pub struct SimpleEventTask { - pub target: Trusted<EventTarget>, - pub name: Atom, +pub(crate) struct SimpleEventTask { + pub(crate) target: Trusted<EventTarget>, + pub(crate) name: Atom, } impl TaskOnce for SimpleEventTask { diff --git a/components/script/dom/eventsource.rs b/components/script/dom/eventsource.rs index d247f0696e4..39adc36332c 100644 --- a/components/script/dom/eventsource.rs +++ b/components/script/dom/eventsource.rs @@ -24,7 +24,6 @@ use net_traits::{ }; use servo_atoms::Atom; use servo_url::ServoUrl; -use utf8; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventSourceBinding::{ @@ -61,7 +60,7 @@ enum ReadyState { } #[dom_struct] -pub struct EventSource { +pub(crate) struct EventSource { eventtarget: EventTarget, #[no_trace] url: ServoUrl, @@ -482,13 +481,13 @@ impl EventSource { } // https://html.spec.whatwg.org/multipage/#sse-processing-model:fail-the-connection-3 - pub fn cancel(&self) { + pub(crate) fn cancel(&self) { self.canceller.borrow_mut().cancel(); self.fail_the_connection(); } /// <https://html.spec.whatwg.org/multipage/#fail-the-connection> - pub fn fail_the_connection(&self) { + pub(crate) fn fail_the_connection(&self) { let global = self.global(); let event_source = Trusted::new(self); global.task_manager().remote_event_task_source().queue( @@ -502,11 +501,11 @@ impl EventSource { ); } - pub fn request(&self) -> RequestBuilder { + pub(crate) fn request(&self) -> RequestBuilder { self.request.borrow().clone().unwrap() } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.url } } @@ -649,7 +648,7 @@ impl EventSourceMethods<crate::DomTypeHolder> for EventSource { } #[derive(JSTraceable, MallocSizeOf)] -pub struct EventSourceTimeoutCallback { +pub(crate) struct EventSourceTimeoutCallback { #[ignore_malloc_size_of = "Because it is non-owning"] event_source: Trusted<EventSource>, #[ignore_malloc_size_of = "Because it is non-owning"] @@ -659,7 +658,7 @@ pub struct EventSourceTimeoutCallback { impl EventSourceTimeoutCallback { // https://html.spec.whatwg.org/multipage/#reestablish-the-connection - pub fn invoke(self) { + pub(crate) fn invoke(self) { let event_source = self.event_source.root(); let global = event_source.global(); // Step 5.1 diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 306320d1a32..b5404890160 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -66,7 +66,7 @@ use crate::script_runtime::CanGc; #[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)] #[allow(clippy::enum_variant_names)] -pub enum CommonEventHandler { +pub(crate) enum CommonEventHandler { EventHandler(#[ignore_malloc_size_of = "Rc"] Rc<EventHandlerNonNull>), ErrorEventHandler(#[ignore_malloc_size_of = "Rc"] Rc<OnErrorEventHandlerNonNull>), @@ -85,7 +85,7 @@ impl CommonEventHandler { } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ListenerPhase { +pub(crate) enum ListenerPhase { Capturing, Bubbling, } @@ -159,14 +159,14 @@ impl EventListenerType { /// A representation of an EventListener/EventHandler object that has previously /// been compiled successfully, if applicable. -pub enum CompiledEventListener { +pub(crate) enum CompiledEventListener { Listener(Rc<EventListener>), Handler(CommonEventHandler), } impl CompiledEventListener { #[allow(unsafe_code)] - pub fn associated_global(&self) -> DomRoot<GlobalScope> { + pub(crate) fn associated_global(&self) -> DomRoot<GlobalScope> { let obj = match self { CompiledEventListener::Listener(listener) => listener.callback(), CompiledEventListener::Handler(CommonEventHandler::EventHandler(handler)) => { @@ -183,7 +183,7 @@ impl CompiledEventListener { } // https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm - pub fn call_or_handle_event( + pub(crate) fn call_or_handle_event( &self, object: &EventTarget, event: &Event, @@ -368,13 +368,13 @@ impl EventListeners { } #[dom_struct] -pub struct EventTarget { +pub(crate) struct EventTarget { reflector_: Reflector, handlers: DomRefCell<HashMapTracedValues<Atom, EventListeners, BuildHasherDefault<FnvHasher>>>, } impl EventTarget { - pub fn new_inherited() -> EventTarget { + pub(crate) fn new_inherited() -> EventTarget { EventTarget { reflector_: Reflector::new(), handlers: DomRefCell::new(Default::default()), @@ -396,14 +396,14 @@ impl EventTarget { /// Determine if there are any listeners for a given event type. /// See <https://github.com/whatwg/dom/issues/453>. - pub fn has_listeners_for(&self, type_: &Atom) -> bool { + pub(crate) fn has_listeners_for(&self, type_: &Atom) -> bool { match self.handlers.borrow().get(type_) { Some(listeners) => listeners.has_listeners(), None => false, } } - pub fn get_listeners_for( + pub(crate) fn get_listeners_for( &self, type_: &Atom, specific_phase: Option<ListenerPhase>, @@ -417,11 +417,11 @@ impl EventTarget { }) } - pub fn dispatch_event(&self, event: &Event, can_gc: CanGc) -> EventStatus { + pub(crate) fn dispatch_event(&self, event: &Event, can_gc: CanGc) -> EventStatus { event.dispatch(self, false, can_gc) } - pub fn remove_all_listeners(&self) { + pub(crate) fn remove_all_listeners(&self) { *self.handlers.borrow_mut() = Default::default(); } @@ -460,7 +460,7 @@ impl EventTarget { } } - pub fn remove_listener_if_once(&self, ty: &Atom, listener: &Rc<EventListener>) { + pub(crate) fn remove_listener_if_once(&self, ty: &Atom, listener: &Rc<EventListener>) { let mut handlers = self.handlers.borrow_mut(); let listener = EventListenerType::Additive(listener.clone()); @@ -478,7 +478,7 @@ impl EventTarget { /// Store the raw uncompiled event handler for on-demand compilation later. /// <https://html.spec.whatwg.org/multipage/#event-handler-attributes:event-handler-content-attributes-3> - pub fn set_event_handler_uncompiled( + pub(crate) fn set_event_handler_uncompiled( &self, url: ServoUrl, line: usize, @@ -612,7 +612,7 @@ impl EventTarget { } #[allow(unsafe_code)] - pub fn set_event_handler_common<T: CallbackContainer>( + pub(crate) fn set_event_handler_common<T: CallbackContainer>( &self, ty: &str, listener: Option<Rc<T>>, @@ -628,7 +628,11 @@ impl EventTarget { } #[allow(unsafe_code)] - pub fn set_error_event_handler<T: CallbackContainer>(&self, ty: &str, listener: Option<Rc<T>>) { + pub(crate) fn set_error_event_handler<T: CallbackContainer>( + &self, + ty: &str, + listener: Option<Rc<T>>, + ) { let cx = GlobalScope::get_cx(); let event_listener = listener.map(|listener| { @@ -640,7 +644,7 @@ impl EventTarget { } #[allow(unsafe_code)] - pub fn set_beforeunload_event_handler<T: CallbackContainer>( + pub(crate) fn set_beforeunload_event_handler<T: CallbackContainer>( &self, ty: &str, listener: Option<Rc<T>>, @@ -656,7 +660,7 @@ impl EventTarget { } #[allow(unsafe_code)] - pub fn get_event_handler_common<T: CallbackContainer>( + pub(crate) fn get_event_handler_common<T: CallbackContainer>( &self, ty: &str, can_gc: CanGc, @@ -670,12 +674,12 @@ impl EventTarget { } } - pub fn has_handlers(&self) -> bool { + pub(crate) fn has_handlers(&self) -> bool { !self.handlers.borrow().is_empty() } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { + pub(crate) fn fire_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { self.fire_event_with_params( name, EventBubbles::DoesNotBubble, @@ -685,7 +689,7 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_bubbling_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { + pub(crate) fn fire_bubbling_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { self.fire_event_with_params( name, EventBubbles::Bubbles, @@ -695,7 +699,7 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_cancelable_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { + pub(crate) fn fire_cancelable_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { self.fire_event_with_params( name, EventBubbles::DoesNotBubble, @@ -705,7 +709,11 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_bubbling_cancelable_event(&self, name: Atom, can_gc: CanGc) -> DomRoot<Event> { + pub(crate) fn fire_bubbling_cancelable_event( + &self, + name: Atom, + can_gc: CanGc, + ) -> DomRoot<Event> { self.fire_event_with_params( name, EventBubbles::Bubbles, @@ -715,7 +723,7 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#concept-event-fire - pub fn fire_event_with_params( + pub(crate) fn fire_event_with_params( &self, name: Atom, bubbles: EventBubbles, @@ -727,7 +735,7 @@ impl EventTarget { event } // https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener - pub fn add_event_listener( + pub(crate) fn add_event_listener( &self, ty: DOMString, listener: Option<Rc<EventListener>>, @@ -759,7 +767,7 @@ impl EventTarget { } // https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener - pub fn remove_event_listener( + pub(crate) fn remove_event_listener( &self, ty: DOMString, listener: Option<Rc<EventListener>>, diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs index 1bec9c8cf25..87c5485f0f8 100644 --- a/components/script/dom/extendableevent.rs +++ b/components/script/dom/extendableevent.rs @@ -21,21 +21,21 @@ use crate::script_runtime::{CanGc, JSContext}; // https://w3c.github.io/ServiceWorker/#extendable-event #[dom_struct] -pub struct ExtendableEvent { +pub(crate) struct ExtendableEvent { event: Event, extensions_allowed: bool, } #[allow(non_snake_case)] impl ExtendableEvent { - pub fn new_inherited() -> ExtendableEvent { + pub(crate) fn new_inherited() -> ExtendableEvent { ExtendableEvent { event: Event::new_inherited(), extensions_allowed: true, } } - pub fn new( + pub(crate) fn new( worker: &ServiceWorkerGlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/extendablemessageevent.rs b/components/script/dom/extendablemessageevent.rs index 484fa06cf84..d05488e7f52 100644 --- a/components/script/dom/extendablemessageevent.rs +++ b/components/script/dom/extendablemessageevent.rs @@ -28,7 +28,7 @@ use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] #[allow(non_snake_case)] -pub struct ExtendableMessageEvent { +pub(crate) struct ExtendableMessageEvent { /// <https://w3c.github.io/ServiceWorker/#extendableevent> event: ExtendableEvent, /// <https://w3c.github.io/ServiceWorker/#dom-extendablemessageevent-data> @@ -46,7 +46,7 @@ pub struct ExtendableMessageEvent { #[allow(non_snake_case)] impl ExtendableMessageEvent { - pub fn new_inherited( + pub(crate) fn new_inherited( origin: DOMString, lastEventId: DOMString, ports: Vec<DomRoot<MessagePort>>, @@ -65,7 +65,7 @@ impl ExtendableMessageEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, @@ -121,7 +121,7 @@ impl ExtendableMessageEvent { #[allow(non_snake_case)] impl ExtendableMessageEvent { - pub fn dispatch_jsval( + pub(crate) fn dispatch_jsval( target: &EventTarget, scope: &GlobalScope, message: HandleValue, @@ -144,7 +144,7 @@ impl ExtendableMessageEvent { .fire(target, can_gc); } - pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) { + pub(crate) fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) { let init = ExtendableMessageEventBinding::ExtendableMessageEventInit::empty(); let ExtendableMsgEvent = ExtendableMessageEvent::new( scope, diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 7863ea5bf59..f3f78fe2c7f 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -24,7 +24,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct File { +pub(crate) struct File { blob: Blob, name: DOMString, modified: SystemTime, @@ -41,7 +41,7 @@ impl File { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, blob_impl: BlobImpl, name: DOMString, @@ -71,7 +71,7 @@ impl File { } // Construct from selected file message from file manager thread - pub fn new_from_selected( + pub(crate) fn new_from_selected( window: &Window, selected: SelectedFile, can_gc: CanGc, @@ -97,15 +97,15 @@ impl File { ) } - pub fn file_bytes(&self) -> Result<Vec<u8>, ()> { + pub(crate) fn file_bytes(&self) -> Result<Vec<u8>, ()> { self.blob.get_bytes() } - pub fn name(&self) -> &DOMString { + pub(crate) fn name(&self) -> &DOMString { &self.name } - pub fn file_type(&self) -> String { + pub(crate) fn file_type(&self) -> String { self.blob.type_string() } } diff --git a/components/script/dom/filelist.rs b/components/script/dom/filelist.rs index 25f463f8dde..f3e077aa3fe 100644 --- a/components/script/dom/filelist.rs +++ b/components/script/dom/filelist.rs @@ -15,7 +15,7 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/FileAPI/#dfn-filelist #[dom_struct] -pub struct FileList { +pub(crate) struct FileList { reflector_: Reflector, list: Vec<Dom<File>>, } @@ -30,7 +30,7 @@ impl FileList { } #[allow(crown::unrooted_must_root)] - pub fn new(window: &Window, files: Vec<DomRoot<File>>) -> DomRoot<FileList> { + pub(crate) fn new(window: &Window, files: Vec<DomRoot<File>>) -> DomRoot<FileList> { reflect_dom_object( Box::new(FileList::new_inherited( files.iter().map(|r| Dom::from_ref(&**r)).collect(), @@ -40,7 +40,7 @@ impl FileList { ) } - pub fn iter_files(&self) -> Iter<Dom<File>> { + pub(crate) fn iter_files(&self) -> Iter<Dom<File>> { self.list.iter() } } diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs index d2b6d864d3d..269ee4913e6 100644 --- a/components/script/dom/filereader.rs +++ b/components/script/dom/filereader.rs @@ -39,7 +39,7 @@ use crate::script_runtime::{CanGc, JSContext}; use crate::task::TaskOnce; #[allow(dead_code)] -pub enum FileReadingTask { +pub(crate) enum FileReadingTask { ProcessRead(TrustedFileReader, GenerationId), ProcessReadData(TrustedFileReader, GenerationId), ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName), @@ -53,7 +53,7 @@ impl TaskOnce for FileReadingTask { } impl FileReadingTask { - pub fn handle_task(self, can_gc: CanGc) { + pub(crate) fn handle_task(self, can_gc: CanGc) { use self::FileReadingTask::*; match self { @@ -71,23 +71,23 @@ impl FileReadingTask { } } #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum FileReaderFunction { +pub(crate) enum FileReaderFunction { Text, DataUrl, ArrayBuffer, } -pub type TrustedFileReader = Trusted<FileReader>; +pub(crate) type TrustedFileReader = Trusted<FileReader>; #[derive(Clone, MallocSizeOf)] -pub struct ReadMetaData { - pub blobtype: String, - pub label: Option<String>, - pub function: FileReaderFunction, +pub(crate) struct ReadMetaData { + pub(crate) blobtype: String, + pub(crate) label: Option<String>, + pub(crate) function: FileReaderFunction, } impl ReadMetaData { - pub fn new( + pub(crate) fn new( blobtype: String, label: Option<String>, function: FileReaderFunction, @@ -101,26 +101,26 @@ impl ReadMetaData { } #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub struct GenerationId(u32); +pub(crate) struct GenerationId(u32); #[repr(u16)] #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum FileReaderReadyState { +pub(crate) enum FileReaderReadyState { Empty = FileReaderConstants::EMPTY, Loading = FileReaderConstants::LOADING, Done = FileReaderConstants::DONE, } #[derive(JSTraceable, MallocSizeOf)] -pub enum FileReaderResult { +pub(crate) enum FileReaderResult { ArrayBuffer(#[ignore_malloc_size_of = "mozjs"] Heap<JSVal>), String(DOMString), } -pub struct FileReaderSharedFunctionality; +pub(crate) struct FileReaderSharedFunctionality; impl FileReaderSharedFunctionality { - pub fn dataurl_format(blob_contents: &[u8], blob_type: String) -> DOMString { + pub(crate) fn dataurl_format(blob_contents: &[u8], blob_type: String) -> DOMString { let base64 = base64::engine::general_purpose::STANDARD.encode(blob_contents); let dataurl = if blob_type.is_empty() { @@ -132,7 +132,7 @@ impl FileReaderSharedFunctionality { DOMString::from(dataurl) } - pub fn text_decode( + pub(crate) fn text_decode( blob_contents: &[u8], blob_type: &str, blob_label: &Option<String>, @@ -165,7 +165,7 @@ impl FileReaderSharedFunctionality { } #[dom_struct] -pub struct FileReader { +pub(crate) struct FileReader { eventtarget: EventTarget, ready_state: Cell<FileReaderReadyState>, error: MutNullableDom<DOMException>, @@ -174,7 +174,7 @@ pub struct FileReader { } impl FileReader { - pub fn new_inherited() -> FileReader { + pub(crate) fn new_inherited() -> FileReader { FileReader { eventtarget: EventTarget::new_inherited(), ready_state: Cell::new(FileReaderReadyState::Empty), @@ -193,7 +193,7 @@ impl FileReader { } //https://w3c.github.io/FileAPI/#dfn-error-steps - pub fn process_read_error( + pub(crate) fn process_read_error( filereader: TrustedFileReader, gen_id: GenerationId, error: DOMErrorName, @@ -227,7 +227,11 @@ impl FileReader { } // https://w3c.github.io/FileAPI/#dfn-readAsText - pub fn process_read_data(filereader: TrustedFileReader, gen_id: GenerationId, can_gc: CanGc) { + pub(crate) fn process_read_data( + filereader: TrustedFileReader, + gen_id: GenerationId, + can_gc: CanGc, + ) { let fr = filereader.root(); macro_rules! return_on_abort( @@ -243,7 +247,7 @@ impl FileReader { } // https://w3c.github.io/FileAPI/#dfn-readAsText - pub fn process_read(filereader: TrustedFileReader, gen_id: GenerationId, can_gc: CanGc) { + pub(crate) fn process_read(filereader: TrustedFileReader, gen_id: GenerationId, can_gc: CanGc) { let fr = filereader.root(); macro_rules! return_on_abort( @@ -259,7 +263,7 @@ impl FileReader { } // https://w3c.github.io/FileAPI/#dfn-readAsText - pub fn process_read_eof( + pub(crate) fn process_read_eof( filereader: TrustedFileReader, gen_id: GenerationId, data: ReadMetaData, diff --git a/components/script/dom/filereadersync.rs b/components/script/dom/filereadersync.rs index fa312532eb9..312b667fcef 100644 --- a/components/script/dom/filereadersync.rs +++ b/components/script/dom/filereadersync.rs @@ -22,12 +22,12 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct FileReaderSync { +pub(crate) struct FileReaderSync { reflector: Reflector, } impl FileReaderSync { - pub fn new_inherited() -> FileReaderSync { + pub(crate) fn new_inherited() -> FileReaderSync { FileReaderSync { reflector: Reflector::new(), } diff --git a/components/script/dom/focusevent.rs b/components/script/dom/focusevent.rs index 0f9eced513c..a90756918ac 100644 --- a/components/script/dom/focusevent.rs +++ b/components/script/dom/focusevent.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FocusEvent { +pub(crate) struct FocusEvent { uievent: UIEvent, related_target: MutNullableDom<EventTarget>, } @@ -35,11 +35,11 @@ impl FocusEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<FocusEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<FocusEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } - pub fn new_uninitialized_with_proto( + pub(crate) fn new_uninitialized_with_proto( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, @@ -48,7 +48,7 @@ impl FocusEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: EventBubbles, diff --git a/components/script/dom/fontfaceset.rs b/components/script/dom/fontfaceset.rs index ac8cd1baa78..dfaaf553b10 100644 --- a/components/script/dom/fontfaceset.rs +++ b/components/script/dom/fontfaceset.rs @@ -17,21 +17,25 @@ use crate::realms::enter_realm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FontFaceSet { +pub(crate) struct FontFaceSet { target: EventTarget, #[ignore_malloc_size_of = "Rc"] promise: Rc<Promise>, } impl FontFaceSet { - pub fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Self { + pub(crate) fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Self { FontFaceSet { target: EventTarget::new_inherited(), promise: Promise::new(global, can_gc), } } - pub fn new(global: &GlobalScope, proto: Option<HandleObject>, can_gc: CanGc) -> DomRoot<Self> { + pub(crate) fn new( + global: &GlobalScope, + proto: Option<HandleObject>, + can_gc: CanGc, + ) -> DomRoot<Self> { reflect_dom_object_with_proto( Box::new(FontFaceSet::new_inherited(global, can_gc)), global, @@ -40,7 +44,7 @@ impl FontFaceSet { ) } - pub fn fulfill_ready_promise_if_needed(&self) { + pub(crate) fn fulfill_ready_promise_if_needed(&self) { if !self.promise.is_fulfilled() { let _ac = enter_realm(&*self.promise); self.promise.resolve_native(self); diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index bcc0f8156c1..d8c2de5a561 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -24,7 +24,7 @@ use crate::dom::htmlformelement::{FormDatum, FormDatumValue, HTMLFormElement}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FormData { +pub(crate) struct FormData { reflector_: Reflector, data: DomRefCell<Vec<(NoTrace<LocalName>, FormDatum)>>, } @@ -45,7 +45,7 @@ impl FormData { } } - pub fn new( + pub(crate) fn new( form_datums: Option<Vec<FormDatum>>, global: &GlobalScope, can_gc: CanGc, @@ -242,7 +242,7 @@ impl FormData { ) } - pub fn datums(&self) -> Vec<FormDatum> { + pub(crate) fn datums(&self) -> Vec<FormDatum> { self.data .borrow() .iter() diff --git a/components/script/dom/formdataevent.rs b/components/script/dom/formdataevent.rs index fc1134f0f80..cb3b91dbf5b 100644 --- a/components/script/dom/formdataevent.rs +++ b/components/script/dom/formdataevent.rs @@ -21,13 +21,13 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FormDataEvent { +pub(crate) struct FormDataEvent { event: Event, form_data: Dom<FormData>, } impl FormDataEvent { - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, can_bubble: EventBubbles, diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index e8f81904fcc..31184925616 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -25,14 +25,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GainNode { +pub(crate) struct GainNode { node: AudioNode, gain: Dom<AudioParam>, } impl GainNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, options: &GainOptions, @@ -65,7 +65,7 @@ impl GainNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &GainOptions, diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index ae3d75f6030..45328e61494 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -33,7 +33,7 @@ const AXIS_TILT_THRESHOLD: f64 = 0.5; const BUTTON_PRESS_THRESHOLD: f64 = 30.0 / 255.0; #[dom_struct] -pub struct Gamepad { +pub(crate) struct Gamepad { reflector_: Reflector, gamepad_id: u32, id: String, @@ -89,7 +89,7 @@ impl Gamepad { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, gamepad_id: u32, id: String, @@ -212,11 +212,11 @@ impl GamepadMethods<crate::DomTypeHolder> for Gamepad { #[allow(dead_code)] impl Gamepad { - pub fn gamepad_id(&self) -> u32 { + pub(crate) fn gamepad_id(&self) -> u32 { self.gamepad_id } - pub fn update_connected(&self, connected: bool, has_gesture: bool, can_gc: CanGc) { + pub(crate) fn update_connected(&self, connected: bool, has_gesture: bool, can_gc: CanGc) { if self.connected.get() == connected { return; } @@ -233,19 +233,19 @@ impl Gamepad { } } - pub fn index(&self) -> i32 { + pub(crate) fn index(&self) -> i32 { self.index.get() } - pub fn update_index(&self, index: i32) { + pub(crate) fn update_index(&self, index: i32) { self.index.set(index); } - pub fn update_timestamp(&self, timestamp: f64) { + pub(crate) fn update_timestamp(&self, timestamp: f64) { self.timestamp.set(timestamp); } - pub fn notify_event(&self, event_type: GamepadEventType, can_gc: CanGc) { + pub(crate) fn notify_event(&self, event_type: GamepadEventType, can_gc: CanGc) { let event = GamepadEvent::new_with_type(&self.global(), event_type, self, can_gc); event .upcast::<Event>() @@ -268,7 +268,7 @@ impl Gamepad { #[allow(unsafe_code)] /// <https://www.w3.org/TR/gamepad/#dfn-map-and-normalize-axes> - pub fn map_and_normalize_axes(&self, axis_index: usize, value: f64) { + pub(crate) fn map_and_normalize_axes(&self, axis_index: usize, value: f64) { // Let normalizedValue be 2 (logicalValue − logicalMinimum) / (logicalMaximum − logicalMinimum) − 1. let numerator = value - self.axis_bounds.0; let denominator = self.axis_bounds.1 - self.axis_bounds.0; @@ -291,7 +291,7 @@ impl Gamepad { } /// <https://www.w3.org/TR/gamepad/#dfn-map-and-normalize-buttons> - pub fn map_and_normalize_buttons(&self, button_index: usize, value: f64) { + pub(crate) fn map_and_normalize_buttons(&self, button_index: usize, value: f64) { // Let normalizedValue be (logicalValue − logicalMinimum) / (logicalMaximum − logicalMinimum). let numerator = value - self.button_bounds.0; let denominator = self.button_bounds.1 - self.button_bounds.0; @@ -312,22 +312,22 @@ impl Gamepad { } /// <https://www.w3.org/TR/gamepad/#dfn-exposed> - pub fn exposed(&self) -> bool { + pub(crate) fn exposed(&self) -> bool { self.exposed.get() } /// <https://www.w3.org/TR/gamepad/#dfn-exposed> - pub fn set_exposed(&self, exposed: bool) { + pub(crate) fn set_exposed(&self, exposed: bool) { self.exposed.set(exposed); } - pub fn vibration_actuator(&self) -> &GamepadHapticActuator { + pub(crate) fn vibration_actuator(&self) -> &GamepadHapticActuator { &self.vibration_actuator } } /// <https://www.w3.org/TR/gamepad/#dfn-gamepad-user-gesture> -pub fn contains_user_gesture(update_type: GamepadUpdateType) -> bool { +pub(crate) fn contains_user_gesture(update_type: GamepadUpdateType) -> bool { match update_type { GamepadUpdateType::Axis(_, value) => value.abs() > AXIS_TILT_THRESHOLD, GamepadUpdateType::Button(_, value) => value > BUTTON_PRESS_THRESHOLD, diff --git a/components/script/dom/gamepadbutton.rs b/components/script/dom/gamepadbutton.rs index 4605983ae6a..7a66654e5e6 100644 --- a/components/script/dom/gamepadbutton.rs +++ b/components/script/dom/gamepadbutton.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GamepadButton { +pub(crate) struct GamepadButton { reflector_: Reflector, pressed: Cell<bool>, touched: Cell<bool>, @@ -22,7 +22,7 @@ pub struct GamepadButton { } impl GamepadButton { - pub fn new_inherited(pressed: bool, touched: bool) -> GamepadButton { + pub(crate) fn new_inherited(pressed: bool, touched: bool) -> GamepadButton { Self { reflector_: Reflector::new(), pressed: Cell::new(pressed), @@ -31,7 +31,11 @@ impl GamepadButton { } } - pub fn new(global: &GlobalScope, pressed: bool, touched: bool) -> DomRoot<GamepadButton> { + pub(crate) fn new( + global: &GlobalScope, + pressed: bool, + touched: bool, + ) -> DomRoot<GamepadButton> { reflect_dom_object( Box::new(GamepadButton::new_inherited(pressed, touched)), global, @@ -58,7 +62,7 @@ impl GamepadButtonMethods<crate::DomTypeHolder> for GamepadButton { } impl GamepadButton { - pub fn update(&self, pressed: bool, touched: bool, value: f64) { + pub(crate) fn update(&self, pressed: bool, touched: bool, value: f64) { self.pressed.set(pressed); self.touched.set(touched); self.value.set(value); diff --git a/components/script/dom/gamepadbuttonlist.rs b/components/script/dom/gamepadbuttonlist.rs index 1d95eecc1a2..caf25661184 100644 --- a/components/script/dom/gamepadbuttonlist.rs +++ b/components/script/dom/gamepadbuttonlist.rs @@ -13,7 +13,7 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/gamepad/#gamepadbutton-interface #[dom_struct] -pub struct GamepadButtonList { +pub(crate) struct GamepadButtonList { reflector_: Reflector, list: Vec<Dom<GamepadButton>>, } @@ -27,7 +27,7 @@ impl GamepadButtonList { } } - pub fn new(global: &GlobalScope, list: &[&GamepadButton]) -> DomRoot<GamepadButtonList> { + pub(crate) fn new(global: &GlobalScope, list: &[&GamepadButton]) -> DomRoot<GamepadButtonList> { reflect_dom_object( Box::new(GamepadButtonList::new_inherited(list)), global, @@ -58,7 +58,7 @@ impl GamepadButtonListMethods<crate::DomTypeHolder> for GamepadButtonList { impl GamepadButtonList { /// Initialize the number of buttons in the "standard" gamepad mapping. /// <https://www.w3.org/TR/gamepad/#dfn-initializing-buttons> - pub fn init_buttons(global: &GlobalScope) -> DomRoot<GamepadButtonList> { + pub(crate) fn init_buttons(global: &GlobalScope) -> DomRoot<GamepadButtonList> { let standard_buttons = &[ GamepadButton::new(global, false, false), // Bottom button in right cluster GamepadButton::new(global, false, false), // Right button in right cluster diff --git a/components/script/dom/gamepadevent.rs b/components/script/dom/gamepadevent.rs index ad835e9f1e5..7b849db3738 100644 --- a/components/script/dom/gamepadevent.rs +++ b/components/script/dom/gamepadevent.rs @@ -21,12 +21,12 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GamepadEvent { +pub(crate) struct GamepadEvent { event: Event, gamepad: Dom<Gamepad>, } -pub enum GamepadEventType { +pub(crate) enum GamepadEventType { Connected, Disconnected, } @@ -39,7 +39,7 @@ impl GamepadEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, @@ -72,7 +72,7 @@ impl GamepadEvent { ev } - pub fn new_with_type( + pub(crate) fn new_with_type( global: &GlobalScope, event_type: GamepadEventType, gamepad: &Gamepad, diff --git a/components/script/dom/gamepadhapticactuator.rs b/components/script/dom/gamepadhapticactuator.rs index ebf45694f45..efd0c370176 100644 --- a/components/script/dom/gamepadhapticactuator.rs +++ b/components/script/dom/gamepadhapticactuator.rs @@ -56,7 +56,7 @@ impl HapticEffectListener { /// <https://www.w3.org/TR/gamepad/#gamepadhapticactuator-interface> #[dom_struct] -pub struct GamepadHapticActuator { +pub(crate) struct GamepadHapticActuator { reflector_: Reflector, gamepad_index: u32, /// <https://www.w3.org/TR/gamepad/#dfn-effects> @@ -98,7 +98,7 @@ impl GamepadHapticActuator { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, gamepad_index: u32, supported_haptic_effects: GamepadSupportedHapticEffects, @@ -299,7 +299,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato impl GamepadHapticActuator { /// <https://www.w3.org/TR/gamepad/#dom-gamepadhapticactuator-playeffect> /// We are in the task queued by the "in-parallel" steps. - pub fn handle_haptic_effect_completed(&self, completed_successfully: bool) { + pub(crate) fn handle_haptic_effect_completed(&self, completed_successfully: bool) { if self.effect_sequence_id.get() != self.sequence_id.get() || !completed_successfully { return; } @@ -312,7 +312,7 @@ impl GamepadHapticActuator { /// <https://www.w3.org/TR/gamepad/#dom-gamepadhapticactuator-reset> /// We are in the task queued by the "in-parallel" steps. - pub fn handle_haptic_effect_stopped(&self, stopped_successfully: bool) { + pub(crate) fn handle_haptic_effect_stopped(&self, stopped_successfully: bool) { if !stopped_successfully { return; } @@ -338,7 +338,7 @@ impl GamepadHapticActuator { } /// <https://www.w3.org/TR/gamepad/#handling-visibility-change> - pub fn handle_visibility_change(&self) { + pub(crate) fn handle_visibility_change(&self) { if self.playing_effect_promise.borrow().is_none() { return; } diff --git a/components/script/dom/gamepadpose.rs b/components/script/dom/gamepadpose.rs index 4b6005a93f9..7780f034f15 100644 --- a/components/script/dom/gamepadpose.rs +++ b/components/script/dom/gamepadpose.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct GamepadPose { +pub(crate) struct GamepadPose { reflector_: Reflector, #[ignore_malloc_size_of = "mozjs"] position: HeapBufferSource<Float32>, @@ -44,7 +44,7 @@ impl GamepadPose { } } - pub fn new(global: &GlobalScope) -> DomRoot<GamepadPose> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<GamepadPose> { reflect_dom_object( Box::new(GamepadPose::new_inherited()), global, diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 60e768f3dc8..97d31ade46d 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -144,7 +144,7 @@ use crate::timers::{ use crate::unminify::unminified_path; #[derive(JSTraceable)] -pub struct AutoCloseWorker { +pub(crate) struct AutoCloseWorker { /// <https://html.spec.whatwg.org/multipage/#dom-workerglobalscope-closing> closing: Arc<AtomicBool>, /// A handle to join on the worker thread. @@ -189,7 +189,7 @@ impl Drop for AutoCloseWorker { } #[dom_struct] -pub struct GlobalScope { +pub(crate) struct GlobalScope { eventtarget: EventTarget, crypto: MutNullableDom<Crypto>, @@ -408,7 +408,7 @@ enum FileListenerState { #[derive(JSTraceable, MallocSizeOf)] /// A holder of a weak reference for a DOM blob or file. -pub enum BlobTracker { +pub(crate) enum BlobTracker { /// A weak ref to a DOM file. File(WeakRef<File>), /// A weak ref to a DOM blob. @@ -417,7 +417,7 @@ pub enum BlobTracker { #[derive(JSTraceable, MallocSizeOf)] /// The info pertaining to a blob managed by this global. -pub struct BlobInfo { +pub(crate) struct BlobInfo { /// The weak ref to the corresponding DOM object. tracker: BlobTracker, /// The data and logic backing the DOM object. @@ -430,7 +430,7 @@ pub struct BlobInfo { /// State representing whether this global is currently managing blobs. #[derive(JSTraceable, MallocSizeOf)] -pub enum BlobState { +pub(crate) enum BlobState { /// A map of managed blobs. Managed(HashMapTracedValues<BlobId, BlobInfo>), /// This global is not managing any blobs at this time. @@ -448,7 +448,7 @@ enum BlobResult { /// Data representing a message-port managed by this global. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct ManagedMessagePort { +pub(crate) struct ManagedMessagePort { /// The DOM port. dom_port: Dom<MessagePort>, /// The logic and data backing the DOM port. @@ -468,7 +468,7 @@ pub struct ManagedMessagePort { /// State representing whether this global is currently managing broadcast channels. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum BroadcastChannelState { +pub(crate) enum BroadcastChannelState { /// The broadcast-channel router id for this global, and a queue of managed channels. /// Step 9, "sort destinations" /// of <https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage> @@ -485,7 +485,7 @@ pub enum BroadcastChannelState { /// State representing whether this global is currently managing messageports. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum MessagePortState { +pub(crate) enum MessagePortState { /// The message-port router id for this global, and a map of managed ports. Managed( #[no_trace] MessagePortRouterId, @@ -701,7 +701,7 @@ impl FileListener { impl GlobalScope { #[allow(clippy::too_many_arguments)] - pub fn new_inherited( + pub(crate) fn new_inherited( pipeline_id: PipelineId, devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, mem_profiler_chan: profile_mem::ProfilerChan, @@ -788,7 +788,7 @@ impl GlobalScope { } /// <https://w3c.github.io/ServiceWorker/#get-the-service-worker-registration-object> - pub fn get_serviceworker_registration( + pub(crate) fn get_serviceworker_registration( &self, script_url: &ServoUrl, scope: &ServoUrl, @@ -826,7 +826,7 @@ impl GlobalScope { } /// <https://w3c.github.io/ServiceWorker/#get-the-service-worker-object> - pub fn get_serviceworker( + pub(crate) fn get_serviceworker( &self, script_url: &ServoUrl, scope: &ServoUrl, @@ -881,7 +881,7 @@ impl GlobalScope { } /// Clean-up DOM related resources - pub fn perform_a_dom_garbage_collection_checkpoint(&self) { + pub(crate) fn perform_a_dom_garbage_collection_checkpoint(&self) { self.perform_a_message_port_garbage_collection_checkpoint(); self.perform_a_blob_garbage_collection_checkpoint(); self.perform_a_broadcast_channel_garbage_collection_checkpoint(); @@ -889,7 +889,7 @@ impl GlobalScope { /// Remove the routers for ports and broadcast-channels. /// Drain the list of workers. - pub fn remove_web_messaging_and_dedicated_workers_infra(&self) { + pub(crate) fn remove_web_messaging_and_dedicated_workers_infra(&self) { self.remove_message_ports_router(); self.remove_broadcast_channel_router(); @@ -932,7 +932,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#entangle> - pub fn entangle_ports(&self, port1: MessagePortId, port2: MessagePortId) { + pub(crate) fn entangle_ports(&self, port1: MessagePortId, port2: MessagePortId) { if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -961,7 +961,7 @@ impl GlobalScope { } /// Note that the entangled port of `port_id` has been removed in another global. - pub fn note_entangled_port_removed(&self, port_id: &MessagePortId) { + pub(crate) fn note_entangled_port_removed(&self, port_id: &MessagePortId) { // Note: currently this is a no-op, // as we only use the `close` method to manage the local lifecyle of a port. // This could be used as part of lifecyle management to determine a port can be GC'ed. @@ -973,7 +973,7 @@ impl GlobalScope { } /// Handle the transfer of a port in the current task. - pub fn mark_port_as_transferred(&self, port_id: &MessagePortId) -> MessagePortImpl { + pub(crate) fn mark_port_as_transferred(&self, port_id: &MessagePortId) -> MessagePortImpl { if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -997,7 +997,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#dom-messageport-start> - pub fn start_message_port(&self, port_id: &MessagePortId) { + pub(crate) fn start_message_port(&self, port_id: &MessagePortId) { if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1029,7 +1029,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#dom-messageport-close> - pub fn close_message_port(&self, port_id: &MessagePortId) { + pub(crate) fn close_message_port(&self, port_id: &MessagePortId) { if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1051,7 +1051,7 @@ impl GlobalScope { /// <https://html.spec.whatwg.org/multipage/#message-port-post-message-steps> // Steps 6 and 7 - pub fn post_messageport_msg(&self, port_id: MessagePortId, task: PortMessageTask) { + pub(crate) fn post_messageport_msg(&self, port_id: MessagePortId, task: PortMessageTask) { if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1092,7 +1092,7 @@ impl GlobalScope { /// <https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage> /// Step 7 and following steps. - pub fn schedule_broadcast(&self, msg: BroadcastMsg, channel_id: &Uuid) { + pub(crate) fn schedule_broadcast(&self, msg: BroadcastMsg, channel_id: &Uuid) { // First, broadcast locally. self.broadcast_message_event(msg.clone(), Some(channel_id)); @@ -1113,7 +1113,7 @@ impl GlobalScope { /// <https://html.spec.whatwg.org/multipage/#dom-broadcastchannel-postmessage> /// Step 7 and following steps. - pub fn broadcast_message_event(&self, event: BroadcastMsg, channel_id: Option<&Uuid>) { + pub(crate) fn broadcast_message_event(&self, event: BroadcastMsg, channel_id: Option<&Uuid>) { if let BroadcastChannelState::Managed(_, channels) = &*self.broadcast_channel_state.borrow() { let BroadcastMsg { @@ -1200,7 +1200,12 @@ impl GlobalScope { } /// Route the task to be handled by the relevant port. - pub fn route_task_to_port(&self, port_id: MessagePortId, task: PortMessageTask, can_gc: CanGc) { + pub(crate) fn route_task_to_port( + &self, + port_id: MessagePortId, + task: PortMessageTask, + can_gc: CanGc, + ) { let should_dispatch = if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1250,7 +1255,7 @@ impl GlobalScope { /// Check all ports that have been transfer-received in the previous task, /// and complete their transfer if they haven't been re-transferred. - pub fn maybe_add_pending_ports(&self) { + pub(crate) fn maybe_add_pending_ports(&self) { if let MessagePortState::Managed(router_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1285,7 +1290,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#ports-and-garbage-collection> - pub fn perform_a_message_port_garbage_collection_checkpoint(&self) { + pub(crate) fn perform_a_message_port_garbage_collection_checkpoint(&self) { let is_empty = if let MessagePortState::Managed(_id, message_ports) = &mut *self.message_port_state.borrow_mut() { @@ -1319,7 +1324,7 @@ impl GlobalScope { /// Remove broadcast-channels that are closed. /// TODO: Also remove them if they do not have an event-listener. /// see <https://github.com/servo/servo/issues/25772> - pub fn perform_a_broadcast_channel_garbage_collection_checkpoint(&self) { + pub(crate) fn perform_a_broadcast_channel_garbage_collection_checkpoint(&self) { let is_empty = if let BroadcastChannelState::Managed(router_id, ref mut channels) = &mut *self.broadcast_channel_state.borrow_mut() { @@ -1348,7 +1353,7 @@ impl GlobalScope { } /// Start tracking a broadcast-channel. - pub fn track_broadcast_channel(&self, dom_channel: &BroadcastChannel) { + pub(crate) fn track_broadcast_channel(&self, dom_channel: &BroadcastChannel) { let mut current_state = self.broadcast_channel_state.borrow_mut(); if let BroadcastChannelState::UnManaged = &*current_state { @@ -1396,7 +1401,11 @@ impl GlobalScope { } /// Start tracking a message-port - pub fn track_message_port(&self, dom_port: &MessagePort, port_impl: Option<MessagePortImpl>) { + pub(crate) fn track_message_port( + &self, + dom_port: &MessagePort, + port_impl: Option<MessagePortImpl>, + ) { let mut current_state = self.message_port_state.borrow_mut(); if let MessagePortState::UnManaged = &*current_state { @@ -1476,7 +1485,7 @@ impl GlobalScope { /// <https://html.spec.whatwg.org/multipage/#serialization-steps> /// defined at <https://w3c.github.io/FileAPI/#blob-section>. /// Get the snapshot state and underlying bytes of the blob. - pub fn serialize_blob(&self, blob_id: &BlobId) -> BlobImpl { + pub(crate) fn serialize_blob(&self, blob_id: &BlobId) -> BlobImpl { // Note: we combine the snapshot state and underlying bytes into one call, // which seems spec compliant. // See https://w3c.github.io/FileAPI/#snapshot-state @@ -1505,7 +1514,7 @@ impl GlobalScope { } /// Start tracking a blob - pub fn track_blob(&self, dom_blob: &Blob, blob_impl: BlobImpl) { + pub(crate) fn track_blob(&self, dom_blob: &Blob, blob_impl: BlobImpl) { let blob_id = blob_impl.blob_id(); let blob_info = BlobInfo { @@ -1518,7 +1527,7 @@ impl GlobalScope { } /// Start tracking a file - pub fn track_file(&self, file: &File, blob_impl: BlobImpl) { + pub(crate) fn track_file(&self, file: &File, blob_impl: BlobImpl) { let blob_id = blob_impl.blob_id(); let blob_info = BlobInfo { @@ -1558,7 +1567,7 @@ impl GlobalScope { /// Clean-up all file related resources on document unload. /// <https://w3c.github.io/FileAPI/#lifeTime> - pub fn clean_up_all_file_resources(&self) { + pub(crate) fn clean_up_all_file_resources(&self) { let mut blob_state = self.blob_state.borrow_mut(); if let BlobState::Managed(blobs_map) = &mut *blob_state { blobs_map.drain().for_each(|(_id, blob_info)| { @@ -1582,7 +1591,7 @@ impl GlobalScope { /// Get a slice to the inner data of a Blob, /// In the case of a File-backed blob, this might incur synchronous read and caching. - pub fn get_blob_bytes(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()> { + pub(crate) fn get_blob_bytes(&self, blob_id: &BlobId) -> Result<Vec<u8>, ()> { let parent = { let blob_state = self.blob_state.borrow(); if let BlobState::Managed(blobs_map) = &*blob_state { @@ -1702,7 +1711,7 @@ impl GlobalScope { } /// Get a copy of the type_string of a blob. - pub fn get_blob_type_string(&self, blob_id: &BlobId) -> String { + pub(crate) fn get_blob_type_string(&self, blob_id: &BlobId) -> String { let blob_state = self.blob_state.borrow(); if let BlobState::Managed(blobs_map) = &*blob_state { let blob_info = blobs_map @@ -1715,7 +1724,7 @@ impl GlobalScope { } /// <https://w3c.github.io/FileAPI/#dfn-size> - pub fn get_blob_size(&self, blob_id: &BlobId) -> u64 { + pub(crate) fn get_blob_size(&self, blob_id: &BlobId) -> u64 { let blob_state = self.blob_state.borrow(); if let BlobState::Managed(blobs_map) = &*blob_state { let parent = { @@ -1755,7 +1764,7 @@ impl GlobalScope { } } - pub fn get_blob_url_id(&self, blob_id: &BlobId) -> Uuid { + pub(crate) fn get_blob_url_id(&self, blob_id: &BlobId) -> Uuid { let mut blob_state = self.blob_state.borrow_mut(); if let BlobState::Managed(blobs_map) = &mut *blob_state { let parent = { @@ -1842,7 +1851,7 @@ impl GlobalScope { /// 2. File-based: If set_valid, then activate the FileID so it can serve as URL /// Depending on set_valid, the returned FileID can be part of /// valid or invalid Blob URL. - pub fn promote(&self, blob_info: &mut BlobInfo, set_valid: bool) -> Uuid { + pub(crate) fn promote(&self, blob_info: &mut BlobInfo, set_valid: bool) -> Uuid { let mut bytes = vec![]; let global_url = self.get_url(); @@ -1905,7 +1914,7 @@ impl GlobalScope { } /// <https://w3c.github.io/FileAPI/#blob-get-stream> - pub fn get_blob_stream( + pub(crate) fn get_blob_stream( &self, blob_id: &BlobId, can_gc: CanGc, @@ -1944,7 +1953,12 @@ impl GlobalScope { Ok(stream) } - pub fn read_file_async(&self, id: Uuid, promise: Rc<Promise>, callback: FileListenerCallback) { + pub(crate) fn read_file_async( + &self, + id: Uuid, + promise: Rc<Promise>, + callback: FileListenerCallback, + ) { let recv = self.send_msg(id); let trusted_promise = TrustedPromise::new(promise); @@ -1994,13 +2008,13 @@ impl GlobalScope { } } - pub fn permission_state_invocation_results( + pub(crate) fn permission_state_invocation_results( &self, ) -> &DomRefCell<HashMap<String, PermissionState>> { &self.permission_state_invocation_results } - pub fn track_worker( + pub(crate) fn track_worker( &self, closing: Arc<AtomicBool>, join_handle: JoinHandle<()>, @@ -2017,11 +2031,11 @@ impl GlobalScope { }); } - pub fn track_event_source(&self, event_source: &EventSource) { + pub(crate) fn track_event_source(&self, event_source: &EventSource) { self.event_source_tracker.track(event_source); } - pub fn close_event_sources(&self) -> bool { + pub(crate) fn close_event_sources(&self) -> bool { let mut canceled_any_fetch = false; self.event_source_tracker .for_each( @@ -2039,13 +2053,16 @@ impl GlobalScope { /// Returns the global scope of the realm that the given DOM object's reflector /// was created in. #[allow(unsafe_code)] - pub fn from_reflector<T: DomObject>(reflector: &T, _realm: &AlreadyInRealm) -> DomRoot<Self> { + pub(crate) fn from_reflector<T: DomObject>( + reflector: &T, + _realm: &AlreadyInRealm, + ) -> DomRoot<Self> { unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) } } /// Returns the global scope of the realm that the given JS object was created in. #[allow(unsafe_code)] - pub unsafe fn from_object(obj: *mut JSObject) -> DomRoot<Self> { + pub(crate) unsafe fn from_object(obj: *mut JSObject) -> DomRoot<Self> { assert!(!obj.is_null()); let global = GetNonCCWObjectGlobal(obj); global_scope_from_global_static(global) @@ -2053,7 +2070,7 @@ impl GlobalScope { /// Returns the global scope for the given JSContext #[allow(unsafe_code)] - pub unsafe fn from_context(cx: *mut JSContext, _realm: InRealm) -> DomRoot<Self> { + pub(crate) unsafe fn from_context(cx: *mut JSContext, _realm: InRealm) -> DomRoot<Self> { let global = CurrentGlobalOrNull(cx); assert!(!global.is_null()); global_scope_from_global(global, cx) @@ -2061,14 +2078,14 @@ impl GlobalScope { /// Returns the global scope for the given SafeJSContext #[allow(unsafe_code)] - pub fn from_safe_context(cx: SafeJSContext, realm: InRealm) -> DomRoot<Self> { + pub(crate) fn from_safe_context(cx: SafeJSContext, realm: InRealm) -> DomRoot<Self> { unsafe { Self::from_context(*cx, realm) } } /// Returns the global object of the realm that the given JS object /// was created in, after unwrapping any wrappers. #[allow(unsafe_code)] - pub unsafe fn from_object_maybe_wrapped( + pub(crate) unsafe fn from_object_maybe_wrapped( mut obj: *mut JSObject, cx: *mut JSContext, ) -> DomRoot<Self> { @@ -2079,13 +2096,13 @@ impl GlobalScope { GlobalScope::from_object(obj) } - pub fn add_uncaught_rejection(&self, rejection: HandleObject) { + pub(crate) fn add_uncaught_rejection(&self, rejection: HandleObject) { self.uncaught_rejections .borrow_mut() .push(Heap::boxed(rejection.get())); } - pub fn remove_uncaught_rejection(&self, rejection: HandleObject) { + pub(crate) fn remove_uncaught_rejection(&self, rejection: HandleObject) { let mut uncaught_rejections = self.uncaught_rejections.borrow_mut(); if let Some(index) = uncaught_rejections @@ -2099,17 +2116,17 @@ impl GlobalScope { // `Heap` values must stay boxed, as they need semantics like `Pin` // (that is, they cannot be moved). #[allow(clippy::vec_box)] - pub fn get_uncaught_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> { + pub(crate) fn get_uncaught_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> { &self.uncaught_rejections } - pub fn add_consumed_rejection(&self, rejection: HandleObject) { + pub(crate) fn add_consumed_rejection(&self, rejection: HandleObject) { self.consumed_rejections .borrow_mut() .push(Heap::boxed(rejection.get())); } - pub fn remove_consumed_rejection(&self, rejection: HandleObject) { + pub(crate) fn remove_consumed_rejection(&self, rejection: HandleObject) { let mut consumed_rejections = self.consumed_rejections.borrow_mut(); if let Some(index) = consumed_rejections @@ -2123,49 +2140,51 @@ impl GlobalScope { // `Heap` values must stay boxed, as they need semantics like `Pin` // (that is, they cannot be moved). #[allow(clippy::vec_box)] - pub fn get_consumed_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> { + pub(crate) fn get_consumed_rejections(&self) -> &DomRefCell<Vec<Box<Heap<*mut JSObject>>>> { &self.consumed_rejections } - pub fn set_module_map(&self, url: ServoUrl, module: ModuleTree) { + pub(crate) fn set_module_map(&self, url: ServoUrl, module: ModuleTree) { self.module_map.borrow_mut().insert(url, Rc::new(module)); } - pub fn get_module_map(&self) -> &DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>> { + pub(crate) fn get_module_map( + &self, + ) -> &DomRefCell<HashMapTracedValues<ServoUrl, Rc<ModuleTree>>> { &self.module_map } - pub fn set_inline_module_map(&self, script_id: ScriptId, module: ModuleTree) { + pub(crate) fn set_inline_module_map(&self, script_id: ScriptId, module: ModuleTree) { self.inline_module_map .borrow_mut() .insert(script_id, Rc::new(module)); } - pub fn get_inline_module_map(&self) -> &DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>> { + pub(crate) fn get_inline_module_map(&self) -> &DomRefCell<HashMap<ScriptId, Rc<ModuleTree>>> { &self.inline_module_map } #[allow(unsafe_code)] - pub fn get_cx() -> SafeJSContext { + pub(crate) fn get_cx() -> SafeJSContext { let cx = Runtime::get() .expect("Can't obtain context after runtime shutdown") .as_ptr(); unsafe { SafeJSContext::from_ptr(cx) } } - pub fn crypto(&self) -> DomRoot<Crypto> { + pub(crate) fn crypto(&self) -> DomRoot<Crypto> { self.crypto.or_init(|| Crypto::new(self)) } - pub fn live_devtools_updates(&self) -> bool { + pub(crate) fn live_devtools_updates(&self) -> bool { self.devtools_wants_updates.get() } - pub fn set_devtools_wants_updates(&self, value: bool) { + pub(crate) fn set_devtools_wants_updates(&self, value: bool) { self.devtools_wants_updates.set(value); } - pub fn time(&self, label: DOMString) -> Result<(), ()> { + pub(crate) fn time(&self, label: DOMString) -> Result<(), ()> { let mut timers = self.console_timers.borrow_mut(); if timers.len() >= 10000 { return Err(()); @@ -2182,7 +2201,7 @@ impl GlobalScope { /// Computes the delta time since a label has been created /// /// Returns an error if the label does not exist. - pub fn time_log(&self, label: &str) -> Result<u64, ()> { + pub(crate) fn time_log(&self, label: &str) -> Result<u64, ()> { self.console_timers .borrow() .get(label) @@ -2194,7 +2213,7 @@ impl GlobalScope { /// tracking the label. /// /// Returns an error if the label does not exist. - pub fn time_end(&self, label: &str) -> Result<u64, ()> { + pub(crate) fn time_end(&self, label: &str) -> Result<u64, ()> { self.console_timers .borrow_mut() .remove(label) @@ -2204,11 +2223,11 @@ impl GlobalScope { /// Get an `&IpcSender<ScriptToDevtoolsControlMsg>` to send messages /// to the devtools thread when available. - pub fn devtools_chan(&self) -> Option<&IpcSender<ScriptToDevtoolsControlMsg>> { + pub(crate) fn devtools_chan(&self) -> Option<&IpcSender<ScriptToDevtoolsControlMsg>> { self.devtools_chan.as_ref() } - pub fn issue_page_warning(&self, warning: &str) { + pub(crate) fn issue_page_warning(&self, warning: &str) { if let Some(ref chan) = self.devtools_chan { let _ = chan.send(ScriptToDevtoolsControlMsg::ReportPageError( self.pipeline_id, @@ -2235,44 +2254,44 @@ impl GlobalScope { } /// Get a sender to the memory profiler thread. - pub fn mem_profiler_chan(&self) -> &profile_mem::ProfilerChan { + pub(crate) fn mem_profiler_chan(&self) -> &profile_mem::ProfilerChan { &self.mem_profiler_chan } /// Get a sender to the time profiler thread. - pub fn time_profiler_chan(&self) -> &profile_time::ProfilerChan { + pub(crate) fn time_profiler_chan(&self) -> &profile_time::ProfilerChan { &self.time_profiler_chan } /// Get a sender to the constellation thread. - pub fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan { + pub(crate) fn script_to_constellation_chan(&self) -> &ScriptToConstellationChan { &self.script_to_constellation_chan } - pub fn send_to_embedder(&self, msg: EmbedderMsg) { + pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) { self.send_to_constellation(ScriptMsg::ForwardToEmbedder(msg)); } - pub fn send_to_constellation(&self, msg: ScriptMsg) { + pub(crate) fn send_to_constellation(&self, msg: ScriptMsg) { self.script_to_constellation_chan().send(msg).unwrap(); } /// Get the `PipelineId` for this global scope. - pub fn pipeline_id(&self) -> PipelineId { + pub(crate) fn pipeline_id(&self) -> PipelineId { self.pipeline_id } /// Get the origin for this global scope - pub fn origin(&self) -> &MutableOrigin { + pub(crate) fn origin(&self) -> &MutableOrigin { &self.origin } /// Get the creation_url for this global scope - pub fn creation_url(&self) -> &Option<ServoUrl> { + pub(crate) fn creation_url(&self) -> &Option<ServoUrl> { &self.creation_url } - pub fn image_cache(&self) -> Arc<dyn ImageCache> { + pub(crate) fn image_cache(&self) -> Arc<dyn ImageCache> { if let Some(window) = self.downcast::<Window>() { return window.image_cache(); } @@ -2296,7 +2315,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#concept-settings-object-policy-container> - pub fn policy_container(&self) -> PolicyContainer { + pub(crate) fn policy_container(&self) -> PolicyContainer { if let Some(window) = self.downcast::<Window>() { return window.Document().policy_container().to_owned(); } @@ -2308,7 +2327,7 @@ impl GlobalScope { /// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url) /// for this global scope. - pub fn api_base_url(&self) -> ServoUrl { + pub(crate) fn api_base_url(&self) -> ServoUrl { if let Some(window) = self.downcast::<Window>() { // https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url return window.Document().base_url(); @@ -2325,7 +2344,7 @@ impl GlobalScope { } /// Get the URL for this global scope. - pub fn get_url(&self) -> ServoUrl { + pub(crate) fn get_url(&self) -> ServoUrl { if let Some(window) = self.downcast::<Window>() { return window.get_url(); } @@ -2340,7 +2359,7 @@ impl GlobalScope { } /// Get the Referrer Policy for this global scope. - pub fn get_referrer_policy(&self) -> ReferrerPolicy { + pub(crate) fn get_referrer_policy(&self) -> ReferrerPolicy { if let Some(window) = self.downcast::<Window>() { let document = window.Document(); @@ -2355,7 +2374,7 @@ impl GlobalScope { } /// Determine the Referrer for a request whose Referrer is "client" - pub fn get_referrer(&self) -> Referrer { + pub(crate) fn get_referrer(&self) -> Referrer { // Step 3 of https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer if let Some(window) = self.downcast::<Window>() { // Substep 3.1 @@ -2396,12 +2415,12 @@ impl GlobalScope { } /// Extract a `Window`, panic if the global object is not a `Window`. - pub fn as_window(&self) -> &Window { + pub(crate) fn as_window(&self) -> &Window { self.downcast::<Window>().expect("expected a Window scope") } /// <https://html.spec.whatwg.org/multipage/#report-the-error> - pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue, can_gc: CanGc) { + pub(crate) fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue, can_gc: CanGc) { // Step 1. if self.in_error_reporting_mode.get() { return; @@ -2467,12 +2486,12 @@ impl GlobalScope { } /// Get the `&ResourceThreads` for this global scope. - pub fn resource_threads(&self) -> &ResourceThreads { + pub(crate) fn resource_threads(&self) -> &ResourceThreads { &self.resource_threads } /// Get the `CoreResourceThread` for this global scope. - pub fn core_resource_thread(&self) -> CoreResourceThread { + pub(crate) fn core_resource_thread(&self) -> CoreResourceThread { self.resource_threads().sender() } @@ -2509,7 +2528,7 @@ impl GlobalScope { } /// Evaluate JS code on this global scope. - pub fn evaluate_js_on_global_with_result( + pub(crate) fn evaluate_js_on_global_with_result( &self, code: &str, rval: MutableHandleValue, @@ -2532,7 +2551,7 @@ impl GlobalScope { /// Evaluate a JS script on this global scope. #[allow(unsafe_code)] #[allow(clippy::too_many_arguments)] - pub fn evaluate_script_on_global_with_result( + pub(crate) fn evaluate_script_on_global_with_result( &self, code: &SourceCode, filename: &str, @@ -2621,7 +2640,7 @@ impl GlobalScope { } /// <https://html.spec.whatwg.org/multipage/#timer-initialisation-steps> - pub fn schedule_callback( + pub(crate) fn schedule_callback( &self, callback: OneshotTimerCallback, duration: Duration, @@ -2630,12 +2649,12 @@ impl GlobalScope { .schedule_callback(callback, duration, self.timer_source()) } - pub fn unschedule_callback(&self, handle: OneshotTimerHandle) { + pub(crate) fn unschedule_callback(&self, handle: OneshotTimerHandle) { self.timers().unschedule_callback(handle); } /// <https://html.spec.whatwg.org/multipage/#timer-initialisation-steps> - pub fn set_timeout_or_interval( + pub(crate) fn set_timeout_or_interval( &self, callback: TimerCallback, arguments: Vec<HandleValue>, @@ -2652,11 +2671,11 @@ impl GlobalScope { ) } - pub fn clear_timeout_or_interval(&self, handle: i32) { + pub(crate) fn clear_timeout_or_interval(&self, handle: i32) { self.timers().clear_timeout_or_interval(self, handle); } - pub fn queue_function_as_microtask(&self, callback: Rc<VoidFunction>) { + pub(crate) fn queue_function_as_microtask(&self, callback: Rc<VoidFunction>) { self.enqueue_microtask(Microtask::User(UserMicrotask { callback, pipeline: self.pipeline_id(), @@ -2664,7 +2683,7 @@ impl GlobalScope { } #[allow(unsafe_code)] - pub fn is_js_evaluation_allowed(&self, cx: SafeJSContext) -> bool { + pub(crate) fn is_js_evaluation_allowed(&self, cx: SafeJSContext) -> bool { let Some(csp_list) = self.get_csp_list() else { return true; }; @@ -2694,7 +2713,7 @@ impl GlobalScope { is_js_evaluation_allowed } - pub fn create_image_bitmap( + pub(crate) fn create_image_bitmap( &self, image: ImageBitmapSource, options: &ImageBitmapOptions, @@ -2759,23 +2778,23 @@ impl GlobalScope { } } - pub fn fire_timer(&self, handle: TimerEventId, can_gc: CanGc) { + pub(crate) fn fire_timer(&self, handle: TimerEventId, can_gc: CanGc) { self.timers().fire_timer(handle, self, can_gc); } - pub fn resume(&self) { + pub(crate) fn resume(&self) { self.timers().resume(); } - pub fn suspend(&self) { + pub(crate) fn suspend(&self) { self.timers().suspend(); } - pub fn slow_down_timers(&self) { + pub(crate) fn slow_down_timers(&self) { self.timers().slow_down(); } - pub fn speed_up_timers(&self) { + pub(crate) fn speed_up_timers(&self) { self.timers().speed_up(); } @@ -2791,7 +2810,7 @@ impl GlobalScope { /// Returns a boolean indicating whether the event-loop /// where this global is running on can continue running JS. - pub fn can_continue_running(&self) -> bool { + pub(crate) fn can_continue_running(&self) -> bool { if self.is::<Window>() { return ScriptThread::can_continue_running(); } @@ -2804,7 +2823,7 @@ impl GlobalScope { } /// Perform a microtask checkpoint. - pub fn perform_a_microtask_checkpoint(&self, can_gc: CanGc) { + pub(crate) fn perform_a_microtask_checkpoint(&self, can_gc: CanGc) { // Only perform the checkpoint if we're not shutting down. if self.can_continue_running() { self.microtask_queue.checkpoint( @@ -2817,7 +2836,7 @@ impl GlobalScope { } /// Enqueue a microtask for subsequent execution. - pub fn enqueue_microtask(&self, job: Microtask) { + pub(crate) fn enqueue_microtask(&self, job: Microtask) { self.microtask_queue.enqueue(job, GlobalScope::get_cx()); } @@ -2835,14 +2854,14 @@ impl GlobalScope { } /// Returns the microtask queue of this global. - pub fn microtask_queue(&self) -> &Rc<MicrotaskQueue> { + pub(crate) fn microtask_queue(&self) -> &Rc<MicrotaskQueue> { &self.microtask_queue } /// Process a single event as if it were the next event /// in the queue for the event-loop where this global scope is running on. /// Returns a boolean indicating whether further events should be processed. - pub fn process_event(&self, msg: CommonScriptMsg) -> bool { + pub(crate) fn process_event(&self, msg: CommonScriptMsg) -> bool { if self.is::<Window>() { return ScriptThread::process_event(msg); } @@ -2852,7 +2871,7 @@ impl GlobalScope { unreachable!(); } - pub fn runtime_handle(&self) -> ParentRuntime { + pub(crate) fn runtime_handle(&self) -> ParentRuntime { if self.is::<Window>() { ScriptThread::runtime_handle() } else if let Some(worker) = self.downcast::<WorkerGlobalScope>() { @@ -2866,7 +2885,7 @@ impl GlobalScope { /// /// ["current"]: https://html.spec.whatwg.org/multipage/#current #[allow(unsafe_code)] - pub fn current() -> Option<DomRoot<Self>> { + pub(crate) fn current() -> Option<DomRoot<Self>> { let cx = Runtime::get()?; unsafe { let global = CurrentGlobalOrNull(cx.as_ptr()); @@ -2881,18 +2900,18 @@ impl GlobalScope { /// Returns the ["entry"] global object. /// /// ["entry"]: https://html.spec.whatwg.org/multipage/#entry - pub fn entry() -> DomRoot<Self> { + pub(crate) fn entry() -> DomRoot<Self> { entry_global() } /// Returns the ["incumbent"] global object. /// /// ["incumbent"]: https://html.spec.whatwg.org/multipage/#incumbent - pub fn incumbent() -> Option<DomRoot<Self>> { + pub(crate) fn incumbent() -> Option<DomRoot<Self>> { incumbent_global() } - pub fn performance(&self) -> DomRoot<Performance> { + pub(crate) fn performance(&self) -> DomRoot<Performance> { if let Some(window) = self.downcast::<Window>() { return window.Performance(); } @@ -2903,7 +2922,11 @@ impl GlobalScope { } /// <https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute> - pub fn supported_performance_entry_types(&self, cx: SafeJSContext, retval: MutableHandleValue) { + pub(crate) fn supported_performance_entry_types( + &self, + cx: SafeJSContext, + retval: MutableHandleValue, + ) { self.frozen_supported_performance_entry_types.get_or_init( || { VALID_ENTRY_TYPES @@ -2916,23 +2939,23 @@ impl GlobalScope { ); } - pub fn is_headless(&self) -> bool { + pub(crate) fn is_headless(&self) -> bool { self.is_headless } - pub fn get_user_agent(&self) -> Cow<'static, str> { + pub(crate) fn get_user_agent(&self) -> Cow<'static, str> { self.user_agent.clone() } - pub fn get_https_state(&self) -> HttpsState { + pub(crate) fn get_https_state(&self) -> HttpsState { self.https_state.get() } - pub fn set_https_state(&self, https_state: HttpsState) { + pub(crate) fn set_https_state(&self, https_state: HttpsState) { self.https_state.set(https_state); } - pub fn is_secure_context(&self) -> bool { + pub(crate) fn is_secure_context(&self) -> bool { if Some(false) == self.inherited_secure_context { return false; } @@ -2946,7 +2969,7 @@ impl GlobalScope { } /// <https://www.w3.org/TR/CSP/#get-csp-of-object> - pub fn get_csp_list(&self) -> Option<CspList> { + pub(crate) fn get_csp_list(&self) -> Option<CspList> { if self.downcast::<Window>().is_some() { return self.policy_container().csp_list; } @@ -2954,7 +2977,7 @@ impl GlobalScope { None } - pub fn status_code(&self) -> Option<u16> { + pub(crate) fn status_code(&self) -> Option<u16> { if let Some(window) = self.downcast::<Window>() { return window.Document().status_code(); } @@ -2962,19 +2985,19 @@ impl GlobalScope { } #[cfg(feature = "webgpu")] - pub fn wgpu_id_hub(&self) -> Arc<IdentityHub> { + pub(crate) fn wgpu_id_hub(&self) -> Arc<IdentityHub> { self.gpu_id_hub.clone() } #[cfg(feature = "webgpu")] - pub fn add_gpu_device(&self, device: &GPUDevice) { + pub(crate) fn add_gpu_device(&self, device: &GPUDevice) { self.gpu_devices .borrow_mut() .insert(device.id(), WeakRef::new(device)); } #[cfg(feature = "webgpu")] - pub fn remove_gpu_device(&self, device: WebGPUDevice) { + pub(crate) fn remove_gpu_device(&self, device: WebGPUDevice) { let device = self .gpu_devices .borrow_mut() @@ -2984,7 +3007,12 @@ impl GlobalScope { } #[cfg(feature = "webgpu")] - pub fn gpu_device_lost(&self, device: WebGPUDevice, reason: DeviceLostReason, msg: String) { + pub(crate) fn gpu_device_lost( + &self, + device: WebGPUDevice, + reason: DeviceLostReason, + msg: String, + ) { let reason = match reason { DeviceLostReason::Unknown => GPUDeviceLostReason::Unknown, DeviceLostReason::Destroyed => GPUDeviceLostReason::Destroyed, @@ -3002,7 +3030,7 @@ impl GlobalScope { } #[cfg(feature = "webgpu")] - pub fn handle_uncaptured_gpu_error( + pub(crate) fn handle_uncaptured_gpu_error( &self, device: WebGPUDevice, error: webgpu::Error, @@ -3020,7 +3048,7 @@ impl GlobalScope { } } - pub fn handle_gamepad_event(&self, gamepad_event: GamepadEvent) { + pub(crate) fn handle_gamepad_event(&self, gamepad_event: GamepadEvent) { match gamepad_event { GamepadEvent::Connected(index, name, bounds, supported_haptic_effects) => { self.handle_gamepad_connect( @@ -3080,7 +3108,7 @@ impl GlobalScope { } /// <https://www.w3.org/TR/gamepad/#dfn-gamepaddisconnected> - pub fn handle_gamepad_disconnect(&self, index: usize) { + pub(crate) fn handle_gamepad_disconnect(&self, index: usize) { let this = Trusted::new(self); self.task_manager() .gamepad_task_source() @@ -3099,7 +3127,11 @@ impl GlobalScope { } /// <https://www.w3.org/TR/gamepad/#receiving-inputs> - pub fn receive_new_gamepad_button_or_axis(&self, index: usize, update_type: GamepadUpdateType) { + pub(crate) fn receive_new_gamepad_button_or_axis( + &self, + index: usize, + update_type: GamepadUpdateType, + ) { let this = Trusted::new(self); // <https://w3c.github.io/gamepad/#dfn-update-gamepad-state> @@ -3235,7 +3267,7 @@ impl GlobalScope { ); } - pub fn unminified_js_dir(&self) -> Option<String> { + pub(crate) fn unminified_js_dir(&self) -> Option<String> { self.unminified_js_dir.clone() } diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs index 42848825adf..da59058fde7 100644 --- a/components/script/dom/gpucanvascontext.rs +++ b/components/script/dom/gpucanvascontext.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutCanvasRenderingContextHelpers}; #[dom_struct] -pub struct GPUCanvasContext { +pub(crate) struct GPUCanvasContext { reflector_: Reflector, } @@ -23,7 +23,7 @@ impl GPUCanvasContext { unimplemented!() } - pub fn new(_global: &GlobalScope, _canvas: &HTMLCanvasElement) -> DomRoot<Self> { + pub(crate) fn new(_global: &GlobalScope, _canvas: &HTMLCanvasElement) -> DomRoot<Self> { unimplemented!() } } diff --git a/components/script/dom/hashchangeevent.rs b/components/script/dom/hashchangeevent.rs index 001eb6497cf..b8ddd7e8306 100644 --- a/components/script/dom/hashchangeevent.rs +++ b/components/script/dom/hashchangeevent.rs @@ -20,7 +20,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#hashchangeevent #[dom_struct] -pub struct HashChangeEvent { +pub(crate) struct HashChangeEvent { event: Event, old_url: String, new_url: String, @@ -35,7 +35,7 @@ impl HashChangeEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<HashChangeEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<HashChangeEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } @@ -52,7 +52,7 @@ impl HashChangeEvent { ) } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, bubbles: bool, diff --git a/components/script/dom/headers.rs b/components/script/dom/headers.rs index 65e82393274..7024f7b8cb5 100644 --- a/components/script/dom/headers.rs +++ b/components/script/dom/headers.rs @@ -25,7 +25,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Headers { +pub(crate) struct Headers { reflector_: Reflector, guard: Cell<Guard>, #[ignore_malloc_size_of = "Defined in hyper"] @@ -35,7 +35,7 @@ pub struct Headers { // https://fetch.spec.whatwg.org/#concept-headers-guard #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum Guard { +pub(crate) enum Guard { Immutable, Request, RequestNoCors, @@ -44,7 +44,7 @@ pub enum Guard { } impl Headers { - pub fn new_inherited() -> Headers { + pub(crate) fn new_inherited() -> Headers { Headers { reflector_: Reflector::new(), guard: Cell::new(Guard::None), @@ -52,7 +52,7 @@ impl Headers { } } - pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { + pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { Self::new_with_proto(global, None, can_gc) } @@ -250,7 +250,7 @@ impl HeadersMethods<crate::DomTypeHolder> for Headers { } impl Headers { - pub fn copy_from_headers(&self, headers: DomRoot<Headers>) -> ErrorResult { + pub(crate) fn copy_from_headers(&self, headers: DomRoot<Headers>) -> ErrorResult { for (name, value) in headers.header_list.borrow().iter() { self.Append( ByteString::new(Vec::from(name.as_str())), @@ -261,7 +261,7 @@ impl Headers { } // https://fetch.spec.whatwg.org/#concept-headers-fill - pub fn fill(&self, filler: Option<HeadersInit>) -> ErrorResult { + pub(crate) fn fill(&self, filler: Option<HeadersInit>) -> ErrorResult { match filler { Some(HeadersInit::ByteStringSequenceSequence(v)) => { for mut seq in v { @@ -287,41 +287,41 @@ impl Headers { } } - pub fn for_request(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { + pub(crate) fn for_request(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { let headers_for_request = Headers::new(global, can_gc); headers_for_request.guard.set(Guard::Request); headers_for_request } - pub fn for_response(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { + pub(crate) fn for_response(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Headers> { let headers_for_response = Headers::new(global, can_gc); headers_for_response.guard.set(Guard::Response); headers_for_response } - pub fn set_guard(&self, new_guard: Guard) { + pub(crate) fn set_guard(&self, new_guard: Guard) { self.guard.set(new_guard) } - pub fn get_guard(&self) -> Guard { + pub(crate) fn get_guard(&self) -> Guard { self.guard.get() } - pub fn set_headers(&self, hyper_headers: HyperHeaders) { + pub(crate) fn set_headers(&self, hyper_headers: HyperHeaders) { *self.header_list.borrow_mut() = hyper_headers; } - pub fn get_headers_list(&self) -> HyperHeaders { + pub(crate) fn get_headers_list(&self) -> HyperHeaders { self.header_list.borrow_mut().clone() } // https://fetch.spec.whatwg.org/#concept-header-extract-mime-type - pub fn extract_mime_type(&self) -> Vec<u8> { + pub(crate) fn extract_mime_type(&self) -> Vec<u8> { extract_mime_type(&self.header_list.borrow()).unwrap_or_default() } // https://fetch.spec.whatwg.org/#concept-header-list-sort-and-combine - pub fn sort_and_combine(&self) -> Vec<(String, Vec<u8>)> { + pub(crate) fn sort_and_combine(&self) -> Vec<(String, Vec<u8>)> { let borrowed_header_list = self.header_list.borrow(); let mut header_vec = vec![]; @@ -341,7 +341,7 @@ impl Headers { } // https://fetch.spec.whatwg.org/#ref-for-privileged-no-cors-request-header-name - pub fn remove_privileged_no_cors_request_headers(&self) { + pub(crate) fn remove_privileged_no_cors_request_headers(&self) { // https://fetch.spec.whatwg.org/#privileged-no-cors-request-header-name self.header_list.borrow_mut().remove("range"); } @@ -373,7 +373,7 @@ impl Iterable for Headers { /// before calling is not necessary /// /// <https://fetch.spec.whatwg.org/#forbidden-request-header> -pub fn is_forbidden_request_header(name: &str, value: &[u8]) -> bool { +pub(crate) fn is_forbidden_request_header(name: &str, value: &[u8]) -> bool { let forbidden_header_names = [ "accept-charset", "accept-encoding", @@ -555,12 +555,12 @@ fn is_legal_header_value(value: &ByteString) -> bool { } // https://tools.ietf.org/html/rfc5234#appendix-B.1 -pub fn is_vchar(x: u8) -> bool { +pub(crate) fn is_vchar(x: u8) -> bool { matches!(x, 0x21..=0x7E) } // http://tools.ietf.org/html/rfc7230#section-3.2.6 -pub fn is_obs_text(x: u8) -> bool { +pub(crate) fn is_obs_text(x: u8) -> bool { matches!(x, 0x80..=0xFF) } @@ -568,7 +568,7 @@ pub fn is_obs_text(x: u8) -> bool { // This function uses data_url::Mime to parse the MIME Type because // mime::Mime does not provide a parser following the Fetch spec // see https://github.com/hyperium/mime/issues/106 -pub fn extract_mime_type(headers: &HyperHeaders) -> Option<Vec<u8>> { +pub(crate) fn extract_mime_type(headers: &HyperHeaders) -> Option<Vec<u8>> { let mut charset: Option<String> = None; let mut essence: String = "".to_string(); let mut mime_type: Option<DataUrlMime> = None; diff --git a/components/script/dom/history.rs b/components/script/dom/history.rs index 7ca64bde6f5..ff56442af86 100644 --- a/components/script/dom/history.rs +++ b/components/script/dom/history.rs @@ -40,7 +40,7 @@ enum PushOrReplace { /// <https://html.spec.whatwg.org/multipage/#the-history-interface> #[dom_struct] -pub struct History { +pub(crate) struct History { reflector_: Reflector, window: Dom<Window>, #[ignore_malloc_size_of = "mozjs"] @@ -50,7 +50,7 @@ pub struct History { } impl History { - pub fn new_inherited(window: &Window) -> History { + pub(crate) fn new_inherited(window: &Window) -> History { let state = Heap::default(); state.set(NullValue()); History { @@ -61,7 +61,7 @@ impl History { } } - pub fn new(window: &Window) -> DomRoot<History> { + pub(crate) fn new(window: &Window) -> DomRoot<History> { reflect_dom_object( Box::new(History::new_inherited(window)), window, @@ -87,7 +87,12 @@ impl History { /// <https://html.spec.whatwg.org/multipage/#history-traversal> /// Steps 5-16 #[allow(unsafe_code)] - pub fn activate_state(&self, state_id: Option<HistoryStateId>, url: ServoUrl, can_gc: CanGc) { + pub(crate) fn activate_state( + &self, + state_id: Option<HistoryStateId>, + url: ServoUrl, + can_gc: CanGc, + ) { // Steps 5 let document = self.window.Document(); let old_url = document.url().clone(); @@ -165,7 +170,7 @@ impl History { } } - pub fn remove_states(&self, states: Vec<HistoryStateId>) { + pub(crate) fn remove_states(&self, states: Vec<HistoryStateId>) { let _ = self .window .as_global_scope() diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 6c15ff4bc23..b3e5563bdd4 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -37,7 +37,7 @@ use crate::links::{follow_hyperlink, LinkRelations}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLAnchorElement { +pub(crate) struct HTMLAnchorElement { htmlelement: HTMLElement, rel_list: MutNullableDom<DOMTokenList>, @@ -62,7 +62,7 @@ impl HTMLAnchorElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 1523ae285d8..b8b668f94e0 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -205,7 +205,7 @@ impl Area { } } - pub fn absolute_coords(&self, p: Point2D<f32>) -> Area { + pub(crate) fn absolute_coords(&self, p: Point2D<f32>) -> Area { match *self { Area::Rectangle { top_left, @@ -237,7 +237,7 @@ impl Area { } #[dom_struct] -pub struct HTMLAreaElement { +pub(crate) struct HTMLAreaElement { htmlelement: HTMLElement, rel_list: MutNullableDom<DOMTokenList>, @@ -259,7 +259,7 @@ impl HTMLAreaElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -274,7 +274,7 @@ impl HTMLAreaElement { ) } - pub fn get_shape_from_coords(&self) -> Option<Area> { + pub(crate) fn get_shape_from_coords(&self) -> Option<Area> { let elem = self.upcast::<Element>(); let shape = elem.get_string_attribute(&"shape".into()); let shp: Shape = match_ignore_ascii_case! { &shape, diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index 288782550c2..44258d73f66 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLAudioElement { +pub(crate) struct HTMLAudioElement { htmlmediaelement: HTMLMediaElement, } @@ -37,7 +37,7 @@ impl HTMLAudioElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 3af35ab3e45..24957bd1e94 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -20,7 +20,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLBaseElement { +pub(crate) struct HTMLBaseElement { htmlelement: HTMLElement, } @@ -36,7 +36,7 @@ impl HTMLBaseElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -52,7 +52,7 @@ impl HTMLBaseElement { } /// <https://html.spec.whatwg.org/multipage/#frozen-base-url> - pub fn frozen_base_url(&self) -> ServoUrl { + pub(crate) fn frozen_base_url(&self) -> ServoUrl { let href = self .upcast::<Element>() .get_attribute(&ns!(), &local_name!("href")) @@ -68,7 +68,7 @@ impl HTMLBaseElement { /// Update the cached base element in response to binding or unbinding from /// a tree. - pub fn bind_unbind(&self, tree_in_doc: bool) { + pub(crate) fn bind_unbind(&self, tree_in_doc: bool) { if !tree_in_doc || self.upcast::<Node>().containing_shadow_root().is_some() { return; } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 93a9ad0d73f..3a15d4c3afa 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -25,7 +25,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLBodyElement { +pub(crate) struct HTMLBodyElement { htmlelement: HTMLElement, } @@ -41,7 +41,7 @@ impl HTMLBodyElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -57,7 +57,7 @@ impl HTMLBodyElement { } /// <https://drafts.csswg.org/cssom-view/#the-html-body-element> - pub fn is_the_html_body_element(&self) -> bool { + pub(crate) fn is_the_html_body_element(&self) -> bool { let self_node = self.upcast::<Node>(); let root_elem = self.upcast::<Element>().root_element(); let root_node = root_elem.upcast::<Node>(); @@ -96,7 +96,7 @@ impl HTMLBodyElementMethods<crate::DomTypeHolder> for HTMLBodyElement { window_event_handlers!(ForwardToWindow); } -pub trait HTMLBodyElementLayoutHelpers { +pub(crate) trait HTMLBodyElementLayoutHelpers { fn get_background_color(self) -> Option<AbsoluteColor>; fn get_color(self) -> Option<AbsoluteColor>; fn get_background(self) -> Option<ServoUrl>; diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs index 7f968c27574..4f299c832c7 100644 --- a/components/script/dom/htmlbrelement.rs +++ b/components/script/dom/htmlbrelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLBRElement { +pub(crate) struct HTMLBRElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLBRElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 793a6a212da..62bd6a964de 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -41,7 +41,7 @@ enum ButtonType { } #[dom_struct] -pub struct HTMLButtonElement { +pub(crate) struct HTMLButtonElement { htmlelement: HTMLElement, button_type: Cell<ButtonType>, form_owner: MutNullableDom<HTMLFormElement>, @@ -70,7 +70,7 @@ impl HTMLButtonElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -88,7 +88,7 @@ impl HTMLButtonElement { } #[inline] - pub fn is_submit_button(&self) -> bool { + pub(crate) fn is_submit_button(&self) -> bool { self.button_type.get() == ButtonType::Submit } } @@ -207,7 +207,7 @@ impl HTMLButtonElementMethods<crate::DomTypeHolder> for HTMLButtonElement { impl HTMLButtonElement { /// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set> /// Steps range from 3.1 to 3.7 (specific to HTMLButtonElement) - pub fn form_datum(&self, submitter: Option<FormSubmitterElement>) -> Option<FormDatum> { + pub(crate) fn form_datum(&self, submitter: Option<FormSubmitterElement>) -> Option<FormDatum> { // Step 3.1: disabled state check is in get_unclean_dataset // Step 3.1: only run steps if this is the submitter diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index e61358325ae..5e30743aeba 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -62,7 +62,7 @@ const DEFAULT_HEIGHT: u32 = 150; #[crown::unrooted_must_root_lint::must_root] #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum CanvasContext { +pub(crate) enum CanvasContext { Context2d(Dom<CanvasRenderingContext2D>), WebGL(Dom<WebGLRenderingContext>), WebGL2(Dom<WebGL2RenderingContext>), @@ -71,7 +71,7 @@ pub enum CanvasContext { } #[dom_struct] -pub struct HTMLCanvasElement { +pub(crate) struct HTMLCanvasElement { htmlelement: HTMLElement, context: DomRefCell<Option<CanvasContext>>, } @@ -89,7 +89,7 @@ impl HTMLCanvasElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -121,11 +121,11 @@ impl HTMLCanvasElement { } } - pub fn get_size(&self) -> Size2D<u32> { + pub(crate) fn get_size(&self) -> Size2D<u32> { Size2D::new(self.Width(), self.Height()) } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { match *self.context.borrow() { Some(CanvasContext::Context2d(ref context)) => context.origin_is_clean(), _ => true, @@ -133,11 +133,11 @@ impl HTMLCanvasElement { } } -pub trait LayoutCanvasRenderingContextHelpers { +pub(crate) trait LayoutCanvasRenderingContextHelpers { fn canvas_data_source(self) -> HTMLCanvasDataSource; } -pub trait LayoutHTMLCanvasElementHelpers { +pub(crate) trait LayoutHTMLCanvasElementHelpers { fn data(self) -> HTMLCanvasData; fn get_canvas_id_for_layout(self) -> CanvasId; } @@ -187,7 +187,7 @@ impl LayoutHTMLCanvasElementHelpers for LayoutDom<'_, HTMLCanvasElement> { } impl HTMLCanvasElement { - pub fn context(&self) -> Option<Ref<CanvasContext>> { + pub(crate) fn context(&self) -> Option<Ref<CanvasContext>> { ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref()) } @@ -288,7 +288,7 @@ impl HTMLCanvasElement { } /// Gets the base WebGLRenderingContext for WebGL or WebGL 2, if exists. - pub fn get_base_webgl_context(&self) -> Option<DomRoot<WebGLRenderingContext>> { + pub(crate) fn get_base_webgl_context(&self) -> Option<DomRoot<WebGLRenderingContext>> { match *self.context.borrow() { Some(CanvasContext::WebGL(ref context)) => Some(DomRoot::from_ref(context)), Some(CanvasContext::WebGL2(ref context)) => Some(context.base_context()), @@ -313,11 +313,11 @@ impl HTMLCanvasElement { } } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { self.Height() != 0 && self.Width() != 0 } - pub fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> { + pub(crate) fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> { let size = self.get_size(); if size.width == 0 || size.height == 0 { @@ -563,14 +563,14 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes { } } -pub mod utils { +pub(crate) mod utils { use net_traits::image_cache::ImageResponse; use net_traits::request::CorsSettings; use servo_url::ServoUrl; use crate::dom::window::Window; - pub fn request_image_from_cache( + pub(crate) fn request_image_from_cache( window: &Window, url: ServoUrl, cors_setting: Option<CorsSettings>, diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 6294c9b93d9..4b3ad216e19 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -22,7 +22,7 @@ use crate::dom::node::{Node, NodeTraits}; use crate::dom::window::Window; use crate::script_runtime::CanGc; -pub trait CollectionFilter: JSTraceable { +pub(crate) trait CollectionFilter: JSTraceable { fn filter<'a>(&self, elem: &'a Element, root: &'a Node) -> bool; } @@ -54,7 +54,7 @@ impl OptionU32 { } #[dom_struct] -pub struct HTMLCollection { +pub(crate) struct HTMLCollection { reflector_: Reflector, root: Dom<Node>, #[ignore_malloc_size_of = "Trait object (Box<dyn CollectionFilter>) cannot be sized"] @@ -70,7 +70,7 @@ pub struct HTMLCollection { impl HTMLCollection { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( root: &Node, filter: Box<dyn CollectionFilter + 'static>, ) -> HTMLCollection { @@ -87,7 +87,7 @@ impl HTMLCollection { } /// Returns a collection which is always empty. - pub fn always_empty(window: &Window, root: &Node) -> DomRoot<Self> { + pub(crate) fn always_empty(window: &Window, root: &Node) -> DomRoot<Self> { #[derive(JSTraceable)] struct NoFilter; impl CollectionFilter for NoFilter { @@ -100,7 +100,7 @@ impl HTMLCollection { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, root: &Node, filter: Box<dyn CollectionFilter + 'static>, @@ -174,7 +174,7 @@ impl HTMLCollection { } /// <https://dom.spec.whatwg.org/#concept-getelementsbytagname> - pub fn by_qualified_name( + pub(crate) fn by_qualified_name( window: &Window, root: &Node, qualified_name: LocalName, @@ -228,7 +228,7 @@ impl HTMLCollection { } } - pub fn by_tag_name_ns( + pub(crate) fn by_tag_name_ns( window: &Window, root: &Node, tag: DOMString, @@ -240,7 +240,7 @@ impl HTMLCollection { HTMLCollection::by_qual_tag_name(window, root, qname) } - pub fn by_qual_tag_name( + pub(crate) fn by_qual_tag_name( window: &Window, root: &Node, qname: QualName, @@ -261,7 +261,7 @@ impl HTMLCollection { HTMLCollection::create(window, root, Box::new(filter)) } - pub fn by_class_name( + pub(crate) fn by_class_name( window: &Window, root: &Node, classes: DOMString, @@ -270,7 +270,7 @@ impl HTMLCollection { HTMLCollection::by_atomic_class_name(window, root, class_atoms) } - pub fn by_atomic_class_name( + pub(crate) fn by_atomic_class_name( window: &Window, root: &Node, classes: Vec<Atom>, @@ -301,13 +301,13 @@ impl HTMLCollection { HTMLCollection::create(window, root, Box::new(filter)) } - pub fn children(window: &Window, root: &Node) -> DomRoot<HTMLCollection> { + pub(crate) fn children(window: &Window, root: &Node) -> DomRoot<HTMLCollection> { HTMLCollection::new_with_filter_fn(window, root, |element, root| { root.is_parent_of(element.upcast()) }) } - pub fn elements_iter_after<'a>( + pub(crate) fn elements_iter_after<'a>( &'a self, after: &'a Node, ) -> impl Iterator<Item = DomRoot<Element>> + 'a { @@ -318,12 +318,12 @@ impl HTMLCollection { .filter(move |element| self.filter.filter(element, &self.root)) } - pub fn elements_iter(&self) -> impl Iterator<Item = DomRoot<Element>> + '_ { + pub(crate) fn elements_iter(&self) -> impl Iterator<Item = DomRoot<Element>> + '_ { // Iterate forwards from the root. self.elements_iter_after(&self.root) } - pub fn elements_iter_before<'a>( + pub(crate) fn elements_iter_before<'a>( &'a self, before: &'a Node, ) -> impl Iterator<Item = DomRoot<Element>> + 'a { @@ -334,7 +334,7 @@ impl HTMLCollection { .filter(move |element| self.filter.filter(element, &self.root)) } - pub fn root_node(&self) -> DomRoot<Node> { + pub(crate) fn root_node(&self) -> DomRoot<Node> { DomRoot::from_ref(&self.root) } } diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs index 5aadd1c8e3a..101bf713810 100644 --- a/components/script/dom/htmldataelement.rs +++ b/components/script/dom/htmldataelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDataElement { +pub(crate) struct HTMLDataElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLDataElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index 105f6e2225d..efa20a67604 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -17,7 +17,7 @@ use crate::dom::node::{Node, NodeTraits}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDataListElement { +pub(crate) struct HTMLDataListElement { htmlelement: HTMLElement, } @@ -33,7 +33,7 @@ impl HTMLDataListElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index f951ef39aa0..5e24031b823 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -22,7 +22,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDetailsElement { +pub(crate) struct HTMLDetailsElement { htmlelement: HTMLElement, toggle_counter: Cell<u32>, } @@ -40,7 +40,7 @@ impl HTMLDetailsElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -57,7 +57,7 @@ impl HTMLDetailsElement { ) } - pub fn toggle(&self) { + pub(crate) fn toggle(&self) { self.SetOpen(!self.Open()); } } diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index 70a57749add..078f47ad1fc 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -19,7 +19,7 @@ use crate::dom::node::{Node, NodeTraits}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDialogElement { +pub(crate) struct HTMLDialogElement { htmlelement: HTMLElement, return_value: DomRefCell<DOMString>, } @@ -37,7 +37,7 @@ impl HTMLDialogElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs index d06b622e5c9..d355caca58e 100644 --- a/components/script/dom/htmldirectoryelement.rs +++ b/components/script/dom/htmldirectoryelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDirectoryElement { +pub(crate) struct HTMLDirectoryElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLDirectoryElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs index 4bb69f863d2..afaacef03e3 100644 --- a/components/script/dom/htmldivelement.rs +++ b/components/script/dom/htmldivelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDivElement { +pub(crate) struct HTMLDivElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLDivElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs index 1e51328fe96..d13b6de1601 100644 --- a/components/script/dom/htmldlistelement.rs +++ b/components/script/dom/htmldlistelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLDListElement { +pub(crate) struct HTMLDListElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLDListElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 1c69482c0e4..070522d216e 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -53,14 +53,14 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct HTMLElement { +pub(crate) struct HTMLElement { element: Element, style_decl: MutNullableDom<CSSStyleDeclaration>, dataset: MutNullableDom<DOMStringMap>, } impl HTMLElement { - pub fn new_inherited( + pub(crate) fn new_inherited( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -68,7 +68,7 @@ impl HTMLElement { HTMLElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document) } - pub fn new_inherited_with_state( + pub(crate) fn new_inherited_with_state( state: ElementState, tag_name: LocalName, prefix: Option<Prefix>, @@ -88,7 +88,7 @@ impl HTMLElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -708,7 +708,12 @@ fn to_camel_case(name: &str) -> Option<DOMString> { } impl HTMLElement { - pub fn set_custom_attr(&self, name: DOMString, value: DOMString, can_gc: CanGc) -> ErrorResult { + pub(crate) fn set_custom_attr( + &self, + name: DOMString, + value: DOMString, + can_gc: CanGc, + ) -> ErrorResult { if name .chars() .skip_while(|&ch| ch != '\u{2d}') @@ -721,7 +726,7 @@ impl HTMLElement { .set_custom_attribute(to_snake_case(name), value, can_gc) } - pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> { + pub(crate) fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> { // FIXME(ajeffrey): Convert directly from DOMString to LocalName let local_name = LocalName::from(to_snake_case(local_name)); self.as_element() @@ -731,14 +736,14 @@ impl HTMLElement { }) } - pub fn delete_custom_attr(&self, local_name: DOMString) { + pub(crate) fn delete_custom_attr(&self, local_name: DOMString) { // FIXME(ajeffrey): Convert directly from DOMString to LocalName let local_name = LocalName::from(to_snake_case(local_name)); self.as_element().remove_attribute(&ns!(), &local_name); } /// <https://html.spec.whatwg.org/multipage/#category-label> - pub fn is_labelable_element(&self) -> bool { + pub(crate) fn is_labelable_element(&self) -> bool { match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id { HTMLElementTypeId::HTMLInputElement => { @@ -757,7 +762,7 @@ impl HTMLElement { } /// <https://html.spec.whatwg.org/multipage/#form-associated-custom-element> - pub fn is_form_associated_custom_element(&self) -> bool { + pub(crate) fn is_form_associated_custom_element(&self) -> bool { if let Some(definition) = self.as_element().get_custom_element_definition() { definition.is_autonomous() && definition.form_associated } else { @@ -766,7 +771,7 @@ impl HTMLElement { } /// <https://html.spec.whatwg.org/multipage/#category-listed> - pub fn is_listed_element(&self) -> bool { + pub(crate) fn is_listed_element(&self) -> bool { match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id { HTMLElementTypeId::HTMLButtonElement | @@ -783,7 +788,7 @@ impl HTMLElement { } /// <https://html.spec.whatwg.org/multipage/#category-submit> - pub fn is_submittable_element(&self) -> bool { + pub(crate) fn is_submittable_element(&self) -> bool { match self.upcast::<Node>().type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) => match type_id { HTMLElementTypeId::HTMLButtonElement | @@ -796,7 +801,7 @@ impl HTMLElement { } } - pub fn supported_prop_names_custom_attr(&self) -> Vec<DOMString> { + pub(crate) fn supported_prop_names_custom_attr(&self) -> Vec<DOMString> { let element = self.as_element(); element .attrs() @@ -810,7 +815,7 @@ impl HTMLElement { // https://html.spec.whatwg.org/multipage/#dom-lfe-labels // This gets the nth label in tree order. - pub fn label_at(&self, index: u32) -> Option<DomRoot<Node>> { + pub(crate) fn label_at(&self, index: u32) -> Option<DomRoot<Node>> { let element = self.as_element(); // Traverse entire tree for <label> elements that have @@ -838,7 +843,7 @@ impl HTMLElement { // https://html.spec.whatwg.org/multipage/#dom-lfe-labels // This counts the labels of the element, to support NodeList::Length - pub fn labels_count(&self) -> u32 { + pub(crate) fn labels_count(&self) -> u32 { // see label_at comments about performance let element = self.as_element(); let root_element = element.root_element(); @@ -856,7 +861,7 @@ impl HTMLElement { // https://html.spec.whatwg.org/multipage/#the-directionality. // returns Some if can infer direction by itself or from child nodes // returns None if requires to go up to parent - pub fn directionality(&self) -> Option<String> { + pub(crate) fn directionality(&self) -> Option<String> { let element_direction: &str = &self.Dir(); if element_direction == "ltr" { @@ -896,7 +901,7 @@ impl HTMLElement { } // https://html.spec.whatwg.org/multipage/#the-summary-element:activation-behaviour - pub fn summary_activation_behavior(&self) { + pub(crate) fn summary_activation_behavior(&self) { // Step 1 if !self.is_summary_for_its_parent_details() { return; diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs index 65314abdd9e..e7b217a6d28 100644 --- a/components/script/dom/htmlembedelement.rs +++ b/components/script/dom/htmlembedelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLEmbedElement { +pub(crate) struct HTMLEmbedElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLEmbedElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index fe5df5b3cdd..28187c14da6 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -29,7 +29,7 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct HTMLFieldSetElement { +pub(crate) struct HTMLFieldSetElement { htmlelement: HTMLElement, form_owner: MutNullableDom<HTMLFormElement>, validity_state: MutNullableDom<ValidityState>, @@ -54,7 +54,7 @@ impl HTMLFieldSetElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -71,7 +71,7 @@ impl HTMLFieldSetElement { ) } - pub fn update_validity(&self) { + pub(crate) fn update_validity(&self) { let has_invalid_child = self .upcast::<Node>() .traverse_preorder(ShadowIncluding::No) diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index b670ff4971f..bc96d8b2ea4 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -27,7 +27,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLFontElement { +pub(crate) struct HTMLFontElement { htmlelement: HTMLElement, } @@ -43,7 +43,7 @@ impl HTMLFontElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -144,7 +144,7 @@ impl VirtualMethods for HTMLFontElement { } } -pub trait HTMLFontElementLayoutHelpers { +pub(crate) trait HTMLFontElementLayoutHelpers { fn get_color(self) -> Option<AbsoluteColor>; fn get_face(self) -> Option<Atom>; fn get_size(self) -> Option<u32>; diff --git a/components/script/dom/htmlformcontrolscollection.rs b/components/script/dom/htmlformcontrolscollection.rs index de9152404c4..390a1ca4d8d 100644 --- a/components/script/dom/htmlformcontrolscollection.rs +++ b/components/script/dom/htmlformcontrolscollection.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLFormControlsCollection { +pub(crate) struct HTMLFormControlsCollection { collection: HTMLCollection, form: Dom<HTMLFormElement>, } @@ -41,7 +41,7 @@ impl HTMLFormControlsCollection { } } - pub fn new( + pub(crate) fn new( window: &Window, form: &HTMLFormElement, filter: Box<dyn CollectionFilter + 'static>, diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 3cebb05bab3..a4f62f94093 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -84,10 +84,10 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub struct GenerationId(u32); +pub(crate) struct GenerationId(u32); #[dom_struct] -pub struct HTMLFormElement { +pub(crate) struct HTMLFormElement { htmlelement: HTMLElement, marked_for_reset: Cell<bool>, /// <https://html.spec.whatwg.org/multipage/#constructing-entry-list> @@ -132,7 +132,7 @@ impl HTMLFormElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -177,7 +177,7 @@ impl HTMLFormElement { false } - pub fn nth_for_radio_list( + pub(crate) fn nth_for_radio_list( &self, index: u32, mode: RadioListMode, @@ -191,7 +191,7 @@ impl HTMLFormElement { .map(|n| DomRoot::from_ref(n.upcast::<Node>())) } - pub fn count_for_radio_list(&self, mode: RadioListMode, name: &Atom) -> u32 { + pub(crate) fn count_for_radio_list(&self, mode: RadioListMode, name: &Atom) -> u32 { self.controls .borrow() .iter() @@ -652,13 +652,13 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement { } #[derive(Clone, Copy, MallocSizeOf, PartialEq)] -pub enum SubmittedFrom { +pub(crate) enum SubmittedFrom { FromForm, NotFromForm, } #[derive(Clone, Copy, MallocSizeOf)] -pub enum ResetFrom { +pub(crate) enum ResetFrom { FromForm, NotFromForm, } @@ -706,7 +706,7 @@ impl HTMLFormElement { result } - pub fn update_validity(&self) { + pub(crate) fn update_validity(&self) { let controls = self.controls.borrow(); let is_any_invalid = controls.iter().any(|control| control.is_invalid(false)); @@ -717,7 +717,7 @@ impl HTMLFormElement { } /// [Form submission](https://html.spec.whatwg.org/multipage/#concept-form-submit) - pub fn submit( + pub(crate) fn submit( &self, submit_method_flag: SubmittedFrom, submitter: FormSubmitterElement, @@ -1200,7 +1200,7 @@ impl HTMLFormElement { } /// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set> - pub fn get_form_dataset( + pub(crate) fn get_form_dataset( &self, submitter: Option<FormSubmitterElement>, encoding: Option<&'static Encoding>, @@ -1243,7 +1243,7 @@ impl HTMLFormElement { Some(form_data.datums()) } - pub fn reset(&self, _reset_method_flag: ResetFrom, can_gc: CanGc) { + pub(crate) fn reset(&self, _reset_method_flag: ResetFrom, can_gc: CanGc) { // https://html.spec.whatwg.org/multipage/#locked-for-reset if self.marked_for_reset.get() { return; @@ -1330,21 +1330,21 @@ impl HTMLFormElement { } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum FormDatumValue { +pub(crate) enum FormDatumValue { #[allow(dead_code)] File(DomRoot<File>), String(DOMString), } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct FormDatum { - pub ty: DOMString, - pub name: DOMString, - pub value: FormDatumValue, +pub(crate) struct FormDatum { + pub(crate) ty: DOMString, + pub(crate) name: DOMString, + pub(crate) value: FormDatumValue, } impl FormDatum { - pub fn replace_value(&self, charset: &str) -> String { + pub(crate) fn replace_value(&self, charset: &str) -> String { if self.name.to_ascii_lowercase() == "_charset_" && self.ty == "hidden" { return charset.to_string(); } @@ -1357,14 +1357,14 @@ impl FormDatum { } #[derive(Clone, Copy, MallocSizeOf)] -pub enum FormEncType { +pub(crate) enum FormEncType { TextPlain, UrlEncoded, MultipartFormData, } #[derive(Clone, Copy, MallocSizeOf)] -pub enum FormMethod { +pub(crate) enum FormMethod { Get, Post, Dialog, @@ -1372,7 +1372,7 @@ pub enum FormMethod { /// <https://html.spec.whatwg.org/multipage/#form-associated-element> #[derive(Clone, Copy, MallocSizeOf)] -pub enum FormSubmitterElement<'a> { +pub(crate) enum FormSubmitterElement<'a> { Form(&'a HTMLFormElement), Input(&'a HTMLInputElement), Button(&'a HTMLButtonElement), @@ -1496,7 +1496,7 @@ impl FormSubmitterElement<'_> { } } -pub trait FormControl: DomObject { +pub(crate) trait FormControl: DomObject { fn form_owner(&self) -> Option<DomRoot<HTMLFormElement>>; fn set_form_owner(&self, form: Option<&HTMLFormElement>); @@ -1745,7 +1745,7 @@ impl VirtualMethods for HTMLFormElement { } } -pub trait FormControlElementHelpers { +pub(crate) trait FormControlElementHelpers { fn as_maybe_form_control(&self) -> Option<&dyn FormControl>; } @@ -1796,7 +1796,7 @@ impl FormControlElementHelpers for Element { } /// <https://html.spec.whatwg.org/multipage/#multipart/form-data-encoding-algorithm> -pub fn encode_multipart_form_data( +pub(crate) fn encode_multipart_form_data( form_data: &mut [FormDatum], boundary: String, encoding: &'static Encoding, @@ -1904,7 +1904,7 @@ pub fn encode_multipart_form_data( } // https://tools.ietf.org/html/rfc7578#section-4.1 -pub fn generate_boundary() -> String { +pub(crate) fn generate_boundary() -> String { let i1 = random::<u32>(); let i2 = random::<u32>(); diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs index 87348f33ebd..f0e61f74e22 100644 --- a/components/script/dom/htmlframeelement.rs +++ b/components/script/dom/htmlframeelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLFrameElement { +pub(crate) struct HTMLFrameElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLFrameElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs index eeefee178d3..83c97387c94 100644 --- a/components/script/dom/htmlframesetelement.rs +++ b/components/script/dom/htmlframesetelement.rs @@ -16,7 +16,7 @@ use crate::dom::node::{Node, NodeTraits}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLFrameSetElement { +pub(crate) struct HTMLFrameSetElement { htmlelement: HTMLElement, } @@ -32,7 +32,7 @@ impl HTMLFrameSetElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index 54a2b49b59b..95b05732cb3 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -20,7 +20,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLHeadElement { +pub(crate) struct HTMLHeadElement { htmlelement: HTMLElement, } @@ -36,7 +36,7 @@ impl HTMLHeadElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -55,7 +55,7 @@ impl HTMLHeadElement { } /// <https://html.spec.whatwg.org/multipage/#meta-referrer> - pub fn set_document_referrer(&self) { + pub(crate) fn set_document_referrer(&self) { let doc = self.owner_document(); if doc.GetHead().as_deref() != Some(self) { @@ -86,7 +86,7 @@ impl HTMLHeadElement { } /// <https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv-content-security-policy> - pub fn set_content_security_policy(&self) { + pub(crate) fn set_content_security_policy(&self) { let doc = self.owner_document(); if doc.GetHead().as_deref() != Some(self) { diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index ed71480b413..0f3d92e4d4e 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] -pub enum HeadingLevel { +pub(crate) enum HeadingLevel { Heading1, Heading2, Heading3, @@ -23,7 +23,7 @@ pub enum HeadingLevel { } #[dom_struct] -pub struct HTMLHeadingElement { +pub(crate) struct HTMLHeadingElement { htmlelement: HTMLElement, level: HeadingLevel, } @@ -42,7 +42,7 @@ impl HTMLHeadingElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index bf9cf8e79a0..298cf008a74 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -20,7 +20,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLHRElement { +pub(crate) struct HTMLHRElement { htmlelement: HTMLElement, } @@ -36,7 +36,7 @@ impl HTMLHRElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -72,7 +72,7 @@ impl HTMLHRElementMethods<crate::DomTypeHolder> for HTMLHRElement { make_dimension_setter!(SetWidth, "width"); } -pub trait HTMLHRLayoutHelpers { +pub(crate) trait HTMLHRLayoutHelpers { fn get_color(self) -> Option<AbsoluteColor>; fn get_width(self) -> LengthOrPercentageOrAuto; } diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs index ebb07276e2e..f2fac7b1c67 100644 --- a/components/script/dom/htmlhtmlelement.rs +++ b/components/script/dom/htmlhtmlelement.rs @@ -14,7 +14,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLHtmlElement { +pub(crate) struct HTMLHtmlElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLHtmlElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( localName: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 85da4c1f12f..ff58bc67b72 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -71,7 +71,7 @@ enum ProcessingMode { } #[dom_struct] -pub struct HTMLIFrameElement { +pub(crate) struct HTMLIFrameElement { htmlelement: HTMLElement, #[no_trace] top_level_browsing_context_id: Cell<Option<TopLevelBrowsingContextId>>, @@ -90,7 +90,7 @@ pub struct HTMLIFrameElement { } impl HTMLIFrameElement { - pub fn is_sandboxed(&self) -> bool { + pub(crate) fn is_sandboxed(&self) -> bool { self.sandbox_allowance.get().is_some() } @@ -111,7 +111,7 @@ impl HTMLIFrameElement { .unwrap_or_else(|| ServoUrl::parse("about:blank").unwrap()) } - pub fn navigate_or_reload_child_browsing_context( + pub(crate) fn navigate_or_reload_child_browsing_context( &self, load_data: LoadData, history_handling: NavigationHistoryBehavior, @@ -425,7 +425,7 @@ impl HTMLIFrameElement { self.browsing_context_id.set(None); } - pub fn update_pipeline_id( + pub(crate) fn update_pipeline_id( &self, new_pipeline_id: PipelineId, reason: UpdatePipelineIdReason, @@ -469,7 +469,7 @@ impl HTMLIFrameElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -487,28 +487,28 @@ impl HTMLIFrameElement { } #[inline] - pub fn pipeline_id(&self) -> Option<PipelineId> { + pub(crate) fn pipeline_id(&self) -> Option<PipelineId> { self.pipeline_id.get() } #[inline] - pub fn browsing_context_id(&self) -> Option<BrowsingContextId> { + pub(crate) fn browsing_context_id(&self) -> Option<BrowsingContextId> { self.browsing_context_id.get() } #[inline] - pub fn top_level_browsing_context_id(&self) -> Option<TopLevelBrowsingContextId> { + pub(crate) fn top_level_browsing_context_id(&self) -> Option<TopLevelBrowsingContextId> { self.top_level_browsing_context_id.get() } - pub fn set_throttled(&self, throttled: bool) { + pub(crate) fn set_throttled(&self, throttled: bool) { if self.throttled.get() != throttled { self.throttled.set(throttled); } } /// <https://html.spec.whatwg.org/multipage/#iframe-load-event-steps> steps 1-4 - pub fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId, can_gc: CanGc) { + pub(crate) fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId, can_gc: CanGc) { // TODO(#9592): assert that the load blocker is present at all times when we // can guarantee that it's created for the case of iframe.reload(). if Some(loaded_pipeline) != self.pending_pipeline_id.get() { @@ -532,7 +532,7 @@ impl HTMLIFrameElement { } } -pub trait HTMLIFrameElementLayoutMethods { +pub(crate) trait HTMLIFrameElementLayoutMethods { fn pipeline_id(self) -> Option<PipelineId>; fn browsing_context_id(self) -> Option<BrowsingContextId>; fn get_width(self) -> LengthOrPercentageOrAuto; diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index ac6a7ae5a7d..268cd2985f1 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -103,7 +103,7 @@ enum ParseState { AfterDescriptor, } -pub struct SourceSet { +pub(crate) struct SourceSet { image_sources: Vec<ImageSource>, source_size: SourceSizeList, } @@ -161,7 +161,7 @@ struct ImageRequest { current_pixel_density: Option<f64>, } #[dom_struct] -pub struct HTMLImageElement { +pub(crate) struct HTMLImageElement { htmlelement: HTMLElement, image_request: Cell<ImageRequestPhase>, current_request: DomRefCell<ImageRequest>, @@ -176,11 +176,11 @@ pub struct HTMLImageElement { } impl HTMLImageElement { - pub fn get_url(&self) -> Option<ServoUrl> { + pub(crate) fn get_url(&self) -> Option<ServoUrl> { self.current_request.borrow().parsed_url.clone() } // https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument - pub fn is_usable(&self) -> Fallible<bool> { + pub(crate) fn is_usable(&self) -> Fallible<bool> { // If image has an intrinsic width or intrinsic height (or both) equal to zero, then return bad. if let Some(image) = &self.current_request.borrow().image { if image.width == 0 || image.height == 0 { @@ -197,7 +197,7 @@ impl HTMLImageElement { } } - pub fn image_data(&self) -> Option<Arc<Image>> { + pub(crate) fn image_data(&self) -> Option<Arc<Image>> { self.current_request.borrow().image.clone() } } @@ -939,7 +939,7 @@ impl HTMLImageElement { } /// <https://html.spec.whatwg.org/multipage/#update-the-image-data> - pub fn update_the_image_data(&self, can_gc: CanGc) { + pub(crate) fn update_the_image_data(&self, can_gc: CanGc) { let document = self.owner_document(); let window = document.window(); let elem = self.upcast::<Element>(); @@ -1043,7 +1043,7 @@ impl HTMLImageElement { } /// <https://html.spec.whatwg.org/multipage/#img-environment-changes> - pub fn react_to_environment_changes(&self) { + pub(crate) fn react_to_environment_changes(&self) { // Step 1 let task = ImageElementMicrotask::EnvironmentChanges { elem: DomRoot::from_ref(self), @@ -1325,7 +1325,7 @@ impl HTMLImageElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -1342,7 +1342,7 @@ impl HTMLImageElement { ) } - pub fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> { + pub(crate) fn areas(&self) -> Option<Vec<DomRoot<HTMLAreaElement>>> { let elem = self.upcast::<Element>(); let usemap_attr = elem.get_attribute(&ns!(), &local_name!("usemap"))?; @@ -1372,7 +1372,7 @@ impl HTMLImageElement { useMapElements.map(|mapElem| mapElem.get_area_elements()) } - pub fn same_origin(&self, origin: &MutableOrigin) -> bool { + pub(crate) fn same_origin(&self, origin: &MutableOrigin) -> bool { if let Some(ref image) = self.current_request.borrow().image { return image.cors_status == CorsStatus::Safe; } @@ -1386,7 +1386,7 @@ impl HTMLImageElement { } #[derive(JSTraceable, MallocSizeOf)] -pub enum ImageElementMicrotask { +pub(crate) enum ImageElementMicrotask { StableStateUpdateImageData { elem: DomRoot<HTMLImageElement>, generation: u32, @@ -1439,7 +1439,7 @@ impl MicrotaskRunnable for ImageElementMicrotask { } } -pub trait LayoutHTMLImageElementHelpers { +pub(crate) trait LayoutHTMLImageElementHelpers { fn image_url(self) -> Option<ServoUrl>; fn image_density(self) -> Option<f64>; fn image_data(self) -> (Option<Arc<Image>>, Option<ImageMetadata>); @@ -1489,7 +1489,7 @@ impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> { } //https://html.spec.whatwg.org/multipage/#parse-a-sizes-attribute -pub fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList { +pub(crate) fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList { let mut input = ParserInput::new(&value); let mut parser = Parser::new(&mut input); let url_data = Url::parse("about:blank").unwrap().into(); @@ -1914,7 +1914,7 @@ fn image_dimension_setter(element: &Element, attr: LocalName, value: u32, can_gc } /// Collect sequence of code points -pub fn collect_sequence_characters( +pub(crate) fn collect_sequence_characters( s: &str, mut predicate: impl FnMut(&char) -> bool, ) -> (&str, &str) { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index cdd4dd850bf..f1c60627082 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -88,7 +88,7 @@ const PASSWORD_REPLACEMENT_CHAR: char = '●'; #[derive(Clone, Copy, Default, JSTraceable, PartialEq)] #[allow(dead_code)] #[derive(MallocSizeOf)] -pub enum InputType { +pub(crate) enum InputType { Button, Checkbox, Color, @@ -174,7 +174,7 @@ impl InputType { } } - pub fn as_ime_type(&self) -> Option<InputMethodType> { + pub(crate) fn as_ime_type(&self) -> Option<InputMethodType> { match *self { InputType::Color => Some(InputMethodType::Color), InputType::Date => Some(InputMethodType::Date), @@ -239,7 +239,7 @@ enum StepDirection { } #[dom_struct] -pub struct HTMLInputElement { +pub(crate) struct HTMLInputElement { htmlelement: HTMLElement, input_type: Cell<InputType>, checked_changed: Cell<bool>, @@ -264,7 +264,7 @@ pub struct HTMLInputElement { } #[derive(JSTraceable)] -pub struct InputActivationState { +pub(crate) struct InputActivationState { indeterminate: bool, checked: bool, checked_radio: Option<DomRoot<HTMLInputElement>>, @@ -320,7 +320,7 @@ impl HTMLInputElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -337,7 +337,7 @@ impl HTMLInputElement { ) } - pub fn auto_directionality(&self) -> Option<String> { + pub(crate) fn auto_directionality(&self) -> Option<String> { match self.input_type() { InputType::Text | InputType::Search | InputType::Url | InputType::Email => { let value: String = self.Value().to_string(); @@ -347,7 +347,7 @@ impl HTMLInputElement { } } - pub fn directionality_from_value(value: &str) -> String { + pub(crate) fn directionality_from_value(value: &str) -> String { if HTMLInputElement::is_first_strong_character_rtl(value) { "rtl".to_owned() } else { @@ -399,21 +399,21 @@ impl HTMLInputElement { } #[inline] - pub fn input_type(&self) -> InputType { + pub(crate) fn input_type(&self) -> InputType { self.input_type.get() } #[inline] - pub fn is_submit_button(&self) -> bool { + pub(crate) fn is_submit_button(&self) -> bool { let input_type = self.input_type.get(); input_type == InputType::Submit || input_type == InputType::Image } - pub fn disable_sanitization(&self) { + pub(crate) fn disable_sanitization(&self) { self.sanitization_flag.set(false); } - pub fn enable_sanitization(&self) { + pub(crate) fn enable_sanitization(&self) { self.sanitization_flag.set(true); let mut textinput = self.textinput.borrow_mut(); let mut value = textinput.single_line_content().clone(); @@ -969,7 +969,7 @@ impl HTMLInputElement { } } -pub trait LayoutHTMLInputElementHelpers<'dom> { +pub(crate) trait LayoutHTMLInputElementHelpers<'dom> { fn value_for_layout(self) -> Cow<'dom, str>; fn size_for_layout(self) -> u32; fn selection_for_layout(self) -> Option<Range<usize>>; @@ -1685,7 +1685,7 @@ impl HTMLInputElement { /// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set> /// Steps range from 5.1 to 5.10 (specific to HTMLInputElement) - pub fn form_datums( + pub(crate) fn form_datums( &self, submitter: Option<FormSubmitterElement>, encoding: Option<&'static Encoding>, @@ -1812,7 +1812,7 @@ impl HTMLInputElement { } // https://html.spec.whatwg.org/multipage/#the-input-element:concept-form-reset-control - pub fn reset(&self) { + pub(crate) fn reset(&self) { match self.input_type() { InputType::Radio | InputType::Checkbox => { self.update_checked_state(self.DefaultChecked(), false); diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index c1f7a4d663c..a7025d678d6 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -28,7 +28,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLLabelElement { +pub(crate) struct HTMLLabelElement { htmlelement: HTMLElement, } @@ -44,7 +44,7 @@ impl HTMLLabelElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -166,7 +166,7 @@ impl VirtualMethods for HTMLLabelElement { } impl HTMLLabelElement { - pub fn first_labelable_descendant(&self) -> Option<DomRoot<HTMLElement>> { + pub(crate) fn first_labelable_descendant(&self) -> Option<DomRoot<HTMLElement>> { self.upcast::<Node>() .traverse_preorder(ShadowIncluding::No) .filter_map(DomRoot::downcast::<HTMLElement>) diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index 7d21ebf65cb..d0f551122e3 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -20,7 +20,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLLegendElement { +pub(crate) struct HTMLLegendElement { htmlelement: HTMLElement, form_owner: MutNullableDom<HTMLFormElement>, } @@ -38,7 +38,7 @@ impl HTMLLegendElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index 1ce637d4089..9d9e8d073c7 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -18,7 +18,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLLIElement { +pub(crate) struct HTMLLIElement { htmlelement: HTMLElement, } @@ -34,7 +34,7 @@ impl HTMLLIElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 9f6e34dccfc..93d38a52aa4 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -58,7 +58,7 @@ use crate::script_runtime::CanGc; use crate::stylesheet_loader::{StylesheetContextSource, StylesheetLoader, StylesheetOwner}; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub struct RequestGenerationId(u32); +pub(crate) struct RequestGenerationId(u32); impl RequestGenerationId { fn increment(self) -> RequestGenerationId { @@ -81,7 +81,7 @@ struct LinkProcessingOptions { } #[dom_struct] -pub struct HTMLLinkElement { +pub(crate) struct HTMLLinkElement { htmlelement: HTMLElement, /// The relations as specified by the "rel" attribute rel_list: MutNullableDom<DOMTokenList>, @@ -131,7 +131,7 @@ impl HTMLLinkElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -149,14 +149,14 @@ impl HTMLLinkElement { ) } - pub fn get_request_generation_id(&self) -> RequestGenerationId { + pub(crate) fn get_request_generation_id(&self) -> RequestGenerationId { self.request_generation_id.get() } // FIXME(emilio): These methods are duplicated with // HTMLStyleElement::set_stylesheet. #[allow(crown::unrooted_must_root)] - pub fn set_stylesheet(&self, s: Arc<Stylesheet>) { + pub(crate) fn set_stylesheet(&self, s: Arc<Stylesheet>) { let stylesheets_owner = self.stylesheet_list_owner(); if let Some(ref s) = *self.stylesheet.borrow() { stylesheets_owner.remove_stylesheet(self.upcast(), s) @@ -166,11 +166,11 @@ impl HTMLLinkElement { stylesheets_owner.add_stylesheet(self.upcast(), s); } - pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { + pub(crate) fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { self.stylesheet.borrow().clone() } - pub fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new( @@ -185,7 +185,7 @@ impl HTMLLinkElement { }) } - pub fn is_alternate(&self) -> bool { + pub(crate) fn is_alternate(&self) -> bool { self.relations.get().contains(LinkRelations::ALTERNATE) } diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs index 10fe90ce61e..ee89c4c4da9 100644 --- a/components/script/dom/htmlmapelement.rs +++ b/components/script/dom/htmlmapelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::{Node, ShadowIncluding}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLMapElement { +pub(crate) struct HTMLMapElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLMapElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -46,7 +46,7 @@ impl HTMLMapElement { ) } - pub fn get_area_elements(&self) -> Vec<DomRoot<HTMLAreaElement>> { + pub(crate) fn get_area_elements(&self) -> Vec<DomRoot<HTMLAreaElement>> { self.upcast::<Node>() .traverse_preorder(ShadowIncluding::No) .filter_map(DomRoot::downcast::<HTMLAreaElement>) diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 100ab754f42..87526b4950d 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -155,7 +155,7 @@ impl FrameHolder { } } -pub struct MediaFrameRenderer { +pub(crate) struct MediaFrameRenderer { player_id: Option<u64>, compositor_api: CrossProcessCompositorApi, current_frame: Option<MediaFrame>, @@ -322,7 +322,7 @@ impl From<MediaStreamOrBlob> for SrcObject { #[dom_struct] #[allow(non_snake_case)] -pub struct HTMLMediaElement { +pub(crate) struct HTMLMediaElement { htmlelement: HTMLElement, /// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate> network_state: Cell<NetworkState>, @@ -416,7 +416,7 @@ pub struct HTMLMediaElement { /// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate> #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] #[repr(u8)] -pub enum NetworkState { +pub(crate) enum NetworkState { Empty = HTMLMediaElementConstants::NETWORK_EMPTY as u8, Idle = HTMLMediaElementConstants::NETWORK_IDLE as u8, Loading = HTMLMediaElementConstants::NETWORK_LOADING as u8, @@ -427,7 +427,7 @@ pub enum NetworkState { #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq, PartialOrd)] #[repr(u8)] #[allow(clippy::enum_variant_names)] // Clippy warning silenced here because these names are from the specification. -pub enum ReadyState { +pub(crate) enum ReadyState { HaveNothing = HTMLMediaElementConstants::HAVE_NOTHING as u8, HaveMetadata = HTMLMediaElementConstants::HAVE_METADATA as u8, HaveCurrentData = HTMLMediaElementConstants::HAVE_CURRENT_DATA as u8, @@ -436,7 +436,11 @@ pub enum ReadyState { } impl HTMLMediaElement { - pub fn new_inherited(tag_name: LocalName, prefix: Option<Prefix>, document: &Document) -> Self { + pub(crate) fn new_inherited( + tag_name: LocalName, + prefix: Option<Prefix>, + document: &Document, + ) -> Self { Self { htmlelement: HTMLElement::new_inherited(tag_name, prefix, document), network_state: Cell::new(NetworkState::Empty), @@ -480,7 +484,7 @@ impl HTMLMediaElement { } } - pub fn get_ready_state(&self) -> ReadyState { + pub(crate) fn get_ready_state(&self) -> ReadyState { self.ready_state.get() } @@ -510,7 +514,7 @@ impl HTMLMediaElement { /// we pass true to that method again. /// /// <https://html.spec.whatwg.org/multipage/#delaying-the-load-event-flag> - pub fn delay_load_event(&self, delay: bool, can_gc: CanGc) { + pub(crate) fn delay_load_event(&self, delay: bool, can_gc: CanGc) { let blocker = &self.delaying_the_load_event_flag; if delay && blocker.borrow().is_none() { *blocker.borrow_mut() = Some(LoadBlocker::new(&self.owner_document(), LoadType::Media)); @@ -1222,7 +1226,7 @@ impl HTMLMediaElement { /// Handles insertion of `source` children. /// /// <https://html.spec.whatwg.org/multipage/#the-source-element:nodes-are-inserted> - pub fn handle_source_child_insertion(&self, can_gc: CanGc) { + pub(crate) fn handle_source_child_insertion(&self, can_gc: CanGc) { if self.upcast::<Element>().has_attribute(&local_name!("src")) { return; } @@ -1311,7 +1315,7 @@ impl HTMLMediaElement { } /// <https://html.spec.whatwg.org/multipage/#poster-frame> - pub fn process_poster_image_loaded(&self, image: Arc<Image>) { + pub(crate) fn process_poster_image_loaded(&self, image: Arc<Image>) { if !self.show_poster.get() { return; } @@ -1454,7 +1458,7 @@ impl HTMLMediaElement { Ok(()) } - pub fn set_audio_track(&self, idx: usize, enabled: bool) { + pub(crate) fn set_audio_track(&self, idx: usize, enabled: bool) { if let Some(ref player) = *self.player.borrow() { if let Err(err) = player.lock().unwrap().set_audio_track(idx as i32, enabled) { warn!("Could not set audio track {:#?}", err); @@ -1462,7 +1466,7 @@ impl HTMLMediaElement { } } - pub fn set_video_track(&self, idx: usize, enabled: bool) { + pub(crate) fn set_video_track(&self, idx: usize, enabled: bool) { if let Some(ref player) = *self.player.borrow() { if let Err(err) = player.lock().unwrap().set_video_track(idx as i32, enabled) { warn!("Could not set video track {:#?}", err); @@ -1947,7 +1951,7 @@ impl HTMLMediaElement { } } - pub fn get_current_frame(&self) -> Option<VideoFrame> { + pub(crate) fn get_current_frame(&self) -> Option<VideoFrame> { self.video_renderer .lock() .unwrap() @@ -1956,11 +1960,11 @@ impl HTMLMediaElement { .map(|holder| holder.get_frame()) } - pub fn get_current_frame_data(&self) -> Option<MediaFrame> { + pub(crate) fn get_current_frame_data(&self) -> Option<MediaFrame> { self.video_renderer.lock().unwrap().current_frame } - pub fn clear_current_frame_data(&self) { + pub(crate) fn clear_current_frame_data(&self) { self.handle_resize(None, None); self.video_renderer.lock().unwrap().current_frame = None; self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); @@ -1976,7 +1980,11 @@ impl HTMLMediaElement { /// selected by the servo-media Player instance. However, in some cases, like /// the WebAudio MediaElementAudioSourceNode, we need to set a custom audio /// renderer. - pub fn set_audio_renderer(&self, audio_renderer: Arc<Mutex<dyn AudioRenderer>>, can_gc: CanGc) { + pub(crate) fn set_audio_renderer( + &self, + audio_renderer: Arc<Mutex<dyn AudioRenderer>>, + can_gc: CanGc, + ) { *self.audio_renderer.borrow_mut() = Some(audio_renderer); if let Some(ref player) = *self.player.borrow() { if let Err(e) = player.lock().unwrap().stop() { @@ -1995,18 +2003,18 @@ impl HTMLMediaElement { media_session.send_event(event); } - pub fn set_duration(&self, duration: f64) { + pub(crate) fn set_duration(&self, duration: f64) { self.duration.set(duration); } /// Sets a new value for the show_poster propperty. Updates video_rederer /// with the new value. - pub fn set_show_poster(&self, show_poster: bool) { + pub(crate) fn set_show_poster(&self, show_poster: bool) { self.show_poster.set(show_poster); self.video_renderer.lock().unwrap().show_poster = show_poster; } - pub fn reset(&self) { + pub(crate) fn reset(&self) { if let Some(ref player) = *self.player.borrow() { if let Err(e) = player.lock().unwrap().stop() { eprintln!("Could not stop player {:?}", e); @@ -2509,7 +2517,7 @@ impl VirtualMethods for HTMLMediaElement { } #[derive(JSTraceable, MallocSizeOf)] -pub enum MediaElementMicrotask { +pub(crate) enum MediaElementMicrotask { ResourceSelection { elem: DomRoot<HTMLMediaElement>, generation_id: u32, @@ -2579,7 +2587,7 @@ enum CancelReason { } #[derive(MallocSizeOf)] -pub struct HTMLMediaElementFetchContext { +pub(crate) struct HTMLMediaElementFetchContext { /// Some if the request has been cancelled. cancel_reason: Option<CancelReason>, /// Indicates whether the fetched stream is seekable. diff --git a/components/script/dom/htmlmenuelement.rs b/components/script/dom/htmlmenuelement.rs index 292124e1b48..2caa6a884e6 100644 --- a/components/script/dom/htmlmenuelement.rs +++ b/components/script/dom/htmlmenuelement.rs @@ -14,7 +14,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLMenuElement { +pub(crate) struct HTMLMenuElement { htmlelement: HTMLElement, } @@ -30,7 +30,7 @@ impl HTMLMenuElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 12f518def07..bff3b9757a2 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -33,19 +33,19 @@ use crate::script_runtime::CanGc; use crate::timers::OneshotTimerCallback; #[dom_struct] -pub struct HTMLMetaElement { +pub(crate) struct HTMLMetaElement { htmlelement: HTMLElement, } #[derive(JSTraceable, MallocSizeOf)] -pub struct RefreshRedirectDue { +pub(crate) struct RefreshRedirectDue { #[no_trace] - pub url: ServoUrl, + pub(crate) url: ServoUrl, #[ignore_malloc_size_of = "non-owning"] - pub window: DomRoot<Window>, + pub(crate) window: DomRoot<Window>, } impl RefreshRedirectDue { - pub fn invoke(self, can_gc: CanGc) { + pub(crate) fn invoke(self, can_gc: CanGc) { self.window.Location().navigate( self.url.clone(), NavigationHistoryBehavior::Replace, @@ -67,7 +67,7 @@ impl HTMLMetaElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs index df7ffa2c6af..a86abf6ab51 100644 --- a/components/script/dom/htmlmeterelement.rs +++ b/components/script/dom/htmlmeterelement.rs @@ -21,7 +21,7 @@ use crate::dom::nodelist::NodeList; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLMeterElement { +pub(crate) struct HTMLMeterElement { htmlelement: HTMLElement, labels_node_list: MutNullableDom<NodeList>, } @@ -40,7 +40,7 @@ impl HTMLMeterElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs index b0b7b86b0a3..f4a0d7ab33d 100644 --- a/components/script/dom/htmlmodelement.rs +++ b/components/script/dom/htmlmodelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLModElement { +pub(crate) struct HTMLModElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLModElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 49fbaaec053..c06ba9c33c7 100644 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -27,7 +27,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLObjectElement { +pub(crate) struct HTMLObjectElement { htmlelement: HTMLElement, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -51,7 +51,7 @@ impl HTMLObjectElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs index 7b42893fbbe..993d4cb534f 100644 --- a/components/script/dom/htmlolistelement.rs +++ b/components/script/dom/htmlolistelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLOListElement { +pub(crate) struct HTMLOListElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLOListElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index ef5adb06f2f..a54a3de95e7 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -23,7 +23,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLOptGroupElement { +pub(crate) struct HTMLOptGroupElement { htmlelement: HTMLElement, } @@ -44,7 +44,7 @@ impl HTMLOptGroupElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 66925d56672..fbf66afbe2f 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -38,7 +38,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLOptionElement { +pub(crate) struct HTMLOptionElement { htmlelement: HTMLElement, /// <https://html.spec.whatwg.org/multipage/#attr-option-selected> @@ -67,7 +67,7 @@ impl HTMLOptionElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -84,11 +84,11 @@ impl HTMLOptionElement { ) } - pub fn set_selectedness(&self, selected: bool) { + pub(crate) fn set_selectedness(&self, selected: bool) { self.selectedness.set(selected); } - pub fn set_dirtiness(&self, dirtiness: bool) { + pub(crate) fn set_dirtiness(&self, dirtiness: bool) { self.dirtiness.set(dirtiness); } diff --git a/components/script/dom/htmloptionscollection.rs b/components/script/dom/htmloptionscollection.rs index 0820b2999b0..88d3bd8dc41 100644 --- a/components/script/dom/htmloptionscollection.rs +++ b/components/script/dom/htmloptionscollection.rs @@ -29,7 +29,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLOptionsCollection { +pub(crate) struct HTMLOptionsCollection { collection: HTMLCollection, } @@ -43,7 +43,7 @@ impl HTMLOptionsCollection { } } - pub fn new( + pub(crate) fn new( window: &Window, select: &HTMLSelectElement, filter: Box<dyn CollectionFilter + 'static>, diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index b2415260b62..70c60d212b7 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -24,7 +24,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLOutputElement { +pub(crate) struct HTMLOutputElement { htmlelement: HTMLElement, form_owner: MutNullableDom<HTMLFormElement>, labels_node_list: MutNullableDom<NodeList>, @@ -48,7 +48,7 @@ impl HTMLOutputElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -65,7 +65,7 @@ impl HTMLOutputElement { ) } - pub fn reset(&self, can_gc: CanGc) { + pub(crate) fn reset(&self, can_gc: CanGc) { Node::string_replace_all(self.DefaultValue(), self.upcast::<Node>(), can_gc); *self.default_value_override.borrow_mut() = None; } diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index 85adea6ae48..b8e23285c32 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLParagraphElement { +pub(crate) struct HTMLParagraphElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLParagraphElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs index 81c081d3ff2..6bed543251a 100644 --- a/components/script/dom/htmlparamelement.rs +++ b/components/script/dom/htmlparamelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLParamElement { +pub(crate) struct HTMLParamElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLParamElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlpictureelement.rs b/components/script/dom/htmlpictureelement.rs index cc19b08518b..0eac2af24ce 100644 --- a/components/script/dom/htmlpictureelement.rs +++ b/components/script/dom/htmlpictureelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLPictureElement { +pub(crate) struct HTMLPictureElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLPictureElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs index fcd152be7e5..2e14491472f 100644 --- a/components/script/dom/htmlpreelement.rs +++ b/components/script/dom/htmlpreelement.rs @@ -18,7 +18,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLPreElement { +pub(crate) struct HTMLPreElement { htmlelement: HTMLElement, } @@ -34,7 +34,7 @@ impl HTMLPreElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs index 5a0ee59aa6b..487415ffc6a 100644 --- a/components/script/dom/htmlprogresselement.rs +++ b/components/script/dom/htmlprogresselement.rs @@ -19,7 +19,7 @@ use crate::dom::nodelist::NodeList; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLProgressElement { +pub(crate) struct HTMLProgressElement { htmlelement: HTMLElement, labels_node_list: MutNullableDom<NodeList>, } @@ -37,7 +37,7 @@ impl HTMLProgressElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs index 53ea04925d5..b0adf962e87 100644 --- a/components/script/dom/htmlquoteelement.rs +++ b/components/script/dom/htmlquoteelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLQuoteElement { +pub(crate) struct HTMLQuoteElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLQuoteElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index bb9f68ac8d9..b0d8d5ab47b 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -97,7 +97,7 @@ impl ScriptSource for ScriptOrigin { } // TODO Implement offthread compilation in mozjs -/*pub struct OffThreadCompilationContext { +/*pub(crate) struct OffThreadCompilationContext { script_element: Trusted<HTMLScriptElement>, script_kind: ExternalScriptKind, final_url: ServoUrl, @@ -163,10 +163,10 @@ unsafe extern "C" fn off_thread_compilation_callback( /// An unique id for script element. #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] -pub struct ScriptId(#[no_trace] Uuid); +pub(crate) struct ScriptId(#[no_trace] Uuid); #[dom_struct] -pub struct HTMLScriptElement { +pub(crate) struct HTMLScriptElement { htmlelement: HTMLElement, /// <https://html.spec.whatwg.org/multipage/#already-started> @@ -210,7 +210,7 @@ impl HTMLScriptElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -228,14 +228,14 @@ impl HTMLScriptElement { ) } - pub fn get_script_id(&self) -> ScriptId { + pub(crate) fn get_script_id(&self) -> ScriptId { self.id } } /// Supported script types as defined by /// <https://html.spec.whatwg.org/multipage/#javascript-mime-type>. -pub static SCRIPT_JS_MIMES: StaticStringVec = &[ +pub(crate) static SCRIPT_JS_MIMES: StaticStringVec = &[ "application/ecmascript", "application/javascript", "application/x-ecmascript", @@ -255,27 +255,27 @@ pub static SCRIPT_JS_MIMES: StaticStringVec = &[ ]; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ScriptType { +pub(crate) enum ScriptType { Classic, Module, } #[derive(JSTraceable, MallocSizeOf)] -pub struct CompiledSourceCode { +pub(crate) struct CompiledSourceCode { #[ignore_malloc_size_of = "SM handles JS values"] - pub source_code: Stencil, + pub(crate) source_code: Stencil, #[ignore_malloc_size_of = "Rc is hard"] - pub original_text: Rc<DOMString>, + pub(crate) original_text: Rc<DOMString>, } #[derive(JSTraceable)] -pub enum SourceCode { +pub(crate) enum SourceCode { Text(Rc<DOMString>), Compiled(CompiledSourceCode), } #[derive(JSTraceable, MallocSizeOf)] -pub struct ScriptOrigin { +pub(crate) struct ScriptOrigin { #[ignore_malloc_size_of = "Rc is hard"] code: SourceCode, #[no_trace] @@ -287,7 +287,7 @@ pub struct ScriptOrigin { } impl ScriptOrigin { - pub fn internal( + pub(crate) fn internal( text: Rc<DOMString>, url: ServoUrl, fetch_options: ScriptFetchOptions, @@ -304,7 +304,7 @@ impl ScriptOrigin { } } - pub fn external( + pub(crate) fn external( text: Rc<DOMString>, url: ServoUrl, fetch_options: ScriptFetchOptions, @@ -321,7 +321,7 @@ impl ScriptOrigin { } } - pub fn text(&self) -> Rc<DOMString> { + pub(crate) fn text(&self) -> Rc<DOMString> { match &self.code { SourceCode::Text(text) => Rc::clone(text), SourceCode::Compiled(compiled_script) => Rc::clone(&compiled_script.original_text), @@ -354,7 +354,7 @@ fn finish_fetching_a_classic_script( document.finish_load(LoadType::Script(url), can_gc); } -pub type ScriptResult = Result<ScriptOrigin, NoTrace<NetworkError>>; +pub(crate) type ScriptResult = Result<ScriptOrigin, NoTrace<NetworkError>>; /// The context required for asynchronously loading an external script source. struct ClassicContext { @@ -602,7 +602,7 @@ fn fetch_a_classic_script( impl HTMLScriptElement { /// <https://html.spec.whatwg.org/multipage/#prepare-a-script> - pub fn prepare(&self, can_gc: CanGc) { + pub(crate) fn prepare(&self, can_gc: CanGc) { // Step 1. if self.already_started.get() { return; @@ -910,7 +910,7 @@ impl HTMLScriptElement { } /// <https://html.spec.whatwg.org/multipage/#execute-the-script-block> - pub fn execute(&self, result: ScriptResult) { + pub(crate) fn execute(&self, result: ScriptResult) { // Step 1. let doc = self.owner_document(); if self.parser_inserted.get() && *doc != *self.parser_document { @@ -981,7 +981,7 @@ impl HTMLScriptElement { } // https://html.spec.whatwg.org/multipage/#run-a-classic-script - pub fn run_a_classic_script(&self, script: &ScriptOrigin, can_gc: CanGc) { + pub(crate) fn run_a_classic_script(&self, script: &ScriptOrigin, can_gc: CanGc) { // TODO use a settings object rather than this element's document/window // Step 2 let document = self.owner_document(); @@ -1012,7 +1012,12 @@ impl HTMLScriptElement { #[allow(unsafe_code)] /// <https://html.spec.whatwg.org/multipage/#run-a-module-script> - pub fn run_a_module_script(&self, script: &ScriptOrigin, _rethrow_errors: bool, can_gc: CanGc) { + pub(crate) fn run_a_module_script( + &self, + script: &ScriptOrigin, + _rethrow_errors: bool, + can_gc: CanGc, + ) { // TODO use a settings object rather than this element's document/window // Step 2 let document = self.owner_document(); @@ -1065,14 +1070,14 @@ impl HTMLScriptElement { } } - pub fn queue_error_event(&self) { + pub(crate) fn queue_error_event(&self) { self.owner_global() .task_manager() .dom_manipulation_task_source() .queue_simple_event(self.upcast(), atom!("error")); } - pub fn dispatch_load_event(&self, can_gc: CanGc) { + pub(crate) fn dispatch_load_event(&self, can_gc: CanGc) { self.dispatch_event( atom!("load"), EventBubbles::DoesNotBubble, @@ -1081,7 +1086,7 @@ impl HTMLScriptElement { ); } - pub fn dispatch_error_event(&self, can_gc: CanGc) { + pub(crate) fn dispatch_error_event(&self, can_gc: CanGc) { self.dispatch_event( atom!("error"), EventBubbles::DoesNotBubble, @@ -1091,7 +1096,7 @@ impl HTMLScriptElement { } // https://html.spec.whatwg.org/multipage/#prepare-a-script Step 7. - pub fn get_script_type(&self) -> Option<ScriptType> { + pub(crate) fn get_script_type(&self) -> Option<ScriptType> { let element = self.upcast::<Element>(); let type_attr = element.get_attribute(&ns!(), &local_name!("type")); @@ -1144,19 +1149,19 @@ impl HTMLScriptElement { script_type } - pub fn set_parser_inserted(&self, parser_inserted: bool) { + pub(crate) fn set_parser_inserted(&self, parser_inserted: bool) { self.parser_inserted.set(parser_inserted); } - pub fn get_parser_inserted(&self) -> bool { + pub(crate) fn get_parser_inserted(&self) -> bool { self.parser_inserted.get() } - pub fn set_already_started(&self, already_started: bool) { + pub(crate) fn set_already_started(&self, already_started: bool) { self.already_started.set(already_started); } - pub fn get_non_blocking(&self) -> bool { + pub(crate) fn get_non_blocking(&self) -> bool { self.non_blocking.get() } diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index d21e84c2087..b3efa6da21d 100644 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -62,7 +62,7 @@ impl CollectionFilter for OptionsFilter { } #[dom_struct] -pub struct HTMLSelectElement { +pub(crate) struct HTMLSelectElement { htmlelement: HTMLElement, options: MutNullableDom<HTMLOptionsCollection>, form_owner: MutNullableDom<HTMLFormElement>, @@ -93,7 +93,7 @@ impl HTMLSelectElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -114,7 +114,7 @@ impl HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#concept-select-option-list - pub fn list_of_options(&self) -> impl Iterator<Item = DomRoot<HTMLOptionElement>> { + pub(crate) fn list_of_options(&self) -> impl Iterator<Item = DomRoot<HTMLOptionElement>> { self.upcast::<Node>().children().flat_map(|node| { if node.is::<HTMLOptionElement>() { let node = DomRoot::downcast::<HTMLOptionElement>(node).unwrap(); @@ -140,7 +140,7 @@ impl HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#the-select-element:concept-form-reset-control - pub fn reset(&self) { + pub(crate) fn reset(&self) { for opt in self.list_of_options() { opt.set_selectedness(opt.DefaultSelected()); opt.set_dirtiness(false); @@ -149,7 +149,7 @@ impl HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#ask-for-a-reset - pub fn ask_for_reset(&self) { + pub(crate) fn ask_for_reset(&self) { if self.Multiple() { return; } @@ -177,7 +177,7 @@ impl HTMLSelectElement { } } - pub fn push_form_data(&self, data_set: &mut Vec<FormDatum>) { + pub(crate) fn push_form_data(&self, data_set: &mut Vec<FormDatum>) { if self.Name().is_empty() { return; } @@ -194,7 +194,7 @@ impl HTMLSelectElement { } // https://html.spec.whatwg.org/multipage/#concept-select-pick - pub fn pick_option(&self, picked: &HTMLOptionElement) { + pub(crate) fn pick_option(&self, picked: &HTMLOptionElement) { if !self.Multiple() { let picked = picked.upcast(); for opt in self.list_of_options() { diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index 886a935b0ea..6dac11e1510 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -22,7 +22,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLSourceElement { +pub(crate) struct HTMLSourceElement { htmlelement: HTMLElement, } @@ -38,7 +38,7 @@ impl HTMLSourceElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs index 5f41592693b..bbf3c459042 100644 --- a/components/script/dom/htmlspanelement.rs +++ b/components/script/dom/htmlspanelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLSpanElement { +pub(crate) struct HTMLSpanElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLSpanElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 0abfa43a877..8d8b7d8492e 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -31,7 +31,7 @@ use crate::script_runtime::CanGc; use crate::stylesheet_loader::{StylesheetLoader, StylesheetOwner}; #[dom_struct] -pub struct HTMLStyleElement { +pub(crate) struct HTMLStyleElement { htmlelement: HTMLElement, #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -65,7 +65,7 @@ impl HTMLStyleElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -83,7 +83,7 @@ impl HTMLStyleElement { ) } - pub fn parse_own_css(&self) { + pub(crate) fn parse_own_css(&self) { let node = self.upcast::<Node>(); let element = self.upcast::<Element>(); assert!(node.is_connected()); @@ -144,7 +144,7 @@ impl HTMLStyleElement { // FIXME(emilio): This is duplicated with HTMLLinkElement::set_stylesheet. #[allow(crown::unrooted_must_root)] - pub fn set_stylesheet(&self, s: Arc<Stylesheet>) { + pub(crate) fn set_stylesheet(&self, s: Arc<Stylesheet>) { let stylesheets_owner = self.stylesheet_list_owner(); if let Some(ref s) = *self.stylesheet.borrow() { stylesheets_owner.remove_stylesheet(self.upcast(), s) @@ -154,11 +154,11 @@ impl HTMLStyleElement { stylesheets_owner.add_stylesheet(self.upcast(), s); } - pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { + pub(crate) fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { self.stylesheet.borrow().clone() } - pub fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { self.get_stylesheet().map(|sheet| { self.cssom_stylesheet.or_init(|| { CSSStyleSheet::new( diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs index aaedfbd2eb2..a684b740627 100644 --- a/components/script/dom/htmltablecaptionelement.rs +++ b/components/script/dom/htmltablecaptionelement.rs @@ -14,7 +14,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTableCaptionElement { +pub(crate) struct HTMLTableCaptionElement { htmlelement: HTMLElement, } @@ -30,7 +30,7 @@ impl HTMLTableCaptionElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 4a5b125f3ea..cc9f5252bf9 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -28,7 +28,7 @@ const DEFAULT_COLSPAN: u32 = 1; const DEFAULT_ROWSPAN: u32 = 1; #[dom_struct] -pub struct HTMLTableCellElement { +pub(crate) struct HTMLTableCellElement { htmlelement: HTMLElement, } @@ -44,7 +44,7 @@ impl HTMLTableCellElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -108,7 +108,7 @@ impl HTMLTableCellElementMethods<crate::DomTypeHolder> for HTMLTableCellElement } } -pub trait HTMLTableCellElementLayoutHelpers<'dom> { +pub(crate) trait HTMLTableCellElementLayoutHelpers<'dom> { fn get_background_color(self) -> Option<AbsoluteColor>; fn get_colspan(self) -> Option<u32>; fn get_rowspan(self) -> Option<u32>; diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs index bdcd083d296..c7857089d23 100644 --- a/components/script/dom/htmltablecolelement.rs +++ b/components/script/dom/htmltablecolelement.rs @@ -23,7 +23,7 @@ use crate::script_runtime::CanGc; const DEFAULT_SPAN: u32 = 1; #[dom_struct] -pub struct HTMLTableColElement { +pub(crate) struct HTMLTableColElement { htmlelement: HTMLElement, } @@ -39,7 +39,7 @@ impl HTMLTableColElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -67,7 +67,7 @@ impl HTMLTableColElementMethods<crate::DomTypeHolder> for HTMLTableColElement { make_uint_setter!(SetSpan, "span", DEFAULT_SPAN); } -pub trait HTMLTableColElementLayoutHelpers<'dom> { +pub(crate) trait HTMLTableColElementLayoutHelpers<'dom> { fn get_span(self) -> Option<u32>; fn get_width(self) -> LengthOrPercentageOrAuto; } diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index ca97199908a..05666f7831e 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -31,7 +31,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTableElement { +pub(crate) struct HTMLTableElement { htmlelement: HTMLElement, border: Cell<Option<u32>>, cellpadding: Cell<Option<u32>>, @@ -71,7 +71,7 @@ impl HTMLTableElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -91,7 +91,7 @@ impl HTMLTableElement { n } - pub fn get_border(&self) -> Option<u32> { + pub(crate) fn get_border(&self) -> Option<u32> { self.border.get() } @@ -447,7 +447,7 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement { make_nonzero_dimension_setter!(SetWidth, "width"); } -pub trait HTMLTableElementLayoutHelpers { +pub(crate) trait HTMLTableElementLayoutHelpers { fn get_background_color(self) -> Option<AbsoluteColor>; fn get_border(self) -> Option<u32>; fn get_cellpadding(self) -> Option<u32>; diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index ae0d8082db3..41564100e05 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -28,7 +28,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTableRowElement { +pub(crate) struct HTMLTableRowElement { htmlelement: HTMLElement, cells: MutNullableDom<HTMLCollection>, } @@ -46,7 +46,7 @@ impl HTMLTableRowElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -151,7 +151,7 @@ impl HTMLTableRowElementMethods<crate::DomTypeHolder> for HTMLTableRowElement { } } -pub trait HTMLTableRowElementLayoutHelpers { +pub(crate) trait HTMLTableRowElementLayoutHelpers { fn get_background_color(self) -> Option<AbsoluteColor>; fn get_height(self) -> LengthOrPercentageOrAuto; } diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 9123e1c20ea..ffdc1e928b1 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -24,7 +24,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTableSectionElement { +pub(crate) struct HTMLTableSectionElement { htmlelement: HTMLElement, } @@ -40,7 +40,7 @@ impl HTMLTableSectionElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -87,7 +87,7 @@ impl HTMLTableSectionElementMethods<crate::DomTypeHolder> for HTMLTableSectionEl } } -pub trait HTMLTableSectionElementLayoutHelpers { +pub(crate) trait HTMLTableSectionElementLayoutHelpers { fn get_background_color(self) -> Option<AbsoluteColor>; fn get_height(self) -> LengthOrPercentageOrAuto; } diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 19e46879b83..8ce3119af1f 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -19,7 +19,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTemplateElement { +pub(crate) struct HTMLTemplateElement { htmlelement: HTMLElement, /// <https://html.spec.whatwg.org/multipage/#template-contents> @@ -39,7 +39,7 @@ impl HTMLTemplateElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 9ec1fb19936..9ea70e03bd6 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -46,7 +46,7 @@ use crate::textinput::{ }; #[dom_struct] -pub struct HTMLTextAreaElement { +pub(crate) struct HTMLTextAreaElement { htmlelement: HTMLElement, #[ignore_malloc_size_of = "TextInput contains an IPCSender which cannot be measured"] #[no_trace] @@ -59,7 +59,7 @@ pub struct HTMLTextAreaElement { validity_state: MutNullableDom<ValidityState>, } -pub trait LayoutHTMLTextAreaElementHelpers { +pub(crate) trait LayoutHTMLTextAreaElementHelpers { fn value_for_layout(self) -> String; fn selection_for_layout(self) -> Option<Range<usize>>; fn get_cols(self) -> u32; @@ -169,7 +169,7 @@ impl HTMLTextAreaElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -186,7 +186,7 @@ impl HTMLTextAreaElement { ) } - pub fn auto_directionality(&self) -> String { + pub(crate) fn auto_directionality(&self) -> String { let value: String = self.Value().to_string(); HTMLInputElement::directionality_from_value(&value) } @@ -445,7 +445,7 @@ impl HTMLTextAreaElementMethods<crate::DomTypeHolder> for HTMLTextAreaElement { } impl HTMLTextAreaElement { - pub fn reset(&self) { + pub(crate) fn reset(&self) { // https://html.spec.whatwg.org/multipage/#the-textarea-element:concept-form-reset-control let mut textinput = self.textinput.borrow_mut(); textinput.set_content(self.DefaultValue()); diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs index c54527548b4..ebb63c6cfb6 100644 --- a/components/script/dom/htmltimeelement.rs +++ b/components/script/dom/htmltimeelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTimeElement { +pub(crate) struct HTMLTimeElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLTimeElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index 10d0ac0751a..5eea0d278fe 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -20,7 +20,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLTitleElement { +pub(crate) struct HTMLTitleElement { htmlelement: HTMLElement, popped: Cell<bool>, } @@ -38,7 +38,7 @@ impl HTMLTitleElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs index f530753858f..03f4773b7c5 100644 --- a/components/script/dom/htmltrackelement.rs +++ b/components/script/dom/htmltrackelement.rs @@ -22,7 +22,7 @@ use crate::script_runtime::CanGc; #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] #[repr(u16)] #[allow(unused)] -pub enum ReadyState { +pub(crate) enum ReadyState { None = HTMLTrackElementConstants::NONE, Loading = HTMLTrackElementConstants::LOADING, Loaded = HTMLTrackElementConstants::LOADED, @@ -30,7 +30,7 @@ pub enum ReadyState { } #[dom_struct] -pub struct HTMLTrackElement { +pub(crate) struct HTMLTrackElement { htmlelement: HTMLElement, ready_state: ReadyState, track: Dom<TextTrack>, @@ -50,7 +50,7 @@ impl HTMLTrackElement { } } - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs index e462d66963e..37be6865e21 100644 --- a/components/script/dom/htmlulistelement.rs +++ b/components/script/dom/htmlulistelement.rs @@ -15,7 +15,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLUListElement { +pub(crate) struct HTMLUListElement { htmlelement: HTMLElement, } @@ -31,7 +31,7 @@ impl HTMLUListElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs index 25efc28cc23..a286c601ffc 100644 --- a/components/script/dom/htmlunknownelement.rs +++ b/components/script/dom/htmlunknownelement.rs @@ -13,7 +13,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLUnknownElement { +pub(crate) struct HTMLUnknownElement { htmlelement: HTMLElement, } @@ -29,7 +29,7 @@ impl HTMLUnknownElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index 3884436cdaa..5291f6c4dbb 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -46,7 +46,7 @@ use crate::network_listener::{self, PreInvoke, ResourceTimingListener}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct HTMLVideoElement { +pub(crate) struct HTMLVideoElement { htmlmediaelement: HTMLMediaElement, /// <https://html.spec.whatwg.org/multipage/#dom-video-videowidth> video_width: Cell<Option<u32>>, @@ -86,7 +86,7 @@ impl HTMLVideoElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -103,16 +103,16 @@ impl HTMLVideoElement { ) } - pub fn get_video_width(&self) -> Option<u32> { + pub(crate) fn get_video_width(&self) -> Option<u32> { self.video_width.get() } - pub fn get_video_height(&self) -> Option<u32> { + pub(crate) fn get_video_height(&self) -> Option<u32> { self.video_height.get() } /// <https://html.spec.whatwg.org/multipage#event-media-resize> - pub fn resize(&self, width: Option<u32>, height: Option<u32>) -> Option<(u32, u32)> { + pub(crate) fn resize(&self, width: Option<u32>, height: Option<u32>) -> Option<(u32, u32)> { self.video_width.set(width); self.video_height.set(height); @@ -136,7 +136,9 @@ impl HTMLVideoElement { sent_resize } - pub fn get_current_frame_data(&self) -> Option<(Option<ipc::IpcSharedMemory>, Size2D<u32>)> { + pub(crate) fn get_current_frame_data( + &self, + ) -> Option<(Option<ipc::IpcSharedMemory>, Size2D<u32>)> { let frame = self.htmlmediaelement.get_current_frame(); if frame.is_some() { *self.last_frame.borrow_mut() = frame; @@ -444,7 +446,7 @@ impl PosterFrameFetchContext { } } -pub trait LayoutHTMLVideoElementHelpers { +pub(crate) trait LayoutHTMLVideoElementHelpers { fn data(self) -> HTMLMediaData; fn get_width(self) -> LengthOrPercentageOrAuto; fn get_height(self) -> LengthOrPercentageOrAuto; diff --git a/components/script/dom/iirfilternode.rs b/components/script/dom/iirfilternode.rs index 8e6d4fd8d11..cf50c47bc5e 100644 --- a/components/script/dom/iirfilternode.rs +++ b/components/script/dom/iirfilternode.rs @@ -28,7 +28,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct IIRFilterNode { +pub(crate) struct IIRFilterNode { node: AudioNode, feedforward: Vec<Finite<f64>>, feedback: Vec<Finite<f64>>, @@ -36,7 +36,7 @@ pub struct IIRFilterNode { impl IIRFilterNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( _window: &Window, context: &BaseAudioContext, options: &IIRFilterOptions, @@ -68,7 +68,7 @@ impl IIRFilterNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &IIRFilterOptions, diff --git a/components/script/dom/imagebitmap.rs b/components/script/dom/imagebitmap.rs index 322c898223c..a3e85ad0477 100644 --- a/components/script/dom/imagebitmap.rs +++ b/components/script/dom/imagebitmap.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ImageBitmap { +pub(crate) struct ImageBitmap { reflector_: Reflector, width: u32, height: u32, @@ -40,18 +40,22 @@ impl ImageBitmap { } #[allow(dead_code)] - pub fn new(global: &GlobalScope, width: u32, height: u32) -> Fallible<DomRoot<ImageBitmap>> { + pub(crate) fn new( + global: &GlobalScope, + width: u32, + height: u32, + ) -> Fallible<DomRoot<ImageBitmap>> { //assigning to a variable the return object of new_inherited let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height)); Ok(reflect_dom_object(imagebitmap, global, CanGc::note())) } - pub fn set_bitmap_data(&self, data: Vec<u8>) { + pub(crate) fn set_bitmap_data(&self, data: Vec<u8>) { *self.bitmap_data.borrow_mut() = Some(data); } - pub fn set_origin_clean(&self, origin_is_clean: bool) { + pub(crate) fn set_origin_clean(&self, origin_is_clean: bool) { self.origin_clean.set(origin_is_clean); } diff --git a/components/script/dom/imagedata.rs b/components/script/dom/imagedata.rs index 4fff85d8b91..4b44cd88a93 100644 --- a/components/script/dom/imagedata.rs +++ b/components/script/dom/imagedata.rs @@ -24,7 +24,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct ImageData { +pub(crate) struct ImageData { reflector_: Reflector, width: u32, height: u32, @@ -34,7 +34,7 @@ pub struct ImageData { impl ImageData { #[allow(unsafe_code)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, width: u32, height: u32, @@ -141,22 +141,22 @@ impl ImageData { )) } #[allow(unsafe_code)] - pub fn to_shared_memory(&self) -> IpcSharedMemory { + pub(crate) fn to_shared_memory(&self) -> IpcSharedMemory { IpcSharedMemory::from_bytes(unsafe { self.as_slice() }) } #[allow(unsafe_code)] - pub unsafe fn get_rect(&self, rect: Rect<u64>) -> Cow<[u8]> { + pub(crate) unsafe fn get_rect(&self, rect: Rect<u64>) -> Cow<[u8]> { pixels::rgba8_get_rect(self.as_slice(), self.get_size().to_u64(), rect) } - pub fn get_size(&self) -> Size2D<u32> { + pub(crate) fn get_size(&self) -> Size2D<u32> { Size2D::new(self.Width(), self.Height()) } /// Nothing must change the array on the JS side while the slice is live. #[allow(unsafe_code)] - pub unsafe fn as_slice(&self) -> &[u8] { + pub(crate) unsafe fn as_slice(&self) -> &[u8] { assert!(self.data.is_initialized()); let internal_data = self .data diff --git a/components/script/dom/inputevent.rs b/components/script/dom/inputevent.rs index 1ba7a593b5c..56933c59d6d 100644 --- a/components/script/dom/inputevent.rs +++ b/components/script/dom/inputevent.rs @@ -16,7 +16,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct InputEvent { +pub(crate) struct InputEvent { uievent: UIEvent, data: Option<DOMString>, is_composing: bool, diff --git a/components/script/dom/intersectionobserver.rs b/components/script/dom/intersectionobserver.rs index fe70429d389..9077c4e1a87 100644 --- a/components/script/dom/intersectionobserver.rs +++ b/components/script/dom/intersectionobserver.rs @@ -26,7 +26,7 @@ use crate::script_runtime::{CanGc, JSContext}; /// /// <https://w3c.github.io/IntersectionObserver/#intersection-observer-interface> #[dom_struct] -pub struct IntersectionObserver { +pub(crate) struct IntersectionObserver { reflector_: Reflector, /// > This callback will be invoked when there are changes to a target’s intersection @@ -37,7 +37,7 @@ pub struct IntersectionObserver { } impl IntersectionObserver { - pub fn new_inherited( + pub(crate) fn new_inherited( callback: Rc<IntersectionObserverCallback>, _init: &IntersectionObserverInit, ) -> Self { diff --git a/components/script/dom/intersectionobserverentry.rs b/components/script/dom/intersectionobserverentry.rs index f612902a2be..3c893c8304f 100644 --- a/components/script/dom/intersectionobserverentry.rs +++ b/components/script/dom/intersectionobserverentry.rs @@ -20,13 +20,13 @@ use crate::script_runtime::CanGc; /// /// <https://w3c.github.io/IntersectionObserver/#intersection-observer-entry> #[dom_struct] -pub struct IntersectionObserverEntry { +pub(crate) struct IntersectionObserverEntry { reflector_: Reflector, target: Dom<Element>, } impl IntersectionObserverEntry { - pub fn new_inherited(init: &IntersectionObserverEntryInit) -> Self { + pub(crate) fn new_inherited(init: &IntersectionObserverEntryInit) -> Self { Self { reflector_: Reflector::new(), target: init.target.as_traced(), diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 586fa715b6a..d5ad1438568 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -23,7 +23,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct KeyboardEvent { +pub(crate) struct KeyboardEvent { uievent: UIEvent, key: DomRefCell<DOMString>, #[no_trace] @@ -54,7 +54,7 @@ impl KeyboardEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<KeyboardEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<KeyboardEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } @@ -72,7 +72,7 @@ impl KeyboardEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: bool, @@ -149,11 +149,11 @@ impl KeyboardEvent { ev } - pub fn key(&self) -> Key { + pub(crate) fn key(&self) -> Key { self.typed_key.borrow().clone() } - pub fn modifiers(&self) -> Modifiers { + pub(crate) fn modifiers(&self) -> Modifiers { self.modifiers.get() } } diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index d8e5d823e3c..e3e310c8f8e 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[derive(PartialEq)] -pub enum NavigationType { +pub(crate) enum NavigationType { /// The "[`Location`-object navigate][1]" steps. /// /// [1]: https://html.spec.whatwg.org/multipage/#location-object-navigate @@ -44,7 +44,7 @@ pub enum NavigationType { } #[dom_struct] -pub struct Location { +pub(crate) struct Location { reflector_: Reflector, window: Dom<Window>, } @@ -57,7 +57,7 @@ impl Location { } } - pub fn new(window: &Window) -> DomRoot<Location> { + pub(crate) fn new(window: &Window) -> DomRoot<Location> { reflect_dom_object( Box::new(Location::new_inherited(window)), window, @@ -66,7 +66,7 @@ impl Location { } /// Navigate the relevant `Document`'s browsing context. - pub fn navigate( + pub(crate) fn navigate( &self, url: ServoUrl, history_handling: NavigationHistoryBehavior, @@ -246,7 +246,7 @@ impl Location { /// [`reload()`][1]). /// /// [1]: https://html.spec.whatwg.org/multipage/#dom-location-reload - pub fn reload_without_origin_check(&self, can_gc: CanGc) { + pub(crate) fn reload_without_origin_check(&self, can_gc: CanGc) { // > When a user requests that the active document of a browsing context // > be reloaded through a user interface element, the user agent should // > navigate the browsing context to the same resource as that @@ -261,7 +261,7 @@ impl Location { } #[allow(dead_code)] - pub fn origin(&self) -> &MutableOrigin { + pub(crate) fn origin(&self) -> &MutableOrigin { self.window.origin() } } diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 24589db02fb..7fc18260890 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -667,7 +667,7 @@ macro_rules! impl_performance_entry_struct( use dom_struct::dom_struct; #[dom_struct] - pub struct $struct { + pub(crate) struct $struct { entry: PerformanceEntry, } @@ -683,7 +683,7 @@ macro_rules! impl_performance_entry_struct( } #[allow(crown::unrooted_must_root)] - pub fn new(global: &GlobalScope, + pub(crate) fn new(global: &GlobalScope, name: DOMString, start_time: CrossProcessInstant, duration: Duration) -> DomRoot<$struct> { diff --git a/components/script/dom/mediadeviceinfo.rs b/components/script/dom/mediadeviceinfo.rs index a7261229987..a9d6469bdcc 100644 --- a/components/script/dom/mediadeviceinfo.rs +++ b/components/script/dom/mediadeviceinfo.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaDeviceInfo { +pub(crate) struct MediaDeviceInfo { reflector_: Reflector, device_id: DOMString, kind: MediaDeviceKind, @@ -40,7 +40,7 @@ impl MediaDeviceInfo { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, device_id: &str, kind: MediaDeviceKind, diff --git a/components/script/dom/mediadevices.rs b/components/script/dom/mediadevices.rs index fd24ed57bbd..2d347dd8611 100644 --- a/components/script/dom/mediadevices.rs +++ b/components/script/dom/mediadevices.rs @@ -29,18 +29,18 @@ use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaDevices { +pub(crate) struct MediaDevices { eventtarget: EventTarget, } impl MediaDevices { - pub fn new_inherited() -> MediaDevices { + pub(crate) fn new_inherited() -> MediaDevices { MediaDevices { eventtarget: EventTarget::new_inherited(), } } - pub fn new(global: &GlobalScope) -> DomRoot<MediaDevices> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<MediaDevices> { reflect_dom_object( Box::new(MediaDevices::new_inherited()), global, diff --git a/components/script/dom/mediaelementaudiosourcenode.rs b/components/script/dom/mediaelementaudiosourcenode.rs index f0d1de62a0f..d56ba30422b 100644 --- a/components/script/dom/mediaelementaudiosourcenode.rs +++ b/components/script/dom/mediaelementaudiosourcenode.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaElementAudioSourceNode { +pub(crate) struct MediaElementAudioSourceNode { node: AudioNode, media_element: Dom<HTMLMediaElement>, } @@ -54,7 +54,7 @@ impl MediaElementAudioSourceNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &AudioContext, media_element: &HTMLMediaElement, diff --git a/components/script/dom/mediaerror.rs b/components/script/dom/mediaerror.rs index 9202634e4d9..78550390ee2 100644 --- a/components/script/dom/mediaerror.rs +++ b/components/script/dom/mediaerror.rs @@ -12,7 +12,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaError { +pub(crate) struct MediaError { reflector_: Reflector, code: u16, } @@ -25,7 +25,7 @@ impl MediaError { } } - pub fn new(window: &Window, code: u16) -> DomRoot<MediaError> { + pub(crate) fn new(window: &Window, code: u16) -> DomRoot<MediaError> { reflect_dom_object( Box::new(MediaError::new_inherited(code)), window, diff --git a/components/script/dom/mediafragmentparser.rs b/components/script/dom/mediafragmentparser.rs index 0dc949b6eef..342ee894a0a 100644 --- a/components/script/dom/mediafragmentparser.rs +++ b/components/script/dom/mediafragmentparser.rs @@ -11,7 +11,7 @@ use servo_url::ServoUrl; use url::{form_urlencoded, Position, Url}; #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum SpatialRegion { +pub(crate) enum SpatialRegion { Pixel, Percent, } @@ -29,7 +29,7 @@ impl FromStr for SpatialRegion { } #[derive(Clone, Debug, Eq, PartialEq)] -pub struct SpatialClipping { +pub(crate) struct SpatialClipping { region: Option<SpatialRegion>, x: u32, y: u32, @@ -38,7 +38,7 @@ pub struct SpatialClipping { } #[derive(Clone, Debug, Default, PartialEq)] -pub struct MediaFragmentParser { +pub(crate) struct MediaFragmentParser { id: Option<String>, tracks: Vec<String>, spatial: Option<SpatialClipping>, @@ -47,20 +47,20 @@ pub struct MediaFragmentParser { } impl MediaFragmentParser { - pub fn id(&self) -> Option<String> { + pub(crate) fn id(&self) -> Option<String> { self.id.clone() } - pub fn tracks(&self) -> &Vec<String> { + pub(crate) fn tracks(&self) -> &Vec<String> { self.tracks.as_ref() } - pub fn start(&self) -> Option<f64> { + pub(crate) fn start(&self) -> Option<f64> { self.start } // Parse an str of key value pairs, a URL, or a fragment. - pub fn parse(input: &str) -> MediaFragmentParser { + pub(crate) fn parse(input: &str) -> MediaFragmentParser { let mut parser = MediaFragmentParser::default(); let (query, fragment) = split_url(input); let mut octets = decode_octets(query.as_bytes()); diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index 244b06c7cb5..d28e15d643b 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaList { +pub(crate) struct MediaList { reflector_: Reflector, parent_stylesheet: Dom<CSSStyleSheet>, #[ignore_malloc_size_of = "Arc"] @@ -31,7 +31,7 @@ pub struct MediaList { impl MediaList { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, media_queries: Arc<Locked<StyleMediaList>>, ) -> MediaList { @@ -43,7 +43,7 @@ impl MediaList { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, media_queries: Arc<Locked<StyleMediaList>>, diff --git a/components/script/dom/mediametadata.rs b/components/script/dom/mediametadata.rs index 083c6475ca3..17ce05e8ee5 100644 --- a/components/script/dom/mediametadata.rs +++ b/components/script/dom/mediametadata.rs @@ -18,7 +18,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaMetadata { +pub(crate) struct MediaMetadata { reflector_: Reflector, session: MutNullableDom<MediaSession>, title: DomRefCell<DOMString>, @@ -37,7 +37,11 @@ impl MediaMetadata { } } - pub fn new(global: &Window, init: &MediaMetadataInit, can_gc: CanGc) -> DomRoot<MediaMetadata> { + pub(crate) fn new( + global: &Window, + init: &MediaMetadataInit, + can_gc: CanGc, + ) -> DomRoot<MediaMetadata> { Self::new_with_proto(global, None, init, can_gc) } @@ -59,7 +63,7 @@ impl MediaMetadata { if self.session.get().is_none() {} } - pub fn set_session(&self, session: &MediaSession) { + pub(crate) fn set_session(&self, session: &MediaSession) { self.session.set(Some(session)); } } diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index aa019c4a178..89e6f3c3ee8 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -22,13 +22,13 @@ use crate::dom::document::Document; use crate::dom::eventtarget::EventTarget; use crate::script_runtime::CanGc; -pub enum MediaQueryListMatchState { +pub(crate) enum MediaQueryListMatchState { Same, Changed, } #[dom_struct] -pub struct MediaQueryList { +pub(crate) struct MediaQueryList { eventtarget: EventTarget, document: Dom<Document>, #[no_trace] @@ -46,7 +46,7 @@ impl MediaQueryList { } } - pub fn new(document: &Document, media_query_list: MediaList) -> DomRoot<MediaQueryList> { + pub(crate) fn new(document: &Document, media_query_list: MediaList) -> DomRoot<MediaQueryList> { reflect_dom_object( Box::new(MediaQueryList::new_inherited(document, media_query_list)), document.window(), @@ -56,7 +56,7 @@ impl MediaQueryList { } impl MediaQueryList { - pub fn evaluate_changes(&self) -> MediaQueryListMatchState { + pub(crate) fn evaluate_changes(&self) -> MediaQueryListMatchState { let matches = self.evaluate(); let result = if let Some(old_matches) = self.last_match_state.get() { @@ -73,7 +73,7 @@ impl MediaQueryList { result } - pub fn evaluate(&self) -> bool { + pub(crate) fn evaluate(&self) -> bool { let quirks_mode = self.document.quirks_mode(); self.media_query_list .evaluate(self.document.window().layout().device(), quirks_mode) diff --git a/components/script/dom/mediaquerylistevent.rs b/components/script/dom/mediaquerylistevent.rs index 1de38417b1b..f36f192dcbb 100644 --- a/components/script/dom/mediaquerylistevent.rs +++ b/components/script/dom/mediaquerylistevent.rs @@ -24,7 +24,7 @@ use crate::script_runtime::CanGc; // https://drafts.csswg.org/cssom-view/#dom-mediaquerylistevent-mediaquerylistevent #[dom_struct] -pub struct MediaQueryListEvent { +pub(crate) struct MediaQueryListEvent { event: Event, media: DOMString, matches: Cell<bool>, @@ -46,7 +46,7 @@ impl MediaQueryListEvent { reflect_dom_object_with_proto(ev, global, proto, can_gc) } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs index 96d121904c4..679188f02c3 100644 --- a/components/script/dom/mediasession.rs +++ b/components/script/dom/mediasession.rs @@ -32,7 +32,7 @@ use crate::realms::{enter_realm, InRealm}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaSession { +pub(crate) struct MediaSession { reflector_: Reflector, /// <https://w3c.github.io/mediasession/#dom-mediasession-metadata> #[ignore_malloc_size_of = "defined in embedder_traits"] @@ -61,7 +61,7 @@ impl MediaSession { } } - pub fn new(window: &Window) -> DomRoot<MediaSession> { + pub(crate) fn new(window: &Window) -> DomRoot<MediaSession> { reflect_dom_object( Box::new(MediaSession::new_inherited()), window, @@ -69,11 +69,11 @@ impl MediaSession { ) } - pub fn register_media_instance(&self, media_instance: &HTMLMediaElement) { + pub(crate) fn register_media_instance(&self, media_instance: &HTMLMediaElement) { self.media_instance.set(Some(media_instance)); } - pub fn handle_action(&self, action: MediaSessionActionType, can_gc: CanGc) { + pub(crate) fn handle_action(&self, action: MediaSessionActionType, can_gc: CanGc) { debug!("Handle media session action {:?}", action); if let Some(handler) = self.action_handlers.borrow().get(&action) { @@ -104,14 +104,14 @@ impl MediaSession { } } - pub fn send_event(&self, event: MediaSessionEvent) { + pub(crate) fn send_event(&self, event: MediaSessionEvent) { let global = self.global(); let window = global.as_window(); let pipeline_id = window.pipeline_id(); window.send_to_constellation(ScriptMsg::MediaSessionEvent(pipeline_id, event)); } - pub fn update_title(&self, title: String) { + pub(crate) fn update_title(&self, title: String) { let mut metadata = self.metadata.borrow_mut(); if let Some(ref mut metadata) = *metadata { // We only update the title with the data provided by the media diff --git a/components/script/dom/mediastream.rs b/components/script/dom/mediastream.rs index 82ae137716a..e56e1a63a20 100644 --- a/components/script/dom/mediastream.rs +++ b/components/script/dom/mediastream.rs @@ -20,20 +20,20 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaStream { +pub(crate) struct MediaStream { eventtarget: EventTarget, tracks: DomRefCell<Vec<Dom<MediaStreamTrack>>>, } impl MediaStream { - pub fn new_inherited() -> MediaStream { + pub(crate) fn new_inherited() -> MediaStream { MediaStream { eventtarget: EventTarget::new_inherited(), tracks: DomRefCell::new(vec![]), } } - pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<MediaStream> { + pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<MediaStream> { Self::new_with_proto(global, None, can_gc) } @@ -50,7 +50,7 @@ impl MediaStream { ) } - pub fn new_single( + pub(crate) fn new_single( global: &GlobalScope, id: MediaStreamId, ty: MediaStreamType, @@ -62,11 +62,11 @@ impl MediaStream { this } - pub fn get_tracks(&self) -> Ref<[Dom<MediaStreamTrack>]> { + pub(crate) fn get_tracks(&self) -> Ref<[Dom<MediaStreamTrack>]> { Ref::map(self.tracks.borrow(), |tracks| &**tracks) } - pub fn add_track(&self, track: &MediaStreamTrack) { + pub(crate) fn add_track(&self, track: &MediaStreamTrack) { self.tracks.borrow_mut().push(Dom::from_ref(track)) } } diff --git a/components/script/dom/mediastreamaudiodestinationnode.rs b/components/script/dom/mediastreamaudiodestinationnode.rs index 068ed364870..9465fbd0c4c 100644 --- a/components/script/dom/mediastreamaudiodestinationnode.rs +++ b/components/script/dom/mediastreamaudiodestinationnode.rs @@ -23,14 +23,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaStreamAudioDestinationNode { +pub(crate) struct MediaStreamAudioDestinationNode { node: AudioNode, stream: Dom<MediaStream>, } impl MediaStreamAudioDestinationNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( context: &AudioContext, options: &AudioNodeOptions, can_gc: CanGc, @@ -56,7 +56,7 @@ impl MediaStreamAudioDestinationNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &AudioContext, options: &AudioNodeOptions, diff --git a/components/script/dom/mediastreamaudiosourcenode.rs b/components/script/dom/mediastreamaudiosourcenode.rs index 59aa6625903..f3eb95f7a5d 100644 --- a/components/script/dom/mediastreamaudiosourcenode.rs +++ b/components/script/dom/mediastreamaudiosourcenode.rs @@ -21,14 +21,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaStreamAudioSourceNode { +pub(crate) struct MediaStreamAudioSourceNode { node: AudioNode, stream: Dom<MediaStream>, } impl MediaStreamAudioSourceNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( context: &AudioContext, stream: &MediaStream, ) -> Fallible<MediaStreamAudioSourceNode> { @@ -51,7 +51,7 @@ impl MediaStreamAudioSourceNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &AudioContext, stream: &MediaStream, diff --git a/components/script/dom/mediastreamtrack.rs b/components/script/dom/mediastreamtrack.rs index 523d9d12f99..f60abe932c1 100644 --- a/components/script/dom/mediastreamtrack.rs +++ b/components/script/dom/mediastreamtrack.rs @@ -15,7 +15,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaStreamTrack { +pub(crate) struct MediaStreamTrack { eventtarget: EventTarget, #[ignore_malloc_size_of = "defined in servo-media"] #[no_trace] @@ -26,7 +26,7 @@ pub struct MediaStreamTrack { } impl MediaStreamTrack { - pub fn new_inherited(id: MediaStreamId, ty: MediaStreamType) -> MediaStreamTrack { + pub(crate) fn new_inherited(id: MediaStreamId, ty: MediaStreamType) -> MediaStreamTrack { MediaStreamTrack { eventtarget: EventTarget::new_inherited(), id, @@ -34,7 +34,7 @@ impl MediaStreamTrack { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, id: MediaStreamId, ty: MediaStreamType, @@ -46,11 +46,11 @@ impl MediaStreamTrack { ) } - pub fn id(&self) -> MediaStreamId { + pub(crate) fn id(&self) -> MediaStreamId { self.id } - pub fn ty(&self) -> MediaStreamType { + pub(crate) fn ty(&self) -> MediaStreamType { self.ty } } diff --git a/components/script/dom/mediastreamtrackaudiosourcenode.rs b/components/script/dom/mediastreamtrackaudiosourcenode.rs index 39996f6ec12..cb58f58ee66 100644 --- a/components/script/dom/mediastreamtrackaudiosourcenode.rs +++ b/components/script/dom/mediastreamtrackaudiosourcenode.rs @@ -20,14 +20,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MediaStreamTrackAudioSourceNode { +pub(crate) struct MediaStreamTrackAudioSourceNode { node: AudioNode, track: Dom<MediaStreamTrack>, } impl MediaStreamTrackAudioSourceNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( context: &AudioContext, track: &MediaStreamTrack, ) -> Fallible<MediaStreamTrackAudioSourceNode> { @@ -44,7 +44,7 @@ impl MediaStreamTrackAudioSourceNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &AudioContext, track: &MediaStreamTrack, diff --git a/components/script/dom/messagechannel.rs b/components/script/dom/messagechannel.rs index 87149c951cb..b15f70b988d 100644 --- a/components/script/dom/messagechannel.rs +++ b/components/script/dom/messagechannel.rs @@ -13,7 +13,7 @@ use crate::dom::messageport::MessagePort; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MessageChannel { +pub(crate) struct MessageChannel { reflector_: Reflector, port1: Dom<MessagePort>, port2: Dom<MessagePort>, @@ -47,7 +47,7 @@ impl MessageChannel { ) } - pub fn new_inherited(port1: &MessagePort, port2: &MessagePort) -> MessageChannel { + pub(crate) fn new_inherited(port1: &MessagePort, port2: &MessagePort) -> MessageChannel { MessageChannel { reflector_: Reflector::new(), port1: Dom::from_ref(port1), diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index c868f1c5b93..c6dc0f3abd2 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -55,7 +55,7 @@ impl From<&WindowProxyOrMessagePortOrServiceWorker> for SrcObject { #[dom_struct] #[allow(non_snake_case)] -pub struct MessageEvent { +pub(crate) struct MessageEvent { event: Event, #[ignore_malloc_size_of = "mozjs"] data: Heap<JSVal>, @@ -69,7 +69,7 @@ pub struct MessageEvent { #[allow(non_snake_case)] impl MessageEvent { - pub fn new_inherited( + pub(crate) fn new_inherited( origin: DOMString, source: Option<&WindowProxyOrMessagePortOrServiceWorker>, lastEventId: DOMString, @@ -91,7 +91,7 @@ impl MessageEvent { } } - pub fn new_uninitialized(global: &GlobalScope, can_gc: CanGc) -> DomRoot<MessageEvent> { + pub(crate) fn new_uninitialized(global: &GlobalScope, can_gc: CanGc) -> DomRoot<MessageEvent> { Self::new_uninitialized_with_proto(global, None, can_gc) } @@ -136,7 +136,7 @@ impl MessageEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, @@ -194,7 +194,7 @@ impl MessageEvent { ev } - pub fn dispatch_jsval( + pub(crate) fn dispatch_jsval( target: &EventTarget, scope: &GlobalScope, message: HandleValue, @@ -222,7 +222,7 @@ impl MessageEvent { messageevent.upcast::<Event>().fire(target, can_gc); } - pub fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) { + pub(crate) fn dispatch_error(target: &EventTarget, scope: &GlobalScope, can_gc: CanGc) { let init = MessageEventBinding::MessageEventInit::empty(); let messageevent = MessageEvent::new( scope, diff --git a/components/script/dom/messageport.rs b/components/script/dom/messageport.rs index 69a2b4a519f..846169c30b2 100644 --- a/components/script/dom/messageport.rs +++ b/components/script/dom/messageport.rs @@ -32,7 +32,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; #[dom_struct] /// The MessagePort used in the DOM. -pub struct MessagePort { +pub(crate) struct MessagePort { eventtarget: EventTarget, #[no_trace] message_port_id: MessagePortId, @@ -52,7 +52,7 @@ impl MessagePort { } /// <https://html.spec.whatwg.org/multipage/#create-a-new-messageport-object> - pub fn new(owner: &GlobalScope) -> DomRoot<MessagePort> { + pub(crate) fn new(owner: &GlobalScope) -> DomRoot<MessagePort> { let port_id = MessagePortId::new(); reflect_dom_object( Box::new(MessagePort::new_inherited(port_id)), @@ -80,15 +80,15 @@ impl MessagePort { } /// <https://html.spec.whatwg.org/multipage/#entangle> - pub fn entangle(&self, other_id: MessagePortId) { + pub(crate) fn entangle(&self, other_id: MessagePortId) { *self.entangled_port.borrow_mut() = Some(other_id); } - pub fn message_port_id(&self) -> &MessagePortId { + pub(crate) fn message_port_id(&self) -> &MessagePortId { &self.message_port_id } - pub fn detached(&self) -> bool { + pub(crate) fn detached(&self) -> bool { self.detached.get() } diff --git a/components/script/dom/mimetype.rs b/components/script/dom/mimetype.rs index 2c15982a9bf..a016ca9fb8c 100644 --- a/components/script/dom/mimetype.rs +++ b/components/script/dom/mimetype.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::str::DOMString; use crate::dom::plugin::Plugin; #[dom_struct] -pub struct MimeType { +pub(crate) struct MimeType { reflector_: Reflector, } diff --git a/components/script/dom/mimetypearray.rs b/components/script/dom/mimetypearray.rs index 52eb77d3a72..78aa6323138 100644 --- a/components/script/dom/mimetypearray.rs +++ b/components/script/dom/mimetypearray.rs @@ -13,18 +13,18 @@ use crate::dom::mimetype::MimeType; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MimeTypeArray { +pub(crate) struct MimeTypeArray { reflector_: Reflector, } impl MimeTypeArray { - pub fn new_inherited() -> MimeTypeArray { + pub(crate) fn new_inherited() -> MimeTypeArray { MimeTypeArray { reflector_: Reflector::new(), } } - pub fn new(global: &GlobalScope) -> DomRoot<MimeTypeArray> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<MimeTypeArray> { reflect_dom_object( Box::new(MimeTypeArray::new_inherited()), global, diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index 8fe9647d3e9..8f51e796320 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -203,416 +203,438 @@ //! `LayoutFooHelpers` traits. #[macro_use] -pub mod macros; +pub(crate) mod macros; -pub mod types { +pub(crate) mod types { include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs")); } -pub mod abortcontroller; -pub mod abstractrange; -pub mod abstractworker; -pub mod abstractworkerglobalscope; -pub mod activation; -pub mod analysernode; -pub mod animationevent; -pub mod attr; -pub mod audiobuffer; -pub mod audiobuffersourcenode; -pub mod audiocontext; -pub mod audiodestinationnode; -pub mod audiolistener; -pub mod audionode; -pub mod audioparam; -pub mod audioscheduledsourcenode; -pub mod audiotrack; -pub mod audiotracklist; -pub mod baseaudiocontext; -pub mod beforeunloadevent; -pub mod bindings; -pub mod biquadfilternode; -pub mod blob; -pub mod bluetooth; -pub mod bluetoothadvertisingevent; -pub mod bluetoothcharacteristicproperties; -pub mod bluetoothdevice; -pub mod bluetoothpermissionresult; -pub mod bluetoothremotegattcharacteristic; -pub mod bluetoothremotegattdescriptor; -pub mod bluetoothremotegattserver; -pub mod bluetoothremotegattservice; -pub mod bluetoothuuid; -pub mod broadcastchannel; -pub mod bytelengthqueuingstrategy; -pub mod canvasgradient; -pub mod canvaspattern; -pub mod canvasrenderingcontext2d; -pub mod cdatasection; -pub mod channelmergernode; -pub mod channelsplitternode; -pub mod characterdata; -pub mod client; -pub mod closeevent; -pub mod comment; -pub mod compositionevent; -pub mod console; -pub mod constantsourcenode; -pub mod countqueuingstrategy; +pub(crate) mod abortcontroller; +#[allow(dead_code)] +pub(crate) mod abstractrange; +pub(crate) mod abstractworker; +pub(crate) mod abstractworkerglobalscope; +pub(crate) mod activation; +pub(crate) mod analysernode; +pub(crate) mod animationevent; +pub(crate) mod attr; +pub(crate) mod audiobuffer; +pub(crate) mod audiobuffersourcenode; +pub(crate) mod audiocontext; +pub(crate) mod audiodestinationnode; +pub(crate) mod audiolistener; +pub(crate) mod audionode; +pub(crate) mod audioparam; +pub(crate) mod audioscheduledsourcenode; +pub(crate) mod audiotrack; +pub(crate) mod audiotracklist; +pub(crate) mod baseaudiocontext; +pub(crate) mod beforeunloadevent; +pub(crate) mod bindings; +pub(crate) mod biquadfilternode; +pub(crate) mod blob; +pub(crate) mod bluetooth; +pub(crate) mod bluetoothadvertisingevent; +pub(crate) mod bluetoothcharacteristicproperties; +pub(crate) mod bluetoothdevice; +pub(crate) mod bluetoothpermissionresult; +pub(crate) mod bluetoothremotegattcharacteristic; +pub(crate) mod bluetoothremotegattdescriptor; +pub(crate) mod bluetoothremotegattserver; +pub(crate) mod bluetoothremotegattservice; +pub(crate) mod bluetoothuuid; +pub(crate) mod broadcastchannel; +pub(crate) mod bytelengthqueuingstrategy; +pub(crate) mod canvasgradient; +pub(crate) mod canvaspattern; +#[allow(dead_code)] +pub(crate) mod canvasrenderingcontext2d; +pub(crate) mod cdatasection; +pub(crate) mod channelmergernode; +pub(crate) mod channelsplitternode; +pub(crate) mod characterdata; +pub(crate) mod client; +pub(crate) mod closeevent; +pub(crate) mod comment; +pub(crate) mod compositionevent; +pub(crate) mod console; +pub(crate) mod constantsourcenode; +pub(crate) mod countqueuingstrategy; mod create; -pub mod crypto; -pub mod cryptokey; -pub mod css; -pub mod cssconditionrule; -pub mod cssfontfacerule; -pub mod cssgroupingrule; -pub mod cssimportrule; -pub mod csskeyframerule; -pub mod csskeyframesrule; -pub mod csslayerblockrule; -pub mod csslayerstatementrule; -pub mod cssmediarule; -pub mod cssnamespacerule; -pub mod cssrule; -pub mod cssrulelist; -pub mod cssstyledeclaration; -pub mod cssstylerule; -pub mod cssstylesheet; -pub mod cssstylevalue; -pub mod csssupportsrule; -pub mod customelementregistry; -pub mod customevent; -pub mod datatransfer; -pub mod datatransferitem; -pub mod datatransferitemlist; -pub mod dedicatedworkerglobalscope; -pub mod defaultteereadrequest; -pub mod defaultteeunderlyingsource; -pub mod dissimilaroriginlocation; -pub mod dissimilaroriginwindow; -pub mod document; -pub mod documentfragment; -pub mod documentorshadowroot; -pub mod documenttype; -pub mod domexception; -pub mod domimplementation; -pub mod dommatrix; -pub mod dommatrixreadonly; -pub mod domparser; -pub mod dompoint; -pub mod dompointreadonly; -pub mod domquad; -pub mod domrect; -pub mod domrectlist; -pub mod domrectreadonly; -pub mod domstringlist; -pub mod domstringmap; -pub mod domtokenlist; -pub mod dynamicmoduleowner; -pub mod element; -pub mod elementinternals; -pub mod errorevent; -pub mod event; -pub mod eventsource; -pub mod eventtarget; -pub mod extendableevent; -pub mod extendablemessageevent; -pub mod file; -pub mod filelist; -pub mod filereader; -pub mod filereadersync; -pub mod focusevent; -pub mod fontfaceset; -pub mod formdata; -pub mod formdataevent; -pub mod gainnode; -pub mod gamepad; -pub mod gamepadbutton; -pub mod gamepadbuttonlist; -pub mod gamepadevent; -pub mod gamepadhapticactuator; -pub mod gamepadpose; -pub mod globalscope; -pub mod hashchangeevent; -pub mod headers; -pub mod history; -pub mod htmlanchorelement; -pub mod htmlareaelement; -pub mod htmlaudioelement; -pub mod htmlbaseelement; -pub mod htmlbodyelement; -pub mod htmlbrelement; -pub mod htmlbuttonelement; -pub mod htmlcanvaselement; -pub mod htmlcollection; -pub mod htmldataelement; -pub mod htmldatalistelement; -pub mod htmldetailselement; -pub mod htmldialogelement; -pub mod htmldirectoryelement; -pub mod htmldivelement; -pub mod htmldlistelement; -pub mod htmlelement; -pub mod htmlembedelement; -pub mod htmlfieldsetelement; -pub mod htmlfontelement; -pub mod htmlformcontrolscollection; -pub mod htmlformelement; -pub mod htmlframeelement; -pub mod htmlframesetelement; -pub mod htmlheadelement; -pub mod htmlheadingelement; -pub mod htmlhrelement; -pub mod htmlhtmlelement; -pub mod htmliframeelement; -pub mod htmlimageelement; -pub mod htmlinputelement; -pub mod htmllabelelement; -pub mod htmllegendelement; -pub mod htmllielement; -pub mod htmllinkelement; -pub mod htmlmapelement; -pub mod htmlmediaelement; -pub mod htmlmenuelement; -pub mod htmlmetaelement; -pub mod htmlmeterelement; -pub mod htmlmodelement; -pub mod htmlobjectelement; -pub mod htmlolistelement; -pub mod htmloptgroupelement; -pub mod htmloptionelement; -pub mod htmloptionscollection; -pub mod htmloutputelement; -pub mod htmlparagraphelement; -pub mod htmlparamelement; -pub mod htmlpictureelement; -pub mod htmlpreelement; -pub mod htmlprogresselement; -pub mod htmlquoteelement; -pub mod htmlscriptelement; -pub mod htmlselectelement; -pub mod htmlsourceelement; -pub mod htmlspanelement; -pub mod htmlstyleelement; -pub mod htmltablecaptionelement; -pub mod htmltablecellelement; -pub mod htmltablecolelement; -pub mod htmltableelement; -pub mod htmltablerowelement; -pub mod htmltablesectionelement; -pub mod htmltemplateelement; -pub mod htmltextareaelement; -pub mod htmltimeelement; -pub mod htmltitleelement; -pub mod htmltrackelement; -pub mod htmlulistelement; -pub mod htmlunknownelement; -pub mod htmlvideoelement; -pub mod iirfilternode; -pub mod imagebitmap; -pub mod imagedata; -pub mod inputevent; -pub mod intersectionobserver; -pub mod intersectionobserverentry; -pub mod keyboardevent; -pub mod location; -pub mod mediadeviceinfo; -pub mod mediadevices; -pub mod mediaelementaudiosourcenode; -pub mod mediaerror; -pub mod mediafragmentparser; -pub mod medialist; -pub mod mediametadata; -pub mod mediaquerylist; -pub mod mediaquerylistevent; -pub mod mediasession; -pub mod mediastream; -pub mod mediastreamaudiodestinationnode; -pub mod mediastreamaudiosourcenode; -pub mod mediastreamtrack; -pub mod mediastreamtrackaudiosourcenode; -pub mod messagechannel; -pub mod messageevent; -pub mod messageport; -pub mod mimetype; -pub mod mimetypearray; -pub mod mouseevent; -pub mod mutationobserver; -pub mod mutationrecord; -pub mod namednodemap; -pub mod navigationpreloadmanager; -pub mod navigator; -pub mod navigatorinfo; -pub mod node; -pub mod nodeiterator; -pub mod nodelist; -pub mod offlineaudiocompletionevent; -pub mod offlineaudiocontext; -pub mod offscreencanvas; -pub mod offscreencanvasrenderingcontext2d; -pub mod oscillatornode; -pub mod pagetransitionevent; -pub mod paintrenderingcontext2d; -pub mod paintsize; -pub mod paintworkletglobalscope; -pub mod pannernode; -pub mod performance; -pub mod performanceentry; -pub mod performancemark; -pub mod performancemeasure; -pub mod performancenavigation; -pub mod performancenavigationtiming; -pub mod performanceobserver; -pub mod performanceobserverentrylist; -pub mod performancepainttiming; -pub mod performanceresourcetiming; -pub mod permissions; -pub mod permissionstatus; -pub mod plugin; -pub mod pluginarray; -pub mod pointerevent; -pub mod popstateevent; -pub mod processinginstruction; -pub mod progressevent; -pub mod promise; -pub mod promisenativehandler; -pub mod promiserejectionevent; -pub mod radionodelist; -pub mod range; -pub mod raredata; -pub mod readablebytestreamcontroller; -pub mod readablestream; -pub mod readablestreambyobreader; -pub mod readablestreambyobrequest; -pub mod readablestreamdefaultcontroller; -pub mod readablestreamdefaultreader; -pub mod request; -pub mod resizeobserver; -pub mod resizeobserverentry; -pub mod resizeobserversize; -pub mod response; -pub mod rtcdatachannel; -pub mod rtcdatachannelevent; -pub mod rtcerror; -pub mod rtcerrorevent; -pub mod rtcicecandidate; -pub mod rtcpeerconnection; -pub mod rtcpeerconnectioniceevent; +pub(crate) mod crypto; +pub(crate) mod cryptokey; +pub(crate) mod css; +pub(crate) mod cssconditionrule; +pub(crate) mod cssfontfacerule; +pub(crate) mod cssgroupingrule; +pub(crate) mod cssimportrule; +pub(crate) mod csskeyframerule; +pub(crate) mod csskeyframesrule; +pub(crate) mod csslayerblockrule; +pub(crate) mod csslayerstatementrule; +pub(crate) mod cssmediarule; +pub(crate) mod cssnamespacerule; +pub(crate) mod cssrule; +pub(crate) mod cssrulelist; +pub(crate) mod cssstyledeclaration; +pub(crate) mod cssstylerule; +pub(crate) mod cssstylesheet; +pub(crate) mod cssstylevalue; +pub(crate) mod csssupportsrule; +pub(crate) mod customelementregistry; +pub(crate) mod customevent; +pub(crate) mod datatransfer; +pub(crate) mod datatransferitem; +pub(crate) mod datatransferitemlist; +pub(crate) mod dedicatedworkerglobalscope; +pub(crate) mod defaultteereadrequest; +pub(crate) mod defaultteeunderlyingsource; +pub(crate) mod dissimilaroriginlocation; +pub(crate) mod dissimilaroriginwindow; +#[allow(dead_code)] +pub(crate) mod document; +pub(crate) mod documentfragment; +pub(crate) mod documentorshadowroot; +pub(crate) mod documenttype; +pub(crate) mod domexception; +pub(crate) mod domimplementation; +pub(crate) mod dommatrix; +pub(crate) mod dommatrixreadonly; +pub(crate) mod domparser; +pub(crate) mod dompoint; +pub(crate) mod dompointreadonly; +pub(crate) mod domquad; +pub(crate) mod domrect; +pub(crate) mod domrectlist; +pub(crate) mod domrectreadonly; +pub(crate) mod domstringlist; +pub(crate) mod domstringmap; +pub(crate) mod domtokenlist; +pub(crate) mod dynamicmoduleowner; +#[allow(dead_code)] +pub(crate) mod element; +pub(crate) mod elementinternals; +pub(crate) mod errorevent; +pub(crate) mod event; +pub(crate) mod eventsource; +pub(crate) mod eventtarget; +pub(crate) mod extendableevent; +pub(crate) mod extendablemessageevent; +pub(crate) mod file; +pub(crate) mod filelist; +pub(crate) mod filereader; +pub(crate) mod filereadersync; +pub(crate) mod focusevent; +pub(crate) mod fontfaceset; +pub(crate) mod formdata; +pub(crate) mod formdataevent; +pub(crate) mod gainnode; +pub(crate) mod gamepad; +pub(crate) mod gamepadbutton; +pub(crate) mod gamepadbuttonlist; +pub(crate) mod gamepadevent; +pub(crate) mod gamepadhapticactuator; +pub(crate) mod gamepadpose; +#[allow(dead_code)] +pub(crate) mod globalscope; +pub(crate) mod hashchangeevent; +pub(crate) mod headers; +pub(crate) mod history; +pub(crate) mod htmlanchorelement; +pub(crate) mod htmlareaelement; +pub(crate) mod htmlaudioelement; +pub(crate) mod htmlbaseelement; +pub(crate) mod htmlbodyelement; +pub(crate) mod htmlbrelement; +pub(crate) mod htmlbuttonelement; +#[allow(dead_code)] +pub(crate) mod htmlcanvaselement; +pub(crate) mod htmlcollection; +pub(crate) mod htmldataelement; +pub(crate) mod htmldatalistelement; +pub(crate) mod htmldetailselement; +pub(crate) mod htmldialogelement; +pub(crate) mod htmldirectoryelement; +pub(crate) mod htmldivelement; +pub(crate) mod htmldlistelement; +pub(crate) mod htmlelement; +pub(crate) mod htmlembedelement; +pub(crate) mod htmlfieldsetelement; +pub(crate) mod htmlfontelement; +pub(crate) mod htmlformcontrolscollection; +pub(crate) mod htmlformelement; +pub(crate) mod htmlframeelement; +pub(crate) mod htmlframesetelement; +pub(crate) mod htmlheadelement; +pub(crate) mod htmlheadingelement; +pub(crate) mod htmlhrelement; +pub(crate) mod htmlhtmlelement; +pub(crate) mod htmliframeelement; +pub(crate) mod htmlimageelement; +pub(crate) mod htmlinputelement; +pub(crate) mod htmllabelelement; +pub(crate) mod htmllegendelement; +pub(crate) mod htmllielement; +pub(crate) mod htmllinkelement; +pub(crate) mod htmlmapelement; +pub(crate) mod htmlmediaelement; +pub(crate) mod htmlmenuelement; +pub(crate) mod htmlmetaelement; +pub(crate) mod htmlmeterelement; +pub(crate) mod htmlmodelement; +pub(crate) mod htmlobjectelement; +pub(crate) mod htmlolistelement; +pub(crate) mod htmloptgroupelement; +pub(crate) mod htmloptionelement; +pub(crate) mod htmloptionscollection; +pub(crate) mod htmloutputelement; +pub(crate) mod htmlparagraphelement; +pub(crate) mod htmlparamelement; +pub(crate) mod htmlpictureelement; +pub(crate) mod htmlpreelement; +pub(crate) mod htmlprogresselement; +pub(crate) mod htmlquoteelement; +#[allow(dead_code)] +pub(crate) mod htmlscriptelement; +pub(crate) mod htmlselectelement; +pub(crate) mod htmlsourceelement; +pub(crate) mod htmlspanelement; +pub(crate) mod htmlstyleelement; +pub(crate) mod htmltablecaptionelement; +pub(crate) mod htmltablecellelement; +pub(crate) mod htmltablecolelement; +pub(crate) mod htmltableelement; +pub(crate) mod htmltablerowelement; +pub(crate) mod htmltablesectionelement; +pub(crate) mod htmltemplateelement; +pub(crate) mod htmltextareaelement; +pub(crate) mod htmltimeelement; +pub(crate) mod htmltitleelement; +pub(crate) mod htmltrackelement; +pub(crate) mod htmlulistelement; +pub(crate) mod htmlunknownelement; +pub(crate) mod htmlvideoelement; +pub(crate) mod iirfilternode; +pub(crate) mod imagebitmap; +pub(crate) mod imagedata; +pub(crate) mod inputevent; +pub(crate) mod intersectionobserver; +pub(crate) mod intersectionobserverentry; +pub(crate) mod keyboardevent; +pub(crate) mod location; +pub(crate) mod mediadeviceinfo; +pub(crate) mod mediadevices; +pub(crate) mod mediaelementaudiosourcenode; +pub(crate) mod mediaerror; +pub(crate) mod mediafragmentparser; +pub(crate) mod medialist; +pub(crate) mod mediametadata; +pub(crate) mod mediaquerylist; +pub(crate) mod mediaquerylistevent; +pub(crate) mod mediasession; +pub(crate) mod mediastream; +pub(crate) mod mediastreamaudiodestinationnode; +pub(crate) mod mediastreamaudiosourcenode; +pub(crate) mod mediastreamtrack; +pub(crate) mod mediastreamtrackaudiosourcenode; +pub(crate) mod messagechannel; +pub(crate) mod messageevent; +#[allow(dead_code)] +pub(crate) mod messageport; +pub(crate) mod mimetype; +pub(crate) mod mimetypearray; +pub(crate) mod mouseevent; +pub(crate) mod mutationobserver; +pub(crate) mod mutationrecord; +pub(crate) mod namednodemap; +pub(crate) mod navigationpreloadmanager; +pub(crate) mod navigator; +pub(crate) mod navigatorinfo; +#[allow(dead_code)] +pub(crate) mod node; +pub(crate) mod nodeiterator; +#[allow(dead_code)] +pub(crate) mod nodelist; +pub(crate) mod offlineaudiocompletionevent; +pub(crate) mod offlineaudiocontext; +pub(crate) mod offscreencanvas; +pub(crate) mod offscreencanvasrenderingcontext2d; +pub(crate) mod oscillatornode; +pub(crate) mod pagetransitionevent; +pub(crate) mod paintrenderingcontext2d; +pub(crate) mod paintsize; +pub(crate) mod paintworkletglobalscope; +pub(crate) mod pannernode; +pub(crate) mod performance; +#[allow(dead_code)] +pub(crate) mod performanceentry; +pub(crate) mod performancemark; +pub(crate) mod performancemeasure; +pub(crate) mod performancenavigation; +pub(crate) mod performancenavigationtiming; +#[allow(dead_code)] +pub(crate) mod performanceobserver; +pub(crate) mod performanceobserverentrylist; +pub(crate) mod performancepainttiming; +pub(crate) mod performanceresourcetiming; +pub(crate) mod permissions; +pub(crate) mod permissionstatus; +pub(crate) mod plugin; +pub(crate) mod pluginarray; +#[allow(dead_code)] +pub(crate) mod pointerevent; +pub(crate) mod popstateevent; +pub(crate) mod processinginstruction; +pub(crate) mod progressevent; +#[allow(dead_code)] +pub(crate) mod promise; +pub(crate) mod promisenativehandler; +pub(crate) mod promiserejectionevent; +pub(crate) mod radionodelist; +pub(crate) mod range; +pub(crate) mod raredata; +#[allow(dead_code)] +pub(crate) mod readablebytestreamcontroller; +pub(crate) mod readablestream; +pub(crate) mod readablestreambyobreader; +pub(crate) mod readablestreambyobrequest; +pub(crate) mod readablestreamdefaultcontroller; +pub(crate) mod readablestreamdefaultreader; +pub(crate) mod request; +pub(crate) mod resizeobserver; +pub(crate) mod resizeobserverentry; +pub(crate) mod resizeobserversize; +pub(crate) mod response; +pub(crate) mod rtcdatachannel; +pub(crate) mod rtcdatachannelevent; +pub(crate) mod rtcerror; +pub(crate) mod rtcerrorevent; +pub(crate) mod rtcicecandidate; +pub(crate) mod rtcpeerconnection; +pub(crate) mod rtcpeerconnectioniceevent; pub(crate) mod rtcrtpsender; pub(crate) mod rtcrtptransceiver; -pub mod rtcsessiondescription; -pub mod rtctrackevent; -pub mod screen; -pub mod securitypolicyviolationevent; -pub mod selection; -pub mod serviceworker; -pub mod serviceworkercontainer; -pub mod serviceworkerglobalscope; -pub mod serviceworkerregistration; -pub mod servoparser; -pub mod shadowroot; -pub mod staticrange; -pub mod stereopannernode; -pub mod storage; -pub mod storageevent; -pub mod stylepropertymapreadonly; -pub mod stylesheet; -pub mod stylesheetlist; -pub mod submitevent; -pub mod subtlecrypto; -pub mod svgelement; -pub mod svggraphicselement; -pub mod svgsvgelement; -pub mod testbinding; -pub mod testbindingiterable; -pub mod testbindingmaplike; -pub mod testbindingpairiterable; -pub mod testbindingproxy; -pub mod testbindingsetlike; -pub mod testns; -pub mod testrunner; -pub mod testworklet; -pub mod testworkletglobalscope; -pub mod text; -pub mod textcontrol; -pub mod textdecoder; -pub mod textencoder; -pub mod textmetrics; -pub mod texttrack; -pub mod texttrackcue; -pub mod texttrackcuelist; -pub mod texttracklist; -pub mod timeranges; -pub mod touch; -pub mod touchevent; -pub mod touchlist; -pub mod trackevent; -pub mod transitionevent; -pub mod treewalker; -pub mod uievent; -pub mod underlyingsourcecontainer; -pub mod url; -pub mod urlhelper; -pub mod urlsearchparams; -pub mod userscripts; -pub mod validation; -pub mod validitystate; -pub mod values; -pub mod vertexarrayobject; -pub mod videotrack; -pub mod videotracklist; -pub mod virtualmethods; -pub mod visibilitystateentry; -pub mod vttcue; -pub mod vttregion; -pub mod webgl2renderingcontext; -pub mod webgl_extensions; -pub mod webgl_validations; -pub mod webglactiveinfo; -pub mod webglbuffer; -pub mod webglcontextevent; -pub mod webglframebuffer; -pub mod webglobject; -pub mod webglprogram; -pub mod webglquery; -pub mod webglrenderbuffer; -pub mod webglrenderingcontext; -pub mod webglsampler; -pub mod webglshader; -pub mod webglshaderprecisionformat; -pub mod webglsync; -pub mod webgltexture; -pub mod webgltransformfeedback; -pub mod webgluniformlocation; -pub mod webglvertexarrayobject; -pub mod webglvertexarrayobjectoes; -pub mod websocket; +pub(crate) mod rtcsessiondescription; +pub(crate) mod rtctrackevent; +pub(crate) mod screen; +pub(crate) mod securitypolicyviolationevent; +pub(crate) mod selection; +#[allow(dead_code)] +pub(crate) mod serviceworker; +pub(crate) mod serviceworkercontainer; +pub(crate) mod serviceworkerglobalscope; +#[allow(dead_code)] +pub(crate) mod serviceworkerregistration; +#[allow(dead_code)] +pub(crate) mod servoparser; +pub(crate) mod shadowroot; +pub(crate) mod staticrange; +pub(crate) mod stereopannernode; +pub(crate) mod storage; +pub(crate) mod storageevent; +pub(crate) mod stylepropertymapreadonly; +pub(crate) mod stylesheet; +pub(crate) mod stylesheetlist; +pub(crate) mod submitevent; +pub(crate) mod subtlecrypto; +pub(crate) mod svgelement; +pub(crate) mod svggraphicselement; +pub(crate) mod svgsvgelement; +pub(crate) mod testbinding; +pub(crate) mod testbindingiterable; +pub(crate) mod testbindingmaplike; +pub(crate) mod testbindingpairiterable; +pub(crate) mod testbindingproxy; +pub(crate) mod testbindingsetlike; +pub(crate) mod testns; +pub(crate) mod testrunner; +pub(crate) mod testworklet; +pub(crate) mod testworkletglobalscope; +pub(crate) mod text; +pub(crate) mod textcontrol; +pub(crate) mod textdecoder; +pub(crate) mod textencoder; +pub(crate) mod textmetrics; +pub(crate) mod texttrack; +pub(crate) mod texttrackcue; +pub(crate) mod texttrackcuelist; +pub(crate) mod texttracklist; +#[allow(dead_code)] +pub(crate) mod timeranges; +pub(crate) mod touch; +pub(crate) mod touchevent; +pub(crate) mod touchlist; +pub(crate) mod trackevent; +pub(crate) mod transitionevent; +pub(crate) mod treewalker; +pub(crate) mod uievent; +pub(crate) mod underlyingsourcecontainer; +pub(crate) mod url; +pub(crate) mod urlhelper; +pub(crate) mod urlsearchparams; +pub(crate) mod userscripts; +pub(crate) mod validation; +pub(crate) mod validitystate; +pub(crate) mod values; +pub(crate) mod vertexarrayobject; +pub(crate) mod videotrack; +pub(crate) mod videotracklist; +pub(crate) mod virtualmethods; +pub(crate) mod visibilitystateentry; +pub(crate) mod vttcue; +pub(crate) mod vttregion; +pub(crate) mod webgl2renderingcontext; +pub(crate) mod webgl_extensions; +pub(crate) mod webgl_validations; +pub(crate) mod webglactiveinfo; +pub(crate) mod webglbuffer; +pub(crate) mod webglcontextevent; +pub(crate) mod webglframebuffer; +pub(crate) mod webglobject; +pub(crate) mod webglprogram; +pub(crate) mod webglquery; +pub(crate) mod webglrenderbuffer; +pub(crate) mod webglrenderingcontext; +pub(crate) mod webglsampler; +pub(crate) mod webglshader; +pub(crate) mod webglshaderprecisionformat; +pub(crate) mod webglsync; +pub(crate) mod webgltexture; +pub(crate) mod webgltransformfeedback; +pub(crate) mod webgluniformlocation; +pub(crate) mod webglvertexarrayobject; +pub(crate) mod webglvertexarrayobjectoes; +pub(crate) mod websocket; #[cfg(feature = "webxr")] mod webxr; #[cfg(feature = "webxr")] -pub use self::webxr::*; +pub(crate) use self::webxr::*; #[cfg(feature = "webgpu")] -pub mod webgpu; +pub(crate) mod webgpu; #[cfg(feature = "webgpu")] -pub use self::webgpu::*; +pub(crate) use self::webgpu::*; #[cfg(not(feature = "webgpu"))] -pub mod gpucanvascontext; +pub(crate) mod gpucanvascontext; #[cfg(not(feature = "webgpu"))] -pub use gpucanvascontext::GPUCanvasContext; -pub mod wheelevent; -pub mod window; -pub mod windowproxy; -pub mod worker; -pub mod workerglobalscope; -pub mod workerlocation; -pub mod workernavigator; -pub mod worklet; -pub mod workletglobalscope; -pub mod xmldocument; -pub mod xmlhttprequest; -pub mod xmlhttprequesteventtarget; -pub mod xmlhttprequestupload; -pub mod xmlserializer; -pub mod xpathevaluator; -pub mod xpathexpression; -pub mod xpathresult; -pub use self::webgl_extensions::ext::*; +pub(crate) use gpucanvascontext::GPUCanvasContext; +pub(crate) mod wheelevent; +#[allow(dead_code)] +pub(crate) mod window; +#[allow(dead_code)] +pub(crate) mod windowproxy; +pub(crate) mod worker; +#[allow(dead_code)] +pub(crate) mod workerglobalscope; +pub(crate) mod workerlocation; +pub(crate) mod workernavigator; +pub(crate) mod worklet; +pub(crate) mod workletglobalscope; +pub(crate) mod xmldocument; +pub(crate) mod xmlhttprequest; +pub(crate) mod xmlhttprequesteventtarget; +pub(crate) mod xmlhttprequestupload; +pub(crate) mod xmlserializer; +pub(crate) mod xpathevaluator; +pub(crate) mod xpathexpression; +pub(crate) mod xpathresult; +pub(crate) use self::webgl_extensions::ext::*; diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index 4a80652e757..1d616c5f1ab 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -27,7 +27,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MouseEvent { +pub(crate) struct MouseEvent { uievent: UIEvent, screen_x: Cell<i32>, screen_y: Cell<i32>, @@ -51,7 +51,7 @@ pub struct MouseEvent { } impl MouseEvent { - pub fn new_inherited() -> MouseEvent { + pub(crate) fn new_inherited() -> MouseEvent { MouseEvent { uievent: UIEvent::new_inherited(), screen_x: Cell::new(0), @@ -75,7 +75,7 @@ impl MouseEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<MouseEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<MouseEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } @@ -88,7 +88,7 @@ impl MouseEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: EventBubbles, @@ -181,7 +181,7 @@ impl MouseEvent { /// <https://w3c.github.io/uievents/#initialize-a-mouseevent> #[allow(clippy::too_many_arguments)] - pub fn initialize_mouse_event( + pub(crate) fn initialize_mouse_event( &self, type_: DOMString, can_bubble: EventBubbles, @@ -234,7 +234,7 @@ impl MouseEvent { self.point_in_target.set(point_in_target); } - pub fn point_in_target(&self) -> Option<Point2D<f32>> { + pub(crate) fn point_in_target(&self) -> Option<Point2D<f32>> { self.point_in_target.get() } } diff --git a/components/script/dom/mutationobserver.rs b/components/script/dom/mutationobserver.rs index 51da85a78dd..e2c86181097 100644 --- a/components/script/dom/mutationobserver.rs +++ b/components/script/dom/mutationobserver.rs @@ -26,7 +26,7 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct MutationObserver { +pub(crate) struct MutationObserver { reflector_: Reflector, #[ignore_malloc_size_of = "can't measure Rc values"] callback: Rc<MutationCallback>, @@ -34,7 +34,7 @@ pub struct MutationObserver { node_list: DomRefCell<Vec<DomRoot<Node>>>, } -pub enum Mutation<'a> { +pub(crate) enum Mutation<'a> { Attribute { name: LocalName, namespace: Namespace, @@ -52,13 +52,13 @@ pub enum Mutation<'a> { } #[derive(JSTraceable, MallocSizeOf)] -pub struct RegisteredObserver { - pub observer: DomRoot<MutationObserver>, +pub(crate) struct RegisteredObserver { + pub(crate) observer: DomRoot<MutationObserver>, options: ObserverOptions, } #[derive(JSTraceable, MallocSizeOf)] -pub struct ObserverOptions { +pub(crate) struct ObserverOptions { attribute_old_value: bool, attributes: bool, character_data: bool, @@ -89,7 +89,7 @@ impl MutationObserver { } /// <https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask> - pub fn queue_mutation_observer_microtask() { + pub(crate) fn queue_mutation_observer_microtask() { // Step 1 if ScriptThread::is_mutation_observer_microtask_queued() { return; @@ -101,7 +101,7 @@ impl MutationObserver { } /// <https://dom.spec.whatwg.org/#notify-mutation-observers> - pub fn notify_mutation_observers() { + pub(crate) fn notify_mutation_observers() { // Step 1 ScriptThread::set_mutation_observer_microtask_queued(false); // Step 2 @@ -122,7 +122,7 @@ impl MutationObserver { } /// <https://dom.spec.whatwg.org/#queueing-a-mutation-record> - pub fn queue_a_mutation_record(target: &Node, attr_type: Mutation) { + pub(crate) fn queue_a_mutation_record(target: &Node, attr_type: Mutation) { if !target.global().as_window().get_exists_mut_observer() { return; } diff --git a/components/script/dom/mutationrecord.rs b/components/script/dom/mutationrecord.rs index 5280b5a7113..3b4195bd01c 100644 --- a/components/script/dom/mutationrecord.rs +++ b/components/script/dom/mutationrecord.rs @@ -14,7 +14,7 @@ use crate::dom::nodelist::NodeList; use crate::script_runtime::CanGc; #[dom_struct] -pub struct MutationRecord { +pub(crate) struct MutationRecord { reflector_: Reflector, record_type: DOMString, target: Dom<Node>, @@ -29,7 +29,7 @@ pub struct MutationRecord { impl MutationRecord { #[allow(crown::unrooted_must_root)] - pub fn attribute_mutated( + pub(crate) fn attribute_mutated( target: &Node, attribute_name: &LocalName, attribute_namespace: Option<&Namespace>, @@ -49,7 +49,7 @@ impl MutationRecord { reflect_dom_object(record, &*target.owner_window(), CanGc::note()) } - pub fn character_data_mutated( + pub(crate) fn character_data_mutated( target: &Node, old_value: Option<DOMString>, ) -> DomRoot<MutationRecord> { @@ -70,7 +70,7 @@ impl MutationRecord { ) } - pub fn child_list_mutated( + pub(crate) fn child_list_mutated( target: &Node, added_nodes: Option<&[&Node]>, removed_nodes: Option<&[&Node]>, diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs index d043591cbfd..b0318aa1c9d 100644 --- a/components/script/dom/namednodemap.rs +++ b/components/script/dom/namednodemap.rs @@ -18,7 +18,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct NamedNodeMap { +pub(crate) struct NamedNodeMap { reflector_: Reflector, owner: Dom<Element>, } @@ -31,7 +31,7 @@ impl NamedNodeMap { } } - pub fn new(window: &Window, elem: &Element) -> DomRoot<NamedNodeMap> { + pub(crate) fn new(window: &Window, elem: &Element) -> DomRoot<NamedNodeMap> { 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 b3965e17cc0..ff8fea3a6b8 100644 --- a/components/script/dom/navigationpreloadmanager.rs +++ b/components/script/dom/navigationpreloadmanager.rs @@ -21,7 +21,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct NavigationPreloadManager { +pub(crate) struct NavigationPreloadManager { reflector_: Reflector, serviceworker_registration: Dom<ServiceWorkerRegistration>, } @@ -35,7 +35,7 @@ impl NavigationPreloadManager { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, registration: &ServiceWorkerRegistration, ) -> DomRoot<NavigationPreloadManager> { diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 71ca760882c..383775ab6b6 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -40,7 +40,7 @@ pub(super) fn hardware_concurrency() -> u64 { } #[dom_struct] -pub struct Navigator { +pub(crate) struct Navigator { reflector_: Reflector, bluetooth: MutNullableDom<Bluetooth>, plugins: MutNullableDom<PluginArray>, @@ -79,20 +79,20 @@ impl Navigator { } } - pub fn new(window: &Window) -> DomRoot<Navigator> { + pub(crate) fn new(window: &Window) -> DomRoot<Navigator> { reflect_dom_object(Box::new(Navigator::new_inherited()), window, CanGc::note()) } #[cfg(feature = "webxr")] - pub fn xr(&self) -> Option<DomRoot<XRSystem>> { + pub(crate) fn xr(&self) -> Option<DomRoot<XRSystem>> { self.xr.get() } - pub fn get_gamepad(&self, index: usize) -> Option<DomRoot<Gamepad>> { + pub(crate) fn get_gamepad(&self, index: usize) -> Option<DomRoot<Gamepad>> { self.gamepads.borrow().get(index).and_then(|g| g.get()) } - pub fn set_gamepad(&self, index: usize, gamepad: &Gamepad, can_gc: CanGc) { + pub(crate) fn set_gamepad(&self, index: usize, gamepad: &Gamepad, can_gc: CanGc) { if let Some(gamepad_to_set) = self.gamepads.borrow().get(index) { gamepad_to_set.set(Some(gamepad)); } @@ -104,7 +104,7 @@ impl Navigator { } } - pub fn remove_gamepad(&self, index: usize) { + pub(crate) fn remove_gamepad(&self, index: usize) { if let Some(gamepad_to_remove) = self.gamepads.borrow_mut().get(index) { gamepad_to_remove.set(None); } @@ -112,7 +112,7 @@ impl Navigator { } /// <https://www.w3.org/TR/gamepad/#dfn-selecting-an-unused-gamepad-index> - pub fn select_gamepad_index(&self) -> u32 { + pub(crate) fn select_gamepad_index(&self) -> u32 { let mut gamepad_list = self.gamepads.borrow_mut(); if let Some(index) = gamepad_list.iter().position(|g| g.get().is_none()) { index as u32 @@ -134,11 +134,11 @@ impl Navigator { } } - pub fn has_gamepad_gesture(&self) -> bool { + pub(crate) fn has_gamepad_gesture(&self) -> bool { self.has_gamepad_gesture.get() } - pub fn set_has_gamepad_gesture(&self, has_gamepad_gesture: bool) { + pub(crate) fn set_has_gamepad_gesture(&self, has_gamepad_gesture: bool) { self.has_gamepad_gesture.set(has_gamepad_gesture); } } diff --git a/components/script/dom/navigatorinfo.rs b/components/script/dom/navigatorinfo.rs index 5450677cb9b..66c2f3658fe 100644 --- a/components/script/dom/navigatorinfo.rs +++ b/components/script/dom/navigatorinfo.rs @@ -7,75 +7,75 @@ use std::borrow::Cow; use crate::dom::bindings::str::DOMString; #[allow(non_snake_case)] -pub fn Product() -> DOMString { +pub(crate) fn Product() -> DOMString { DOMString::from("Gecko") } #[allow(non_snake_case)] -pub fn ProductSub() -> DOMString { +pub(crate) fn ProductSub() -> DOMString { DOMString::from("20100101") } #[allow(non_snake_case)] -pub fn Vendor() -> DOMString { +pub(crate) fn Vendor() -> DOMString { DOMString::from("") } #[allow(non_snake_case)] -pub fn VendorSub() -> DOMString { +pub(crate) fn VendorSub() -> DOMString { DOMString::from("") } #[allow(non_snake_case)] -pub fn TaintEnabled() -> bool { +pub(crate) fn TaintEnabled() -> bool { false } #[allow(non_snake_case)] -pub fn AppName() -> DOMString { +pub(crate) fn AppName() -> DOMString { DOMString::from("Netscape") // Like Gecko/Webkit } #[allow(non_snake_case)] -pub fn AppCodeName() -> DOMString { +pub(crate) fn AppCodeName() -> DOMString { DOMString::from("Mozilla") } #[allow(non_snake_case)] #[cfg(target_os = "windows")] -pub fn Platform() -> DOMString { +pub(crate) fn Platform() -> DOMString { DOMString::from("Win32") } #[allow(non_snake_case)] #[cfg(any(target_os = "android", target_os = "linux"))] -pub fn Platform() -> DOMString { +pub(crate) fn Platform() -> DOMString { DOMString::from("Linux") } #[allow(non_snake_case)] #[cfg(target_os = "macos")] -pub fn Platform() -> DOMString { +pub(crate) fn Platform() -> DOMString { DOMString::from("Mac") } #[allow(non_snake_case)] #[cfg(target_os = "ios")] -pub fn Platform() -> DOMString { +pub(crate) fn Platform() -> DOMString { DOMString::from("iOS") } #[allow(non_snake_case)] -pub fn UserAgent(user_agent: Cow<'static, str>) -> DOMString { +pub(crate) fn UserAgent(user_agent: Cow<'static, str>) -> DOMString { DOMString::from(&*user_agent) } #[allow(non_snake_case)] -pub fn AppVersion() -> DOMString { +pub(crate) fn AppVersion() -> DOMString { DOMString::from("4.0") } #[allow(non_snake_case)] -pub fn Language() -> DOMString { +pub(crate) fn Language() -> DOMString { DOMString::from("en-US") } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 22a46f423c6..3925c532a5c 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -189,7 +189,7 @@ impl fmt::Debug for DomRoot<Node> { /// Flags for node items #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] -pub struct NodeFlags(u16); +pub(crate) struct NodeFlags(u16); bitflags! { impl NodeFlags: u16 { @@ -318,14 +318,14 @@ impl Node { } } - pub fn clean_up_style_and_layout_data(&self) { + pub(crate) fn clean_up_style_and_layout_data(&self) { self.owner_doc().cancel_animations_for_node(self); self.style_data.borrow_mut().take(); self.layout_data.borrow_mut().take(); } /// Clean up flags and unbind from tree. - pub fn complete_remove_subtree(root: &Node, context: &UnbindContext) { + pub(crate) fn complete_remove_subtree(root: &Node, context: &UnbindContext) { // Flags that reset when a node is disconnected const RESET_FLAGS: NodeFlags = NodeFlags::IS_IN_A_DOCUMENT_TREE .union(NodeFlags::IS_CONNECTED) @@ -411,15 +411,15 @@ impl Node { Self::complete_remove_subtree(child, &context); } - pub fn to_untrusted_node_address(&self) -> UntrustedNodeAddress { + pub(crate) fn to_untrusted_node_address(&self) -> UntrustedNodeAddress { UntrustedNodeAddress(self.reflector().get_jsobject().get() as *const c_void) } - pub fn to_opaque(&self) -> OpaqueNode { + pub(crate) fn to_opaque(&self) -> OpaqueNode { OpaqueNode(self.reflector().get_jsobject().get() as usize) } - pub fn as_custom_element(&self) -> Option<DomRoot<Element>> { + pub(crate) fn as_custom_element(&self) -> Option<DomRoot<Element>> { self.downcast::<Element>().and_then(|element| { if element.get_custom_element_definition().is_some() { Some(DomRoot::from_ref(element)) @@ -430,7 +430,7 @@ impl Node { } /// <https://html.spec.whatg.org/#fire_a_synthetic_mouse_event> - pub fn fire_synthetic_mouse_event_not_trusted(&self, name: DOMString, can_gc: CanGc) { + pub(crate) fn fire_synthetic_mouse_event_not_trusted(&self, name: DOMString, can_gc: CanGc) { // Spec says the choice of which global to create // the mouse event on is not well-defined, // and refers to heycam/webidl#135 @@ -470,7 +470,7 @@ impl Node { .dispatch(self.upcast::<EventTarget>(), false, can_gc); } - pub fn parent_directionality(&self) -> String { + pub(crate) fn parent_directionality(&self) -> String { let mut current = self.GetParentNode(); loop { @@ -491,7 +491,7 @@ impl Node { } } -pub struct QuerySelectorIterator { +pub(crate) struct QuerySelectorIterator { selectors: SelectorList<SelectorImpl>, iterator: TreeIterator, } @@ -541,7 +541,7 @@ impl Node { /// Returns true if this node is before `other` in the same connected DOM /// tree. - pub fn is_before(&self, other: &Node) -> bool { + pub(crate) fn is_before(&self, other: &Node) -> bool { let cmp = other.CompareDocumentPosition(self); if cmp & NodeConstants::DOCUMENT_POSITION_DISCONNECTED != 0 { return false; @@ -552,13 +552,13 @@ impl Node { /// Return all registered mutation observers for this node. Lazily initialize the /// raredata if it does not exist. - pub fn registered_mutation_observers_mut(&self) -> RefMut<Vec<RegisteredObserver>> { + pub(crate) fn registered_mutation_observers_mut(&self) -> RefMut<Vec<RegisteredObserver>> { RefMut::map(self.ensure_rare_data(), |rare_data| { &mut rare_data.mutation_observers }) } - pub fn registered_mutation_observers(&self) -> Option<Ref<Vec<RegisteredObserver>>> { + pub(crate) fn registered_mutation_observers(&self) -> Option<Ref<Vec<RegisteredObserver>>> { let rare_data: Ref<_> = self.rare_data.borrow(); if rare_data.is_none() { @@ -570,24 +570,24 @@ impl Node { } /// Add a new mutation observer for a given node. - pub fn add_mutation_observer(&self, observer: RegisteredObserver) { + pub(crate) fn add_mutation_observer(&self, observer: RegisteredObserver) { self.ensure_rare_data().mutation_observers.push(observer); } /// Removes the mutation observer for a given node. - pub fn remove_mutation_observer(&self, observer: &MutationObserver) { + pub(crate) fn remove_mutation_observer(&self, observer: &MutationObserver) { self.ensure_rare_data() .mutation_observers .retain(|reg_obs| &*reg_obs.observer != observer) } /// Dumps the subtree rooted at this node, for debugging. - pub fn dump(&self) { + pub(crate) fn dump(&self) { self.dump_indent(0); } /// Dumps the node tree, for debugging, with indentation. - pub fn dump_indent(&self, indent: u32) { + pub(crate) fn dump_indent(&self, indent: u32) { let mut s = String::new(); for _ in 0..indent { s.push_str(" "); @@ -603,37 +603,37 @@ impl Node { } /// Returns a string that describes this node. - pub fn debug_str(&self) -> String { + pub(crate) fn debug_str(&self) -> String { format!("{:?}", self.type_id()) } /// <https://dom.spec.whatwg.org/#in-a-document-tree> - pub fn is_in_a_document_tree(&self) -> bool { + pub(crate) fn is_in_a_document_tree(&self) -> bool { self.flags.get().contains(NodeFlags::IS_IN_A_DOCUMENT_TREE) } /// Return true iff node's root is a shadow-root. - pub fn is_in_a_shadow_tree(&self) -> bool { + pub(crate) fn is_in_a_shadow_tree(&self) -> bool { self.flags.get().contains(NodeFlags::IS_IN_SHADOW_TREE) } - pub fn has_weird_parser_insertion_mode(&self) -> bool { + pub(crate) fn has_weird_parser_insertion_mode(&self) -> bool { self.flags .get() .contains(NodeFlags::HAS_WEIRD_PARSER_INSERTION_MODE) } - pub fn set_weird_parser_insertion_mode(&self) { + pub(crate) fn set_weird_parser_insertion_mode(&self) { self.set_flag(NodeFlags::HAS_WEIRD_PARSER_INSERTION_MODE, true) } /// <https://dom.spec.whatwg.org/#connected> - pub fn is_connected(&self) -> bool { + pub(crate) fn is_connected(&self) -> bool { self.flags.get().contains(NodeFlags::IS_CONNECTED) } /// Returns the type ID of this node. - pub fn type_id(&self) -> NodeTypeId { + pub(crate) fn type_id(&self) -> NodeTypeId { match *self.eventtarget.type_id() { EventTargetTypeId::Node(type_id) => type_id, _ => unreachable!(), @@ -641,7 +641,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-length> - pub fn len(&self) -> u32 { + pub(crate) fn len(&self) -> u32 { match self.type_id() { NodeTypeId::DocumentType => 0, NodeTypeId::CharacterData(_) => self.downcast::<CharacterData>().unwrap().Length(), @@ -649,39 +649,39 @@ impl Node { } } - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { // A node is considered empty if its length is 0. self.len() == 0 } /// <https://dom.spec.whatwg.org/#concept-tree-index> - pub fn index(&self) -> u32 { + pub(crate) fn index(&self) -> u32 { self.preceding_siblings().count() as u32 } /// Returns true if this node has a parent. - pub fn has_parent(&self) -> bool { + pub(crate) fn has_parent(&self) -> bool { self.parent_node.get().is_some() } - pub fn children_count(&self) -> u32 { + pub(crate) fn children_count(&self) -> u32 { self.children_count.get() } - pub fn ranges(&self) -> &WeakRangeVec { + pub(crate) fn ranges(&self) -> &WeakRangeVec { &self.ranges } #[inline] - pub fn is_doctype(&self) -> bool { + pub(crate) fn is_doctype(&self) -> bool { self.type_id() == NodeTypeId::DocumentType } - pub fn get_flag(&self, flag: NodeFlags) -> bool { + pub(crate) fn get_flag(&self, flag: NodeFlags) -> bool { self.flags.get().contains(flag) } - pub fn set_flag(&self, flag: NodeFlags, value: bool) { + pub(crate) fn set_flag(&self, flag: NodeFlags, value: bool) { let mut flags = self.flags.get(); if value { @@ -694,15 +694,15 @@ impl Node { } // FIXME(emilio): This and the function below should move to Element. - pub fn note_dirty_descendants(&self) { + pub(crate) fn note_dirty_descendants(&self) { self.owner_doc().note_node_with_dirty_descendants(self); } - pub fn has_dirty_descendants(&self) -> bool { + pub(crate) fn has_dirty_descendants(&self) -> bool { self.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) } - pub fn rev_version(&self) { + pub(crate) fn rev_version(&self) { // The new version counter is 1 plus the max of the node's current version counter, // its descendants version, and the document's version. Normally, this will just be // the document's version, but we do have to deal with the case where the node has moved @@ -718,7 +718,7 @@ impl Node { doc.inclusive_descendants_version.set(version); } - pub fn dirty(&self, damage: NodeDamage) { + pub(crate) fn dirty(&self, damage: NodeDamage) { self.rev_version(); if !self.is_connected() { return; @@ -740,30 +740,30 @@ impl Node { } /// The maximum version number of this node's descendants, including itself - pub fn inclusive_descendants_version(&self) -> u64 { + pub(crate) fn inclusive_descendants_version(&self) -> u64 { self.inclusive_descendants_version.get() } /// Iterates over this node and all its descendants, in preorder. - pub fn traverse_preorder(&self, shadow_including: ShadowIncluding) -> TreeIterator { + pub(crate) fn traverse_preorder(&self, shadow_including: ShadowIncluding) -> TreeIterator { TreeIterator::new(self, shadow_including) } - pub fn inclusively_following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn inclusively_following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: Some(DomRoot::from_ref(self)), next_node: |n| n.GetNextSibling(), } } - pub fn inclusively_preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn inclusively_preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: Some(DomRoot::from_ref(self)), next_node: |n| n.GetPreviousSibling(), } } - pub fn common_ancestor( + pub(crate) fn common_ancestor( &self, other: &Node, shadow_including: ShadowIncluding, @@ -775,86 +775,86 @@ impl Node { }) } - pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool { + pub(crate) fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool { self == parent || self.is_ancestor_of(parent) } - pub fn is_ancestor_of(&self, parent: &Node) -> bool { + pub(crate) fn is_ancestor_of(&self, parent: &Node) -> bool { parent.ancestors().any(|ancestor| &*ancestor == self) } - pub fn is_shadow_including_inclusive_ancestor_of(&self, node: &Node) -> bool { + pub(crate) fn is_shadow_including_inclusive_ancestor_of(&self, node: &Node) -> bool { node.inclusive_ancestors(ShadowIncluding::Yes) .any(|ancestor| &*ancestor == self) } - pub fn following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn following_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetNextSibling(), next_node: |n| n.GetNextSibling(), } } - pub fn preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn preceding_siblings(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetPreviousSibling(), next_node: |n| n.GetPreviousSibling(), } } - pub fn following_nodes(&self, root: &Node) -> FollowingNodeIterator { + pub(crate) fn following_nodes(&self, root: &Node) -> FollowingNodeIterator { FollowingNodeIterator { current: Some(DomRoot::from_ref(self)), root: DomRoot::from_ref(root), } } - pub fn preceding_nodes(&self, root: &Node) -> PrecedingNodeIterator { + pub(crate) fn preceding_nodes(&self, root: &Node) -> PrecedingNodeIterator { PrecedingNodeIterator { current: Some(DomRoot::from_ref(self)), root: DomRoot::from_ref(root), } } - pub fn descending_last_children(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn descending_last_children(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetLastChild(), next_node: |n| n.GetLastChild(), } } - pub fn is_parent_of(&self, child: &Node) -> bool { + pub(crate) fn is_parent_of(&self, child: &Node) -> bool { child .parent_node .get() .is_some_and(|parent| &*parent == self) } - pub fn to_trusted_node_address(&self) -> TrustedNodeAddress { + pub(crate) fn to_trusted_node_address(&self) -> TrustedNodeAddress { TrustedNodeAddress(self as *const Node as *const libc::c_void) } /// Returns the rendered bounding content box if the element is rendered, /// and none otherwise. - pub fn bounding_content_box(&self, can_gc: CanGc) -> Option<Rect<Au>> { + pub(crate) fn bounding_content_box(&self, can_gc: CanGc) -> Option<Rect<Au>> { self.owner_window().content_box_query(self, can_gc) } - pub fn bounding_content_box_or_zero(&self, can_gc: CanGc) -> Rect<Au> { + pub(crate) fn bounding_content_box_or_zero(&self, can_gc: CanGc) -> Rect<Au> { self.bounding_content_box(can_gc).unwrap_or_else(Rect::zero) } - pub fn content_boxes(&self, can_gc: CanGc) -> Vec<Rect<Au>> { + pub(crate) fn content_boxes(&self, can_gc: CanGc) -> Vec<Rect<Au>> { self.owner_window().content_boxes_query(self, can_gc) } - pub fn client_rect(&self, can_gc: CanGc) -> Rect<i32> { + pub(crate) fn client_rect(&self, can_gc: CanGc) -> Rect<i32> { self.owner_window().client_rect_query(self, can_gc) } /// <https://drafts.csswg.org/cssom-view/#dom-element-scrollwidth> /// <https://drafts.csswg.org/cssom-view/#dom-element-scrollheight> - pub fn scroll_area(&self, can_gc: CanGc) -> Rect<i32> { + pub(crate) fn scroll_area(&self, can_gc: CanGc) -> Rect<i32> { // "1. Let document be the element’s node document."" let document = self.owner_doc(); @@ -893,14 +893,14 @@ impl Node { window.scrolling_area_query(Some(self), can_gc) } - pub fn scroll_offset(&self) -> Vector2D<f32> { + pub(crate) fn scroll_offset(&self) -> Vector2D<f32> { let document = self.owner_doc(); let window = document.window(); window.scroll_offset_query(self).to_untyped() } /// <https://dom.spec.whatwg.org/#dom-childnode-before> - pub fn before(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn before(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let parent = &self.parent_node; @@ -931,7 +931,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-childnode-after> - pub fn after(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn after(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let parent = &self.parent_node; @@ -956,7 +956,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-childnode-replacewith> - pub fn replace_with(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn replace_with(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let parent = if let Some(parent) = self.GetParentNode() { parent @@ -981,7 +981,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-parentnode-prepend> - pub fn prepend(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn prepend(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let doc = self.owner_doc(); let node = doc.node_from_nodes_and_strings(nodes, can_gc)?; @@ -991,7 +991,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-parentnode-append> - pub fn append(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn append(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let doc = self.owner_doc(); let node = doc.node_from_nodes_and_strings(nodes, can_gc)?; @@ -1000,7 +1000,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-parentnode-replacechildren> - pub fn replace_children(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { + pub(crate) fn replace_children(&self, nodes: Vec<NodeOrString>, can_gc: CanGc) -> ErrorResult { // Step 1. let doc = self.owner_doc(); let node = doc.node_from_nodes_and_strings(nodes, can_gc)?; @@ -1012,7 +1012,10 @@ impl Node { } /// <https://dom.spec.whatwg.org/#dom-parentnode-queryselector> - pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> { + pub(crate) fn query_selector( + &self, + selectors: DOMString, + ) -> Fallible<Option<DomRoot<Element>>> { // Step 1. let doc = self.owner_doc(); match SelectorParser::parse_author_origin_no_namespace( @@ -1046,7 +1049,10 @@ impl Node { /// Get an iterator over all nodes which match a set of selectors /// Be careful not to do anything which may manipulate the DOM tree /// whilst iterating, otherwise the iterator may be invalidated. - pub fn query_selector_iter(&self, selectors: DOMString) -> Fallible<QuerySelectorIterator> { + pub(crate) fn query_selector_iter( + &self, + selectors: DOMString, + ) -> Fallible<QuerySelectorIterator> { // Step 1. let url = self.owner_doc().url(); match SelectorParser::parse_author_origin_no_namespace( @@ -1067,13 +1073,13 @@ impl Node { /// <https://dom.spec.whatwg.org/#dom-parentnode-queryselectorall> #[allow(unsafe_code)] - pub fn query_selector_all(&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> { + pub(crate) fn query_selector_all(&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> { let window = self.owner_window(); let iter = self.query_selector_iter(selectors)?; Ok(NodeList::new_simple_list(&window, iter)) } - pub fn ancestors(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn ancestors(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetParentNode(), next_node: |n| n.GetParentNode(), @@ -1081,7 +1087,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor> - pub fn inclusive_ancestors( + pub(crate) fn inclusive_ancestors( &self, shadow_including: ShadowIncluding, ) -> impl Iterator<Item = DomRoot<Node>> { @@ -1098,15 +1104,15 @@ impl Node { } } - pub fn owner_doc(&self) -> DomRoot<Document> { + pub(crate) fn owner_doc(&self) -> DomRoot<Document> { self.owner_doc.get().unwrap() } - pub fn set_owner_doc(&self, document: &Document) { + pub(crate) fn set_owner_doc(&self, document: &Document) { self.owner_doc.set(Some(document)); } - pub fn containing_shadow_root(&self) -> Option<DomRoot<ShadowRoot>> { + pub(crate) fn containing_shadow_root(&self) -> Option<DomRoot<ShadowRoot>> { self.rare_data() .as_ref()? .containing_shadow_root @@ -1114,45 +1120,45 @@ impl Node { .map(|sr| DomRoot::from_ref(&**sr)) } - pub fn set_containing_shadow_root(&self, shadow_root: Option<&ShadowRoot>) { + pub(crate) fn set_containing_shadow_root(&self, shadow_root: Option<&ShadowRoot>) { self.ensure_rare_data().containing_shadow_root = shadow_root.map(Dom::from_ref); } - pub fn is_in_html_doc(&self) -> bool { + pub(crate) fn is_in_html_doc(&self) -> bool { self.owner_doc().is_html_document() } - pub fn is_connected_with_browsing_context(&self) -> bool { + pub(crate) fn is_connected_with_browsing_context(&self) -> bool { self.is_connected() && self.owner_doc().browsing_context().is_some() } - pub fn children(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn children(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetFirstChild(), next_node: |n| n.GetNextSibling(), } } - pub fn rev_children(&self) -> impl Iterator<Item = DomRoot<Node>> { + pub(crate) fn rev_children(&self) -> impl Iterator<Item = DomRoot<Node>> { SimpleNodeIterator { current: self.GetLastChild(), next_node: |n| n.GetPreviousSibling(), } } - pub fn child_elements(&self) -> impl Iterator<Item = DomRoot<Element>> { + pub(crate) fn child_elements(&self) -> impl Iterator<Item = DomRoot<Element>> { self.children() .filter_map(DomRoot::downcast as fn(_) -> _) .peekable() } - pub fn remove_self(&self) { + pub(crate) fn remove_self(&self) { if let Some(ref parent) = self.GetParentNode() { Node::remove(self, parent, SuppressObserver::Unsuppressed); } } - pub fn unique_id(&self) -> String { + pub(crate) fn unique_id(&self) -> String { let mut rare_data = self.ensure_rare_data(); if rare_data.unique_id.is_none() { @@ -1169,7 +1175,7 @@ impl Node { .to_string() } - pub fn summarize(&self) -> NodeInfo { + pub(crate) fn summarize(&self) -> NodeInfo { let USVString(base_uri) = self.BaseURI(); let node_type = self.NodeType(); NodeInfo { @@ -1188,7 +1194,7 @@ impl Node { } /// Used by `HTMLTableSectionElement::InsertRow` and `HTMLTableRowElement::InsertCell` - pub fn insert_cell_or_row<F, G, I>( + pub(crate) fn insert_cell_or_row<F, G, I>( &self, index: i32, get_items: F, @@ -1229,7 +1235,7 @@ impl Node { } /// Used by `HTMLTableSectionElement::DeleteRow` and `HTMLTableRowElement::DeleteCell` - pub fn delete_cell_or_row<F, G>( + pub(crate) fn delete_cell_or_row<F, G>( &self, index: i32, get_items: F, @@ -1262,7 +1268,7 @@ impl Node { Ok(()) } - pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { + pub(crate) fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { if let Some(node) = self.downcast::<HTMLStyleElement>() { node.get_stylesheet() } else if let Some(node) = self.downcast::<HTMLLinkElement>() { @@ -1272,7 +1278,7 @@ impl Node { } } - pub fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn get_cssom_stylesheet(&self) -> Option<DomRoot<CSSStyleSheet>> { if let Some(node) = self.downcast::<HTMLStyleElement>() { node.get_cssom_stylesheet() } else if let Some(node) = self.downcast::<HTMLLinkElement>() { @@ -1282,11 +1288,11 @@ impl Node { } } - pub fn is_styled(&self) -> bool { + pub(crate) fn is_styled(&self) -> bool { self.style_data.borrow().is_some() } - pub fn is_display_none(&self) -> bool { + pub(crate) fn is_display_none(&self) -> bool { self.style_data.borrow().as_ref().map_or(true, |data| { data.element_data .borrow() @@ -1298,7 +1304,7 @@ impl Node { }) } - pub fn style(&self, can_gc: CanGc) -> Option<Arc<ComputedValues>> { + pub(crate) fn style(&self, can_gc: CanGc) -> Option<Arc<ComputedValues>> { if !self .owner_window() .layout_reflow(QueryMsg::StyleQuery, can_gc) @@ -1328,12 +1334,12 @@ where /// If the given untrusted node address represents a valid DOM node in the given runtime, /// returns it. #[allow(unsafe_code)] -pub unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress) -> DomRoot<Node> { +pub(crate) unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress) -> DomRoot<Node> { DomRoot::from_ref(Node::from_untrusted_node_address(candidate)) } #[allow(unsafe_code)] -pub trait LayoutNodeHelpers<'dom> { +pub(crate) trait LayoutNodeHelpers<'dom> { fn type_id_for_layout(self) -> NodeTypeId; fn composed_parent_node_ref(self) -> Option<LayoutDom<'dom, Node>>; @@ -1606,14 +1612,14 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> { // Iteration and traversal // -pub struct FollowingNodeIterator { +pub(crate) struct FollowingNodeIterator { current: Option<DomRoot<Node>>, root: DomRoot<Node>, } impl FollowingNodeIterator { /// Skips iterating the children of the current node - pub fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { + pub(crate) fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { let current = self.current.take()?; self.next_skipping_children_impl(current) } @@ -1659,7 +1665,7 @@ impl Iterator for FollowingNodeIterator { } } -pub struct PrecedingNodeIterator { +pub(crate) struct PrecedingNodeIterator { current: Option<DomRoot<Node>>, root: DomRoot<Node>, } @@ -1711,12 +1717,12 @@ where /// Whether a tree traversal should pass shadow tree boundaries. #[derive(Clone, Copy, PartialEq)] -pub enum ShadowIncluding { +pub(crate) enum ShadowIncluding { No, Yes, } -pub struct TreeIterator { +pub(crate) struct TreeIterator { current: Option<DomRoot<Node>>, depth: usize, shadow_including: bool, @@ -1731,7 +1737,7 @@ impl TreeIterator { } } - pub fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { + pub(crate) fn next_skipping_children(&mut self) -> Option<DomRoot<Node>> { let current = self.current.take()?; self.next_skipping_children_impl(current) @@ -1793,7 +1799,7 @@ impl Iterator for TreeIterator { /// Specifies whether children must be recursively cloned or not. #[derive(Clone, Copy, MallocSizeOf, PartialEq)] -pub enum CloneChildrenFlag { +pub(crate) enum CloneChildrenFlag { CloneChildren, DoNotCloneChildren, } @@ -1803,14 +1809,14 @@ fn as_uintptr<T>(t: &T) -> uintptr_t { } impl Node { - pub fn reflect_node<N>(node: Box<N>, document: &Document, can_gc: CanGc) -> DomRoot<N> + pub(crate) fn reflect_node<N>(node: Box<N>, document: &Document, can_gc: CanGc) -> DomRoot<N> where N: DerivedFrom<Node> + DomObject + DomObjectWrap, { Self::reflect_node_with_proto(node, document, None, can_gc) } - pub fn reflect_node_with_proto<N>( + pub(crate) fn reflect_node_with_proto<N>( node: Box<N>, document: &Document, proto: Option<HandleObject>, @@ -1823,12 +1829,12 @@ impl Node { reflect_dom_object_with_proto(node, window, proto, can_gc) } - pub fn new_inherited(doc: &Document) -> Node { + pub(crate) fn new_inherited(doc: &Document) -> Node { Node::new_(NodeFlags::empty(), Some(doc)) } #[allow(crown::unrooted_must_root)] - pub fn new_document_node() -> Node { + pub(crate) fn new_document_node() -> Node { Node::new_( NodeFlags::IS_IN_A_DOCUMENT_TREE | NodeFlags::IS_CONNECTED, None, @@ -1858,7 +1864,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-adopt> - pub fn adopt(node: &Node, document: &Document) { + pub(crate) fn adopt(node: &Node, document: &Document) { document.add_script_and_layout_blocker(); // Step 1. @@ -1894,7 +1900,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity> - pub fn ensure_pre_insertion_validity( + pub(crate) fn ensure_pre_insertion_validity( node: &Node, parent: &Node, child: Option<&Node>, @@ -2012,7 +2018,11 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-pre-insert> - pub fn pre_insert(node: &Node, parent: &Node, child: Option<&Node>) -> Fallible<DomRoot<Node>> { + pub(crate) fn pre_insert( + node: &Node, + parent: &Node, + child: Option<&Node>, + ) -> Fallible<DomRoot<Node>> { // Step 1. Node::ensure_pre_insertion_validity(node, parent, child)?; @@ -2173,7 +2183,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-replace-all> - pub fn replace_all(node: Option<&Node>, parent: &Node) { + pub(crate) fn replace_all(node: Option<&Node>, parent: &Node) { parent.owner_doc().add_script_and_layout_blocker(); // Step 1. if let Some(node) = node { @@ -2220,7 +2230,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/multipage/#string-replace-all> - pub fn string_replace_all(string: DOMString, parent: &Node, can_gc: CanGc) { + pub(crate) fn string_replace_all(string: DOMString, parent: &Node, can_gc: CanGc) { if string.len() == 0 { Node::replace_all(None, parent); } else { @@ -2296,7 +2306,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#concept-node-clone> - pub fn clone( + pub(crate) fn clone( node: &Node, maybe_doc: Option<&Document>, clone_children: CloneChildrenFlag, @@ -2481,16 +2491,18 @@ impl Node { } /// <https://html.spec.whatwg.org/multipage/#child-text-content> - pub fn child_text_content(&self) -> DOMString { + pub(crate) fn child_text_content(&self) -> DOMString { Node::collect_text_contents(self.children()) } /// <https://html.spec.whatwg.org/multipage/#descendant-text-content> - pub fn descendant_text_content(&self) -> DOMString { + pub(crate) fn descendant_text_content(&self) -> DOMString { Node::collect_text_contents(self.traverse_preorder(ShadowIncluding::No)) } - pub fn collect_text_contents<T: Iterator<Item = DomRoot<Node>>>(iterator: T) -> DOMString { + pub(crate) fn collect_text_contents<T: Iterator<Item = DomRoot<Node>>>( + iterator: T, + ) -> DOMString { let mut content = String::new(); for node in iterator { if let Some(text) = node.downcast::<Text>() { @@ -2500,7 +2512,7 @@ impl Node { DOMString::from(content) } - pub fn namespace_to_string(namespace: Namespace) -> Option<DOMString> { + pub(crate) fn namespace_to_string(namespace: Namespace) -> Option<DOMString> { match namespace { ns!() => None, // FIXME(ajeffrey): convert directly from Namespace to DOMString @@ -2509,7 +2521,7 @@ impl Node { } /// <https://dom.spec.whatwg.org/#locate-a-namespace> - pub fn locate_namespace(node: &Node, prefix: Option<DOMString>) -> Namespace { + pub(crate) fn locate_namespace(node: &Node, prefix: Option<DOMString>) -> Namespace { match node.type_id() { NodeTypeId::Element(_) => node.downcast::<Element>().unwrap().locate_namespace(prefix), NodeTypeId::Attr => node @@ -2540,7 +2552,9 @@ impl Node { /// Callers should ensure they pass an UntrustedNodeAddress that points to a valid [`JSObject`] /// in memory that represents a [`Node`]. #[allow(unsafe_code)] - pub unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress) -> &'static Self { + pub(crate) unsafe fn from_untrusted_node_address( + candidate: UntrustedNodeAddress, + ) -> &'static Self { // https://github.com/servo/servo/issues/6383 let candidate = candidate.0 as usize; let object = candidate as *mut JSObject; @@ -2550,7 +2564,10 @@ impl Node { &*(conversions::private_from_object(object) as *const Self) } - pub fn html_serialize(&self, traversal_scope: html_serialize::TraversalScope) -> DOMString { + pub(crate) fn html_serialize( + &self, + traversal_scope: html_serialize::TraversalScope, + ) -> DOMString { let mut writer = vec![]; html_serialize::serialize( &mut writer, @@ -2566,7 +2583,10 @@ impl Node { DOMString::from(String::from_utf8(writer).unwrap()) } - pub fn xml_serialize(&self, traversal_scope: xml_serialize::TraversalScope) -> DOMString { + pub(crate) fn xml_serialize( + &self, + traversal_scope: xml_serialize::TraversalScope, + ) -> DOMString { let mut writer = vec![]; xml_serialize::serialize( &mut writer, @@ -2580,7 +2600,7 @@ impl Node { } /// <https://html.spec.whatwg.org/multipage/#fragment-serializing-algorithm-steps> - pub fn fragment_serialization_algorithm(&self, require_well_formed: bool) -> DOMString { + pub(crate) fn fragment_serialization_algorithm(&self, require_well_formed: bool) -> DOMString { // Step 1. Let context document be node's node document. let context_document = self.owner_document(); @@ -3391,14 +3411,14 @@ impl VirtualMethods for Node { /// A summary of the changes that happened to a node. #[derive(Clone, Copy, MallocSizeOf, PartialEq)] -pub enum NodeDamage { +pub(crate) enum NodeDamage { /// The node's `style` attribute changed. NodeStyleDamaged, /// Other parts of a node changed; attributes, text content, etc. OtherNodeDamage, } -pub enum ChildrenMutation<'a> { +pub(crate) enum ChildrenMutation<'a> { Append { prev: &'a Node, added: &'a [&'a Node], @@ -3479,7 +3499,7 @@ impl<'a> ChildrenMutation<'a> { /// Currently only used when this mutation might force us to /// restyle later children (see HAS_SLOW_SELECTOR_LATER_SIBLINGS and /// Element's implementation of VirtualMethods::children_changed). - pub fn next_child(&self) -> Option<&Node> { + pub(crate) fn next_child(&self) -> Option<&Node> { match *self { ChildrenMutation::Append { .. } => None, ChildrenMutation::Insert { next, .. } => Some(next), @@ -3496,7 +3516,7 @@ impl<'a> ChildrenMutation<'a> { /// NOTE: This does not check whether the inserted/removed nodes were elements, so in some /// cases it will return a false positive. This doesn't matter for correctness, because at /// worst the returned element will be restyled unnecessarily. - pub fn modified_edge_element(&self) -> Option<DomRoot<Node>> { + pub(crate) fn modified_edge_element(&self) -> Option<DomRoot<Node>> { match *self { // Add/remove at start of container: Return the first following element. ChildrenMutation::Prepend { next, .. } | @@ -3554,57 +3574,57 @@ impl<'a> ChildrenMutation<'a> { } /// The context of the binding to tree of a node. -pub struct BindContext { +pub(crate) struct BindContext { /// Whether the tree is connected. /// /// <https://dom.spec.whatwg.org/#connected> - pub tree_connected: bool, + pub(crate) tree_connected: bool, /// Whether the tree's root is a document. /// /// <https://dom.spec.whatwg.org/#in-a-document-tree> - pub tree_is_in_a_document_tree: bool, + pub(crate) tree_is_in_a_document_tree: bool, /// Whether the tree's root is a shadow root - pub tree_is_in_a_shadow_tree: bool, + pub(crate) tree_is_in_a_shadow_tree: bool, } impl BindContext { /// Return true iff the tree is inside either a document- or a shadow tree. - pub fn is_in_tree(&self) -> bool { + pub(crate) fn is_in_tree(&self) -> bool { self.tree_is_in_a_document_tree || self.tree_is_in_a_shadow_tree } } /// The context of the unbinding from a tree of a node when one of its /// inclusive ancestors is removed. -pub struct UnbindContext<'a> { +pub(crate) struct UnbindContext<'a> { /// The index of the inclusive ancestor that was removed. index: Cell<Option<u32>>, /// The parent of the inclusive ancestor that was removed. - pub parent: &'a Node, + pub(crate) parent: &'a Node, /// The previous sibling of the inclusive ancestor that was removed. prev_sibling: Option<&'a Node>, /// The next sibling of the inclusive ancestor that was removed. - pub next_sibling: Option<&'a Node>, + pub(crate) next_sibling: Option<&'a Node>, /// Whether the tree is connected. /// /// <https://dom.spec.whatwg.org/#connected> - pub tree_connected: bool, + pub(crate) tree_connected: bool, /// Whether the tree's root is a document. /// /// <https://dom.spec.whatwg.org/#in-a-document-tree> - pub tree_is_in_a_document_tree: bool, + pub(crate) tree_is_in_a_document_tree: bool, /// Whether the tree's root is a shadow root - pub tree_is_in_a_shadow_tree: bool, + pub(crate) tree_is_in_a_shadow_tree: bool, } impl<'a> UnbindContext<'a> { /// Create a new `UnbindContext` value. - pub fn new( + pub(crate) fn new( parent: &'a Node, prev_sibling: Option<&'a Node>, next_sibling: Option<&'a Node>, @@ -3623,7 +3643,7 @@ impl<'a> UnbindContext<'a> { /// The index of the inclusive ancestor that was removed from the tree. #[allow(unsafe_code)] - pub fn index(&self) -> u32 { + pub(crate) fn index(&self) -> u32 { if let Some(index) = self.index.get() { return index; } @@ -3634,7 +3654,7 @@ impl<'a> UnbindContext<'a> { } /// A node's unique ID, for devtools. -pub struct UniqueId { +pub(crate) struct UniqueId { cell: UnsafeCell<Option<Box<Uuid>>>, } @@ -3757,7 +3777,7 @@ impl From<ElementTypeId> for LayoutElementType { /// Helper trait to insert an element into vector whose elements /// are maintained in tree order -pub trait VecPreOrderInsertionHelper<T> { +pub(crate) trait VecPreOrderInsertionHelper<T> { fn insert_pre_order(&mut self, elem: &T, tree_root: &Node); } diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index ede0cee139e..8467741c7e9 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -19,7 +19,7 @@ use crate::dom::node::Node; use crate::script_runtime::CanGc; #[dom_struct] -pub struct NodeIterator { +pub(crate) struct NodeIterator { reflector_: Reflector, root_node: Dom<Node>, #[ignore_malloc_size_of = "Defined in rust-mozjs"] @@ -44,7 +44,7 @@ impl NodeIterator { } } - pub fn new_with_filter( + pub(crate) fn new_with_filter( document: &Document, root_node: &Node, what_to_show: u32, @@ -57,7 +57,7 @@ impl NodeIterator { ) } - pub fn new( + pub(crate) fn new( document: &Document, root_node: &Node, what_to_show: u32, @@ -226,7 +226,7 @@ impl NodeIterator { } #[derive(JSTraceable)] -pub enum Filter { +pub(crate) enum Filter { None, Callback(Rc<NodeFilter>), } diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index cc2b60f7c8d..0900996a611 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -21,7 +21,7 @@ use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum NodeListType { +pub(crate) enum NodeListType { Simple(Vec<Dom<Node>>), Children(ChildrenList), Labels(LabelsList), @@ -31,14 +31,14 @@ pub enum NodeListType { // https://dom.spec.whatwg.org/#interface-nodelist #[dom_struct] -pub struct NodeList { +pub(crate) struct NodeList { reflector_: Reflector, list_type: NodeListType, } impl NodeList { #[allow(crown::unrooted_must_root)] - pub fn new_inherited(list_type: NodeListType) -> NodeList { + pub(crate) fn new_inherited(list_type: NodeListType) -> NodeList { NodeList { reflector_: Reflector::new(), list_type, @@ -46,7 +46,7 @@ impl NodeList { } #[allow(crown::unrooted_must_root)] - pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<NodeList> { + pub(crate) fn new(window: &Window, list_type: NodeListType) -> DomRoot<NodeList> { reflect_dom_object( Box::new(NodeList::new_inherited(list_type)), window, @@ -54,7 +54,7 @@ impl NodeList { ) } - pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<NodeList> + pub(crate) fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<NodeList> where T: Iterator<Item = DomRoot<Node>>, { @@ -64,22 +64,22 @@ impl NodeList { ) } - pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> DomRoot<NodeList> { + pub(crate) fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> DomRoot<NodeList> { NodeList::new( window, NodeListType::Simple(slice.iter().map(|r| Dom::from_ref(*r)).collect()), ) } - pub fn new_child_list(window: &Window, node: &Node) -> DomRoot<NodeList> { + pub(crate) fn new_child_list(window: &Window, node: &Node) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Children(ChildrenList::new(node))) } - pub fn new_labels_list(window: &Window, element: &HTMLElement) -> DomRoot<NodeList> { + pub(crate) fn new_labels_list(window: &Window, element: &HTMLElement) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Labels(LabelsList::new(element))) } - pub fn new_elements_by_name_list( + pub(crate) fn new_elements_by_name_list( window: &Window, document: &Document, name: DOMString, @@ -90,7 +90,7 @@ impl NodeList { ) } - pub fn empty(window: &Window) -> DomRoot<NodeList> { + pub(crate) fn empty(window: &Window) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Simple(vec![])) } } @@ -127,7 +127,7 @@ impl NodeListMethods<crate::DomTypeHolder> for NodeList { } impl NodeList { - pub fn as_children_list(&self) -> &ChildrenList { + pub(crate) fn as_children_list(&self) -> &ChildrenList { if let NodeListType::Children(ref list) = self.list_type { list } else { @@ -135,7 +135,7 @@ impl NodeList { } } - pub fn as_radio_list(&self) -> &RadioList { + pub(crate) fn as_radio_list(&self) -> &RadioList { if let NodeListType::Radio(ref list) = self.list_type { list } else { @@ -143,7 +143,7 @@ impl NodeList { } } - pub fn iter(&self) -> impl Iterator<Item = DomRoot<Node>> + '_ { + pub(crate) fn iter(&self) -> impl Iterator<Item = DomRoot<Node>> + '_ { let len = self.Length(); // There is room for optimization here in non-simple cases, // as calling Item repeatedly on a live list can involve redundant work. @@ -153,7 +153,7 @@ impl NodeList { #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct ChildrenList { +pub(crate) struct ChildrenList { node: Dom<Node>, #[ignore_malloc_size_of = "Defined in rust-mozjs"] last_visited: MutNullableDom<Node>, @@ -161,7 +161,7 @@ pub struct ChildrenList { } impl ChildrenList { - pub fn new(node: &Node) -> ChildrenList { + pub(crate) fn new(node: &Node) -> ChildrenList { let last_visited = node.GetFirstChild(); ChildrenList { node: Dom::from_ref(node), @@ -170,11 +170,11 @@ impl ChildrenList { } } - pub fn len(&self) -> u32 { + pub(crate) fn len(&self) -> u32 { self.node.children_count() } - pub fn item(&self, index: u32) -> Option<DomRoot<Node>> { + pub(crate) fn item(&self, index: u32) -> Option<DomRoot<Node>> { // This always start traversing the children from the closest element // among parent's first and last children and the last visited one. let len = self.len(); @@ -246,7 +246,7 @@ impl ChildrenList { Some(last_visited) } - pub fn children_changed(&self, mutation: &ChildrenMutation) { + pub(crate) fn children_changed(&self, mutation: &ChildrenMutation) { fn prepend(list: &ChildrenList, added: &[&Node], next: &Node) { let len = added.len() as u32; if len == 0u32 { @@ -363,22 +363,22 @@ impl ChildrenList { // than recalculating labels. #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct LabelsList { +pub(crate) struct LabelsList { element: Dom<HTMLElement>, } impl LabelsList { - pub fn new(element: &HTMLElement) -> LabelsList { + pub(crate) fn new(element: &HTMLElement) -> LabelsList { LabelsList { element: Dom::from_ref(element), } } - pub fn len(&self) -> u32 { + pub(crate) fn len(&self) -> u32 { self.element.labels_count() } - pub fn item(&self, index: u32) -> Option<DomRoot<Node>> { + pub(crate) fn item(&self, index: u32) -> Option<DomRoot<Node>> { self.element.label_at(index) } } @@ -389,14 +389,14 @@ impl LabelsList { // just by hooking into what the form already knows without a // separate mutation observer. FIXME #25482 #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] -pub enum RadioListMode { +pub(crate) enum RadioListMode { ControlsExceptImageInputs, Images, } #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct RadioList { +pub(crate) struct RadioList { form: Dom<HTMLFormElement>, mode: RadioListMode, #[no_trace] @@ -404,7 +404,7 @@ pub struct RadioList { } impl RadioList { - pub fn new(form: &HTMLFormElement, mode: RadioListMode, name: Atom) -> RadioList { + pub(crate) fn new(form: &HTMLFormElement, mode: RadioListMode, name: Atom) -> RadioList { RadioList { form: Dom::from_ref(form), mode, @@ -412,35 +412,35 @@ impl RadioList { } } - pub fn len(&self) -> u32 { + pub(crate) fn len(&self) -> u32 { self.form.count_for_radio_list(self.mode, &self.name) } - pub fn item(&self, index: u32) -> Option<DomRoot<Node>> { + pub(crate) fn item(&self, index: u32) -> Option<DomRoot<Node>> { self.form.nth_for_radio_list(index, self.mode, &self.name) } } #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct ElementsByNameList { +pub(crate) struct ElementsByNameList { document: Dom<Document>, name: DOMString, } impl ElementsByNameList { - pub fn new(document: &Document, name: DOMString) -> ElementsByNameList { + pub(crate) fn new(document: &Document, name: DOMString) -> ElementsByNameList { ElementsByNameList { document: Dom::from_ref(document), name, } } - pub fn len(&self) -> u32 { + pub(crate) fn len(&self) -> u32 { self.document.elements_by_name_count(&self.name) } - pub fn item(&self, index: u32) -> Option<DomRoot<Node>> { + pub(crate) fn item(&self, index: u32) -> Option<DomRoot<Node>> { self.document .nth_element_by_name(index, &self.name) .map(|n| DomRoot::from_ref(&*n)) diff --git a/components/script/dom/offlineaudiocompletionevent.rs b/components/script/dom/offlineaudiocompletionevent.rs index ab9144964dd..e40f7014214 100644 --- a/components/script/dom/offlineaudiocompletionevent.rs +++ b/components/script/dom/offlineaudiocompletionevent.rs @@ -21,20 +21,20 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OfflineAudioCompletionEvent { +pub(crate) struct OfflineAudioCompletionEvent { event: Event, rendered_buffer: Dom<AudioBuffer>, } impl OfflineAudioCompletionEvent { - pub fn new_inherited(rendered_buffer: &AudioBuffer) -> OfflineAudioCompletionEvent { + pub(crate) fn new_inherited(rendered_buffer: &AudioBuffer) -> OfflineAudioCompletionEvent { OfflineAudioCompletionEvent { event: Event::new_inherited(), rendered_buffer: Dom::from_ref(rendered_buffer), } } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 5cda35e4e10..55047da46b8 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -34,7 +34,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OfflineAudioContext { +pub(crate) struct OfflineAudioContext { context: BaseAudioContext, channel_count: u32, length: u32, diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs index a33aea573eb..d57599217ca 100644 --- a/components/script/dom/offscreencanvas.rs +++ b/components/script/dom/offscreencanvas.rs @@ -27,14 +27,14 @@ use crate::script_runtime::{CanGc, JSContext}; #[crown::unrooted_must_root_lint::must_root] #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum OffscreenCanvasContext { +pub(crate) enum OffscreenCanvasContext { OffscreenContext2d(Dom<OffscreenCanvasRenderingContext2D>), //WebGL(Dom<WebGLRenderingContext>), //WebGL2(Dom<WebGL2RenderingContext>), } #[dom_struct] -pub struct OffscreenCanvas { +pub(crate) struct OffscreenCanvas { eventtarget: EventTarget, width: Cell<u64>, height: Cell<u64>, @@ -43,7 +43,7 @@ pub struct OffscreenCanvas { } impl OffscreenCanvas { - pub fn new_inherited( + pub(crate) fn new_inherited( width: u64, height: u64, placeholder: Option<&HTMLCanvasElement>, @@ -73,11 +73,11 @@ impl OffscreenCanvas { ) } - pub fn get_size(&self) -> Size2D<u64> { + pub(crate) fn get_size(&self) -> Size2D<u64> { Size2D::new(self.Width(), self.Height()) } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { match *self.context.borrow() { Some(OffscreenCanvasContext::OffscreenContext2d(ref context)) => { context.origin_is_clean() @@ -86,11 +86,11 @@ impl OffscreenCanvas { } } - pub fn context(&self) -> Option<Ref<OffscreenCanvasContext>> { + pub(crate) fn context(&self) -> Option<Ref<OffscreenCanvasContext>> { ref_filter_map(self.context.borrow(), |ctx| ctx.as_ref()) } - pub fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> { + pub(crate) fn fetch_all_data(&self) -> Option<(Option<IpcSharedMemory>, Size2D<u32>)> { let size = self.get_size(); if size.width == 0 || size.height == 0 { @@ -133,7 +133,7 @@ impl OffscreenCanvas { Some(context) } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { self.Width() != 0 && self.Height() != 0 } } diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 974ee519ec4..67dae84012a 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -30,7 +30,7 @@ use crate::dom::textmetrics::TextMetrics; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OffscreenCanvasRenderingContext2D { +pub(crate) struct OffscreenCanvasRenderingContext2D { reflector_: Reflector, canvas: Dom<OffscreenCanvas>, canvas_state: CanvasState, @@ -51,7 +51,7 @@ impl OffscreenCanvasRenderingContext2D { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, canvas: &OffscreenCanvas, htmlcanvas: Option<&HTMLCanvasElement>, @@ -62,23 +62,23 @@ impl OffscreenCanvasRenderingContext2D { reflect_dom_object(boxed, global, CanGc::note()) } - pub fn set_canvas_bitmap_dimensions(&self, size: Size2D<u64>) { + pub(crate) fn set_canvas_bitmap_dimensions(&self, size: Size2D<u64>) { self.canvas_state.set_bitmap_dimensions(size); } - pub fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { + pub(crate) fn send_canvas_2d_msg(&self, msg: Canvas2dMsg) { self.canvas_state.send_canvas_2d_msg(msg) } - pub fn origin_is_clean(&self) -> bool { + pub(crate) fn origin_is_clean(&self) -> bool { self.canvas_state.origin_is_clean() } - pub fn get_canvas_id(&self) -> CanvasId { + pub(crate) fn get_canvas_id(&self) -> CanvasId { self.canvas_state.get_canvas_id() } - pub fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> { + pub(crate) fn get_ipc_renderer(&self) -> IpcSender<CanvasMsg> { self.canvas_state.get_ipc_renderer().clone() } } diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index c9b349e4e60..c05a95fdd69 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -32,7 +32,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OscillatorNode { +pub(crate) struct OscillatorNode { source_node: AudioScheduledSourceNode, detune: Dom<AudioParam>, frequency: Dom<AudioParam>, @@ -41,7 +41,7 @@ pub struct OscillatorNode { impl OscillatorNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, options: &OscillatorOptions, @@ -88,7 +88,7 @@ impl OscillatorNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &OscillatorOptions, diff --git a/components/script/dom/pagetransitionevent.rs b/components/script/dom/pagetransitionevent.rs index 4718f86afca..6437ef50ad5 100644 --- a/components/script/dom/pagetransitionevent.rs +++ b/components/script/dom/pagetransitionevent.rs @@ -22,7 +22,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#pagetransitionevent #[dom_struct] -pub struct PageTransitionEvent { +pub(crate) struct PageTransitionEvent { event: Event, persisted: Cell<bool>, } @@ -48,7 +48,7 @@ impl PageTransitionEvent { ) } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, bubbles: bool, diff --git a/components/script/dom/paintrenderingcontext2d.rs b/components/script/dom/paintrenderingcontext2d.rs index f6c906b2c06..352d948ab03 100644 --- a/components/script/dom/paintrenderingcontext2d.rs +++ b/components/script/dom/paintrenderingcontext2d.rs @@ -32,7 +32,7 @@ use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PaintRenderingContext2D { +pub(crate) struct PaintRenderingContext2D { context: CanvasRenderingContext2D, #[no_trace] device_pixel_ratio: Cell<Scale<f32, CSSPixel, DevicePixel>>, @@ -47,7 +47,7 @@ impl PaintRenderingContext2D { } } - pub fn new(global: &PaintWorkletGlobalScope) -> DomRoot<PaintRenderingContext2D> { + pub(crate) fn new(global: &PaintWorkletGlobalScope) -> DomRoot<PaintRenderingContext2D> { reflect_dom_object( Box::new(PaintRenderingContext2D::new_inherited(global)), global, @@ -55,7 +55,7 @@ impl PaintRenderingContext2D { ) } - pub fn send_data(&self, sender: IpcSender<CanvasImageData>) { + pub(crate) fn send_data(&self, sender: IpcSender<CanvasImageData>) { let msg = CanvasMsg::FromLayout( FromLayoutMsg::SendData(sender), self.context.get_canvas_id(), @@ -63,11 +63,11 @@ impl PaintRenderingContext2D { let _ = self.context.get_ipc_renderer().send(msg); } - pub fn take_missing_image_urls(&self) -> Vec<ServoUrl> { + pub(crate) fn take_missing_image_urls(&self) -> Vec<ServoUrl> { self.context.take_missing_image_urls() } - pub fn set_bitmap_dimensions( + pub(crate) fn set_bitmap_dimensions( &self, size: Size2D<f32, CSSPixel>, device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>, diff --git a/components/script/dom/paintsize.rs b/components/script/dom/paintsize.rs index 09cde954640..573e6146860 100644 --- a/components/script/dom/paintsize.rs +++ b/components/script/dom/paintsize.rs @@ -14,7 +14,7 @@ use crate::dom::paintworkletglobalscope::PaintWorkletGlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PaintSize { +pub(crate) struct PaintSize { reflector: Reflector, width: Finite<f64>, height: Finite<f64>, @@ -29,7 +29,7 @@ impl PaintSize { } } - pub fn new( + pub(crate) fn new( global: &PaintWorkletGlobalScope, size: Size2D<f32, CSSPixel>, ) -> DomRoot<PaintSize> { diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index efcbe332b62..b806927a9b9 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -53,7 +53,7 @@ use crate::script_runtime::JSContext; /// <https://drafts.css-houdini.org/css-paint-api/#paintworkletglobalscope> #[dom_struct] -pub struct PaintWorkletGlobalScope { +pub(crate) struct PaintWorkletGlobalScope { /// The worklet global for this object worklet_global: WorkletGlobalScope, /// The image cache @@ -123,11 +123,11 @@ impl PaintWorkletGlobalScope { unsafe { PaintWorkletGlobalScopeBinding::Wrap(JSContext::from_ptr(runtime.cx()), global) } } - pub fn image_cache(&self) -> Arc<dyn ImageCache> { + pub(crate) fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } - pub fn perform_a_worklet_task(&self, task: PaintWorkletTask) { + pub(crate) fn perform_a_worklet_task(&self, task: PaintWorkletTask) { match task { PaintWorkletTask::DrawAPaintImage( name, @@ -436,7 +436,7 @@ impl PaintWorkletGlobalScope { } /// Tasks which can be peformed by a paint worklet -pub enum PaintWorkletTask { +pub(crate) enum PaintWorkletTask { DrawAPaintImage( Atom, Size2D<f32, CSSPixel>, diff --git a/components/script/dom/pannernode.rs b/components/script/dom/pannernode.rs index 5600342bc15..4ebcf4abc6b 100644 --- a/components/script/dom/pannernode.rs +++ b/components/script/dom/pannernode.rs @@ -35,7 +35,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PannerNode { +pub(crate) struct PannerNode { node: AudioNode, position_x: Dom<AudioParam>, position_y: Dom<AudioParam>, @@ -59,7 +59,7 @@ pub struct PannerNode { impl PannerNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, options: &PannerOptions, @@ -181,7 +181,7 @@ impl PannerNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &PannerOptions, diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 7c212e22511..76c39a1f318 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -59,17 +59,17 @@ const INVALID_ENTRY_NAMES: &[&str] = &[ /// Implementation of a list of PerformanceEntry items shared by the /// Performance and PerformanceObserverEntryList interfaces implementations. #[derive(JSTraceable, MallocSizeOf)] -pub struct PerformanceEntryList { +pub(crate) struct PerformanceEntryList { /// <https://w3c.github.io/performance-timeline/#dfn-performance-entry-buffer> entries: DOMPerformanceEntryList, } impl PerformanceEntryList { - pub fn new(entries: DOMPerformanceEntryList) -> Self { + pub(crate) fn new(entries: DOMPerformanceEntryList) -> Self { PerformanceEntryList { entries } } - pub fn get_entries_by_name_and_type( + pub(crate) fn get_entries_by_name_and_type( &self, name: Option<DOMString>, entry_type: Option<DOMString>, @@ -93,7 +93,7 @@ impl PerformanceEntryList { res } - pub fn clear_entries_by_name_and_type( + pub(crate) fn clear_entries_by_name_and_type( &mut self, name: Option<DOMString>, entry_type: DOMString, @@ -132,7 +132,7 @@ struct PerformanceObserver { } #[dom_struct] -pub struct Performance { +pub(crate) struct Performance { eventtarget: EventTarget, buffer: DomRefCell<PerformanceEntryList>, observers: DomRefCell<Vec<PerformanceObserver>>, @@ -165,7 +165,7 @@ impl Performance { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, navigation_start: CrossProcessInstant, ) -> DomRoot<Performance> { @@ -193,7 +193,7 @@ impl Performance { /// Clear all buffered performance entries, and disable the buffer. /// Called as part of the window's "clear_js_runtime" workflow, /// performed when exiting a pipeline. - pub fn clear_and_disable_performance_entry_buffer(&self) { + pub(crate) fn clear_and_disable_performance_entry_buffer(&self) { let mut buffer = self.buffer.borrow_mut(); buffer.entries.clear(); self.resource_timing_buffer_size_limit.set(0); @@ -202,7 +202,7 @@ impl Performance { // Add a PerformanceObserver to the list of observers with a set of // observed entry types. - pub fn add_multiple_type_observer( + pub(crate) fn add_multiple_type_observer( &self, observer: &DOMPerformanceObserver, entry_types: Vec<DOMString>, @@ -220,7 +220,7 @@ impl Performance { }; } - pub fn add_single_type_observer( + pub(crate) fn add_single_type_observer( &self, observer: &DOMPerformanceObserver, entry_type: &DOMString, @@ -267,7 +267,7 @@ impl Performance { } /// Remove a PerformanceObserver from the list of observers. - pub fn remove_observer(&self, observer: &DOMPerformanceObserver) { + pub(crate) fn remove_observer(&self, observer: &DOMPerformanceObserver) { let mut observers = self.observers.borrow_mut(); let index = match observers.iter().position(|o| &(*o.observer) == observer) { Some(p) => p, @@ -285,7 +285,7 @@ impl Performance { /// <https://w3c.github.io/performance-timeline/#queue-a-performanceentry> /// Also this algorithm has been extented according to : /// <https://w3c.github.io/resource-timing/#sec-extensions-performance-interface> - pub fn queue_entry(&self, entry: &PerformanceEntry, can_gc: CanGc) -> Option<usize> { + pub(crate) fn queue_entry(&self, entry: &PerformanceEntry, can_gc: CanGc) -> Option<usize> { // https://w3c.github.io/performance-timeline/#dfn-determine-eligibility-for-adding-a-performance-entry if entry.entry_type() == "resource" && !self.should_queue_resource_entry(entry, can_gc) { return None; @@ -339,7 +339,7 @@ impl Performance { /// /// Algorithm spec (step 7): /// <https://w3c.github.io/performance-timeline/#queue-a-performanceentry> - pub fn notify_observers(&self) { + pub(crate) fn notify_observers(&self) { // Step 7.1. self.pending_notification_observers_task.set(false); @@ -422,7 +422,7 @@ impl Performance { false } - pub fn update_entry(&self, index: usize, entry: &PerformanceEntry) { + pub(crate) fn update_entry(&self, index: usize, entry: &PerformanceEntry) { if let Some(e) = self.buffer.borrow_mut().entries.get_mut(index) { *e = DomRoot::from_ref(entry); } diff --git a/components/script/dom/performanceentry.rs b/components/script/dom/performanceentry.rs index ee639856894..8c3fb3e1120 100644 --- a/components/script/dom/performanceentry.rs +++ b/components/script/dom/performanceentry.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PerformanceEntry { +pub(crate) struct PerformanceEntry { reflector_: Reflector, name: DOMString, entry_type: DOMString, @@ -30,7 +30,7 @@ pub struct PerformanceEntry { } impl PerformanceEntry { - pub fn new_inherited( + pub(crate) fn new_inherited( name: DOMString, entry_type: DOMString, start_time: Option<CrossProcessInstant>, @@ -46,7 +46,7 @@ impl PerformanceEntry { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, name: DOMString, entry_type: DOMString, @@ -57,19 +57,19 @@ impl PerformanceEntry { reflect_dom_object(Box::new(entry), global, CanGc::note()) } - pub fn entry_type(&self) -> &DOMString { + pub(crate) fn entry_type(&self) -> &DOMString { &self.entry_type } - pub fn name(&self) -> &DOMString { + pub(crate) fn name(&self) -> &DOMString { &self.name } - pub fn start_time(&self) -> Option<CrossProcessInstant> { + pub(crate) fn start_time(&self) -> Option<CrossProcessInstant> { self.start_time } - pub fn duration(&self) -> Duration { + pub(crate) fn duration(&self) -> Duration { self.duration } } diff --git a/components/script/dom/performancenavigation.rs b/components/script/dom/performancenavigation.rs index 92863b6bd8b..fb97a373e24 100644 --- a/components/script/dom/performancenavigation.rs +++ b/components/script/dom/performancenavigation.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PerformanceNavigation { +pub(crate) struct PerformanceNavigation { reflector_: Reflector, } @@ -25,7 +25,7 @@ impl PerformanceNavigation { } } - pub fn new(global: &GlobalScope) -> DomRoot<PerformanceNavigation> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<PerformanceNavigation> { reflect_dom_object( Box::new(PerformanceNavigation::new_inherited()), global, diff --git a/components/script/dom/performancenavigationtiming.rs b/components/script/dom/performancenavigationtiming.rs index 955cc09423d..e28b669713b 100644 --- a/components/script/dom/performancenavigationtiming.rs +++ b/components/script/dom/performancenavigationtiming.rs @@ -21,7 +21,7 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/navigation-timing/#dom-performancenavigationtiming /// Only the current document resource is included in the performance timeline; /// there is only one PerformanceNavigationTiming object in the performance timeline. -pub struct PerformanceNavigationTiming { +pub(crate) struct PerformanceNavigationTiming { // https://w3c.github.io/navigation-timing/#PerformanceResourceTiming performanceresourcetiming: PerformanceResourceTiming, document: Dom<Document>, @@ -45,7 +45,7 @@ impl PerformanceNavigationTiming { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, fetch_start: CrossProcessInstant, document: &Document, diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index c65d1555c5b..a3093ed9815 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -26,7 +26,7 @@ use crate::dom::performanceobserverentrylist::PerformanceObserverEntryList; use crate::script_runtime::{CanGc, JSContext}; /// List of allowed performance entry types, in alphabetical order. -pub const VALID_ENTRY_TYPES: &[&str] = &[ +pub(crate) const VALID_ENTRY_TYPES: &[&str] = &[ // "frame", //TODO Frame Timing API "mark", // User Timing API "measure", // User Timing API @@ -44,7 +44,7 @@ enum ObserverType { } #[dom_struct] -pub struct PerformanceObserver { +pub(crate) struct PerformanceObserver { reflector_: Reflector, #[ignore_malloc_size_of = "can't measure Rc values"] callback: Rc<PerformanceObserverCallback>, @@ -65,7 +65,7 @@ impl PerformanceObserver { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, callback: Rc<PerformanceObserverCallback>, entries: DOMPerformanceEntryList, @@ -87,13 +87,13 @@ impl PerformanceObserver { } /// Buffer a new performance entry. - pub fn queue_entry(&self, entry: &PerformanceEntry) { + pub(crate) fn queue_entry(&self, entry: &PerformanceEntry) { self.entries.borrow_mut().push(DomRoot::from_ref(entry)); } /// Trigger performance observer callback with the list of performance entries /// buffered since the last callback call. - pub fn notify(&self) { + pub(crate) fn notify(&self) { if self.entries.borrow().is_empty() { return; } @@ -105,15 +105,15 @@ impl PerformanceObserver { .Call_(self, &observer_entry_list, self, ExceptionHandling::Report); } - pub fn callback(&self) -> Rc<PerformanceObserverCallback> { + pub(crate) fn callback(&self) -> Rc<PerformanceObserverCallback> { self.callback.clone() } - pub fn entries(&self) -> DOMPerformanceEntryList { + pub(crate) fn entries(&self) -> DOMPerformanceEntryList { self.entries.borrow().clone() } - pub fn set_entries(&self, entries: DOMPerformanceEntryList) { + pub(crate) fn set_entries(&self, entries: DOMPerformanceEntryList) { *self.entries.borrow_mut() = entries; } } diff --git a/components/script/dom/performanceobserverentrylist.rs b/components/script/dom/performanceobserverentrylist.rs index 12e706abfa2..71e97fdb925 100644 --- a/components/script/dom/performanceobserverentrylist.rs +++ b/components/script/dom/performanceobserverentrylist.rs @@ -15,7 +15,7 @@ use crate::dom::performanceentry::PerformanceEntry; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PerformanceObserverEntryList { +pub(crate) struct PerformanceObserverEntryList { reflector_: Reflector, entries: DomRefCell<PerformanceEntryList>, } @@ -29,7 +29,7 @@ impl PerformanceObserverEntryList { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, entries: PerformanceEntryList, ) -> DomRoot<PerformanceObserverEntryList> { diff --git a/components/script/dom/performancepainttiming.rs b/components/script/dom/performancepainttiming.rs index 6bfc06e1bd1..0e556f3c13c 100644 --- a/components/script/dom/performancepainttiming.rs +++ b/components/script/dom/performancepainttiming.rs @@ -15,7 +15,7 @@ use crate::dom::performanceentry::PerformanceEntry; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PerformancePaintTiming { +pub(crate) struct PerformancePaintTiming { entry: PerformanceEntry, } @@ -42,7 +42,7 @@ impl PerformancePaintTiming { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, metric_type: ProgressiveWebMetricType, start_time: CrossProcessInstant, diff --git a/components/script/dom/performanceresourcetiming.rs b/components/script/dom/performanceresourcetiming.rs index d571a04c5d9..02e703fcdab 100644 --- a/components/script/dom/performanceresourcetiming.rs +++ b/components/script/dom/performanceresourcetiming.rs @@ -25,7 +25,7 @@ use crate::script_runtime::CanGc; // TODO CSS, Beacon #[derive(Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum InitiatorType { +pub(crate) enum InitiatorType { LocalName(String), Navigation, XMLHttpRequest, @@ -34,7 +34,7 @@ pub enum InitiatorType { } #[dom_struct] -pub struct PerformanceResourceTiming { +pub(crate) struct PerformanceResourceTiming { entry: PerformanceEntry, initiator_type: InitiatorType, next_hop: Option<DOMString>, @@ -75,7 +75,7 @@ pub struct PerformanceResourceTiming { // TODO(#21261): connect_start // TODO(#21262): connect_end impl PerformanceResourceTiming { - pub fn new_inherited( + pub(crate) fn new_inherited( url: ServoUrl, initiator_type: InitiatorType, next_hop: Option<DOMString>, @@ -153,7 +153,7 @@ impl PerformanceResourceTiming { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, url: ServoUrl, initiator_type: InitiatorType, diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs index d4f78d4fb63..badadb9b0ee 100644 --- a/components/script/dom/permissions.rs +++ b/components/script/dom/permissions.rs @@ -28,7 +28,7 @@ use crate::dom::promise::Promise; use crate::realms::{AlreadyInRealm, InRealm}; use crate::script_runtime::{CanGc, JSContext}; -pub trait PermissionAlgorithm { +pub(crate) trait PermissionAlgorithm { type Descriptor; #[crown::unrooted_must_root_lint::must_root] type Status; @@ -59,18 +59,18 @@ enum Operation { // https://w3c.github.io/permissions/#permissions #[dom_struct] -pub struct Permissions { +pub(crate) struct Permissions { reflector_: Reflector, } impl Permissions { - pub fn new_inherited() -> Permissions { + pub(crate) fn new_inherited() -> Permissions { Permissions { reflector_: Reflector::new(), } } - pub fn new(global: &GlobalScope) -> DomRoot<Permissions> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<Permissions> { reflect_dom_object( Box::new(Permissions::new_inherited()), global, @@ -284,7 +284,7 @@ impl PermissionAlgorithm for Permissions { } // https://w3c.github.io/permissions/#permission-state -pub fn get_descriptor_permission_state( +pub(crate) fn get_descriptor_permission_state( permission_name: PermissionName, env_settings_obj: Option<&GlobalScope>, ) -> PermissionState { diff --git a/components/script/dom/permissionstatus.rs b/components/script/dom/permissionstatus.rs index d34d4a58213..4fe4a3acbfe 100644 --- a/components/script/dom/permissionstatus.rs +++ b/components/script/dom/permissionstatus.rs @@ -18,14 +18,14 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/permissions/#permissionstatus #[dom_struct] -pub struct PermissionStatus { +pub(crate) struct PermissionStatus { eventtarget: EventTarget, state: Cell<PermissionState>, query: Cell<PermissionName>, } impl PermissionStatus { - pub fn new_inherited(query: PermissionName) -> PermissionStatus { + pub(crate) fn new_inherited(query: PermissionName) -> PermissionStatus { PermissionStatus { eventtarget: EventTarget::new_inherited(), state: Cell::new(PermissionState::Denied), @@ -33,7 +33,10 @@ impl PermissionStatus { } } - pub fn new(global: &GlobalScope, query: &PermissionDescriptor) -> DomRoot<PermissionStatus> { + pub(crate) fn new( + global: &GlobalScope, + query: &PermissionDescriptor, + ) -> DomRoot<PermissionStatus> { reflect_dom_object( Box::new(PermissionStatus::new_inherited(query.name)), global, @@ -41,11 +44,11 @@ impl PermissionStatus { ) } - pub fn set_state(&self, state: PermissionState) { + pub(crate) fn set_state(&self, state: PermissionState) { self.state.set(state); } - pub fn get_query(&self) -> PermissionName { + pub(crate) fn get_query(&self) -> PermissionName { self.query.get() } } diff --git a/components/script/dom/plugin.rs b/components/script/dom/plugin.rs index 8352acf3c95..96035623748 100644 --- a/components/script/dom/plugin.rs +++ b/components/script/dom/plugin.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::str::DOMString; use crate::dom::mimetype::MimeType; #[dom_struct] -pub struct Plugin { +pub(crate) struct Plugin { reflector_: Reflector, } diff --git a/components/script/dom/pluginarray.rs b/components/script/dom/pluginarray.rs index fba0efa7093..fc5b9dd5ad7 100644 --- a/components/script/dom/pluginarray.rs +++ b/components/script/dom/pluginarray.rs @@ -13,18 +13,18 @@ use crate::dom::plugin::Plugin; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PluginArray { +pub(crate) struct PluginArray { reflector_: Reflector, } impl PluginArray { - pub fn new_inherited() -> PluginArray { + pub(crate) fn new_inherited() -> PluginArray { PluginArray { reflector_: Reflector::new(), } } - pub fn new(global: &GlobalScope) -> DomRoot<PluginArray> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<PluginArray> { reflect_dom_object( Box::new(PluginArray::new_inherited()), global, diff --git a/components/script/dom/pointerevent.rs b/components/script/dom/pointerevent.rs index 1c95723c140..719518c64b2 100644 --- a/components/script/dom/pointerevent.rs +++ b/components/script/dom/pointerevent.rs @@ -24,7 +24,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct PointerEvent { +pub(crate) struct PointerEvent { mouseevent: MouseEvent, pointer_id: Cell<i32>, width: Cell<i32>, @@ -43,7 +43,7 @@ pub struct PointerEvent { } impl PointerEvent { - pub fn new_inherited() -> PointerEvent { + pub(crate) fn new_inherited() -> PointerEvent { PointerEvent { mouseevent: MouseEvent::new_inherited(), pointer_id: Cell::new(0), @@ -63,7 +63,7 @@ impl PointerEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<PointerEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<PointerEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } @@ -81,7 +81,7 @@ impl PointerEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, proto: Option<HandleObject>, type_: DOMString, diff --git a/components/script/dom/popstateevent.rs b/components/script/dom/popstateevent.rs index b7140a0661d..99ba0f58b14 100644 --- a/components/script/dom/popstateevent.rs +++ b/components/script/dom/popstateevent.rs @@ -24,7 +24,7 @@ use crate::script_runtime::{CanGc, JSContext}; // https://html.spec.whatwg.org/multipage/#the-popstateevent-interface #[dom_struct] -pub struct PopStateEvent { +pub(crate) struct PopStateEvent { event: Event, #[ignore_malloc_size_of = "Defined in rust-mozjs"] state: Heap<JSVal>, @@ -69,7 +69,7 @@ impl PopStateEvent { ev } - pub fn dispatch_jsval( + pub(crate) fn dispatch_jsval( target: &EventTarget, window: &Window, state: HandleValue, diff --git a/components/script/dom/processinginstruction.rs b/components/script/dom/processinginstruction.rs index d09b1b9cd7d..ce884db8eea 100644 --- a/components/script/dom/processinginstruction.rs +++ b/components/script/dom/processinginstruction.rs @@ -14,7 +14,7 @@ use crate::script_runtime::CanGc; /// An HTML processing instruction node. #[dom_struct] -pub struct ProcessingInstruction { +pub(crate) struct ProcessingInstruction { characterdata: CharacterData, target: DOMString, } @@ -31,7 +31,7 @@ impl ProcessingInstruction { } } - pub fn new( + pub(crate) fn new( target: DOMString, data: DOMString, document: &Document, @@ -46,7 +46,7 @@ impl ProcessingInstruction { } impl ProcessingInstruction { - pub fn target(&self) -> &DOMString { + pub(crate) fn target(&self) -> &DOMString { &self.target } } diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index e46e0a314a4..1041ff750ea 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -19,7 +19,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ProgressEvent { +pub(crate) struct ProgressEvent { event: Event, length_computable: bool, loaded: u64, @@ -37,7 +37,7 @@ impl ProgressEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, can_bubble: EventBubbles, diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index c56d7e91349..41c40fce556 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -42,7 +42,7 @@ use crate::script_thread::ScriptThread; #[dom_struct] #[crown::unrooted_must_root_lint::allow_unrooted_in_rc] -pub struct Promise { +pub(crate) struct Promise { reflector: Reflector, /// Since Promise values are natively reference counted without the knowledge of /// the SpiderMonkey GC, an explicit root for the reflector is stored while any @@ -86,13 +86,13 @@ impl Drop for Promise { } impl Promise { - pub fn new(global: &GlobalScope, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> Rc<Promise> { let realm = enter_realm(global); let comp = InRealm::Entered(&realm); Promise::new_in_current_realm(comp, can_gc) } - pub fn new_in_current_realm(_comp: InRealm, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn new_in_current_realm(_comp: InRealm, can_gc: CanGc) -> Rc<Promise> { let cx = GlobalScope::get_cx(); rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>()); Promise::create_js_promise(cx, obj.handle_mut(), can_gc); @@ -100,13 +100,13 @@ impl Promise { } #[allow(unsafe_code)] - pub fn duplicate(&self) -> Rc<Promise> { + pub(crate) fn duplicate(&self) -> Rc<Promise> { let cx = GlobalScope::get_cx(); Promise::new_with_js_promise(self.reflector().get_jsobject(), cx) } #[allow(unsafe_code, crown::unrooted_must_root)] - pub fn new_with_js_promise(obj: HandleObject, cx: SafeJSContext) -> Rc<Promise> { + pub(crate) fn new_with_js_promise(obj: HandleObject, cx: SafeJSContext) -> Rc<Promise> { unsafe { assert!(IsPromiseObject(obj)); let promise = Promise { @@ -147,7 +147,7 @@ impl Promise { } #[allow(crown::unrooted_must_root, unsafe_code)] - pub fn new_resolved( + pub(crate) fn new_resolved( global: &GlobalScope, cx: SafeJSContext, value: impl ToJSValConvertible, @@ -163,7 +163,7 @@ impl Promise { } #[allow(crown::unrooted_must_root, unsafe_code)] - pub fn new_rejected( + pub(crate) fn new_rejected( global: &GlobalScope, cx: SafeJSContext, value: impl ToJSValConvertible, @@ -179,7 +179,7 @@ impl Promise { } #[allow(unsafe_code)] - pub fn resolve_native<T>(&self, val: &T) + pub(crate) fn resolve_native<T>(&self, val: &T) where T: ToJSValConvertible, { @@ -193,7 +193,7 @@ impl Promise { } #[allow(crown::unrooted_must_root, unsafe_code)] - pub fn resolve(&self, cx: SafeJSContext, value: HandleValue) { + pub(crate) fn resolve(&self, cx: SafeJSContext, value: HandleValue) { unsafe { if !ResolvePromise(*cx, self.promise_obj(), value) { JS_ClearPendingException(*cx); @@ -202,7 +202,7 @@ impl Promise { } #[allow(unsafe_code)] - pub fn reject_native<T>(&self, val: &T) + pub(crate) fn reject_native<T>(&self, val: &T) where T: ToJSValConvertible, { @@ -216,7 +216,7 @@ impl Promise { } #[allow(unsafe_code)] - pub fn reject_error(&self, error: Error) { + pub(crate) fn reject_error(&self, error: Error) { let cx = GlobalScope::get_cx(); let _ac = enter_realm(self); rooted!(in(*cx) let mut v = UndefinedValue()); @@ -227,7 +227,7 @@ impl Promise { } #[allow(crown::unrooted_must_root, unsafe_code)] - pub fn reject(&self, cx: SafeJSContext, value: HandleValue) { + pub(crate) fn reject(&self, cx: SafeJSContext, value: HandleValue) { unsafe { if !RejectPromise(*cx, self.promise_obj(), value) { JS_ClearPendingException(*cx); @@ -236,25 +236,25 @@ impl Promise { } #[allow(unsafe_code)] - pub fn is_fulfilled(&self) -> bool { + pub(crate) fn is_fulfilled(&self) -> bool { let state = unsafe { GetPromiseState(self.promise_obj()) }; matches!(state, PromiseState::Rejected | PromiseState::Fulfilled) } #[allow(unsafe_code)] - pub fn is_rejected(&self) -> bool { + pub(crate) fn is_rejected(&self) -> bool { let state = unsafe { GetPromiseState(self.promise_obj()) }; matches!(state, PromiseState::Rejected) } #[allow(unsafe_code)] - pub fn is_pending(&self) -> bool { + pub(crate) fn is_pending(&self) -> bool { let state = unsafe { GetPromiseState(self.promise_obj()) }; matches!(state, PromiseState::Pending) } #[allow(unsafe_code)] - pub fn promise_obj(&self) -> HandleObject { + pub(crate) fn promise_obj(&self) -> HandleObject { let obj = self.reflector().get_jsobject(); unsafe { assert!(IsPromiseObject(obj)); @@ -263,7 +263,7 @@ impl Promise { } #[allow(unsafe_code)] - pub fn append_native_handler( + pub(crate) fn append_native_handler( &self, handler: &PromiseNativeHandler, _comp: InRealm, @@ -295,12 +295,12 @@ impl Promise { } #[allow(unsafe_code)] - pub fn get_promise_is_handled(&self) -> bool { + pub(crate) fn get_promise_is_handled(&self) -> bool { unsafe { GetPromiseIsHandled(self.reflector().get_jsobject()) } } #[allow(unsafe_code)] - pub fn set_promise_is_handled(&self) -> bool { + pub(crate) fn set_promise_is_handled(&self) -> bool { let cx = GlobalScope::get_cx(); unsafe { SetAnyPromiseIsHandled(*cx, self.reflector().get_jsobject()) } } diff --git a/components/script/dom/promisenativehandler.rs b/components/script/dom/promisenativehandler.rs index be071a11abc..26bcda26680 100644 --- a/components/script/dom/promisenativehandler.rs +++ b/components/script/dom/promisenativehandler.rs @@ -18,19 +18,19 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; /// as types that use the `#[dom_struct]` attribute. /// Prefer storing `Dom<T>` members inside them instead of `DomRoot<T>` /// to minimize redundant work by the garbage collector. -pub trait Callback: JSTraceable + MallocSizeOf { +pub(crate) trait Callback: JSTraceable + MallocSizeOf { fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm, can_gc: CanGc); } #[dom_struct] -pub struct PromiseNativeHandler { +pub(crate) struct PromiseNativeHandler { reflector: Reflector, resolve: Option<Box<dyn Callback>>, reject: Option<Box<dyn Callback>>, } impl PromiseNativeHandler { - pub fn new( + pub(crate) fn new( global: &GlobalScope, resolve: Option<Box<dyn Callback>>, reject: Option<Box<dyn Callback>>, @@ -60,7 +60,7 @@ impl PromiseNativeHandler { } } - pub fn resolved_callback( + pub(crate) fn resolved_callback( &self, cx: *mut JSContext, v: HandleValue, @@ -70,7 +70,7 @@ impl PromiseNativeHandler { PromiseNativeHandler::callback(&self.resolve, cx, v, realm, can_gc) } - pub fn rejected_callback( + pub(crate) fn rejected_callback( &self, cx: *mut JSContext, v: HandleValue, diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs index 30ca5ce5cf4..432f1be7fdb 100644 --- a/components/script/dom/promiserejectionevent.rs +++ b/components/script/dom/promiserejectionevent.rs @@ -26,7 +26,7 @@ use crate::dom::promise::Promise; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct PromiseRejectionEvent { +pub(crate) struct PromiseRejectionEvent { event: Event, #[ignore_malloc_size_of = "Defined in mozjs"] promise: Heap<*mut JSObject>, @@ -44,7 +44,7 @@ impl PromiseRejectionEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/radionodelist.rs b/components/script/dom/radionodelist.rs index 9b1e7a88ca2..b47a38f0d4f 100644 --- a/components/script/dom/radionodelist.rs +++ b/components/script/dom/radionodelist.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RadioNodeList { +pub(crate) struct RadioNodeList { node_list: NodeList, } @@ -33,7 +33,7 @@ impl RadioNodeList { } #[allow(crown::unrooted_must_root)] - pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> { + pub(crate) fn new(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> { reflect_dom_object( Box::new(RadioNodeList::new_inherited(list_type)), window, @@ -41,7 +41,7 @@ impl RadioNodeList { ) } - pub fn new_controls_except_image_inputs( + pub(crate) fn new_controls_except_image_inputs( window: &Window, form: &HTMLFormElement, name: &Atom, @@ -56,7 +56,7 @@ impl RadioNodeList { ) } - pub fn new_images( + pub(crate) fn new_images( window: &Window, form: &HTMLFormElement, name: &Atom, diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index d6e4a403c1b..83a1ef533b4 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -38,7 +38,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Range { +pub(crate) struct Range { abstract_range: AbstractRange, // A range that belongs to a Selection needs to know about it // so selectionchange can fire when the range changes. @@ -78,7 +78,7 @@ impl Range { } } - pub fn new_with_doc( + pub(crate) fn new_with_doc( document: &Document, proto: Option<HandleObject>, can_gc: CanGc, @@ -87,7 +87,7 @@ impl Range { Range::new_with_proto(document, proto, root, 0, root, 0, can_gc) } - pub fn new( + pub(crate) fn new( document: &Document, start_container: &Node, start_offset: u32, @@ -273,14 +273,14 @@ impl Range { Ok(Ordering::Equal) } - pub fn associate_selection(&self, selection: &Selection) { + pub(crate) fn associate_selection(&self, selection: &Selection) { let mut selections = self.associated_selections.borrow_mut(); if !selections.iter().any(|s| &**s == selection) { selections.push(Dom::from_ref(selection)); } } - pub fn disassociate_selection(&self, selection: &Selection) { + pub(crate) fn disassociate_selection(&self, selection: &Selection) { self.associated_selections .borrow_mut() .retain(|s| &**s != selection); @@ -305,23 +305,23 @@ impl Range { self.abstract_range().end() } - pub fn start_container(&self) -> DomRoot<Node> { + pub(crate) fn start_container(&self) -> DomRoot<Node> { self.abstract_range().StartContainer() } - pub fn start_offset(&self) -> u32 { + pub(crate) fn start_offset(&self) -> u32 { self.abstract_range().StartOffset() } - pub fn end_container(&self) -> DomRoot<Node> { + pub(crate) fn end_container(&self) -> DomRoot<Node> { self.abstract_range().EndContainer() } - pub fn end_offset(&self) -> u32 { + pub(crate) fn end_offset(&self) -> u32 { self.abstract_range().EndOffset() } - pub fn collapsed(&self) -> bool { + pub(crate) fn collapsed(&self) -> bool { self.abstract_range().Collapsed() } } @@ -1107,7 +1107,7 @@ impl RangeMethods<crate::DomTypeHolder> for Range { } } -pub struct WeakRangeVec { +pub(crate) struct WeakRangeVec { cell: UnsafeCell<WeakRefVec<Range>>, } @@ -1122,30 +1122,30 @@ impl Default for WeakRangeVec { #[allow(unsafe_code)] impl WeakRangeVec { /// Create a new vector of weak references. - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self::default() } /// Whether that vector of ranges is empty. - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { unsafe { (*self.cell.get()).is_empty() } } /// Used for steps 2.1-2. when inserting a node. /// <https://dom.spec.whatwg.org/#concept-node-insert> - pub fn increase_above(&self, node: &Node, offset: u32, delta: u32) { + pub(crate) fn increase_above(&self, node: &Node, offset: u32, delta: u32) { self.map_offset_above(node, offset, |offset| offset + delta); } /// Used for steps 4-5. when removing a node. /// <https://dom.spec.whatwg.org/#concept-node-remove> - pub fn decrease_above(&self, node: &Node, offset: u32, delta: u32) { + pub(crate) fn decrease_above(&self, node: &Node, offset: u32, delta: u32) { self.map_offset_above(node, offset, |offset| offset - delta); } /// Used for steps 2-3. when removing a node. /// <https://dom.spec.whatwg.org/#concept-node-remove> - pub fn drain_to_parent(&self, context: &UnbindContext, child: &Node) { + pub(crate) fn drain_to_parent(&self, context: &UnbindContext, child: &Node) { if self.is_empty() { return; } @@ -1176,7 +1176,7 @@ impl WeakRangeVec { /// Used for steps 7.1-2. when normalizing a node. /// <https://dom.spec.whatwg.org/#dom-node-normalize> - pub fn drain_to_preceding_text_sibling(&self, node: &Node, sibling: &Node, length: u32) { + pub(crate) fn drain_to_preceding_text_sibling(&self, node: &Node, sibling: &Node, length: u32) { if self.is_empty() { return; } @@ -1205,7 +1205,13 @@ impl WeakRangeVec { /// Used for steps 7.3-4. when normalizing a node. /// <https://dom.spec.whatwg.org/#dom-node-normalize> - pub fn move_to_text_child_at(&self, node: &Node, offset: u32, child: &Node, new_offset: u32) { + pub(crate) fn move_to_text_child_at( + &self, + node: &Node, + offset: u32, + child: &Node, + new_offset: u32, + ) { unsafe { let child_ranges = &mut *child.ranges().cell.get(); @@ -1247,7 +1253,7 @@ impl WeakRangeVec { /// Used for steps 8-11. when replacing character data. /// <https://dom.spec.whatwg.org/#concept-cd-replace> - pub fn replace_code_units( + pub(crate) fn replace_code_units( &self, node: &Node, offset: u32, @@ -1265,7 +1271,12 @@ impl WeakRangeVec { /// Used for steps 7.2-3. when splitting a text node. /// <https://dom.spec.whatwg.org/#concept-text-split> - pub fn move_to_following_text_sibling_above(&self, node: &Node, offset: u32, sibling: &Node) { + pub(crate) fn move_to_following_text_sibling_above( + &self, + node: &Node, + offset: u32, + sibling: &Node, + ) { unsafe { let sibling_ranges = &mut *sibling.ranges().cell.get(); @@ -1310,7 +1321,7 @@ impl WeakRangeVec { /// Used for steps 7.4-5. when splitting a text node. /// <https://dom.spec.whatwg.org/#concept-text-split> - pub fn increment_at(&self, node: &Node, offset: u32) { + pub(crate) fn increment_at(&self, node: &Node, offset: u32) { unsafe { (*self.cell.get()).update(|entry| { let range = entry.root().unwrap(); @@ -1344,7 +1355,7 @@ impl WeakRangeVec { } } - pub fn push(&self, ref_: WeakRef<Range>) { + pub(crate) fn push(&self, ref_: WeakRef<Range>) { unsafe { (*self.cell.get()).push(ref_); } diff --git a/components/script/dom/raredata.rs b/components/script/dom/raredata.rs index df32b27f007..cbcb2934c42 100644 --- a/components/script/dom/raredata.rs +++ b/components/script/dom/raredata.rs @@ -22,39 +22,39 @@ use crate::dom::window::LayoutValue; #[derive(Default, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct NodeRareData { +pub(crate) struct NodeRareData { /// The shadow root the node belongs to. /// This is None if the node is not in a shadow tree or /// if it is a ShadowRoot. - pub containing_shadow_root: Option<Dom<ShadowRoot>>, + pub(crate) containing_shadow_root: Option<Dom<ShadowRoot>>, /// Registered observers for this node. - pub mutation_observers: Vec<RegisteredObserver>, + pub(crate) mutation_observers: Vec<RegisteredObserver>, /// Lazily-generated Unique Id for this node. - pub unique_id: Option<UniqueId>, + pub(crate) unique_id: Option<UniqueId>, } #[derive(Default, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct ElementRareData { +pub(crate) struct ElementRareData { /// <https://dom.spec.whatwg.org/#dom-element-shadowroot> /// The ShadowRoot this element is host of. /// XXX This is currently not exposed to web content. Only for /// internal use. - pub shadow_root: Option<Dom<ShadowRoot>>, + pub(crate) shadow_root: Option<Dom<ShadowRoot>>, /// <https://html.spec.whatwg.org/multipage/#custom-element-reaction-queue> - pub custom_element_reaction_queue: Vec<CustomElementReaction>, + pub(crate) custom_element_reaction_queue: Vec<CustomElementReaction>, /// <https://dom.spec.whatwg.org/#concept-element-custom-element-definition> #[ignore_malloc_size_of = "Rc"] - pub custom_element_definition: Option<Rc<CustomElementDefinition>>, + pub(crate) custom_element_definition: Option<Rc<CustomElementDefinition>>, /// <https://dom.spec.whatwg.org/#concept-element-custom-element-state> - pub custom_element_state: CustomElementState, + pub(crate) custom_element_state: CustomElementState, /// The "name" content attribute; not used as frequently as id, but used /// in named getter loops so it's worth looking up quickly when present #[no_trace] - pub name_attribute: Option<Atom>, + pub(crate) name_attribute: Option<Atom>, /// The client rect reported by layout. #[no_trace] - pub client_rect: Option<LayoutValue<Rect<i32>>>, + pub(crate) client_rect: Option<LayoutValue<Rect<i32>>>, /// <https://html.spec.whatwg.org/multipage#elementinternals> - pub element_internals: Option<Dom<ElementInternals>>, + pub(crate) element_internals: Option<Dom<ElementInternals>>, } diff --git a/components/script/dom/readablebytestreamcontroller.rs b/components/script/dom/readablebytestreamcontroller.rs index 058fce5ad3c..774cd71149e 100644 --- a/components/script/dom/readablebytestreamcontroller.rs +++ b/components/script/dom/readablebytestreamcontroller.rs @@ -14,13 +14,13 @@ use crate::script_runtime::JSContext as SafeJSContext; /// <https://streams.spec.whatwg.org/#readablebytestreamcontroller> #[dom_struct] -pub struct ReadableByteStreamController { +pub(crate) struct ReadableByteStreamController { reflector_: Reflector, stream: MutNullableDom<ReadableStream>, } impl ReadableByteStreamController { - pub fn set_stream(&self, stream: &ReadableStream) { + pub(crate) fn set_stream(&self, stream: &ReadableStream) { self.stream.set(Some(stream)) } } diff --git a/components/script/dom/readablestream.rs b/components/script/dom/readablestream.rs index 4be4487aaf5..51f6802a5df 100644 --- a/components/script/dom/readablestream.rs +++ b/components/script/dom/readablestream.rs @@ -81,7 +81,7 @@ impl Callback for SourceCancelPromiseRejectionHandler { /// <https://streams.spec.whatwg.org/#readablestream-state> #[derive(Clone, Copy, Debug, Default, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ReadableStreamState { +pub(crate) enum ReadableStreamState { #[default] Readable, Closed, @@ -91,7 +91,7 @@ pub enum ReadableStreamState { /// <https://streams.spec.whatwg.org/#readablestream-controller> #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum ControllerType { +pub(crate) enum ControllerType { /// <https://streams.spec.whatwg.org/#readablebytestreamcontroller> Byte(MutNullableDom<ReadableByteStreamController>), /// <https://streams.spec.whatwg.org/#readablestreamdefaultcontroller> @@ -101,7 +101,7 @@ pub enum ControllerType { /// <https://streams.spec.whatwg.org/#readablestream-readerr> #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub enum ReaderType { +pub(crate) enum ReaderType { /// <https://streams.spec.whatwg.org/#readablestreambyobreader> #[allow(clippy::upper_case_acronyms)] BYOB(MutNullableDom<ReadableStreamBYOBReader>), @@ -158,7 +158,7 @@ fn create_readable_stream( /// <https://streams.spec.whatwg.org/#rs-class> #[dom_struct] -pub struct ReadableStream { +pub(crate) struct ReadableStream { reflector_: Reflector, /// <https://streams.spec.whatwg.org/#readablestream-controller> @@ -215,7 +215,7 @@ impl ReadableStream { /// Used as part of /// <https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller> - pub fn set_default_controller(&self, controller: &ReadableStreamDefaultController) { + pub(crate) fn set_default_controller(&self, controller: &ReadableStreamDefaultController) { match self.controller { ControllerType::Default(ref ctrl) => ctrl.set(Some(controller)), ControllerType::Byte(_) => { @@ -226,7 +226,7 @@ impl ReadableStream { /// Used as part of /// <https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller> - pub fn assert_no_controller(&self) { + pub(crate) fn assert_no_controller(&self) { let has_no_controller = match self.controller { ControllerType::Default(ref ctrl) => ctrl.get().is_none(), ControllerType::Byte(ref ctrl) => ctrl.get().is_none(), @@ -235,7 +235,7 @@ impl ReadableStream { } /// Build a stream backed by a Rust source that has already been read into memory. - pub fn new_from_bytes( + pub(crate) fn new_from_bytes( global: &GlobalScope, bytes: Vec<u8>, can_gc: CanGc, @@ -253,7 +253,7 @@ impl ReadableStream { /// Build a stream backed by a Rust underlying source. /// Note: external sources are always paired with a default controller. #[allow(crown::unrooted_must_root)] - pub fn new_with_external_underlying_source( + pub(crate) fn new_with_external_underlying_source( global: &GlobalScope, source: UnderlyingSourceType, can_gc: CanGc, @@ -277,7 +277,7 @@ impl ReadableStream { } /// Call into the release steps of the controller, - pub fn perform_release_steps(&self) { + pub(crate) fn perform_release_steps(&self) { match self.controller { ControllerType::Default(ref controller) => controller .get() @@ -290,7 +290,7 @@ impl ReadableStream { /// Call into the pull steps of the controller, /// as part of /// <https://streams.spec.whatwg.org/#readable-stream-default-reader-read> - pub fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc) { + pub(crate) fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc) { match self.controller { ControllerType::Default(ref controller) => controller .get() @@ -301,7 +301,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readable-stream-add-read-request> - pub fn add_read_request(&self, read_request: &ReadRequest) { + pub(crate) fn add_read_request(&self, read_request: &ReadRequest) { match self.reader { // Assert: stream.[[reader]] implements ReadableStreamDefaultReader. ReaderType::Default(ref reader) => { @@ -323,7 +323,7 @@ impl ReadableStream { /// Endpoint to enqueue chunks directly from Rust. /// Note: in other use cases this call happens via the controller. - pub fn enqueue_native(&self, bytes: Vec<u8>) { + pub(crate) fn enqueue_native(&self, bytes: Vec<u8>) { match self.controller { ControllerType::Default(ref controller) => controller .get() @@ -336,7 +336,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readable-stream-error> - pub fn error(&self, e: SafeHandleValue) { + pub(crate) fn error(&self, e: SafeHandleValue) { // Assert: stream.[[state]] is "readable". assert!(self.is_readable()); // Set stream.[[state]] to "errored". @@ -359,14 +359,14 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readablestream-storederror> - pub fn get_stored_error(&self, mut handle_mut: SafeMutableHandleValue) { + pub(crate) fn get_stored_error(&self, mut handle_mut: SafeMutableHandleValue) { handle_mut.set(self.stored_error.get()); } /// <https://streams.spec.whatwg.org/#readable-stream-error> /// Note: in other use cases this call happens via the controller. #[allow(unsafe_code)] - pub fn error_native(&self, error: Error) { + pub(crate) fn error_native(&self, error: Error) { let cx = GlobalScope::get_cx(); rooted!(in(*cx) let mut error_val = UndefinedValue()); unsafe { error.to_jsval(*cx, &self.global(), error_val.handle_mut()) }; @@ -375,7 +375,7 @@ impl ReadableStream { /// Call into the controller's `Close` method. /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-close> - pub fn controller_close_native(&self) { + pub(crate) fn controller_close_native(&self) { match self.controller { ControllerType::Default(ref controller) => { let _ = controller @@ -391,7 +391,7 @@ impl ReadableStream { /// Returns a boolean reflecting whether the stream has all data in memory. /// Useful for native source integration only. - pub fn in_memory(&self) -> bool { + pub(crate) fn in_memory(&self) -> bool { match self.controller { ControllerType::Default(ref controller) => controller .get() @@ -405,7 +405,7 @@ impl ReadableStream { /// Return bytes for synchronous use, if the stream has all data in memory. /// Useful for native source integration only. - pub fn get_in_memory_bytes(&self) -> Option<Vec<u8>> { + pub(crate) fn get_in_memory_bytes(&self) -> Option<Vec<u8>> { match self.controller { ControllerType::Default(ref controller) => controller .get() @@ -421,7 +421,7 @@ impl ReadableStream { /// must be done before `read_a_chunk`. /// Native call to /// <https://streams.spec.whatwg.org/#acquire-readable-stream-reader> - pub fn acquire_default_reader( + pub(crate) fn acquire_default_reader( &self, can_gc: CanGc, ) -> Fallible<DomRoot<ReadableStreamDefaultReader>> { @@ -442,7 +442,7 @@ impl ReadableStream { Ok(reader) } - pub fn get_default_controller(&self) -> DomRoot<ReadableStreamDefaultController> { + pub(crate) fn get_default_controller(&self) -> DomRoot<ReadableStreamDefaultController> { match self.controller { ControllerType::Default(ref controller) => { controller.get().expect("Stream should have controller.") @@ -458,7 +458,7 @@ impl ReadableStream { /// and before `stop_reading`. /// Native call to /// <https://streams.spec.whatwg.org/#readable-stream-default-reader-read> - pub fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn read_a_chunk(&self, can_gc: CanGc) -> Rc<Promise> { match self.reader { ReaderType::Default(ref reader) => { let Some(reader) = reader.get() else { @@ -478,7 +478,7 @@ impl ReadableStream { /// must be done after `start_reading`. /// Native call to /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaultreaderrelease> - pub fn stop_reading(&self) { + pub(crate) fn stop_reading(&self) { match self.reader { ReaderType::Default(ref reader) => { let Some(reader) = reader.get() else { @@ -493,34 +493,34 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#is-readable-stream-locked> - pub fn is_locked(&self) -> bool { + pub(crate) fn is_locked(&self) -> bool { match self.reader { ReaderType::Default(ref reader) => reader.get().is_some(), ReaderType::BYOB(ref reader) => reader.get().is_some(), } } - pub fn is_disturbed(&self) -> bool { + pub(crate) fn is_disturbed(&self) -> bool { self.disturbed.get() } - pub fn set_is_disturbed(&self, disturbed: bool) { + pub(crate) fn set_is_disturbed(&self, disturbed: bool) { self.disturbed.set(disturbed); } - pub fn is_closed(&self) -> bool { + pub(crate) fn is_closed(&self) -> bool { self.state.get() == ReadableStreamState::Closed } - pub fn is_errored(&self) -> bool { + pub(crate) fn is_errored(&self) -> bool { self.state.get() == ReadableStreamState::Errored } - pub fn is_readable(&self) -> bool { + pub(crate) fn is_readable(&self) -> bool { self.state.get() == ReadableStreamState::Readable } - pub fn has_default_reader(&self) -> bool { + pub(crate) fn has_default_reader(&self) -> bool { match self.reader { ReaderType::Default(ref reader) => reader.get().is_some(), ReaderType::BYOB(_) => false, @@ -528,7 +528,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readable-stream-get-num-read-requests> - pub fn get_num_read_requests(&self) -> usize { + pub(crate) fn get_num_read_requests(&self) -> usize { assert!(self.has_default_reader()); match self.reader { ReaderType::Default(ref reader) => { @@ -545,7 +545,7 @@ impl ReadableStream { /// <https://streams.spec.whatwg.org/#readable-stream-fulfill-read-request> #[allow(crown::unrooted_must_root)] - pub fn fulfill_read_request(&self, chunk: SafeHandleValue, done: bool) { + pub(crate) fn fulfill_read_request(&self, chunk: SafeHandleValue, done: bool) { // step 1 - Assert: ! ReadableStreamHasDefaultReader(stream) is true. assert!(self.has_default_reader()); match self.reader { @@ -577,7 +577,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readable-stream-close> - pub fn close(&self) { + pub(crate) fn close(&self) { // Assert: stream.[[state]] is "readable". assert!(self.is_readable()); // Set stream.[[state]] to "closed". @@ -598,7 +598,7 @@ impl ReadableStream { /// <https://streams.spec.whatwg.org/#readable-stream-cancel> #[allow(unsafe_code)] - pub fn cancel(&self, reason: SafeHandleValue, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn cancel(&self, reason: SafeHandleValue, can_gc: CanGc) -> Rc<Promise> { // Set stream.[[disturbed]] to true. self.disturbed.set(true); @@ -656,7 +656,7 @@ impl ReadableStream { result_promise } - pub fn set_reader(&self, new_reader: Option<&ReadableStreamDefaultReader>) { + pub(crate) fn set_reader(&self, new_reader: Option<&ReadableStreamDefaultReader>) { match self.reader { ReaderType::Default(ref reader) => { reader.set(new_reader); @@ -913,7 +913,7 @@ impl ReadableStreamMethods<crate::DomTypeHolder> for ReadableStream { #[allow(unsafe_code)] /// Get the `done` property of an object that a read promise resolved to. -pub fn get_read_promise_done(cx: SafeJSContext, v: &SafeHandleValue) -> Result<bool, Error> { +pub(crate) fn get_read_promise_done(cx: SafeJSContext, v: &SafeHandleValue) -> Result<bool, Error> { if !v.is_object() { return Err(Error::Type("Unknown format for done property.".to_string())); } @@ -934,7 +934,10 @@ pub fn get_read_promise_done(cx: SafeJSContext, v: &SafeHandleValue) -> Result<b #[allow(unsafe_code)] /// Get the `value` property of an object that a read promise resolved to. -pub fn get_read_promise_bytes(cx: SafeJSContext, v: &SafeHandleValue) -> Result<Vec<u8>, Error> { +pub(crate) fn get_read_promise_bytes( + cx: SafeJSContext, + v: &SafeHandleValue, +) -> Result<Vec<u8>, Error> { if !v.is_object() { return Err(Error::Type( "Unknown format for for bytes read.".to_string(), diff --git a/components/script/dom/readablestreambyobreader.rs b/components/script/dom/readablestreambyobreader.rs index 556fe15ea54..9f341ed4198 100644 --- a/components/script/dom/readablestreambyobreader.rs +++ b/components/script/dom/readablestreambyobreader.rs @@ -23,7 +23,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; /// <https://streams.spec.whatwg.org/#readablestreambyobreader> #[dom_struct] -pub struct ReadableStreamBYOBReader { +pub(crate) struct ReadableStreamBYOBReader { reflector_: Reflector, } diff --git a/components/script/dom/readablestreambyobrequest.rs b/components/script/dom/readablestreambyobrequest.rs index e2f7199d170..47df222e1d8 100644 --- a/components/script/dom/readablestreambyobrequest.rs +++ b/components/script/dom/readablestreambyobrequest.rs @@ -11,7 +11,7 @@ use crate::script_runtime::JSContext as SafeJSContext; /// <https://streams.spec.whatwg.org/#readablestreambyobrequest> #[dom_struct] -pub struct ReadableStreamBYOBRequest { +pub(crate) struct ReadableStreamBYOBRequest { reflector_: Reflector, } diff --git a/components/script/dom/readablestreamdefaultcontroller.rs b/components/script/dom/readablestreamdefaultcontroller.rs index 655e6231bfb..3f40558a161 100644 --- a/components/script/dom/readablestreamdefaultcontroller.rs +++ b/components/script/dom/readablestreamdefaultcontroller.rs @@ -129,7 +129,7 @@ impl Callback for StartAlgorithmRejectionHandler { /// <https://streams.spec.whatwg.org/#value-with-size> #[derive(JSTraceable)] #[crown::unrooted_must_root_lint::must_root] -pub struct ValueWithSize { +pub(crate) struct ValueWithSize { value: Box<Heap<JSVal>>, size: f64, } @@ -137,7 +137,7 @@ pub struct ValueWithSize { /// <https://streams.spec.whatwg.org/#value-with-size> #[derive(JSTraceable)] #[crown::unrooted_must_root_lint::must_root] -pub enum EnqueuedValue { +pub(crate) enum EnqueuedValue { /// A value enqueued from Rust. Native(Box<[u8]>), /// A Js value. @@ -194,7 +194,7 @@ fn is_non_negative_number(value: &EnqueuedValue) -> bool { /// <https://streams.spec.whatwg.org/#queue-with-sizes> #[derive(Default, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct QueueWithSizes { +pub(crate) struct QueueWithSizes { #[ignore_malloc_size_of = "EnqueuedValue::Js"] queue: VecDeque<EnqueuedValue>, /// <https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-queuetotalsize> @@ -264,7 +264,7 @@ impl QueueWithSizes { /// <https://streams.spec.whatwg.org/#readablestreamdefaultcontroller> #[dom_struct] -pub struct ReadableStreamDefaultController { +pub(crate) struct ReadableStreamDefaultController { reflector_: Reflector, /// <https://streams.spec.whatwg.org/#readablestreamdefaultcontroller-queue> @@ -327,7 +327,7 @@ impl ReadableStreamDefaultController { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, underlying_source: UnderlyingSourceType, strategy_hwm: f64, @@ -349,7 +349,11 @@ impl ReadableStreamDefaultController { /// <https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller> #[allow(unsafe_code)] - pub fn setup(&self, stream: DomRoot<ReadableStream>, can_gc: CanGc) -> Result<(), Error> { + pub(crate) fn setup( + &self, + stream: DomRoot<ReadableStream>, + can_gc: CanGc, + ) -> Result<(), Error> { // Assert: stream.[[controller]] is undefined stream.assert_no_controller(); @@ -412,7 +416,7 @@ impl ReadableStreamDefaultController { } /// Setting the JS object after the heap has settled down. - pub fn set_underlying_source_this_object(&self, this_object: HandleObject) { + pub(crate) fn set_underlying_source_this_object(&self, this_object: HandleObject) { if let Some(underlying_source) = self.underlying_source.get() { underlying_source.set_underlying_source_this_object(this_object); } @@ -526,7 +530,11 @@ impl ReadableStreamDefaultController { /// <https://streams.spec.whatwg.org/#rs-default-controller-private-cancel> #[allow(unsafe_code)] - pub fn perform_cancel_steps(&self, reason: SafeHandleValue, can_gc: CanGc) -> Rc<Promise> { + pub(crate) fn perform_cancel_steps( + &self, + reason: SafeHandleValue, + can_gc: CanGc, + ) -> Rc<Promise> { // Perform ! ResetQueue(this). self.queue.borrow_mut().reset(); @@ -566,7 +574,7 @@ impl ReadableStreamDefaultController { } /// <https://streams.spec.whatwg.org/#rs-default-controller-private-pull> - pub fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc) { + pub(crate) fn perform_pull_steps(&self, read_request: &ReadRequest, can_gc: CanGc) { // Let stream be this.[[stream]]. // Note: the spec does not assert that there is a stream. let Some(stream) = self.stream.get() else { @@ -604,13 +612,13 @@ impl ReadableStreamDefaultController { } /// <https://streams.spec.whatwg.org/#ref-for-abstract-opdef-readablestreamcontroller-releasesteps> - pub fn perform_release_steps(&self) { + pub(crate) fn perform_release_steps(&self) { // step 1 - Return. } /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-enqueue> #[allow(unsafe_code)] - pub fn enqueue( + pub(crate) fn enqueue( &self, cx: SafeJSContext, chunk: SafeHandleValue, @@ -705,7 +713,7 @@ impl ReadableStreamDefaultController { /// Native call to /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-enqueue> - pub fn enqueue_native(&self, chunk: Vec<u8>) { + pub(crate) fn enqueue_native(&self, chunk: Vec<u8>) { let stream = self .stream .get() @@ -724,7 +732,7 @@ impl ReadableStreamDefaultController { } /// Does the stream have all data in memory? - pub fn in_memory(&self) -> bool { + pub(crate) fn in_memory(&self) -> bool { let Some(underlying_source) = self.underlying_source.get() else { return false; }; @@ -732,7 +740,7 @@ impl ReadableStreamDefaultController { } /// Return bytes synchronously if the stream has all data in memory. - pub fn get_in_memory_bytes(&self) -> Option<Vec<u8>> { + pub(crate) fn get_in_memory_bytes(&self) -> Option<Vec<u8>> { let underlying_source = self.underlying_source.get()?; if underlying_source.in_memory() { return self.queue.borrow().get_in_memory_bytes(); @@ -751,7 +759,7 @@ impl ReadableStreamDefaultController { } /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-close> - pub fn close(&self) { + pub(crate) fn close(&self) { // If ! ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) is false, return. if !self.can_close_or_enqueue() { return; @@ -809,7 +817,7 @@ impl ReadableStreamDefaultController { } /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-error> - pub fn error(&self, e: SafeHandleValue) { + pub(crate) fn error(&self, e: SafeHandleValue) { let Some(stream) = self.stream.get() else { return; }; diff --git a/components/script/dom/readablestreamdefaultreader.rs b/components/script/dom/readablestreamdefaultreader.rs index 33c545258c2..03da63255d2 100644 --- a/components/script/dom/readablestreamdefaultreader.rs +++ b/components/script/dom/readablestreamdefaultreader.rs @@ -34,7 +34,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; /// <https://streams.spec.whatwg.org/#read-request> #[derive(Clone, JSTraceable)] #[crown::unrooted_must_root_lint::must_root] -pub enum ReadRequest { +pub(crate) enum ReadRequest { /// <https://streams.spec.whatwg.org/#default-reader-read> Read(Rc<Promise>), /// <https://streams.spec.whatwg.org/#ref-for-read-request%E2%91%A2> @@ -45,7 +45,7 @@ pub enum ReadRequest { impl ReadRequest { /// <https://streams.spec.whatwg.org/#read-request-chunk-steps> - pub fn chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) { + pub(crate) fn chunk_steps(&self, chunk: RootedTraceableBox<Heap<JSVal>>) { match self { ReadRequest::Read(promise) => { promise.resolve_native(&ReadableStreamReadResult { @@ -60,7 +60,7 @@ impl ReadRequest { } /// <https://streams.spec.whatwg.org/#read-request-close-steps> - pub fn close_steps(&self) { + pub(crate) fn close_steps(&self) { match self { ReadRequest::Read(promise) => { let result = RootedTraceableBox::new(Heap::default()); @@ -77,7 +77,7 @@ impl ReadRequest { } /// <https://streams.spec.whatwg.org/#read-request-error-steps> - pub fn error_steps(&self, e: SafeHandleValue) { + pub(crate) fn error_steps(&self, e: SafeHandleValue) { match self { ReadRequest::Read(promise) => promise.reject_native(&e), ReadRequest::DefaultTee { tee_read_request } => { @@ -123,7 +123,7 @@ impl Callback for ClosedPromiseRejectionHandler { /// <https://streams.spec.whatwg.org/#readablestreamdefaultreader> #[dom_struct] -pub struct ReadableStreamDefaultReader { +pub(crate) struct ReadableStreamDefaultReader { reflector_: Reflector, /// <https://streams.spec.whatwg.org/#readablestreamgenericreader-stream> @@ -140,7 +140,7 @@ pub struct ReadableStreamDefaultReader { impl ReadableStreamDefaultReader { /// <https://streams.spec.whatwg.org/#default-reader-constructor> #[allow(non_snake_case)] - pub fn Constructor( + pub(crate) fn Constructor( global: &GlobalScope, proto: Option<SafeHandleObject>, can_gc: CanGc, @@ -167,7 +167,10 @@ impl ReadableStreamDefaultReader { ) } - pub fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> ReadableStreamDefaultReader { + pub(crate) fn new_inherited( + global: &GlobalScope, + can_gc: CanGc, + ) -> ReadableStreamDefaultReader { ReadableStreamDefaultReader { reflector_: Reflector::new(), stream: MutNullableDom::new(None), @@ -177,7 +180,7 @@ impl ReadableStreamDefaultReader { } /// <https://streams.spec.whatwg.org/#set-up-readable-stream-default-reader> - pub fn set_up( + pub(crate) fn set_up( &self, stream: &ReadableStream, global: &GlobalScope, @@ -198,7 +201,7 @@ impl ReadableStreamDefaultReader { } /// <https://streams.spec.whatwg.org/#readable-stream-reader-generic-initialize> - pub fn generic_initialize( + pub(crate) fn generic_initialize( &self, global: &GlobalScope, stream: &ReadableStream, @@ -239,7 +242,7 @@ impl ReadableStreamDefaultReader { /// <https://streams.spec.whatwg.org/#readable-stream-close> #[allow(crown::unrooted_must_root)] - pub fn close(&self) { + pub(crate) fn close(&self) { // Resolve reader.[[closedPromise]] with undefined. self.closed_promise.borrow().resolve_native(&()); // If reader implements ReadableStreamDefaultReader, @@ -254,19 +257,19 @@ impl ReadableStreamDefaultReader { } /// <https://streams.spec.whatwg.org/#readable-stream-add-read-request> - pub fn add_read_request(&self, read_request: &ReadRequest) { + pub(crate) fn add_read_request(&self, read_request: &ReadRequest) { self.read_requests .borrow_mut() .push_back(read_request.clone()); } /// <https://streams.spec.whatwg.org/#readable-stream-get-num-read-requests> - pub fn get_num_read_requests(&self) -> usize { + pub(crate) fn get_num_read_requests(&self) -> usize { self.read_requests.borrow().len() } /// <https://streams.spec.whatwg.org/#readable-stream-error> - pub fn error(&self, e: SafeHandleValue) { + pub(crate) fn error(&self, e: SafeHandleValue) { // Reject reader.[[closedPromise]] with e. self.closed_promise.borrow().reject_native(&e); @@ -279,7 +282,7 @@ impl ReadableStreamDefaultReader { /// The removal steps of <https://streams.spec.whatwg.org/#readable-stream-fulfill-read-request> #[allow(crown::unrooted_must_root)] - pub fn remove_read_request(&self) -> ReadRequest { + pub(crate) fn remove_read_request(&self) -> ReadRequest { self.read_requests .borrow_mut() .pop_front() @@ -288,7 +291,7 @@ impl ReadableStreamDefaultReader { /// <https://streams.spec.whatwg.org/#readable-stream-reader-generic-release> #[allow(unsafe_code)] - pub fn generic_release(&self) { + pub(crate) fn generic_release(&self) { // Let stream be reader.[[stream]]. // Assert: stream is not undefined. @@ -333,7 +336,7 @@ impl ReadableStreamDefaultReader { /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaultreaderrelease> #[allow(unsafe_code)] - pub fn release(&self) { + pub(crate) fn release(&self) { // Perform ! ReadableStreamReaderGenericRelease(reader). self.generic_release(); // Let e be a new TypeError exception. @@ -382,7 +385,7 @@ impl ReadableStreamDefaultReader { } /// <https://streams.spec.whatwg.org/#readable-stream-default-reader-read> - pub fn read(&self, read_request: &ReadRequest, can_gc: CanGc) { + pub(crate) fn read(&self, read_request: &ReadRequest, can_gc: CanGc) { // Let stream be reader.[[stream]]. // Assert: stream is not undefined. @@ -412,7 +415,7 @@ impl ReadableStreamDefaultReader { } /// <https://streams.spec.whatwg.org/#ref-for-readablestreamgenericreader-closedpromise%E2%91%A1> - pub fn append_native_handler_to_closed_promise( + pub(crate) fn append_native_handler_to_closed_promise( &self, branch_1: &ReadableStream, branch_2: &ReadableStream, diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs index 32f0b912f7a..6f672660db5 100644 --- a/components/script/dom/request.rs +++ b/components/script/dom/request.rs @@ -41,7 +41,7 @@ use crate::dom::readablestream::ReadableStream; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Request { +pub(crate) struct Request { reflector_: Reflector, #[no_trace] request: DomRefCell<NetTraitsRequest>, @@ -102,7 +102,7 @@ impl Request { Ok(r_clone) } - pub fn get_request(&self) -> NetTraitsRequest { + pub(crate) fn get_request(&self) -> NetTraitsRequest { self.request.borrow().clone() } } diff --git a/components/script/dom/resizeobserver.rs b/components/script/dom/resizeobserver.rs index c7bc2f9f7a7..02c90c9d727 100644 --- a/components/script/dom/resizeobserver.rs +++ b/components/script/dom/resizeobserver.rs @@ -29,10 +29,10 @@ use crate::script_runtime::CanGc; /// <https://drafts.csswg.org/resize-observer/#calculate-depth-for-node> #[derive(Debug, Default, PartialEq, PartialOrd)] -pub struct ResizeObservationDepth(usize); +pub(crate) struct ResizeObservationDepth(usize); impl ResizeObservationDepth { - pub fn max() -> ResizeObservationDepth { + pub(crate) fn max() -> ResizeObservationDepth { ResizeObservationDepth(usize::MAX) } } @@ -40,7 +40,7 @@ impl ResizeObservationDepth { /// <https://drafts.csswg.org/resize-observer/#resize-observer-slots> /// See `ObservationState` for active and skipped observation targets. #[dom_struct] -pub struct ResizeObserver { +pub(crate) struct ResizeObserver { reflector_: Reflector, /// <https://drafts.csswg.org/resize-observer/#dom-resizeobserver-callback-slot> #[ignore_malloc_size_of = "Rc are hard"] @@ -50,7 +50,7 @@ pub struct ResizeObserver { } impl ResizeObserver { - pub fn new_inherited(callback: Rc<ResizeObserverCallback>) -> ResizeObserver { + pub(crate) fn new_inherited(callback: Rc<ResizeObserverCallback>) -> ResizeObserver { ResizeObserver { reflector_: Reflector::new(), callback, @@ -70,7 +70,7 @@ impl ResizeObserver { /// <https://drafts.csswg.org/resize-observer/#gather-active-observations-h> /// <https://drafts.csswg.org/resize-observer/#has-active-resize-observations> - pub fn gather_active_resize_observations_at_depth( + pub(crate) fn gather_active_resize_observations_at_depth( &self, depth: &ResizeObservationDepth, has_active: &mut bool, @@ -91,7 +91,7 @@ impl ResizeObserver { } /// <https://drafts.csswg.org/resize-observer/#broadcast-active-resize-observations> - pub fn broadcast_active_resize_observations( + pub(crate) fn broadcast_active_resize_observations( &self, shallowest_target_depth: &mut ResizeObservationDepth, can_gc: CanGc, @@ -152,7 +152,7 @@ impl ResizeObserver { } /// <https://drafts.csswg.org/resize-observer/#has-skipped-observations-h> - pub fn has_skipped_resize_observations(&self) -> bool { + pub(crate) fn has_skipped_resize_observations(&self) -> bool { self.observation_targets .borrow() .iter() @@ -235,7 +235,7 @@ struct ResizeObservation { impl ResizeObservation { /// <https://drafts.csswg.org/resize-observer/#dom-resizeobservation-resizeobservation> - pub fn new(observed_box: ResizeObserverBoxOptions) -> ResizeObservation { + pub(crate) fn new(observed_box: ResizeObserverBoxOptions) -> ResizeObservation { let size_impl = ResizeObserverSizeImpl::new(0.0, 0.0); ResizeObservation { observed_box: RefCell::new(observed_box), diff --git a/components/script/dom/resizeobserverentry.rs b/components/script/dom/resizeobserverentry.rs index 3ffd53fad99..ec76a9d3617 100644 --- a/components/script/dom/resizeobserverentry.rs +++ b/components/script/dom/resizeobserverentry.rs @@ -17,7 +17,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; /// <https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface> #[dom_struct] -pub struct ResizeObserverEntry { +pub(crate) struct ResizeObserverEntry { reflector_: Reflector, /// <https://drafts.csswg.org/resize-observer/#dom-resizeobserverentry-target> target: Dom<Element>, @@ -58,7 +58,7 @@ impl ResizeObserverEntry { } } - pub fn new( + pub(crate) fn new( window: &Window, target: &Element, content_rect: &DOMRectReadOnly, diff --git a/components/script/dom/resizeobserversize.rs b/components/script/dom/resizeobserversize.rs index db5ef2a7e96..c89b43f215b 100644 --- a/components/script/dom/resizeobserversize.rs +++ b/components/script/dom/resizeobserversize.rs @@ -12,31 +12,31 @@ use crate::script_runtime::CanGc; /// Non-DOM implementation backing `ResizeObserverSize`. #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub struct ResizeObserverSizeImpl { +pub(crate) struct ResizeObserverSizeImpl { inline_size: f64, block_size: f64, } impl ResizeObserverSizeImpl { - pub fn new(inline_size: f64, block_size: f64) -> ResizeObserverSizeImpl { + pub(crate) fn new(inline_size: f64, block_size: f64) -> ResizeObserverSizeImpl { ResizeObserverSizeImpl { inline_size, block_size, } } - pub fn inline_size(&self) -> f64 { + pub(crate) fn inline_size(&self) -> f64 { self.inline_size } - pub fn block_size(&self) -> f64 { + pub(crate) fn block_size(&self) -> f64 { self.block_size } } /// <https://drafts.csswg.org/resize-observer/#resizeobserversize> #[dom_struct] -pub struct ResizeObserverSize { +pub(crate) struct ResizeObserverSize { reflector_: Reflector, size_impl: ResizeObserverSizeImpl, } @@ -49,7 +49,7 @@ impl ResizeObserverSize { } } - pub fn new( + pub(crate) fn new( window: &Window, size_impl: ResizeObserverSizeImpl, can_gc: CanGc, diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index 10768da2189..bfe7b1af198 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -33,7 +33,7 @@ use crate::dom::underlyingsourcecontainer::UnderlyingSourceType; use crate::script_runtime::{CanGc, StreamConsumer}; #[dom_struct] -pub struct Response { +pub(crate) struct Response { reflector_: Reflector, headers_reflector: MutNullableDom<Headers>, #[no_trace] @@ -52,7 +52,7 @@ pub struct Response { #[allow(non_snake_case)] impl Response { - pub fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Response { + pub(crate) fn new_inherited(global: &GlobalScope, can_gc: CanGc) -> Response { let stream = ReadableStream::new_with_external_underlying_source( global, UnderlyingSourceType::FetchResponse, @@ -73,7 +73,7 @@ impl Response { } // https://fetch.spec.whatwg.org/#dom-response - pub fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> { + pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Response> { Self::new_with_proto(global, None, can_gc) } @@ -90,7 +90,7 @@ impl Response { ) } - pub fn error_stream(&self, error: Error) { + pub(crate) fn error_stream(&self, error: Error) { if let Some(body) = self.body_stream.get() { body.error_native(error); } @@ -393,12 +393,16 @@ fn serialize_without_fragment(url: &ServoUrl) -> &str { } impl Response { - pub fn set_type(&self, new_response_type: DOMResponseType, can_gc: CanGc) { + pub(crate) fn set_type(&self, new_response_type: DOMResponseType, can_gc: CanGc) { *self.response_type.borrow_mut() = new_response_type; self.set_response_members_by_type(new_response_type, can_gc); } - pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>, can_gc: CanGc) { + pub(crate) fn set_headers( + &self, + option_hyper_headers: Option<Serde<HyperHeaders>>, + can_gc: CanGc, + ) { self.Headers(can_gc) .set_headers(match option_hyper_headers { Some(hyper_headers) => hyper_headers.into_inner(), @@ -406,15 +410,15 @@ impl Response { }); } - pub fn set_status(&self, status: &HttpStatus) { + pub(crate) fn set_status(&self, status: &HttpStatus) { self.status.borrow_mut().clone_from(status); } - pub fn set_final_url(&self, final_url: ServoUrl) { + pub(crate) fn set_final_url(&self, final_url: ServoUrl) { *self.url.borrow_mut() = Some(final_url); } - pub fn set_redirected(&self, is_redirected: bool) { + pub(crate) fn set_redirected(&self, is_redirected: bool) { *self.redirected.borrow_mut() = is_redirected; } @@ -441,11 +445,11 @@ impl Response { } } - pub fn set_stream_consumer(&self, sc: Option<StreamConsumer>) { + pub(crate) fn set_stream_consumer(&self, sc: Option<StreamConsumer>) { *self.stream_consumer.borrow_mut() = sc; } - pub fn stream_chunk(&self, chunk: Vec<u8>) { + pub(crate) fn stream_chunk(&self, chunk: Vec<u8>) { // Note, are these two actually mutually exclusive? if let Some(stream_consumer) = self.stream_consumer.borrow().as_ref() { stream_consumer.consume_chunk(chunk.as_slice()); @@ -455,7 +459,7 @@ impl Response { } #[allow(crown::unrooted_must_root)] - pub fn finish(&self) { + pub(crate) fn finish(&self) { if let Some(body) = self.body_stream.get() { body.controller_close_native(); } diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs index 55111759a78..5b5f8f353bd 100644 --- a/components/script/dom/rtcdatachannel.rs +++ b/components/script/dom/rtcdatachannel.rs @@ -38,7 +38,7 @@ use crate::dom::rtcpeerconnection::RTCPeerConnection; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCDataChannel { +pub(crate) struct RTCDataChannel { eventtarget: EventTarget, #[ignore_malloc_size_of = "defined in servo-media"] servo_media_id: DataChannelId, @@ -56,7 +56,7 @@ pub struct RTCDataChannel { impl RTCDataChannel { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( peer_connection: &RTCPeerConnection, label: USVString, options: &RTCDataChannelInit, @@ -90,7 +90,7 @@ impl RTCDataChannel { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, peer_connection: &RTCPeerConnection, label: USVString, @@ -113,7 +113,7 @@ impl RTCDataChannel { rtc_data_channel } - pub fn on_open(&self, can_gc: CanGc) { + pub(crate) fn on_open(&self, can_gc: CanGc) { let event = Event::new( &self.global(), atom!("open"), @@ -124,7 +124,7 @@ impl RTCDataChannel { event.upcast::<Event>().fire(self.upcast(), can_gc); } - pub fn on_close(&self, can_gc: CanGc) { + pub(crate) fn on_close(&self, can_gc: CanGc) { let event = Event::new( &self.global(), atom!("close"), @@ -138,7 +138,7 @@ impl RTCDataChannel { .unregister_data_channel(&self.servo_media_id); } - pub fn on_error(&self, error: WebRtcError, can_gc: CanGc) { + pub(crate) fn on_error(&self, error: WebRtcError, can_gc: CanGc) { let global = self.global(); let cx = GlobalScope::get_cx(); let _ac = JSAutoRealm::new(*cx, self.reflector().get_jsobject().get()); @@ -159,7 +159,7 @@ impl RTCDataChannel { } #[allow(unsafe_code)] - pub fn on_message(&self, channel_message: DataChannelMessage, can_gc: CanGc) { + pub(crate) fn on_message(&self, channel_message: DataChannelMessage, can_gc: CanGc) { unsafe { let global = self.global(); let cx = GlobalScope::get_cx(); @@ -206,7 +206,7 @@ impl RTCDataChannel { } } - pub fn on_state_change(&self, state: DataChannelState, can_gc: CanGc) { + pub(crate) fn on_state_change(&self, state: DataChannelState, can_gc: CanGc) { if let DataChannelState::Closing = state { let event = Event::new( &self.global(), diff --git a/components/script/dom/rtcdatachannelevent.rs b/components/script/dom/rtcdatachannelevent.rs index dc35fc55621..2b7951d8d82 100644 --- a/components/script/dom/rtcdatachannelevent.rs +++ b/components/script/dom/rtcdatachannelevent.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCDataChannelEvent { +pub(crate) struct RTCDataChannelEvent { event: Event, channel: Dom<RTCDataChannel>, } @@ -34,7 +34,7 @@ impl RTCDataChannelEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/rtcerror.rs b/components/script/dom/rtcerror.rs index c58a09d4d01..114e886950c 100644 --- a/components/script/dom/rtcerror.rs +++ b/components/script/dom/rtcerror.rs @@ -17,7 +17,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCError { +pub(crate) struct RTCError { exception: Dom<DOMException>, error_detail: RTCErrorDetailType, sdp_line_number: Option<i32>, @@ -43,7 +43,7 @@ impl RTCError { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, init: &RTCErrorInit, message: DOMString, diff --git a/components/script/dom/rtcerrorevent.rs b/components/script/dom/rtcerrorevent.rs index 9dccf41402e..722f9e3e42f 100644 --- a/components/script/dom/rtcerrorevent.rs +++ b/components/script/dom/rtcerrorevent.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCErrorEvent { +pub(crate) struct RTCErrorEvent { event: Event, error: Dom<RTCError>, } @@ -34,7 +34,7 @@ impl RTCErrorEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/rtcicecandidate.rs b/components/script/dom/rtcicecandidate.rs index 1fec862fc60..9b9350604ec 100644 --- a/components/script/dom/rtcicecandidate.rs +++ b/components/script/dom/rtcicecandidate.rs @@ -17,7 +17,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCIceCandidate { +pub(crate) struct RTCIceCandidate { reflector: Reflector, candidate: DOMString, sdp_m_id: Option<DOMString>, @@ -26,7 +26,7 @@ pub struct RTCIceCandidate { } impl RTCIceCandidate { - pub fn new_inherited( + pub(crate) fn new_inherited( candidate: DOMString, sdp_m_id: Option<DOMString>, sdp_m_line_index: Option<u16>, @@ -41,7 +41,7 @@ impl RTCIceCandidate { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, candidate: DOMString, sdp_m_id: Option<DOMString>, diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 25d99c26893..71e39922991 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -55,7 +55,7 @@ use crate::script_runtime::CanGc; use crate::task_source::SendableTaskSource; #[dom_struct] -pub struct RTCPeerConnection { +pub(crate) struct RTCPeerConnection { eventtarget: EventTarget, #[ignore_malloc_size_of = "defined in servo-media"] #[no_trace] @@ -159,7 +159,7 @@ impl WebRtcSignaller for RTCSignaller { } impl RTCPeerConnection { - pub fn new_inherited() -> RTCPeerConnection { + pub(crate) fn new_inherited() -> RTCPeerConnection { RTCPeerConnection { eventtarget: EventTarget::new_inherited(), controller: DomRefCell::new(None), @@ -213,7 +213,7 @@ impl RTCPeerConnection { this } - pub fn get_webrtc_controller(&self) -> &DomRefCell<Option<WebRtcController>> { + pub(crate) fn get_webrtc_controller(&self) -> &DomRefCell<Option<WebRtcController>> { &self.controller } @@ -325,7 +325,7 @@ impl RTCPeerConnection { }; } - pub fn register_data_channel(&self, id: DataChannelId, channel: &RTCDataChannel) { + pub(crate) fn register_data_channel(&self, id: DataChannelId, channel: &RTCDataChannel) { if self .data_channels .borrow_mut() @@ -336,7 +336,7 @@ impl RTCPeerConnection { } } - pub fn unregister_data_channel(&self, id: &DataChannelId) { + pub(crate) fn unregister_data_channel(&self, id: &DataChannelId) { self.data_channels.borrow_mut().remove(id); } diff --git a/components/script/dom/rtcpeerconnectioniceevent.rs b/components/script/dom/rtcpeerconnectioniceevent.rs index e677b96b3f9..f3391dcf9cd 100644 --- a/components/script/dom/rtcpeerconnectioniceevent.rs +++ b/components/script/dom/rtcpeerconnectioniceevent.rs @@ -22,14 +22,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCPeerConnectionIceEvent { +pub(crate) struct RTCPeerConnectionIceEvent { event: Event, candidate: Option<Dom<RTCIceCandidate>>, url: Option<DOMString>, } impl RTCPeerConnectionIceEvent { - pub fn new_inherited( + pub(crate) fn new_inherited( candidate: Option<&RTCIceCandidate>, url: Option<DOMString>, ) -> RTCPeerConnectionIceEvent { @@ -40,7 +40,7 @@ impl RTCPeerConnectionIceEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, ty: Atom, candidate: Option<&RTCIceCandidate>, diff --git a/components/script/dom/rtcrtpsender.rs b/components/script/dom/rtcrtpsender.rs index 398ae160347..60c2049dbaa 100644 --- a/components/script/dom/rtcrtpsender.rs +++ b/components/script/dom/rtcrtpsender.rs @@ -17,7 +17,7 @@ use crate::dom::promise::Promise; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCRtpSender { +pub(crate) struct RTCRtpSender { reflector_: Reflector, } diff --git a/components/script/dom/rtcrtptransceiver.rs b/components/script/dom/rtcrtptransceiver.rs index 514f9fe18cc..2aa8e07482f 100644 --- a/components/script/dom/rtcrtptransceiver.rs +++ b/components/script/dom/rtcrtptransceiver.rs @@ -16,7 +16,7 @@ use crate::dom::rtcrtpsender::RTCRtpSender; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCRtpTransceiver { +pub(crate) struct RTCRtpTransceiver { reflector_: Reflector, sender: Dom<RTCRtpSender>, direction: Cell<RTCRtpTransceiverDirection>, diff --git a/components/script/dom/rtcsessiondescription.rs b/components/script/dom/rtcsessiondescription.rs index fae3d5f6b3b..b3cb92f7240 100644 --- a/components/script/dom/rtcsessiondescription.rs +++ b/components/script/dom/rtcsessiondescription.rs @@ -17,14 +17,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCSessionDescription { +pub(crate) struct RTCSessionDescription { reflector: Reflector, ty: RTCSdpType, sdp: DOMString, } impl RTCSessionDescription { - pub fn new_inherited(ty: RTCSdpType, sdp: DOMString) -> RTCSessionDescription { + pub(crate) fn new_inherited(ty: RTCSdpType, sdp: DOMString) -> RTCSessionDescription { RTCSessionDescription { reflector: Reflector::new(), ty, diff --git a/components/script/dom/rtctrackevent.rs b/components/script/dom/rtctrackevent.rs index 03779eae794..d90e3fa2d0d 100644 --- a/components/script/dom/rtctrackevent.rs +++ b/components/script/dom/rtctrackevent.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct RTCTrackEvent { +pub(crate) struct RTCTrackEvent { event: Event, track: Dom<MediaStreamTrack>, } @@ -34,7 +34,7 @@ impl RTCTrackEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/screen.rs b/components/script/dom/screen.rs index 09335176aa4..b8acb37b041 100644 --- a/components/script/dom/screen.rs +++ b/components/script/dom/screen.rs @@ -17,7 +17,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Screen { +pub(crate) struct Screen { reflector_: Reflector, window: Dom<Window>, } @@ -30,7 +30,7 @@ impl Screen { } } - pub fn new(window: &Window) -> DomRoot<Screen> { + pub(crate) fn new(window: &Window) -> DomRoot<Screen> { reflect_dom_object( Box::new(Screen::new_inherited(window)), window, diff --git a/components/script/dom/securitypolicyviolationevent.rs b/components/script/dom/securitypolicyviolationevent.rs index 31bb29af2d2..fc973ac874e 100644 --- a/components/script/dom/securitypolicyviolationevent.rs +++ b/components/script/dom/securitypolicyviolationevent.rs @@ -21,7 +21,7 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/webappsec-csp/#securitypolicyviolationevent #[dom_struct] -pub struct SecurityPolicyViolationEvent { +pub(crate) struct SecurityPolicyViolationEvent { event: Event, document_uri: USVString, referrer: USVString, @@ -56,7 +56,7 @@ impl SecurityPolicyViolationEvent { } } - pub fn new_initialized( + pub(crate) fn new_initialized( global: &GlobalScope, init: &SecurityPolicyViolationEventInit, proto: Option<HandleObject>, @@ -87,7 +87,7 @@ impl SecurityPolicyViolationEvent { ev } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/selection.rs b/components/script/dom/selection.rs index 98b6be67059..9c5e2cd02ad 100644 --- a/components/script/dom/selection.rs +++ b/components/script/dom/selection.rs @@ -29,7 +29,7 @@ enum Direction { } #[dom_struct] -pub struct Selection { +pub(crate) struct Selection { reflector_: Reflector, document: Dom<Document>, range: MutNullableDom<Range>, @@ -48,7 +48,7 @@ impl Selection { } } - pub fn new(document: &Document) -> DomRoot<Selection> { + pub(crate) fn new(document: &Document) -> DomRoot<Selection> { reflect_dom_object( Box::new(Selection::new_inherited(document)), &*document.global(), @@ -80,7 +80,7 @@ impl Selection { } } - pub fn queue_selectionchange_task(&self) { + pub(crate) fn queue_selectionchange_task(&self) { if self.task_queued.get() { // Spec doesn't specify not to queue multiple tasks, // but it's much easier to code range operations if diff --git a/components/script/dom/serviceworker.rs b/components/script/dom/serviceworker.rs index 4c5e21adf08..0568bb40938 100644 --- a/components/script/dom/serviceworker.rs +++ b/components/script/dom/serviceworker.rs @@ -30,10 +30,10 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; use crate::task::TaskOnce; -pub type TrustedServiceWorkerAddress = Trusted<ServiceWorker>; +pub(crate) type TrustedServiceWorkerAddress = Trusted<ServiceWorker>; #[dom_struct] -pub struct ServiceWorker { +pub(crate) struct ServiceWorker { eventtarget: EventTarget, script_url: DomRefCell<String>, #[no_trace] @@ -58,7 +58,7 @@ impl ServiceWorker { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, script_url: ServoUrl, scope_url: ServoUrl, @@ -75,18 +75,18 @@ impl ServiceWorker { ) } - pub fn dispatch_simple_error(address: TrustedServiceWorkerAddress, can_gc: CanGc) { + pub(crate) fn dispatch_simple_error(address: TrustedServiceWorkerAddress, can_gc: CanGc) { let service_worker = address.root(); service_worker.upcast().fire_event(atom!("error"), can_gc); } - pub fn set_transition_state(&self, state: ServiceWorkerState, can_gc: CanGc) { + pub(crate) fn set_transition_state(&self, state: ServiceWorkerState, can_gc: CanGc) { self.state.set(state); self.upcast::<EventTarget>() .fire_event(atom!("statechange"), can_gc); } - pub fn get_script_url(&self) -> ServoUrl { + pub(crate) fn get_script_url(&self) -> ServoUrl { ServoUrl::parse(&self.script_url.borrow().clone()).unwrap() } diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index e7a8f223547..2028c21960a 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -29,7 +29,7 @@ use crate::script_runtime::CanGc; use crate::task_source::SendableTaskSource; #[dom_struct] -pub struct ServiceWorkerContainer { +pub(crate) struct ServiceWorkerContainer { eventtarget: EventTarget, controller: MutNullableDom<ServiceWorker>, client: Dom<Client>, @@ -45,7 +45,7 @@ impl ServiceWorkerContainer { } #[allow(crown::unrooted_must_root)] - pub fn new(global: &GlobalScope) -> DomRoot<ServiceWorkerContainer> { + pub(crate) 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, CanGc::note()) @@ -189,7 +189,7 @@ impl RegisterJobResultHandler { /// <https://w3c.github.io/ServiceWorker/#reject-job-promise> /// <https://w3c.github.io/ServiceWorker/#resolve-job-promise> /// Handle a result to either resolve or reject the register job promise. - pub fn handle(&mut self, result: JobResult) { + pub(crate) fn handle(&mut self, result: JobResult) { match result { JobResult::RejectPromise(error) => { let promise = self diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index b547dd51b57..870940d0609 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -52,7 +52,7 @@ use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue}; use crate::task_source::TaskSourceName; /// Messages used to control service worker event loop -pub enum ServiceWorkerScriptMsg { +pub(crate) enum ServiceWorkerScriptMsg { /// Message common to all workers CommonWorker(WorkerScriptMsg), /// Message to request a custom response by the service worker @@ -116,12 +116,12 @@ impl QueuedTaskConversion for ServiceWorkerScriptMsg { } /// Messages sent from the owning registration. -pub enum ServiceWorkerControlMsg { +pub(crate) enum ServiceWorkerControlMsg { /// Shutdown. Exit, } -pub enum MixedMessage { +pub(crate) enum MixedMessage { ServiceWorker(ServiceWorkerScriptMsg), Devtools(DevtoolScriptControlMsg), Control(ServiceWorkerControlMsg), @@ -129,7 +129,7 @@ pub enum MixedMessage { } #[dom_struct] -pub struct ServiceWorkerGlobalScope { +pub(crate) struct ServiceWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, #[ignore_malloc_size_of = "Defined in std"] @@ -235,7 +235,7 @@ impl ServiceWorkerGlobalScope { } #[allow(unsafe_code, clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( init: WorkerGlobalScopeInit, worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, @@ -267,7 +267,7 @@ impl ServiceWorkerGlobalScope { /// <https://w3c.github.io/ServiceWorker/#run-service-worker-algorithm> #[allow(unsafe_code, clippy::too_many_arguments)] - pub fn run_serviceworker_scope( + pub(crate) fn run_serviceworker_scope( scope_things: ScopeThings, own_sender: Sender<ServiceWorkerScriptMsg>, receiver: Receiver<ServiceWorkerScriptMsg>, diff --git a/components/script/dom/serviceworkerregistration.rs b/components/script/dom/serviceworkerregistration.rs index 0f48c7339a9..2f1318f2d8d 100644 --- a/components/script/dom/serviceworkerregistration.rs +++ b/components/script/dom/serviceworkerregistration.rs @@ -27,7 +27,7 @@ use crate::dom::workerglobalscope::prepare_workerscope_init; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ServiceWorkerRegistration { +pub(crate) struct ServiceWorkerRegistration { eventtarget: EventTarget, active: DomRefCell<Option<Dom<ServiceWorker>>>, installing: DomRefCell<Option<Dom<ServiceWorker>>>, @@ -64,7 +64,7 @@ impl ServiceWorkerRegistration { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, scope: ServoUrl, registration_id: ServiceWorkerRegistrationId, @@ -80,40 +80,40 @@ impl ServiceWorkerRegistration { } /// Does this registration have an active worker? - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.active.borrow().is_some() } - pub fn set_installing(&self, worker: &ServiceWorker) { + pub(crate) fn set_installing(&self, worker: &ServiceWorker) { *self.installing.borrow_mut() = Some(Dom::from_ref(worker)); } - pub fn get_navigation_preload_header_value(&self) -> Option<ByteString> { + pub(crate) fn get_navigation_preload_header_value(&self) -> Option<ByteString> { self.navigation_preload_header_value.borrow().clone() } - pub fn set_navigation_preload_header_value(&self, value: ByteString) { + pub(crate) fn set_navigation_preload_header_value(&self, value: ByteString) { let mut header_value = self.navigation_preload_header_value.borrow_mut(); *header_value = Some(value); } - pub fn get_navigation_preload_enabled(&self) -> bool { + pub(crate) fn get_navigation_preload_enabled(&self) -> bool { self.navigation_preload_enabled.get() } - pub fn set_navigation_preload_enabled(&self, flag: bool) { + pub(crate) fn set_navigation_preload_enabled(&self, flag: bool) { self.navigation_preload_enabled.set(flag) } - pub fn get_uninstalling(&self) -> bool { + pub(crate) fn get_uninstalling(&self) -> bool { self.uninstalling.get() } - pub fn set_uninstalling(&self, flag: bool) { + pub(crate) fn set_uninstalling(&self, flag: bool) { self.uninstalling.set(flag) } - pub fn create_scope_things(global: &GlobalScope, script_url: ServoUrl) -> ScopeThings { + pub(crate) fn create_scope_things(global: &GlobalScope, script_url: ServoUrl) -> ScopeThings { let worker_load_origin = WorkerScriptLoadOrigin { referrer_url: match global.get_referrer() { Referrer::Client(url) => Some(url), @@ -137,7 +137,7 @@ impl ServiceWorkerRegistration { } // https://w3c.github.io/ServiceWorker/#get-newest-worker-algorithm - pub fn get_newest_worker(&self) -> Option<DomRoot<ServiceWorker>> { + pub(crate) fn get_newest_worker(&self) -> Option<DomRoot<ServiceWorker>> { let installing = self.installing.borrow(); let waiting = self.waiting.borrow(); let active = self.active.borrow(); @@ -149,7 +149,7 @@ impl ServiceWorkerRegistration { } } -pub fn longest_prefix_match(stored_scope: &ServoUrl, potential_match: &ServoUrl) -> bool { +pub(crate) fn longest_prefix_match(stored_scope: &ServoUrl, potential_match: &ServoUrl) -> bool { if stored_scope.origin() != potential_match.origin() { return false; } diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index e9be6f8b657..8c80068ef83 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -46,7 +46,7 @@ use crate::script_runtime::CanGc; type ParseNodeId = usize; #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct ParseNode { +pub(crate) struct ParseNode { id: ParseNodeId, #[no_trace] qual_name: Option<QualName>, @@ -206,7 +206,7 @@ fn create_buffer_queue(mut buffers: VecDeque<SendTendril<UTF8>>) -> BufferQueue // #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { document: Dom<Document>, #[ignore_malloc_size_of = "Defined in std"] #[no_trace] @@ -222,7 +222,7 @@ pub struct Tokenizer { } impl Tokenizer { - pub fn new( + pub(crate) fn new( document: &Document, url: ServoUrl, fragment_context: Option<super::FragmentContext>, @@ -284,7 +284,7 @@ impl Tokenizer { tokenizer } - pub fn feed( + pub(crate) fn feed( &self, input: &BufferQueue, can_gc: CanGc, @@ -330,7 +330,7 @@ impl Tokenizer { } } - pub fn end(&self, can_gc: CanGc) { + pub(crate) fn end(&self, can_gc: CanGc) { self.html_tokenizer_sender .send(ToHtmlTokenizerMsg::End) .unwrap(); @@ -353,11 +353,11 @@ impl Tokenizer { } } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.url } - pub fn set_plaintext_state(&self) { + pub(crate) fn set_plaintext_state(&self) { self.html_tokenizer_sender .send(ToHtmlTokenizerMsg::SetPlainTextState) .unwrap(); @@ -634,7 +634,7 @@ struct ParseNodeData { is_integration_point: bool, } -pub struct Sink { +pub(crate) struct Sink { current_line: Cell<u64>, parse_node_data: RefCell<HashMap<ParseNodeId, ParseNodeData>>, next_parse_node_id: Cell<ParseNodeId>, diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index b4102a2c153..a7fad312af5 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -34,13 +34,13 @@ use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>>, } impl Tokenizer { - pub fn new( + pub(crate) fn new( document: &Document, url: ServoUrl, fragment_context: Option<super::FragmentContext>, @@ -80,7 +80,7 @@ impl Tokenizer { Tokenizer { inner } } - pub fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { + pub(crate) fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { match self.inner.feed(input) { TokenizerResult::Done => TokenizerResult::Done, TokenizerResult::Script(script) => { @@ -89,15 +89,15 @@ impl Tokenizer { } } - pub fn end(&self) { + pub(crate) fn end(&self) { self.inner.end(); } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.inner.sink.sink.base_url } - pub fn set_plaintext_state(&self) { + pub(crate) fn set_plaintext_state(&self) { self.inner.set_plaintext_state(); } } diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index bc51413f5f3..18a7aed45f0 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -89,7 +89,7 @@ mod xml; /// ^ /// insertion point /// ``` -pub struct ServoParser { +pub(crate) struct ServoParser { reflector: Reflector, /// The document associated with this parser. document: Dom<Document>, @@ -130,29 +130,29 @@ pub struct ServoParser { prefetch_input: BufferQueue, } -pub struct ElementAttribute { +pub(crate) struct ElementAttribute { name: QualName, value: DOMString, } #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ParsingAlgorithm { +pub(crate) enum ParsingAlgorithm { Normal, Fragment, } impl ElementAttribute { - pub fn new(name: QualName, value: DOMString) -> ElementAttribute { + pub(crate) fn new(name: QualName, value: DOMString) -> ElementAttribute { ElementAttribute { name, value } } } impl ServoParser { - pub fn parser_is_not_active(&self) -> bool { + pub(crate) fn parser_is_not_active(&self) -> bool { self.can_write() } - pub fn parse_html_document( + pub(crate) fn parse_html_document( document: &Document, input: Option<DOMString>, url: ServoUrl, @@ -186,7 +186,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#parsing-html-fragments - pub fn parse_html_fragment( + pub(crate) fn parse_html_fragment( context: &Element, input: DOMString, can_gc: CanGc, @@ -251,7 +251,7 @@ impl ServoParser { } } - pub fn parse_html_script_input(document: &Document, url: ServoUrl) { + pub(crate) fn parse_html_script_input(document: &Document, url: ServoUrl) { let parser = ServoParser::new( document, Tokenizer::Html(self::html::Tokenizer::new( @@ -266,7 +266,7 @@ impl ServoParser { document.set_current_parser(Some(&parser)); } - pub fn parse_xml_document( + pub(crate) fn parse_xml_document( document: &Document, input: Option<DOMString>, url: ServoUrl, @@ -286,11 +286,11 @@ impl ServoParser { } } - pub fn script_nesting_level(&self) -> usize { + pub(crate) fn script_nesting_level(&self) -> usize { self.script_nesting_level.get() } - pub fn is_script_created(&self) -> bool { + pub(crate) fn is_script_created(&self) -> bool { self.script_created_parser } @@ -308,7 +308,7 @@ impl ServoParser { /// ^ /// insertion point /// ``` - pub fn resume_with_pending_parsing_blocking_script( + pub(crate) fn resume_with_pending_parsing_blocking_script( &self, script: &HTMLScriptElement, result: ScriptResult, @@ -334,12 +334,12 @@ impl ServoParser { } } - pub fn can_write(&self) -> bool { + pub(crate) fn can_write(&self) -> bool { self.script_created_parser || self.script_nesting_level.get() > 0 } /// Steps 6-8 of <https://html.spec.whatwg.org/multipage/#document.write()> - pub fn write(&self, text: Vec<DOMString>, can_gc: CanGc) { + pub(crate) fn write(&self, text: Vec<DOMString>, can_gc: CanGc) { assert!(self.can_write()); if self.document.has_pending_parsing_blocking_script() { @@ -399,7 +399,7 @@ impl ServoParser { } // Steps 4-6 of https://html.spec.whatwg.org/multipage/#dom-document-close - pub fn close(&self, can_gc: CanGc) { + pub(crate) fn close(&self, can_gc: CanGc) { assert!(self.script_created_parser); // Step 4. @@ -415,7 +415,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#abort-a-parser - pub fn abort(&self, can_gc: CanGc) { + pub(crate) fn abort(&self, can_gc: CanGc) { assert!(!self.aborted.get()); self.aborted.set(true); @@ -437,7 +437,7 @@ impl ServoParser { } // https://html.spec.whatwg.org/multipage/#active-parser - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.script_nesting_level() > 0 && !self.aborted.get() } @@ -773,7 +773,7 @@ impl Tokenizer { /// The context required for asynchronously fetching a document /// and parsing it progressively. -pub struct ParserContext { +pub(crate) struct ParserContext { /// The parser that initiated the request. parser: Option<Trusted<ServoParser>>, /// Is this a synthesized document @@ -789,7 +789,7 @@ pub struct ParserContext { } impl ParserContext { - pub fn new(id: PipelineId, url: ServoUrl) -> ParserContext { + pub(crate) fn new(id: PipelineId, url: ServoUrl) -> ParserContext { ParserContext { parser: None, is_synthesized_document: false, @@ -1057,9 +1057,9 @@ impl FetchResponseListener for ParserContext { impl PreInvoke for ParserContext {} -pub struct FragmentContext<'a> { - pub context_elem: &'a Node, - pub form_elem: Option<&'a Node>, +pub(crate) struct FragmentContext<'a> { + pub(crate) context_elem: &'a Node, + pub(crate) form_elem: Option<&'a Node>, } #[allow(crown::unrooted_must_root)] @@ -1104,7 +1104,7 @@ fn insert( #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Sink { +pub(crate) struct Sink { #[no_trace] base_url: ServoUrl, document: Dom<Document>, diff --git a/components/script/dom/servoparser/prefetch.rs b/components/script/dom/servoparser/prefetch.rs index 750af5c5f48..835cdc1d1f3 100644 --- a/components/script/dom/servoparser/prefetch.rs +++ b/components/script/dom/servoparser/prefetch.rs @@ -26,7 +26,7 @@ use crate::stylesheet_loader::stylesheet_fetch_request; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<PrefetchSink>, } @@ -39,7 +39,7 @@ unsafe impl CustomTraceable for HtmlTokenizer<PrefetchSink> { } impl Tokenizer { - pub fn new(document: &Document) -> Self { + pub(crate) fn new(document: &Document) -> Self { let sink = PrefetchSink { origin: document.origin().immutable().clone(), pipeline_id: document.global().pipeline_id(), @@ -58,7 +58,7 @@ impl Tokenizer { Tokenizer { inner } } - pub fn feed(&self, input: &BufferQueue) { + pub(crate) fn feed(&self, input: &BufferQueue) { while let TokenizerResult::Script(PrefetchHandle) = self.inner.feed(input) {} } } diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index d0d7b153b99..43248988094 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -22,13 +22,13 @@ use crate::dom::servoparser::{ParsingAlgorithm, Sink}; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct Tokenizer { +pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in xml5ever"] inner: XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>>, } impl Tokenizer { - pub fn new(document: &Document, url: ServoUrl) -> Self { + pub(crate) fn new(document: &Document, url: ServoUrl) -> Self { let sink = Sink { base_url: url, document: Dom::from_ref(document), @@ -43,7 +43,7 @@ impl Tokenizer { Tokenizer { inner: tok } } - pub fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { + pub(crate) fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> { self.inner.run(input); match self.inner.sink.sink.script.take() { Some(script) => TokenizerResult::Script(script), @@ -51,11 +51,11 @@ impl Tokenizer { } } - pub fn end(&self) { + pub(crate) fn end(&self) { self.inner.end() } - pub fn url(&self) -> &ServoUrl { + pub(crate) fn url(&self) -> &ServoUrl { &self.inner.sink.sink.base_url } } diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index ad75bf72e5f..f6ccd7c9477 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -36,14 +36,14 @@ use crate::stylesheet_set::StylesheetSetRef; /// Whether a shadow root hosts an User Agent widget. #[derive(JSTraceable, MallocSizeOf, PartialEq)] -pub enum IsUserAgentWidget { +pub(crate) enum IsUserAgentWidget { No, Yes, } /// <https://dom.spec.whatwg.org/#interface-shadowroot> #[dom_struct] -pub struct ShadowRoot { +pub(crate) struct ShadowRoot { document_fragment: DocumentFragment, document_or_shadow_root: DocumentOrShadowRoot, document: Dom<Document>, @@ -90,7 +90,7 @@ impl ShadowRoot { } } - pub fn new( + pub(crate) fn new( host: &Element, document: &Document, mode: ShadowRootMode, @@ -103,7 +103,7 @@ impl ShadowRoot { ) } - pub fn detach(&self) { + pub(crate) fn detach(&self) { self.document.unregister_shadow_root(self); let node = self.upcast::<Node>(); node.set_containing_shadow_root(None); @@ -111,16 +111,16 @@ impl ShadowRoot { self.host.set(None); } - pub fn get_focused_element(&self) -> Option<DomRoot<Element>> { + pub(crate) fn get_focused_element(&self) -> Option<DomRoot<Element>> { //XXX get retargeted focused element None } - pub fn stylesheet_count(&self) -> usize { + pub(crate) fn stylesheet_count(&self) -> usize { self.author_styles.borrow().stylesheets.len() } - pub fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { let stylesheets = &self.author_styles.borrow().stylesheets; stylesheets @@ -131,7 +131,7 @@ impl ShadowRoot { /// Add a stylesheet owned by `owner` to the list of shadow root sheets, in the /// correct tree position. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { + pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { let stylesheets = &mut self.author_styles.borrow_mut().stylesheets; let insertion_point = stylesheets .iter() @@ -152,7 +152,7 @@ impl ShadowRoot { /// Remove a stylesheet owned by `owner` from the list of shadow root sheets. #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. - pub fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) { + pub(crate) fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) { DocumentOrShadowRoot::remove_stylesheet( owner, s, @@ -160,7 +160,7 @@ impl ShadowRoot { ) } - pub fn invalidate_stylesheets(&self) { + pub(crate) fn invalidate_stylesheets(&self) { self.document.invalidate_shadow_roots_stylesheets(); self.author_styles.borrow_mut().stylesheets.force_dirty(); // Mark the host element dirty so a reflow will be performed. @@ -171,7 +171,7 @@ impl ShadowRoot { /// Remove any existing association between the provided id and any elements /// in this shadow tree. - pub fn unregister_element_id(&self, to_unregister: &Element, id: Atom) { + pub(crate) fn unregister_element_id(&self, to_unregister: &Element, id: Atom) { self.document_or_shadow_root.unregister_named_element( self.document_fragment.id_map(), to_unregister, @@ -180,7 +180,7 @@ impl ShadowRoot { } /// Associate an element present in this shadow tree with the provided id. - pub fn register_element_id(&self, element: &Element, id: Atom) { + pub(crate) fn register_element_id(&self, element: &Element, id: Atom) { let root = self .upcast::<Node>() .inclusive_ancestors(ShadowIncluding::No) @@ -345,7 +345,7 @@ impl VirtualMethods for ShadowRoot { } #[allow(unsafe_code)] -pub trait LayoutShadowRootHelpers<'dom> { +pub(crate) trait LayoutShadowRootHelpers<'dom> { fn get_host_for_layout(self) -> LayoutDom<'dom, Element>; fn get_style_data_for_layout(self) -> &'dom CascadeData; unsafe fn flush_stylesheets<E: TElement>( diff --git a/components/script/dom/staticrange.rs b/components/script/dom/staticrange.rs index 31c4e276338..fef76ea1c2e 100644 --- a/components/script/dom/staticrange.rs +++ b/components/script/dom/staticrange.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct StaticRange { +pub(crate) struct StaticRange { abstract_range: AbstractRange, } @@ -40,7 +40,7 @@ impl StaticRange { ), } } - pub fn new_with_doc( + pub(crate) fn new_with_doc( document: &Document, proto: Option<HandleObject>, init: &StaticRangeInit, @@ -49,7 +49,7 @@ impl StaticRange { StaticRange::new_with_proto(document, proto, init, can_gc) } - pub fn new_with_proto( + pub(crate) fn new_with_proto( document: &Document, proto: Option<HandleObject>, init: &StaticRangeInit, diff --git a/components/script/dom/stereopannernode.rs b/components/script/dom/stereopannernode.rs index 6a7929b8735..12a578a8fce 100644 --- a/components/script/dom/stereopannernode.rs +++ b/components/script/dom/stereopannernode.rs @@ -25,14 +25,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct StereoPannerNode { +pub(crate) struct StereoPannerNode { source_node: AudioScheduledSourceNode, pan: Dom<AudioParam>, } impl StereoPannerNode { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, options: &StereoPannerOptions, @@ -74,7 +74,7 @@ impl StereoPannerNode { }) } - pub fn new( + pub(crate) fn new( window: &Window, context: &BaseAudioContext, options: &StereoPannerOptions, diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index d307b5817ef..ae166e9fc9f 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -23,7 +23,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Storage { +pub(crate) struct Storage { reflector_: Reflector, #[no_trace] storage_type: StorageType, @@ -37,7 +37,7 @@ impl Storage { } } - pub fn new(global: &Window, storage_type: StorageType) -> DomRoot<Storage> { + pub(crate) fn new(global: &Window, storage_type: StorageType) -> DomRoot<Storage> { reflect_dom_object( Box::new(Storage::new_inherited(storage_type)), global, @@ -199,7 +199,7 @@ impl Storage { } /// <https://html.spec.whatwg.org/multipage/#send-a-storage-notification> - pub fn queue_storage_event( + pub(crate) fn queue_storage_event( &self, url: ServoUrl, key: Option<String>, diff --git a/components/script/dom/storageevent.rs b/components/script/dom/storageevent.rs index a99e8ce1a6d..343aa66b6ba 100644 --- a/components/script/dom/storageevent.rs +++ b/components/script/dom/storageevent.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct StorageEvent { +pub(crate) struct StorageEvent { event: Event, key: DomRefCell<Option<DOMString>>, old_value: DomRefCell<Option<DOMString>>, @@ -32,7 +32,7 @@ pub struct StorageEvent { #[allow(non_snake_case)] impl StorageEvent { - pub fn new_inherited( + pub(crate) fn new_inherited( key: Option<DOMString>, old_value: Option<DOMString>, new_value: Option<DOMString>, @@ -49,7 +49,7 @@ impl StorageEvent { } } - pub fn new_uninitialized( + pub(crate) fn new_uninitialized( window: &Window, url: DOMString, can_gc: CanGc, @@ -72,7 +72,7 @@ impl StorageEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &Window, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/stylepropertymapreadonly.rs b/components/script/dom/stylepropertymapreadonly.rs index 76e25c362e3..8b142685861 100644 --- a/components/script/dom/stylepropertymapreadonly.rs +++ b/components/script/dom/stylepropertymapreadonly.rs @@ -19,7 +19,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct StylePropertyMapReadOnly { +pub(crate) struct StylePropertyMapReadOnly { reflector: Reflector, entries: HashMapTracedValues<Atom, Dom<CSSStyleValue>>, } @@ -35,7 +35,7 @@ impl StylePropertyMapReadOnly { } } - pub fn from_iter<Entries>( + pub(crate) fn from_iter<Entries>( global: &GlobalScope, entries: Entries, ) -> DomRoot<StylePropertyMapReadOnly> diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs index bedb79c931d..be5de8ae4c2 100644 --- a/components/script/dom/stylesheet.rs +++ b/components/script/dom/stylesheet.rs @@ -14,7 +14,7 @@ use crate::dom::element::Element; use crate::dom::medialist::MediaList; #[dom_struct] -pub struct StyleSheet { +pub(crate) struct StyleSheet { reflector_: Reflector, type_: DOMString, href: Option<DOMString>, @@ -23,7 +23,7 @@ pub struct StyleSheet { impl StyleSheet { #[allow(crown::unrooted_must_root)] - pub fn new_inherited( + pub(crate) fn new_inherited( type_: DOMString, href: Option<DOMString>, title: Option<DOMString>, diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs index edfbbed5367..5315cb06360 100644 --- a/components/script/dom/stylesheetlist.rs +++ b/components/script/dom/stylesheetlist.rs @@ -19,27 +19,27 @@ use crate::script_runtime::CanGc; #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] -pub enum StyleSheetListOwner { +pub(crate) enum StyleSheetListOwner { Document(Dom<Document>), ShadowRoot(Dom<ShadowRoot>), } impl StyleSheetListOwner { - pub fn stylesheet_count(&self) -> usize { + pub(crate) fn stylesheet_count(&self) -> usize { match *self { StyleSheetListOwner::Document(ref doc) => doc.stylesheet_count(), StyleSheetListOwner::ShadowRoot(ref shadow_root) => shadow_root.stylesheet_count(), } } - pub fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { + pub(crate) fn stylesheet_at(&self, index: usize) -> Option<DomRoot<CSSStyleSheet>> { match *self { StyleSheetListOwner::Document(ref doc) => doc.stylesheet_at(index), StyleSheetListOwner::ShadowRoot(ref shadow_root) => shadow_root.stylesheet_at(index), } } - pub fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { + pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { match *self { StyleSheetListOwner::Document(ref doc) => doc.add_stylesheet(owner, sheet), StyleSheetListOwner::ShadowRoot(ref shadow_root) => { @@ -48,7 +48,7 @@ impl StyleSheetListOwner { } } - pub fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) { + pub(crate) fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) { match *self { StyleSheetListOwner::Document(ref doc) => doc.remove_stylesheet(owner, s), StyleSheetListOwner::ShadowRoot(ref shadow_root) => { @@ -57,7 +57,7 @@ impl StyleSheetListOwner { } } - pub fn invalidate_stylesheets(&self) { + pub(crate) fn invalidate_stylesheets(&self) { match *self { StyleSheetListOwner::Document(ref doc) => doc.invalidate_stylesheets(), StyleSheetListOwner::ShadowRoot(ref shadow_root) => { @@ -68,7 +68,7 @@ impl StyleSheetListOwner { } #[dom_struct] -pub struct StyleSheetList { +pub(crate) struct StyleSheetList { reflector_: Reflector, document_or_shadow_root: StyleSheetListOwner, } @@ -83,7 +83,7 @@ impl StyleSheetList { } #[allow(crown::unrooted_must_root)] - pub fn new(window: &Window, doc_or_sr: StyleSheetListOwner) -> DomRoot<StyleSheetList> { + pub(crate) fn new(window: &Window, doc_or_sr: StyleSheetListOwner) -> DomRoot<StyleSheetList> { 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 6fb4e345b72..dd31099971a 100644 --- a/components/script/dom/submitevent.rs +++ b/components/script/dom/submitevent.rs @@ -21,7 +21,7 @@ use crate::script_runtime::CanGc; #[dom_struct] #[allow(non_snake_case)] -pub struct SubmitEvent { +pub(crate) struct SubmitEvent { event: Event, submitter: Option<DomRoot<HTMLElement>>, } @@ -34,7 +34,7 @@ impl SubmitEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/subtlecrypto.rs b/components/script/dom/subtlecrypto.rs index 7ac614b95fe..dc05ae822b3 100644 --- a/components/script/dom/subtlecrypto.rs +++ b/components/script/dom/subtlecrypto.rs @@ -21,7 +21,6 @@ use js::jsval::ObjectValue; use js::rust::MutableHandleObject; use js::typedarray::ArrayBufferU8; use ring::{digest, hkdf, hmac, pbkdf2}; -use serde_json; use servo_rand::{RngCore, ServoRng}; use crate::dom::bindings::buffer_source::create_buffer_source; @@ -114,7 +113,7 @@ type Aes192Gcm256Iv = AesGcm<Aes192, U32>; type Aes256Gcm256Iv = AesGcm<Aes256, U32>; #[dom_struct] -pub struct SubtleCrypto { +pub(crate) struct SubtleCrypto { reflector_: Reflector, #[no_trace] rng: DomRefCell<ServoRng>, @@ -1075,9 +1074,9 @@ impl SubtleCryptoMethods<crate::DomTypeHolder> for SubtleCrypto { // so they can be sent safely when running steps in parallel. #[derive(Clone, Debug)] -pub struct SubtleAlgorithm { +pub(crate) struct SubtleAlgorithm { #[allow(dead_code)] - pub name: String, + pub(crate) name: String, } impl From<DOMString> for SubtleAlgorithm { @@ -1089,10 +1088,10 @@ impl From<DOMString> for SubtleAlgorithm { } #[derive(Clone, Debug)] -pub struct SubtleAesCbcParams { +pub(crate) struct SubtleAesCbcParams { #[allow(dead_code)] - pub name: String, - pub iv: Vec<u8>, + pub(crate) name: String, + pub(crate) iv: Vec<u8>, } impl From<RootedTraceableBox<AesCbcParams>> for SubtleAesCbcParams { @@ -1109,10 +1108,10 @@ impl From<RootedTraceableBox<AesCbcParams>> for SubtleAesCbcParams { } #[derive(Clone, Debug)] -pub struct SubtleAesCtrParams { - pub name: String, - pub counter: Vec<u8>, - pub length: u8, +pub(crate) struct SubtleAesCtrParams { + pub(crate) name: String, + pub(crate) counter: Vec<u8>, + pub(crate) length: u8, } impl From<RootedTraceableBox<AesCtrParams>> for SubtleAesCtrParams { @@ -1130,11 +1129,11 @@ impl From<RootedTraceableBox<AesCtrParams>> for SubtleAesCtrParams { } #[derive(Clone, Debug)] -pub struct SubtleAesGcmParams { - pub name: String, - pub iv: Vec<u8>, - pub additional_data: Option<Vec<u8>>, - pub tag_length: Option<u8>, +pub(crate) struct SubtleAesGcmParams { + pub(crate) name: String, + pub(crate) iv: Vec<u8>, + pub(crate) additional_data: Option<Vec<u8>>, + pub(crate) tag_length: Option<u8>, } impl From<RootedTraceableBox<AesGcmParams>> for SubtleAesGcmParams { @@ -1158,9 +1157,9 @@ impl From<RootedTraceableBox<AesGcmParams>> for SubtleAesGcmParams { } #[derive(Clone, Debug)] -pub struct SubtleAesKeyGenParams { - pub name: String, - pub length: u16, +pub(crate) struct SubtleAesKeyGenParams { + pub(crate) name: String, + pub(crate) length: u16, } impl From<AesKeyGenParams> for SubtleAesKeyGenParams { @@ -1244,7 +1243,7 @@ impl SubtleHmacKeyGenParams { } /// <https://w3c.github.io/webcrypto/#hkdf-params> #[derive(Clone, Debug)] -pub struct SubtleHkdfParams { +pub(crate) struct SubtleHkdfParams { /// <https://w3c.github.io/webcrypto/#dfn-HkdfParams-hash> hash: DigestAlgorithm, @@ -1275,7 +1274,7 @@ impl SubtleHkdfParams { /// <https://w3c.github.io/webcrypto/#dfn-Pbkdf2Params> #[derive(Clone, Debug)] -pub struct SubtlePbkdf2Params { +pub(crate) struct SubtlePbkdf2Params { /// <https://w3c.github.io/webcrypto/#dfn-Pbkdf2Params-salt> salt: Vec<u8>, @@ -2576,7 +2575,7 @@ impl SubtleCrypto { } } -pub enum AesExportedKey { +pub(crate) enum AesExportedKey { Raw(Vec<u8>), Jwk(Box<JsonWebKey>), } diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs index d96f0ff3e50..0a24ff4b545 100644 --- a/components/script/dom/svgelement.rs +++ b/components/script/dom/svgelement.rs @@ -18,7 +18,7 @@ use crate::dom::virtualmethods::VirtualMethods; use crate::script_runtime::CanGc; #[dom_struct] -pub struct SVGElement { +pub(crate) struct SVGElement { element: Element, style_decl: MutNullableDom<CSSStyleDeclaration>, } @@ -32,7 +32,7 @@ impl SVGElement { SVGElement::new_inherited_with_state(ElementState::empty(), tag_name, prefix, document) } - pub fn new_inherited_with_state( + pub(crate) fn new_inherited_with_state( state: ElementState, tag_name: LocalName, prefix: Option<Prefix>, @@ -44,7 +44,7 @@ impl SVGElement { } } - pub fn new( + pub(crate) fn new( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs index 629cd582892..48e7f1069a0 100644 --- a/components/script/dom/svggraphicselement.rs +++ b/components/script/dom/svggraphicselement.rs @@ -12,12 +12,12 @@ use crate::dom::svgelement::SVGElement; use crate::dom::virtualmethods::VirtualMethods; #[dom_struct] -pub struct SVGGraphicsElement { +pub(crate) struct SVGGraphicsElement { svgelement: SVGElement, } impl SVGGraphicsElement { - pub fn new_inherited( + pub(crate) fn new_inherited( tag_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -30,7 +30,7 @@ impl SVGGraphicsElement { ) } - pub fn new_inherited_with_state( + pub(crate) fn new_inherited_with_state( state: ElementState, tag_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 731df017367..50f4eb0e957 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -23,7 +23,7 @@ const DEFAULT_WIDTH: u32 = 300; const DEFAULT_HEIGHT: u32 = 150; #[dom_struct] -pub struct SVGSVGElement { +pub(crate) struct SVGSVGElement { svggraphicselement: SVGGraphicsElement, } @@ -39,7 +39,7 @@ impl SVGSVGElement { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, document: &Document, @@ -55,7 +55,7 @@ impl SVGSVGElement { } } -pub trait LayoutSVGSVGElementHelpers { +pub(crate) trait LayoutSVGSVGElementHelpers { fn data(self) -> SVGSVGData; } diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 530544c97e1..9e3aa7749c6 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -53,7 +53,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; use crate::timers::OneshotTimerCallback; #[dom_struct] -pub struct TestBinding { +pub(crate) struct TestBinding { reflector_: Reflector, url: MutableWeakRef<URL>, } @@ -1143,16 +1143,16 @@ impl TestBindingMethods<crate::DomTypeHolder> for TestBinding { } impl TestBinding { - pub fn condition_satisfied(_: SafeJSContext, _: HandleObject) -> bool { + pub(crate) fn condition_satisfied(_: SafeJSContext, _: HandleObject) -> bool { true } - pub fn condition_unsatisfied(_: SafeJSContext, _: HandleObject) -> bool { + pub(crate) fn condition_unsatisfied(_: SafeJSContext, _: HandleObject) -> bool { false } } #[derive(JSTraceable, MallocSizeOf)] -pub struct TestBindingCallback { +pub(crate) struct TestBindingCallback { #[ignore_malloc_size_of = "unclear ownership semantics"] promise: TrustedPromise, value: DOMString, @@ -1160,7 +1160,7 @@ pub struct TestBindingCallback { impl TestBindingCallback { #[allow(crown::unrooted_must_root)] - pub fn invoke(self) { + pub(crate) fn invoke(self) { self.promise.root().resolve_native(&self.value); } } diff --git a/components/script/dom/testbindingiterable.rs b/components/script/dom/testbindingiterable.rs index 85fa46d2cb2..20da79122f7 100644 --- a/components/script/dom/testbindingiterable.rs +++ b/components/script/dom/testbindingiterable.rs @@ -17,7 +17,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TestBindingIterable { +pub(crate) struct TestBindingIterable { reflector: Reflector, vals: DomRefCell<Vec<DOMString>>, } diff --git a/components/script/dom/testbindingmaplike.rs b/components/script/dom/testbindingmaplike.rs index 86b4c423939..81da08748c7 100644 --- a/components/script/dom/testbindingmaplike.rs +++ b/components/script/dom/testbindingmaplike.rs @@ -22,7 +22,7 @@ use crate::script_runtime::CanGc; /// maplike<DOMString, long> #[dom_struct] -pub struct TestBindingMaplike { +pub(crate) struct TestBindingMaplike { reflector: Reflector, #[custom_trace] internal: DomRefCell<IndexMap<DOMString, i32>>, diff --git a/components/script/dom/testbindingpairiterable.rs b/components/script/dom/testbindingpairiterable.rs index 8f11432d45a..03df811260b 100644 --- a/components/script/dom/testbindingpairiterable.rs +++ b/components/script/dom/testbindingpairiterable.rs @@ -18,7 +18,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TestBindingPairIterable { +pub(crate) struct TestBindingPairIterable { reflector: Reflector, map: DomRefCell<Vec<(DOMString, u32)>>, } diff --git a/components/script/dom/testbindingproxy.rs b/components/script/dom/testbindingproxy.rs index 4908d078bed..c223b56c36e 100644 --- a/components/script/dom/testbindingproxy.rs +++ b/components/script/dom/testbindingproxy.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::str::DOMString; use crate::dom::testbinding::TestBinding; #[dom_struct] -pub struct TestBindingProxy { +pub(crate) struct TestBindingProxy { testbinding_: TestBinding, } diff --git a/components/script/dom/testbindingsetlike.rs b/components/script/dom/testbindingsetlike.rs index 3bf26c17f7f..b3a8c4b450a 100644 --- a/components/script/dom/testbindingsetlike.rs +++ b/components/script/dom/testbindingsetlike.rs @@ -21,7 +21,7 @@ use crate::setlike; // setlike<DOMString> #[dom_struct] -pub struct TestBindingSetlike { +pub(crate) struct TestBindingSetlike { reflector: Reflector, #[custom_trace] internal: DomRefCell<IndexSet<DOMString>>, diff --git a/components/script/dom/testns.rs b/components/script/dom/testns.rs index e6a3574449b..bd9f8a20127 100644 --- a/components/script/dom/testns.rs +++ b/components/script/dom/testns.rs @@ -4,4 +4,4 @@ // check-tidy: no specs after this line -pub struct TestNS(()); +pub(crate) struct TestNS(()); diff --git a/components/script/dom/testrunner.rs b/components/script/dom/testrunner.rs index 1d0dd0177ce..e8084e5cb2a 100644 --- a/components/script/dom/testrunner.rs +++ b/components/script/dom/testrunner.rs @@ -18,18 +18,18 @@ use crate::script_runtime::CanGc; // https://webbluetoothcg.github.io/web-bluetooth/tests#test-runner #[dom_struct] -pub struct TestRunner { +pub(crate) struct TestRunner { reflector_: Reflector, } impl TestRunner { - pub fn new_inherited() -> TestRunner { + pub(crate) fn new_inherited() -> TestRunner { TestRunner { reflector_: Reflector::new(), } } - pub fn new(global: &GlobalScope) -> DomRoot<TestRunner> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<TestRunner> { reflect_dom_object(Box::new(TestRunner::new_inherited()), global, CanGc::note()) } diff --git a/components/script/dom/testworklet.rs b/components/script/dom/testworklet.rs index b1589dd24f8..ae09e2b0d22 100644 --- a/components/script/dom/testworklet.rs +++ b/components/script/dom/testworklet.rs @@ -24,7 +24,7 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct TestWorklet { +pub(crate) struct TestWorklet { reflector: Reflector, worklet: Dom<Worklet>, } diff --git a/components/script/dom/testworkletglobalscope.rs b/components/script/dom/testworkletglobalscope.rs index 4a42d71a292..986dd0ce20b 100644 --- a/components/script/dom/testworkletglobalscope.rs +++ b/components/script/dom/testworkletglobalscope.rs @@ -22,7 +22,7 @@ use crate::script_runtime::JSContext; // check-tidy: no specs after this line #[dom_struct] -pub struct TestWorkletGlobalScope { +pub(crate) struct TestWorkletGlobalScope { // The worklet global for this object worklet_global: WorkletGlobalScope, // The key/value pairs @@ -54,7 +54,7 @@ impl TestWorkletGlobalScope { unsafe { TestWorkletGlobalScopeBinding::Wrap(JSContext::from_ptr(runtime.cx()), global) } } - pub fn perform_a_worklet_task(&self, task: TestWorkletTask) { + pub(crate) fn perform_a_worklet_task(&self, task: TestWorkletTask) { match task { TestWorkletTask::Lookup(key, sender) => { debug!("Looking up key {}.", key); @@ -75,6 +75,6 @@ impl TestWorkletGlobalScopeMethods<crate::DomTypeHolder> for TestWorkletGlobalSc } /// Tasks which can be performed by test worklets. -pub enum TestWorkletTask { +pub(crate) enum TestWorkletTask { Lookup(String, Sender<Option<String>>), } diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs index b2d3fab2396..2f0e1c66857 100644 --- a/components/script/dom/text.rs +++ b/components/script/dom/text.rs @@ -22,18 +22,18 @@ use crate::script_runtime::CanGc; /// An HTML text node. #[dom_struct] -pub struct Text { +pub(crate) struct Text { characterdata: CharacterData, } impl Text { - pub fn new_inherited(text: DOMString, document: &Document) -> Text { + pub(crate) fn new_inherited(text: DOMString, document: &Document) -> Text { Text { characterdata: CharacterData::new_inherited(text, document), } } - pub fn new(text: DOMString, document: &Document, can_gc: CanGc) -> DomRoot<Text> { + pub(crate) fn new(text: DOMString, document: &Document, can_gc: CanGc) -> DomRoot<Text> { Self::new_with_proto(text, document, None, can_gc) } diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs index 313832d1471..184138ab3c0 100644 --- a/components/script/dom/textcontrol.rs +++ b/components/script/dom/textcontrol.rs @@ -19,19 +19,19 @@ use crate::dom::eventtarget::EventTarget; use crate::dom::node::{Node, NodeDamage, NodeTraits}; use crate::textinput::{SelectionDirection, SelectionState, TextInput, UTF8Bytes}; -pub trait TextControlElement: DerivedFrom<EventTarget> + DerivedFrom<Node> { +pub(crate) trait TextControlElement: DerivedFrom<EventTarget> + DerivedFrom<Node> { fn selection_api_applies(&self) -> bool; fn has_selectable_text(&self) -> bool; fn set_dirty_value_flag(&self, value: bool); } -pub struct TextControlSelection<'a, E: TextControlElement> { +pub(crate) struct TextControlSelection<'a, E: TextControlElement> { element: &'a E, textinput: &'a DomRefCell<TextInput<ScriptToConstellationChan>>, } impl<'a, E: TextControlElement> TextControlSelection<'a, E> { - pub fn new( + pub(crate) fn new( element: &'a E, textinput: &'a DomRefCell<TextInput<ScriptToConstellationChan>>, ) -> Self { @@ -39,7 +39,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-select - pub fn dom_select(&self) { + pub(crate) fn dom_select(&self) { // Step 1 if !self.element.has_selectable_text() { return; @@ -50,7 +50,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart - pub fn dom_start(&self) -> Option<u32> { + pub(crate) fn dom_start(&self) -> Option<u32> { // Step 1 if !self.element.selection_api_applies() { return None; @@ -61,7 +61,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart - pub fn set_dom_start(&self, start: Option<u32>) -> ErrorResult { + pub(crate) fn set_dom_start(&self, start: Option<u32>) -> ErrorResult { // Step 1 if !self.element.selection_api_applies() { return Err(Error::InvalidState); @@ -83,7 +83,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend - pub fn dom_end(&self) -> Option<u32> { + pub(crate) fn dom_end(&self) -> Option<u32> { // Step 1 if !self.element.selection_api_applies() { return None; @@ -94,7 +94,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend - pub fn set_dom_end(&self, end: Option<u32>) -> ErrorResult { + pub(crate) fn set_dom_end(&self, end: Option<u32>) -> ErrorResult { // Step 1 if !self.element.selection_api_applies() { return Err(Error::InvalidState); @@ -106,7 +106,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection - pub fn dom_direction(&self) -> Option<DOMString> { + pub(crate) fn dom_direction(&self) -> Option<DOMString> { // Step 1 if !self.element.selection_api_applies() { return None; @@ -116,7 +116,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection - pub fn set_dom_direction(&self, direction: Option<DOMString>) -> ErrorResult { + pub(crate) fn set_dom_direction(&self, direction: Option<DOMString>) -> ErrorResult { // Step 1 if !self.element.selection_api_applies() { return Err(Error::InvalidState); @@ -133,7 +133,12 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-setselectionrange - pub fn set_dom_range(&self, start: u32, end: u32, direction: Option<DOMString>) -> ErrorResult { + pub(crate) fn set_dom_range( + &self, + start: u32, + end: u32, + direction: Option<DOMString>, + ) -> ErrorResult { // Step 1 if !self.element.selection_api_applies() { return Err(Error::InvalidState); @@ -150,7 +155,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> { } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-setrangetext - pub fn set_dom_range_text( + pub(crate) fn set_dom_range_text( &self, replacement: DOMString, start: Option<u32>, diff --git a/components/script/dom/textdecoder.rs b/components/script/dom/textdecoder.rs index c1312631647..9368d63306d 100644 --- a/components/script/dom/textdecoder.rs +++ b/components/script/dom/textdecoder.rs @@ -23,7 +23,7 @@ use crate::script_runtime::CanGc; #[dom_struct] #[allow(non_snake_case)] -pub struct TextDecoder { +pub(crate) struct TextDecoder { reflector_: Reflector, #[no_trace] encoding: &'static Encoding, diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 55c5346029c..3c18a7fa016 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -23,7 +23,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct TextEncoder { +pub(crate) struct TextEncoder { reflector_: Reflector, } diff --git a/components/script/dom/textmetrics.rs b/components/script/dom/textmetrics.rs index cd4245f5f70..0e5cb0c89f5 100644 --- a/components/script/dom/textmetrics.rs +++ b/components/script/dom/textmetrics.rs @@ -13,7 +13,7 @@ use crate::script_runtime::CanGc; #[dom_struct] #[allow(non_snake_case)] -pub struct TextMetrics { +pub(crate) struct TextMetrics { reflector_: Reflector, width: Finite<f64>, actualBoundingBoxLeft: Finite<f64>, @@ -64,7 +64,7 @@ impl TextMetrics { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, width: f64, actualBoundingBoxLeft: f64, diff --git a/components/script/dom/texttrack.rs b/components/script/dom/texttrack.rs index 61b485f1bb0..6ff39cf39e1 100644 --- a/components/script/dom/texttrack.rs +++ b/components/script/dom/texttrack.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TextTrack { +pub(crate) struct TextTrack { eventtarget: EventTarget, kind: TextTrackKind, label: String, @@ -34,7 +34,7 @@ pub struct TextTrack { } impl TextTrack { - pub fn new_inherited( + pub(crate) fn new_inherited( id: DOMString, kind: TextTrackKind, label: DOMString, @@ -54,7 +54,7 @@ impl TextTrack { } } - pub fn new( + pub(crate) fn new( window: &Window, id: DOMString, kind: TextTrackKind, @@ -72,20 +72,20 @@ impl TextTrack { ) } - pub fn get_cues(&self) -> DomRoot<TextTrackCueList> { + pub(crate) fn get_cues(&self) -> DomRoot<TextTrackCueList> { self.cue_list .or_init(|| TextTrackCueList::new(self.global().as_window(), &[])) } - pub fn id(&self) -> &str { + pub(crate) fn id(&self) -> &str { &self.id } - pub fn add_track_list(&self, track_list: &TextTrackList) { + pub(crate) fn add_track_list(&self, track_list: &TextTrackList) { *self.track_list.borrow_mut() = Some(Dom::from_ref(track_list)); } - pub fn remove_track_list(&self) { + pub(crate) fn remove_track_list(&self) { *self.track_list.borrow_mut() = None; } } diff --git a/components/script/dom/texttrackcue.rs b/components/script/dom/texttrackcue.rs index 7d3711420f2..cc8e0c094d0 100644 --- a/components/script/dom/texttrackcue.rs +++ b/components/script/dom/texttrackcue.rs @@ -18,7 +18,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TextTrackCue { +pub(crate) struct TextTrackCue { eventtarget: EventTarget, id: DomRefCell<DOMString>, track: Option<Dom<TextTrack>>, @@ -28,7 +28,7 @@ pub struct TextTrackCue { } impl TextTrackCue { - pub fn new_inherited( + pub(crate) fn new_inherited( id: DOMString, start_time: f64, end_time: f64, @@ -45,7 +45,7 @@ impl TextTrackCue { } #[allow(dead_code)] - pub fn new( + pub(crate) fn new( window: &Window, id: DOMString, start_time: f64, @@ -59,11 +59,11 @@ impl TextTrackCue { ) } - pub fn id(&self) -> DOMString { + pub(crate) fn id(&self) -> DOMString { self.id.borrow().clone() } - pub fn get_track(&self) -> Option<DomRoot<TextTrack>> { + pub(crate) fn get_track(&self) -> Option<DomRoot<TextTrack>> { self.track.as_ref().map(|t| DomRoot::from_ref(&**t)) } } diff --git a/components/script/dom/texttrackcuelist.rs b/components/script/dom/texttrackcuelist.rs index ba0f6295a1e..89c3980397d 100644 --- a/components/script/dom/texttrackcuelist.rs +++ b/components/script/dom/texttrackcuelist.rs @@ -14,20 +14,20 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TextTrackCueList { +pub(crate) struct TextTrackCueList { reflector_: Reflector, dom_cues: DomRefCell<Vec<Dom<TextTrackCue>>>, } impl TextTrackCueList { - pub fn new_inherited(cues: &[&TextTrackCue]) -> TextTrackCueList { + pub(crate) fn new_inherited(cues: &[&TextTrackCue]) -> TextTrackCueList { TextTrackCueList { reflector_: Reflector::new(), dom_cues: DomRefCell::new(cues.iter().map(|g| Dom::from_ref(&**g)).collect()), } } - pub fn new(window: &Window, cues: &[&TextTrackCue]) -> DomRoot<TextTrackCueList> { + pub(crate) fn new(window: &Window, cues: &[&TextTrackCue]) -> DomRoot<TextTrackCueList> { reflect_dom_object( Box::new(TextTrackCueList::new_inherited(cues)), window, @@ -35,14 +35,14 @@ impl TextTrackCueList { ) } - pub fn item(&self, idx: usize) -> Option<DomRoot<TextTrackCue>> { + pub(crate) fn item(&self, idx: usize) -> Option<DomRoot<TextTrackCue>> { self.dom_cues .borrow() .get(idx) .map(|t| DomRoot::from_ref(&**t)) } - pub fn find(&self, cue: &TextTrackCue) -> Option<usize> { + pub(crate) fn find(&self, cue: &TextTrackCue) -> Option<usize> { self.dom_cues .borrow() .iter() @@ -51,14 +51,14 @@ impl TextTrackCueList { .map(|(i, _)| i) } - pub fn add(&self, cue: &TextTrackCue) { + pub(crate) fn add(&self, cue: &TextTrackCue) { // Only add a cue if it does not exist in the list if self.find(cue).is_none() { self.dom_cues.borrow_mut().push(Dom::from_ref(cue)); } } - pub fn remove(&self, idx: usize) { + pub(crate) fn remove(&self, idx: usize) { self.dom_cues.borrow_mut().remove(idx); } } diff --git a/components/script/dom/texttracklist.rs b/components/script/dom/texttracklist.rs index f0e0f4bd93b..a5ce68eafce 100644 --- a/components/script/dom/texttracklist.rs +++ b/components/script/dom/texttracklist.rs @@ -20,20 +20,20 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TextTrackList { +pub(crate) struct TextTrackList { eventtarget: EventTarget, dom_tracks: DomRefCell<Vec<Dom<TextTrack>>>, } impl TextTrackList { - pub fn new_inherited(tracks: &[&TextTrack]) -> TextTrackList { + pub(crate) fn new_inherited(tracks: &[&TextTrack]) -> TextTrackList { TextTrackList { eventtarget: EventTarget::new_inherited(), dom_tracks: DomRefCell::new(tracks.iter().map(|g| Dom::from_ref(&**g)).collect()), } } - pub fn new(window: &Window, tracks: &[&TextTrack]) -> DomRoot<TextTrackList> { + pub(crate) fn new(window: &Window, tracks: &[&TextTrack]) -> DomRoot<TextTrackList> { reflect_dom_object( Box::new(TextTrackList::new_inherited(tracks)), window, @@ -41,14 +41,14 @@ impl TextTrackList { ) } - pub fn item(&self, idx: usize) -> Option<DomRoot<TextTrack>> { + pub(crate) fn item(&self, idx: usize) -> Option<DomRoot<TextTrack>> { self.dom_tracks .borrow() .get(idx) .map(|t| DomRoot::from_ref(&**t)) } - pub fn find(&self, track: &TextTrack) -> Option<usize> { + pub(crate) fn find(&self, track: &TextTrack) -> Option<usize> { self.dom_tracks .borrow() .iter() @@ -57,7 +57,7 @@ impl TextTrackList { .map(|(i, _)| i) } - pub fn add(&self, track: &TextTrack) { + pub(crate) fn add(&self, track: &TextTrack) { // Only add a track if it does not exist in the list if self.find(track).is_none() { self.dom_tracks.borrow_mut().push(Dom::from_ref(track)); @@ -95,7 +95,7 @@ impl TextTrackList { // FIXME(#22314, dlrobertson) allow TextTracks to be // removed from the TextTrackList. #[allow(dead_code)] - pub fn remove(&self, idx: usize, can_gc: CanGc) { + pub(crate) fn remove(&self, idx: usize, can_gc: CanGc) { if let Some(track) = self.dom_tracks.borrow().get(idx) { track.remove_track_list(); } diff --git a/components/script/dom/timeranges.rs b/components/script/dom/timeranges.rs index 60a7ec679cd..4c1a7401711 100644 --- a/components/script/dom/timeranges.rs +++ b/components/script/dom/timeranges.rs @@ -21,7 +21,7 @@ struct TimeRange { } impl TimeRange { - pub fn union(&mut self, other: &TimeRange) { + pub(crate) fn union(&mut self, other: &TimeRange) { self.start = f64::min(self.start, other.start); self.end = f64::max(self.end, other.end); } @@ -40,7 +40,7 @@ impl TimeRange { other.start == self.end || other.end == self.start } - pub fn is_before(&self, other: &TimeRange) -> bool { + pub(crate) fn is_before(&self, other: &TimeRange) -> bool { other.start >= self.end } } @@ -63,11 +63,12 @@ pub struct TimeRangesContainer { } impl TimeRangesContainer { + #[allow(clippy::len_without_is_empty)] pub fn len(&self) -> u32 { self.ranges.len() as u32 } - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.ranges.is_empty() } @@ -126,7 +127,7 @@ impl TimeRangesContainer { } #[dom_struct] -pub struct TimeRanges { +pub(crate) struct TimeRanges { reflector_: Reflector, ranges: TimeRangesContainer, } @@ -139,7 +140,7 @@ impl TimeRanges { } } - pub fn new(window: &Window, ranges: TimeRangesContainer) -> DomRoot<TimeRanges> { + pub(crate) fn new(window: &Window, ranges: TimeRangesContainer) -> DomRoot<TimeRanges> { 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 9ac50b8058d..11041ba441e 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -13,7 +13,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct Touch { +pub(crate) struct Touch { reflector_: Reflector, identifier: i32, target: MutDom<EventTarget>, @@ -51,7 +51,7 @@ impl Touch { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, identifier: i32, target: &EventTarget, diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs index fb402d6d806..ce13210842c 100644 --- a/components/script/dom/touchevent.rs +++ b/components/script/dom/touchevent.rs @@ -19,7 +19,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TouchEvent { +pub(crate) struct TouchEvent { uievent: UIEvent, touches: MutDom<TouchList>, target_touches: MutDom<TouchList>, @@ -48,7 +48,7 @@ impl TouchEvent { } } - pub fn new_uninitialized( + pub(crate) fn new_uninitialized( window: &Window, touches: &TouchList, changed_touches: &TouchList, @@ -66,7 +66,7 @@ impl TouchEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: EventBubbles, diff --git a/components/script/dom/touchlist.rs b/components/script/dom/touchlist.rs index 9991b14aa71..dddd7427b75 100644 --- a/components/script/dom/touchlist.rs +++ b/components/script/dom/touchlist.rs @@ -12,7 +12,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TouchList { +pub(crate) struct TouchList { reflector_: Reflector, touches: Vec<Dom<Touch>>, } @@ -25,7 +25,7 @@ impl TouchList { } } - pub fn new(window: &Window, touches: &[&Touch]) -> DomRoot<TouchList> { + pub(crate) fn new(window: &Window, touches: &[&Touch]) -> DomRoot<TouchList> { 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 5a9c7b44578..a93bd5da619 100644 --- a/components/script/dom/trackevent.rs +++ b/components/script/dom/trackevent.rs @@ -32,7 +32,7 @@ enum MediaTrack { } #[dom_struct] -pub struct TrackEvent { +pub(crate) struct TrackEvent { event: Event, track: Option<MediaTrack>, } @@ -59,7 +59,7 @@ impl TrackEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/transitionevent.rs b/components/script/dom/transitionevent.rs index 66e7669ba69..c7d2f2ec73c 100644 --- a/components/script/dom/transitionevent.rs +++ b/components/script/dom/transitionevent.rs @@ -21,7 +21,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct TransitionEvent { +pub(crate) struct TransitionEvent { event: Event, #[no_trace] property_name: Atom, @@ -39,7 +39,7 @@ impl TransitionEvent { } } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, init: &TransitionEventInit, diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 36127c1ad1b..6be38a8b5d5 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -20,7 +20,7 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#interface-treewalker #[dom_struct] -pub struct TreeWalker { +pub(crate) struct TreeWalker { reflector_: Reflector, root_node: Dom<Node>, current_node: MutDom<Node>, @@ -42,7 +42,7 @@ impl TreeWalker { } } - pub fn new_with_filter( + pub(crate) fn new_with_filter( document: &Document, root_node: &Node, what_to_show: u32, @@ -55,7 +55,7 @@ impl TreeWalker { ) } - pub fn new( + pub(crate) fn new( document: &Document, root_node: &Node, what_to_show: u32, @@ -476,7 +476,7 @@ impl Iterator for &TreeWalker { } #[derive(JSTraceable)] -pub enum Filter { +pub(crate) enum Filter { None, Dom(Rc<NodeFilter>), } diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index 650160e5efb..35e84d8e42b 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -27,14 +27,14 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/uievents/#interface-uievent #[dom_struct] -pub struct UIEvent { +pub(crate) struct UIEvent { event: Event, view: MutNullableDom<Window>, detail: Cell<i32>, } impl UIEvent { - pub fn new_inherited() -> UIEvent { + pub(crate) fn new_inherited() -> UIEvent { UIEvent { event: Event::new_inherited(), view: Default::default(), @@ -42,7 +42,7 @@ impl UIEvent { } } - pub fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<UIEvent> { + pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<UIEvent> { Self::new_uninitialized_with_proto(window, None, can_gc) } @@ -54,7 +54,7 @@ impl UIEvent { reflect_dom_object_with_proto(Box::new(UIEvent::new_inherited()), window, proto, can_gc) } - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: EventBubbles, @@ -91,7 +91,7 @@ impl UIEvent { } /// <https://w3c.github.io/uievents/#initialize-a-uievent> - pub fn initialize_ui_event( + pub(crate) fn initialize_ui_event( &self, type_: DOMString, target_: Option<&EventTarget>, @@ -114,7 +114,7 @@ impl UIEvent { self.detail.set(0_i32); } - pub fn set_detail(&self, detail_: i32) { + pub(crate) fn set_detail(&self, detail_: i32) { self.detail.set(detail_); } } diff --git a/components/script/dom/underlyingsourcecontainer.rs b/components/script/dom/underlyingsourcecontainer.rs index 06db74fb4bd..603c6a1a88a 100644 --- a/components/script/dom/underlyingsourcecontainer.rs +++ b/components/script/dom/underlyingsourcecontainer.rs @@ -27,7 +27,7 @@ use crate::script_runtime::CanGc; /// The other variants are native sources in Rust. #[derive(JSTraceable)] #[crown::unrooted_must_root_lint::must_root] -pub enum UnderlyingSourceType { +pub(crate) enum UnderlyingSourceType { /// Facilitate partial integration with sources /// that are currently read into memory. Memory(usize), @@ -44,7 +44,7 @@ pub enum UnderlyingSourceType { impl UnderlyingSourceType { /// Is the source backed by a Rust native source? - pub fn is_native(&self) -> bool { + pub(crate) fn is_native(&self) -> bool { matches!( self, UnderlyingSourceType::Memory(_) | @@ -54,14 +54,14 @@ impl UnderlyingSourceType { } /// Does the source have all data in memory? - pub fn in_memory(&self) -> bool { + pub(crate) fn in_memory(&self) -> bool { matches!(self, UnderlyingSourceType::Memory(_)) } } /// Wrapper around the underlying source. #[dom_struct] -pub struct UnderlyingSourceContainer { +pub(crate) struct UnderlyingSourceContainer { reflector_: Reflector, #[ignore_malloc_size_of = "JsUnderlyingSource implemented in SM."] underlying_source_type: UnderlyingSourceType, @@ -77,7 +77,7 @@ impl UnderlyingSourceContainer { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, underlying_source_type: UnderlyingSourceType, can_gc: CanGc, @@ -96,7 +96,7 @@ impl UnderlyingSourceContainer { } /// Setting the JS object after the heap has settled down. - pub fn set_underlying_source_this_object(&self, object: HandleObject) { + pub(crate) fn set_underlying_source_this_object(&self, object: HandleObject) { if let UnderlyingSourceType::Js(_source, this_obj) = &self.underlying_source_type { this_obj.set(*object); } @@ -104,7 +104,7 @@ impl UnderlyingSourceContainer { /// <https://streams.spec.whatwg.org/#dom-underlyingsource-cancel> #[allow(unsafe_code)] - pub fn call_cancel_algorithm( + pub(crate) fn call_cancel_algorithm( &self, reason: SafeHandleValue, can_gc: CanGc, @@ -133,7 +133,7 @@ impl UnderlyingSourceContainer { /// <https://streams.spec.whatwg.org/#dom-underlyingsource-pull> #[allow(unsafe_code)] - pub fn call_pull_algorithm( + pub(crate) fn call_pull_algorithm( &self, controller: Controller, can_gc: CanGc, @@ -169,7 +169,7 @@ impl UnderlyingSourceContainer { /// see "Let startPromise be a promise resolved with startResult." /// at <https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller> #[allow(unsafe_code)] - pub fn call_start_algorithm( + pub(crate) fn call_start_algorithm( &self, controller: Controller, can_gc: CanGc, @@ -219,7 +219,7 @@ impl UnderlyingSourceContainer { } /// Does the source have all data in memory? - pub fn in_memory(&self) -> bool { + pub(crate) fn in_memory(&self) -> bool { self.underlying_source_type.in_memory() } } diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index f9f87a9bba3..13e68c3ce84 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -28,7 +28,7 @@ use crate::script_runtime::CanGc; /// <https://url.spec.whatwg.org/#url> #[dom_struct] #[allow(clippy::upper_case_acronyms)] -pub struct URL { +pub(crate) struct URL { reflector_: Reflector, /// <https://url.spec.whatwg.org/#concept-url-url> @@ -57,7 +57,7 @@ impl URL { reflect_dom_object_with_proto(Box::new(URL::new_inherited(url)), global, proto, can_gc) } - pub fn query_pairs(&self) -> Vec<(String, String)> { + pub(crate) fn query_pairs(&self) -> Vec<(String, String)> { self.url .borrow() .as_url() @@ -66,7 +66,7 @@ impl URL { .collect() } - pub fn set_query_pairs(&self, pairs: &[(String, String)]) { + pub(crate) fn set_query_pairs(&self, pairs: &[(String, String)]) { let mut url = self.url.borrow_mut(); if pairs.is_empty() { diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index 03a3c3150ae..f2edef16fc7 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -10,68 +10,68 @@ use url::quirks; use crate::dom::bindings::str::USVString; #[derive(MallocSizeOf)] -pub struct UrlHelper; +pub(crate) struct UrlHelper; #[allow(non_snake_case)] impl UrlHelper { - pub fn Origin(url: &ServoUrl) -> USVString { + pub(crate) fn Origin(url: &ServoUrl) -> USVString { USVString(quirks::origin(url.as_url()).to_owned()) } - pub fn Href(url: &ServoUrl) -> USVString { + pub(crate) fn Href(url: &ServoUrl) -> USVString { USVString(quirks::href(url.as_url()).to_owned()) } - pub fn Hash(url: &ServoUrl) -> USVString { + pub(crate) fn Hash(url: &ServoUrl) -> USVString { USVString(quirks::hash(url.as_url()).to_owned()) } - pub fn Host(url: &ServoUrl) -> USVString { + pub(crate) fn Host(url: &ServoUrl) -> USVString { USVString(quirks::host(url.as_url()).to_owned()) } - pub fn Port(url: &ServoUrl) -> USVString { + pub(crate) fn Port(url: &ServoUrl) -> USVString { USVString(quirks::port(url.as_url()).to_owned()) } - pub fn Search(url: &ServoUrl) -> USVString { + pub(crate) fn Search(url: &ServoUrl) -> USVString { USVString(quirks::search(url.as_url()).to_owned()) } - pub fn Hostname(url: &ServoUrl) -> USVString { + pub(crate) fn Hostname(url: &ServoUrl) -> USVString { USVString(quirks::hostname(url.as_url()).to_owned()) } - pub fn Password(url: &ServoUrl) -> USVString { + pub(crate) fn Password(url: &ServoUrl) -> USVString { USVString(quirks::password(url.as_url()).to_owned()) } - pub fn Pathname(url: &ServoUrl) -> USVString { + pub(crate) fn Pathname(url: &ServoUrl) -> USVString { USVString(quirks::pathname(url.as_url()).to_owned()) } - pub fn Protocol(url: &ServoUrl) -> USVString { + pub(crate) fn Protocol(url: &ServoUrl) -> USVString { USVString(quirks::protocol(url.as_url()).to_owned()) } - pub fn Username(url: &ServoUrl) -> USVString { + pub(crate) fn Username(url: &ServoUrl) -> USVString { USVString(quirks::username(url.as_url()).to_owned()) } - pub fn SetHash(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetHash(url: &mut ServoUrl, value: USVString) { quirks::set_hash(url.as_mut_url(), &value.0) } - pub fn SetHost(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetHost(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_host(url.as_mut_url(), &value.0); } - pub fn SetPort(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetPort(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_port(url.as_mut_url(), &value.0); } - pub fn SetSearch(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetSearch(url: &mut ServoUrl, value: USVString) { quirks::set_search(url.as_mut_url(), &value.0) } - pub fn SetPathname(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetPathname(url: &mut ServoUrl, value: USVString) { quirks::set_pathname(url.as_mut_url(), &value.0) } - pub fn SetHostname(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetHostname(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_hostname(url.as_mut_url(), &value.0); } - pub fn SetPassword(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetPassword(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_password(url.as_mut_url(), &value.0); } - pub fn SetProtocol(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetProtocol(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_protocol(url.as_mut_url(), &value.0); } - pub fn SetUsername(url: &mut ServoUrl, value: USVString) { + pub(crate) fn SetUsername(url: &mut ServoUrl, value: USVString) { let _ = quirks::set_username(url.as_mut_url(), &value.0); } } diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index b3712209f25..b7c13e312fa 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -21,7 +21,7 @@ use crate::script_runtime::CanGc; /// <https://url.spec.whatwg.org/#interface-urlsearchparams> #[dom_struct] -pub struct URLSearchParams { +pub(crate) struct URLSearchParams { reflector_: Reflector, /// <https://url.spec.whatwg.org/#concept-urlsearchparams-list> list: DomRefCell<Vec<(String, String)>>, @@ -38,11 +38,15 @@ impl URLSearchParams { } } - pub fn new(global: &GlobalScope, url: Option<&URL>, can_gc: CanGc) -> DomRoot<URLSearchParams> { + pub(crate) fn new( + global: &GlobalScope, + url: Option<&URL>, + can_gc: CanGc, + ) -> DomRoot<URLSearchParams> { Self::new_with_proto(global, None, url, can_gc) } - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, url: Option<&URL>, @@ -56,7 +60,7 @@ impl URLSearchParams { ) } - pub fn set_list(&self, list: Vec<(String, String)>) { + pub(crate) fn set_list(&self, list: Vec<(String, String)>) { *self.list.borrow_mut() = list; } } @@ -211,7 +215,7 @@ impl URLSearchParamsMethods<crate::DomTypeHolder> for URLSearchParams { impl URLSearchParams { /// <https://url.spec.whatwg.org/#concept-urlencoded-serializer> - pub fn serialize_utf8(&self) -> String { + pub(crate) fn serialize_utf8(&self) -> String { let list = self.list.borrow(); form_urlencoded::Serializer::new(String::new()) .extend_pairs(&*list) diff --git a/components/script/dom/userscripts.rs b/components/script/dom/userscripts.rs index ff92ed84d15..6f884ab641b 100644 --- a/components/script/dom/userscripts.rs +++ b/components/script/dom/userscripts.rs @@ -17,7 +17,7 @@ use crate::dom::node::NodeTraits; use crate::script_module::ScriptFetchOptions; use crate::script_runtime::CanGc; -pub fn load_script(head: &HTMLHeadElement) { +pub(crate) fn load_script(head: &HTMLHeadElement) { let doc = head.owner_document(); let path_str = match doc.window().get_userscripts_path() { Some(p) => p, diff --git a/components/script/dom/validation.rs b/components/script/dom/validation.rs index e46b41732d0..666eac6dcee 100755 --- a/components/script/dom/validation.rs +++ b/components/script/dom/validation.rs @@ -15,7 +15,7 @@ use crate::dom::validitystate::{ValidationFlags, ValidityState}; use crate::script_runtime::CanGc; /// Trait for elements with constraint validation support -pub trait Validatable { +pub(crate) trait Validatable { fn as_element(&self) -> ∈ /// <https://html.spec.whatwg.org/multipage/#dom-cva-validity> @@ -91,7 +91,7 @@ pub trait Validatable { } /// <https://html.spec.whatwg.org/multipage/#the-datalist-element%3Abarred-from-constraint-validation> -pub fn is_barred_by_datalist_ancestor(elem: &Node) -> bool { +pub(crate) fn is_barred_by_datalist_ancestor(elem: &Node) -> bool { elem.upcast::<Node>() .ancestors() .any(|node| node.is::<HTMLDataListElement>()) diff --git a/components/script/dom/validitystate.rs b/components/script/dom/validitystate.rs index a6593fab941..fc198be82f1 100755 --- a/components/script/dom/validitystate.rs +++ b/components/script/dom/validitystate.rs @@ -26,7 +26,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#validity-states #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] -pub struct ValidationFlags(u32); +pub(crate) struct ValidationFlags(u32); bitflags! { impl ValidationFlags: u32 { @@ -74,7 +74,7 @@ impl fmt::Display for ValidationFlags { // https://html.spec.whatwg.org/multipage/#validitystate #[dom_struct] -pub struct ValidityState { +pub(crate) struct ValidityState { reflector_: Reflector, element: Dom<Element>, custom_error_message: DomRefCell<DOMString>, @@ -91,7 +91,7 @@ impl ValidityState { } } - pub fn new(window: &Window, element: &Element) -> DomRoot<ValidityState> { + pub(crate) fn new(window: &Window, element: &Element) -> DomRoot<ValidityState> { reflect_dom_object( Box::new(ValidityState::new_inherited(element)), window, @@ -100,12 +100,12 @@ impl ValidityState { } // https://html.spec.whatwg.org/multipage/#custom-validity-error-message - pub fn custom_error_message(&self) -> Ref<DOMString> { + pub(crate) fn custom_error_message(&self) -> Ref<DOMString> { self.custom_error_message.borrow() } // https://html.spec.whatwg.org/multipage/#custom-validity-error-message - pub fn set_custom_error_message(&self, error: DOMString) { + pub(crate) fn set_custom_error_message(&self, error: DOMString) { *self.custom_error_message.borrow_mut() = error; self.perform_validation_and_update(ValidationFlags::CUSTOM_ERROR); } @@ -115,7 +115,7 @@ impl ValidityState { /// if [ValidationFlags::CUSTOM_ERROR] is in `update_flags` and a custom /// error has been set on this [ValidityState], the state will be updated /// to reflect the existance of a custom error. - pub fn perform_validation_and_update(&self, update_flags: ValidationFlags) { + pub(crate) fn perform_validation_and_update(&self, update_flags: ValidationFlags) { let mut invalid_flags = self.invalid_flags.get(); invalid_flags.remove(update_flags); @@ -135,15 +135,15 @@ impl ValidityState { self.update_pseudo_classes(); } - pub fn update_invalid_flags(&self, update_flags: ValidationFlags) { + pub(crate) fn update_invalid_flags(&self, update_flags: ValidationFlags) { self.invalid_flags.set(update_flags); } - pub fn invalid_flags(&self) -> ValidationFlags { + pub(crate) fn invalid_flags(&self) -> ValidationFlags { self.invalid_flags.get() } - pub fn update_pseudo_classes(&self) { + pub(crate) fn update_pseudo_classes(&self) { if self.element.is_instance_validatable() { let is_valid = self.invalid_flags.get().is_empty(); self.element.set_state(ElementState::VALID, is_valid); diff --git a/components/script/dom/values.rs b/components/script/dom/values.rs index 4b87c1b1c8c..36dbc66da5c 100644 --- a/components/script/dom/values.rs +++ b/components/script/dom/values.rs @@ -4,4 +4,4 @@ // https://html.spec.whatwg.org/multipage#reflecting-content-attributes-in-idl-attributes:idl-unsigned-long // https://html.spec.whatwg.org/multipage#limited-to-only-non-negative-numbers-greater-than-zero -pub const UNSIGNED_LONG_MAX: u32 = 2147483647; +pub(crate) const UNSIGNED_LONG_MAX: u32 = 2147483647; diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index b5cfad1d172..4100e230493 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.rs @@ -17,7 +17,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct VertexArrayObject { +pub(crate) struct VertexArrayObject { context: Dom<WebGLRenderingContext>, #[no_trace] id: Option<WebGLVertexArrayId>, @@ -28,7 +28,7 @@ pub struct VertexArrayObject { } impl VertexArrayObject { - pub fn new(context: &WebGLRenderingContext, id: Option<WebGLVertexArrayId>) -> Self { + pub(crate) fn new(context: &WebGLRenderingContext, id: Option<WebGLVertexArrayId>) -> Self { let max_vertex_attribs = context.limits().max_vertex_attribs as usize; Self { context: Dom::from_ref(context), @@ -40,15 +40,15 @@ impl VertexArrayObject { } } - pub fn id(&self) -> Option<WebGLVertexArrayId> { + pub(crate) fn id(&self) -> Option<WebGLVertexArrayId> { self.id } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.is_deleted.get() } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { assert!(self.id.is_some()); if self.is_deleted.get() { return; @@ -70,29 +70,29 @@ impl VertexArrayObject { } } - pub fn ever_bound(&self) -> bool { + pub(crate) fn ever_bound(&self) -> bool { self.ever_bound.get() } - pub fn set_ever_bound(&self) { + pub(crate) fn set_ever_bound(&self) { self.ever_bound.set(true); } - pub fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { + pub(crate) fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { &self.element_array_buffer } - pub fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { + pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { ref_filter_map(self.vertex_attribs.borrow(), |attribs| { attribs.get(index as usize) }) } - pub fn set_vertex_attrib_type(&self, index: u32, type_: u32) { + pub(crate) fn set_vertex_attrib_type(&self, index: u32, type_: u32) { self.vertex_attribs.borrow_mut()[index as usize].type_ = type_; } - pub fn vertex_attrib_pointer( + pub(crate) fn vertex_attrib_pointer( &self, index: u32, size: i32, @@ -173,15 +173,15 @@ impl VertexArrayObject { Ok(()) } - pub fn vertex_attrib_divisor(&self, index: u32, value: u32) { + pub(crate) fn vertex_attrib_divisor(&self, index: u32, value: u32) { self.vertex_attribs.borrow_mut()[index as usize].divisor = value; } - pub fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { + pub(crate) fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { self.vertex_attribs.borrow_mut()[index as usize].enabled_as_array = value; } - pub fn unbind_buffer(&self, buffer: &WebGLBuffer) { + pub(crate) fn unbind_buffer(&self, buffer: &WebGLBuffer) { for attrib in &mut **self.vertex_attribs.borrow_mut() { if let Some(b) = attrib.buffer() { if b.id() != buffer.id() { @@ -201,7 +201,7 @@ impl VertexArrayObject { } } - pub fn validate_for_draw( + pub(crate) fn validate_for_draw( &self, required_len: u32, instance_count: u32, @@ -262,16 +262,16 @@ impl Drop for VertexArrayObject { #[derive(Clone, JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] -pub struct VertexAttribData { - pub enabled_as_array: bool, - pub size: u8, - pub type_: u32, +pub(crate) struct VertexAttribData { + pub(crate) enabled_as_array: bool, + pub(crate) size: u8, + pub(crate) type_: u32, bytes_per_vertex: u8, - pub normalized: bool, - pub stride: u8, - pub offset: u32, - pub buffer: Option<Dom<WebGLBuffer>>, - pub divisor: u32, + pub(crate) normalized: bool, + pub(crate) stride: u8, + pub(crate) offset: u32, + pub(crate) buffer: Option<Dom<WebGLBuffer>>, + pub(crate) divisor: u32, } impl Default for VertexAttribData { @@ -292,11 +292,11 @@ impl Default for VertexAttribData { } impl VertexAttribData { - pub fn buffer(&self) -> Option<&WebGLBuffer> { + pub(crate) fn buffer(&self) -> Option<&WebGLBuffer> { self.buffer.as_deref() } - pub fn max_vertices(&self) -> u32 { + pub(crate) fn max_vertices(&self) -> u32 { let capacity = (self.buffer().unwrap().capacity() as u32).saturating_sub(self.offset); if capacity < self.bytes_per_vertex as u32 { 0 diff --git a/components/script/dom/videotrack.rs b/components/script/dom/videotrack.rs index 6d035eec04c..5fe5dd1960a 100644 --- a/components/script/dom/videotrack.rs +++ b/components/script/dom/videotrack.rs @@ -16,7 +16,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct VideoTrack { +pub(crate) struct VideoTrack { reflector_: Reflector, id: DOMString, kind: DOMString, @@ -27,7 +27,7 @@ pub struct VideoTrack { } impl VideoTrack { - pub fn new_inherited( + pub(crate) fn new_inherited( id: DOMString, kind: DOMString, label: DOMString, @@ -45,7 +45,7 @@ impl VideoTrack { } } - pub fn new( + pub(crate) fn new( window: &Window, id: DOMString, kind: DOMString, @@ -62,27 +62,27 @@ impl VideoTrack { ) } - pub fn id(&self) -> DOMString { + pub(crate) fn id(&self) -> DOMString { self.id.clone() } - pub fn kind(&self) -> DOMString { + pub(crate) fn kind(&self) -> DOMString { self.kind.clone() } - pub fn selected(&self) -> bool { + pub(crate) fn selected(&self) -> bool { self.selected.get() } - pub fn set_selected(&self, value: bool) { + pub(crate) fn set_selected(&self, value: bool) { self.selected.set(value); } - pub fn add_track_list(&self, track_list: &VideoTrackList) { + pub(crate) fn add_track_list(&self, track_list: &VideoTrackList) { *self.track_list.borrow_mut() = Some(Dom::from_ref(track_list)); } - pub fn remove_track_list(&self) { + pub(crate) fn remove_track_list(&self) { *self.track_list.borrow_mut() = None; } } diff --git a/components/script/dom/videotracklist.rs b/components/script/dom/videotracklist.rs index 03a27742ddb..019319e75a0 100644 --- a/components/script/dom/videotracklist.rs +++ b/components/script/dom/videotracklist.rs @@ -18,14 +18,14 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct VideoTrackList { +pub(crate) struct VideoTrackList { eventtarget: EventTarget, tracks: DomRefCell<Vec<Dom<VideoTrack>>>, media_element: Option<Dom<HTMLMediaElement>>, } impl VideoTrackList { - pub fn new_inherited( + pub(crate) fn new_inherited( tracks: &[&VideoTrack], media_element: Option<&HTMLMediaElement>, ) -> VideoTrackList { @@ -36,7 +36,7 @@ impl VideoTrackList { } } - pub fn new( + pub(crate) fn new( window: &Window, tracks: &[&VideoTrack], media_element: Option<&HTMLMediaElement>, @@ -48,29 +48,29 @@ impl VideoTrackList { ) } - pub fn len(&self) -> usize { + pub(crate) fn len(&self) -> usize { self.tracks.borrow().len() } - pub fn find(&self, track: &VideoTrack) -> Option<usize> { + pub(crate) fn find(&self, track: &VideoTrack) -> Option<usize> { self.tracks.borrow().iter().position(|t| &**t == track) } - pub fn item(&self, idx: usize) -> Option<DomRoot<VideoTrack>> { + pub(crate) fn item(&self, idx: usize) -> Option<DomRoot<VideoTrack>> { self.tracks .borrow() .get(idx) .map(|track| DomRoot::from_ref(&**track)) } - pub fn selected_index(&self) -> Option<usize> { + pub(crate) fn selected_index(&self) -> Option<usize> { self.tracks .borrow() .iter() .position(|track| track.selected()) } - pub fn set_selected(&self, idx: usize, value: bool) { + pub(crate) fn set_selected(&self, idx: usize, value: bool) { let track = match self.item(idx) { Some(t) => t, None => return, @@ -100,7 +100,7 @@ impl VideoTrackList { })); } - pub fn add(&self, track: &VideoTrack) { + pub(crate) fn add(&self, track: &VideoTrack) { self.tracks.borrow_mut().push(Dom::from_ref(track)); if track.selected() { if let Some(idx) = self.selected_index() { @@ -110,7 +110,7 @@ impl VideoTrackList { track.add_track_list(self); } - pub fn clear(&self) { + pub(crate) fn clear(&self) { self.tracks .borrow() .iter() diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 2c329fa92a9..4f552cefee1 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -61,7 +61,7 @@ use crate::dom::svgsvgelement::SVGSVGElement; /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common /// behaviours. Replicates the effect of C++ virtual methods. -pub trait VirtualMethods { +pub(crate) trait VirtualMethods { /// Returns self as the superclass of the implementation for this trait, /// if any. fn super_type(&self) -> Option<&dyn VirtualMethods>; @@ -166,7 +166,7 @@ pub trait VirtualMethods { /// method call on the trait object will invoke the corresponding method on the /// concrete type, propagating up the parent hierarchy unless otherwise /// interrupted. -pub fn vtable_for(node: &Node) -> &dyn VirtualMethods { +pub(crate) fn vtable_for(node: &Node) -> &dyn VirtualMethods { match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { node.downcast::<HTMLAnchorElement>().unwrap() as &dyn VirtualMethods diff --git a/components/script/dom/visibilitystateentry.rs b/components/script/dom/visibilitystateentry.rs index b650bdc54e6..c39fd23b2d9 100644 --- a/components/script/dom/visibilitystateentry.rs +++ b/components/script/dom/visibilitystateentry.rs @@ -20,7 +20,7 @@ use crate::dom::performanceentry::PerformanceEntry; use crate::script_runtime::CanGc; #[dom_struct] -pub struct VisibilityStateEntry { +pub(crate) struct VisibilityStateEntry { entry: PerformanceEntry, } @@ -44,7 +44,7 @@ impl VisibilityStateEntry { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, state: DocumentVisibilityState, timestamp: CrossProcessInstant, diff --git a/components/script/dom/vttcue.rs b/components/script/dom/vttcue.rs index 3c1b484ed09..4b829ad0a7e 100644 --- a/components/script/dom/vttcue.rs +++ b/components/script/dom/vttcue.rs @@ -25,7 +25,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct VTTCue { +pub(crate) struct VTTCue { texttrackcue: TextTrackCue, region: DomRefCell<Option<Dom<VTTRegion>>>, vertical: Cell<DirectionSetting>, @@ -40,7 +40,7 @@ pub struct VTTCue { } impl VTTCue { - pub fn new_inherited(start_time: f64, end_time: f64, text: DOMString) -> Self { + pub(crate) fn new_inherited(start_time: f64, end_time: f64, text: DOMString) -> Self { VTTCue { texttrackcue: TextTrackCue::new_inherited( DOMString::default(), diff --git a/components/script/dom/vttregion.rs b/components/script/dom/vttregion.rs index 58a72f13544..e9ac9ebbdc1 100644 --- a/components/script/dom/vttregion.rs +++ b/components/script/dom/vttregion.rs @@ -19,7 +19,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct VTTRegion { +pub(crate) struct VTTRegion { reflector_: Reflector, id: DomRefCell<DOMString>, width: Cell<f64>, diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index 5041a82b25d..c351f025245 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -88,7 +88,7 @@ impl IndexedBinding { } #[dom_struct] -pub struct WebGL2RenderingContext { +pub(crate) struct WebGL2RenderingContext { reflector_: Reflector, base: Dom<WebGLRenderingContext>, occlusion_query: MutNullableDom<WebGLQuery>, @@ -185,7 +185,7 @@ impl WebGL2RenderingContext { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, canvas: &HTMLCanvasElementOrOffscreenCanvas, size: Size2D<u32>, @@ -197,7 +197,7 @@ impl WebGL2RenderingContext { } #[allow(unsafe_code)] - pub fn is_webgl2_enabled(_cx: JSContext, global: HandleObject) -> bool { + pub(crate) fn is_webgl2_enabled(_cx: JSContext, global: HandleObject) -> bool { if pref!(dom.webgl2.enabled) { return true; } @@ -216,15 +216,15 @@ impl WebGL2RenderingContext { static WEBGL2_ORIGINS: &[&str] = &["www.servoexperiments.com"]; impl WebGL2RenderingContext { - pub fn recreate(&self, size: Size2D<u32>) { + pub(crate) fn recreate(&self, size: Size2D<u32>) { self.base.recreate(size) } - pub fn current_vao(&self) -> DomRoot<WebGLVertexArrayObject> { + pub(crate) fn current_vao(&self) -> DomRoot<WebGLVertexArrayObject> { self.base.current_vao_webgl2() } - pub fn validate_uniform_block_for_draw(&self) { + pub(crate) fn validate_uniform_block_for_draw(&self) { let program = match self.base.current_program() { Some(program) => program, None => return, @@ -326,7 +326,7 @@ impl WebGL2RenderingContext { } } - pub fn base_context(&self) -> DomRoot<WebGLRenderingContext> { + pub(crate) fn base_context(&self) -> DomRoot<WebGLRenderingContext> { DomRoot::from_ref(&*self.base) } @@ -343,7 +343,7 @@ impl WebGL2RenderingContext { } } - pub fn buffer_usage(&self, usage: u32) -> WebGLResult<u32> { + pub(crate) fn buffer_usage(&self, usage: u32) -> WebGLResult<u32> { match usage { constants::STATIC_READ | constants::DYNAMIC_READ | diff --git a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs index 6bd8b445241..6d92b4f53e3 100644 --- a/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs +++ b/components/script/dom/webgl_extensions/ext/angleinstancedarrays.rs @@ -15,7 +15,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct ANGLEInstancedArrays { +pub(crate) struct ANGLEInstancedArrays { reflector_: Reflector, ctx: Dom<WebGLRenderingContext>, } diff --git a/components/script/dom/webgl_extensions/ext/extblendminmax.rs b/components/script/dom/webgl_extensions/ext/extblendminmax.rs index b18d88cacb7..c6033b371ec 100644 --- a/components/script/dom/webgl_extensions/ext/extblendminmax.rs +++ b/components/script/dom/webgl_extensions/ext/extblendminmax.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct EXTBlendMinmax { +pub(crate) struct EXTBlendMinmax { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs index f2ec665ea4d..c17867c5188 100644 --- a/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/extcolorbufferhalffloat.rs @@ -13,7 +13,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct EXTColorBufferHalfFloat { +pub(crate) struct EXTColorBufferHalfFloat { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/extfragdepth.rs b/components/script/dom/webgl_extensions/ext/extfragdepth.rs index ae4d9fac5d9..9d5f7138678 100644 --- a/components/script/dom/webgl_extensions/ext/extfragdepth.rs +++ b/components/script/dom/webgl_extensions/ext/extfragdepth.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct EXTFragDepth { +pub(crate) struct EXTFragDepth { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs index a7bbe262c7b..3d7b2ebc29e 100644 --- a/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs +++ b/components/script/dom/webgl_extensions/ext/extshadertexturelod.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct EXTShaderTextureLod { +pub(crate) struct EXTShaderTextureLod { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs index 58e2b05b50b..903a7a2e6a3 100644 --- a/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs +++ b/components/script/dom/webgl_extensions/ext/exttexturefilteranisotropic.rs @@ -13,7 +13,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct EXTTextureFilterAnisotropic { +pub(crate) struct EXTTextureFilterAnisotropic { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/mod.rs b/components/script/dom/webgl_extensions/ext/mod.rs index 229d09d56f5..14f9d08b2ab 100644 --- a/components/script/dom/webgl_extensions/ext/mod.rs +++ b/components/script/dom/webgl_extensions/ext/mod.rs @@ -5,19 +5,19 @@ use super::{WebGLExtension, WebGLExtensionSpec, WebGLExtensions}; use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; -pub mod angleinstancedarrays; -pub mod extblendminmax; -pub mod extcolorbufferhalffloat; -pub mod extfragdepth; -pub mod extshadertexturelod; -pub mod exttexturefilteranisotropic; -pub mod oeselementindexuint; -pub mod oesstandardderivatives; -pub mod oestexturefloat; -pub mod oestexturefloatlinear; -pub mod oestexturehalffloat; -pub mod oestexturehalffloatlinear; -pub mod oesvertexarrayobject; -pub mod webglcolorbufferfloat; -pub mod webglcompressedtextureetc1; -pub mod webglcompressedtextures3tc; +pub(crate) mod angleinstancedarrays; +pub(crate) mod extblendminmax; +pub(crate) mod extcolorbufferhalffloat; +pub(crate) mod extfragdepth; +pub(crate) mod extshadertexturelod; +pub(crate) mod exttexturefilteranisotropic; +pub(crate) mod oeselementindexuint; +pub(crate) mod oesstandardderivatives; +pub(crate) mod oestexturefloat; +pub(crate) mod oestexturefloatlinear; +pub(crate) mod oestexturehalffloat; +pub(crate) mod oestexturehalffloatlinear; +pub(crate) mod oesvertexarrayobject; +pub(crate) mod webglcolorbufferfloat; +pub(crate) mod webglcompressedtextureetc1; +pub(crate) mod webglcompressedtextures3tc; diff --git a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs index 2425c42ce4f..9034d79550b 100644 --- a/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs +++ b/components/script/dom/webgl_extensions/ext/oeselementindexuint.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESElementIndexUint { +pub(crate) struct OESElementIndexUint { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs index 5afc46b3597..e5a5bf38f17 100644 --- a/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs +++ b/components/script/dom/webgl_extensions/ext/oesstandardderivatives.rs @@ -13,7 +13,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESStandardDerivatives { +pub(crate) struct OESStandardDerivatives { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs index a7e738828ac..cd6545195b2 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloat.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESTextureFloat { +pub(crate) struct OESTextureFloat { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs index 4bd2afd171f..e2b922c9743 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturefloatlinear.rs @@ -11,7 +11,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESTextureFloatLinear { +pub(crate) struct OESTextureFloatLinear { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs index 92bfffeeea5..e5e3c0e06c8 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloat.rs @@ -13,7 +13,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESTextureHalfFloat { +pub(crate) struct OESTextureHalfFloat { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs index ee0e5c10cb4..649d898a2fb 100644 --- a/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs +++ b/components/script/dom/webgl_extensions/ext/oestexturehalffloatlinear.rs @@ -12,7 +12,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESTextureHalfFloatLinear { +pub(crate) struct OESTextureHalfFloatLinear { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs index a2ed17aea16..369a3c0d90d 100644 --- a/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs +++ b/components/script/dom/webgl_extensions/ext/oesvertexarrayobject.rs @@ -16,7 +16,7 @@ use crate::dom::webglvertexarrayobjectoes::WebGLVertexArrayObjectOES; use crate::script_runtime::CanGc; #[dom_struct] -pub struct OESVertexArrayObject { +pub(crate) struct OESVertexArrayObject { reflector_: Reflector, ctx: Dom<WebGLRenderingContext>, } diff --git a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs index 71fbaf3ae05..8a9225f3e2e 100644 --- a/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs +++ b/components/script/dom/webgl_extensions/ext/webglcolorbufferfloat.rs @@ -13,7 +13,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WEBGLColorBufferFloat { +pub(crate) struct WEBGLColorBufferFloat { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs index 48ce0c36e10..0bac158f512 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextureetc1.rs @@ -13,7 +13,7 @@ use crate::dom::webgltexture::{TexCompression, TexCompressionValidation}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WEBGLCompressedTextureETC1 { +pub(crate) struct WEBGLCompressedTextureETC1 { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs index 63c39756d78..77a57772431 100644 --- a/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs +++ b/components/script/dom/webgl_extensions/ext/webglcompressedtextures3tc.rs @@ -13,7 +13,7 @@ use crate::dom::webgltexture::{TexCompression, TexCompressionValidation}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WEBGLCompressedTextureS3TC { +pub(crate) struct WEBGLCompressedTextureS3TC { reflector_: Reflector, } diff --git a/components/script/dom/webgl_extensions/extension.rs b/components/script/dom/webgl_extensions/extension.rs index 23350b0059e..0c59a7dbf82 100644 --- a/components/script/dom/webgl_extensions/extension.rs +++ b/components/script/dom/webgl_extensions/extension.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::trace::JSTraceable; use crate::dom::webglrenderingcontext::WebGLRenderingContext; /// Trait implemented by WebGL extensions. -pub trait WebGLExtension: Sized +pub(crate) trait WebGLExtension: Sized where Self::Extension: DomObject + JSTraceable, { @@ -34,7 +34,7 @@ where fn name() -> &'static str; } -pub enum WebGLExtensionSpec { +pub(crate) enum WebGLExtensionSpec { /// Extensions written against both WebGL and WebGL2 specs. All, /// Extensions writen against a specific WebGL version spec. diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index c458593d6da..fa0b4c17bc7 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -166,7 +166,7 @@ impl WebGLExtensionFeatures { /// Handles the list of implemented, supported and enabled WebGL extensions. #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] -pub struct WebGLExtensions { +pub(crate) struct WebGLExtensions { extensions: DomRefCell<HashMap<String, Box<dyn WebGLExtensionWrapper>>>, features: DomRefCell<WebGLExtensionFeatures>, #[no_trace] @@ -178,7 +178,7 @@ pub struct WebGLExtensions { } impl WebGLExtensions { - pub fn new( + pub(crate) fn new( webgl_version: WebGLVersion, api_type: GlType, glsl_version: WebGLSLVersion, @@ -192,7 +192,7 @@ impl WebGLExtensions { } } - pub fn init_once<F>(&self, cb: F) + pub(crate) fn init_once<F>(&self, cb: F) where F: FnOnce() -> String, { @@ -204,14 +204,14 @@ impl WebGLExtensions { } } - pub fn register<T: 'static + WebGLExtension + JSTraceable + MallocSizeOf>(&self) { + pub(crate) fn register<T: 'static + WebGLExtension + JSTraceable + MallocSizeOf>(&self) { let name = T::name().to_uppercase(); self.extensions .borrow_mut() .insert(name, Box::new(TypedWebGLExtensionWrapper::<T>::new())); } - pub fn get_supported_extensions(&self) -> Vec<&'static str> { + pub(crate) fn get_supported_extensions(&self) -> Vec<&'static str> { self.extensions .borrow() .iter() @@ -227,7 +227,7 @@ impl WebGLExtensions { .collect() } - pub fn get_or_init_extension( + pub(crate) fn get_or_init_extension( &self, name: &str, ctx: &WebGLRenderingContext, @@ -242,7 +242,7 @@ impl WebGLExtensions { }) } - pub fn is_enabled<T>(&self) -> bool + pub(crate) fn is_enabled<T>(&self) -> bool where T: 'static + WebGLExtension + JSTraceable + MallocSizeOf, { @@ -253,32 +253,32 @@ impl WebGLExtensions { .is_some_and(|ext| ext.is_enabled()) } - pub fn supports_gl_extension(&self, name: &str) -> bool { + pub(crate) fn supports_gl_extension(&self, name: &str) -> bool { self.features.borrow().gl_extensions.contains(name) } - pub fn supports_any_gl_extension(&self, names: &[&str]) -> bool { + pub(crate) fn supports_any_gl_extension(&self, names: &[&str]) -> bool { let features = self.features.borrow(); names .iter() .any(|name| features.gl_extensions.contains(*name)) } - pub fn supports_all_gl_extension(&self, names: &[&str]) -> bool { + pub(crate) fn supports_all_gl_extension(&self, names: &[&str]) -> bool { let features = self.features.borrow(); names .iter() .all(|name| features.gl_extensions.contains(*name)) } - pub fn enable_tex_type(&self, data_type: GLenum) { + pub(crate) fn enable_tex_type(&self, data_type: GLenum) { self.features .borrow_mut() .disabled_tex_types .remove(&data_type); } - pub fn is_tex_type_enabled(&self, data_type: GLenum) -> bool { + pub(crate) fn is_tex_type_enabled(&self, data_type: GLenum) -> bool { !self .features .borrow() @@ -286,7 +286,7 @@ impl WebGLExtensions { .contains(&data_type) } - pub fn add_effective_tex_internal_format( + pub(crate) fn add_effective_tex_internal_format( &self, source_internal_format: TexFormat, source_data_type: u32, @@ -299,7 +299,7 @@ impl WebGLExtensions { .insert(format, effective_internal_format); } - pub fn get_effective_tex_internal_format( + pub(crate) fn get_effective_tex_internal_format( &self, source_internal_format: TexFormat, source_data_type: u32, @@ -313,14 +313,14 @@ impl WebGLExtensions { .unwrap_or(&source_internal_format)) } - pub fn enable_filterable_tex_type(&self, text_data_type: GLenum) { + pub(crate) fn enable_filterable_tex_type(&self, text_data_type: GLenum) { self.features .borrow_mut() .not_filterable_tex_types .remove(&text_data_type); } - pub fn is_filterable(&self, text_data_type: u32) -> bool { + pub(crate) fn is_filterable(&self, text_data_type: u32) -> bool { !self .features .borrow() @@ -328,22 +328,22 @@ impl WebGLExtensions { .contains(&text_data_type) } - pub fn enable_hint_target(&self, name: GLenum) { + pub(crate) fn enable_hint_target(&self, name: GLenum) { self.features.borrow_mut().hint_targets.insert(name); } - pub fn is_hint_target_enabled(&self, name: GLenum) -> bool { + pub(crate) fn is_hint_target_enabled(&self, name: GLenum) -> bool { self.features.borrow().hint_targets.contains(&name) } - pub fn enable_get_parameter_name(&self, name: GLenum) { + pub(crate) fn enable_get_parameter_name(&self, name: GLenum) { self.features .borrow_mut() .disabled_get_parameter_names .remove(&name); } - pub fn is_get_parameter_name_enabled(&self, name: GLenum) -> bool { + pub(crate) fn is_get_parameter_name_enabled(&self, name: GLenum) -> bool { !self .features .borrow() @@ -351,14 +351,14 @@ impl WebGLExtensions { .contains(&name) } - pub fn enable_get_tex_parameter_name(&self, name: GLenum) { + pub(crate) fn enable_get_tex_parameter_name(&self, name: GLenum) { self.features .borrow_mut() .disabled_get_tex_parameter_names .remove(&name); } - pub fn is_get_tex_parameter_name_enabled(&self, name: GLenum) -> bool { + pub(crate) fn is_get_tex_parameter_name_enabled(&self, name: GLenum) -> bool { !self .features .borrow() @@ -366,14 +366,14 @@ impl WebGLExtensions { .contains(&name) } - pub fn enable_get_vertex_attrib_name(&self, name: GLenum) { + pub(crate) fn enable_get_vertex_attrib_name(&self, name: GLenum) { self.features .borrow_mut() .disabled_get_vertex_attrib_names .remove(&name); } - pub fn is_get_vertex_attrib_name_enabled(&self, name: GLenum) -> bool { + pub(crate) fn is_get_vertex_attrib_name_enabled(&self, name: GLenum) -> bool { !self .features .borrow() @@ -381,7 +381,7 @@ impl WebGLExtensions { .contains(&name) } - pub fn add_tex_compression_formats(&self, formats: &[TexCompression]) { + pub(crate) fn add_tex_compression_formats(&self, formats: &[TexCompression]) { let formats: FnvHashMap<GLenum, TexCompression> = formats .iter() .map(|&compression| (compression.format.as_gl_constant(), compression)) @@ -393,7 +393,7 @@ impl WebGLExtensions { .extend(formats.iter()); } - pub fn get_tex_compression_format(&self, format_id: GLenum) -> Option<TexCompression> { + pub(crate) fn get_tex_compression_format(&self, format_id: GLenum) -> Option<TexCompression> { self.features .borrow() .tex_compression_formats @@ -401,7 +401,7 @@ impl WebGLExtensions { .cloned() } - pub fn get_tex_compression_ids(&self) -> Vec<GLenum> { + pub(crate) fn get_tex_compression_ids(&self) -> Vec<GLenum> { self.features .borrow() .tex_compression_formats @@ -429,35 +429,35 @@ impl WebGLExtensions { self.register::<ext::webglcompressedtextures3tc::WEBGLCompressedTextureS3TC>(); } - pub fn enable_element_index_uint(&self) { + pub(crate) fn enable_element_index_uint(&self) { self.features.borrow_mut().element_index_uint_enabled = true; } - pub fn is_element_index_uint_enabled(&self) -> bool { + pub(crate) fn is_element_index_uint_enabled(&self) -> bool { self.features.borrow().element_index_uint_enabled } - pub fn enable_blend_minmax(&self) { + pub(crate) fn enable_blend_minmax(&self) { self.features.borrow_mut().blend_minmax_enabled = true; } - pub fn is_blend_minmax_enabled(&self) -> bool { + pub(crate) fn is_blend_minmax_enabled(&self) -> bool { self.features.borrow().blend_minmax_enabled } - pub fn is_float_buffer_renderable(&self) -> bool { + pub(crate) fn is_float_buffer_renderable(&self) -> bool { self.is_enabled::<WEBGLColorBufferFloat>() || self.is_enabled::<OESTextureFloat>() } - pub fn is_min_glsl_version_satisfied(&self, min_glsl_version: WebGLSLVersion) -> bool { + pub(crate) fn is_min_glsl_version_satisfied(&self, min_glsl_version: WebGLSLVersion) -> bool { self.glsl_version >= min_glsl_version } - pub fn is_half_float_buffer_renderable(&self) -> bool { + pub(crate) fn is_half_float_buffer_renderable(&self) -> bool { self.is_enabled::<EXTColorBufferHalfFloat>() || self.is_enabled::<OESTextureHalfFloat>() } - pub fn effective_type(&self, type_: u32) -> u32 { + pub(crate) fn effective_type(&self, type_: u32) -> u32 { if type_ == OESTextureHalfFloatConstants::HALF_FLOAT_OES && !self.supports_gl_extension("GL_OES_texture_half_float") { @@ -466,7 +466,7 @@ impl WebGLExtensions { type_ } - pub fn is_gles(&self) -> bool { + pub(crate) fn is_gles(&self) -> bool { self.api_type == GlType::Gles } } diff --git a/components/script/dom/webgl_extensions/mod.rs b/components/script/dom/webgl_extensions/mod.rs index df91a5e00d1..2bcf2c3d679 100644 --- a/components/script/dom/webgl_extensions/mod.rs +++ b/components/script/dom/webgl_extensions/mod.rs @@ -2,10 +2,10 @@ * 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/. */ -pub mod ext; +pub(crate) mod ext; mod extension; mod extensions; mod wrapper; -pub use self::extension::{WebGLExtension, WebGLExtensionSpec}; -pub use self::extensions::WebGLExtensions; +pub(crate) use self::extension::{WebGLExtension, WebGLExtensionSpec}; +pub(crate) use self::extensions::WebGLExtensions; diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index fc9b6074e8e..1d1957f10ec 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -15,7 +15,7 @@ use crate::dom::webglrenderingcontext::WebGLRenderingContext; /// Trait used internally by WebGLExtensions to store and /// handle the different WebGL extensions in a common list. -pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { +pub(crate) trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { fn instance_or_init( &self, ctx: &WebGLRenderingContext, @@ -30,14 +30,14 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] -pub struct TypedWebGLExtensionWrapper<T: WebGLExtension> { +pub(crate) struct TypedWebGLExtensionWrapper<T: WebGLExtension> { extension: MutNullableDom<T::Extension>, } /// Typed WebGL Extension implementation. /// Exposes the exact `MutNullableDom<DOMObject>` type defined by the extension. impl<T: WebGLExtension> TypedWebGLExtensionWrapper<T> { - pub fn new() -> TypedWebGLExtensionWrapper<T> { + pub(crate) fn new() -> TypedWebGLExtensionWrapper<T> { TypedWebGLExtensionWrapper { extension: MutNullableDom::new(None), } diff --git a/components/script/dom/webgl_validations/mod.rs b/components/script/dom/webgl_validations/mod.rs index c590b6029c4..02b5d40ce08 100644 --- a/components/script/dom/webgl_validations/mod.rs +++ b/components/script/dom/webgl_validations/mod.rs @@ -2,12 +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/. */ -pub trait WebGLValidator { +pub(crate) trait WebGLValidator { type ValidatedOutput; type Error: ::std::error::Error; fn validate(self) -> Result<Self::ValidatedOutput, Self::Error>; } -pub mod tex_image_2d; -pub mod types; +pub(crate) mod tex_image_2d; +pub(crate) mod types; diff --git a/components/script/dom/webgl_validations/tex_image_2d.rs b/components/script/dom/webgl_validations/tex_image_2d.rs index 2fad80a8b34..3bc518b7546 100644 --- a/components/script/dom/webgl_validations/tex_image_2d.rs +++ b/components/script/dom/webgl_validations/tex_image_2d.rs @@ -15,7 +15,7 @@ use crate::dom::webgltexture::{ImageInfo, TexCompression, TexCompressionValidati /// The errors that the texImage* family of functions can generate. #[derive(Debug)] -pub enum TexImageValidationError { +pub(crate) enum TexImageValidationError { /// An invalid texture target was passed, it contains the invalid target. InvalidTextureTarget(u32), /// The passed texture target was not bound. @@ -87,7 +87,7 @@ fn log2(n: u32) -> u32 { 31 - n.leading_zeros() } -pub struct CommonTexImage2DValidator<'a> { +pub(crate) struct CommonTexImage2DValidator<'a> { context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -97,14 +97,14 @@ pub struct CommonTexImage2DValidator<'a> { border: i32, } -pub struct CommonTexImage2DValidatorResult { - pub texture: DomRoot<WebGLTexture>, - pub target: TexImageTarget, - pub level: u32, - pub internal_format: TexFormat, - pub width: u32, - pub height: u32, - pub border: u32, +pub(crate) struct CommonTexImage2DValidatorResult { + pub(crate) texture: DomRoot<WebGLTexture>, + pub(crate) target: TexImageTarget, + pub(crate) level: u32, + pub(crate) internal_format: TexFormat, + pub(crate) width: u32, + pub(crate) height: u32, + pub(crate) border: u32, } impl WebGLValidator for CommonTexImage2DValidator<'_> { @@ -226,7 +226,7 @@ impl WebGLValidator for CommonTexImage2DValidator<'_> { } impl<'a> CommonTexImage2DValidator<'a> { - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -247,7 +247,7 @@ impl<'a> CommonTexImage2DValidator<'a> { } } -pub struct TexImage2DValidator<'a> { +pub(crate) struct TexImage2DValidator<'a> { common_validator: CommonTexImage2DValidator<'a>, format: u32, data_type: u32, @@ -256,7 +256,7 @@ pub struct TexImage2DValidator<'a> { impl<'a> TexImage2DValidator<'a> { /// TODO: Move data validation logic here. #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -284,17 +284,17 @@ impl<'a> TexImage2DValidator<'a> { } /// The validated result of a TexImage2DValidator-validated call. -pub struct TexImage2DValidatorResult { +pub(crate) struct TexImage2DValidatorResult { /// NB: width, height and level are already unsigned after validation. - pub width: u32, - pub height: u32, - pub level: u32, - pub border: u32, - pub texture: DomRoot<WebGLTexture>, - pub target: TexImageTarget, - pub internal_format: TexFormat, - pub format: TexFormat, - pub data_type: TexDataType, + pub(crate) width: u32, + pub(crate) height: u32, + pub(crate) level: u32, + pub(crate) border: u32, + pub(crate) texture: DomRoot<WebGLTexture>, + pub(crate) target: TexImageTarget, + pub(crate) internal_format: TexFormat, + pub(crate) format: TexFormat, + pub(crate) data_type: TexDataType, } /// TexImage2d validator as per @@ -381,14 +381,14 @@ impl WebGLValidator for TexImage2DValidator<'_> { } } -pub struct CommonCompressedTexImage2DValidator<'a> { +pub(crate) struct CommonCompressedTexImage2DValidator<'a> { common_validator: CommonTexImage2DValidator<'a>, data_len: usize, } impl<'a> CommonCompressedTexImage2DValidator<'a> { #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -413,13 +413,13 @@ impl<'a> CommonCompressedTexImage2DValidator<'a> { } } -pub struct CommonCompressedTexImage2DValidatorResult { - pub texture: DomRoot<WebGLTexture>, - pub target: TexImageTarget, - pub level: u32, - pub width: u32, - pub height: u32, - pub compression: TexCompression, +pub(crate) struct CommonCompressedTexImage2DValidatorResult { + pub(crate) texture: DomRoot<WebGLTexture>, + pub(crate) target: TexImageTarget, + pub(crate) level: u32, + pub(crate) width: u32, + pub(crate) height: u32, + pub(crate) compression: TexCompression, } fn valid_s3tc_dimension(level: u32, side_length: u32, block_size: u32) -> bool { @@ -506,13 +506,13 @@ impl WebGLValidator for CommonCompressedTexImage2DValidator<'_> { } } -pub struct CompressedTexImage2DValidator<'a> { +pub(crate) struct CompressedTexImage2DValidator<'a> { compression_validator: CommonCompressedTexImage2DValidator<'a>, } impl<'a> CompressedTexImage2DValidator<'a> { #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -581,7 +581,7 @@ impl WebGLValidator for CompressedTexImage2DValidator<'_> { } } -pub struct CompressedTexSubImage2DValidator<'a> { +pub(crate) struct CompressedTexSubImage2DValidator<'a> { compression_validator: CommonCompressedTexImage2DValidator<'a>, xoffset: i32, yoffset: i32, @@ -589,7 +589,7 @@ pub struct CompressedTexSubImage2DValidator<'a> { impl<'a> CompressedTexSubImage2DValidator<'a> { #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, target: u32, level: i32, @@ -684,25 +684,25 @@ impl WebGLValidator for CompressedTexSubImage2DValidator<'_> { } } -pub struct TexStorageValidator<'a> { +pub(crate) struct TexStorageValidator<'a> { common_validator: CommonTexImage2DValidator<'a>, dimensions: u8, depth: i32, } -pub struct TexStorageValidatorResult { - pub texture: DomRoot<WebGLTexture>, - pub target: TexImageTarget, - pub levels: u32, - pub internal_format: TexFormat, - pub width: u32, - pub height: u32, - pub depth: u32, +pub(crate) struct TexStorageValidatorResult { + pub(crate) texture: DomRoot<WebGLTexture>, + pub(crate) target: TexImageTarget, + pub(crate) levels: u32, + pub(crate) internal_format: TexFormat, + pub(crate) width: u32, + pub(crate) height: u32, + pub(crate) depth: u32, } impl<'a> TexStorageValidator<'a> { #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( context: &'a WebGLRenderingContext, dimensions: u8, target: u32, diff --git a/components/script/dom/webgl_validations/types.rs b/components/script/dom/webgl_validations/types.rs index 5d37a6d12f1..f72aa4e8be8 100644 --- a/components/script/dom/webgl_validations/types.rs +++ b/components/script/dom/webgl_validations/types.rs @@ -23,11 +23,11 @@ gl_enums! { } impl TexImageTarget { - pub fn is_cubic(&self) -> bool { + pub(crate) fn is_cubic(&self) -> bool { !matches!(*self, TexImageTarget::Texture2D) } - pub fn dimensions(self) -> u8 { + pub(crate) fn dimensions(self) -> u8 { match self { TexImageTarget::Texture3D | TexImageTarget::Texture2DArray => 3, _ => 2, diff --git a/components/script/dom/webglactiveinfo.rs b/components/script/dom/webglactiveinfo.rs index 744f7fe6195..f34376fad83 100644 --- a/components/script/dom/webglactiveinfo.rs +++ b/components/script/dom/webglactiveinfo.rs @@ -13,7 +13,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLActiveInfo { +pub(crate) struct WebGLActiveInfo { reflector_: Reflector, size: i32, // NOTE: `ty` stands for `type`, which is a reserved keyword @@ -31,7 +31,12 @@ impl WebGLActiveInfo { } } - pub fn new(window: &Window, size: i32, ty: u32, name: DOMString) -> DomRoot<WebGLActiveInfo> { + pub(crate) fn new( + window: &Window, + size: i32, + ty: u32, + name: DOMString, + ) -> DomRoot<WebGLActiveInfo> { reflect_dom_object( Box::new(WebGLActiveInfo::new_inherited(size, ty, name)), window, diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs index 2b057001eef..3060e5d4bf8 100644 --- a/components/script/dom/webglbuffer.rs +++ b/components/script/dom/webglbuffer.rs @@ -24,7 +24,7 @@ fn target_is_copy_buffer(target: u32) -> bool { } #[dom_struct] -pub struct WebGLBuffer { +pub(crate) struct WebGLBuffer { webgl_object: WebGLObject, #[no_trace] id: WebGLBufferId, @@ -50,7 +50,7 @@ impl WebGLBuffer { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateBuffer(sender)); receiver @@ -59,7 +59,7 @@ impl WebGLBuffer { .map(|id| WebGLBuffer::new(context, id)) } - pub fn new(context: &WebGLRenderingContext, id: WebGLBufferId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLBufferId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLBuffer::new_inherited(context, id)), &*context.global(), @@ -69,11 +69,11 @@ impl WebGLBuffer { } impl WebGLBuffer { - pub fn id(&self) -> WebGLBufferId { + pub(crate) fn id(&self) -> WebGLBufferId { self.id } - pub fn buffer_data(&self, target: u32, data: &[u8], usage: u32) -> WebGLResult<()> { + pub(crate) fn buffer_data(&self, target: u32, data: &[u8], usage: u32) -> WebGLResult<()> { match usage { WebGLRenderingContextConstants::STREAM_DRAW | WebGLRenderingContextConstants::STATIC_DRAW | @@ -97,11 +97,11 @@ impl WebGLBuffer { Ok(()) } - pub fn capacity(&self) -> usize { + pub(crate) fn capacity(&self) -> usize { self.capacity.get() } - pub fn mark_for_deletion(&self, operation_fallibility: Operation) { + pub(crate) fn mark_for_deletion(&self, operation_fallibility: Operation) { if self.marked_for_deletion.get() { return; } @@ -121,15 +121,15 @@ impl WebGLBuffer { } } - pub fn is_marked_for_deletion(&self) -> bool { + pub(crate) fn is_marked_for_deletion(&self) -> bool { self.marked_for_deletion.get() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.marked_for_deletion.get() && !self.is_attached() } - pub fn target(&self) -> Option<u32> { + pub(crate) fn target(&self) -> Option<u32> { self.target.get() } @@ -144,7 +144,7 @@ impl WebGLBuffer { true } - pub fn set_target_maybe(&self, target: u32) -> WebGLResult<()> { + pub(crate) fn set_target_maybe(&self, target: u32) -> WebGLResult<()> { if !self.can_bind_to(target) { return Err(WebGLError::InvalidOperation); } @@ -154,11 +154,11 @@ impl WebGLBuffer { Ok(()) } - pub fn is_attached(&self) -> bool { + pub(crate) fn is_attached(&self) -> bool { self.attached_counter.get() != 0 } - pub fn increment_attached_counter(&self) { + pub(crate) fn increment_attached_counter(&self) { self.attached_counter.set( self.attached_counter .get() @@ -167,7 +167,7 @@ impl WebGLBuffer { ); } - pub fn decrement_attached_counter(&self, operation_fallibility: Operation) { + pub(crate) fn decrement_attached_counter(&self, operation_fallibility: Operation) { self.attached_counter.set( self.attached_counter .get() @@ -179,7 +179,7 @@ impl WebGLBuffer { } } - pub fn usage(&self) -> u32 { + pub(crate) fn usage(&self) -> u32 { self.usage.get() } } diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs index f8773c82224..a96e3218f37 100644 --- a/components/script/dom/webglcontextevent.rs +++ b/components/script/dom/webglcontextevent.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLContextEvent { +pub(crate) struct WebGLContextEvent { event: Event, status_message: DOMString, } @@ -73,7 +73,7 @@ impl WebGLContextEvent { } } - pub fn new( + pub(crate) fn new( window: &Window, type_: Atom, bubbles: EventBubbles, diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index 5c015e36549..b3faf613a1c 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -29,7 +29,7 @@ use crate::dom::webgltexture::WebGLTexture; use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; -pub enum CompleteForRendering { +pub(crate) enum CompleteForRendering { Complete, Incomplete, MissingColorAttachment, @@ -86,13 +86,13 @@ impl WebGLFramebufferAttachment { } #[derive(Clone, JSTraceable, MallocSizeOf)] -pub enum WebGLFramebufferAttachmentRoot { +pub(crate) enum WebGLFramebufferAttachmentRoot { Renderbuffer(DomRoot<WebGLRenderbuffer>), Texture(DomRoot<WebGLTexture>), } #[dom_struct] -pub struct WebGLFramebuffer { +pub(crate) struct WebGLFramebuffer { webgl_object: WebGLObject, #[no_trace] webgl_version: WebGLVersion, @@ -139,7 +139,7 @@ impl WebGLFramebuffer { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateFramebuffer(sender)); let id = receiver.recv().unwrap()?; @@ -150,7 +150,7 @@ impl WebGLFramebuffer { // TODO: depth, stencil and alpha // https://github.com/servo/servo/issues/24498 #[cfg(feature = "webxr")] - pub fn maybe_new_webxr( + pub(crate) fn maybe_new_webxr( session: &XRSession, context: &WebGLRenderingContext, size: Size2D<i32, Viewport>, @@ -162,7 +162,7 @@ impl WebGLFramebuffer { Some(framebuffer) } - pub fn new(context: &WebGLRenderingContext, id: WebGLFramebufferId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLFramebufferId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLFramebuffer::new_inherited(context, id)), &*context.global(), @@ -172,7 +172,7 @@ impl WebGLFramebuffer { } impl WebGLFramebuffer { - pub fn id(&self) -> WebGLFramebufferId { + pub(crate) fn id(&self) -> WebGLFramebufferId { self.id } @@ -186,7 +186,7 @@ impl WebGLFramebuffer { false } - pub fn validate_transparent(&self) -> WebGLResult<()> { + pub(crate) fn validate_transparent(&self) -> WebGLResult<()> { if self.is_in_xr_session() { Err(WebGLError::InvalidOperation) } else { @@ -194,7 +194,7 @@ impl WebGLFramebuffer { } } - pub fn bind(&self, target: u32) { + pub(crate) fn bind(&self, target: u32) { if !self.is_in_xr_session() { // Update the framebuffer status on binding. It may have // changed if its attachments were resized or deleted while @@ -211,7 +211,7 @@ impl WebGLFramebuffer { )); } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -223,18 +223,20 @@ impl WebGLFramebuffer { } } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { // TODO: if a framebuffer has an attachment which is invalid due to // being outside a webxr rAF, should this make the framebuffer invalid? // https://github.com/immersive-web/layers/issues/196 self.is_deleted.get() } - pub fn size(&self) -> Option<(i32, i32)> { + pub(crate) fn size(&self) -> Option<(i32, i32)> { self.size.get() } - pub fn get_attachment_formats(&self) -> WebGLResult<(Option<u32>, Option<u32>, Option<u32>)> { + pub(crate) fn get_attachment_formats( + &self, + ) -> WebGLResult<(Option<u32>, Option<u32>, Option<u32>)> { if self.check_status() != constants::FRAMEBUFFER_COMPLETE { return Err(WebGLError::InvalidFramebufferOperation); } @@ -296,7 +298,7 @@ impl WebGLFramebuffer { Ok(()) } - pub fn update_status(&self) { + pub(crate) fn update_status(&self) { let z = self.depth.borrow(); let s = self.stencil.borrow(); let zs = self.depthstencil.borrow(); @@ -476,7 +478,7 @@ impl WebGLFramebuffer { } } - pub fn check_status(&self) -> u32 { + pub(crate) fn check_status(&self) -> u32 { // For opaque framebuffers, check to see if the XR session is currently processing an rAF // https://immersive-web.github.io/webxr/#opaque-framebuffer #[cfg(feature = "webxr")] @@ -494,7 +496,7 @@ impl WebGLFramebuffer { // https://github.com/immersive-web/layers/issues/196 } - pub fn check_status_for_rendering(&self) -> CompleteForRendering { + pub(crate) fn check_status_for_rendering(&self) -> CompleteForRendering { let result = self.check_status(); if result != constants::FRAMEBUFFER_COMPLETE { return CompleteForRendering::Incomplete; @@ -550,7 +552,11 @@ impl WebGLFramebuffer { CompleteForRendering::Complete } - pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> { + pub(crate) fn renderbuffer( + &self, + attachment: u32, + rb: Option<&WebGLRenderbuffer>, + ) -> WebGLResult<()> { // Opaque framebuffers cannot have their attachments changed // https://immersive-web.github.io/webxr/#opaque-framebuffer self.validate_transparent()?; @@ -672,7 +678,7 @@ impl WebGLFramebuffer { Ok(()) } - pub fn attachment(&self, attachment: u32) -> Option<WebGLFramebufferAttachmentRoot> { + pub(crate) fn attachment(&self, attachment: u32) -> Option<WebGLFramebufferAttachmentRoot> { let binding = self.attachment_binding(attachment)?; binding .borrow() @@ -680,7 +686,7 @@ impl WebGLFramebuffer { .map(WebGLFramebufferAttachment::root) } - pub fn texture2d( + pub(crate) fn texture2d( &self, attachment: u32, textarget: u32, @@ -734,7 +740,7 @@ impl WebGLFramebuffer { self.texture2d_even_if_opaque(attachment, textarget, texture, level) } - pub fn texture2d_even_if_opaque( + pub(crate) fn texture2d_even_if_opaque( &self, attachment: u32, textarget: u32, @@ -780,7 +786,7 @@ impl WebGLFramebuffer { Ok(()) } - pub fn texture_layer( + pub(crate) fn texture_layer( &self, attachment: u32, texture: Option<&WebGLTexture>, @@ -907,7 +913,7 @@ impl WebGLFramebuffer { } } - pub fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) -> WebGLResult<()> { + pub(crate) fn detach_renderbuffer(&self, rb: &WebGLRenderbuffer) -> WebGLResult<()> { // Opaque framebuffers cannot have their attachments changed // https://immersive-web.github.io/webxr/#opaque-framebuffer self.validate_transparent()?; @@ -928,7 +934,7 @@ impl WebGLFramebuffer { Ok(()) } - pub fn detach_texture(&self, texture: &WebGLTexture) -> WebGLResult<()> { + pub(crate) fn detach_texture(&self, texture: &WebGLTexture) -> WebGLResult<()> { // Opaque framebuffers cannot have their attachments changed // https://immersive-web.github.io/webxr/#opaque-framebuffer self.validate_transparent()?; @@ -949,20 +955,20 @@ impl WebGLFramebuffer { Ok(()) } - pub fn invalidate_renderbuffer(&self, rb: &WebGLRenderbuffer) { + pub(crate) fn invalidate_renderbuffer(&self, rb: &WebGLRenderbuffer) { self.with_matching_renderbuffers(rb, |_att, _| { self.is_initialized.set(false); self.update_status(); }); } - pub fn invalidate_texture(&self, texture: &WebGLTexture) { + pub(crate) fn invalidate_texture(&self, texture: &WebGLTexture) { self.with_matching_textures(texture, |_att, _name| { self.update_status(); }); } - pub fn set_read_buffer(&self, buffer: u32) -> WebGLResult<()> { + pub(crate) fn set_read_buffer(&self, buffer: u32) -> WebGLResult<()> { let context = self.upcast::<WebGLObject>().context(); match buffer { @@ -976,7 +982,7 @@ impl WebGLFramebuffer { Ok(()) } - pub fn set_draw_buffers(&self, buffers: Vec<u32>) -> WebGLResult<()> { + pub(crate) fn set_draw_buffers(&self, buffers: Vec<u32>) -> WebGLResult<()> { let context = self.upcast::<WebGLObject>().context(); if buffers.len() > context.limits().max_draw_buffers as usize { @@ -1002,16 +1008,16 @@ impl WebGLFramebuffer { Ok(()) } - pub fn read_buffer(&self) -> u32 { + pub(crate) fn read_buffer(&self) -> u32 { *self.color_read_buffer.borrow() } - pub fn draw_buffer_i(&self, index: usize) -> u32 { + pub(crate) fn draw_buffer_i(&self, index: usize) -> u32 { let buffers = &*self.color_draw_buffers.borrow(); *buffers.get(index).unwrap_or(&constants::NONE) } - pub fn target(&self) -> Option<u32> { + pub(crate) fn target(&self) -> Option<u32> { self.target.get() } } diff --git a/components/script/dom/webglobject.rs b/components/script/dom/webglobject.rs index 3eb03ce4620..bab32629a8e 100644 --- a/components/script/dom/webglobject.rs +++ b/components/script/dom/webglobject.rs @@ -13,14 +13,14 @@ use crate::dom::bindings::str::USVString; use crate::dom::webglrenderingcontext::WebGLRenderingContext; #[dom_struct] -pub struct WebGLObject { +pub(crate) struct WebGLObject { reflector_: Reflector, context: Dom<WebGLRenderingContext>, label: DomRefCell<USVString>, } impl WebGLObject { - pub fn new_inherited(context: &WebGLRenderingContext) -> WebGLObject { + pub(crate) fn new_inherited(context: &WebGLRenderingContext) -> WebGLObject { WebGLObject { reflector_: Reflector::new(), context: Dom::from_ref(context), @@ -28,7 +28,7 @@ impl WebGLObject { } } - pub fn context(&self) -> &WebGLRenderingContext { + pub(crate) fn context(&self) -> &WebGLRenderingContext { &self.context } } diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs index 61673289566..52c48872eb1 100644 --- a/components/script/dom/webglprogram.rs +++ b/components/script/dom/webglprogram.rs @@ -27,7 +27,7 @@ use crate::dom::webgluniformlocation::WebGLUniformLocation; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLProgram { +pub(crate) struct WebGLProgram { webgl_object: WebGLObject, #[no_trace] id: WebGLProgramId, @@ -68,7 +68,7 @@ impl WebGLProgram { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateProgram(sender)); receiver @@ -77,7 +77,7 @@ impl WebGLProgram { .map(|id| WebGLProgram::new(context, id)) } - pub fn new(context: &WebGLRenderingContext, id: WebGLProgramId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLProgramId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLProgram::new_inherited(context, id)), &*context.global(), @@ -87,12 +87,12 @@ impl WebGLProgram { } impl WebGLProgram { - pub fn id(&self) -> WebGLProgramId { + pub(crate) fn id(&self) -> WebGLProgramId { self.id } /// glDeleteProgram - pub fn mark_for_deletion(&self, operation_fallibility: Operation) { + pub(crate) fn mark_for_deletion(&self, operation_fallibility: Operation) { if self.marked_for_deletion.get() { return; } @@ -108,7 +108,7 @@ impl WebGLProgram { } } - pub fn in_use(&self, value: bool) { + pub(crate) fn in_use(&self, value: bool) { if self.is_in_use.get() == value { return; } @@ -130,24 +130,24 @@ impl WebGLProgram { } } - pub fn is_in_use(&self) -> bool { + pub(crate) fn is_in_use(&self) -> bool { self.is_in_use.get() } - pub fn is_marked_for_deletion(&self) -> bool { + pub(crate) fn is_marked_for_deletion(&self) -> bool { self.marked_for_deletion.get() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.marked_for_deletion.get() && !self.is_in_use.get() } - pub fn is_linked(&self) -> bool { + pub(crate) fn is_linked(&self) -> bool { self.linked.get() } /// glLinkProgram - pub fn link(&self) -> WebGLResult<()> { + pub(crate) fn link(&self) -> WebGLResult<()> { self.linked.set(false); self.link_generation .set(self.link_generation.get().checked_add(1).unwrap()); @@ -212,20 +212,20 @@ impl WebGLProgram { Ok(()) } - pub fn active_attribs(&self) -> Ref<[ActiveAttribInfo]> { + pub(crate) fn active_attribs(&self) -> Ref<[ActiveAttribInfo]> { Ref::map(self.active_attribs.borrow(), |attribs| &**attribs) } - pub fn active_uniforms(&self) -> Ref<[ActiveUniformInfo]> { + pub(crate) fn active_uniforms(&self) -> Ref<[ActiveUniformInfo]> { Ref::map(self.active_uniforms.borrow(), |uniforms| &**uniforms) } - pub fn active_uniform_blocks(&self) -> Ref<[ActiveUniformBlockInfo]> { + pub(crate) fn active_uniform_blocks(&self) -> Ref<[ActiveUniformBlockInfo]> { Ref::map(self.active_uniform_blocks.borrow(), |blocks| &**blocks) } /// glValidateProgram - pub fn validate(&self) -> WebGLResult<()> { + pub(crate) fn validate(&self) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -236,7 +236,7 @@ impl WebGLProgram { } /// glAttachShader - pub fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { + pub(crate) fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { if self.is_deleted() || shader.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -264,7 +264,7 @@ impl WebGLProgram { } /// glDetachShader - pub fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { + pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -293,7 +293,7 @@ impl WebGLProgram { } /// glBindAttribLocation - pub fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> { + pub(crate) fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> { if self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -315,7 +315,7 @@ impl WebGLProgram { Ok(()) } - pub fn get_active_uniform(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { + pub(crate) fn get_active_uniform(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -332,7 +332,7 @@ impl WebGLProgram { } /// glGetActiveAttrib - pub fn get_active_attrib(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { + pub(crate) fn get_active_attrib(&self, index: u32) -> WebGLResult<DomRoot<WebGLActiveInfo>> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -349,7 +349,7 @@ impl WebGLProgram { } /// glGetAttribLocation - pub fn get_attrib_location(&self, name: DOMString) -> WebGLResult<i32> { + pub(crate) fn get_attrib_location(&self, name: DOMString) -> WebGLResult<i32> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -372,7 +372,7 @@ impl WebGLProgram { } /// glGetFragDataLocation - pub fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> { + pub(crate) fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -396,7 +396,7 @@ impl WebGLProgram { } /// glGetUniformLocation - pub fn get_uniform_location( + pub(crate) fn get_uniform_location( &self, name: DOMString, ) -> WebGLResult<Option<DomRoot<WebGLUniformLocation>>> { @@ -454,7 +454,7 @@ impl WebGLProgram { ))) } - pub fn get_uniform_block_index(&self, name: DOMString) -> WebGLResult<u32> { + pub(crate) fn get_uniform_block_index(&self, name: DOMString) -> WebGLResult<u32> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -474,7 +474,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_uniform_indices(&self, names: Vec<DOMString>) -> WebGLResult<Vec<u32>> { + pub(crate) fn get_uniform_indices(&self, names: Vec<DOMString>) -> WebGLResult<Vec<u32>> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -500,7 +500,11 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniforms(&self, indices: Vec<u32>, pname: u32) -> WebGLResult<Vec<i32>> { + pub(crate) fn get_active_uniforms( + &self, + indices: Vec<u32>, + pname: u32, + ) -> WebGLResult<Vec<i32>> { if !self.is_linked() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -529,7 +533,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniform_block_parameter( + pub(crate) fn get_active_uniform_block_parameter( &self, block_index: u32, pname: u32, @@ -559,7 +563,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn get_active_uniform_block_name(&self, block_index: u32) -> WebGLResult<String> { + pub(crate) fn get_active_uniform_block_name(&self, block_index: u32) -> WebGLResult<String> { if !self.link_called.get() || self.is_deleted() { return Err(WebGLError::InvalidOperation); } @@ -575,7 +579,11 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn bind_uniform_block(&self, block_index: u32, block_binding: u32) -> WebGLResult<()> { + pub(crate) fn bind_uniform_block( + &self, + block_index: u32, + block_binding: u32, + ) -> WebGLResult<()> { if block_index as usize >= self.active_uniform_blocks.borrow().len() { return Err(WebGLError::InvalidValue); } @@ -596,7 +604,7 @@ impl WebGLProgram { } /// glGetProgramInfoLog - pub fn get_info_log(&self) -> WebGLResult<String> { + pub(crate) fn get_info_log(&self) -> WebGLResult<String> { if self.is_deleted() { return Err(WebGLError::InvalidValue); } @@ -616,7 +624,7 @@ impl WebGLProgram { Ok(receiver.recv().unwrap()) } - pub fn attached_shaders(&self) -> WebGLResult<Vec<DomRoot<WebGLShader>>> { + pub(crate) fn attached_shaders(&self) -> WebGLResult<Vec<DomRoot<WebGLShader>>> { if self.marked_for_deletion.get() { return Err(WebGLError::InvalidValue); } @@ -631,15 +639,15 @@ impl WebGLProgram { ) } - pub fn link_generation(&self) -> u64 { + pub(crate) fn link_generation(&self) -> u64 { self.link_generation.get() } - pub fn transform_feedback_varyings_length(&self) -> i32 { + pub(crate) fn transform_feedback_varyings_length(&self) -> i32 { self.transform_feedback_varyings_length.get() } - pub fn transform_feedback_buffer_mode(&self) -> i32 { + pub(crate) fn transform_feedback_buffer_mode(&self) -> i32 { self.transform_feedback_mode.get() } } @@ -718,4 +726,4 @@ fn parse_uniform_name(name: &str) -> Option<(&str, Option<i32>)> { Some((&name[..bracket_pos], Some(index))) } -pub const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256; +pub(crate) const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256; diff --git a/components/script/dom/webglquery.rs b/components/script/dom/webglquery.rs index b60185a7abd..aa7f84075cd 100644 --- a/components/script/dom/webglquery.rs +++ b/components/script/dom/webglquery.rs @@ -18,7 +18,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLQuery { +pub(crate) struct WebGLQuery { webgl_object: WebGLObject, #[no_trace] gl_id: WebGLQueryId, @@ -40,7 +40,7 @@ impl WebGLQuery { } } - pub fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::GenerateQuery(sender)); let id = receiver.recv().unwrap(); @@ -52,7 +52,7 @@ impl WebGLQuery { ) } - pub fn begin( + pub(crate) fn begin( &self, context: &WebGLRenderingContext, target: u32, @@ -77,7 +77,7 @@ impl WebGLQuery { Ok(()) } - pub fn end( + pub(crate) fn end( &self, context: &WebGLRenderingContext, target: u32, @@ -100,7 +100,7 @@ impl WebGLQuery { Ok(()) } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); @@ -113,11 +113,11 @@ impl WebGLQuery { } } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { !self.marked_for_deletion.get() && self.target().is_some() } - pub fn target(&self) -> Option<u32> { + pub(crate) fn target(&self) -> Option<u32> { self.gl_target.get() } @@ -146,7 +146,7 @@ impl WebGLQuery { } #[rustfmt::skip] - pub fn get_parameter( + pub(crate) fn get_parameter( &self, context: &WebGLRenderingContext, pname: u32, diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index 83a2d4af88e..4fdec4cd72f 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -23,7 +23,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLRenderbuffer { +pub(crate) struct WebGLRenderbuffer { webgl_object: WebGLObject, #[no_trace] id: WebGLRenderbufferId, @@ -49,7 +49,7 @@ impl WebGLRenderbuffer { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateRenderbuffer(sender)); receiver @@ -58,7 +58,7 @@ impl WebGLRenderbuffer { .map(|id| WebGLRenderbuffer::new(context, id)) } - pub fn new(context: &WebGLRenderingContext, id: WebGLRenderbufferId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLRenderbufferId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLRenderbuffer::new_inherited(context, id)), &*context.global(), @@ -68,34 +68,34 @@ impl WebGLRenderbuffer { } impl WebGLRenderbuffer { - pub fn id(&self) -> WebGLRenderbufferId { + pub(crate) fn id(&self) -> WebGLRenderbufferId { self.id } - pub fn size(&self) -> Option<(i32, i32)> { + pub(crate) fn size(&self) -> Option<(i32, i32)> { self.size.get() } - pub fn internal_format(&self) -> u32 { + pub(crate) fn internal_format(&self) -> u32 { self.internal_format.get().unwrap_or(constants::RGBA4) } - pub fn mark_initialized(&self) { + pub(crate) fn mark_initialized(&self) { self.is_initialized.set(true); } - pub fn is_initialized(&self) -> bool { + pub(crate) fn is_initialized(&self) -> bool { self.is_initialized.get() } - pub fn bind(&self, target: u32) { + pub(crate) fn bind(&self, target: u32) { self.ever_bound.set(true); self.upcast::<WebGLObject>() .context() .send_command(WebGLCommand::BindRenderbuffer(target, Some(self.id))); } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); @@ -125,15 +125,15 @@ impl WebGLRenderbuffer { } } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.is_deleted.get() } - pub fn ever_bound(&self) -> bool { + pub(crate) fn ever_bound(&self) -> bool { self.ever_bound.get() } - pub fn storage( + pub(crate) fn storage( &self, api_type: GlType, sample_count: i32, @@ -270,11 +270,11 @@ impl WebGLRenderbuffer { Ok(()) } - pub fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) { + pub(crate) fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) { self.attached_framebuffer.set(Some(fb)); } - pub fn detach_from_framebuffer(&self) { + pub(crate) fn detach_from_framebuffer(&self) { self.attached_framebuffer.set(None); } } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 0d0c03a61a8..0b8e53f5961 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -117,7 +117,7 @@ fn has_invalid_blend_constants(arg1: u32, arg2: u32) -> bool { } } -pub fn uniform_get<T, F>(triple: (&WebGLRenderingContext, WebGLProgramId, i32), f: F) -> T +pub(crate) fn uniform_get<T, F>(triple: (&WebGLRenderingContext, WebGLProgramId, i32), f: F) -> T where F: FnOnce(WebGLProgramId, i32, WebGLSender<T>) -> WebGLCommand, T: for<'de> Deserialize<'de> + Serialize, @@ -128,7 +128,7 @@ where } #[allow(unsafe_code)] -pub unsafe fn uniform_typed<T>( +pub(crate) unsafe fn uniform_typed<T>( cx: *mut JSContext, value: &[T::Element], mut retval: MutableHandleValue, @@ -154,20 +154,20 @@ bitflags! { } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] -pub enum VertexAttrib { +pub(crate) enum VertexAttrib { Float(f32, f32, f32, f32), Int(i32, i32, i32, i32), Uint(u32, u32, u32, u32), } #[derive(Clone, Copy, Debug)] -pub enum Operation { +pub(crate) enum Operation { Fallible, Infallible, } #[dom_struct] -pub struct WebGLRenderingContext { +pub(crate) struct WebGLRenderingContext { reflector_: Reflector, #[ignore_malloc_size_of = "Channels are hard"] webgl_sender: WebGLMessageSender, @@ -215,7 +215,7 @@ pub struct WebGLRenderingContext { } impl WebGLRenderingContext { - pub fn new_inherited( + pub(crate) fn new_inherited( window: &Window, canvas: &HTMLCanvasElementOrOffscreenCanvas, webgl_version: WebGLVersion, @@ -282,7 +282,7 @@ impl WebGLRenderingContext { } #[allow(crown::unrooted_must_root)] - pub fn new( + pub(crate) fn new( window: &Window, canvas: &HTMLCanvasElementOrOffscreenCanvas, webgl_version: WebGLVersion, @@ -315,19 +315,19 @@ impl WebGLRenderingContext { } } - pub fn webgl_version(&self) -> WebGLVersion { + pub(crate) fn webgl_version(&self) -> WebGLVersion { self.webgl_version } - pub fn limits(&self) -> &GLLimits { + pub(crate) fn limits(&self) -> &GLLimits { &self.limits } - pub fn texture_unpacking_alignment(&self) -> u32 { + pub(crate) fn texture_unpacking_alignment(&self) -> u32 { self.texture_unpacking_alignment.get() } - pub fn current_vao(&self) -> DomRoot<WebGLVertexArrayObjectOES> { + pub(crate) fn current_vao(&self) -> DomRoot<WebGLVertexArrayObjectOES> { self.current_vao.or_init(|| { DomRoot::from_ref( self.default_vao @@ -336,7 +336,7 @@ impl WebGLRenderingContext { }) } - pub fn current_vao_webgl2(&self) -> DomRoot<WebGLVertexArrayObject> { + pub(crate) fn current_vao_webgl2(&self) -> DomRoot<WebGLVertexArrayObject> { self.current_vao_webgl2.or_init(|| { DomRoot::from_ref( self.default_vao_webgl2 @@ -345,11 +345,11 @@ impl WebGLRenderingContext { }) } - pub fn current_vertex_attribs(&self) -> RefMut<Box<[VertexAttrib]>> { + pub(crate) fn current_vertex_attribs(&self) -> RefMut<Box<[VertexAttrib]>> { self.current_vertex_attribs.borrow_mut() } - pub fn recreate(&self, size: Size2D<u32>) { + pub(crate) fn recreate(&self, size: Size2D<u32>) { let (sender, receiver) = webgl_channel().unwrap(); self.webgl_sender.send_resize(size, sender).unwrap(); // FIXME(#21718) The backend is allowed to choose a size smaller than @@ -398,11 +398,11 @@ impl WebGLRenderingContext { } } - pub fn context_id(&self) -> WebGLContextId { + pub(crate) fn context_id(&self) -> WebGLContextId { self.webgl_sender.context_id() } - pub fn onscreen(&self) -> bool { + pub(crate) fn onscreen(&self) -> bool { match self.canvas { HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(ref canvas) => { canvas.upcast::<Node>().is_connected() @@ -412,19 +412,19 @@ impl WebGLRenderingContext { } #[inline] - pub fn send_command(&self, command: WebGLCommand) { + pub(crate) fn send_command(&self, command: WebGLCommand) { self.webgl_sender .send(command, capture_webgl_backtrace(self)) .unwrap(); } - pub fn send_command_ignored(&self, command: WebGLCommand) { + pub(crate) fn send_command_ignored(&self, command: WebGLCommand) { let _ = self .webgl_sender .send(command, capture_webgl_backtrace(self)); } - pub fn webgl_error(&self, err: WebGLError) { + pub(crate) fn webgl_error(&self, err: WebGLError) { // TODO(emilio): Add useful debug messages to this warn!( "WebGL error: {:?}, previous error was {:?}", @@ -457,7 +457,7 @@ impl WebGLRenderingContext { // // The WebGL spec mentions a couple more operations that trigger // this: clear() and getParameter(IMPLEMENTATION_COLOR_READ_*). - pub fn validate_framebuffer(&self) -> WebGLResult<()> { + pub(crate) fn validate_framebuffer(&self) -> WebGLResult<()> { match self.bound_draw_framebuffer.get() { Some(fb) => match fb.check_status_for_rendering() { CompleteForRendering::Complete => Ok(()), @@ -468,7 +468,7 @@ impl WebGLRenderingContext { } } - pub fn validate_ownership<T>(&self, object: &T) -> WebGLResult<()> + pub(crate) fn validate_ownership<T>(&self, object: &T) -> WebGLResult<()> where T: DerivedFrom<WebGLObject>, { @@ -478,7 +478,7 @@ impl WebGLRenderingContext { Ok(()) } - pub fn with_location<F>(&self, location: Option<&WebGLUniformLocation>, f: F) + pub(crate) fn with_location<F>(&self, location: Option<&WebGLUniformLocation>, f: F) where F: FnOnce(&WebGLUniformLocation) -> WebGLResult<()>, { @@ -495,7 +495,7 @@ impl WebGLRenderingContext { handle_potential_webgl_error!(self, f(location)); } - pub fn textures(&self) -> &Textures { + pub(crate) fn textures(&self) -> &Textures { &self.textures } @@ -536,7 +536,7 @@ impl WebGLRenderingContext { } } - pub fn mark_as_dirty(&self) { + pub(crate) fn mark_as_dirty(&self) { // If we have a bound framebuffer, then don't mark the canvas as dirty. if self.bound_draw_framebuffer.get().is_some() { return; @@ -575,7 +575,7 @@ impl WebGLRenderingContext { self.send_command(WebGLCommand::VertexAttrib(indx, x, y, z, w)); } - pub fn get_current_framebuffer_size(&self) -> Option<(i32, i32)> { + pub(crate) fn get_current_framebuffer_size(&self) -> Option<(i32, i32)> { match self.bound_draw_framebuffer.get() { Some(fb) => fb.size(), @@ -584,7 +584,7 @@ impl WebGLRenderingContext { } } - pub fn get_texture_packing_alignment(&self) -> u8 { + pub(crate) fn get_texture_packing_alignment(&self) -> u8 { self.texture_packing_alignment.get() } @@ -653,7 +653,7 @@ impl WebGLRenderingContext { ) } - pub fn get_image_pixels(&self, source: TexImageSource) -> Fallible<Option<TexPixels>> { + pub(crate) fn get_image_pixels(&self, source: TexImageSource) -> Fallible<Option<TexPixels>> { Ok(Some(match source { TexImageSource::ImageData(image_data) => TexPixels::new( image_data.to_shared_memory(), @@ -730,7 +730,7 @@ impl WebGLRenderingContext { } // TODO(emilio): Move this logic to a validator. - pub fn validate_tex_image_2d_data( + pub(crate) fn validate_tex_image_2d_data( &self, width: u32, height: u32, @@ -776,7 +776,7 @@ impl WebGLRenderingContext { } #[allow(clippy::too_many_arguments)] - pub fn tex_image_2d( + pub(crate) fn tex_image_2d( &self, texture: &WebGLTexture, target: TexImageTarget, @@ -956,7 +956,7 @@ impl WebGLRenderingContext { } // https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/ - pub fn draw_arrays_instanced( + pub(crate) fn draw_arrays_instanced( &self, mode: u32, first: i32, @@ -1024,7 +1024,7 @@ impl WebGLRenderingContext { } // https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/ - pub fn draw_elements_instanced( + pub(crate) fn draw_elements_instanced( &self, mode: u32, count: i32, @@ -1117,7 +1117,7 @@ impl WebGLRenderingContext { Ok(()) } - pub fn vertex_attrib_divisor(&self, index: u32, divisor: u32) { + pub(crate) fn vertex_attrib_divisor(&self, index: u32, divisor: u32) { if index >= self.limits.max_vertex_attribs { return self.webgl_error(InvalidValue); } @@ -1137,7 +1137,7 @@ impl WebGLRenderingContext { // can fail and that it is UB what happens in that case. // // https://www.khronos.org/registry/webgl/specs/latest/1.0/#2.2 - pub fn get_image_data(&self, mut size: Size2D<u32>) -> Option<Vec<u8>> { + pub(crate) fn get_image_data(&self, mut size: Size2D<u32>) -> Option<Vec<u8>> { handle_potential_webgl_error!(self, self.validate_framebuffer(), return None); let (fb_width, fb_height) = handle_potential_webgl_error!( @@ -1158,15 +1158,15 @@ impl WebGLRenderingContext { Some(receiver.recv().unwrap()) } - pub fn array_buffer(&self) -> Option<DomRoot<WebGLBuffer>> { + pub(crate) fn array_buffer(&self) -> Option<DomRoot<WebGLBuffer>> { self.bound_buffer_array.get() } - pub fn array_buffer_slot(&self) -> &MutNullableDom<WebGLBuffer> { + pub(crate) fn array_buffer_slot(&self) -> &MutNullableDom<WebGLBuffer> { &self.bound_buffer_array } - pub fn bound_buffer(&self, target: u32) -> WebGLResult<Option<DomRoot<WebGLBuffer>>> { + pub(crate) fn bound_buffer(&self, target: u32) -> WebGLResult<Option<DomRoot<WebGLBuffer>>> { match target { constants::ARRAY_BUFFER => Ok(self.bound_buffer_array.get()), constants::ELEMENT_ARRAY_BUFFER => Ok(self.current_vao().element_array_buffer().get()), @@ -1174,14 +1174,14 @@ impl WebGLRenderingContext { } } - pub fn buffer_usage(&self, usage: u32) -> WebGLResult<u32> { + pub(crate) fn buffer_usage(&self, usage: u32) -> WebGLResult<u32> { match usage { constants::STREAM_DRAW | constants::STATIC_DRAW | constants::DYNAMIC_DRAW => Ok(usage), _ => Err(WebGLError::InvalidEnum), } } - pub fn create_vertex_array(&self) -> Option<DomRoot<WebGLVertexArrayObjectOES>> { + pub(crate) fn create_vertex_array(&self) -> Option<DomRoot<WebGLVertexArrayObjectOES>> { let (sender, receiver) = webgl_channel().unwrap(); self.send_command(WebGLCommand::CreateVertexArray(sender)); receiver @@ -1190,7 +1190,7 @@ impl WebGLRenderingContext { .map(|id| WebGLVertexArrayObjectOES::new(self, Some(id))) } - pub fn create_vertex_array_webgl2(&self) -> Option<DomRoot<WebGLVertexArrayObject>> { + pub(crate) fn create_vertex_array_webgl2(&self) -> Option<DomRoot<WebGLVertexArrayObject>> { let (sender, receiver) = webgl_channel().unwrap(); self.send_command(WebGLCommand::CreateVertexArray(sender)); receiver @@ -1199,7 +1199,7 @@ impl WebGLRenderingContext { .map(|id| WebGLVertexArrayObject::new(self, Some(id))) } - pub fn delete_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) { + pub(crate) fn delete_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) { if let Some(vao) = vao { handle_potential_webgl_error!(self, self.validate_ownership(vao), return); // The default vertex array has no id and should never be passed around. @@ -1217,7 +1217,7 @@ impl WebGLRenderingContext { } } - pub fn delete_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) { + pub(crate) fn delete_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) { if let Some(vao) = vao { handle_potential_webgl_error!(self, self.validate_ownership(vao), return); // The default vertex array has no id and should never be passed around. @@ -1235,7 +1235,7 @@ impl WebGLRenderingContext { } } - pub fn is_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) -> bool { + pub(crate) fn is_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) -> bool { vao.is_some_and(|vao| { // The default vertex array has no id and should never be passed around. assert!(vao.id().is_some()); @@ -1243,7 +1243,7 @@ impl WebGLRenderingContext { }) } - pub fn is_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) -> bool { + pub(crate) fn is_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) -> bool { vao.is_some_and(|vao| { // The default vertex array has no id and should never be passed around. assert!(vao.id().is_some()); @@ -1251,7 +1251,7 @@ impl WebGLRenderingContext { }) } - pub fn bind_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) { + pub(crate) fn bind_vertex_array(&self, vao: Option<&WebGLVertexArrayObjectOES>) { if let Some(vao) = vao { // The default vertex array has no id and should never be passed around. assert!(vao.id().is_some()); @@ -1267,7 +1267,7 @@ impl WebGLRenderingContext { self.current_vao.set(vao); } - pub fn bind_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) { + pub(crate) fn bind_vertex_array_webgl2(&self, vao: Option<&WebGLVertexArrayObject>) { if let Some(vao) = vao { // The default vertex array has no id and should never be passed around. assert!(vao.id().is_some()); @@ -1297,7 +1297,7 @@ impl WebGLRenderingContext { } } - pub fn initialize_framebuffer(&self, clear_bits: u32) { + pub(crate) fn initialize_framebuffer(&self, clear_bits: u32) { if clear_bits == 0 { return; } @@ -1308,12 +1308,12 @@ impl WebGLRenderingContext { }); } - pub fn extension_manager(&self) -> &WebGLExtensions { + pub(crate) fn extension_manager(&self) -> &WebGLExtensions { &self.extension_manager } #[allow(unsafe_code)] - pub fn buffer_data( + pub(crate) fn buffer_data( &self, target: u32, data: Option<ArrayBufferViewOrArrayBuffer>, @@ -1334,7 +1334,7 @@ impl WebGLRenderingContext { handle_potential_webgl_error!(self, bound_buffer.buffer_data(target, data, usage)); } - pub fn buffer_data_( + pub(crate) fn buffer_data_( &self, target: u32, size: i64, @@ -1355,7 +1355,7 @@ impl WebGLRenderingContext { } #[allow(unsafe_code)] - pub fn buffer_sub_data( + pub(crate) fn buffer_sub_data( &self, target: u32, offset: i64, @@ -1388,7 +1388,7 @@ impl WebGLRenderingContext { sender.send(data).unwrap(); } - pub fn bind_buffer_maybe( + pub(crate) fn bind_buffer_maybe( &self, slot: &MutNullableDom<WebGLBuffer>, target: u32, @@ -1412,11 +1412,11 @@ impl WebGLRenderingContext { slot.set(buffer); } - pub fn current_program(&self) -> Option<DomRoot<WebGLProgram>> { + pub(crate) fn current_program(&self) -> Option<DomRoot<WebGLProgram>> { self.current_program.get() } - pub fn uniform_check_program( + pub(crate) fn uniform_check_program( &self, program: &WebGLProgram, location: &WebGLUniformLocation, @@ -1465,7 +1465,7 @@ impl WebGLRenderingContext { self.uniform_vec_section::<f32>(vec, offset, length, uniform_size, uniform_location) } - pub fn uniform_vec_section<T: Clone>( + pub(crate) fn uniform_vec_section<T: Clone>( &self, vec: Vec<T>, offset: u32, @@ -1503,7 +1503,7 @@ impl WebGLRenderingContext { Ok(vec) } - pub fn uniform_matrix_section( + pub(crate) fn uniform_matrix_section( &self, vec: Float32ArrayOrUnrestrictedFloatSequence, offset: u32, @@ -1522,15 +1522,15 @@ impl WebGLRenderingContext { self.uniform_vec_section::<f32>(vec, offset, length, uniform_size, uniform_location) } - pub fn get_draw_framebuffer_slot(&self) -> &MutNullableDom<WebGLFramebuffer> { + pub(crate) fn get_draw_framebuffer_slot(&self) -> &MutNullableDom<WebGLFramebuffer> { &self.bound_draw_framebuffer } - pub fn get_read_framebuffer_slot(&self) -> &MutNullableDom<WebGLFramebuffer> { + pub(crate) fn get_read_framebuffer_slot(&self) -> &MutNullableDom<WebGLFramebuffer> { &self.bound_read_framebuffer } - pub fn validate_new_framebuffer_binding( + pub(crate) fn validate_new_framebuffer_binding( &self, framebuffer: Option<&WebGLFramebuffer>, ) -> WebGLResult<()> { @@ -1548,7 +1548,7 @@ impl WebGLRenderingContext { Ok(()) } - pub fn bind_framebuffer_to( + pub(crate) fn bind_framebuffer_to( &self, target: u32, framebuffer: Option<&WebGLFramebuffer>, @@ -1566,7 +1566,7 @@ impl WebGLRenderingContext { slot.set(framebuffer); } - pub fn renderbuffer_storage( + pub(crate) fn renderbuffer_storage( &self, target: u32, samples: i32, @@ -1600,13 +1600,13 @@ impl WebGLRenderingContext { // FIXME: https://github.com/servo/servo/issues/13710 } - pub fn valid_color_attachment_enum(&self, attachment: u32) -> bool { + pub(crate) fn valid_color_attachment_enum(&self, attachment: u32) -> bool { let last_slot = constants::COLOR_ATTACHMENT0 + self.limits().max_color_attachments - 1; constants::COLOR_ATTACHMENT0 <= attachment && attachment <= last_slot } #[allow(clippy::too_many_arguments)] - pub fn compressed_tex_image_2d( + pub(crate) fn compressed_tex_image_2d( &self, target: u32, level: i32, @@ -1674,7 +1674,7 @@ impl WebGLRenderingContext { } #[allow(clippy::too_many_arguments)] - pub fn compressed_tex_sub_image_2d( + pub(crate) fn compressed_tex_sub_image_2d( &self, target: u32, level: i32, @@ -1723,7 +1723,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform1iv( + pub(crate) fn uniform1iv( &self, location: Option<&WebGLUniformLocation>, val: Int32ArrayOrLongSequence, @@ -1759,7 +1759,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform1fv( + pub(crate) fn uniform1fv( &self, location: Option<&WebGLUniformLocation>, val: Float32ArrayOrUnrestrictedFloatSequence, @@ -1777,7 +1777,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform2fv( + pub(crate) fn uniform2fv( &self, location: Option<&WebGLUniformLocation>, val: Float32ArrayOrUnrestrictedFloatSequence, @@ -1795,7 +1795,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform2iv( + pub(crate) fn uniform2iv( &self, location: Option<&WebGLUniformLocation>, val: Int32ArrayOrLongSequence, @@ -1813,7 +1813,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform3fv( + pub(crate) fn uniform3fv( &self, location: Option<&WebGLUniformLocation>, val: Float32ArrayOrUnrestrictedFloatSequence, @@ -1831,7 +1831,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform3iv( + pub(crate) fn uniform3iv( &self, location: Option<&WebGLUniformLocation>, val: Int32ArrayOrLongSequence, @@ -1849,7 +1849,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform4iv( + pub(crate) fn uniform4iv( &self, location: Option<&WebGLUniformLocation>, val: Int32ArrayOrLongSequence, @@ -1867,7 +1867,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform4fv( + pub(crate) fn uniform4fv( &self, location: Option<&WebGLUniformLocation>, val: Float32ArrayOrUnrestrictedFloatSequence, @@ -1885,7 +1885,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform_matrix_2fv( + pub(crate) fn uniform_matrix_2fv( &self, location: Option<&WebGLUniformLocation>, transpose: bool, @@ -1905,7 +1905,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform_matrix_3fv( + pub(crate) fn uniform_matrix_3fv( &self, location: Option<&WebGLUniformLocation>, transpose: bool, @@ -1925,7 +1925,7 @@ impl WebGLRenderingContext { }); } - pub fn uniform_matrix_4fv( + pub(crate) fn uniform_matrix_4fv( &self, location: Option<&WebGLUniformLocation>, transpose: bool, @@ -1945,7 +1945,7 @@ impl WebGLRenderingContext { }); } - pub fn get_buffer_param( + pub(crate) fn get_buffer_param( &self, buffer: Option<DomRoot<WebGLBuffer>>, parameter: u32, @@ -1970,13 +1970,13 @@ impl WebGLRenderingContext { #[cfg(not(feature = "webgl_backtrace"))] #[inline] -pub fn capture_webgl_backtrace<T: DomObject>(_: &T) -> WebGLCommandBacktrace { +pub(crate) fn capture_webgl_backtrace<T: DomObject>(_: &T) -> WebGLCommandBacktrace { WebGLCommandBacktrace {} } #[cfg(feature = "webgl_backtrace")] #[cfg_attr(feature = "webgl_backtrace", allow(unsafe_code))] -pub fn capture_webgl_backtrace<T: DomObject>(obj: &T) -> WebGLCommandBacktrace { +pub(crate) fn capture_webgl_backtrace<T: DomObject>(obj: &T) -> WebGLCommandBacktrace { let bt = Backtrace::new(); unsafe { capture_stack!(in(*obj.global().get_cx()) let stack); @@ -4847,7 +4847,7 @@ macro_rules! capabilities { }; ($prev:ident, [$($name:ident = $value:expr;)*]) => { #[derive(Clone, Copy, JSTraceable, MallocSizeOf)] - pub struct CapFlags(u16); + pub(crate) struct CapFlags(u16); bitflags! { impl CapFlags: u16 { @@ -4880,7 +4880,7 @@ capabilities! { #[crown::unrooted_must_root_lint::must_root] #[derive(JSTraceable, MallocSizeOf)] -pub struct Textures { +pub(crate) struct Textures { active_unit: Cell<u32>, units: Box<[TextureUnit]>, } @@ -4896,7 +4896,7 @@ impl Textures { } } - pub fn active_unit_enum(&self) -> u32 { + pub(crate) fn active_unit_enum(&self) -> u32 { self.active_unit.get() + constants::TEXTURE0 } @@ -4909,7 +4909,7 @@ impl Textures { Ok(()) } - pub fn active_texture_slot( + pub(crate) fn active_texture_slot( &self, target: u32, webgl_version: WebGLVersion, @@ -4927,7 +4927,7 @@ impl Textures { } } - pub fn active_texture_for_image_target( + pub(crate) fn active_texture_for_image_target( &self, target: TexImageTarget, ) -> Option<DomRoot<WebGLTexture>> { @@ -4988,7 +4988,7 @@ impl TextureUnit { } } -pub struct TexPixels { +pub(crate) struct TexPixels { data: IpcSharedMemory, size: Size2D<u32>, pixel_format: Option<PixelFormat>, @@ -5010,7 +5010,7 @@ impl TexPixels { } } - pub fn from_array(data: IpcSharedMemory, size: Size2D<u32>) -> Self { + pub(crate) fn from_array(data: IpcSharedMemory, size: Size2D<u32>) -> Self { Self { data, size, @@ -5019,28 +5019,28 @@ impl TexPixels { } } - pub fn size(&self) -> Size2D<u32> { + pub(crate) fn size(&self) -> Size2D<u32> { self.size } } -pub enum TexSource { +pub(crate) enum TexSource { Pixels(TexPixels), BufferOffset(i64), } #[derive(JSTraceable)] -pub struct WebGLCommandSender { +pub(crate) struct WebGLCommandSender { #[no_trace] sender: WebGLChan, } impl WebGLCommandSender { - pub fn new(sender: WebGLChan) -> WebGLCommandSender { + pub(crate) fn new(sender: WebGLChan) -> WebGLCommandSender { WebGLCommandSender { sender } } - pub fn send(&self, msg: WebGLMsg) -> WebGLSendResult { + pub(crate) fn send(&self, msg: WebGLMsg) -> WebGLSendResult { self.sender.send(msg) } } @@ -5060,19 +5060,23 @@ impl Clone for WebGLMessageSender { } impl WebGLMessageSender { - pub fn new(sender: WebGLMsgSender) -> WebGLMessageSender { + pub(crate) fn new(sender: WebGLMsgSender) -> WebGLMessageSender { WebGLMessageSender { sender } } - pub fn context_id(&self) -> WebGLContextId { + pub(crate) fn context_id(&self) -> WebGLContextId { self.sender.context_id() } - pub fn send(&self, msg: WebGLCommand, backtrace: WebGLCommandBacktrace) -> WebGLSendResult { + pub(crate) fn send( + &self, + msg: WebGLCommand, + backtrace: WebGLCommandBacktrace, + ) -> WebGLSendResult { self.sender.send(msg, backtrace) } - pub fn send_resize( + pub(crate) fn send_resize( &self, size: Size2D<u32>, sender: WebGLSender<Result<(), String>>, @@ -5080,7 +5084,7 @@ impl WebGLMessageSender { self.sender.send_resize(size, sender) } - pub fn send_remove(&self) -> WebGLSendResult { + pub(crate) fn send_remove(&self) -> WebGLSendResult { self.sender.send_remove() } } diff --git a/components/script/dom/webglsampler.rs b/components/script/dom/webglsampler.rs index 65f636129cf..0b42f8cb523 100644 --- a/components/script/dom/webglsampler.rs +++ b/components/script/dom/webglsampler.rs @@ -17,7 +17,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLSampler { +pub(crate) struct WebGLSampler { webgl_object: WebGLObject, #[no_trace] gl_id: WebGLSamplerId, @@ -25,7 +25,7 @@ pub struct WebGLSampler { } #[derive(Clone, Copy)] -pub enum WebGLSamplerValue { +pub(crate) enum WebGLSamplerValue { Float(f32), GLenum(u32), } @@ -83,7 +83,7 @@ impl WebGLSampler { } } - pub fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::GenerateSampler(sender)); let id = receiver.recv().unwrap(); @@ -95,7 +95,7 @@ impl WebGLSampler { ) } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); @@ -108,11 +108,11 @@ impl WebGLSampler { } } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { !self.marked_for_deletion.get() } - pub fn bind( + pub(crate) fn bind( &self, context: &WebGLRenderingContext, unit: u32, @@ -124,7 +124,7 @@ impl WebGLSampler { Ok(()) } - pub fn set_parameter( + pub(crate) fn set_parameter( &self, context: &WebGLRenderingContext, pname: u32, @@ -148,7 +148,7 @@ impl WebGLSampler { Ok(()) } - pub fn get_parameter( + pub(crate) fn get_parameter( &self, context: &WebGLRenderingContext, pname: u32, diff --git a/components/script/dom/webglshader.rs b/components/script/dom/webglshader.rs index 76e0ccc1b2d..338eabc8338 100644 --- a/components/script/dom/webglshader.rs +++ b/components/script/dom/webglshader.rs @@ -28,14 +28,14 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ShaderCompilationStatus { +pub(crate) enum ShaderCompilationStatus { NotCompiled, Succeeded, Failed, } #[dom_struct] -pub struct WebGLShader { +pub(crate) struct WebGLShader { webgl_object: WebGLObject, #[no_trace] id: WebGLShaderId, @@ -64,7 +64,10 @@ impl WebGLShader { } } - pub fn maybe_new(context: &WebGLRenderingContext, shader_type: u32) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new( + context: &WebGLRenderingContext, + shader_type: u32, + ) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateShader(shader_type, sender)); receiver @@ -73,7 +76,7 @@ impl WebGLShader { .map(|id| WebGLShader::new(context, id, shader_type)) } - pub fn new( + pub(crate) fn new( context: &WebGLRenderingContext, id: WebGLShaderId, shader_type: u32, @@ -87,16 +90,16 @@ impl WebGLShader { } impl WebGLShader { - pub fn id(&self) -> WebGLShaderId { + pub(crate) fn id(&self) -> WebGLShaderId { self.id } - pub fn gl_type(&self) -> u32 { + pub(crate) fn gl_type(&self) -> u32 { self.gl_type } /// glCompileShader - pub fn compile( + pub(crate) fn compile( &self, api_type: GlType, webgl_version: WebGLVersion, @@ -229,7 +232,7 @@ impl WebGLShader { /// Mark this shader as deleted (if it wasn't previously) /// and delete it as if calling glDeleteShader. /// Currently does not check if shader is attached - pub fn mark_for_deletion(&self, operation_fallibility: Operation) { + pub(crate) fn mark_for_deletion(&self, operation_fallibility: Operation) { if !self.marked_for_deletion.get() { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -241,43 +244,43 @@ impl WebGLShader { } } - pub fn is_marked_for_deletion(&self) -> bool { + pub(crate) fn is_marked_for_deletion(&self) -> bool { self.marked_for_deletion.get() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.marked_for_deletion.get() && !self.is_attached() } - pub fn is_attached(&self) -> bool { + pub(crate) fn is_attached(&self) -> bool { self.attached_counter.get() > 0 } - pub fn increment_attached_counter(&self) { + pub(crate) fn increment_attached_counter(&self) { self.attached_counter.set(self.attached_counter.get() + 1); } - pub fn decrement_attached_counter(&self) { + pub(crate) fn decrement_attached_counter(&self) { assert!(self.attached_counter.get() > 0); self.attached_counter.set(self.attached_counter.get() - 1); } /// glGetShaderInfoLog - pub fn info_log(&self) -> DOMString { + pub(crate) fn info_log(&self) -> DOMString { self.info_log.borrow().clone() } /// Get the shader source - pub fn source(&self) -> DOMString { + pub(crate) fn source(&self) -> DOMString { self.source.borrow().clone() } /// glShaderSource - pub fn set_source(&self, source: DOMString) { + pub(crate) fn set_source(&self, source: DOMString) { *self.source.borrow_mut() = source; } - pub fn successfully_compiled(&self) -> bool { + pub(crate) fn successfully_compiled(&self) -> bool { self.compilation_status.get() == ShaderCompilationStatus::Succeeded } } diff --git a/components/script/dom/webglshaderprecisionformat.rs b/components/script/dom/webglshaderprecisionformat.rs index 1429b291057..2502c2f34a1 100644 --- a/components/script/dom/webglshaderprecisionformat.rs +++ b/components/script/dom/webglshaderprecisionformat.rs @@ -14,7 +14,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLShaderPrecisionFormat { +pub(crate) struct WebGLShaderPrecisionFormat { reflector_: Reflector, range_min: i32, range_max: i32, @@ -31,7 +31,7 @@ impl WebGLShaderPrecisionFormat { } } - pub fn new( + pub(crate) fn new( window: &Window, range_min: i32, range_max: i32, diff --git a/components/script/dom/webglsync.rs b/components/script/dom/webglsync.rs index 79b0ca9fd21..227fd350947 100644 --- a/components/script/dom/webglsync.rs +++ b/components/script/dom/webglsync.rs @@ -17,7 +17,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLSync { +pub(crate) struct WebGLSync { webgl_object: WebGLObject, #[no_trace] sync_id: WebGLSyncId, @@ -37,7 +37,7 @@ impl WebGLSync { } } - pub fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::FenceSync(sender)); let sync_id = receiver.recv().unwrap(); @@ -51,7 +51,7 @@ impl WebGLSync { } impl WebGLSync { - pub fn client_wait_sync( + pub(crate) fn client_wait_sync( &self, context: &WebGLRenderingContext, flags: u32, @@ -83,7 +83,7 @@ impl WebGLSync { self.client_wait_status.get() } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if self.is_valid() { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -95,7 +95,11 @@ impl WebGLSync { } } - pub fn get_sync_status(&self, pname: u32, context: &WebGLRenderingContext) -> Option<u32> { + pub(crate) fn get_sync_status( + &self, + pname: u32, + context: &WebGLRenderingContext, + ) -> Option<u32> { match self.sync_status.get() { Some(constants::UNSIGNALED) | None => { let this = Trusted::new(self); @@ -117,11 +121,11 @@ impl WebGLSync { self.sync_status.get() } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { !self.marked_for_deletion.get() } - pub fn id(&self) -> WebGLSyncId { + pub(crate) fn id(&self) -> WebGLSyncId { self.sync_id } } diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index 7e9c4c2e059..cd1d20a67fc 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -29,7 +29,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; -pub enum TexParameterValue { +pub(crate) enum TexParameterValue { Float(f32), Int(i32), Bool(bool), @@ -49,7 +49,7 @@ const MAX_LEVEL_COUNT: usize = 31; const MAX_FACE_COUNT: usize = 6; #[dom_struct] -pub struct WebGLTexture { +pub(crate) struct WebGLTexture { webgl_object: WebGLObject, #[no_trace] id: WebGLTextureId, @@ -99,7 +99,7 @@ impl WebGLTexture { } } - pub fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { + pub(crate) fn maybe_new(context: &WebGLRenderingContext) -> Option<DomRoot<Self>> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateTexture(sender)); receiver @@ -108,7 +108,7 @@ impl WebGLTexture { .map(|id| WebGLTexture::new(context, id)) } - pub fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext, id: WebGLTextureId) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLTexture::new_inherited( context, @@ -122,7 +122,7 @@ impl WebGLTexture { } #[cfg(feature = "webxr")] - pub fn new_webxr( + pub(crate) fn new_webxr( context: &WebGLRenderingContext, id: WebGLTextureId, session: &XRSession, @@ -136,12 +136,12 @@ impl WebGLTexture { } impl WebGLTexture { - pub fn id(&self) -> WebGLTextureId { + pub(crate) fn id(&self) -> WebGLTextureId { self.id } // NB: Only valid texture targets come here - pub fn bind(&self, target: u32) -> WebGLResult<()> { + pub(crate) fn bind(&self, target: u32) -> WebGLResult<()> { if self.is_invalid() { return Err(WebGLError::InvalidOperation); } @@ -169,7 +169,7 @@ impl WebGLTexture { } #[allow(clippy::too_many_arguments)] - pub fn initialize( + pub(crate) fn initialize( &self, target: TexImageTarget, width: u32, @@ -197,7 +197,7 @@ impl WebGLTexture { Ok(()) } - pub fn generate_mipmap(&self) -> WebGLResult<()> { + pub(crate) fn generate_mipmap(&self) -> WebGLResult<()> { let target = match self.target.get() { Some(target) => target, None => { @@ -233,7 +233,7 @@ impl WebGLTexture { self.populate_mip_chain(self.base_mipmap_level, last_level) } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if !self.is_deleted.get() { self.is_deleted.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -267,7 +267,7 @@ impl WebGLTexture { } } - pub fn is_invalid(&self) -> bool { + pub(crate) fn is_invalid(&self) -> bool { // https://immersive-web.github.io/layers/#xrwebglsubimagetype #[cfg(feature = "webxr")] if let WebGLTextureOwner::WebXR(ref session) = self.owner { @@ -278,15 +278,15 @@ impl WebGLTexture { self.is_deleted.get() } - pub fn is_immutable(&self) -> bool { + pub(crate) fn is_immutable(&self) -> bool { self.immutable_levels.get().is_some() } - pub fn target(&self) -> Option<u32> { + pub(crate) fn target(&self) -> Option<u32> { self.target.get() } - pub fn maybe_get_tex_parameter(&self, param: TexParameter) -> Option<TexParameterValue> { + pub(crate) fn maybe_get_tex_parameter(&self, param: TexParameter) -> Option<TexParameterValue> { match param { TexParameter::Int(TexParameterInt::TextureImmutableLevels) => Some( TexParameterValue::Int(self.immutable_levels.get().unwrap_or(0) as i32), @@ -300,7 +300,7 @@ impl WebGLTexture { /// We have to follow the conversion rules for GLES 2.0. See: /// <https://www.khronos.org/webgl/public-mailing-list/archives/1008/msg00014.html> - pub fn tex_parameter(&self, param: u32, value: TexParameterValue) -> WebGLResult<()> { + pub(crate) fn tex_parameter(&self, param: u32, value: TexParameterValue) -> WebGLResult<()> { let target = self.target().unwrap(); let (int_value, float_value) = match value { @@ -356,15 +356,15 @@ impl WebGLTexture { } } - pub fn min_filter(&self) -> u32 { + pub(crate) fn min_filter(&self) -> u32 { self.min_filter.get() } - pub fn mag_filter(&self) -> u32 { + pub(crate) fn mag_filter(&self) -> u32 { self.mag_filter.get() } - pub fn is_using_linear_filtering(&self) -> bool { + pub(crate) fn is_using_linear_filtering(&self) -> bool { let filters = [self.min_filter.get(), self.mag_filter.get()]; filters.iter().any(|filter| { matches!( @@ -377,7 +377,7 @@ impl WebGLTexture { }) } - pub fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> { + pub(crate) fn populate_mip_chain(&self, first_level: u32, last_level: u32) -> WebGLResult<()> { let base_image_info = self .image_info_at_face(0, first_level) .ok_or(WebGLError::InvalidOperation)?; @@ -451,12 +451,16 @@ impl WebGLTexture { } } - pub fn image_info_for_target(&self, target: &TexImageTarget, level: u32) -> Option<ImageInfo> { + pub(crate) fn image_info_for_target( + &self, + target: &TexImageTarget, + level: u32, + ) -> Option<ImageInfo> { let face_index = self.face_index_for_target(target); self.image_info_at_face(face_index, level) } - pub fn image_info_at_face(&self, face: u8, level: u32) -> Option<ImageInfo> { + pub(crate) fn image_info_at_face(&self, face: u8, level: u32) -> Option<ImageInfo> { let pos = (level * self.face_count.get() as u32) + face as u32; self.image_info_array.borrow()[pos as usize] } @@ -479,15 +483,15 @@ impl WebGLTexture { self.image_info_at_face(0, self.base_mipmap_level) } - pub fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) { + pub(crate) fn attach_to_framebuffer(&self, fb: &WebGLFramebuffer) { self.attached_framebuffer.set(Some(fb)); } - pub fn detach_from_framebuffer(&self) { + pub(crate) fn detach_from_framebuffer(&self) { self.attached_framebuffer.set(None); } - pub fn storage( + pub(crate) fn storage( &self, target: TexImageTarget, levels: u32, @@ -547,7 +551,7 @@ impl Drop for WebGLTexture { } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)] -pub struct ImageInfo { +pub(crate) struct ImageInfo { width: u32, height: u32, depth: u32, @@ -558,19 +562,19 @@ pub struct ImageInfo { } impl ImageInfo { - pub fn width(&self) -> u32 { + pub(crate) fn width(&self) -> u32 { self.width } - pub fn height(&self) -> u32 { + pub(crate) fn height(&self) -> u32 { self.height } - pub fn internal_format(&self) -> TexFormat { + pub(crate) fn internal_format(&self) -> TexFormat { self.internal_format } - pub fn data_type(&self) -> Option<TexDataType> { + pub(crate) fn data_type(&self) -> Option<TexDataType> { self.data_type } @@ -595,17 +599,17 @@ impl ImageInfo { } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] -pub enum TexCompressionValidation { +pub(crate) enum TexCompressionValidation { None, S3TC, } #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] -pub struct TexCompression { +pub(crate) struct TexCompression { #[no_trace] - pub format: TexFormat, - pub bytes_per_block: u8, - pub block_width: u8, - pub block_height: u8, - pub validation: TexCompressionValidation, + pub(crate) format: TexFormat, + pub(crate) bytes_per_block: u8, + pub(crate) block_width: u8, + pub(crate) block_height: u8, + pub(crate) validation: TexCompressionValidation, } diff --git a/components/script/dom/webgltransformfeedback.rs b/components/script/dom/webgltransformfeedback.rs index ecf7ca786f4..f8f7fa58251 100644 --- a/components/script/dom/webgltransformfeedback.rs +++ b/components/script/dom/webgltransformfeedback.rs @@ -15,7 +15,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLTransformFeedback { +pub(crate) struct WebGLTransformFeedback { webgl_object: WebGLObject, id: u32, marked_for_deletion: Cell<bool>, @@ -36,7 +36,7 @@ impl WebGLTransformFeedback { } } - pub fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { + pub(crate) fn new(context: &WebGLRenderingContext) -> DomRoot<Self> { let (sender, receiver) = webgl_channel().unwrap(); context.send_command(WebGLCommand::CreateTransformFeedback(sender)); let id = receiver.recv().unwrap(); @@ -50,19 +50,19 @@ impl WebGLTransformFeedback { } impl WebGLTransformFeedback { - pub fn bind(&self, context: &WebGLRenderingContext, target: u32) { + pub(crate) fn bind(&self, context: &WebGLRenderingContext, target: u32) { context.send_command(WebGLCommand::BindTransformFeedback(target, self.id())); self.has_been_bound.set(true); } - pub fn begin(&self, context: &WebGLRenderingContext, primitive_mode: u32) { + pub(crate) fn begin(&self, context: &WebGLRenderingContext, primitive_mode: u32) { if self.has_been_bound.get() && !self.is_active() { context.send_command(WebGLCommand::BeginTransformFeedback(primitive_mode)); self.set_active(true); } } - pub fn end(&self, context: &WebGLRenderingContext) { + pub(crate) fn end(&self, context: &WebGLRenderingContext) { if self.has_been_bound.get() && self.is_active() { if self.is_paused() { context.send_command(WebGLCommand::ResumeTransformFeedback()); @@ -72,37 +72,37 @@ impl WebGLTransformFeedback { } } - pub fn resume(&self, context: &WebGLRenderingContext) { + pub(crate) fn resume(&self, context: &WebGLRenderingContext) { if self.is_active() && self.is_paused() { context.send_command(WebGLCommand::ResumeTransformFeedback()); self.set_pause(false); } } - pub fn pause(&self, context: &WebGLRenderingContext) { + pub(crate) fn pause(&self, context: &WebGLRenderingContext) { if self.is_active() && !self.is_paused() { context.send_command(WebGLCommand::PauseTransformFeedback()); self.set_pause(true); } } - pub fn id(&self) -> u32 { + pub(crate) fn id(&self) -> u32 { self.id } - pub fn is_valid(&self) -> bool { + pub(crate) fn is_valid(&self) -> bool { !self.marked_for_deletion.get() } - pub fn is_active(&self) -> bool { + pub(crate) fn is_active(&self) -> bool { self.is_active.get() } - pub fn is_paused(&self) -> bool { + pub(crate) fn is_paused(&self) -> bool { self.is_paused.get() } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { if self.is_valid() && self.id() != 0 { self.marked_for_deletion.set(true); let context = self.upcast::<WebGLObject>().context(); @@ -114,13 +114,13 @@ impl WebGLTransformFeedback { } } - pub fn set_active(&self, value: bool) { + pub(crate) fn set_active(&self, value: bool) { if self.is_valid() && self.has_been_bound.get() { self.is_active.set(value); } } - pub fn set_pause(&self, value: bool) { + pub(crate) fn set_pause(&self, value: bool) { if self.is_valid() && self.is_active() { self.is_active.set(value); } diff --git a/components/script/dom/webgluniformlocation.rs b/components/script/dom/webgluniformlocation.rs index 5155225d917..b85a87c29bb 100644 --- a/components/script/dom/webgluniformlocation.rs +++ b/components/script/dom/webgluniformlocation.rs @@ -12,7 +12,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLUniformLocation { +pub(crate) struct WebGLUniformLocation { reflector_: Reflector, id: i32, #[no_trace] @@ -44,7 +44,7 @@ impl WebGLUniformLocation { } } - pub fn new( + pub(crate) fn new( window: &Window, id: i32, context_id: WebGLContextId, @@ -67,27 +67,27 @@ impl WebGLUniformLocation { ) } - pub fn id(&self) -> i32 { + pub(crate) fn id(&self) -> i32 { self.id } - pub fn program_id(&self) -> WebGLProgramId { + pub(crate) fn program_id(&self) -> WebGLProgramId { self.program_id } - pub fn context_id(&self) -> WebGLContextId { + pub(crate) fn context_id(&self) -> WebGLContextId { self.context_id } - pub fn link_generation(&self) -> u64 { + pub(crate) fn link_generation(&self) -> u64 { self.link_generation } - pub fn size(&self) -> Option<i32> { + pub(crate) fn size(&self) -> Option<i32> { self.size } - pub fn type_(&self) -> u32 { + pub(crate) fn type_(&self) -> u32 { self.type_ } } diff --git a/components/script/dom/webglvertexarrayobject.rs b/components/script/dom/webglvertexarrayobject.rs index 9b896132d28..c3598d3e4a9 100644 --- a/components/script/dom/webglvertexarrayobject.rs +++ b/components/script/dom/webglvertexarrayobject.rs @@ -15,7 +15,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLVertexArrayObject { +pub(crate) struct WebGLVertexArrayObject { webgl_object_: WebGLObject, array_object: VertexArrayObject, } @@ -28,7 +28,10 @@ impl WebGLVertexArrayObject { } } - pub fn new(context: &WebGLRenderingContext, id: Option<WebGLVertexArrayId>) -> DomRoot<Self> { + pub(crate) fn new( + context: &WebGLRenderingContext, + id: Option<WebGLVertexArrayId>, + ) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLVertexArrayObject::new_inherited(context, id)), &*context.global(), @@ -36,39 +39,39 @@ impl WebGLVertexArrayObject { ) } - pub fn id(&self) -> Option<WebGLVertexArrayId> { + pub(crate) fn id(&self) -> Option<WebGLVertexArrayId> { self.array_object.id() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.array_object.is_deleted() } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { self.array_object.delete(operation_fallibility); } - pub fn ever_bound(&self) -> bool { + pub(crate) fn ever_bound(&self) -> bool { self.array_object.ever_bound() } - pub fn set_ever_bound(&self) { + pub(crate) fn set_ever_bound(&self) { self.array_object.set_ever_bound(); } - pub fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { + pub(crate) fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { self.array_object.element_array_buffer() } - pub fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { + pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { self.array_object.get_vertex_attrib(index) } - pub fn set_vertex_attrib_type(&self, index: u32, type_: u32) { + pub(crate) fn set_vertex_attrib_type(&self, index: u32, type_: u32) { self.array_object.set_vertex_attrib_type(index, type_); } - pub fn vertex_attrib_pointer( + pub(crate) fn vertex_attrib_pointer( &self, index: u32, size: i32, @@ -81,19 +84,19 @@ impl WebGLVertexArrayObject { .vertex_attrib_pointer(index, size, type_, normalized, stride, offset) } - pub fn vertex_attrib_divisor(&self, index: u32, value: u32) { + pub(crate) fn vertex_attrib_divisor(&self, index: u32, value: u32) { self.array_object.vertex_attrib_divisor(index, value); } - pub fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { + pub(crate) fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { self.array_object.enabled_vertex_attrib_array(index, value); } - pub fn unbind_buffer(&self, buffer: &WebGLBuffer) { + pub(crate) fn unbind_buffer(&self, buffer: &WebGLBuffer) { self.array_object.unbind_buffer(buffer); } - pub fn validate_for_draw( + pub(crate) fn validate_for_draw( &self, required_len: u32, instance_count: u32, diff --git a/components/script/dom/webglvertexarrayobjectoes.rs b/components/script/dom/webglvertexarrayobjectoes.rs index d8e1555b997..e9c2eedfb2f 100644 --- a/components/script/dom/webglvertexarrayobjectoes.rs +++ b/components/script/dom/webglvertexarrayobjectoes.rs @@ -15,7 +15,7 @@ use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WebGLVertexArrayObjectOES { +pub(crate) struct WebGLVertexArrayObjectOES { webgl_object_: WebGLObject, array_object: VertexArrayObject, } @@ -28,7 +28,10 @@ impl WebGLVertexArrayObjectOES { } } - pub fn new(context: &WebGLRenderingContext, id: Option<WebGLVertexArrayId>) -> DomRoot<Self> { + pub(crate) fn new( + context: &WebGLRenderingContext, + id: Option<WebGLVertexArrayId>, + ) -> DomRoot<Self> { reflect_dom_object( Box::new(WebGLVertexArrayObjectOES::new_inherited(context, id)), &*context.global(), @@ -36,39 +39,39 @@ impl WebGLVertexArrayObjectOES { ) } - pub fn id(&self) -> Option<WebGLVertexArrayId> { + pub(crate) fn id(&self) -> Option<WebGLVertexArrayId> { self.array_object.id() } - pub fn is_deleted(&self) -> bool { + pub(crate) fn is_deleted(&self) -> bool { self.array_object.is_deleted() } - pub fn delete(&self, operation_fallibility: Operation) { + pub(crate) fn delete(&self, operation_fallibility: Operation) { self.array_object.delete(operation_fallibility); } - pub fn ever_bound(&self) -> bool { + pub(crate) fn ever_bound(&self) -> bool { self.array_object.ever_bound() } - pub fn set_ever_bound(&self) { + pub(crate) fn set_ever_bound(&self) { self.array_object.set_ever_bound(); } - pub fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { + pub(crate) fn element_array_buffer(&self) -> &MutNullableDom<WebGLBuffer> { self.array_object.element_array_buffer() } - pub fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { + pub(crate) fn get_vertex_attrib(&self, index: u32) -> Option<Ref<VertexAttribData>> { self.array_object.get_vertex_attrib(index) } - pub fn set_vertex_attrib_type(&self, index: u32, type_: u32) { + pub(crate) fn set_vertex_attrib_type(&self, index: u32, type_: u32) { self.array_object.set_vertex_attrib_type(index, type_); } - pub fn vertex_attrib_pointer( + pub(crate) fn vertex_attrib_pointer( &self, index: u32, size: i32, @@ -81,19 +84,19 @@ impl WebGLVertexArrayObjectOES { .vertex_attrib_pointer(index, size, type_, normalized, stride, offset) } - pub fn vertex_attrib_divisor(&self, index: u32, value: u32) { + pub(crate) fn vertex_attrib_divisor(&self, index: u32, value: u32) { self.array_object.vertex_attrib_divisor(index, value); } - pub fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { + pub(crate) fn enabled_vertex_attrib_array(&self, index: u32, value: bool) { self.array_object.enabled_vertex_attrib_array(index, value); } - pub fn unbind_buffer(&self, buffer: &WebGLBuffer) { + pub(crate) fn unbind_buffer(&self, buffer: &WebGLBuffer) { self.array_object.unbind_buffer(buffer); } - pub fn validate_for_draw( + pub(crate) fn validate_for_draw( &self, required_len: u32, instance_count: u32, diff --git a/components/script/dom/webgpu/gpu.rs b/components/script/dom/webgpu/gpu.rs index dd760229d58..5bb124b3ee7 100644 --- a/components/script/dom/webgpu/gpu.rs +++ b/components/script/dom/webgpu/gpu.rs @@ -28,23 +28,23 @@ use crate::script_runtime::CanGc; #[dom_struct] #[allow(clippy::upper_case_acronyms)] -pub struct GPU { +pub(crate) struct GPU { reflector_: Reflector, } impl GPU { - pub fn new_inherited() -> GPU { + pub(crate) fn new_inherited() -> GPU { GPU { reflector_: Reflector::new(), } } - pub fn new(global: &GlobalScope) -> DomRoot<GPU> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<GPU> { reflect_dom_object(Box::new(GPU::new_inherited()), global, CanGc::note()) } } -pub trait AsyncWGPUListener { +pub(crate) trait AsyncWGPUListener { fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, can_gc: CanGc); } @@ -63,7 +63,7 @@ impl<T: AsyncWGPUListener + DomObject> WGPUResponse<T> { } } -pub fn response_async<T: AsyncWGPUListener + DomObject + 'static>( +pub(crate) fn response_async<T: AsyncWGPUListener + DomObject + 'static>( promise: &Rc<Promise>, receiver: &T, ) -> IpcSender<WebGPUResponse> { diff --git a/components/script/dom/webgpu/gpuadapter.rs b/components/script/dom/webgpu/gpuadapter.rs index 409f701c635..80b2570f09a 100644 --- a/components/script/dom/webgpu/gpuadapter.rs +++ b/components/script/dom/webgpu/gpuadapter.rs @@ -29,7 +29,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUAdapter { +pub(crate) struct GPUAdapter { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -67,7 +67,7 @@ impl GPUAdapter { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, name: DOMString, diff --git a/components/script/dom/webgpu/gpuadapterinfo.rs b/components/script/dom/webgpu/gpuadapterinfo.rs index 8ce3dae97c6..ebf87ec7cff 100644 --- a/components/script/dom/webgpu/gpuadapterinfo.rs +++ b/components/script/dom/webgpu/gpuadapterinfo.rs @@ -8,12 +8,12 @@ use webgpu::wgt::AdapterInfo; use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUAdapterInfoMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::str::DOMString; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; -use crate::test::DOMString; #[dom_struct] -pub struct GPUAdapterInfo { +pub(crate) struct GPUAdapterInfo { reflector_: Reflector, #[ignore_malloc_size_of = "defined in wgpu-types"] #[no_trace] @@ -28,7 +28,7 @@ impl GPUAdapterInfo { } } - pub fn new(global: &GlobalScope, info: AdapterInfo) -> DomRoot<Self> { + pub(crate) fn new(global: &GlobalScope, info: AdapterInfo) -> DomRoot<Self> { reflect_dom_object(Box::new(Self::new_inherited(info)), global, CanGc::note()) } } diff --git a/components/script/dom/webgpu/gpubindgroup.rs b/components/script/dom/webgpu/gpubindgroup.rs index c542046ae27..2ece4cdbdde 100644 --- a/components/script/dom/webgpu/gpubindgroup.rs +++ b/components/script/dom/webgpu/gpubindgroup.rs @@ -22,7 +22,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUBindGroup { +pub(crate) struct GPUBindGroup { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -53,7 +53,7 @@ impl GPUBindGroup { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, bind_group: WebGPUBindGroup, @@ -72,12 +72,12 @@ impl GPUBindGroup { } impl GPUBindGroup { - pub fn id(&self) -> &WebGPUBindGroup { + pub(crate) fn id(&self) -> &WebGPUBindGroup { &self.bind_group } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbindgroup> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUBindGroupDescriptor, ) -> DomRoot<GPUBindGroup> { diff --git a/components/script/dom/webgpu/gpubindgrouplayout.rs b/components/script/dom/webgpu/gpubindgrouplayout.rs index 8c753a22499..5a8d68c96f9 100644 --- a/components/script/dom/webgpu/gpubindgrouplayout.rs +++ b/components/script/dom/webgpu/gpubindgrouplayout.rs @@ -23,7 +23,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUBindGroupLayout { +pub(crate) struct GPUBindGroupLayout { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -47,7 +47,7 @@ impl GPUBindGroupLayout { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, bind_group_layout: WebGPUBindGroupLayout, @@ -66,12 +66,12 @@ impl GPUBindGroupLayout { } impl GPUBindGroupLayout { - pub fn id(&self) -> WebGPUBindGroupLayout { + pub(crate) fn id(&self) -> WebGPUBindGroupLayout { self.bind_group_layout } /// <https://gpuweb.github.io/gpuweb/#GPUDevice-createBindGroupLayout> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUBindGroupLayoutDescriptor, ) -> Fallible<DomRoot<GPUBindGroupLayout>> { diff --git a/components/script/dom/webgpu/gpubuffer.rs b/components/script/dom/webgpu/gpubuffer.rs index e6e591cc392..c994ae60d4f 100644 --- a/components/script/dom/webgpu/gpubuffer.rs +++ b/components/script/dom/webgpu/gpubuffer.rs @@ -31,11 +31,11 @@ use crate::realms::InRealm; use crate::script_runtime::{CanGc, JSContext}; #[derive(JSTraceable, MallocSizeOf)] -pub struct ActiveBufferMapping { +pub(crate) struct ActiveBufferMapping { // TODO(sagudev): Use IpcSharedMemory when https://github.com/servo/ipc-channel/pull/356 lands /// <https://gpuweb.github.io/gpuweb/#active-buffer-mapping-data> /// <https://gpuweb.github.io/gpuweb/#active-buffer-mapping-views> - pub data: DataBlock, + pub(crate) data: DataBlock, /// <https://gpuweb.github.io/gpuweb/#active-buffer-mapping-mode> mode: GPUMapModeFlags, /// <https://gpuweb.github.io/gpuweb/#active-buffer-mapping-range> @@ -44,7 +44,7 @@ pub struct ActiveBufferMapping { impl ActiveBufferMapping { /// <https://gpuweb.github.io/gpuweb/#abstract-opdef-initialize-an-active-buffer-mapping> - pub fn new(mode: GPUMapModeFlags, range: Range<u64>) -> Fallible<Self> { + pub(crate) fn new(mode: GPUMapModeFlags, range: Range<u64>) -> Fallible<Self> { // Step 1 let size = range.end - range.start; // Step 2 @@ -63,7 +63,7 @@ impl ActiveBufferMapping { } #[dom_struct] -pub struct GPUBuffer { +pub(crate) struct GPUBuffer { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -107,7 +107,7 @@ impl GPUBuffer { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, buffer: WebGPUBuffer, @@ -128,12 +128,12 @@ impl GPUBuffer { } impl GPUBuffer { - pub fn id(&self) -> WebGPUBuffer { + pub(crate) fn id(&self) -> WebGPUBuffer { self.buffer } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUBufferDescriptor, ) -> Fallible<DomRoot<GPUBuffer>> { diff --git a/components/script/dom/webgpu/gpubufferusage.rs b/components/script/dom/webgpu/gpubufferusage.rs index b35768d25d5..3da27857b40 100644 --- a/components/script/dom/webgpu/gpubufferusage.rs +++ b/components/script/dom/webgpu/gpubufferusage.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::bindings::reflector::Reflector; #[dom_struct] -pub struct GPUBufferUsage { +pub(crate) struct GPUBufferUsage { reflector_: Reflector, } diff --git a/components/script/dom/webgpu/gpucanvascontext.rs b/components/script/dom/webgpu/gpucanvascontext.rs index cb6d7a2182a..51627071271 100644 --- a/components/script/dom/webgpu/gpucanvascontext.rs +++ b/components/script/dom/webgpu/gpucanvascontext.rs @@ -74,7 +74,7 @@ struct DrawingBuffer { } #[dom_struct] -pub struct GPUCanvasContext { +pub(crate) struct GPUCanvasContext { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -140,7 +140,11 @@ impl GPUCanvasContext { } } - pub fn new(global: &GlobalScope, canvas: &HTMLCanvasElement, channel: WebGPU) -> DomRoot<Self> { + pub(crate) fn new( + global: &GlobalScope, + canvas: &HTMLCanvasElement, + channel: WebGPU, + ) -> DomRoot<Self> { let document = canvas.owner_document(); let this = reflect_dom_object( Box::new(GPUCanvasContext::new_inherited( diff --git a/components/script/dom/webgpu/gpucolorwrite.rs b/components/script/dom/webgpu/gpucolorwrite.rs index 29e19826342..2c64fd11e68 100644 --- a/components/script/dom/webgpu/gpucolorwrite.rs +++ b/components/script/dom/webgpu/gpucolorwrite.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::bindings::reflector::Reflector; #[dom_struct] -pub struct GPUColorWrite { +pub(crate) struct GPUColorWrite { reflector_: Reflector, } diff --git a/components/script/dom/webgpu/gpucommandbuffer.rs b/components/script/dom/webgpu/gpucommandbuffer.rs index c6a6c9a934d..0ffc2ea7a0e 100644 --- a/components/script/dom/webgpu/gpucommandbuffer.rs +++ b/components/script/dom/webgpu/gpucommandbuffer.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUCommandBuffer { +pub(crate) struct GPUCommandBuffer { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -38,7 +38,7 @@ impl GPUCommandBuffer { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, command_buffer: WebGPUCommandBuffer, @@ -72,7 +72,7 @@ impl Drop for GPUCommandBuffer { } impl GPUCommandBuffer { - pub fn id(&self) -> WebGPUCommandBuffer { + pub(crate) fn id(&self) -> WebGPUCommandBuffer { self.command_buffer } } diff --git a/components/script/dom/webgpu/gpucommandencoder.rs b/components/script/dom/webgpu/gpucommandencoder.rs index 85b5e106ea9..c9fbf777c2e 100644 --- a/components/script/dom/webgpu/gpucommandencoder.rs +++ b/components/script/dom/webgpu/gpucommandencoder.rs @@ -30,7 +30,7 @@ use crate::dom::webgpu::gpurenderpassencoder::GPURenderPassEncoder; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUCommandEncoder { +pub(crate) struct GPUCommandEncoder { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -42,7 +42,7 @@ pub struct GPUCommandEncoder { } impl GPUCommandEncoder { - pub fn new_inherited( + pub(crate) fn new_inherited( channel: WebGPU, device: &GPUDevice, encoder: WebGPUCommandEncoder, @@ -57,7 +57,7 @@ impl GPUCommandEncoder { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, device: &GPUDevice, @@ -75,16 +75,16 @@ impl GPUCommandEncoder { } impl GPUCommandEncoder { - pub fn id(&self) -> WebGPUCommandEncoder { + pub(crate) fn id(&self) -> WebGPUCommandEncoder { self.encoder } - pub fn device_id(&self) -> WebGPUDevice { + pub(crate) fn device_id(&self) -> WebGPUDevice { self.device.id() } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createcommandencoder> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUCommandEncoderDescriptor, ) -> DomRoot<GPUCommandEncoder> { diff --git a/components/script/dom/webgpu/gpucompilationinfo.rs b/components/script/dom/webgpu/gpucompilationinfo.rs index 08751c03d57..288c3b1f7b8 100644 --- a/components/script/dom/webgpu/gpucompilationinfo.rs +++ b/components/script/dom/webgpu/gpucompilationinfo.rs @@ -15,14 +15,14 @@ use crate::dom::types::GPUCompilationMessage; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct GPUCompilationInfo { +pub(crate) struct GPUCompilationInfo { reflector_: Reflector, // currently we only get one message from wgpu msg: Vec<DomRoot<GPUCompilationMessage>>, } impl GPUCompilationInfo { - pub fn new_inherited(msg: Vec<DomRoot<GPUCompilationMessage>>) -> Self { + pub(crate) fn new_inherited(msg: Vec<DomRoot<GPUCompilationMessage>>) -> Self { Self { reflector_: Reflector::new(), msg, @@ -30,7 +30,7 @@ impl GPUCompilationInfo { } #[allow(dead_code)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, msg: Vec<DomRoot<GPUCompilationMessage>>, can_gc: CanGc, @@ -38,7 +38,7 @@ impl GPUCompilationInfo { reflect_dom_object_with_proto(Box::new(Self::new_inherited(msg)), global, None, can_gc) } - pub fn from( + pub(crate) fn from( global: &GlobalScope, error: Option<ShaderCompilationInfo>, can_gc: CanGc, diff --git a/components/script/dom/webgpu/gpucompilationmessage.rs b/components/script/dom/webgpu/gpucompilationmessage.rs index 157118d056d..13555c47eee 100644 --- a/components/script/dom/webgpu/gpucompilationmessage.rs +++ b/components/script/dom/webgpu/gpucompilationmessage.rs @@ -12,12 +12,12 @@ use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ }; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::str::DOMString; use crate::dom::types::GlobalScope; use crate::script_runtime::CanGc; -use crate::test::DOMString; #[dom_struct] -pub struct GPUCompilationMessage { +pub(crate) struct GPUCompilationMessage { reflector_: Reflector, // #[ignore_malloc_size_of = "defined in wgpu-types"] message: DOMString, @@ -48,7 +48,7 @@ impl GPUCompilationMessage { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, message: DOMString, mtype: GPUCompilationMessageType, @@ -66,7 +66,7 @@ impl GPUCompilationMessage { ) } - pub fn from(global: &GlobalScope, info: ShaderCompilationInfo) -> DomRoot<Self> { + pub(crate) fn from(global: &GlobalScope, info: ShaderCompilationInfo) -> DomRoot<Self> { GPUCompilationMessage::new( global, info.message.into(), diff --git a/components/script/dom/webgpu/gpucomputepassencoder.rs b/components/script/dom/webgpu/gpucomputepassencoder.rs index 1ad305fcecd..3ddb8afa018 100644 --- a/components/script/dom/webgpu/gpucomputepassencoder.rs +++ b/components/script/dom/webgpu/gpucomputepassencoder.rs @@ -18,7 +18,7 @@ use crate::dom::webgpu::gpucomputepipeline::GPUComputePipeline; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUComputePassEncoder { +pub(crate) struct GPUComputePassEncoder { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -45,7 +45,7 @@ impl GPUComputePassEncoder { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, parent: &GPUCommandEncoder, diff --git a/components/script/dom/webgpu/gpucomputepipeline.rs b/components/script/dom/webgpu/gpucomputepipeline.rs index 8a0cf4ab6e1..f1eaa2c8b0c 100644 --- a/components/script/dom/webgpu/gpucomputepipeline.rs +++ b/components/script/dom/webgpu/gpucomputepipeline.rs @@ -22,7 +22,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUComputePipeline { +pub(crate) struct GPUComputePipeline { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -48,7 +48,7 @@ impl GPUComputePipeline { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, compute_pipeline: WebGPUComputePipeline, label: USVString, @@ -67,12 +67,12 @@ impl GPUComputePipeline { } impl GPUComputePipeline { - pub fn id(&self) -> &WebGPUComputePipeline { + pub(crate) fn id(&self) -> &WebGPUComputePipeline { &self.compute_pipeline } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createcomputepipeline> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUComputePipelineDescriptor, async_sender: Option<IpcSender<WebGPUResponse>>, diff --git a/components/script/dom/webgpu/gpuconvert.rs b/components/script/dom/webgpu/gpuconvert.rs index 7f03c507e1b..d83d1e86dfa 100644 --- a/components/script/dom/webgpu/gpuconvert.rs +++ b/components/script/dom/webgpu/gpuconvert.rs @@ -506,7 +506,7 @@ impl<'a> Convert<Option<Cow<'a, str>>> for &GPUObjectDescriptorBase { } } -pub fn convert_bind_group_layout_entry( +pub(crate) fn convert_bind_group_layout_entry( bgle: &GPUBindGroupLayoutEntry, device: &GPUDevice, ) -> Fallible<Result<wgt::BindGroupLayoutEntry, webgpu::Error>> { @@ -581,7 +581,7 @@ pub fn convert_bind_group_layout_entry( })) } -pub fn convert_texture_descriptor( +pub(crate) fn convert_texture_descriptor( descriptor: &GPUTextureDescriptor, device: &GPUDevice, ) -> Fallible<(TextureDescriptor<'static>, wgt::Extent3d)> { diff --git a/components/script/dom/webgpu/gpudevice.rs b/components/script/dom/webgpu/gpudevice.rs index 217f6ff5826..d33142d9c11 100644 --- a/components/script/dom/webgpu/gpudevice.rs +++ b/components/script/dom/webgpu/gpudevice.rs @@ -65,7 +65,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUDevice { +pub(crate) struct GPUDevice { eventtarget: EventTarget, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -85,20 +85,20 @@ pub struct GPUDevice { valid: Cell<bool>, } -pub enum PipelineLayout { +pub(crate) enum PipelineLayout { Implicit(PipelineLayoutId, Vec<BindGroupLayoutId>), Explicit(PipelineLayoutId), } impl PipelineLayout { - pub fn explicit(&self) -> Option<PipelineLayoutId> { + pub(crate) fn explicit(&self) -> Option<PipelineLayoutId> { match self { PipelineLayout::Explicit(layout_id) => Some(*layout_id), _ => None, } } - pub fn implicit(self) -> Option<(PipelineLayoutId, Vec<BindGroupLayoutId>)> { + pub(crate) fn implicit(self) -> Option<(PipelineLayoutId, Vec<BindGroupLayoutId>)> { match self { PipelineLayout::Implicit(layout_id, bind_group_layout_ids) => { Some((layout_id, bind_group_layout_ids)) @@ -137,7 +137,7 @@ impl GPUDevice { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, adapter: &GPUAdapter, @@ -174,19 +174,19 @@ impl GPUDevice { } impl GPUDevice { - pub fn id(&self) -> webgpu::WebGPUDevice { + pub(crate) fn id(&self) -> webgpu::WebGPUDevice { self.device } - pub fn queue_id(&self) -> webgpu::WebGPUQueue { + pub(crate) fn queue_id(&self) -> webgpu::WebGPUQueue { self.default_queue.id() } - pub fn channel(&self) -> WebGPU { + pub(crate) fn channel(&self) -> WebGPU { self.channel.clone() } - pub fn dispatch_error(&self, error: webgpu::Error) { + pub(crate) fn dispatch_error(&self, error: webgpu::Error) { if let Err(e) = self.channel.0.send(WebGPURequest::DispatchError { device_id: self.device.0, error, @@ -195,7 +195,7 @@ impl GPUDevice { } } - pub fn fire_uncaptured_error(&self, error: webgpu::Error, can_gc: CanGc) { + pub(crate) fn fire_uncaptured_error(&self, error: webgpu::Error, can_gc: CanGc) { let error = GPUError::from_error(&self.global(), error, can_gc); let ev = GPUUncapturedErrorEvent::new( &self.global(), @@ -213,7 +213,7 @@ impl GPUDevice { /// /// Validates that the device suppports required features, /// and if so returns an ok containing wgpu's `TextureFormat` - pub fn validate_texture_format_required_features( + pub(crate) fn validate_texture_format_required_features( &self, format: &GPUTextureFormat, ) -> Fallible<TextureFormat> { @@ -231,11 +231,11 @@ impl GPUDevice { } } - pub fn is_lost(&self) -> bool { + pub(crate) fn is_lost(&self) -> bool { self.lost_promise.borrow().is_fulfilled() } - pub fn get_pipeline_layout_data( + pub(crate) fn get_pipeline_layout_data( &self, layout: &GPUPipelineLayoutOrGPUAutoLayoutMode, ) -> PipelineLayout { @@ -253,7 +253,7 @@ impl GPUDevice { } } - pub fn parse_render_pipeline<'a>( + pub(crate) fn parse_render_pipeline<'a>( &self, descriptor: &GPURenderPipelineDescriptor, ) -> Fallible<(PipelineLayout, RenderPipelineDescriptor<'a>)> { @@ -369,7 +369,7 @@ impl GPUDevice { } /// <https://gpuweb.github.io/gpuweb/#lose-the-device> - pub fn lose(&self, reason: GPUDeviceLostReason, msg: String) { + pub(crate) fn lose(&self, reason: GPUDeviceLostReason, msg: String) { let lost_promise = &(*self.lost_promise.borrow()); let global = &self.global(); let lost = GPUDeviceLostInfo::new(global, msg.into(), reason); diff --git a/components/script/dom/webgpu/gpudevicelostinfo.rs b/components/script/dom/webgpu/gpudevicelostinfo.rs index 68bb7278061..90a2d480fba 100644 --- a/components/script/dom/webgpu/gpudevicelostinfo.rs +++ b/components/script/dom/webgpu/gpudevicelostinfo.rs @@ -16,7 +16,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUDeviceLostInfo { +pub(crate) struct GPUDeviceLostInfo { reflector_: Reflector, message: DOMString, reason: GPUDeviceLostReason, @@ -31,7 +31,7 @@ impl GPUDeviceLostInfo { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, message: DOMString, reason: GPUDeviceLostReason, diff --git a/components/script/dom/webgpu/gpuerror.rs b/components/script/dom/webgpu/gpuerror.rs index bc349ed4377..5d403b89061 100644 --- a/components/script/dom/webgpu/gpuerror.rs +++ b/components/script/dom/webgpu/gpuerror.rs @@ -16,13 +16,13 @@ use crate::dom::types::{GPUInternalError, GPUOutOfMemoryError, GPUValidationErro use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUError { +pub(crate) struct GPUError { reflector_: Reflector, message: DOMString, } impl GPUError { - pub fn new_inherited(message: DOMString) -> Self { + pub(crate) fn new_inherited(message: DOMString) -> Self { Self { reflector_: Reflector::new(), message, @@ -30,12 +30,12 @@ impl GPUError { } #[allow(dead_code)] - pub fn new(global: &GlobalScope, message: DOMString, can_gc: CanGc) -> DomRoot<Self> { + pub(crate) fn new(global: &GlobalScope, message: DOMString, can_gc: CanGc) -> DomRoot<Self> { Self::new_with_proto(global, None, message, can_gc) } #[allow(dead_code)] - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, message: DOMString, @@ -49,7 +49,7 @@ impl GPUError { ) } - pub fn from_error(global: &GlobalScope, error: Error, can_gc: CanGc) -> DomRoot<Self> { + pub(crate) fn from_error(global: &GlobalScope, error: Error, can_gc: CanGc) -> DomRoot<Self> { match error { Error::Validation(msg) => DomRoot::upcast(GPUValidationError::new_with_proto( global, @@ -91,7 +91,7 @@ impl Convert<GPUErrorFilter> for ErrorFilter { } impl GPUErrorFilter { - pub fn as_webgpu(&self) -> ErrorFilter { + pub(crate) fn as_webgpu(&self) -> ErrorFilter { match self { GPUErrorFilter::Validation => ErrorFilter::Validation, GPUErrorFilter::Out_of_memory => ErrorFilter::OutOfMemory, diff --git a/components/script/dom/webgpu/gpuinternalerror.rs b/components/script/dom/webgpu/gpuinternalerror.rs index c622d4ff495..43f3e35dc0a 100644 --- a/components/script/dom/webgpu/gpuinternalerror.rs +++ b/components/script/dom/webgpu/gpuinternalerror.rs @@ -14,7 +14,7 @@ use crate::dom::types::GPUError; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUInternalError { +pub(crate) struct GPUInternalError { gpu_error: GPUError, } @@ -25,7 +25,7 @@ impl GPUInternalError { } } - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, message: DOMString, diff --git a/components/script/dom/webgpu/gpumapmode.rs b/components/script/dom/webgpu/gpumapmode.rs index 4db3455483d..c2c535ce371 100644 --- a/components/script/dom/webgpu/gpumapmode.rs +++ b/components/script/dom/webgpu/gpumapmode.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::bindings::reflector::Reflector; #[dom_struct] -pub struct GPUMapMode { +pub(crate) struct GPUMapMode { reflector_: Reflector, } diff --git a/components/script/dom/webgpu/gpuoutofmemoryerror.rs b/components/script/dom/webgpu/gpuoutofmemoryerror.rs index 01c77ef8185..92db6b080f3 100644 --- a/components/script/dom/webgpu/gpuoutofmemoryerror.rs +++ b/components/script/dom/webgpu/gpuoutofmemoryerror.rs @@ -14,7 +14,7 @@ use crate::dom::types::GPUError; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUOutOfMemoryError { +pub(crate) struct GPUOutOfMemoryError { gpu_error: GPUError, } @@ -25,7 +25,7 @@ impl GPUOutOfMemoryError { } } - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, message: DOMString, diff --git a/components/script/dom/webgpu/gpupipelineerror.rs b/components/script/dom/webgpu/gpupipelineerror.rs index ae2b57bc781..bb5dc8e3d3f 100644 --- a/components/script/dom/webgpu/gpupipelineerror.rs +++ b/components/script/dom/webgpu/gpupipelineerror.rs @@ -17,7 +17,7 @@ use crate::script_runtime::CanGc; /// <https://gpuweb.github.io/gpuweb/#gpupipelineerror> #[dom_struct] -pub struct GPUPipelineError { +pub(crate) struct GPUPipelineError { exception: DOMException, reason: GPUPipelineErrorReason, } @@ -30,7 +30,7 @@ impl GPUPipelineError { } } - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, message: DOMString, @@ -45,7 +45,7 @@ impl GPUPipelineError { ) } - pub fn new( + pub(crate) fn new( global: &GlobalScope, message: DOMString, reason: GPUPipelineErrorReason, diff --git a/components/script/dom/webgpu/gpupipelinelayout.rs b/components/script/dom/webgpu/gpupipelinelayout.rs index 33c5b1f72bb..87a593410c4 100644 --- a/components/script/dom/webgpu/gpupipelinelayout.rs +++ b/components/script/dom/webgpu/gpupipelinelayout.rs @@ -21,7 +21,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUPipelineLayout { +pub(crate) struct GPUPipelineLayout { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -49,7 +49,7 @@ impl GPUPipelineLayout { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, pipeline_layout: WebGPUPipelineLayout, @@ -70,16 +70,16 @@ impl GPUPipelineLayout { } impl GPUPipelineLayout { - pub fn id(&self) -> WebGPUPipelineLayout { + pub(crate) fn id(&self) -> WebGPUPipelineLayout { self.pipeline_layout } - pub fn bind_group_layouts(&self) -> Vec<WebGPUBindGroupLayout> { + pub(crate) fn bind_group_layouts(&self) -> Vec<WebGPUBindGroupLayout> { self.bind_group_layouts.clone() } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createpipelinelayout> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUPipelineLayoutDescriptor, ) -> DomRoot<GPUPipelineLayout> { diff --git a/components/script/dom/webgpu/gpuqueryset.rs b/components/script/dom/webgpu/gpuqueryset.rs index d2c3eb03336..37e1f86b1c2 100644 --- a/components/script/dom/webgpu/gpuqueryset.rs +++ b/components/script/dom/webgpu/gpuqueryset.rs @@ -11,7 +11,7 @@ use crate::dom::bindings::reflector::Reflector; use crate::dom::bindings::str::USVString; #[dom_struct] -pub struct GPUQuerySet { +pub(crate) struct GPUQuerySet { reflector_: Reflector, // #[ignore_malloc_size_of = "defined in wgpu-types"] } diff --git a/components/script/dom/webgpu/gpuqueue.rs b/components/script/dom/webgpu/gpuqueue.rs index cbba6a24cdb..fa11b972c26 100644 --- a/components/script/dom/webgpu/gpuqueue.rs +++ b/components/script/dom/webgpu/gpuqueue.rs @@ -27,7 +27,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUQueue { +pub(crate) struct GPUQueue { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -49,7 +49,7 @@ impl GPUQueue { } } - pub fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<Self> { + pub(crate) fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<Self> { reflect_dom_object( Box::new(GPUQueue::new_inherited(channel, queue)), global, @@ -59,11 +59,11 @@ impl GPUQueue { } impl GPUQueue { - pub fn set_device(&self, device: &GPUDevice) { + pub(crate) fn set_device(&self, device: &GPUDevice) { *self.device.borrow_mut() = Some(Dom::from_ref(device)); } - pub fn id(&self) -> WebGPUQueue { + pub(crate) fn id(&self) -> WebGPUQueue { self.queue } } diff --git a/components/script/dom/webgpu/gpurenderbundle.rs b/components/script/dom/webgpu/gpurenderbundle.rs index 85e38b6b49c..c87df7c06a2 100644 --- a/components/script/dom/webgpu/gpurenderbundle.rs +++ b/components/script/dom/webgpu/gpurenderbundle.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPURenderBundle { +pub(crate) struct GPURenderBundle { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -42,7 +42,7 @@ impl GPURenderBundle { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, render_bundle: WebGPURenderBundle, device: WebGPUDevice, @@ -63,7 +63,7 @@ impl GPURenderBundle { } impl GPURenderBundle { - pub fn id(&self) -> WebGPURenderBundle { + pub(crate) fn id(&self) -> WebGPURenderBundle { self.render_bundle } } diff --git a/components/script/dom/webgpu/gpurenderbundleencoder.rs b/components/script/dom/webgpu/gpurenderbundleencoder.rs index 11899083d63..d3f28bdb7c8 100644 --- a/components/script/dom/webgpu/gpurenderbundleencoder.rs +++ b/components/script/dom/webgpu/gpurenderbundleencoder.rs @@ -29,7 +29,7 @@ use crate::dom::webgpu::gpurenderpipeline::GPURenderPipeline; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPURenderBundleEncoder { +pub(crate) struct GPURenderBundleEncoder { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -57,7 +57,7 @@ impl GPURenderBundleEncoder { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, render_bundle_encoder: RenderBundleEncoder, device: &GPUDevice, @@ -79,7 +79,7 @@ impl GPURenderBundleEncoder { impl GPURenderBundleEncoder { /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createrenderbundleencoder> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPURenderBundleEncoderDescriptor, ) -> Fallible<DomRoot<GPURenderBundleEncoder>> { diff --git a/components/script/dom/webgpu/gpurenderpassencoder.rs b/components/script/dom/webgpu/gpurenderpassencoder.rs index 9ec0e5e83e8..c0e96dffea1 100644 --- a/components/script/dom/webgpu/gpurenderpassencoder.rs +++ b/components/script/dom/webgpu/gpurenderpassencoder.rs @@ -24,7 +24,7 @@ use crate::dom::webgpu::gpurenderpipeline::GPURenderPipeline; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPURenderPassEncoder { +pub(crate) struct GPURenderPassEncoder { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -51,7 +51,7 @@ impl GPURenderPassEncoder { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, render_pass: WebGPURenderPass, diff --git a/components/script/dom/webgpu/gpurenderpipeline.rs b/components/script/dom/webgpu/gpurenderpipeline.rs index 21230ff6899..439701b6b27 100644 --- a/components/script/dom/webgpu/gpurenderpipeline.rs +++ b/components/script/dom/webgpu/gpurenderpipeline.rs @@ -19,7 +19,7 @@ use crate::dom::webgpu::gpudevice::{GPUDevice, PipelineLayout}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPURenderPipeline { +pub(crate) struct GPURenderPipeline { reflector_: Reflector, #[ignore_malloc_size_of = "channels are hard"] #[no_trace] @@ -45,7 +45,7 @@ impl GPURenderPipeline { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, render_pipeline: WebGPURenderPipeline, label: USVString, @@ -64,12 +64,12 @@ impl GPURenderPipeline { } impl GPURenderPipeline { - pub fn id(&self) -> WebGPURenderPipeline { + pub(crate) fn id(&self) -> WebGPURenderPipeline { self.render_pipeline } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createrenderpipeline> - pub fn create( + pub(crate) fn create( device: &GPUDevice, pipeline_layout: PipelineLayout, descriptor: RenderPipelineDescriptor<'static>, diff --git a/components/script/dom/webgpu/gpusampler.rs b/components/script/dom/webgpu/gpusampler.rs index ec3562d0e52..8eeb0cb9f7b 100644 --- a/components/script/dom/webgpu/gpusampler.rs +++ b/components/script/dom/webgpu/gpusampler.rs @@ -19,7 +19,7 @@ use crate::dom::webgpu::gpudevice::GPUDevice; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUSampler { +pub(crate) struct GPUSampler { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -50,7 +50,7 @@ impl GPUSampler { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, device: WebGPUDevice, @@ -73,12 +73,15 @@ impl GPUSampler { } impl GPUSampler { - pub fn id(&self) -> WebGPUSampler { + pub(crate) fn id(&self) -> WebGPUSampler { self.sampler } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler> - pub fn create(device: &GPUDevice, descriptor: &GPUSamplerDescriptor) -> DomRoot<GPUSampler> { + pub(crate) fn create( + device: &GPUDevice, + descriptor: &GPUSamplerDescriptor, + ) -> DomRoot<GPUSampler> { let sampler_id = device.global().wgpu_id_hub().create_sampler_id(); let compare_enable = descriptor.compare.is_some(); let desc = SamplerDescriptor { diff --git a/components/script/dom/webgpu/gpushadermodule.rs b/components/script/dom/webgpu/gpushadermodule.rs index 9b353dd71c1..03f9653276a 100644 --- a/components/script/dom/webgpu/gpushadermodule.rs +++ b/components/script/dom/webgpu/gpushadermodule.rs @@ -25,7 +25,7 @@ use crate::realms::InRealm; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUShaderModule { +pub(crate) struct GPUShaderModule { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -53,7 +53,7 @@ impl GPUShaderModule { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, shader_module: WebGPUShaderModule, @@ -74,12 +74,12 @@ impl GPUShaderModule { } impl GPUShaderModule { - pub fn id(&self) -> WebGPUShaderModule { + pub(crate) fn id(&self) -> WebGPUShaderModule { self.shader_module } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createshadermodule> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: RootedTraceableBox<GPUShaderModuleDescriptor>, comp: InRealm, diff --git a/components/script/dom/webgpu/gpushaderstage.rs b/components/script/dom/webgpu/gpushaderstage.rs index 611ffb12283..aadf76ce297 100644 --- a/components/script/dom/webgpu/gpushaderstage.rs +++ b/components/script/dom/webgpu/gpushaderstage.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::bindings::reflector::Reflector; #[dom_struct] -pub struct GPUShaderStage { +pub(crate) struct GPUShaderStage { reflector_: Reflector, } diff --git a/components/script/dom/webgpu/gpusupportedfeatures.rs b/components/script/dom/webgpu/gpusupportedfeatures.rs index 8cc161e172c..a32ed75490d 100644 --- a/components/script/dom/webgpu/gpusupportedfeatures.rs +++ b/components/script/dom/webgpu/gpusupportedfeatures.rs @@ -22,7 +22,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUSupportedFeatures { +pub(crate) struct GPUSupportedFeatures { reflector: Reflector, // internal storage for features #[custom_trace] @@ -96,7 +96,7 @@ impl GPUSupportedFeatures { } #[allow(non_snake_case)] - pub fn Constructor( + pub(crate) fn Constructor( global: &GlobalScope, proto: Option<HandleObject>, features: Features, @@ -107,7 +107,7 @@ impl GPUSupportedFeatures { } impl GPUSupportedFeatures { - pub fn wgpu_features(&self) -> Features { + pub(crate) fn wgpu_features(&self) -> Features { self.features } } @@ -118,7 +118,7 @@ impl GPUSupportedFeaturesMethods<crate::DomTypeHolder> for GPUSupportedFeatures } } -pub fn gpu_to_wgt_feature(feature: GPUFeatureName) -> Option<Features> { +pub(crate) fn gpu_to_wgt_feature(feature: GPUFeatureName) -> Option<Features> { match feature { GPUFeatureName::Depth_clip_control => Some(Features::DEPTH_CLIP_CONTROL), GPUFeatureName::Depth32float_stencil8 => Some(Features::DEPTH32FLOAT_STENCIL8), diff --git a/components/script/dom/webgpu/gpusupportedlimits.rs b/components/script/dom/webgpu/gpusupportedlimits.rs index 8f25526eae1..6eaaa3de304 100644 --- a/components/script/dom/webgpu/gpusupportedlimits.rs +++ b/components/script/dom/webgpu/gpusupportedlimits.rs @@ -14,7 +14,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUSupportedLimits { +pub(crate) struct GPUSupportedLimits { reflector_: Reflector, #[ignore_malloc_size_of = "defined in wgpu-types"] #[no_trace] @@ -29,7 +29,7 @@ impl GPUSupportedLimits { } } - pub fn new(global: &GlobalScope, limits: Limits) -> DomRoot<Self> { + pub(crate) fn new(global: &GlobalScope, limits: Limits) -> DomRoot<Self> { reflect_dom_object(Box::new(Self::new_inherited(limits)), global, CanGc::note()) } } @@ -199,7 +199,7 @@ impl GPUSupportedLimitsMethods<crate::DomTypeHolder> for GPUSupportedLimits { } /// Returns false if unknown limit or other value error -pub fn set_limit(limits: &mut Limits, limit: &str, value: u64) -> bool { +pub(crate) fn set_limit(limits: &mut Limits, limit: &str, value: u64) -> bool { /// per spec defaults are lower bounds for values /// /// <https://www.w3.org/TR/webgpu/#limit-class-maximum> diff --git a/components/script/dom/webgpu/gputexture.rs b/components/script/dom/webgpu/gputexture.rs index a07537d73b1..b610c0f57b3 100644 --- a/components/script/dom/webgpu/gputexture.rs +++ b/components/script/dom/webgpu/gputexture.rs @@ -25,7 +25,7 @@ use crate::dom::webgpu::gputextureview::GPUTextureView; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUTexture { +pub(crate) struct GPUTexture { reflector_: Reflector, #[no_trace] texture: WebGPUTexture, @@ -74,7 +74,7 @@ impl GPUTexture { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, texture: WebGPUTexture, device: &GPUDevice, @@ -122,12 +122,12 @@ impl Drop for GPUTexture { } impl GPUTexture { - pub fn id(&self) -> WebGPUTexture { + pub(crate) fn id(&self) -> WebGPUTexture { self.texture } /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture> - pub fn create( + pub(crate) fn create( device: &GPUDevice, descriptor: &GPUTextureDescriptor, ) -> Fallible<DomRoot<GPUTexture>> { diff --git a/components/script/dom/webgpu/gputextureusage.rs b/components/script/dom/webgpu/gputextureusage.rs index f2d9645364b..8c77b49fe23 100644 --- a/components/script/dom/webgpu/gputextureusage.rs +++ b/components/script/dom/webgpu/gputextureusage.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::bindings::reflector::Reflector; #[dom_struct] -pub struct GPUTextureUsage { +pub(crate) struct GPUTextureUsage { reflector_: Reflector, } diff --git a/components/script/dom/webgpu/gputextureview.rs b/components/script/dom/webgpu/gputextureview.rs index f988eb1c41d..c358dcf3f8c 100644 --- a/components/script/dom/webgpu/gputextureview.rs +++ b/components/script/dom/webgpu/gputextureview.rs @@ -15,7 +15,7 @@ use crate::dom::webgpu::gputexture::GPUTexture; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUTextureView { +pub(crate) struct GPUTextureView { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webgpu"] #[no_trace] @@ -42,7 +42,7 @@ impl GPUTextureView { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, channel: WebGPU, texture_view: WebGPUTextureView, @@ -63,7 +63,7 @@ impl GPUTextureView { } impl GPUTextureView { - pub fn id(&self) -> WebGPUTextureView { + pub(crate) fn id(&self) -> WebGPUTextureView { self.texture_view } } diff --git a/components/script/dom/webgpu/gpuuncapturederrorevent.rs b/components/script/dom/webgpu/gpuuncapturederrorevent.rs index 2e53e62bbd4..bae6948bce3 100644 --- a/components/script/dom/webgpu/gpuuncapturederrorevent.rs +++ b/components/script/dom/webgpu/gpuuncapturederrorevent.rs @@ -19,7 +19,7 @@ use crate::dom::webgpu::gpuerror::GPUError; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUUncapturedErrorEvent { +pub(crate) struct GPUUncapturedErrorEvent { event: Event, #[ignore_malloc_size_of = "Because it is non-owning"] gpu_error: Dom<GPUError>, @@ -33,7 +33,7 @@ impl GPUUncapturedErrorEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: DOMString, init: &GPUUncapturedErrorEventInit, @@ -63,7 +63,7 @@ impl GPUUncapturedErrorEvent { ev } - pub fn event(&self) -> &Event { + pub(crate) fn event(&self) -> &Event { &self.event } } diff --git a/components/script/dom/webgpu/gpuvalidationerror.rs b/components/script/dom/webgpu/gpuvalidationerror.rs index 0b20375e728..685aa2fb725 100644 --- a/components/script/dom/webgpu/gpuvalidationerror.rs +++ b/components/script/dom/webgpu/gpuvalidationerror.rs @@ -14,7 +14,7 @@ use crate::dom::types::GPUError; use crate::script_runtime::CanGc; #[dom_struct] -pub struct GPUValidationError { +pub(crate) struct GPUValidationError { gpu_error: GPUError, } @@ -25,7 +25,7 @@ impl GPUValidationError { } } - pub fn new_with_proto( + pub(crate) fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, message: DOMString, diff --git a/components/script/dom/webgpu/identityhub.rs b/components/script/dom/webgpu/identityhub.rs index c98618e97f0..102699c033e 100644 --- a/components/script/dom/webgpu/identityhub.rs +++ b/components/script/dom/webgpu/identityhub.rs @@ -16,7 +16,7 @@ use webgpu::wgc::id::{ use webgpu::wgc::identity::IdentityManager; #[derive(Debug)] -pub struct IdentityHub { +pub(crate) struct IdentityHub { adapters: IdentityManager<Adapter>, devices: IdentityManager<Device>, queues: IdentityManager<Queue>, @@ -61,139 +61,139 @@ impl Default for IdentityHub { } impl IdentityHub { - pub fn create_device_id(&self) -> DeviceId { + pub(crate) fn create_device_id(&self) -> DeviceId { self.devices.process() } - pub fn free_device_id(&self, id: DeviceId) { + pub(crate) fn free_device_id(&self, id: DeviceId) { self.devices.free(id); } - pub fn create_queue_id(&self) -> QueueId { + pub(crate) fn create_queue_id(&self) -> QueueId { self.queues.process() } - pub fn free_queue_id(&self, id: QueueId) { + pub(crate) fn free_queue_id(&self, id: QueueId) { self.queues.free(id); } - pub fn create_adapter_id(&self) -> AdapterId { + pub(crate) fn create_adapter_id(&self) -> AdapterId { self.adapters.process() } - pub fn free_adapter_id(&self, id: AdapterId) { + pub(crate) fn free_adapter_id(&self, id: AdapterId) { self.adapters.free(id); } - pub fn create_buffer_id(&self) -> BufferId { + pub(crate) fn create_buffer_id(&self) -> BufferId { self.buffers.process() } - pub fn free_buffer_id(&self, id: BufferId) { + pub(crate) fn free_buffer_id(&self, id: BufferId) { self.buffers.free(id); } - pub fn create_bind_group_id(&self) -> BindGroupId { + pub(crate) fn create_bind_group_id(&self) -> BindGroupId { self.bind_groups.process() } - pub fn free_bind_group_id(&self, id: BindGroupId) { + pub(crate) fn free_bind_group_id(&self, id: BindGroupId) { self.bind_groups.free(id); } - pub fn create_bind_group_layout_id(&self) -> BindGroupLayoutId { + pub(crate) fn create_bind_group_layout_id(&self) -> BindGroupLayoutId { self.bind_group_layouts.process() } - pub fn free_bind_group_layout_id(&self, id: BindGroupLayoutId) { + pub(crate) fn free_bind_group_layout_id(&self, id: BindGroupLayoutId) { self.bind_group_layouts.free(id); } - pub fn create_compute_pipeline_id(&self) -> ComputePipelineId { + pub(crate) fn create_compute_pipeline_id(&self) -> ComputePipelineId { self.compute_pipelines.process() } - pub fn free_compute_pipeline_id(&self, id: ComputePipelineId) { + pub(crate) fn free_compute_pipeline_id(&self, id: ComputePipelineId) { self.compute_pipelines.free(id); } - pub fn create_pipeline_layout_id(&self) -> PipelineLayoutId { + pub(crate) fn create_pipeline_layout_id(&self) -> PipelineLayoutId { self.pipeline_layouts.process() } - pub fn free_pipeline_layout_id(&self, id: PipelineLayoutId) { + pub(crate) fn free_pipeline_layout_id(&self, id: PipelineLayoutId) { self.pipeline_layouts.free(id); } - pub fn create_shader_module_id(&self) -> ShaderModuleId { + pub(crate) fn create_shader_module_id(&self) -> ShaderModuleId { self.shader_modules.process() } - pub fn free_shader_module_id(&self, id: ShaderModuleId) { + pub(crate) fn free_shader_module_id(&self, id: ShaderModuleId) { self.shader_modules.free(id); } - pub fn create_command_encoder_id(&self) -> CommandEncoderId { + pub(crate) fn create_command_encoder_id(&self) -> CommandEncoderId { self.command_encoders.process() } - pub fn free_command_buffer_id(&self, id: CommandEncoderId) { + pub(crate) fn free_command_buffer_id(&self, id: CommandEncoderId) { self.command_encoders.free(id); } - pub fn create_sampler_id(&self) -> SamplerId { + pub(crate) fn create_sampler_id(&self) -> SamplerId { self.samplers.process() } - pub fn free_sampler_id(&self, id: SamplerId) { + pub(crate) fn free_sampler_id(&self, id: SamplerId) { self.samplers.free(id); } - pub fn create_render_pipeline_id(&self) -> RenderPipelineId { + pub(crate) fn create_render_pipeline_id(&self) -> RenderPipelineId { self.render_pipelines.process() } - pub fn free_render_pipeline_id(&self, id: RenderPipelineId) { + pub(crate) fn free_render_pipeline_id(&self, id: RenderPipelineId) { self.render_pipelines.free(id); } - pub fn create_texture_id(&self) -> TextureId { + pub(crate) fn create_texture_id(&self) -> TextureId { self.textures.process() } - pub fn free_texture_id(&self, id: TextureId) { + pub(crate) fn free_texture_id(&self, id: TextureId) { self.textures.free(id); } - pub fn create_texture_view_id(&self) -> TextureViewId { + pub(crate) fn create_texture_view_id(&self) -> TextureViewId { self.texture_views.process() } - pub fn free_texture_view_id(&self, id: TextureViewId) { + pub(crate) fn free_texture_view_id(&self, id: TextureViewId) { self.texture_views.free(id); } - pub fn create_render_bundle_id(&self) -> RenderBundleId { + pub(crate) fn create_render_bundle_id(&self) -> RenderBundleId { self.render_bundles.process() } - pub fn free_render_bundle_id(&self, id: RenderBundleId) { + pub(crate) fn free_render_bundle_id(&self, id: RenderBundleId) { self.render_bundles.free(id); } - pub fn create_compute_pass_id(&self) -> ComputePassId { + pub(crate) fn create_compute_pass_id(&self) -> ComputePassId { self.compute_passes.process() } - pub fn free_compute_pass_id(&self, id: ComputePassId) { + pub(crate) fn free_compute_pass_id(&self, id: ComputePassId) { self.compute_passes.free(id); } - pub fn create_render_pass_id(&self) -> RenderPassId { + pub(crate) fn create_render_pass_id(&self) -> RenderPassId { self.render_passes.process() } - pub fn free_render_pass_id(&self, id: RenderPassId) { + pub(crate) fn free_render_pass_id(&self, id: RenderPassId) { self.render_passes.free(id); } } diff --git a/components/script/dom/webgpu/mod.rs b/components/script/dom/webgpu/mod.rs index 2b06224c6fb..ac14d1eb3ae 100644 --- a/components/script/dom/webgpu/mod.rs +++ b/components/script/dom/webgpu/mod.rs @@ -2,44 +2,46 @@ * 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/. */ -pub mod gpu; -pub mod gpuadapter; -pub mod gpuadapterinfo; -pub mod gpubindgroup; -pub mod gpubindgrouplayout; -pub mod gpubuffer; -pub mod gpubufferusage; -pub mod gpucanvascontext; -pub mod gpucolorwrite; -pub mod gpucommandbuffer; -pub mod gpucommandencoder; -pub mod gpucompilationinfo; -pub mod gpucompilationmessage; -pub mod gpucomputepassencoder; -pub mod gpucomputepipeline; -pub mod gpuconvert; -pub mod gpudevice; -pub mod gpudevicelostinfo; -pub mod gpuerror; -pub mod gpuinternalerror; -pub mod gpumapmode; -pub mod gpuoutofmemoryerror; -pub mod gpupipelineerror; -pub mod gpupipelinelayout; -pub mod gpuqueryset; -pub mod gpuqueue; -pub mod gpurenderbundle; -pub mod gpurenderbundleencoder; -pub mod gpurenderpassencoder; -pub mod gpurenderpipeline; -pub mod gpusampler; -pub mod gpushadermodule; -pub mod gpushaderstage; -pub mod gpusupportedfeatures; -pub mod gpusupportedlimits; -pub mod gputexture; -pub mod gputextureusage; -pub mod gputextureview; -pub mod gpuuncapturederrorevent; -pub mod gpuvalidationerror; -pub mod identityhub; +pub(crate) mod gpu; +pub(crate) mod gpuadapter; +pub(crate) mod gpuadapterinfo; +pub(crate) mod gpubindgroup; +pub(crate) mod gpubindgrouplayout; +pub(crate) mod gpubuffer; +pub(crate) mod gpubufferusage; +pub(crate) mod gpucanvascontext; +pub(crate) mod gpucolorwrite; +pub(crate) mod gpucommandbuffer; +pub(crate) mod gpucommandencoder; +pub(crate) mod gpucompilationinfo; +pub(crate) mod gpucompilationmessage; +pub(crate) mod gpucomputepassencoder; +pub(crate) mod gpucomputepipeline; +pub(crate) mod gpuconvert; +pub(crate) mod gpudevice; +pub(crate) mod gpudevicelostinfo; +pub(crate) mod gpuerror; +pub(crate) mod gpuinternalerror; +pub(crate) mod gpumapmode; +pub(crate) mod gpuoutofmemoryerror; +pub(crate) mod gpupipelineerror; +#[allow(dead_code)] +pub(crate) mod gpupipelinelayout; +pub(crate) mod gpuqueryset; +pub(crate) mod gpuqueue; +pub(crate) mod gpurenderbundle; +pub(crate) mod gpurenderbundleencoder; +pub(crate) mod gpurenderpassencoder; +pub(crate) mod gpurenderpipeline; +pub(crate) mod gpusampler; +pub(crate) mod gpushadermodule; +pub(crate) mod gpushaderstage; +pub(crate) mod gpusupportedfeatures; +pub(crate) mod gpusupportedlimits; +pub(crate) mod gputexture; +pub(crate) mod gputextureusage; +pub(crate) mod gputextureview; +pub(crate) mod gpuuncapturederrorevent; +pub(crate) mod gpuvalidationerror; +#[allow(dead_code)] +pub(crate) mod identityhub; diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index fa69d70e07a..ab4303bf863 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -54,18 +54,18 @@ enum WebSocketRequestState { // Names are from https://github.com/mozilla/gecko-dev/blob/master/netwerk/protocol/websocket/nsIWebSocketChannel.idl #[allow(dead_code)] mod close_code { - pub const NORMAL: u16 = 1000; - pub const GOING_AWAY: u16 = 1001; - pub const PROTOCOL_ERROR: u16 = 1002; - pub const UNSUPPORTED_DATATYPE: u16 = 1003; - pub const NO_STATUS: u16 = 1005; - pub const ABNORMAL: u16 = 1006; - pub const INVALID_PAYLOAD: u16 = 1007; - pub const POLICY_VIOLATION: u16 = 1008; - pub const TOO_LARGE: u16 = 1009; - pub const EXTENSION_MISSING: u16 = 1010; - pub const INTERNAL_ERROR: u16 = 1011; - pub const TLS_FAILED: u16 = 1015; + pub(crate) const NORMAL: u16 = 1000; + pub(crate) const GOING_AWAY: u16 = 1001; + pub(crate) const PROTOCOL_ERROR: u16 = 1002; + pub(crate) const UNSUPPORTED_DATATYPE: u16 = 1003; + pub(crate) const NO_STATUS: u16 = 1005; + pub(crate) const ABNORMAL: u16 = 1006; + pub(crate) const INVALID_PAYLOAD: u16 = 1007; + pub(crate) const POLICY_VIOLATION: u16 = 1008; + pub(crate) const TOO_LARGE: u16 = 1009; + pub(crate) const EXTENSION_MISSING: u16 = 1010; + pub(crate) const INTERNAL_ERROR: u16 = 1011; + pub(crate) const TLS_FAILED: u16 = 1015; } fn close_the_websocket_connection( @@ -92,7 +92,7 @@ fn fail_the_websocket_connection(address: Trusted<WebSocket>, task_source: &Send } #[dom_struct] -pub struct WebSocket { +pub(crate) struct WebSocket { eventtarget: EventTarget, #[no_trace] url: ServoUrl, @@ -169,7 +169,7 @@ impl WebSocket { Ok(true) } - pub fn origin(&self) -> ImmutableOrigin { + pub(crate) fn origin(&self) -> ImmutableOrigin { self.url.origin() } } diff --git a/components/script/dom/webxr/fakexrdevice.rs b/components/script/dom/webxr/fakexrdevice.rs index 2910ed13490..a954e5ec0f4 100644 --- a/components/script/dom/webxr/fakexrdevice.rs +++ b/components/script/dom/webxr/fakexrdevice.rs @@ -37,7 +37,7 @@ use crate::dom::promise::Promise; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FakeXRDevice { +pub(crate) struct FakeXRDevice { reflector: Reflector, #[ignore_malloc_size_of = "defined in ipc-channel"] #[no_trace] @@ -48,7 +48,7 @@ pub struct FakeXRDevice { } impl FakeXRDevice { - pub fn new_inherited(sender: IpcSender<MockDeviceMsg>) -> FakeXRDevice { + pub(crate) fn new_inherited(sender: IpcSender<MockDeviceMsg>) -> FakeXRDevice { FakeXRDevice { reflector: Reflector::new(), sender, @@ -56,7 +56,10 @@ impl FakeXRDevice { } } - pub fn new(global: &GlobalScope, sender: IpcSender<MockDeviceMsg>) -> DomRoot<FakeXRDevice> { + pub(crate) fn new( + global: &GlobalScope, + sender: IpcSender<MockDeviceMsg>, + ) -> DomRoot<FakeXRDevice> { reflect_dom_object( Box::new(FakeXRDevice::new_inherited(sender)), global, @@ -64,12 +67,12 @@ impl FakeXRDevice { ) } - pub fn disconnect(&self, sender: IpcSender<()>) { + pub(crate) fn disconnect(&self, sender: IpcSender<()>) { let _ = self.sender.send(MockDeviceMsg::Disconnect(sender)); } } -pub fn view<Eye>(view: &FakeXRViewInit) -> Fallible<MockViewInit<Eye>> { +pub(crate) fn view<Eye>(view: &FakeXRViewInit) -> Fallible<MockViewInit<Eye>> { if view.projectionMatrix.len() != 16 || view.viewOffset.position.len() != 3 { return Err(Error::Type("Incorrectly sized array".into())); } @@ -106,7 +109,7 @@ pub fn view<Eye>(view: &FakeXRViewInit) -> Fallible<MockViewInit<Eye>> { }) } -pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<MockViewsInit> { +pub(crate) fn get_views(views: &[FakeXRViewInit]) -> Fallible<MockViewsInit> { match views.len() { 1 => Ok(MockViewsInit::Mono(view(&views[0])?)), 2 => { @@ -121,7 +124,7 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<MockViewsInit> { } } -pub fn get_origin<T, U>( +pub(crate) fn get_origin<T, U>( origin: &FakeXRRigidTransformInit, ) -> Fallible<RigidTransform3D<f32, T, U>> { if origin.position.len() != 3 || origin.orientation.len() != 4 { @@ -142,11 +145,11 @@ pub fn get_origin<T, U>( Ok(RigidTransform3D::new(o, p)) } -pub fn get_point<T>(pt: &DOMPointInit) -> Point3D<f32, T> { +pub(crate) fn get_point<T>(pt: &DOMPointInit) -> Point3D<f32, T> { Point3D::new(pt.x / pt.w, pt.y / pt.w, pt.z / pt.w).cast() } -pub fn get_world(world: &FakeXRWorldInit) -> Fallible<MockWorld> { +pub(crate) fn get_world(world: &FakeXRWorldInit) -> Fallible<MockWorld> { let regions = world .hitTestRegions .iter() diff --git a/components/script/dom/webxr/fakexrinputcontroller.rs b/components/script/dom/webxr/fakexrinputcontroller.rs index e52dc0a21fd..07257311da6 100644 --- a/components/script/dom/webxr/fakexrinputcontroller.rs +++ b/components/script/dom/webxr/fakexrinputcontroller.rs @@ -26,7 +26,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct FakeXRInputController { +pub(crate) struct FakeXRInputController { reflector: Reflector, #[ignore_malloc_size_of = "defined in ipc-channel"] #[no_trace] @@ -37,7 +37,10 @@ pub struct FakeXRInputController { } impl FakeXRInputController { - pub fn new_inherited(sender: IpcSender<MockDeviceMsg>, id: InputId) -> FakeXRInputController { + pub(crate) fn new_inherited( + sender: IpcSender<MockDeviceMsg>, + id: InputId, + ) -> FakeXRInputController { FakeXRInputController { reflector: Reflector::new(), sender, @@ -45,7 +48,7 @@ impl FakeXRInputController { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, sender: IpcSender<MockDeviceMsg>, id: InputId, @@ -181,7 +184,7 @@ impl Convert<MockButtonType> for FakeXRButtonType { } /// <https://immersive-web.github.io/webxr-test-api/#parse-supported-buttons> -pub fn init_to_mock_buttons(buttons: &[FakeXRButtonStateInit]) -> Vec<MockButton> { +pub(crate) fn init_to_mock_buttons(buttons: &[FakeXRButtonStateInit]) -> Vec<MockButton> { let supported: Vec<MockButton> = buttons .iter() .map(|b| MockButton { diff --git a/components/script/dom/webxr/mod.rs b/components/script/dom/webxr/mod.rs index 6faee016890..d8c52d83315 100644 --- a/components/script/dom/webxr/mod.rs +++ b/components/script/dom/webxr/mod.rs @@ -2,43 +2,44 @@ * 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/. */ -pub mod fakexrdevice; -pub mod fakexrinputcontroller; -pub mod xrboundedreferencespace; -pub mod xrcompositionlayer; -pub mod xrcubelayer; -pub mod xrcylinderlayer; -pub mod xrequirectlayer; -pub mod xrframe; -pub mod xrhand; -pub mod xrhittestresult; -pub mod xrhittestsource; -pub mod xrinputsource; -pub mod xrinputsourcearray; -pub mod xrinputsourceevent; -pub mod xrinputsourceschangeevent; -pub mod xrjointpose; -pub mod xrjointspace; -pub mod xrlayer; -pub mod xrlayerevent; -pub mod xrmediabinding; -pub mod xrpose; -pub mod xrprojectionlayer; -pub mod xrquadlayer; -pub mod xrray; -pub mod xrreferencespace; -pub mod xrreferencespaceevent; -pub mod xrrenderstate; -pub mod xrrigidtransform; -pub mod xrsession; -pub mod xrsessionevent; -pub mod xrspace; -pub mod xrsubimage; -pub mod xrsystem; -pub mod xrtest; -pub mod xrview; -pub mod xrviewerpose; -pub mod xrviewport; -pub mod xrwebglbinding; -pub mod xrwebgllayer; -pub mod xrwebglsubimage; +pub(crate) mod fakexrdevice; +pub(crate) mod fakexrinputcontroller; +pub(crate) mod xrboundedreferencespace; +pub(crate) mod xrcompositionlayer; +pub(crate) mod xrcubelayer; +pub(crate) mod xrcylinderlayer; +pub(crate) mod xrequirectlayer; +pub(crate) mod xrframe; +pub(crate) mod xrhand; +pub(crate) mod xrhittestresult; +pub(crate) mod xrhittestsource; +pub(crate) mod xrinputsource; +pub(crate) mod xrinputsourcearray; +pub(crate) mod xrinputsourceevent; +pub(crate) mod xrinputsourceschangeevent; +pub(crate) mod xrjointpose; +pub(crate) mod xrjointspace; +pub(crate) mod xrlayer; +pub(crate) mod xrlayerevent; +pub(crate) mod xrmediabinding; +pub(crate) mod xrpose; +pub(crate) mod xrprojectionlayer; +pub(crate) mod xrquadlayer; +pub(crate) mod xrray; +pub(crate) mod xrreferencespace; +pub(crate) mod xrreferencespaceevent; +pub(crate) mod xrrenderstate; +pub(crate) mod xrrigidtransform; +#[allow(dead_code)] +pub(crate) mod xrsession; +pub(crate) mod xrsessionevent; +pub(crate) mod xrspace; +pub(crate) mod xrsubimage; +pub(crate) mod xrsystem; +pub(crate) mod xrtest; +pub(crate) mod xrview; +pub(crate) mod xrviewerpose; +pub(crate) mod xrviewport; +pub(crate) mod xrwebglbinding; +pub(crate) mod xrwebgllayer; +pub(crate) mod xrwebglsubimage; diff --git a/components/script/dom/webxr/xrboundedreferencespace.rs b/components/script/dom/webxr/xrboundedreferencespace.rs index ef5480bd72b..91d98467e92 100644 --- a/components/script/dom/webxr/xrboundedreferencespace.rs +++ b/components/script/dom/webxr/xrboundedreferencespace.rs @@ -18,13 +18,13 @@ use crate::dom::xrsession::XRSession; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRBoundedReferenceSpace { +pub(crate) struct XRBoundedReferenceSpace { reference_space: XRReferenceSpace, offset: Dom<XRRigidTransform>, } impl XRBoundedReferenceSpace { - pub fn new_inherited( + pub(crate) fn new_inherited( session: &XRSession, offset: &XRRigidTransform, ) -> XRBoundedReferenceSpace { @@ -39,7 +39,7 @@ impl XRBoundedReferenceSpace { } #[allow(unused)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: &XRSession, can_gc: CanGc, @@ -49,7 +49,7 @@ impl XRBoundedReferenceSpace { } #[allow(unused)] - pub fn new_offset( + pub(crate) fn new_offset( global: &GlobalScope, session: &XRSession, offset: &XRRigidTransform, @@ -61,7 +61,7 @@ impl XRBoundedReferenceSpace { ) } - pub fn reference_space(&self) -> &XRReferenceSpace { + pub(crate) fn reference_space(&self) -> &XRReferenceSpace { &self.reference_space } } diff --git a/components/script/dom/webxr/xrcompositionlayer.rs b/components/script/dom/webxr/xrcompositionlayer.rs index fbb71149716..5e563dba60b 100644 --- a/components/script/dom/webxr/xrcompositionlayer.rs +++ b/components/script/dom/webxr/xrcompositionlayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrlayer::XRLayer; #[dom_struct] -pub struct XRCompositionLayer { +pub(crate) struct XRCompositionLayer { xr_layer: XRLayer, } diff --git a/components/script/dom/webxr/xrcubelayer.rs b/components/script/dom/webxr/xrcubelayer.rs index 587d088e88b..ad269dbd94a 100644 --- a/components/script/dom/webxr/xrcubelayer.rs +++ b/components/script/dom/webxr/xrcubelayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrcompositionlayer::XRCompositionLayer; #[dom_struct] -pub struct XRCubeLayer { +pub(crate) struct XRCubeLayer { composition_layer: XRCompositionLayer, } diff --git a/components/script/dom/webxr/xrcylinderlayer.rs b/components/script/dom/webxr/xrcylinderlayer.rs index f468380bb36..be48d982ee5 100644 --- a/components/script/dom/webxr/xrcylinderlayer.rs +++ b/components/script/dom/webxr/xrcylinderlayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrcompositionlayer::XRCompositionLayer; #[dom_struct] -pub struct XRCylinderLayer { +pub(crate) struct XRCylinderLayer { composition_layer: XRCompositionLayer, } diff --git a/components/script/dom/webxr/xrequirectlayer.rs b/components/script/dom/webxr/xrequirectlayer.rs index 25cc04595ef..dc086c37e66 100644 --- a/components/script/dom/webxr/xrequirectlayer.rs +++ b/components/script/dom/webxr/xrequirectlayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrcompositionlayer::XRCompositionLayer; #[dom_struct] -pub struct XREquirectLayer { +pub(crate) struct XREquirectLayer { composition_layer: XRCompositionLayer, } diff --git a/components/script/dom/webxr/xrframe.rs b/components/script/dom/webxr/xrframe.rs index 432e35857af..729aa4cc957 100644 --- a/components/script/dom/webxr/xrframe.rs +++ b/components/script/dom/webxr/xrframe.rs @@ -28,7 +28,7 @@ use crate::dom::xrviewerpose::XRViewerPose; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRFrame { +pub(crate) struct XRFrame { reflector_: Reflector, session: Dom<XRSession>, #[ignore_malloc_size_of = "defined in webxr_api"] @@ -49,7 +49,7 @@ impl XRFrame { } } - pub fn new(global: &GlobalScope, session: &XRSession, data: Frame) -> DomRoot<XRFrame> { + pub(crate) fn new(global: &GlobalScope, session: &XRSession, data: Frame) -> DomRoot<XRFrame> { reflect_dom_object( Box::new(XRFrame::new_inherited(session, data)), global, @@ -58,20 +58,20 @@ impl XRFrame { } /// <https://immersive-web.github.io/webxr/#xrframe-active> - pub fn set_active(&self, active: bool) { + pub(crate) fn set_active(&self, active: bool) { self.active.set(active); } /// <https://immersive-web.github.io/webxr/#xrframe-animationframe> - pub fn set_animation_frame(&self, animation_frame: bool) { + pub(crate) fn set_animation_frame(&self, animation_frame: bool) { self.animation_frame.set(animation_frame); } - pub fn get_pose(&self, space: &XRSpace) -> Option<ApiPose> { + pub(crate) fn get_pose(&self, space: &XRSpace) -> Option<ApiPose> { space.get_pose(&self.data) } - pub fn get_sub_images(&self, layer_id: LayerId) -> Option<&SubImages> { + pub(crate) fn get_sub_images(&self, layer_id: LayerId) -> Option<&SubImages> { self.data .sub_images .iter() diff --git a/components/script/dom/webxr/xrhand.rs b/components/script/dom/webxr/xrhand.rs index e3ed4268a1f..a9253ccb72b 100644 --- a/components/script/dom/webxr/xrhand.rs +++ b/components/script/dom/webxr/xrhand.rs @@ -102,7 +102,7 @@ const JOINT_SPACE_MAP: [(XRHandJoint, Joint); 25] = [ ]; #[dom_struct] -pub struct XRHand { +pub(crate) struct XRHand { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webxr"] source: Dom<XRInputSource>, @@ -120,7 +120,11 @@ impl XRHand { } } - pub fn new(global: &GlobalScope, source: &XRInputSource, support: Hand<()>) -> DomRoot<XRHand> { + pub(crate) fn new( + global: &GlobalScope, + source: &XRInputSource, + support: Hand<()>, + ) -> DomRoot<XRHand> { let id = source.id(); let session = source.session(); let spaces = support.map(|field, joint| { diff --git a/components/script/dom/webxr/xrhittestresult.rs b/components/script/dom/webxr/xrhittestresult.rs index 4b4db410812..de9693136c7 100644 --- a/components/script/dom/webxr/xrhittestresult.rs +++ b/components/script/dom/webxr/xrhittestresult.rs @@ -15,7 +15,7 @@ use crate::dom::xrspace::XRSpace; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRHitTestResult { +pub(crate) struct XRHitTestResult { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webxr"] #[no_trace] @@ -32,7 +32,7 @@ impl XRHitTestResult { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, result: HitTestResult, frame: &XRFrame, diff --git a/components/script/dom/webxr/xrhittestsource.rs b/components/script/dom/webxr/xrhittestsource.rs index ba829f44aba..fad7e492249 100644 --- a/components/script/dom/webxr/xrhittestsource.rs +++ b/components/script/dom/webxr/xrhittestsource.rs @@ -13,7 +13,7 @@ use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRHitTestSource { +pub(crate) struct XRHitTestSource { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webxr"] #[no_trace] @@ -30,7 +30,7 @@ impl XRHitTestSource { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, id: HitTestId, session: &XRSession, @@ -42,7 +42,7 @@ impl XRHitTestSource { ) } - pub fn id(&self) -> HitTestId { + pub(crate) fn id(&self) -> HitTestId { self.id } } diff --git a/components/script/dom/webxr/xrinputsource.rs b/components/script/dom/webxr/xrinputsource.rs index cc240919324..f3486a83758 100644 --- a/components/script/dom/webxr/xrinputsource.rs +++ b/components/script/dom/webxr/xrinputsource.rs @@ -24,7 +24,7 @@ use crate::realms::enter_realm; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRInputSource { +pub(crate) struct XRInputSource { reflector: Reflector, session: Dom<XRSession>, #[ignore_malloc_size_of = "Defined in rust-webxr"] @@ -39,7 +39,7 @@ pub struct XRInputSource { } impl XRInputSource { - pub fn new_inherited( + pub(crate) fn new_inherited( global: &GlobalScope, session: &XRSession, info: InputSource, @@ -73,7 +73,7 @@ impl XRInputSource { } #[allow(unsafe_code)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: &XRSession, info: InputSource, @@ -95,15 +95,15 @@ impl XRInputSource { source } - pub fn id(&self) -> InputId { + pub(crate) fn id(&self) -> InputId { self.info.id } - pub fn session(&self) -> &XRSession { + pub(crate) fn session(&self) -> &XRSession { &self.session } - pub fn update_gamepad_state(&self, frame: InputFrame) { + pub(crate) fn update_gamepad_state(&self, frame: InputFrame) { frame .button_values .iter() @@ -116,7 +116,7 @@ impl XRInputSource { }); } - pub fn gamepad(&self) -> &DomRoot<Gamepad> { + pub(crate) fn gamepad(&self) -> &DomRoot<Gamepad> { &self.gamepad } } diff --git a/components/script/dom/webxr/xrinputsourcearray.rs b/components/script/dom/webxr/xrinputsourcearray.rs index 5c26f2b5824..98e9ac2c85b 100644 --- a/components/script/dom/webxr/xrinputsourcearray.rs +++ b/components/script/dom/webxr/xrinputsourcearray.rs @@ -18,7 +18,7 @@ use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRInputSourceArray { +pub(crate) struct XRInputSourceArray { reflector_: Reflector, input_sources: DomRefCell<Vec<Dom<XRInputSource>>>, } @@ -31,7 +31,7 @@ impl XRInputSourceArray { } } - pub fn new(global: &GlobalScope) -> DomRoot<XRInputSourceArray> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<XRInputSourceArray> { reflect_dom_object( Box::new(XRInputSourceArray::new_inherited()), global, @@ -39,7 +39,12 @@ impl XRInputSourceArray { ) } - pub fn add_input_sources(&self, session: &XRSession, inputs: &[InputSource], can_gc: CanGc) { + pub(crate) fn add_input_sources( + &self, + session: &XRSession, + inputs: &[InputSource], + can_gc: CanGc, + ) { let global = self.global(); let mut added = vec![]; @@ -72,7 +77,7 @@ impl XRInputSourceArray { event.upcast::<Event>().fire(session.upcast(), can_gc); } - pub fn remove_input_source(&self, session: &XRSession, id: InputId, can_gc: CanGc) { + pub(crate) fn remove_input_source(&self, session: &XRSession, id: InputId, can_gc: CanGc) { let global = self.global(); let removed = if let Some(i) = self.input_sources.borrow().iter().find(|i| i.id() == id) { i.gamepad().update_connected(false, false, can_gc); @@ -95,7 +100,7 @@ impl XRInputSourceArray { event.upcast::<Event>().fire(session.upcast(), can_gc); } - pub fn add_remove_input_source( + pub(crate) fn add_remove_input_source( &self, session: &XRSession, id: InputId, @@ -131,7 +136,7 @@ impl XRInputSourceArray { event.upcast::<Event>().fire(session.upcast(), can_gc); } - pub fn find(&self, id: InputId) -> Option<DomRoot<XRInputSource>> { + pub(crate) fn find(&self, id: InputId) -> Option<DomRoot<XRInputSource>> { self.input_sources .borrow() .iter() diff --git a/components/script/dom/webxr/xrinputsourceevent.rs b/components/script/dom/webxr/xrinputsourceevent.rs index cc694f8f99c..1e381b13a54 100644 --- a/components/script/dom/webxr/xrinputsourceevent.rs +++ b/components/script/dom/webxr/xrinputsourceevent.rs @@ -23,7 +23,7 @@ use crate::dom::xrinputsource::XRInputSource; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRInputSourceEvent { +pub(crate) struct XRInputSourceEvent { event: Event, frame: Dom<XRFrame>, source: Dom<XRInputSource>, @@ -39,7 +39,7 @@ impl XRInputSourceEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/webxr/xrinputsourceschangeevent.rs b/components/script/dom/webxr/xrinputsourceschangeevent.rs index 4429f7d545e..1e2057b0c72 100644 --- a/components/script/dom/webxr/xrinputsourceschangeevent.rs +++ b/components/script/dom/webxr/xrinputsourceschangeevent.rs @@ -26,7 +26,7 @@ use crate::realms::enter_realm; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRInputSourcesChangeEvent { +pub(crate) struct XRInputSourcesChangeEvent { event: Event, session: Dom<XRSession>, #[ignore_malloc_size_of = "mozjs"] @@ -47,7 +47,7 @@ impl XRInputSourcesChangeEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/webxr/xrjointpose.rs b/components/script/dom/webxr/xrjointpose.rs index 315dfc9cfe9..df80b9a88d8 100644 --- a/components/script/dom/webxr/xrjointpose.rs +++ b/components/script/dom/webxr/xrjointpose.rs @@ -15,7 +15,7 @@ use crate::dom::xrsession::ApiRigidTransform; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRJointPose { +pub(crate) struct XRJointPose { pose: XRPose, radius: Option<f32>, } @@ -29,7 +29,7 @@ impl XRJointPose { } #[allow(unsafe_code)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, pose: ApiRigidTransform, radius: Option<f32>, diff --git a/components/script/dom/webxr/xrjointspace.rs b/components/script/dom/webxr/xrjointspace.rs index 933f57339c5..7a125d54861 100644 --- a/components/script/dom/webxr/xrjointspace.rs +++ b/components/script/dom/webxr/xrjointspace.rs @@ -16,7 +16,7 @@ use crate::dom::xrspace::XRSpace; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRJointSpace { +pub(crate) struct XRJointSpace { xrspace: XRSpace, #[ignore_malloc_size_of = "defined in rust-webxr"] #[no_trace] @@ -28,7 +28,7 @@ pub struct XRJointSpace { } impl XRJointSpace { - pub fn new_inherited( + pub(crate) fn new_inherited( session: &XRSession, input: InputId, joint: Joint, @@ -43,7 +43,7 @@ impl XRJointSpace { } #[allow(unused)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: &XRSession, input: InputId, @@ -57,13 +57,13 @@ impl XRJointSpace { ) } - pub fn space(&self) -> Space { + pub(crate) fn space(&self) -> Space { let base = BaseSpace::Joint(self.input, self.joint); let offset = RigidTransform3D::identity(); Space { base, offset } } - pub fn frame<'a>(&self, frame: &'a Frame) -> Option<&'a JointFrame> { + pub(crate) fn frame<'a>(&self, frame: &'a Frame) -> Option<&'a JointFrame> { frame .inputs .iter() @@ -72,7 +72,7 @@ impl XRJointSpace { .and_then(|h| h.get(self.joint)) } - pub fn get_pose(&self, frame: &Frame) -> Option<ApiPose> { + pub(crate) fn get_pose(&self, frame: &Frame) -> Option<ApiPose> { self.frame(frame).map(|f| f.pose).map(|t| t.cast_unit()) } } diff --git a/components/script/dom/webxr/xrlayer.rs b/components/script/dom/webxr/xrlayer.rs index 3dc3b4dfeea..4db2cfe3ac2 100644 --- a/components/script/dom/webxr/xrlayer.rs +++ b/components/script/dom/webxr/xrlayer.rs @@ -15,7 +15,7 @@ use crate::dom::xrsession::XRSession; use crate::dom::xrwebgllayer::XRWebGLLayer; #[dom_struct] -pub struct XRLayer { +pub(crate) struct XRLayer { event_target: EventTarget, session: Dom<XRSession>, context: Dom<WebGLRenderingContext>, @@ -28,7 +28,7 @@ pub struct XRLayer { impl XRLayer { #[allow(dead_code)] - pub fn new_inherited( + pub(crate) fn new_inherited( session: &XRSession, context: &WebGLRenderingContext, layer_id: Option<LayerId>, @@ -57,7 +57,7 @@ impl XRLayer { &self.session } - pub fn begin_frame(&self, frame: &XRFrame) -> Option<()> { + pub(crate) fn begin_frame(&self, frame: &XRFrame) -> Option<()> { // TODO: Implement this for other layer types if let Some(this) = self.downcast::<XRWebGLLayer>() { this.begin_frame(frame) @@ -66,7 +66,7 @@ impl XRLayer { } } - pub fn end_frame(&self, frame: &XRFrame) -> Option<()> { + pub(crate) fn end_frame(&self, frame: &XRFrame) -> Option<()> { // TODO: Implement this for other layer types if let Some(this) = self.downcast::<XRWebGLLayer>() { this.end_frame(frame) diff --git a/components/script/dom/webxr/xrlayerevent.rs b/components/script/dom/webxr/xrlayerevent.rs index 136aac87450..67d91539aa1 100644 --- a/components/script/dom/webxr/xrlayerevent.rs +++ b/components/script/dom/webxr/xrlayerevent.rs @@ -20,13 +20,13 @@ use crate::script_runtime::CanGc; // https://w3c.github.io/uievents/#interface-uievent #[dom_struct] -pub struct XRLayerEvent { +pub(crate) struct XRLayerEvent { event: Event, layer: Dom<XRLayer>, } impl XRLayerEvent { - pub fn new_inherited(layer: &XRLayer) -> XRLayerEvent { + pub(crate) fn new_inherited(layer: &XRLayer) -> XRLayerEvent { XRLayerEvent { event: Event::new_inherited(), layer: Dom::from_ref(layer), diff --git a/components/script/dom/webxr/xrmediabinding.rs b/components/script/dom/webxr/xrmediabinding.rs index 14eec1fb354..db535542f88 100644 --- a/components/script/dom/webxr/xrmediabinding.rs +++ b/components/script/dom/webxr/xrmediabinding.rs @@ -19,13 +19,13 @@ use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRMediaBinding { +pub(crate) struct XRMediaBinding { reflector: Reflector, session: Dom<XRSession>, } impl XRMediaBinding { - pub fn new_inherited(session: &XRSession) -> XRMediaBinding { + pub(crate) fn new_inherited(session: &XRSession) -> XRMediaBinding { XRMediaBinding { reflector: Reflector::new(), session: Dom::from_ref(session), diff --git a/components/script/dom/webxr/xrpose.rs b/components/script/dom/webxr/xrpose.rs index 08442f54806..71d67eb48e1 100644 --- a/components/script/dom/webxr/xrpose.rs +++ b/components/script/dom/webxr/xrpose.rs @@ -14,13 +14,13 @@ use crate::dom::xrsession::ApiRigidTransform; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRPose { +pub(crate) struct XRPose { reflector_: Reflector, transform: Dom<XRRigidTransform>, } impl XRPose { - pub fn new_inherited(transform: &XRRigidTransform) -> XRPose { + pub(crate) fn new_inherited(transform: &XRRigidTransform) -> XRPose { XRPose { reflector_: Reflector::new(), transform: Dom::from_ref(transform), @@ -28,7 +28,7 @@ impl XRPose { } #[allow(unused)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, transform: ApiRigidTransform, can_gc: CanGc, diff --git a/components/script/dom/webxr/xrprojectionlayer.rs b/components/script/dom/webxr/xrprojectionlayer.rs index 489c3a9e706..6b9b4964cc2 100644 --- a/components/script/dom/webxr/xrprojectionlayer.rs +++ b/components/script/dom/webxr/xrprojectionlayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrcompositionlayer::XRCompositionLayer; #[dom_struct] -pub struct XRProjectionLayer { +pub(crate) struct XRProjectionLayer { composition_layer: XRCompositionLayer, } diff --git a/components/script/dom/webxr/xrquadlayer.rs b/components/script/dom/webxr/xrquadlayer.rs index dd93aea9c0a..73f7b32cc83 100644 --- a/components/script/dom/webxr/xrquadlayer.rs +++ b/components/script/dom/webxr/xrquadlayer.rs @@ -7,6 +7,6 @@ use dom_struct::dom_struct; use crate::dom::xrcompositionlayer::XRCompositionLayer; #[dom_struct] -pub struct XRQuadLayer { +pub(crate) struct XRQuadLayer { composition_layer: XRCompositionLayer, } diff --git a/components/script/dom/webxr/xrray.rs b/components/script/dom/webxr/xrray.rs index 4936edd0acb..548f30ea111 100644 --- a/components/script/dom/webxr/xrray.rs +++ b/components/script/dom/webxr/xrray.rs @@ -21,7 +21,7 @@ use crate::dom::xrrigidtransform::XRRigidTransform; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRRay { +pub(crate) struct XRRay { reflector_: Reflector, #[ignore_malloc_size_of = "defined in webxr"] #[no_trace] @@ -48,7 +48,7 @@ impl XRRay { reflect_dom_object_with_proto(Box::new(XRRay::new_inherited(ray)), global, proto, can_gc) } - pub fn ray(&self) -> Ray<ApiSpace> { + pub(crate) fn ray(&self) -> Ray<ApiSpace> { self.ray } } diff --git a/components/script/dom/webxr/xrreferencespace.rs b/components/script/dom/webxr/xrreferencespace.rs index 04d81070095..abd9f47c69f 100644 --- a/components/script/dom/webxr/xrreferencespace.rs +++ b/components/script/dom/webxr/xrreferencespace.rs @@ -19,14 +19,14 @@ use crate::dom::xrspace::XRSpace; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRReferenceSpace { +pub(crate) struct XRReferenceSpace { xrspace: XRSpace, offset: Dom<XRRigidTransform>, ty: XRReferenceSpaceType, } impl XRReferenceSpace { - pub fn new_inherited( + pub(crate) fn new_inherited( session: &XRSession, offset: &XRRigidTransform, ty: XRReferenceSpaceType, @@ -39,7 +39,7 @@ impl XRReferenceSpace { } #[allow(unused)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: &XRSession, ty: XRReferenceSpaceType, @@ -50,7 +50,7 @@ impl XRReferenceSpace { } #[allow(unused)] - pub fn new_offset( + pub(crate) fn new_offset( global: &GlobalScope, session: &XRSession, ty: XRReferenceSpaceType, @@ -63,7 +63,7 @@ impl XRReferenceSpace { ) } - pub fn space(&self) -> Space { + pub(crate) fn space(&self) -> Space { let base = match self.ty { XRReferenceSpaceType::Local => webxr_api::BaseSpace::Local, XRReferenceSpaceType::Viewer => webxr_api::BaseSpace::Viewer, @@ -75,7 +75,7 @@ impl XRReferenceSpace { Space { base, offset } } - pub fn ty(&self) -> XRReferenceSpaceType { + pub(crate) fn ty(&self) -> XRReferenceSpaceType { self.ty } } @@ -102,7 +102,7 @@ impl XRReferenceSpace { /// /// This is equivalent to `get_pose(self).inverse()` (in column vector notation), /// but with better types - pub fn get_base_transform(&self, base_pose: &Frame) -> Option<BaseTransform> { + pub(crate) fn get_base_transform(&self, base_pose: &Frame) -> Option<BaseTransform> { let pose = self.get_pose(base_pose)?; Some(pose.inverse().cast_unit()) } @@ -112,7 +112,7 @@ impl XRReferenceSpace { /// The reference origin used is common between all /// get_pose calls for spaces from the same device, so this can be used to compare /// with other spaces - pub fn get_pose(&self, base_pose: &Frame) -> Option<ApiPose> { + pub(crate) fn get_pose(&self, base_pose: &Frame) -> Option<ApiPose> { let pose = self.get_unoffset_pose(base_pose)?; let offset = self.offset.transform(); // pose is a transform from the unoffset space to native space, @@ -125,7 +125,7 @@ impl XRReferenceSpace { /// Gets pose represented by this space /// /// Does not apply originOffset, use get_viewer_pose instead if you need it - pub fn get_unoffset_pose(&self, base_pose: &Frame) -> Option<ApiPose> { + pub(crate) fn get_unoffset_pose(&self, base_pose: &Frame) -> Option<ApiPose> { match self.ty { XRReferenceSpaceType::Local => { // The eye-level pose is basically whatever the headset pose was at t=0, which @@ -146,7 +146,7 @@ impl XRReferenceSpace { } } - pub fn get_bounds(&self) -> Option<Vec<Point2D<f32, Floor>>> { + pub(crate) fn get_bounds(&self) -> Option<Vec<Point2D<f32, Floor>>> { self.upcast::<XRSpace>() .session() .with_session(|s| s.reference_space_bounds()) diff --git a/components/script/dom/webxr/xrreferencespaceevent.rs b/components/script/dom/webxr/xrreferencespaceevent.rs index e75aabe14a1..cce439c3757 100644 --- a/components/script/dom/webxr/xrreferencespaceevent.rs +++ b/components/script/dom/webxr/xrreferencespaceevent.rs @@ -23,7 +23,7 @@ use crate::dom::xrrigidtransform::XRRigidTransform; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRReferenceSpaceEvent { +pub(crate) struct XRReferenceSpaceEvent { event: Event, space: Dom<XRReferenceSpace>, transform: Option<Dom<XRRigidTransform>>, @@ -42,7 +42,7 @@ impl XRReferenceSpaceEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/webxr/xrrenderstate.rs b/components/script/dom/webxr/xrrenderstate.rs index b2d5219ed00..3c7a12393b3 100644 --- a/components/script/dom/webxr/xrrenderstate.rs +++ b/components/script/dom/webxr/xrrenderstate.rs @@ -20,7 +20,7 @@ use crate::dom::xrwebgllayer::XRWebGLLayer; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRRenderState { +pub(crate) struct XRRenderState { reflector_: Reflector, depth_near: Cell<f64>, depth_far: Cell<f64>, @@ -30,7 +30,7 @@ pub struct XRRenderState { } impl XRRenderState { - pub fn new_inherited( + pub(crate) fn new_inherited( depth_near: f64, depth_far: f64, inline_vertical_fov: Option<f64>, @@ -48,7 +48,7 @@ impl XRRenderState { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, depth_near: f64, depth_far: f64, @@ -69,7 +69,7 @@ impl XRRenderState { ) } - pub fn clone_object(&self) -> DomRoot<Self> { + pub(crate) fn clone_object(&self) -> DomRoot<Self> { XRRenderState::new( &self.global(), self.depth_near.get(), @@ -80,30 +80,30 @@ impl XRRenderState { ) } - pub fn set_depth_near(&self, depth: f64) { + pub(crate) fn set_depth_near(&self, depth: f64) { self.depth_near.set(depth) } - pub fn set_depth_far(&self, depth: f64) { + pub(crate) fn set_depth_far(&self, depth: f64) { self.depth_far.set(depth) } - pub fn set_inline_vertical_fov(&self, fov: f64) { + pub(crate) fn set_inline_vertical_fov(&self, fov: f64) { debug_assert!(self.inline_vertical_fov.get().is_some()); self.inline_vertical_fov.set(Some(fov)) } - pub fn set_base_layer(&self, layer: Option<&XRWebGLLayer>) { + pub(crate) fn set_base_layer(&self, layer: Option<&XRWebGLLayer>) { self.base_layer.set(layer) } - pub fn set_layers(&self, layers: Vec<&XRLayer>) { + pub(crate) fn set_layers(&self, layers: Vec<&XRLayer>) { *self.layers.borrow_mut() = layers.into_iter().map(Dom::from_ref).collect(); } - pub fn with_layers<F, R>(&self, f: F) -> R + pub(crate) fn with_layers<F, R>(&self, f: F) -> R where F: FnOnce(&[Dom<XRLayer>]) -> R, { let layers = self.layers.borrow(); f(&layers) } - pub fn has_sub_images(&self, sub_images: &[SubImages]) -> bool { + pub(crate) fn has_sub_images(&self, sub_images: &[SubImages]) -> bool { if let Some(base_layer) = self.base_layer.get() { match sub_images.len() { // For inline sessions, there may be a base layer, but it won't have a framebuffer diff --git a/components/script/dom/webxr/xrrigidtransform.rs b/components/script/dom/webxr/xrrigidtransform.rs index e215c17cf4e..57c6dd4de0d 100644 --- a/components/script/dom/webxr/xrrigidtransform.rs +++ b/components/script/dom/webxr/xrrigidtransform.rs @@ -20,7 +20,7 @@ use crate::dom::xrsession::ApiRigidTransform; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRRigidTransform { +pub(crate) struct XRRigidTransform { reflector_: Reflector, position: MutNullableDom<DOMPointReadOnly>, orientation: MutNullableDom<DOMPointReadOnly>, @@ -44,7 +44,7 @@ impl XRRigidTransform { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, transform: ApiRigidTransform, can_gc: CanGc, @@ -66,7 +66,7 @@ impl XRRigidTransform { ) } - pub fn identity(window: &GlobalScope, can_gc: CanGc) -> DomRoot<XRRigidTransform> { + pub(crate) fn identity(window: &GlobalScope, can_gc: CanGc) -> DomRoot<XRRigidTransform> { let transform = RigidTransform3D::identity(); XRRigidTransform::new(window, transform, can_gc) } @@ -182,7 +182,7 @@ impl XRRigidTransformMethods<crate::DomTypeHolder> for XRRigidTransform { impl XRRigidTransform { /// <https://immersive-web.github.io/webxr/#dom-xrpose-transform> - pub fn transform(&self) -> ApiRigidTransform { + pub(crate) fn transform(&self) -> ApiRigidTransform { self.transform } } diff --git a/components/script/dom/webxr/xrsession.rs b/components/script/dom/webxr/xrsession.rs index 7e45d0c3f55..13ed485139b 100644 --- a/components/script/dom/webxr/xrsession.rs +++ b/components/script/dom/webxr/xrsession.rs @@ -71,7 +71,7 @@ use crate::script_runtime::JSContext; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRSession { +pub(crate) struct XRSession { eventtarget: EventTarget, blend_mode: XREnvironmentBlendMode, mode: XRSessionMode, @@ -150,7 +150,7 @@ impl XRSession { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: Session, mode: XRSessionMode, @@ -178,21 +178,21 @@ impl XRSession { ret } - pub fn with_session<R, F: FnOnce(&Session) -> R>(&self, with: F) -> R { + pub(crate) fn with_session<R, F: FnOnce(&Session) -> R>(&self, with: F) -> R { let session = self.session.borrow(); with(&session) } - pub fn is_ended(&self) -> bool { + pub(crate) fn is_ended(&self) -> bool { self.ended.get() } - pub fn is_immersive(&self) -> bool { + pub(crate) fn is_immersive(&self) -> bool { self.mode != XRSessionMode::Inline } // https://immersive-web.github.io/layers/#feature-descriptor-layers - pub fn has_layers_feature(&self) -> bool { + pub(crate) fn has_layers_feature(&self) -> bool { // We do not support creating layers other than projection layers // https://github.com/servo/servo/issues/27493 false @@ -220,7 +220,7 @@ impl XRSession { self.session.borrow_mut().start_render_loop(); } - pub fn is_outside_raf(&self) -> bool { + pub(crate) fn is_outside_raf(&self) -> bool { self.outside_raf.get() } @@ -252,7 +252,7 @@ impl XRSession { // // This enables content that assumes all input sources are accompanied // by an inputsourceschange event to work properly. Without - pub fn setup_initial_inputs(&self) { + pub(crate) fn setup_initial_inputs(&self) { let initial_inputs = self.session.borrow().initial_inputs().to_owned(); if initial_inputs.is_empty() { @@ -519,7 +519,7 @@ impl XRSession { } /// Constructs a View suitable for inline sessions using the inlineVerticalFieldOfView and canvas size - pub fn inline_view(&self) -> View<Viewer> { + pub(crate) fn inline_view(&self) -> View<Viewer> { debug_assert!(!self.is_immersive()); View { // Inline views have no offset @@ -528,11 +528,11 @@ impl XRSession { } } - pub fn session_id(&self) -> SessionId { + pub(crate) fn session_id(&self) -> SessionId { self.session.borrow().id() } - pub fn dirty_layers(&self) { + pub(crate) fn dirty_layers(&self) { if let Some(layer) = self.RenderState().GetBaseLayer() { layer.context().mark_as_dirty(); } @@ -1071,17 +1071,17 @@ impl XRSessionMethods<crate::DomTypeHolder> for XRSession { } // The pose of an object in native-space. Should never be exposed. -pub type ApiPose = RigidTransform3D<f32, ApiSpace, webxr_api::Native>; +pub(crate) type ApiPose = RigidTransform3D<f32, ApiSpace, webxr_api::Native>; // A transform between objects in some API-space -pub type ApiRigidTransform = RigidTransform3D<f32, ApiSpace, ApiSpace>; +pub(crate) type ApiRigidTransform = RigidTransform3D<f32, ApiSpace, ApiSpace>; #[derive(Clone, Copy)] -pub struct BaseSpace; +pub(crate) struct BaseSpace; -pub type BaseTransform = RigidTransform3D<f32, webxr_api::Native, BaseSpace>; +pub(crate) type BaseTransform = RigidTransform3D<f32, webxr_api::Native, BaseSpace>; #[allow(unsafe_code)] -pub fn cast_transform<T, U, V, W>( +pub(crate) fn cast_transform<T, U, V, W>( transform: RigidTransform3D<f32, T, U>, ) -> RigidTransform3D<f32, V, W> { unsafe { mem::transmute(transform) } diff --git a/components/script/dom/webxr/xrsessionevent.rs b/components/script/dom/webxr/xrsessionevent.rs index fda299a9f2a..98f5ce710b8 100644 --- a/components/script/dom/webxr/xrsessionevent.rs +++ b/components/script/dom/webxr/xrsessionevent.rs @@ -20,7 +20,7 @@ use crate::dom::xrsession::XRSession; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRSessionEvent { +pub(crate) struct XRSessionEvent { event: Event, session: Dom<XRSession>, } @@ -34,7 +34,7 @@ impl XRSessionEvent { } } - pub fn new( + pub(crate) fn new( global: &GlobalScope, type_: Atom, bubbles: bool, diff --git a/components/script/dom/webxr/xrspace.rs b/components/script/dom/webxr/xrspace.rs index 42a2933edee..df7503677b6 100644 --- a/components/script/dom/webxr/xrspace.rs +++ b/components/script/dom/webxr/xrspace.rs @@ -18,7 +18,7 @@ use crate::dom::xrsession::{cast_transform, ApiPose, XRSession}; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRSpace { +pub(crate) struct XRSpace { eventtarget: EventTarget, session: Dom<XRSession>, input_source: MutNullableDom<XRInputSource>, @@ -27,7 +27,7 @@ pub struct XRSpace { } impl XRSpace { - pub fn new_inherited(session: &XRSession) -> XRSpace { + pub(crate) fn new_inherited(session: &XRSession) -> XRSpace { XRSpace { eventtarget: EventTarget::new_inherited(), session: Dom::from_ref(session), @@ -49,7 +49,7 @@ impl XRSpace { } } - pub fn new_inputspace( + pub(crate) fn new_inputspace( global: &GlobalScope, session: &XRSession, input: &XRInputSource, @@ -62,7 +62,7 @@ impl XRSpace { ) } - pub fn space(&self) -> Space { + pub(crate) fn space(&self) -> Space { if let Some(rs) = self.downcast::<XRReferenceSpace>() { rs.space() } else if let Some(j) = self.downcast::<XRJointSpace>() { @@ -89,7 +89,7 @@ impl XRSpace { /// The reference origin used is common between all /// get_pose calls for spaces from the same device, so this can be used to compare /// with other spaces - pub fn get_pose(&self, base_pose: &Frame) -> Option<ApiPose> { + pub(crate) fn get_pose(&self, base_pose: &Frame) -> Option<ApiPose> { if let Some(reference) = self.downcast::<XRReferenceSpace>() { reference.get_pose(base_pose) } else if let Some(joint) = self.downcast::<XRJointSpace>() { @@ -116,7 +116,7 @@ impl XRSpace { } } - pub fn session(&self) -> &XRSession { + pub(crate) fn session(&self) -> &XRSession { &self.session } } diff --git a/components/script/dom/webxr/xrsubimage.rs b/components/script/dom/webxr/xrsubimage.rs index 53d2e3ca697..8bf84b82063 100644 --- a/components/script/dom/webxr/xrsubimage.rs +++ b/components/script/dom/webxr/xrsubimage.rs @@ -10,7 +10,7 @@ use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::xrviewport::XRViewport; #[dom_struct] -pub struct XRSubImage { +pub(crate) struct XRSubImage { reflector: Reflector, viewport: Dom<XRViewport>, } diff --git a/components/script/dom/webxr/xrsystem.rs b/components/script/dom/webxr/xrsystem.rs index 3eace3892f7..82736d540e9 100644 --- a/components/script/dom/webxr/xrsystem.rs +++ b/components/script/dom/webxr/xrsystem.rs @@ -37,7 +37,7 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct XRSystem { +pub(crate) struct XRSystem { eventtarget: EventTarget, gamepads: DomRefCell<Vec<Dom<Gamepad>>>, pending_immersive_session: Cell<bool>, @@ -61,7 +61,7 @@ impl XRSystem { } } - pub fn new(window: &Window) -> DomRoot<XRSystem> { + pub(crate) fn new(window: &Window) -> DomRoot<XRSystem> { reflect_dom_object( Box::new(XRSystem::new_inherited(window.pipeline_id())), window, @@ -69,15 +69,15 @@ impl XRSystem { ) } - pub fn pending_or_active_session(&self) -> bool { + pub(crate) fn pending_or_active_session(&self) -> bool { self.pending_immersive_session.get() || self.active_immersive_session.get().is_some() } - pub fn set_pending(&self) { + pub(crate) fn set_pending(&self) { self.pending_immersive_session.set(true) } - pub fn set_active_immersive_session(&self, session: &XRSession) { + pub(crate) fn set_active_immersive_session(&self, session: &XRSession) { // XXXManishearth when we support non-immersive (inline) sessions we should // ensure they never reach these codepaths self.pending_immersive_session.set(false); @@ -85,7 +85,7 @@ impl XRSystem { } /// <https://immersive-web.github.io/webxr/#ref-for-eventdef-xrsession-end> - pub fn end_session(&self, session: &XRSession) { + pub(crate) fn end_session(&self, session: &XRSession) { // Step 3 if let Some(active) = self.active_immersive_session.get() { if Dom::from_ref(&*active) == Dom::from_ref(session) { @@ -308,7 +308,7 @@ impl XRSystem { } // https://github.com/immersive-web/navigation/issues/10 - pub fn dispatch_sessionavailable(&self) { + pub(crate) fn dispatch_sessionavailable(&self) { let xr = Trusted::new(self); self.global() .task_manager() diff --git a/components/script/dom/webxr/xrtest.rs b/components/script/dom/webxr/xrtest.rs index 59f489f980d..04c4f2f866f 100644 --- a/components/script/dom/webxr/xrtest.rs +++ b/components/script/dom/webxr/xrtest.rs @@ -30,20 +30,20 @@ use crate::script_runtime::CanGc; use crate::script_thread::ScriptThread; #[dom_struct] -pub struct XRTest { +pub(crate) struct XRTest { reflector: Reflector, devices_connected: DomRefCell<Vec<Dom<FakeXRDevice>>>, } impl XRTest { - pub fn new_inherited() -> XRTest { + pub(crate) fn new_inherited() -> XRTest { XRTest { reflector: Reflector::new(), devices_connected: DomRefCell::new(vec![]), } } - pub fn new(global: &GlobalScope) -> DomRoot<XRTest> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<XRTest> { reflect_dom_object(Box::new(XRTest::new_inherited()), global, CanGc::note()) } diff --git a/components/script/dom/webxr/xrview.rs b/components/script/dom/webxr/xrview.rs index 115fde4ec35..fb2d64087b1 100644 --- a/components/script/dom/webxr/xrview.rs +++ b/components/script/dom/webxr/xrview.rs @@ -20,7 +20,7 @@ use crate::dom::xrsession::{cast_transform, BaseSpace, BaseTransform, XRSession} use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRView { +pub(crate) struct XRView { reflector_: Reflector, session: Dom<XRSession>, eye: XREye, @@ -54,7 +54,7 @@ impl XRView { } } - pub fn new<V: Copy>( + pub(crate) fn new<V: Copy>( global: &GlobalScope, session: &XRSession, view: &View<V>, @@ -79,11 +79,11 @@ impl XRView { ) } - pub fn session(&self) -> &XRSession { + pub(crate) fn session(&self) -> &XRSession { &self.session } - pub fn viewport_index(&self) -> usize { + pub(crate) fn viewport_index(&self) -> usize { self.viewport_index } } diff --git a/components/script/dom/webxr/xrviewerpose.rs b/components/script/dom/webxr/xrviewerpose.rs index 1ab6e1b92e1..f7f1924d963 100644 --- a/components/script/dom/webxr/xrviewerpose.rs +++ b/components/script/dom/webxr/xrviewerpose.rs @@ -23,7 +23,7 @@ use crate::realms::enter_realm; use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] -pub struct XRViewerPose { +pub(crate) struct XRViewerPose { pose: XRPose, #[ignore_malloc_size_of = "mozjs"] views: Heap<JSVal>, @@ -38,7 +38,7 @@ impl XRViewerPose { } #[allow(unsafe_code)] - pub fn new( + pub(crate) fn new( global: &GlobalScope, session: &XRSession, to_base: BaseTransform, diff --git a/components/script/dom/webxr/xrviewport.rs b/components/script/dom/webxr/xrviewport.rs index 49c137c28b0..1c759be7089 100644 --- a/components/script/dom/webxr/xrviewport.rs +++ b/components/script/dom/webxr/xrviewport.rs @@ -13,7 +13,7 @@ use crate::dom::globalscope::GlobalScope; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRViewport { +pub(crate) struct XRViewport { reflector_: Reflector, #[no_trace] viewport: Rect<i32, Viewport>, @@ -27,7 +27,7 @@ impl XRViewport { } } - pub fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> { + pub(crate) fn new(global: &GlobalScope, viewport: Rect<i32, Viewport>) -> DomRoot<XRViewport> { reflect_dom_object( Box::new(XRViewport::new_inherited(viewport)), global, diff --git a/components/script/dom/webxr/xrwebglbinding.rs b/components/script/dom/webxr/xrwebglbinding.rs index c2d652bb81d..d0e7c3a3d01 100644 --- a/components/script/dom/webxr/xrwebglbinding.rs +++ b/components/script/dom/webxr/xrwebglbinding.rs @@ -31,14 +31,17 @@ use crate::dom::xrwebglsubimage::XRWebGLSubImage; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XRWebGLBinding { +pub(crate) struct XRWebGLBinding { reflector: Reflector, session: Dom<XRSession>, context: Dom<WebGLRenderingContext>, } impl XRWebGLBinding { - pub fn new_inherited(session: &XRSession, context: &WebGLRenderingContext) -> XRWebGLBinding { + pub(crate) fn new_inherited( + session: &XRSession, + context: &WebGLRenderingContext, + ) -> XRWebGLBinding { XRWebGLBinding { reflector: Reflector::new(), session: Dom::from_ref(session), diff --git a/components/script/dom/webxr/xrwebgllayer.rs b/components/script/dom/webxr/xrwebgllayer.rs index 031bd4b2f4d..0fd4147b80f 100644 --- a/components/script/dom/webxr/xrwebgllayer.rs +++ b/components/script/dom/webxr/xrwebgllayer.rs @@ -48,7 +48,7 @@ impl<'a> From<&'a XRWebGLLayerInit> for LayerInit { } #[dom_struct] -pub struct XRWebGLLayer { +pub(crate) struct XRWebGLLayer { xr_layer: XRLayer, antialias: bool, depth: bool, @@ -60,7 +60,7 @@ pub struct XRWebGLLayer { } impl XRWebGLLayer { - pub fn new_inherited( + pub(crate) fn new_inherited( session: &XRSession, context: &WebGLRenderingContext, init: &XRWebGLLayerInit, @@ -103,19 +103,19 @@ impl XRWebGLLayer { ) } - pub fn layer_id(&self) -> Option<LayerId> { + pub(crate) fn layer_id(&self) -> Option<LayerId> { self.xr_layer.layer_id() } - pub fn context_id(&self) -> WebGLContextId { + pub(crate) fn context_id(&self) -> WebGLContextId { self.xr_layer.context_id() } - pub fn session(&self) -> &XRSession { + pub(crate) fn session(&self) -> &XRSession { self.xr_layer.session() } - pub fn size(&self) -> Size2D<u32, Viewport> { + pub(crate) fn size(&self) -> Size2D<u32, Viewport> { if let Some(framebuffer) = self.framebuffer.as_ref() { let size = framebuffer.size().unwrap_or((0, 0)); Size2D::new( @@ -145,7 +145,7 @@ impl XRWebGLLayer { } } - pub fn begin_frame(&self, frame: &XRFrame) -> Option<()> { + pub(crate) fn begin_frame(&self, frame: &XRFrame) -> Option<()> { debug!("XRWebGLLayer begin frame"); let framebuffer = self.framebuffer.as_ref()?; let context = framebuffer.upcast::<WebGLObject>().context(); @@ -211,7 +211,7 @@ impl XRWebGLLayer { Some(()) } - pub fn end_frame(&self, _frame: &XRFrame) -> Option<()> { + pub(crate) fn end_frame(&self, _frame: &XRFrame) -> Option<()> { debug!("XRWebGLLayer end frame"); // TODO: invalidate the old texture let framebuffer = self.framebuffer.as_ref()?; diff --git a/components/script/dom/webxr/xrwebglsubimage.rs b/components/script/dom/webxr/xrwebglsubimage.rs index acdcd22f4a9..67b2c5e8c1d 100644 --- a/components/script/dom/webxr/xrwebglsubimage.rs +++ b/components/script/dom/webxr/xrwebglsubimage.rs @@ -12,7 +12,7 @@ use crate::dom::webgltexture::WebGLTexture; use crate::dom::xrsubimage::XRSubImage; #[dom_struct] -pub struct XRWebGLSubImage { +pub(crate) struct XRWebGLSubImage { xr_sub_image: XRSubImage, color_texture: Dom<WebGLTexture>, depth_stencil_texture: Option<Dom<WebGLTexture>>, diff --git a/components/script/dom/wheelevent.rs b/components/script/dom/wheelevent.rs index a81406d43a6..6f2b0d535e3 100644 --- a/components/script/dom/wheelevent.rs +++ b/components/script/dom/wheelevent.rs @@ -22,7 +22,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct WheelEvent { +pub(crate) struct WheelEvent { mouseevent: MouseEvent, delta_x: Cell<Finite<f64>>, delta_y: Cell<Finite<f64>>, @@ -50,7 +50,7 @@ impl WheelEvent { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, type_: DOMString, can_bubble: EventBubbles, diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 6c9d1f1f0c8..2b79e923590 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -200,7 +200,7 @@ impl LayoutBlocker { } #[dom_struct] -pub struct Window { +pub(crate) struct Window { globalscope: GlobalScope, script_chan: Sender<MainThreadScriptMsg>, #[no_trace] @@ -385,24 +385,24 @@ impl Window { self.upcast::<GlobalScope>() } - pub fn layout(&self) -> Ref<Box<dyn Layout>> { + pub(crate) fn layout(&self) -> Ref<Box<dyn Layout>> { self.layout.borrow() } - pub fn layout_mut(&self) -> RefMut<Box<dyn Layout>> { + pub(crate) fn layout_mut(&self) -> RefMut<Box<dyn Layout>> { self.layout.borrow_mut() } - pub fn get_exists_mut_observer(&self) -> bool { + pub(crate) fn get_exists_mut_observer(&self) -> bool { self.exists_mut_observer.get() } - pub fn set_exists_mut_observer(&self) { + pub(crate) fn set_exists_mut_observer(&self) { self.exists_mut_observer.set(true); } #[allow(unsafe_code)] - pub fn clear_js_runtime_for_script_deallocation(&self) { + pub(crate) fn clear_js_runtime_for_script_deallocation(&self) { self.as_global_scope() .remove_web_messaging_and_dedicated_workers_infra(); unsafe { @@ -417,7 +417,7 @@ impl Window { /// A convenience method for /// <https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded> - pub fn discard_browsing_context(&self) { + pub(crate) fn discard_browsing_context(&self) { let proxy = match self.window_proxy.get() { Some(proxy) => proxy, None => panic!("Discarding a BC from a window that has none"), @@ -432,20 +432,20 @@ impl Window { } /// Get a sender to the time profiler thread. - pub fn time_profiler_chan(&self) -> &TimeProfilerChan { + pub(crate) fn time_profiler_chan(&self) -> &TimeProfilerChan { self.globalscope.time_profiler_chan() } - pub fn origin(&self) -> &MutableOrigin { + pub(crate) fn origin(&self) -> &MutableOrigin { self.globalscope.origin() } #[allow(unsafe_code)] - pub fn get_cx(&self) -> JSContext { + pub(crate) fn get_cx(&self) -> JSContext { unsafe { JSContext::from_ptr(self.js_runtime.borrow().as_ref().unwrap().cx()) } } - pub fn get_js_runtime(&self) -> Ref<Option<Rc<Runtime>>> { + pub(crate) fn get_js_runtime(&self) -> Ref<Option<Rc<Runtime>>> { self.js_runtime.borrow() } @@ -453,7 +453,7 @@ impl Window { &self.script_chan } - pub fn parent_info(&self) -> Option<PipelineId> { + pub(crate) fn parent_info(&self) -> Option<PipelineId> { self.parent_info } @@ -469,18 +469,18 @@ impl Window { ScriptEventLoopSender::MainThread(self.script_chan.clone()) } - pub fn image_cache(&self) -> Arc<dyn ImageCache> { + pub(crate) fn image_cache(&self) -> Arc<dyn ImageCache> { self.image_cache.clone() } /// This can panic if it is called after the browsing context has been discarded - pub fn window_proxy(&self) -> DomRoot<WindowProxy> { + pub(crate) fn window_proxy(&self) -> DomRoot<WindowProxy> { self.window_proxy.get().unwrap() } /// Returns the window proxy if it has not been discarded. /// <https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded> - pub fn undiscarded_window_proxy(&self) -> Option<DomRoot<WindowProxy>> { + pub(crate) fn undiscarded_window_proxy(&self) -> Option<DomRoot<WindowProxy>> { self.window_proxy.get().and_then(|window_proxy| { if window_proxy.is_browsing_context_discarded() { None @@ -490,26 +490,29 @@ impl Window { }) } - pub fn bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { + pub(crate) fn bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { self.bluetooth_thread.clone() } - pub fn bluetooth_extra_permission_data(&self) -> &BluetoothExtraPermissionData { + pub(crate) fn bluetooth_extra_permission_data(&self) -> &BluetoothExtraPermissionData { &self.bluetooth_extra_permission_data } - pub fn css_error_reporter(&self) -> Option<&dyn ParseErrorReporter> { + pub(crate) fn css_error_reporter(&self) -> Option<&dyn ParseErrorReporter> { Some(&self.error_reporter) } /// Sets a new list of scroll offsets. /// /// This is called when layout gives us new ones and WebRender is in use. - pub fn set_scroll_offsets(&self, offsets: HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>) { + pub(crate) fn set_scroll_offsets( + &self, + offsets: HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>, + ) { *self.scroll_offsets.borrow_mut() = offsets } - pub fn current_viewport(&self) -> UntypedRect<Au> { + pub(crate) fn current_viewport(&self) -> UntypedRect<Au> { self.current_viewport.clone().get() } @@ -520,7 +523,7 @@ impl Window { } #[cfg(feature = "webxr")] - pub fn webxr_registry(&self) -> Option<webxr_api::Registry> { + pub(crate) fn webxr_registry(&self) -> Option<webxr_api::Registry> { self.webxr_registry.clone() } @@ -529,7 +532,7 @@ impl Window { Worklet::new(self, WorkletGlobalScopeType::Paint) } - pub fn pending_image_notification(&self, response: PendingImageResponse) { + pub(crate) fn pending_image_notification(&self, response: PendingImageResponse) { //XXXjdm could be more efficient to send the responses to layout, // rather than making layout talk to the image cache to // obtain the same data. @@ -552,30 +555,34 @@ impl Window { } } - pub fn compositor_api(&self) -> &CrossProcessCompositorApi { + pub(crate) fn compositor_api(&self) -> &CrossProcessCompositorApi { &self.compositor_api } - pub fn get_userscripts_path(&self) -> Option<String> { + pub(crate) fn get_userscripts_path(&self) -> Option<String> { self.userscripts_path.clone() } - pub fn replace_surrogates(&self) -> bool { + pub(crate) fn replace_surrogates(&self) -> bool { self.replace_surrogates } - pub fn get_player_context(&self) -> WindowGLContext { + pub(crate) fn get_player_context(&self) -> WindowGLContext { self.player_context.clone() } // see note at https://dom.spec.whatwg.org/#concept-event-dispatch step 2 - pub fn dispatch_event_with_target_override(&self, event: &Event, can_gc: CanGc) -> EventStatus { + pub(crate) fn dispatch_event_with_target_override( + &self, + event: &Event, + can_gc: CanGc, + ) -> EventStatus { event.dispatch(self.upcast(), true, can_gc) } } // https://html.spec.whatwg.org/multipage/#atob -pub fn base64_btoa(input: DOMString) -> Fallible<DOMString> { +pub(crate) fn base64_btoa(input: DOMString) -> Fallible<DOMString> { // "The btoa() method must throw an InvalidCharacterError exception if // the method's first argument contains any character whose code point // is greater than U+00FF." @@ -598,7 +605,7 @@ pub fn base64_btoa(input: DOMString) -> Fallible<DOMString> { } // https://html.spec.whatwg.org/multipage/#atob -pub fn base64_atob(input: DOMString) -> Fallible<DOMString> { +pub(crate) fn base64_atob(input: DOMString) -> Fallible<DOMString> { // "Remove all space characters from input." fn is_html_space(c: char) -> bool { HTML_SPACE_CHARACTERS.iter().any(|&m| m == c) @@ -1598,7 +1605,7 @@ impl Window { // https://heycam.github.io/webidl/#named-properties-object // https://html.spec.whatwg.org/multipage/#named-access-on-the-window-object #[allow(unsafe_code)] - pub fn create_named_properties_object( + pub(crate) fn create_named_properties_object( cx: JSContext, proto: HandleObject, object: MutableHandleObject, @@ -1648,15 +1655,15 @@ impl Window { } // https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet - pub fn paint_worklet(&self) -> DomRoot<Worklet> { + pub(crate) fn paint_worklet(&self) -> DomRoot<Worklet> { self.paint_worklet.or_init(|| self.new_paint_worklet()) } - pub fn has_document(&self) -> bool { + pub(crate) fn has_document(&self) -> bool { self.document.get().is_some() } - pub fn clear_js_runtime(&self) { + pub(crate) fn clear_js_runtime(&self) { self.as_global_scope() .remove_web_messaging_and_dedicated_workers_infra(); @@ -1703,7 +1710,7 @@ impl Window { } /// <https://drafts.csswg.org/cssom-view/#dom-window-scroll> - pub fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior, can_gc: CanGc) { + pub(crate) fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior, can_gc: CanGc) { // Step 3 let xfinite = if x_.is_finite() { x_ } else { 0.0f64 }; let yfinite = if y_.is_finite() { y_ } else { 0.0f64 }; @@ -1747,7 +1754,7 @@ impl Window { } /// <https://drafts.csswg.org/cssom-view/#perform-a-scroll> - pub fn perform_a_scroll( + pub(crate) fn perform_a_scroll( &self, x: f32, y: f32, @@ -1768,13 +1775,13 @@ impl Window { ); } - pub fn update_viewport_for_scroll(&self, x: f32, y: f32) { + pub(crate) fn update_viewport_for_scroll(&self, x: f32, y: f32) { let size = self.current_viewport.get().size; let new_viewport = Rect::new(Point2D::new(Au::from_f32_px(x), Au::from_f32_px(y)), size); self.current_viewport.set(new_viewport) } - pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { + pub(crate) fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel> { self.window_size.get().device_pixel_ratio } @@ -1796,7 +1803,7 @@ impl Window { /// Prepares to tick animations and then does a reflow which also advances the /// layout animation clock. #[allow(unsafe_code)] - pub fn advance_animation_clock(&self, delta_ms: i32) { + pub(crate) fn advance_animation_clock(&self, delta_ms: i32) { self.Document() .advance_animation_timeline_for_testing(delta_ms as f64 / 1000.); ScriptThread::handle_tick_all_animations_for_testing(self.pipeline_id()); @@ -2120,11 +2127,11 @@ impl Window { let _ = receiver.recv(); } - pub fn layout_reflow(&self, query_msg: QueryMsg, can_gc: CanGc) -> bool { + pub(crate) fn layout_reflow(&self, query_msg: QueryMsg, can_gc: CanGc) -> bool { self.reflow(ReflowGoal::LayoutQuery(query_msg), can_gc) } - pub fn resolved_font_style_query( + pub(crate) fn resolved_font_style_query( &self, node: &Node, value: String, @@ -2144,21 +2151,21 @@ impl Window { ) } - pub fn content_box_query(&self, node: &Node, can_gc: CanGc) -> Option<UntypedRect<Au>> { + pub(crate) fn content_box_query(&self, node: &Node, can_gc: CanGc) -> Option<UntypedRect<Au>> { if !self.layout_reflow(QueryMsg::ContentBox, can_gc) { return None; } self.layout.borrow().query_content_box(node.to_opaque()) } - pub fn content_boxes_query(&self, node: &Node, can_gc: CanGc) -> Vec<UntypedRect<Au>> { + pub(crate) fn content_boxes_query(&self, node: &Node, can_gc: CanGc) -> Vec<UntypedRect<Au>> { if !self.layout_reflow(QueryMsg::ContentBoxes, can_gc) { return vec![]; } self.layout.borrow().query_content_boxes(node.to_opaque()) } - pub fn client_rect_query(&self, node: &Node, can_gc: CanGc) -> UntypedRect<i32> { + pub(crate) fn client_rect_query(&self, node: &Node, can_gc: CanGc) -> UntypedRect<i32> { if !self.layout_reflow(QueryMsg::ClientRectQuery, can_gc) { return Rect::zero(); } @@ -2167,7 +2174,11 @@ impl Window { /// Find the scroll area of the given node, if it is not None. If the node /// is None, find the scroll area of the viewport. - pub fn scrolling_area_query(&self, node: Option<&Node>, can_gc: CanGc) -> UntypedRect<i32> { + pub(crate) fn scrolling_area_query( + &self, + node: Option<&Node>, + can_gc: CanGc, + ) -> UntypedRect<i32> { let opaque = node.map(|node| node.to_opaque()); if !self.layout_reflow(QueryMsg::ScrollingAreaQuery, can_gc) { return Rect::zero(); @@ -2175,7 +2186,7 @@ impl Window { self.layout.borrow().query_scrolling_area(opaque) } - pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32, LayoutPixel> { + pub(crate) fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32, LayoutPixel> { if let Some(scroll_offset) = self.scroll_offsets.borrow().get(&node.to_opaque()) { return *scroll_offset; } @@ -2183,7 +2194,7 @@ impl Window { } // https://drafts.csswg.org/cssom-view/#element-scrolling-members - pub fn scroll_node( + pub(crate) fn scroll_node( &self, node: &Node, x_: f64, @@ -2213,7 +2224,7 @@ impl Window { ); } - pub fn resolved_style_query( + pub(crate) fn resolved_style_query( &self, element: TrustedNodeAddress, pseudo: Option<PseudoElement>, @@ -2252,7 +2263,7 @@ impl Window { } #[allow(unsafe_code)] - pub fn offset_parent_query( + pub(crate) fn offset_parent_query( &self, node: &Node, can_gc: CanGc, @@ -2269,7 +2280,7 @@ impl Window { (element, response.rect) } - pub fn text_index_query( + pub(crate) fn text_index_query( &self, node: &Node, point_in_node: UntypedPoint2D<f32>, @@ -2284,13 +2295,13 @@ impl Window { } #[allow(unsafe_code)] - pub fn init_window_proxy(&self, window_proxy: &WindowProxy) { + pub(crate) fn init_window_proxy(&self, window_proxy: &WindowProxy) { assert!(self.window_proxy.get().is_none()); self.window_proxy.set(Some(window_proxy)); } #[allow(unsafe_code)] - pub fn init_document(&self, document: &Document) { + pub(crate) fn init_document(&self, document: &Document) { assert!(self.document.get().is_none()); assert!(document.window() == self); self.document.set(Some(document)); @@ -2303,7 +2314,7 @@ impl Window { /// Commence a new URL load which will either replace this window or scroll to a fragment. /// /// <https://html.spec.whatwg.org/multipage/#navigating-across-documents> - pub fn load_url( + pub(crate) fn load_url( &self, history_handling: NavigationHistoryBehavior, force_reload: bool, @@ -2407,11 +2418,11 @@ impl Window { }; } - pub fn set_window_size(&self, size: WindowSizeData) { + pub(crate) fn set_window_size(&self, size: WindowSizeData) { self.window_size.set(size); } - pub fn window_size(&self) -> WindowSizeData { + pub(crate) fn window_size(&self) -> WindowSizeData { self.window_size.get() } @@ -2429,25 +2440,25 @@ impl Window { self.Document().set_needs_paint(true); } - pub fn get_url(&self) -> ServoUrl { + pub(crate) fn get_url(&self) -> ServoUrl { self.Document().url() } - pub fn windowproxy_handler(&self) -> &'static WindowProxyHandler { + pub(crate) fn windowproxy_handler(&self) -> &'static WindowProxyHandler { self.dom_static.windowproxy_handler } - pub fn add_resize_event(&self, event: WindowSizeData, event_type: WindowSizeType) { + pub(crate) fn add_resize_event(&self, event: WindowSizeData, event_type: WindowSizeType) { // Whenever we receive a new resize event we forget about all the ones that came before // it, to avoid unnecessary relayouts *self.unhandled_resize_event.borrow_mut() = Some((event, event_type)) } - pub fn take_unhandled_resize_event(&self) -> Option<(WindowSizeData, WindowSizeType)> { + pub(crate) fn take_unhandled_resize_event(&self) -> Option<(WindowSizeData, WindowSizeType)> { self.unhandled_resize_event.borrow_mut().take() } - pub fn set_page_clip_rect_with_new_viewport(&self, viewport: UntypedRect<f32>) -> bool { + pub(crate) fn set_page_clip_rect_with_new_viewport(&self, viewport: UntypedRect<f32>) -> bool { let rect = f32_rect_to_au_rect(viewport); self.current_viewport.set(rect); // We use a clipping rectangle that is five times the size of the of the viewport, @@ -2479,7 +2490,7 @@ impl Window { had_clip_rect } - pub fn suspend(&self) { + pub(crate) fn suspend(&self) { // Suspend timer events. self.as_global_scope().suspend(); @@ -2495,7 +2506,7 @@ impl Window { self.Gc(); } - pub fn resume(&self) { + pub(crate) fn resume(&self) { // Resume timer events. self.as_global_scope().resume(); @@ -2507,18 +2518,18 @@ impl Window { self.Document().title_changed(); } - pub fn need_emit_timeline_marker(&self, timeline_type: TimelineMarkerType) -> bool { + pub(crate) fn need_emit_timeline_marker(&self, timeline_type: TimelineMarkerType) -> bool { let markers = self.devtools_markers.borrow(); markers.contains(&timeline_type) } - pub fn emit_timeline_marker(&self, marker: TimelineMarker) { + pub(crate) fn emit_timeline_marker(&self, marker: TimelineMarker) { let sender = self.devtools_marker_sender.borrow(); let sender = sender.as_ref().expect("There is no marker sender"); sender.send(Some(marker)).unwrap(); } - pub fn set_devtools_timeline_markers( + pub(crate) fn set_devtools_timeline_markers( &self, markers: Vec<TimelineMarkerType>, reply: IpcSender<Option<TimelineMarker>>, @@ -2527,7 +2538,7 @@ impl Window { self.devtools_markers.borrow_mut().extend(markers); } - pub fn drop_devtools_timeline_markers(&self, markers: Vec<TimelineMarkerType>) { + pub(crate) fn drop_devtools_timeline_markers(&self, markers: Vec<TimelineMarkerType>) { let mut devtools_markers = self.devtools_markers.borrow_mut(); for marker in markers { devtools_markers.remove(&marker); @@ -2537,16 +2548,16 @@ impl Window { } } - pub fn set_webdriver_script_chan(&self, chan: Option<IpcSender<WebDriverJSResult>>) { + pub(crate) fn set_webdriver_script_chan(&self, chan: Option<IpcSender<WebDriverJSResult>>) { *self.webdriver_script_chan.borrow_mut() = chan; } - pub fn is_alive(&self) -> bool { + pub(crate) fn is_alive(&self) -> bool { self.current_state.get() == WindowState::Alive } // https://html.spec.whatwg.org/multipage/#top-level-browsing-context - pub fn is_top_level(&self) -> bool { + pub(crate) fn is_top_level(&self) -> bool { self.parent_info.is_none() } @@ -2594,7 +2605,7 @@ impl Window { /// Evaluate media query lists and report changes /// <https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes> - pub fn evaluate_media_queries_and_report_changes(&self, can_gc: CanGc) { + pub(crate) fn evaluate_media_queries_and_report_changes(&self, can_gc: CanGc) { let _realm = enter_realm(self); rooted_vec!(let mut mql_list); @@ -2622,7 +2633,7 @@ impl Window { } /// Set whether to use less resources by running timers at a heavily limited rate. - pub fn set_throttled(&self, throttled: bool) { + pub(crate) fn set_throttled(&self, throttled: bool) { self.throttled.set(throttled); if throttled { self.as_global_scope().slow_down_timers(); @@ -2631,39 +2642,39 @@ impl Window { } } - pub fn throttled(&self) -> bool { + pub(crate) fn throttled(&self) -> bool { self.throttled.get() } - pub fn unminified_css_dir(&self) -> Option<String> { + pub(crate) fn unminified_css_dir(&self) -> Option<String> { self.unminified_css_dir.borrow().clone() } - pub fn local_script_source(&self) -> &Option<String> { + pub(crate) fn local_script_source(&self) -> &Option<String> { &self.local_script_source } - pub fn set_navigation_start(&self) { + pub(crate) fn set_navigation_start(&self) { self.navigation_start.set(CrossProcessInstant::now()); } - pub fn send_to_embedder(&self, msg: EmbedderMsg) { + pub(crate) fn send_to_embedder(&self, msg: EmbedderMsg) { self.send_to_constellation(ScriptMsg::ForwardToEmbedder(msg)); } - pub fn send_to_constellation(&self, msg: ScriptMsg) { + pub(crate) fn send_to_constellation(&self, msg: ScriptMsg) { self.as_global_scope() .script_to_constellation_chan() .send(msg) .unwrap(); } - pub fn webrender_document(&self) -> DocumentId { + pub(crate) fn webrender_document(&self) -> DocumentId { self.webrender_document } #[cfg(feature = "webxr")] - pub fn in_immersive_xr_session(&self) -> bool { + pub(crate) fn in_immersive_xr_session(&self) -> bool { self.navigator .get() .as_ref() @@ -2672,7 +2683,7 @@ impl Window { } #[cfg(not(feature = "webxr"))] - pub fn in_immersive_xr_session(&self) -> bool { + pub(crate) fn in_immersive_xr_session(&self) -> bool { false } } @@ -2813,7 +2824,7 @@ impl Window { } /// Create a new cached instance of the given value. - pub fn cache_layout_value<T>(&self, value: T) -> LayoutValue<T> + pub(crate) fn cache_layout_value<T>(&self, value: T) -> LayoutValue<T> where T: Copy + MallocSizeOf, { @@ -2826,7 +2837,7 @@ impl Window { /// valid. It will automatically become unavailable when the next layout operation is /// performed. #[derive(MallocSizeOf)] -pub struct LayoutValue<T: MallocSizeOf> { +pub(crate) struct LayoutValue<T: MallocSizeOf> { #[ignore_malloc_size_of = "Rc is hard"] is_valid: Rc<Cell<bool>>, value: T, @@ -2848,7 +2859,7 @@ impl<T: Copy + MallocSizeOf> LayoutValue<T> { } /// Retrieve the stored value if it is still valid. - pub fn get(&self) -> Result<T, ()> { + pub(crate) fn get(&self) -> Result<T, ()> { if self.is_valid.get() { return Ok(self.value); } @@ -2905,7 +2916,7 @@ fn debug_reflow_events(id: PipelineId, reflow_goal: &ReflowGoal) { impl Window { // https://html.spec.whatwg.org/multipage/#dom-window-postmessage step 7. - pub fn post_message( + pub(crate) fn post_message( &self, target_origin: Option<ImmutableOrigin>, source_origin: ImmutableOrigin, @@ -2960,13 +2971,13 @@ impl Window { } #[derive(Clone, MallocSizeOf)] -pub struct CSSErrorReporter { - pub pipelineid: PipelineId, +pub(crate) struct CSSErrorReporter { + pub(crate) pipelineid: PipelineId, // Arc+Mutex combo is necessary to make this struct Sync, // which is necessary to fulfill the bounds required by the // uses of the ParseErrorReporter trait. #[ignore_malloc_size_of = "Arc is defined in libstd"] - pub script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>, + pub(crate) script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>, } unsafe_no_jsmanaged_fields!(CSSErrorReporter); diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index 7637227ac74..a4659eedf9d 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -62,7 +62,7 @@ use crate::script_thread::ScriptThread; // here, in script, but also in the constellation. The constellation // manages the session history, which in script is accessed through // History objects, messaging the constellation. -pub struct WindowProxy { +pub(crate) struct WindowProxy { /// The JS WindowProxy object. /// Unlike other reflectors, we mutate this field because /// we have to brain-transplant the reflector when the WindowProxy @@ -159,7 +159,7 @@ impl WindowProxy { } #[allow(unsafe_code)] - pub fn new( + pub(crate) fn new( window: &Window, browsing_context_id: BrowsingContextId, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -219,7 +219,7 @@ impl WindowProxy { } #[allow(unsafe_code)] - pub fn new_dissimilar_origin( + pub(crate) fn new_dissimilar_origin( global_to_clone_from: &GlobalScope, browsing_context_id: BrowsingContextId, top_level_browsing_context_id: TopLevelBrowsingContextId, @@ -352,17 +352,17 @@ impl WindowProxy { } /// <https://html.spec.whatwg.org/multipage/#delaying-load-events-mode> - pub fn is_delaying_load_events_mode(&self) -> bool { + pub(crate) fn is_delaying_load_events_mode(&self) -> bool { self.delaying_load_events_mode.get() } /// <https://html.spec.whatwg.org/multipage/#delaying-load-events-mode> - pub fn start_delaying_load_events_mode(&self) { + pub(crate) fn start_delaying_load_events_mode(&self) { self.delaying_load_events_mode.set(true); } /// <https://html.spec.whatwg.org/multipage/#delaying-load-events-mode> - pub fn stop_delaying_load_events_mode(&self) { + pub(crate) fn stop_delaying_load_events_mode(&self) { self.delaying_load_events_mode.set(false); if let Some(document) = self.document() { if !document.loader().events_inhibited() { @@ -372,51 +372,51 @@ impl WindowProxy { } // https://html.spec.whatwg.org/multipage/#disowned-its-opener - pub fn disown(&self) { + pub(crate) fn disown(&self) { self.disowned.set(true); } /// <https://html.spec.whatwg.org/multipage/#dom-window-close> /// Step 3.1, set BCs `is_closing` to true. - pub fn close(&self) { + pub(crate) fn close(&self) { self.is_closing.set(true); } /// <https://html.spec.whatwg.org/multipage/#is-closing> - pub fn is_closing(&self) -> bool { + pub(crate) fn is_closing(&self) -> bool { self.is_closing.get() } /// <https://html.spec.whatwg.org/multipage/#creator-base-url> - pub fn creator_base_url(&self) -> Option<ServoUrl> { + pub(crate) fn creator_base_url(&self) -> Option<ServoUrl> { self.creator_base_url.clone() } - pub fn has_creator_base_url(&self) -> bool { + pub(crate) fn has_creator_base_url(&self) -> bool { self.creator_base_url.is_some() } /// <https://html.spec.whatwg.org/multipage/#creator-url> - pub fn creator_url(&self) -> Option<ServoUrl> { + pub(crate) fn creator_url(&self) -> Option<ServoUrl> { self.creator_url.clone() } - pub fn has_creator_url(&self) -> bool { + pub(crate) fn has_creator_url(&self) -> bool { self.creator_base_url.is_some() } /// <https://html.spec.whatwg.org/multipage/#creator-origin> - pub fn creator_origin(&self) -> Option<ImmutableOrigin> { + pub(crate) fn creator_origin(&self) -> Option<ImmutableOrigin> { self.creator_origin.clone() } - pub fn has_creator_origin(&self) -> bool { + pub(crate) fn has_creator_origin(&self) -> bool { self.creator_origin.is_some() } #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-opener - pub fn opener( + pub(crate) fn opener( &self, cx: *mut JSContext, in_realm_proof: InRealm, @@ -463,7 +463,7 @@ impl WindowProxy { } // https://html.spec.whatwg.org/multipage/#window-open-steps - pub fn open( + pub(crate) fn open( &self, url: USVString, target: DOMString, @@ -543,7 +543,7 @@ impl WindowProxy { } // https://html.spec.whatwg.org/multipage/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name - pub fn choose_browsing_context( + pub(crate) fn choose_browsing_context( &self, name: DOMString, noopener: bool, @@ -578,41 +578,41 @@ impl WindowProxy { } } - pub fn is_auxiliary(&self) -> bool { + pub(crate) fn is_auxiliary(&self) -> bool { self.opener.is_some() } - pub fn discard_browsing_context(&self) { + pub(crate) fn discard_browsing_context(&self) { self.discarded.set(true); } - pub fn is_browsing_context_discarded(&self) -> bool { + pub(crate) fn is_browsing_context_discarded(&self) -> bool { self.discarded.get() } - pub fn browsing_context_id(&self) -> BrowsingContextId { + pub(crate) fn browsing_context_id(&self) -> BrowsingContextId { self.browsing_context_id } - pub fn top_level_browsing_context_id(&self) -> TopLevelBrowsingContextId { + pub(crate) fn top_level_browsing_context_id(&self) -> TopLevelBrowsingContextId { self.top_level_browsing_context_id } - pub fn frame_element(&self) -> Option<&Element> { + pub(crate) fn frame_element(&self) -> Option<&Element> { self.frame_element.as_deref() } - pub fn document(&self) -> Option<DomRoot<Document>> { + pub(crate) fn document(&self) -> Option<DomRoot<Document>> { self.currently_active .get() .and_then(ScriptThread::find_document) } - pub fn parent(&self) -> Option<&WindowProxy> { + pub(crate) fn parent(&self) -> Option<&WindowProxy> { self.parent.as_deref() } - pub fn top(&self) -> &WindowProxy { + pub(crate) fn top(&self) -> &WindowProxy { let mut result = self; while let Some(parent) = result.parent() { result = parent; @@ -674,7 +674,7 @@ impl WindowProxy { } } - pub fn set_currently_active(&self, window: &Window) { + pub(crate) fn set_currently_active(&self, window: &Window) { if let Some(pipeline_id) = self.currently_active() { if pipeline_id == window.pipeline_id() { return debug!( @@ -688,7 +688,7 @@ impl WindowProxy { self.currently_active.set(Some(global_scope.pipeline_id())); } - pub fn unset_currently_active(&self) { + pub(crate) fn unset_currently_active(&self) { if self.currently_active().is_none() { return debug!("Attempt to unset the currently active window on a windowproxy that does not have one."); } @@ -701,15 +701,15 @@ impl WindowProxy { self.currently_active.set(None); } - pub fn currently_active(&self) -> Option<PipelineId> { + pub(crate) fn currently_active(&self) -> Option<PipelineId> { self.currently_active.get() } - pub fn get_name(&self) -> DOMString { + pub(crate) fn get_name(&self) -> DOMString { self.name.borrow().clone() } - pub fn set_name(&self, name: DOMString) { + pub(crate) fn set_name(&self, name: DOMString) { *self.name.borrow_mut() = name; } } @@ -726,7 +726,7 @@ impl WindowProxy { /// /// See: <https://html.spec.whatwg.org/multipage/#creating-browsing-contexts> #[derive(Debug, Deserialize, Serialize)] -pub struct CreatorBrowsingContextInfo { +pub(crate) struct CreatorBrowsingContextInfo { /// Creator document URL. url: Option<ServoUrl>, @@ -738,7 +738,7 @@ pub struct CreatorBrowsingContextInfo { } impl CreatorBrowsingContextInfo { - pub fn from( + pub(crate) fn from( parent: Option<&WindowProxy>, opener: Option<&WindowProxy>, ) -> CreatorBrowsingContextInfo { @@ -1081,7 +1081,7 @@ static PROXY_TRAPS: ProxyTraps = ProxyTraps { /// Proxy handler for a WindowProxy. /// Has ownership of the inner pointer and deallocates it when it is no longer needed. -pub struct WindowProxyHandler(*const libc::c_void); +pub(crate) struct WindowProxyHandler(*const libc::c_void); impl MallocSizeOf for WindowProxyHandler { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { @@ -1107,7 +1107,7 @@ impl WindowProxyHandler { } /// Returns a single, shared WindowProxyHandler that contains XORIGIN_PROXY_TRAPS. - pub fn x_origin_proxy_handler() -> &'static Self { + pub(crate) fn x_origin_proxy_handler() -> &'static Self { use std::sync::OnceLock; /// We are sharing a single instance for the entire programs here due to lifetime issues. /// The pointer in self.0 is known to C++ and visited by the GC. Hence, we don't know when @@ -1119,7 +1119,7 @@ impl WindowProxyHandler { } /// Returns a single, shared WindowProxyHandler that contains normal PROXY_TRAPS. - pub fn proxy_handler() -> &'static Self { + pub(crate) fn proxy_handler() -> &'static Self { use std::sync::OnceLock; /// We are sharing a single instance for the entire programs here due to lifetime issues. /// The pointer in self.0 is known to C++ and visited by the GC. Hence, we don't know when @@ -1132,7 +1132,7 @@ impl WindowProxyHandler { /// Creates a new WindowProxy object on the C++ side and returns the pointer to it. /// The pointer should be owned by the GC. - pub fn new_window_proxy( + pub(crate) fn new_window_proxy( &self, cx: &crate::script_runtime::JSContext, window_jsobject: js::gc::HandleObject, diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 0370161582a..9c3525c9aa3 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -41,11 +41,11 @@ use crate::realms::enter_realm; use crate::script_runtime::{CanGc, JSContext, ThreadSafeJSContext}; use crate::task::TaskOnce; -pub type TrustedWorkerAddress = Trusted<Worker>; +pub(crate) type TrustedWorkerAddress = Trusted<Worker>; // https://html.spec.whatwg.org/multipage/#worker #[dom_struct] -pub struct Worker { +pub(crate) struct Worker { eventtarget: EventTarget, /// Sender to the Receiver associated with the DedicatedWorkerGlobalScope /// this Worker created. @@ -84,11 +84,11 @@ impl Worker { ) } - pub fn is_terminated(&self) -> bool { + pub(crate) fn is_terminated(&self) -> bool { self.terminated.get() } - pub fn set_context_for_interrupt(&self, cx: ThreadSafeJSContext) { + pub(crate) fn set_context_for_interrupt(&self, cx: ThreadSafeJSContext) { assert!( self.context_for_interrupt.borrow().is_none(), "Context for interrupt must be set only once" @@ -96,7 +96,7 @@ impl Worker { *self.context_for_interrupt.borrow_mut() = Some(cx); } - pub fn handle_message( + pub(crate) fn handle_message( address: TrustedWorkerAddress, data: StructuredSerializedData, can_gc: CanGc, @@ -127,7 +127,7 @@ impl Worker { } } - pub fn dispatch_simple_error(address: TrustedWorkerAddress, can_gc: CanGc) { + pub(crate) fn dispatch_simple_error(address: TrustedWorkerAddress, can_gc: CanGc) { let worker = address.root(); worker.upcast().fire_event(atom!("error"), can_gc); } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index d7b353e0644..80654a9826a 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -62,7 +62,7 @@ use crate::script_runtime::{CanGc, JSContext, Runtime}; use crate::task::TaskCanceller; use crate::timers::{IsInterval, TimerCallback}; -pub fn prepare_workerscope_init( +pub(crate) fn prepare_workerscope_init( global: &GlobalScope, devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>, worker_id: Option<WorkerId>, @@ -88,7 +88,7 @@ pub fn prepare_workerscope_init( // https://html.spec.whatwg.org/multipage/#the-workerglobalscope-common-interface #[dom_struct] -pub struct WorkerGlobalScope { +pub(crate) struct WorkerGlobalScope { globalscope: GlobalScope, worker_name: DOMString, @@ -131,7 +131,7 @@ pub struct WorkerGlobalScope { impl WorkerGlobalScope { #[allow(clippy::too_many_arguments)] - pub fn new_inherited( + pub(crate) fn new_inherited( init: WorkerGlobalScopeInit, worker_name: DOMString, worker_type: WorkerType, @@ -185,7 +185,7 @@ impl WorkerGlobalScope { } /// Clear various items when the worker event-loop shuts-down. - pub fn clear_js_runtime(&self) { + pub(crate) fn clear_js_runtime(&self) { self.upcast::<GlobalScope>() .remove_web_messaging_and_dedicated_workers_infra(); @@ -194,7 +194,7 @@ impl WorkerGlobalScope { drop(runtime); } - pub fn runtime_handle(&self) -> ParentRuntime { + pub(crate) fn runtime_handle(&self) -> ParentRuntime { self.runtime .borrow() .as_ref() @@ -202,36 +202,36 @@ impl WorkerGlobalScope { .prepare_for_new_child() } - pub fn devtools_receiver(&self) -> Option<&Receiver<DevtoolScriptControlMsg>> { + pub(crate) fn devtools_receiver(&self) -> Option<&Receiver<DevtoolScriptControlMsg>> { self.devtools_receiver.as_ref() } #[allow(unsafe_code)] - pub fn get_cx(&self) -> JSContext { + pub(crate) fn get_cx(&self) -> JSContext { unsafe { JSContext::from_ptr(self.runtime.borrow().as_ref().unwrap().cx()) } } - pub fn is_closing(&self) -> bool { + pub(crate) fn is_closing(&self) -> bool { self.closing.load(Ordering::SeqCst) } - pub fn get_url(&self) -> Ref<ServoUrl> { + pub(crate) fn get_url(&self) -> Ref<ServoUrl> { self.worker_url.borrow() } - pub fn set_url(&self, url: ServoUrl) { + pub(crate) fn set_url(&self, url: ServoUrl) { *self.worker_url.borrow_mut() = url; } - pub fn get_worker_id(&self) -> WorkerId { + pub(crate) fn get_worker_id(&self) -> WorkerId { self.worker_id } - pub fn pipeline_id(&self) -> PipelineId { + pub(crate) fn pipeline_id(&self) -> PipelineId { self.globalscope.pipeline_id() } - pub fn policy_container(&self) -> Ref<PolicyContainer> { + pub(crate) fn policy_container(&self) -> Ref<PolicyContainer> { self.policy_container.borrow() } @@ -464,7 +464,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope { impl WorkerGlobalScope { #[allow(unsafe_code)] - pub fn execute_script(&self, source: DOMString, can_gc: CanGc) { + pub(crate) fn execute_script(&self, source: DOMString, can_gc: CanGc) { let _aes = AutoEntryScript::new(self.upcast()); let cx = self.runtime.borrow().as_ref().unwrap().cx(); rooted!(in(cx) let mut rval = UndefinedValue()); @@ -505,7 +505,7 @@ impl WorkerGlobalScope { /// in the queue for this worker event-loop. /// Returns a boolean indicating whether further events should be processed. #[allow(unsafe_code)] - pub fn process_event(&self, msg: CommonScriptMsg) -> bool { + pub(crate) fn process_event(&self, msg: CommonScriptMsg) -> bool { if self.is_closing() { return false; } @@ -520,7 +520,7 @@ impl WorkerGlobalScope { true } - pub fn close(&self) { + pub(crate) fn close(&self) { self.closing.store(true, Ordering::SeqCst); self.upcast::<GlobalScope>() .task_manager() diff --git a/components/script/dom/workerlocation.rs b/components/script/dom/workerlocation.rs index 6dce917684f..0d11b0038c6 100644 --- a/components/script/dom/workerlocation.rs +++ b/components/script/dom/workerlocation.rs @@ -15,7 +15,7 @@ use crate::script_runtime::CanGc; // https://html.spec.whatwg.org/multipage/#worker-locations #[dom_struct] -pub struct WorkerLocation { +pub(crate) struct WorkerLocation { reflector_: Reflector, #[no_trace] url: ServoUrl, @@ -29,7 +29,7 @@ impl WorkerLocation { } } - pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> DomRoot<WorkerLocation> { + pub(crate) fn new(global: &WorkerGlobalScope, url: ServoUrl) -> DomRoot<WorkerLocation> { reflect_dom_object( Box::new(WorkerLocation::new_inherited(url)), global, @@ -39,7 +39,7 @@ impl WorkerLocation { // https://html.spec.whatwg.org/multipage/#dom-workerlocation-origin #[allow(dead_code)] - pub fn origin(&self) -> ImmutableOrigin { + pub(crate) fn origin(&self) -> ImmutableOrigin { self.url.origin() } } diff --git a/components/script/dom/workernavigator.rs b/components/script/dom/workernavigator.rs index 71f09168644..42201cc4bbc 100644 --- a/components/script/dom/workernavigator.rs +++ b/components/script/dom/workernavigator.rs @@ -20,7 +20,7 @@ use crate::script_runtime::{CanGc, JSContext}; // https://html.spec.whatwg.org/multipage/#workernavigator #[dom_struct] -pub struct WorkerNavigator { +pub(crate) struct WorkerNavigator { reflector_: Reflector, permissions: MutNullableDom<Permissions>, #[cfg(feature = "webgpu")] @@ -37,7 +37,7 @@ impl WorkerNavigator { } } - pub fn new(global: &WorkerGlobalScope) -> DomRoot<WorkerNavigator> { + pub(crate) fn new(global: &WorkerGlobalScope) -> DomRoot<WorkerNavigator> { reflect_dom_object( Box::new(WorkerNavigator::new_inherited()), global, diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index 1d47c646dd5..efa2f34aa62 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -80,7 +80,7 @@ impl Drop for DroppableField { #[dom_struct] /// <https://drafts.css-houdini.org/worklets/#worklet> -pub struct Worklet { +pub(crate) struct Worklet { reflector: Reflector, window: Dom<Window>, global_type: WorkletGlobalScopeType, @@ -100,7 +100,7 @@ impl Worklet { } } - pub fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { + pub(crate) fn new(window: &Window, global_type: WorkletGlobalScopeType) -> DomRoot<Worklet> { debug!("Creating worklet {:?}.", global_type); reflect_dom_object( Box::new(Worklet::new_inherited(window, global_type)), @@ -109,12 +109,12 @@ impl Worklet { ) } - pub fn worklet_id(&self) -> WorkletId { + pub(crate) fn worklet_id(&self) -> WorkletId { self.droppable_field.worklet_id } #[allow(dead_code)] - pub fn worklet_global_scope_type(&self) -> WorkletGlobalScopeType { + pub(crate) fn worklet_global_scope_type(&self) -> WorkletGlobalScopeType { self.global_type } } @@ -169,7 +169,7 @@ impl WorkletMethods<crate::DomTypeHolder> for Worklet { /// A guid for worklets. #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] -pub struct WorkletId(#[no_trace] Uuid); +pub(crate) struct WorkletId(#[no_trace] Uuid); malloc_size_of_is_0!(WorkletId); @@ -249,7 +249,7 @@ impl PendingTasksStruct { /// by a backup thread, not by the primary thread. #[derive(Clone, JSTraceable)] -pub struct WorkletThreadPool { +pub(crate) struct WorkletThreadPool { // Channels to send data messages to the three roles. #[no_trace] primary_sender: Sender<WorkletData>, @@ -350,7 +350,7 @@ impl WorkletThreadPool { } /// For testing. - pub fn test_worklet_lookup(&self, id: WorkletId, key: String) -> Option<String> { + pub(crate) fn test_worklet_lookup(&self, id: WorkletId, key: String) -> Option<String> { let (sender, receiver) = unbounded(); let msg = WorkletData::Task(id, WorkletTask::Test(TestWorkletTask::Lookup(key, sender))); let _ = self.primary_sender.send(msg); @@ -766,7 +766,7 @@ impl WorkletThread { /// An executor of worklet tasks #[derive(Clone, JSTraceable, MallocSizeOf)] -pub struct WorkletExecutor { +pub(crate) struct WorkletExecutor { worklet_id: WorkletId, #[no_trace] primary_sender: Sender<WorkletData>, @@ -781,7 +781,7 @@ impl WorkletExecutor { } /// Schedule a worklet task to be peformed by the worklet thread pool. - pub fn schedule_a_worklet_task(&self, task: WorkletTask) { + pub(crate) fn schedule_a_worklet_task(&self, task: WorkletTask) { let _ = self .primary_sender .send(WorkletData::Task(self.worklet_id, task)); diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs index c6c6361ba25..629bcd9a470 100644 --- a/components/script/dom/workletglobalscope.rs +++ b/components/script/dom/workletglobalscope.rs @@ -34,7 +34,7 @@ use crate::script_runtime::{CanGc, JSContext}; #[dom_struct] /// <https://drafts.css-houdini.org/worklets/#workletglobalscope> -pub struct WorkletGlobalScope { +pub(crate) struct WorkletGlobalScope { /// The global for this worklet. globalscope: GlobalScope, /// The base URL for this worklet. @@ -110,12 +110,12 @@ impl WorkletGlobalScope { } /// Get the JS context. - pub fn get_cx() -> JSContext { + pub(crate) fn get_cx() -> JSContext { GlobalScope::get_cx() } /// Evaluate a JS script in this global. - pub fn evaluate_js(&self, script: &str, can_gc: CanGc) -> bool { + pub(crate) fn evaluate_js(&self, script: &str, can_gc: CanGc) -> bool { debug!("Evaluating Dom in a worklet."); rooted!(in (*GlobalScope::get_cx()) let mut rval = UndefinedValue()); self.globalscope.evaluate_js_on_global_with_result( @@ -128,7 +128,7 @@ impl WorkletGlobalScope { } /// Register a paint worklet to the script thread. - pub fn register_paint_worklet( + pub(crate) fn register_paint_worklet( &self, name: Atom, properties: Vec<Atom>, @@ -145,17 +145,17 @@ impl WorkletGlobalScope { } /// The base URL of this global. - pub fn base_url(&self) -> ServoUrl { + pub(crate) fn base_url(&self) -> ServoUrl { self.base_url.clone() } /// The worklet executor. - pub fn executor(&self) -> WorkletExecutor { + pub(crate) fn executor(&self) -> WorkletExecutor { self.executor.clone() } /// Perform a worklet task - pub fn perform_a_worklet_task(&self, task: WorkletTask) { + pub(crate) fn perform_a_worklet_task(&self, task: WorkletTask) { match task { WorkletTask::Test(task) => match self.downcast::<TestWorkletGlobalScope>() { Some(global) => global.perform_a_worklet_task(task), @@ -173,33 +173,33 @@ impl WorkletGlobalScope { #[derive(Clone)] pub(crate) struct WorkletGlobalScopeInit { /// Channel to the main script thread - pub to_script_thread_sender: Sender<MainThreadScriptMsg>, + pub(crate) to_script_thread_sender: Sender<MainThreadScriptMsg>, /// Channel to a resource thread - pub resource_threads: ResourceThreads, + pub(crate) resource_threads: ResourceThreads, /// Channel to the memory profiler - pub mem_profiler_chan: mem::ProfilerChan, + pub(crate) mem_profiler_chan: mem::ProfilerChan, /// Channel to the time profiler - pub time_profiler_chan: time::ProfilerChan, + pub(crate) time_profiler_chan: time::ProfilerChan, /// Channel to devtools - pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, + pub(crate) devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, /// Messages to send to constellation - pub to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>, + pub(crate) to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>, /// The image cache - pub image_cache: Arc<dyn ImageCache>, + pub(crate) image_cache: Arc<dyn ImageCache>, /// True if in headless mode - pub is_headless: bool, + pub(crate) is_headless: bool, /// An optional string allowing the user agent to be set for testing - pub user_agent: Cow<'static, str>, + pub(crate) user_agent: Cow<'static, str>, /// Identity manager for WebGPU resources #[cfg(feature = "webgpu")] - pub gpu_id_hub: Arc<IdentityHub>, + pub(crate) gpu_id_hub: Arc<IdentityHub>, /// Is considered secure - pub inherited_secure_context: Option<bool>, + pub(crate) inherited_secure_context: Option<bool>, } /// <https://drafts.css-houdini.org/worklets/#worklet-global-scope-type> #[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)] -pub enum WorkletGlobalScopeType { +pub(crate) enum WorkletGlobalScopeType { /// A servo-specific testing worklet Test, /// A paint worklet @@ -207,7 +207,7 @@ pub enum WorkletGlobalScopeType { } /// A task which can be performed in the context of a worklet global. -pub enum WorkletTask { +pub(crate) enum WorkletTask { Test(TestWorkletTask), Paint(PaintWorkletTask), } diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs index ca50e0fb0b0..278ca246304 100644 --- a/components/script/dom/xmldocument.rs +++ b/components/script/dom/xmldocument.rs @@ -24,7 +24,7 @@ use crate::script_runtime::CanGc; // https://dom.spec.whatwg.org/#xmldocument #[dom_struct] -pub struct XMLDocument { +pub(crate) struct XMLDocument { document: Document, } @@ -63,7 +63,7 @@ impl XMLDocument { } #[allow(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( window: &Window, has_browsing_context: HasBrowsingContext, url: Option<ServoUrl>, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index c79671e2eee..451176af6d9 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -86,7 +86,7 @@ enum XMLHttpRequestState { } #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub struct GenerationId(u32); +pub(crate) struct GenerationId(u32); /// Closure of required data for each async network event that comprises the /// XHR's response. @@ -164,7 +164,7 @@ impl PreInvoke for XHRContext { } #[derive(Clone)] -pub enum XHRProgress { +pub(crate) enum XHRProgress { /// Notify that headers have been received HeadersReceived(GenerationId, Option<HeaderMap>, HttpStatus), /// Partial progress (after receiving headers), containing portion of the response @@ -187,7 +187,7 @@ impl XHRProgress { } #[dom_struct] -pub struct XMLHttpRequest { +pub(crate) struct XMLHttpRequest { eventtarget: XMLHttpRequestEventTarget, ready_state: Cell<XMLHttpRequestState>, timeout: Cell<Duration>, @@ -992,7 +992,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest { } } -pub type TrustedXHRAddress = Trusted<XMLHttpRequest>; +pub(crate) type TrustedXHRAddress = Trusted<XMLHttpRequest>; impl XMLHttpRequest { fn change_ready_state(&self, rs: XMLHttpRequestState, can_gc: CanGc) { @@ -1651,14 +1651,14 @@ impl XMLHttpRequest { } #[derive(JSTraceable, MallocSizeOf)] -pub struct XHRTimeoutCallback { +pub(crate) struct XHRTimeoutCallback { #[ignore_malloc_size_of = "Because it is non-owning"] xhr: Trusted<XMLHttpRequest>, generation_id: GenerationId, } impl XHRTimeoutCallback { - pub fn invoke(self, can_gc: CanGc) { + pub(crate) fn invoke(self, can_gc: CanGc) { let xhr = self.xhr.root(); if xhr.ready_state.get() != XMLHttpRequestState::Done { xhr.process_partial_response( @@ -1679,7 +1679,7 @@ fn serialize_document(doc: &Document) -> Fallible<DOMString> { /// Returns whether `bs` is a `field-value`, as defined by /// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-32). -pub fn is_field_value(slice: &[u8]) -> bool { +pub(crate) fn is_field_value(slice: &[u8]) -> bool { // Classifications of characters necessary for the [CRLF] (SP|HT) rule #[derive(PartialEq)] #[allow(clippy::upper_case_acronyms)] diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 3cbc648c6f0..fdef0532976 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -8,12 +8,12 @@ use crate::dom::bindings::codegen::Bindings::XMLHttpRequestEventTargetBinding::X use crate::dom::eventtarget::EventTarget; #[dom_struct] -pub struct XMLHttpRequestEventTarget { +pub(crate) struct XMLHttpRequestEventTarget { eventtarget: EventTarget, } impl XMLHttpRequestEventTarget { - pub fn new_inherited() -> XMLHttpRequestEventTarget { + pub(crate) fn new_inherited() -> XMLHttpRequestEventTarget { XMLHttpRequestEventTarget { eventtarget: EventTarget::new_inherited(), } diff --git a/components/script/dom/xmlhttprequestupload.rs b/components/script/dom/xmlhttprequestupload.rs index 3094e8a1521..20f3ba155e7 100644 --- a/components/script/dom/xmlhttprequestupload.rs +++ b/components/script/dom/xmlhttprequestupload.rs @@ -11,7 +11,7 @@ use crate::dom::xmlhttprequesteventtarget::XMLHttpRequestEventTarget; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XMLHttpRequestUpload { +pub(crate) struct XMLHttpRequestUpload { eventtarget: XMLHttpRequestEventTarget, } @@ -21,7 +21,7 @@ impl XMLHttpRequestUpload { eventtarget: XMLHttpRequestEventTarget::new_inherited(), } } - pub fn new(global: &GlobalScope) -> DomRoot<XMLHttpRequestUpload> { + pub(crate) fn new(global: &GlobalScope) -> DomRoot<XMLHttpRequestUpload> { reflect_dom_object( Box::new(XMLHttpRequestUpload::new_inherited()), global, diff --git a/components/script/dom/xmlserializer.rs b/components/script/dom/xmlserializer.rs index f9d616ebf10..74941f9018d 100644 --- a/components/script/dom/xmlserializer.rs +++ b/components/script/dom/xmlserializer.rs @@ -16,7 +16,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XMLSerializer { +pub(crate) struct XMLSerializer { reflector_: Reflector, window: Dom<Window>, } @@ -29,7 +29,7 @@ impl XMLSerializer { } } - pub fn new( + pub(crate) fn new( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, diff --git a/components/script/dom/xpathevaluator.rs b/components/script/dom/xpathevaluator.rs index 967f7ef6076..eee70a2f07e 100644 --- a/components/script/dom/xpathevaluator.rs +++ b/components/script/dom/xpathevaluator.rs @@ -22,7 +22,7 @@ use crate::dom::xpathresult::XPathResult; use crate::script_runtime::CanGc; #[dom_struct] -pub struct XPathEvaluator { +pub(crate) struct XPathEvaluator { reflector_: Reflector, window: Dom<Window>, } @@ -35,7 +35,7 @@ impl XPathEvaluator { } } - pub fn new( + pub(crate) fn new( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, diff --git a/components/script/dom/xpathexpression.rs b/components/script/dom/xpathexpression.rs index 16e898c2e72..b4fdef478c6 100644 --- a/components/script/dom/xpathexpression.rs +++ b/components/script/dom/xpathexpression.rs @@ -16,7 +16,7 @@ use crate::script_runtime::CanGc; use crate::xpath::{evaluate_parsed_xpath, Expr}; #[dom_struct] -pub struct XPathExpression { +pub(crate) struct XPathExpression { reflector_: Reflector, window: Dom<Window>, #[no_trace] @@ -32,7 +32,7 @@ impl XPathExpression { } } - pub fn new( + pub(crate) fn new( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, diff --git a/components/script/dom/xpathresult.rs b/components/script/dom/xpathresult.rs index 93905b05ff7..c3e768474e5 100644 --- a/components/script/dom/xpathresult.rs +++ b/components/script/dom/xpathresult.rs @@ -21,7 +21,7 @@ use crate::xpath::{NodesetHelpers, Value}; #[repr(u16)] #[derive(Clone, Copy, Debug, Eq, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub enum XPathResultType { +pub(crate) enum XPathResultType { Any = XPathResultConstants::ANY_TYPE, Number = XPathResultConstants::NUMBER_TYPE, String = XPathResultConstants::STRING_TYPE, @@ -55,7 +55,7 @@ impl TryFrom<u16> for XPathResultType { } #[derive(JSTraceable, MallocSizeOf)] -pub enum XPathResultValue { +pub(crate) enum XPathResultValue { Boolean(bool), /// A IEEE-754 double-precision floating point number Number(f64), @@ -81,7 +81,7 @@ impl From<Value> for XPathResultValue { } #[dom_struct] -pub struct XPathResult { +pub(crate) struct XPathResult { reflector_: Reflector, window: Dom<Window>, result_type: XPathResultType, @@ -122,7 +122,7 @@ impl XPathResult { /// NB: Blindly trusts `result_type` and constructs an object regardless of the contents /// of `value`. The exception is `XPathResultType::Any`, for which we look at the value /// to determine the type. - pub fn new( + pub(crate) fn new( window: &Window, proto: Option<HandleObject>, can_gc: CanGc, diff --git a/components/script/drag_data_store.rs b/components/script/drag_data_store.rs index 8cc893dd73c..a4db339dff4 100644 --- a/components/script/drag_data_store.rs +++ b/components/script/drag_data_store.rs @@ -16,45 +16,45 @@ use crate::script_runtime::CanGc; /// <https://html.spec.whatwg.org/multipage/#the-drag-data-item-kind> #[derive(Clone)] -pub enum Kind { +pub(crate) enum Kind { Text(PlainString), File(Binary), } #[derive(Clone)] -pub struct PlainString { +pub(crate) struct PlainString { data: DOMString, type_: DOMString, } impl PlainString { - pub fn new(data: DOMString, type_: DOMString) -> Self { + pub(crate) fn new(data: DOMString, type_: DOMString) -> Self { Self { data, type_ } } } #[derive(Clone)] -pub struct Binary { +pub(crate) struct Binary { bytes: Vec<u8>, name: DOMString, type_: String, } impl Binary { - pub fn new(bytes: Vec<u8>, name: DOMString, type_: String) -> Self { + pub(crate) fn new(bytes: Vec<u8>, name: DOMString, type_: String) -> Self { Self { bytes, name, type_ } } } impl Kind { - pub fn type_(&self) -> DOMString { + pub(crate) fn type_(&self) -> DOMString { match self { Kind::Text(string) => string.type_.clone(), Kind::File(binary) => DOMString::from(binary.type_.clone()), } } - pub fn as_string(&self) -> Option<DOMString> { + pub(crate) fn as_string(&self) -> Option<DOMString> { match self { Kind::Text(string) => Some(string.data.clone()), Kind::File(_) => None, @@ -63,7 +63,7 @@ impl Kind { // TODO for now we create a new BlobImpl // since File constructor requires moving it. - pub fn as_file(&self, global: &GlobalScope) -> Option<DomRoot<File>> { + pub(crate) fn as_file(&self, global: &GlobalScope) -> Option<DomRoot<File>> { match self { Kind::Text(_) => None, Kind::File(binary) => Some(File::new( @@ -95,7 +95,7 @@ struct Bitmap { /// Control the behaviour of the drag data store #[derive(Clone, Copy, Eq, PartialEq)] -pub enum Mode { +pub(crate) enum Mode { /// <https://html.spec.whatwg.org/multipage/#concept-dnd-rw> ReadWrite, /// <https://html.spec.whatwg.org/multipage/#concept-dnd-ro> @@ -106,7 +106,7 @@ pub enum Mode { } #[allow(dead_code)] // TODO some fields are used by DragEvent. -pub struct DragDataStore { +pub(crate) struct DragDataStore { /// <https://html.spec.whatwg.org/multipage/#drag-data-store-item-list> item_list: Vec<Kind>, /// <https://html.spec.whatwg.org/multipage/#drag-data-store-default-feedback> @@ -121,7 +121,7 @@ impl DragDataStore { /// <https://html.spec.whatwg.org/multipage/#create-a-drag-data-store> // We don't really need it since it's only instantiated by DataTransfer. #[allow(clippy::new_without_default)] - pub fn new() -> DragDataStore { + pub(crate) fn new() -> DragDataStore { DragDataStore { item_list: Vec::new(), default_feedback: None, @@ -132,21 +132,21 @@ impl DragDataStore { } /// Get the drag data store mode - pub fn mode(&self) -> Mode { + pub(crate) fn mode(&self) -> Mode { self.mode } /// Set the drag data store mode - pub fn set_mode(&mut self, mode: Mode) { + pub(crate) fn set_mode(&mut self, mode: Mode) { self.mode = mode; } - pub fn set_bitmap(&mut self, image: Option<Arc<Image>>, x: i32, y: i32) { + pub(crate) fn set_bitmap(&mut self, image: Option<Arc<Image>>, x: i32, y: i32) { self.bitmap = Some(Bitmap { image, x, y }); } /// <https://html.spec.whatwg.org/multipage/#concept-datatransfer-types> - pub fn types(&self) -> Vec<DOMString> { + pub(crate) fn types(&self) -> Vec<DOMString> { let mut types = Vec::new(); let has_files = self.item_list.iter().fold(false, |has_files, item| { @@ -168,14 +168,14 @@ impl DragDataStore { types } - pub fn find_matching_text(&self, type_: &str) -> Option<DOMString> { + pub(crate) fn find_matching_text(&self, type_: &str) -> Option<DOMString> { self.item_list .iter() .find(|item| item.text_type_matches(type_)) .and_then(|item| item.as_string()) } - pub fn add(&mut self, kind: Kind) -> Fallible<()> { + pub(crate) fn add(&mut self, kind: Kind) -> Fallible<()> { if let Kind::Text(ref string) = kind { // Step 2.1 If there is already an item in the item list whose kind is text // and whose type string is equal to the method's second argument, throw "NotSupportedError". @@ -194,7 +194,7 @@ impl DragDataStore { Ok(()) } - pub fn set_data(&mut self, format: DOMString, data: DOMString) { + pub(crate) fn set_data(&mut self, format: DOMString, data: DOMString) { // Step 3-4 let type_ = normalize_mime(format); @@ -207,7 +207,7 @@ impl DragDataStore { self.item_list.push(Kind::Text(PlainString { data, type_ })); } - pub fn clear_data(&mut self, format: Option<DOMString>) -> bool { + pub(crate) fn clear_data(&mut self, format: Option<DOMString>) -> bool { let mut was_modified = false; if let Some(format) = format { @@ -238,7 +238,7 @@ impl DragDataStore { was_modified } - pub fn files(&self, global: &GlobalScope, file_list: &mut Vec<DomRoot<File>>) { + pub(crate) fn files(&self, global: &GlobalScope, file_list: &mut Vec<DomRoot<File>>) { // Step 3 If the data store is in the protected mode return the empty list. if self.mode == Mode::Protected { return; @@ -251,19 +251,19 @@ impl DragDataStore { .for_each(|file| file_list.push(file)); } - pub fn list_len(&self) -> usize { + pub(crate) fn list_len(&self) -> usize { self.item_list.len() } - pub fn get_item(&self, index: usize) -> Option<Kind> { + pub(crate) fn get_item(&self, index: usize) -> Option<Kind> { self.item_list.get(index).cloned() } - pub fn remove(&mut self, index: usize) { + pub(crate) fn remove(&mut self, index: usize) { self.item_list.remove(index); } - pub fn clear_list(&mut self) { + pub(crate) fn clear_list(&mut self) { self.item_list.clear(); } } diff --git a/components/script/fetch.rs b/components/script/fetch.rs index 852ced296ff..428f4f86e4e 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -51,7 +51,7 @@ struct FetchContext { /// in which case it will store the sender. You can manually cancel it /// or let it cancel on Drop in that case. #[derive(Default, JSTraceable, MallocSizeOf)] -pub struct FetchCanceller { +pub(crate) struct FetchCanceller { #[ignore_malloc_size_of = "channels are hard"] #[no_trace] cancel_chan: Option<ipc::IpcSender<()>>, @@ -59,13 +59,13 @@ pub struct FetchCanceller { impl FetchCanceller { /// Create an empty FetchCanceller - pub fn new() -> Self { + pub(crate) fn new() -> Self { Default::default() } /// Obtain an IpcReceiver to send over to Fetch, and initialize /// the internal sender - pub fn initialize(&mut self) -> ipc::IpcReceiver<()> { + pub(crate) fn initialize(&mut self) -> ipc::IpcReceiver<()> { // cancel previous fetch self.cancel(); let (rx, tx) = ipc::channel().unwrap(); @@ -74,7 +74,7 @@ impl FetchCanceller { } /// Cancel a fetch if it is ongoing - pub fn cancel(&mut self) { + pub(crate) fn cancel(&mut self) { if let Some(chan) = self.cancel_chan.take() { // stop trying to make fetch happen // it's not going to happen @@ -88,7 +88,7 @@ impl FetchCanceller { /// Use this if you don't want it to send a cancellation request /// on drop (e.g. if the fetch completes) - pub fn ignore(&mut self) { + pub(crate) fn ignore(&mut self) { let _ = self.cancel_chan.take(); } } @@ -138,7 +138,7 @@ fn request_init_from_request(request: NetTraitsRequest) -> RequestBuilder { /// <https://fetch.spec.whatwg.org/#fetch-method> #[allow(crown::unrooted_must_root, non_snake_case)] -pub fn Fetch( +pub(crate) fn Fetch( global: &GlobalScope, input: RequestInfo, init: RootedTraceableBox<RequestInit>, @@ -332,7 +332,7 @@ fn fill_headers_with_metadata(r: DomRoot<Response>, m: Metadata, can_gc: CanGc) } /// Convenience function for synchronously loading a whole resource. -pub fn load_whole_resource( +pub(crate) fn load_whole_resource( request: RequestBuilder, core_resource_thread: &CoreResourceThread, global: &GlobalScope, diff --git a/components/script/iframe_collection.rs b/components/script/iframe_collection.rs index d489a4355e7..ada71128e87 100644 --- a/components/script/iframe_collection.rs +++ b/components/script/iframe_collection.rs @@ -23,9 +23,9 @@ use crate::script_thread::with_script_thread; #[derive(JSTraceable, MallocSizeOf)] #[crown::unrooted_must_root_lint::must_root] pub(crate) struct IFrame { - pub element: Dom<HTMLIFrameElement>, + pub(crate) element: Dom<HTMLIFrameElement>, #[no_trace] - pub size: Option<Size2D<f32, CSSPixel>>, + pub(crate) size: Option<Size2D<f32, CSSPixel>>, } #[derive(Default, JSTraceable, MallocSizeOf)] diff --git a/components/script/image_listener.rs b/components/script/image_listener.rs index 5b6fb756c6e..84b09048466 100644 --- a/components/script/image_listener.rs +++ b/components/script/image_listener.rs @@ -13,12 +13,12 @@ use crate::dom::bindings::reflector::DomObject; use crate::dom::node::{Node, NodeTraits}; use crate::script_runtime::CanGc; -pub trait ImageCacheListener { +pub(crate) trait ImageCacheListener { fn generation_id(&self) -> u32; fn process_image_response(&self, response: ImageResponse, can_gc: CanGc); } -pub fn generate_cache_listener_for_element< +pub(crate) fn generate_cache_listener_for_element< T: ImageCacheListener + DerivedFrom<Node> + DomObject, >( elem: &T, diff --git a/components/script/layout_dom/document.rs b/components/script/layout_dom/document.rs index c2e556ad7fc..9db7d420444 100644 --- a/components/script/layout_dom/document.rs +++ b/components/script/layout_dom/document.rs @@ -82,7 +82,7 @@ impl<'ld> ServoLayoutDocument<'ld> { } } - pub fn from_layout_js(document: LayoutDom<'ld, Document>) -> Self { + pub(crate) fn from_layout_js(document: LayoutDom<'ld, Document>) -> Self { ServoLayoutDocument { document } } } diff --git a/components/script/layout_dom/node.rs b/components/script/layout_dom/node.rs index 60d3b9ee28a..2ef11841ca6 100644 --- a/components/script/layout_dom/node.rs +++ b/components/script/layout_dom/node.rs @@ -90,7 +90,7 @@ impl<'dom> ServoLayoutNode<'dom> { } /// Returns the interior of this node as a `LayoutDom`. - pub fn get_jsmanaged(self) -> LayoutDom<'dom, Node> { + pub(crate) fn get_jsmanaged(self) -> LayoutDom<'dom, Node> { self.node } } diff --git a/components/script/layout_image.rs b/components/script/layout_image.rs index e3fac59b72d..4a222046462 100644 --- a/components/script/layout_image.rs +++ b/components/script/layout_image.rs @@ -91,7 +91,7 @@ impl ResourceTimingListener for LayoutImageContext { impl PreInvoke for LayoutImageContext {} -pub fn fetch_image_for_layout( +pub(crate) fn fetch_image_for_layout( url: ServoUrl, node: &Node, id: PendingImageId, diff --git a/components/script/lib.rs b/components/script/lib.rs index e406eb084fb..b9c09d33258 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -29,39 +29,42 @@ mod animations; #[macro_use] mod task; mod body; -pub mod clipboard_provider; -pub mod conversions; +pub(crate) mod clipboard_provider; +pub(crate) mod conversions; mod devtools; -pub mod document_loader; +pub(crate) mod document_loader; #[macro_use] mod dom; mod canvas_state; -pub mod fetch; +pub(crate) mod fetch; mod image_listener; mod init; mod layout_image; -pub mod document_collection; -pub mod iframe_collection; +pub(crate) mod document_collection; +pub(crate) mod iframe_collection; pub mod layout_dom; mod mem; #[allow(unsafe_code)] -pub mod messaging; +pub(crate) mod messaging; mod microtask; mod network_listener; +#[allow(dead_code)] mod realms; +#[allow(dead_code)] mod script_module; -pub mod script_runtime; +pub(crate) mod script_runtime; #[allow(unsafe_code)] -pub mod script_thread; -pub mod security_manager; -pub mod serviceworker_manager; +pub(crate) mod script_thread; +pub(crate) mod security_manager; +pub(crate) mod serviceworker_manager; mod stylesheet_loader; mod stylesheet_set; mod task_manager; mod task_queue; mod task_source; pub mod test; +#[allow(dead_code)] pub mod textinput; mod timers; mod unpremultiplytable; @@ -76,12 +79,14 @@ mod xpath; pub use init::init; pub use script_runtime::JSEngineSetup; +pub use script_thread::ScriptThread; +pub use serviceworker_manager::ServiceWorkerManager; -pub use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder; -pub use crate::dom::bindings::codegen::DomTypes::DomTypes; +pub(crate) use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder; +pub(crate) use crate::dom::bindings::codegen::DomTypes::DomTypes; // These trait exports are public, because they are used in the DOM bindings. // Since they are used in derive macros, // it is useful that they are accessible at the root of the crate. -pub use crate::dom::bindings::inheritance::HasParent; -pub use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; -pub use crate::dom::bindings::trace::{CustomTraceable, JSTraceable}; +pub(crate) use crate::dom::bindings::inheritance::HasParent; +pub(crate) use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; +pub(crate) use crate::dom::bindings::trace::{CustomTraceable, JSTraceable}; diff --git a/components/script/links.rs b/components/script/links.rs index cff1a1ebaa2..9babd4c3987 100644 --- a/components/script/links.rs +++ b/components/script/links.rs @@ -29,7 +29,7 @@ bitflags::bitflags! { /// /// Refer to <https://html.spec.whatwg.org/multipage/#linkTypes> for more information. #[derive(Clone, Copy, Debug)] - pub struct LinkRelations: u32 { + pub(crate) struct LinkRelations: u32 { /// <https://html.spec.whatwg.org/multipage/#rel-alternate> const ALTERNATE = 1; @@ -117,7 +117,7 @@ impl LinkRelations { /// The set of allowed relations for [`<link>`] elements /// /// [`<link>`]: https://html.spec.whatwg.org/multipage/#htmllinkelement - pub const ALLOWED_LINK_RELATIONS: Self = Self::ALTERNATE + pub(crate) const ALLOWED_LINK_RELATIONS: Self = Self::ALTERNATE .union(Self::CANONICAL) .union(Self::AUTHOR) .union(Self::DNS_PREFETCH) @@ -142,7 +142,7 @@ impl LinkRelations { /// /// [`<a>`]: https://html.spec.whatwg.org/multipage/#the-a-element /// [`<area>`]: https://html.spec.whatwg.org/multipage/#the-area-element - pub const ALLOWED_ANCHOR_OR_AREA_RELATIONS: Self = Self::ALTERNATE + pub(crate) const ALLOWED_ANCHOR_OR_AREA_RELATIONS: Self = Self::ALTERNATE .union(Self::AUTHOR) .union(Self::BOOKMARK) .union(Self::EXTERNAL) @@ -162,7 +162,7 @@ impl LinkRelations { /// The set of allowed relations for [`<form>`] elements /// /// [`<form>`]: https://html.spec.whatwg.org/multipage/#the-form-element - pub const ALLOWED_FORM_RELATIONS: Self = Self::EXTERNAL + pub(crate) const ALLOWED_FORM_RELATIONS: Self = Self::EXTERNAL .union(Self::HELP) .union(Self::LICENSE) .union(Self::NEXT) @@ -181,7 +181,7 @@ impl LinkRelations { /// [`<a>`]: https://html.spec.whatwg.org/multipage/#the-a-element /// [`<area>`]: https://html.spec.whatwg.org/multipage/#the-area-element /// [`<form>`]: https://html.spec.whatwg.org/multipage/#the-form-element - pub fn for_element(element: &Element) -> Self { + pub(crate) fn for_element(element: &Element) -> Self { let rel = element.get_attribute(&ns!(), &local_name!("rel")).map(|e| { let value = e.value(); (**value).to_owned() @@ -289,7 +289,7 @@ impl LinkRelations { } /// <https://html.spec.whatwg.org/multipage/#get-an-element's-noopener> - pub fn get_element_noopener(&self, target_attribute_value: Option<&DOMString>) -> bool { + pub(crate) fn get_element_noopener(&self, target_attribute_value: Option<&DOMString>) -> bool { // Step 1. If element's link types include the noopener or noreferrer keyword, then return true. if self.contains(Self::NO_OPENER) || self.contains(Self::NO_REFERRER) { return true; @@ -311,7 +311,7 @@ impl LinkRelations { malloc_size_of_is_0!(LinkRelations); /// <https://html.spec.whatwg.org/multipage/#get-an-element's-target> -pub fn get_element_target(subject: &Element) -> Option<DOMString> { +pub(crate) fn get_element_target(subject: &Element) -> Option<DOMString> { if !(subject.is::<HTMLAreaElement>() || subject.is::<HTMLAnchorElement>() || subject.is::<HTMLFormElement>()) @@ -337,7 +337,7 @@ pub fn get_element_target(subject: &Element) -> Option<DOMString> { } /// <https://html.spec.whatwg.org/multipage/#following-hyperlinks-2> -pub fn follow_hyperlink( +pub(crate) fn follow_hyperlink( subject: &Element, relations: LinkRelations, hyperlink_suffix: Option<String>, diff --git a/components/script/mem.rs b/components/script/mem.rs index 56401d8a51e..52a6e724b22 100644 --- a/components/script/mem.rs +++ b/components/script/mem.rs @@ -12,7 +12,7 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; /// IDL interface. This way we don't have to find the most-derived interface of DOM /// objects by hand in code. #[allow(unsafe_code)] -pub unsafe fn malloc_size_of_including_raw_self<T: MallocSizeOf>( +pub(crate) unsafe fn malloc_size_of_including_raw_self<T: MallocSizeOf>( ops: &mut MallocSizeOfOps, obj: *const c_void, ) -> usize { diff --git a/components/script/messaging.rs b/components/script/messaging.rs index 7dd1db6b3ba..d0fa7e7e38e 100644 --- a/components/script/messaging.rs +++ b/components/script/messaging.rs @@ -130,7 +130,7 @@ pub(crate) enum MainThreadScriptMsg { } /// Common messages used to control the event loops in both the script and the worker -pub enum CommonScriptMsg { +pub(crate) enum CommonScriptMsg { /// Requests that the script thread measure its memory usage. The results are sent back via the /// supplied channel. CollectReports(ReportsChan), @@ -297,68 +297,68 @@ impl OpaqueSender<CommonScriptMsg> for ScriptEventLoopSender { pub(crate) struct ScriptThreadSenders { /// A channel to hand out to script thread-based entities that need to be able to enqueue /// events in the event queue. - pub self_sender: Sender<MainThreadScriptMsg>, + pub(crate) self_sender: Sender<MainThreadScriptMsg>, /// A handle to the bluetooth thread. #[no_trace] - pub bluetooth_sender: IpcSender<BluetoothRequest>, + pub(crate) bluetooth_sender: IpcSender<BluetoothRequest>, /// A [`Sender`] that sends messages to the `Constellation`. #[no_trace] - pub constellation_sender: IpcSender<ConstellationControlMsg>, + pub(crate) constellation_sender: IpcSender<ConstellationControlMsg>, /// A [`Sender`] that sends messages to the `Constellation` associated with /// particular pipelines. #[no_trace] - pub pipeline_to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>, + pub(crate) pipeline_to_constellation_sender: IpcSender<(PipelineId, ScriptMsg)>, /// A sender for layout to communicate to the constellation. #[no_trace] - pub layout_to_constellation_ipc_sender: IpcSender<LayoutMsg>, + pub(crate) layout_to_constellation_ipc_sender: IpcSender<LayoutMsg>, /// The [`Sender`] on which messages can be sent to the `ImageCache`. #[no_trace] - pub image_cache_sender: Sender<ImageCacheMsg>, + pub(crate) image_cache_sender: Sender<ImageCacheMsg>, /// For providing contact with the time profiler. #[no_trace] - pub time_profiler_sender: profile_time::ProfilerChan, + pub(crate) time_profiler_sender: profile_time::ProfilerChan, /// For providing contact with the memory profiler. #[no_trace] - pub memory_profiler_sender: profile_mem::ProfilerChan, + pub(crate) memory_profiler_sender: profile_mem::ProfilerChan, /// For providing instructions to an optional devtools server. #[no_trace] - pub devtools_server_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>, + pub(crate) devtools_server_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>, #[no_trace] - pub devtools_client_to_script_thread_sender: IpcSender<DevtoolScriptControlMsg>, + pub(crate) devtools_client_to_script_thread_sender: IpcSender<DevtoolScriptControlMsg>, #[no_trace] - pub content_process_shutdown_sender: Sender<()>, + pub(crate) content_process_shutdown_sender: Sender<()>, } #[derive(JSTraceable)] pub(crate) struct ScriptThreadReceivers { /// A [`Receiver`] that receives messages from the constellation. #[no_trace] - pub constellation_receiver: Receiver<ConstellationControlMsg>, + pub(crate) constellation_receiver: Receiver<ConstellationControlMsg>, /// The [`Receiver`] which receives incoming messages from the `ImageCache`. #[no_trace] - pub image_cache_receiver: Receiver<ImageCacheMsg>, + pub(crate) image_cache_receiver: Receiver<ImageCacheMsg>, /// For receiving commands from an optional devtools server. Will be ignored if no such server /// exists. When devtools are not active this will be [`crossbeam_channel::never()`]. #[no_trace] - pub devtools_server_receiver: Receiver<DevtoolScriptControlMsg>, + pub(crate) devtools_server_receiver: Receiver<DevtoolScriptControlMsg>, /// Receiver to receive commands from optional WebGPU server. When there is no active /// WebGPU context, this will be [`crossbeam_channel::never()`]. #[no_trace] #[cfg(feature = "webgpu")] - pub webgpu_receiver: RefCell<Receiver<WebGPUMsg>>, + pub(crate) webgpu_receiver: RefCell<Receiver<WebGPUMsg>>, } impl ScriptThreadReceivers { diff --git a/components/script/microtask.rs b/components/script/microtask.rs index 87bd4e1da1a..b186d7aa337 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -29,7 +29,7 @@ use crate::script_thread::ScriptThread; /// A collection of microtasks in FIFO order. #[derive(Default, JSTraceable, MallocSizeOf)] -pub struct MicrotaskQueue { +pub(crate) struct MicrotaskQueue { /// The list of enqueued microtasks that will be invoked at the next microtask checkpoint. microtask_queue: DomRefCell<Vec<Microtask>>, /// <https://html.spec.whatwg.org/multipage/#performing-a-microtask-checkpoint> @@ -37,7 +37,7 @@ pub struct MicrotaskQueue { } #[derive(JSTraceable, MallocSizeOf)] -pub enum Microtask { +pub(crate) enum Microtask { Promise(EnqueuedPromiseCallback), User(UserMicrotask), MediaElement(MediaElementMicrotask), @@ -47,36 +47,36 @@ pub enum Microtask { NotifyMutationObservers, } -pub trait MicrotaskRunnable { +pub(crate) trait MicrotaskRunnable { fn handler(&self, _can_gc: CanGc) {} fn enter_realm(&self) -> JSAutoRealm; } /// A promise callback scheduled to run during the next microtask checkpoint (#4283). #[derive(JSTraceable, MallocSizeOf)] -pub struct EnqueuedPromiseCallback { +pub(crate) struct EnqueuedPromiseCallback { #[ignore_malloc_size_of = "Rc has unclear ownership"] - pub callback: Rc<PromiseJobCallback>, + pub(crate) callback: Rc<PromiseJobCallback>, #[no_trace] - pub pipeline: PipelineId, - pub is_user_interacting: bool, + pub(crate) pipeline: PipelineId, + pub(crate) is_user_interacting: bool, } /// A microtask that comes from a queueMicrotask() Javascript call, /// identical to EnqueuedPromiseCallback once it's on the queue #[derive(JSTraceable, MallocSizeOf)] -pub struct UserMicrotask { +pub(crate) struct UserMicrotask { #[ignore_malloc_size_of = "Rc has unclear ownership"] - pub callback: Rc<VoidFunction>, + pub(crate) callback: Rc<VoidFunction>, #[no_trace] - pub pipeline: PipelineId, + pub(crate) pipeline: PipelineId, } impl MicrotaskQueue { /// Add a new microtask to this queue. It will be invoked as part of the next /// microtask checkpoint. #[allow(unsafe_code)] - pub fn enqueue(&self, job: Microtask, cx: JSContext) { + pub(crate) fn enqueue(&self, job: Microtask, cx: JSContext) { self.microtask_queue.borrow_mut().push(job); unsafe { JobQueueMayNotBeEmpty(*cx) }; } @@ -84,7 +84,7 @@ impl MicrotaskQueue { /// <https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint> /// Perform a microtask checkpoint, executing all queued microtasks until the queue is empty. #[allow(unsafe_code)] - pub fn checkpoint<F>( + pub(crate) fn checkpoint<F>( &self, cx: JSContext, target_provider: F, @@ -160,11 +160,11 @@ impl MicrotaskQueue { self.performing_a_microtask_checkpoint.set(false); } - pub fn empty(&self) -> bool { + pub(crate) fn empty(&self) -> bool { self.microtask_queue.borrow().is_empty() } - pub fn clear(&self) { + pub(crate) fn clear(&self) { self.microtask_queue.borrow_mut().clear(); } } diff --git a/components/script/network_listener.rs b/components/script/network_listener.rs index 8de3b0ca527..5e662b8ef76 100644 --- a/components/script/network_listener.rs +++ b/components/script/network_listener.rs @@ -21,17 +21,17 @@ use crate::task_source::SendableTaskSource; /// An off-thread sink for async network event tasks. All such events are forwarded to /// a target thread, where they are invoked on the provided context object. -pub struct NetworkListener<Listener: PreInvoke + Send + 'static> { - pub context: Arc<Mutex<Listener>>, - pub task_source: SendableTaskSource, +pub(crate) struct NetworkListener<Listener: PreInvoke + Send + 'static> { + pub(crate) context: Arc<Mutex<Listener>>, + pub(crate) task_source: SendableTaskSource, } -pub trait ResourceTimingListener { +pub(crate) trait ResourceTimingListener { fn resource_timing_information(&self) -> (InitiatorType, ServoUrl); fn resource_timing_global(&self) -> DomRoot<GlobalScope>; } -pub fn submit_timing<T: ResourceTimingListener + FetchResponseListener>( +pub(crate) fn submit_timing<T: ResourceTimingListener + FetchResponseListener>( listener: &T, can_gc: CanGc, ) { @@ -58,7 +58,7 @@ pub fn submit_timing<T: ResourceTimingListener + FetchResponseListener>( ); } -pub fn submit_timing_data( +pub(crate) fn submit_timing_data( global: &GlobalScope, url: ServoUrl, initiator_type: InitiatorType, @@ -73,7 +73,7 @@ pub fn submit_timing_data( } impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> { - pub fn notify<A: Action<Listener> + Send + 'static>(&self, action: A) { + pub(crate) fn notify<A: Action<Listener> + Send + 'static>(&self, action: A) { self.task_source.queue(ListenerTask { context: self.context.clone(), action, @@ -83,11 +83,11 @@ impl<Listener: PreInvoke + Send + 'static> NetworkListener<Listener> { // helps type inference impl<Listener: FetchResponseListener + PreInvoke + Send + 'static> NetworkListener<Listener> { - pub fn notify_fetch(&self, action: FetchResponseMsg) { + pub(crate) fn notify_fetch(&self, action: FetchResponseMsg) { self.notify(action); } - pub fn into_callback(self) -> BoxedFetchCallback { + pub(crate) fn into_callback(self) -> BoxedFetchCallback { Box::new(move |response_msg| self.notify_fetch(response_msg)) } } @@ -95,7 +95,7 @@ impl<Listener: FetchResponseListener + PreInvoke + Send + 'static> NetworkListen /// A gating mechanism that runs before invoking the task on the target thread. /// If the `should_invoke` method returns false, the task is discarded without /// being invoked. -pub trait PreInvoke { +pub(crate) trait PreInvoke { fn should_invoke(&self) -> bool { true } diff --git a/components/script/realms.rs b/components/script/realms.rs index 5fb2b42e7d0..9180a925382 100644 --- a/components/script/realms.rs +++ b/components/script/realms.rs @@ -8,18 +8,18 @@ use crate::dom::bindings::reflector::DomObject; use crate::dom::globalscope::GlobalScope; use crate::script_runtime::JSContext; -pub struct AlreadyInRealm(()); +pub(crate) struct AlreadyInRealm(()); impl AlreadyInRealm { #![allow(unsafe_code)] - pub fn assert() -> AlreadyInRealm { + pub(crate) fn assert() -> AlreadyInRealm { unsafe { assert!(!GetCurrentRealmOrNull(*GlobalScope::get_cx()).is_null()); } AlreadyInRealm(()) } - pub fn assert_for_cx(cx: JSContext) -> AlreadyInRealm { + pub(crate) fn assert_for_cx(cx: JSContext) -> AlreadyInRealm { unsafe { assert!(!GetCurrentRealmOrNull(*cx).is_null()); } @@ -28,22 +28,22 @@ impl AlreadyInRealm { } #[derive(Clone, Copy)] -pub enum InRealm<'a> { +pub(crate) enum InRealm<'a> { Already(&'a AlreadyInRealm), Entered(&'a JSAutoRealm), } impl InRealm<'_> { - pub fn already(token: &AlreadyInRealm) -> InRealm { + pub(crate) fn already(token: &AlreadyInRealm) -> InRealm { InRealm::Already(token) } - pub fn entered(token: &JSAutoRealm) -> InRealm { + pub(crate) fn entered(token: &JSAutoRealm) -> InRealm { InRealm::Entered(token) } } -pub fn enter_realm(object: &impl DomObject) -> JSAutoRealm { +pub(crate) fn enter_realm(object: &impl DomObject) -> JSAutoRealm { JSAutoRealm::new( *GlobalScope::get_cx(), object.reflector().get_jsobject().get(), diff --git a/components/script/script_module.rs b/components/script/script_module.rs index 44a7b6ed7bf..0651983c105 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -85,7 +85,7 @@ unsafe fn gen_type_error(global: &GlobalScope, string: String) -> RethrowError { } #[derive(JSTraceable)] -pub struct ModuleObject(Box<Heap<*mut JSObject>>); +pub(crate) struct ModuleObject(Box<Heap<*mut JSObject>>); impl ModuleObject { fn new(obj: RustHandleObject) -> ModuleObject { @@ -93,13 +93,13 @@ impl ModuleObject { } #[allow(unsafe_code)] - pub fn handle(&self) -> HandleObject { + pub(crate) fn handle(&self) -> HandleObject { unsafe { self.0.handle() } } } #[derive(JSTraceable)] -pub struct RethrowError(RootedTraceableBox<Heap<JSVal>>); +pub(crate) struct RethrowError(RootedTraceableBox<Heap<JSVal>>); impl RethrowError { fn handle(&self) -> Handle<JSVal> { @@ -120,7 +120,7 @@ pub(crate) struct ModuleScript { } impl ModuleScript { - pub fn new( + pub(crate) fn new( base_url: ServoUrl, options: ScriptFetchOptions, owner: Option<ModuleOwner>, @@ -142,13 +142,13 @@ impl ModuleScript { /// from a descendant no matter the parent is an /// inline script or a external script #[derive(Clone, Debug, Eq, Hash, JSTraceable, PartialEq)] -pub enum ModuleIdentity { +pub(crate) enum ModuleIdentity { ScriptId(ScriptId), ModuleUrl(#[no_trace] ServoUrl), } impl ModuleIdentity { - pub fn get_module_tree(&self, global: &GlobalScope) -> Rc<ModuleTree> { + pub(crate) fn get_module_tree(&self, global: &GlobalScope) -> Rc<ModuleTree> { match self { ModuleIdentity::ModuleUrl(url) => { let module_map = global.get_module_map().borrow(); @@ -163,7 +163,7 @@ impl ModuleIdentity { } #[derive(JSTraceable)] -pub struct ModuleTree { +pub(crate) struct ModuleTree { #[no_trace] url: ServoUrl, text: DomRefCell<Rc<DOMString>>, @@ -196,7 +196,7 @@ pub struct ModuleTree { } impl ModuleTree { - pub fn new(url: ServoUrl, external: bool, visited_urls: HashSet<ServoUrl>) -> Self { + pub(crate) fn new(url: ServoUrl, external: bool, visited_urls: HashSet<ServoUrl>) -> Self { ModuleTree { url, text: DomRefCell::new(Rc::new(DOMString::new())), @@ -213,55 +213,55 @@ impl ModuleTree { } } - pub fn get_status(&self) -> ModuleStatus { + pub(crate) fn get_status(&self) -> ModuleStatus { *self.status.borrow() } - pub fn set_status(&self, status: ModuleStatus) { + pub(crate) fn set_status(&self, status: ModuleStatus) { *self.status.borrow_mut() = status; } - pub fn get_record(&self) -> &DomRefCell<Option<ModuleObject>> { + pub(crate) fn get_record(&self) -> &DomRefCell<Option<ModuleObject>> { &self.record } - pub fn set_record(&self, record: ModuleObject) { + pub(crate) fn set_record(&self, record: ModuleObject) { *self.record.borrow_mut() = Some(record); } - pub fn get_rethrow_error(&self) -> &DomRefCell<Option<RethrowError>> { + pub(crate) fn get_rethrow_error(&self) -> &DomRefCell<Option<RethrowError>> { &self.rethrow_error } - pub fn set_rethrow_error(&self, rethrow_error: RethrowError) { + pub(crate) fn set_rethrow_error(&self, rethrow_error: RethrowError) { *self.rethrow_error.borrow_mut() = Some(rethrow_error); } - pub fn get_network_error(&self) -> &DomRefCell<Option<NetworkError>> { + pub(crate) fn get_network_error(&self) -> &DomRefCell<Option<NetworkError>> { &self.network_error } - pub fn set_network_error(&self, network_error: NetworkError) { + pub(crate) fn set_network_error(&self, network_error: NetworkError) { *self.network_error.borrow_mut() = Some(network_error); } - pub fn get_text(&self) -> &DomRefCell<Rc<DOMString>> { + pub(crate) fn get_text(&self) -> &DomRefCell<Rc<DOMString>> { &self.text } - pub fn set_text(&self, module_text: Rc<DOMString>) { + pub(crate) fn set_text(&self, module_text: Rc<DOMString>) { *self.text.borrow_mut() = module_text; } - pub fn get_incomplete_fetch_urls(&self) -> &DomRefCell<IndexSet<ServoUrl>> { + pub(crate) fn get_incomplete_fetch_urls(&self) -> &DomRefCell<IndexSet<ServoUrl>> { &self.incomplete_fetch_urls } - pub fn get_descendant_urls(&self) -> &DomRefCell<IndexSet<ServoUrl>> { + pub(crate) fn get_descendant_urls(&self) -> &DomRefCell<IndexSet<ServoUrl>> { &self.descendant_urls } - pub fn get_parent_urls(&self) -> IndexSet<ServoUrl> { + pub(crate) fn get_parent_urls(&self) -> IndexSet<ServoUrl> { let parent_identities = self.parent_identities.borrow(); parent_identities @@ -273,17 +273,17 @@ impl ModuleTree { .collect() } - pub fn insert_parent_identity(&self, parent_identity: ModuleIdentity) { + pub(crate) fn insert_parent_identity(&self, parent_identity: ModuleIdentity) { self.parent_identities.borrow_mut().insert(parent_identity); } - pub fn insert_incomplete_fetch_url(&self, dependency: &ServoUrl) { + pub(crate) fn insert_incomplete_fetch_url(&self, dependency: &ServoUrl) { self.incomplete_fetch_urls .borrow_mut() .insert(dependency.clone()); } - pub fn remove_incomplete_fetch_url(&self, dependency: &ServoUrl) { + pub(crate) fn remove_incomplete_fetch_url(&self, dependency: &ServoUrl) { self.incomplete_fetch_urls .borrow_mut() .shift_remove(dependency); @@ -411,7 +411,7 @@ impl ModuleTree { } #[derive(Clone, Copy, Debug, JSTraceable, PartialEq, PartialOrd)] -pub enum ModuleStatus { +pub(crate) enum ModuleStatus { Initial, Fetching, FetchingDescendants, @@ -516,7 +516,7 @@ impl ModuleTree { #[allow(unsafe_code)] /// <https://html.spec.whatwg.org/multipage/#fetch-the-descendants-of-and-link-a-module-script> /// Step 5-2. - pub fn instantiate_module_tree( + pub(crate) fn instantiate_module_tree( &self, global: &GlobalScope, module_record: HandleObject, @@ -547,7 +547,7 @@ impl ModuleTree { /// mutable handle. Although the CanGc appears unused, it represents the GC operations /// possible when evluating arbitrary JS. #[allow(unsafe_code)] - pub fn execute_module( + pub(crate) fn execute_module( &self, global: &GlobalScope, module_record: HandleObject, @@ -589,7 +589,7 @@ impl ModuleTree { } #[allow(unsafe_code)] - pub fn report_error(&self, global: &GlobalScope, can_gc: CanGc) { + pub(crate) fn report_error(&self, global: &GlobalScope, can_gc: CanGc) { let module_error = self.rethrow_error.borrow(); if let Some(exception) = &*module_error { @@ -917,7 +917,7 @@ struct ModuleHandler { } impl ModuleHandler { - pub fn new_boxed(task: Box<dyn TaskBox>) -> Box<dyn Callback> { + pub(crate) fn new_boxed(task: Box<dyn TaskBox>) -> Box<dyn Callback> { Box::new(Self { task: DomRefCell::new(Some(task)), }) @@ -950,7 +950,7 @@ impl ModuleOwner { } } - pub fn notify_owner_to_finish( + pub(crate) fn notify_owner_to_finish( &self, module_identity: ModuleIdentity, fetch_options: ScriptFetchOptions, @@ -1292,7 +1292,7 @@ impl PreInvoke for ModuleContext {} #[allow(unsafe_code, non_snake_case)] /// A function to register module hooks (e.g. listening on resolving modules, /// getting module metadata, getting script private reference and resolving dynamic import) -pub unsafe fn EnsureModuleHooksInitialized(rt: *mut JSRuntime) { +pub(crate) unsafe fn EnsureModuleHooksInitialized(rt: *mut JSRuntime) { if GetModuleResolveHook(rt).is_some() { return; } @@ -1321,7 +1321,7 @@ unsafe extern "C" fn host_release_top_level_script(value: *const Value) { #[allow(unsafe_code)] /// <https://html.spec.whatwg.org/multipage/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)> -pub unsafe extern "C" fn host_import_module_dynamically( +pub(crate) unsafe extern "C" fn host_import_module_dynamically( cx: *mut JSContext, reference_private: RawHandleValue, specifier: RawHandle<*mut JSObject>, @@ -1366,22 +1366,22 @@ pub unsafe extern "C" fn host_import_module_dynamically( #[derive(Clone, JSTraceable, MallocSizeOf)] /// <https://html.spec.whatwg.org/multipage/#script-fetch-options> -pub struct ScriptFetchOptions { +pub(crate) struct ScriptFetchOptions { #[no_trace] - pub referrer: Referrer, - pub integrity_metadata: String, + pub(crate) referrer: Referrer, + pub(crate) integrity_metadata: String, #[no_trace] - pub credentials_mode: CredentialsMode, - pub cryptographic_nonce: String, + pub(crate) credentials_mode: CredentialsMode, + pub(crate) cryptographic_nonce: String, #[no_trace] - pub parser_metadata: ParserMetadata, + pub(crate) parser_metadata: ParserMetadata, #[no_trace] - pub referrer_policy: ReferrerPolicy, + pub(crate) referrer_policy: ReferrerPolicy, } impl ScriptFetchOptions { /// <https://html.spec.whatwg.org/multipage/#default-classic-script-fetch-options> - pub fn default_classic_script(global: &GlobalScope) -> ScriptFetchOptions { + pub(crate) fn default_classic_script(global: &GlobalScope) -> ScriptFetchOptions { Self { cryptographic_nonce: String::new(), integrity_metadata: String::new(), @@ -1602,7 +1602,7 @@ pub(crate) struct DynamicModuleList { } impl DynamicModuleList { - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self { requests: vec![], next_id: DynamicModuleId(Uuid::new_v4()), diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index f02ec3f4c04..5f084685445 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -42,7 +42,7 @@ use js::jsapi::{ use js::jsval::UndefinedValue; use js::panic::wrap_panic; use js::rust::wrappers::{GetPromiseIsHandled, JS_GetPromiseResult}; -pub use js::rust::ThreadSafeJSContext; +pub(crate) use js::rust::ThreadSafeJSContext; use js::rust::{ describe_scripted_caller, Handle, HandleObject as RustHandleObject, IntoHandle, JSEngine, JSEngineHandle, ParentRuntime, Runtime as RustRuntime, @@ -96,7 +96,7 @@ static SECURITY_CALLBACKS: JSSecurityCallbacks = JSSecurityCallbacks { }; #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)] -pub enum ScriptThreadEventCategory { +pub(crate) enum ScriptThreadEventCategory { AttachLayout, ConstellationMsg, DevtoolsMsg, @@ -418,7 +418,7 @@ unsafe extern "C" fn content_security_policy_allows( #[allow(unsafe_code, crown::unrooted_must_root)] /// <https://html.spec.whatwg.org/multipage/#notify-about-rejected-promises> -pub fn notify_about_rejected_promises(global: &GlobalScope) { +pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) { let cx = GlobalScope::get_cx(); unsafe { // Step 2. @@ -489,9 +489,9 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) { } #[derive(JSTraceable)] -pub struct Runtime { +pub(crate) struct Runtime { rt: RustRuntime, - pub microtask_queue: Rc<MicrotaskQueue>, + pub(crate) microtask_queue: Rc<MicrotaskQueue>, job_queue: *mut JobQueue, networking_task_src: Option<Box<SendableTaskSource>>, } @@ -929,7 +929,7 @@ unsafe fn set_gc_zeal_options(_: *mut RawJSContext) {} #[derive(Clone, Copy)] #[repr(transparent)] -pub struct JSContext(*mut RawJSContext); +pub(crate) struct JSContext(*mut RawJSContext); #[allow(unsafe_code)] impl JSContext { @@ -1011,30 +1011,30 @@ impl Deref for JSContext { } } -pub struct StreamConsumer(*mut JSStreamConsumer); +pub(crate) struct StreamConsumer(*mut JSStreamConsumer); #[allow(unsafe_code)] impl StreamConsumer { - pub fn consume_chunk(&self, stream: &[u8]) -> bool { + pub(crate) fn consume_chunk(&self, stream: &[u8]) -> bool { unsafe { let stream_ptr = stream.as_ptr(); StreamConsumerConsumeChunk(self.0, stream_ptr, stream.len()) } } - pub fn stream_end(&self) { + pub(crate) fn stream_end(&self) { unsafe { StreamConsumerStreamEnd(self.0); } } - pub fn stream_error(&self, error_code: usize) { + pub(crate) fn stream_error(&self, error_code: usize) { unsafe { StreamConsumerStreamError(self.0, error_code); } } - pub fn note_response_urls( + pub(crate) fn note_response_urls( &self, maybe_url: Option<String>, maybe_source_map_url: Option<String>, @@ -1150,7 +1150,7 @@ unsafe extern "C" fn report_stream_error(_cx: *mut RawJSContext, error_code: usi ); } -pub struct Runnable(*mut JSRunnable); +pub(crate) struct Runnable(*mut JSRunnable); #[allow(unsafe_code)] unsafe impl Sync for Runnable {} @@ -1172,12 +1172,12 @@ impl Runnable { /// as a function argument and reused when calling other functions whenever possible. Since it /// is only meaningful within the current stack frame, it is impossible to move it to a different /// thread or into a task that will execute asynchronously. -pub struct CanGc(std::marker::PhantomData<*mut ()>); +pub(crate) struct CanGc(std::marker::PhantomData<*mut ()>); impl CanGc { /// Create a new CanGc value, representing that a GC operation is possible within the /// current stack frame. - pub fn note() -> CanGc { + pub(crate) fn note() -> CanGc { CanGc(std::marker::PhantomData) } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 74c63bf1ebc..0ecef0de2d2 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -174,7 +174,7 @@ pub(crate) fn with_script_thread<R: Default>(f: impl FnOnce(&ScriptThread) -> R) /// The `JSTracer` argument must point to a valid `JSTracer` in memory. In addition, /// implementors of this method must ensure that all active objects are properly traced /// or else the garbage collector may end up collecting objects that are still reachable. -pub unsafe fn trace_thread(tr: *mut JSTracer) { +pub(crate) unsafe fn trace_thread(tr: *mut JSTracer) { with_script_thread(|script_thread| { trace!("tracing fields of ScriptThread"); script_thread.trace(tr); @@ -263,7 +263,7 @@ impl InProgressLoad { // which can trigger GC, and so we can end up tracing the script // thread during parsing. For this reason, we don't trace the // incomplete parser contexts during GC. -pub struct IncompleteParserContexts(RefCell<Vec<(PipelineId, ParserContext)>>); +pub(crate) struct IncompleteParserContexts(RefCell<Vec<(PipelineId, ParserContext)>>); unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>); @@ -542,33 +542,33 @@ impl ScriptThreadFactory for ScriptThread { } impl ScriptThread { - pub fn runtime_handle() -> ParentRuntime { + pub(crate) fn runtime_handle() -> ParentRuntime { with_optional_script_thread(|script_thread| { script_thread.unwrap().js_runtime.prepare_for_new_child() }) } - pub fn can_continue_running() -> bool { + pub(crate) fn can_continue_running() -> bool { with_script_thread(|script_thread| script_thread.can_continue_running_inner()) } - pub fn prepare_for_shutdown() { + pub(crate) fn prepare_for_shutdown() { with_script_thread(|script_thread| { script_thread.prepare_for_shutdown_inner(); }) } - pub fn set_mutation_observer_microtask_queued(value: bool) { + pub(crate) fn set_mutation_observer_microtask_queued(value: bool) { with_script_thread(|script_thread| { script_thread.mutation_observer_microtask_queued.set(value); }) } - pub fn is_mutation_observer_microtask_queued() -> bool { + pub(crate) fn is_mutation_observer_microtask_queued() -> bool { with_script_thread(|script_thread| script_thread.mutation_observer_microtask_queued.get()) } - pub fn add_mutation_observer(observer: &MutationObserver) { + pub(crate) fn add_mutation_observer(observer: &MutationObserver) { with_script_thread(|script_thread| { script_thread .mutation_observers @@ -577,7 +577,7 @@ impl ScriptThread { }) } - pub fn get_mutation_observers() -> Vec<DomRoot<MutationObserver>> { + pub(crate) fn get_mutation_observers() -> Vec<DomRoot<MutationObserver>> { with_script_thread(|script_thread| { script_thread .mutation_observers @@ -588,7 +588,7 @@ impl ScriptThread { }) } - pub fn mark_document_with_no_blocked_loads(doc: &Document) { + pub(crate) fn mark_document_with_no_blocked_loads(doc: &Document) { with_script_thread(|script_thread| { script_thread .docs_with_no_blocking_loads @@ -597,7 +597,7 @@ impl ScriptThread { }) } - pub fn page_headers_available( + pub(crate) fn page_headers_available( id: &PipelineId, metadata: Option<Metadata>, can_gc: CanGc, @@ -610,7 +610,7 @@ impl ScriptThread { /// Process a single event as if it were the next event /// in the queue for this window event-loop. /// Returns a boolean indicating whether further events should be processed. - pub fn process_event(msg: CommonScriptMsg) -> bool { + pub(crate) fn process_event(msg: CommonScriptMsg) -> bool { with_script_thread(|script_thread| { if !script_thread.can_continue_running_inner() { return false; @@ -626,7 +626,7 @@ impl ScriptThread { } // https://html.spec.whatwg.org/multipage/#await-a-stable-state - pub fn await_stable_state(task: Microtask) { + pub(crate) fn await_stable_state(task: Microtask) { with_script_thread(|script_thread| { script_thread .microtask_queue @@ -638,7 +638,7 @@ impl ScriptThread { /// for now only used to prevent cross-origin JS url evaluation. /// /// <https://github.com/whatwg/html/issues/2591> - pub fn check_load_origin(source: &LoadOrigin, target: &ImmutableOrigin) -> bool { + pub(crate) fn check_load_origin(source: &LoadOrigin, target: &ImmutableOrigin) -> bool { match (source, target) { (LoadOrigin::Constellation, _) | (LoadOrigin::WebDriver, _) => { // Always allow loads initiated by the constellation or webdriver. @@ -655,7 +655,7 @@ impl ScriptThread { } /// Step 13 of <https://html.spec.whatwg.org/multipage/#navigate> - pub fn navigate( + pub(crate) fn navigate( browsing_context: BrowsingContextId, pipeline_id: PipelineId, mut load_data: LoadData, @@ -709,7 +709,7 @@ impl ScriptThread { }); } - pub fn process_attach_layout(new_layout_info: NewLayoutInfo, origin: MutableOrigin) { + pub(crate) fn process_attach_layout(new_layout_info: NewLayoutInfo, origin: MutableOrigin) { with_script_thread(|script_thread| { let pipeline_id = Some(new_layout_info.new_pipeline_id); script_thread.profile_event( @@ -722,7 +722,7 @@ impl ScriptThread { }); } - pub fn get_top_level_for_browsing_context( + pub(crate) fn get_top_level_for_browsing_context( sender_pipeline: PipelineId, browsing_context_id: BrowsingContextId, ) -> Option<TopLevelBrowsingContextId> { @@ -731,21 +731,21 @@ impl ScriptThread { }) } - pub fn find_document(id: PipelineId) -> Option<DomRoot<Document>> { + pub(crate) fn find_document(id: PipelineId) -> Option<DomRoot<Document>> { with_script_thread(|script_thread| script_thread.documents.borrow().find_document(id)) } - pub fn set_user_interacting(interacting: bool) { + pub(crate) fn set_user_interacting(interacting: bool) { with_script_thread(|script_thread| { script_thread.is_user_interacting.set(interacting); }); } - pub fn is_user_interacting() -> bool { + pub(crate) fn is_user_interacting() -> bool { with_script_thread(|script_thread| script_thread.is_user_interacting.get()) } - pub fn get_fully_active_document_ids() -> HashSet<PipelineId> { + pub(crate) fn get_fully_active_document_ids() -> HashSet<PipelineId> { with_script_thread(|script_thread| { script_thread .documents @@ -765,7 +765,7 @@ impl ScriptThread { }) } - pub fn find_window_proxy(id: BrowsingContextId) -> Option<DomRoot<WindowProxy>> { + pub(crate) fn find_window_proxy(id: BrowsingContextId) -> Option<DomRoot<WindowProxy>> { with_script_thread(|script_thread| { script_thread .window_proxies @@ -775,7 +775,7 @@ impl ScriptThread { }) } - pub fn find_window_proxy_by_name(name: &DOMString) -> Option<DomRoot<WindowProxy>> { + pub(crate) fn find_window_proxy_by_name(name: &DOMString) -> Option<DomRoot<WindowProxy>> { with_script_thread(|script_thread| { for (_, proxy) in script_thread.window_proxies.borrow().iter() { if proxy.get_name() == *name { @@ -786,7 +786,7 @@ impl ScriptThread { }) } - pub fn worklet_thread_pool() -> Rc<WorkletThreadPool> { + pub(crate) fn worklet_thread_pool() -> Rc<WorkletThreadPool> { with_optional_script_thread(|script_thread| { let script_thread = script_thread.unwrap(); script_thread @@ -833,7 +833,7 @@ impl ScriptThread { .register_paint_worklet_modules(name, properties, painter); } - pub fn push_new_element_queue() { + pub(crate) fn push_new_element_queue() { with_script_thread(|script_thread| { script_thread .custom_element_reaction_stack @@ -841,7 +841,7 @@ impl ScriptThread { }) } - pub fn pop_current_element_queue(can_gc: CanGc) { + pub(crate) fn pop_current_element_queue(can_gc: CanGc) { with_script_thread(|script_thread| { script_thread .custom_element_reaction_stack @@ -849,7 +849,7 @@ impl ScriptThread { }) } - pub fn enqueue_callback_reaction( + pub(crate) fn enqueue_callback_reaction( element: &Element, reaction: CallbackReaction, definition: Option<Rc<CustomElementDefinition>>, @@ -861,7 +861,10 @@ impl ScriptThread { }) } - pub fn enqueue_upgrade_reaction(element: &Element, definition: Rc<CustomElementDefinition>) { + pub(crate) fn enqueue_upgrade_reaction( + element: &Element, + definition: Rc<CustomElementDefinition>, + ) { with_script_thread(|script_thread| { script_thread .custom_element_reaction_stack @@ -869,7 +872,7 @@ impl ScriptThread { }) } - pub fn invoke_backup_element_queue(can_gc: CanGc) { + pub(crate) fn invoke_backup_element_queue(can_gc: CanGc) { with_script_thread(|script_thread| { script_thread .custom_element_reaction_stack @@ -877,13 +880,13 @@ impl ScriptThread { }) } - pub fn save_node_id(node_id: String) { + pub(crate) fn save_node_id(node_id: String) { with_script_thread(|script_thread| { script_thread.node_ids.borrow_mut().insert(node_id); }) } - pub fn has_node_id(node_id: &str) -> bool { + pub(crate) fn has_node_id(node_id: &str) -> bool { with_script_thread(|script_thread| script_thread.node_ids.borrow().contains(node_id)) } @@ -1014,7 +1017,7 @@ impl ScriptThread { } #[allow(unsafe_code)] - pub fn get_cx(&self) -> JSContext { + pub(crate) fn get_cx(&self) -> JSContext { unsafe { JSContext::from_ptr(self.js_runtime.cx()) } } @@ -1039,7 +1042,7 @@ impl ScriptThread { /// Starts the script thread. After calling this method, the script thread will loop receiving /// messages on its port. - pub fn start(&self, can_gc: CanGc) { + pub(crate) fn start(&self, can_gc: CanGc) { debug!("Starting script thread."); while self.handle_msgs(can_gc) { // Go on... @@ -2888,7 +2891,7 @@ impl ScriptThread { } /// Handles animation tick requested during testing. - pub fn handle_tick_all_animations_for_testing(id: PipelineId) { + pub(crate) fn handle_tick_all_animations_for_testing(id: PipelineId) { with_script_thread(|script_thread| { let Some(document) = script_thread.documents.borrow().find_document(id) else { warn!("Animation tick for tests for closed pipeline {id}."); @@ -3461,7 +3464,7 @@ impl ScriptThread { /// Turn javascript: URL into JS code to eval, according to the steps in /// <https://html.spec.whatwg.org/multipage/#javascript-protocol> - pub fn eval_js_url(global_scope: &GlobalScope, load_data: &mut LoadData, can_gc: CanGc) { + pub(crate) fn eval_js_url(global_scope: &GlobalScope, load_data: &mut LoadData, can_gc: CanGc) { // This slice of the URL’s serialization is equivalent to (5.) to (7.): // Start with the scheme data of the parsed URL; // append question mark and query component, if any; @@ -3716,7 +3719,7 @@ impl ScriptThread { }; } - pub fn enqueue_microtask(job: Microtask) { + pub(crate) fn enqueue_microtask(job: Microtask) { with_script_thread(|script_thread| { script_thread .microtask_queue diff --git a/components/script/security_manager.rs b/components/script/security_manager.rs index 22d99c07e72..1b5de378412 100644 --- a/components/script/security_manager.rs +++ b/components/script/security_manager.rs @@ -23,7 +23,7 @@ use crate::dom::types::GlobalScope; use crate::script_runtime::CanGc; use crate::task::TaskOnce; -pub struct CSPViolationReporter { +pub(crate) struct CSPViolationReporter { sample: Option<String>, filename: String, report_only: bool, @@ -35,7 +35,7 @@ pub struct CSPViolationReporter { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub struct SecurityPolicyViolationReport { +pub(crate) struct SecurityPolicyViolationReport { sample: Option<String>, #[serde(rename = "blockedURL")] blocked_url: String, @@ -53,7 +53,7 @@ pub struct SecurityPolicyViolationReport { } impl CSPViolationReporter { - pub fn new( + pub(crate) fn new( global: &GlobalScope, sample: Option<String>, report_only: bool, diff --git a/components/script/serviceworker_manager.rs b/components/script/serviceworker_manager.rs index 3be5d3a9ef2..9f1ad777110 100644 --- a/components/script/serviceworker_manager.rs +++ b/components/script/serviceworker_manager.rs @@ -38,13 +38,13 @@ enum Message { /// <https://w3c.github.io/ServiceWorker/#dfn-service-worker> #[derive(Clone)] -struct ServiceWorker { +pub(crate) struct ServiceWorker { /// A unique identifer. - pub id: ServiceWorkerId, + pub(crate) id: ServiceWorkerId, /// <https://w3c.github.io/ServiceWorker/#dfn-script-url> - pub script_url: ServoUrl, + pub(crate) script_url: ServoUrl, /// A sender to the running service worker scope. - pub sender: Sender<ServiceWorkerScriptMsg>, + pub(crate) sender: Sender<ServiceWorkerScriptMsg>, } impl ServiceWorker { @@ -140,7 +140,7 @@ struct ServiceWorkerRegistration { } impl ServiceWorkerRegistration { - pub fn new() -> ServiceWorkerRegistration { + pub(crate) fn new() -> ServiceWorkerRegistration { ServiceWorkerRegistration { id: ServiceWorkerRegistrationId::new(), active_worker: None, @@ -241,7 +241,7 @@ impl ServiceWorkerManager { } } - pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> { + pub(crate) fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> { for scope in self.registrations.keys() { if longest_prefix_match(scope, load_url) { return Some(scope.clone()); @@ -516,6 +516,6 @@ impl ServiceWorkerManagerFactory for ServiceWorkerManager { } } -pub fn serviceworker_enabled() -> bool { +pub(crate) fn serviceworker_enabled() -> bool { pref!(dom.serviceworker.enabled) } diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 4266d50ce34..8f6f83390e3 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -47,7 +47,7 @@ use crate::unminify::{ create_output_file, create_temp_files, execute_js_beautify, BeautifyFileType, }; -pub trait StylesheetOwner { +pub(crate) trait StylesheetOwner { /// Returns whether this element was inserted by the parser (i.e., it should /// trigger a document-load-blocking load). fn parser_inserted(&self) -> bool; @@ -66,14 +66,14 @@ pub trait StylesheetOwner { fn set_origin_clean(&self, origin_clean: bool); } -pub enum StylesheetContextSource { +pub(crate) enum StylesheetContextSource { // NB: `media` is just an option so we avoid cloning it. LinkElement { media: Option<MediaList> }, Import(Arc<Stylesheet>), } /// The context required for asynchronously loading an external stylesheet. -pub struct StylesheetContext { +pub(crate) struct StylesheetContext { /// The element that initiated the request. elem: Trusted<HTMLElement>, source: StylesheetContextSource, @@ -292,18 +292,18 @@ impl ResourceTimingListener for StylesheetContext { } } -pub struct StylesheetLoader<'a> { +pub(crate) struct StylesheetLoader<'a> { elem: &'a HTMLElement, } impl<'a> StylesheetLoader<'a> { - pub fn for_element(element: &'a HTMLElement) -> Self { + pub(crate) fn for_element(element: &'a HTMLElement) -> Self { StylesheetLoader { elem: element } } } impl StylesheetLoader<'_> { - pub fn load( + pub(crate) fn load( &self, source: StylesheetContextSource, url: ServoUrl, diff --git a/components/script/stylesheet_set.rs b/components/script/stylesheet_set.rs index c4794b62d12..b3de20e379f 100644 --- a/components/script/stylesheet_set.rs +++ b/components/script/stylesheet_set.rs @@ -8,7 +8,7 @@ use style::stylesheet_set::{AuthorStylesheetSet, DocumentStylesheetSet}; use style::stylesheets::StylesheetInDocument; /// Functionality common to DocumentStylesheetSet and AuthorStylesheetSet. -pub enum StylesheetSetRef<'a, S> +pub(crate) enum StylesheetSetRef<'a, S> where S: StylesheetInDocument + PartialEq + 'static, { @@ -25,7 +25,7 @@ where /// Appends a new stylesheet to the current set. /// /// No device implies not computing invalidations. - pub fn append_stylesheet( + pub(crate) fn append_stylesheet( &mut self, device: Option<&Device>, sheet: S, @@ -38,7 +38,7 @@ where } /// Insert a given stylesheet before another stylesheet in the document. - pub fn insert_stylesheet_before( + pub(crate) fn insert_stylesheet_before( &mut self, device: Option<&Device>, sheet: S, @@ -56,7 +56,7 @@ where } /// Remove a given stylesheet from the set. - pub fn remove_stylesheet( + pub(crate) fn remove_stylesheet( &mut self, device: Option<&Device>, sheet: S, diff --git a/components/script/task.rs b/components/script/task.rs index 3b808828ce0..ce99731df79 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -29,7 +29,7 @@ macro_rules! task { } /// A task that can be run. The name method is for profiling purposes. -pub trait TaskOnce: Send { +pub(crate) trait TaskOnce: Send { #[allow(unsafe_code)] fn name(&self) -> &'static str { ::std::any::type_name::<Self>() @@ -39,7 +39,7 @@ pub trait TaskOnce: Send { } /// A boxed version of `TaskOnce`. -pub trait TaskBox: Send { +pub(crate) trait TaskBox: Send { fn name(&self) -> &'static str; fn run_box(self: Box<Self>); @@ -68,9 +68,9 @@ impl fmt::Debug for dyn TaskBox { /// Encapsulated state required to create cancellable tasks from non-script threads. #[derive(Clone, Default, JSTraceable, MallocSizeOf)] -pub struct TaskCanceller { +pub(crate) struct TaskCanceller { #[ignore_malloc_size_of = "This is difficult, because only one of them should be measured"] - pub cancelled: Arc<AtomicBool>, + pub(crate) cancelled: Arc<AtomicBool>, } impl TaskCanceller { @@ -88,7 +88,7 @@ impl TaskCanceller { } /// A task that can be cancelled by toggling a shared flag. -pub struct CancellableTask<T: TaskOnce> { +pub(crate) struct CancellableTask<T: TaskOnce> { canceller: TaskCanceller, inner: T, } diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index e63f8f72794..5dd6a2f3b01 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -18,7 +18,7 @@ use crate::script_thread::ScriptThread; use crate::task::TaskBox; use crate::task_source::TaskSourceName; -pub type QueuedTask = ( +pub(crate) type QueuedTask = ( Option<TrustedWorkerAddress>, ScriptThreadEventCategory, Box<dyn TaskBox>, @@ -27,7 +27,7 @@ pub type QueuedTask = ( ); /// Defining the operations used to convert from a msg T to a QueuedTask. -pub trait QueuedTaskConversion { +pub(crate) trait QueuedTaskConversion { fn task_source_name(&self) -> Option<&TaskSourceName>; fn pipeline_id(&self) -> Option<PipelineId>; fn into_queued_task(self) -> Option<QueuedTask>; @@ -37,7 +37,7 @@ pub trait QueuedTaskConversion { fn is_wake_up(&self) -> bool; } -pub struct TaskQueue<T> { +pub(crate) struct TaskQueue<T> { /// The original port on which the task-sources send tasks as messages. port: Receiver<T>, /// A sender to ensure the port doesn't block on select while there are throttled tasks. @@ -53,7 +53,7 @@ pub struct TaskQueue<T> { } impl<T: QueuedTaskConversion> TaskQueue<T> { - pub fn new(port: Receiver<T>, wake_up_sender: Sender<T>) -> TaskQueue<T> { + pub(crate) fn new(port: Receiver<T>, wake_up_sender: Sender<T>) -> TaskQueue<T> { TaskQueue { port, wake_up_sender, @@ -182,7 +182,7 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { /// Reset the queue for a new iteration of the event-loop, /// returning the port about whose readiness we want to be notified. - pub fn select(&self) -> &crossbeam_channel::Receiver<T> { + pub(crate) fn select(&self) -> &crossbeam_channel::Receiver<T> { // This is a new iteration of the event-loop, so we reset the "business" counter. self.taken_task_counter.set(0); // We want to be notified when the script-port is ready to receive. @@ -191,19 +191,19 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { } /// Take a message from the front of the queue, without waiting if empty. - pub fn recv(&self) -> Result<T, ()> { + pub(crate) fn recv(&self) -> Result<T, ()> { self.msg_queue.borrow_mut().pop_front().ok_or(()) } /// Take all tasks again and then run `recv()`. - pub fn take_tasks_and_recv(&self) -> Result<T, ()> { + pub(crate) fn take_tasks_and_recv(&self) -> Result<T, ()> { self.take_tasks(T::wake_up_msg()); self.recv() } /// Drain the queue for the current iteration of the event-loop. /// Holding-back throttles above a given high-water mark. - pub fn take_tasks(&self, first_msg: T) { + pub(crate) fn take_tasks(&self, first_msg: T) { // High-watermark: once reached, throttled tasks will be held-back. const PER_ITERATION_MAX: u64 = 5; let fully_active = ScriptThread::get_fully_active_document_ids(); diff --git a/components/script/task_source.rs b/components/script/task_source.rs index 0b9bf41e3be..418dcf5501c 100644 --- a/components/script/task_source.rs +++ b/components/script/task_source.rs @@ -23,7 +23,7 @@ use crate::task_manager::TaskManager; /// Note: When adding or removing a [`TaskSourceName`], be sure to also update the return value of /// [`TaskSourceName::all`]. #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)] -pub enum TaskSourceName { +pub(crate) enum TaskSourceName { DOMManipulation, FileReading, HistoryTraversal, @@ -64,7 +64,7 @@ impl From<TaskSourceName> for ScriptThreadEventCategory { } impl TaskSourceName { - pub fn all() -> &'static [TaskSourceName] { + pub(crate) fn all() -> &'static [TaskSourceName] { &[ TaskSourceName::DOMManipulation, TaskSourceName::FileReading, @@ -84,8 +84,8 @@ impl TaskSourceName { } pub(crate) struct TaskSource<'task_manager> { - pub task_manager: &'task_manager TaskManager, - pub name: TaskSourceName, + pub(crate) task_manager: &'task_manager TaskManager, + pub(crate) name: TaskSourceName, } impl TaskSource<'_> { @@ -160,11 +160,11 @@ impl<'task_manager> From<TaskSource<'task_manager>> for SendableTaskSource { #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct SendableTaskSource { - pub sender: ScriptEventLoopSender, + pub(crate) sender: ScriptEventLoopSender, #[no_trace] - pub pipeline_id: PipelineId, - pub name: TaskSourceName, - pub canceller: TaskCanceller, + pub(crate) pipeline_id: PipelineId, + pub(crate) name: TaskSourceName, + pub(crate) canceller: TaskCanceller, } impl SendableTaskSource { diff --git a/components/script/test.rs b/components/script/test.rs index 406190b0717..1ddaf7e64e8 100644 --- a/components/script/test.rs +++ b/components/script/test.rs @@ -3,12 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ // For compile-fail tests only. -pub use crate::dom::bindings::cell::DomRefCell; +//pub use crate::dom::bindings::cell::DomRefCell; pub use crate::dom::bindings::refcounted::TrustedPromise; -pub use crate::dom::bindings::root::Dom; +//pub use crate::dom::bindings::root::Dom; pub use crate::dom::bindings::str::{ByteString, DOMString}; pub use crate::dom::headers::normalize_value; -pub use crate::dom::node::Node; +//pub use crate::dom::node::Node; pub mod area { pub use crate::dom::htmlareaelement::{Area, Shape}; @@ -67,3 +67,11 @@ pub mod srcset { pub mod timeranges { pub use crate::dom::timeranges::TimeRangesContainer; } + +pub mod textinput { + pub use crate::clipboard_provider::ClipboardProvider; + pub use crate::textinput::{ + Direction, Lines, Selection, SelectionDirection, TextInput, TextPoint, UTF16CodeUnits, + UTF8Bytes, + }; +} diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 38fbf3543d1..338303fc7b8 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -42,11 +42,11 @@ impl UTF8Bytes { UTF8Bytes(1) } - pub fn unwrap_range(byte_range: Range<UTF8Bytes>) -> Range<usize> { + pub(crate) fn unwrap_range(byte_range: Range<UTF8Bytes>) -> Range<usize> { byte_range.start.0..byte_range.end.0 } - pub fn saturating_sub(self, other: UTF8Bytes) -> UTF8Bytes { + pub(crate) fn saturating_sub(self, other: UTF8Bytes) -> UTF8Bytes { if self > other { UTF8Bytes(self.0 - other.0) } else { @@ -90,7 +90,7 @@ impl UTF16CodeUnits { UTF16CodeUnits(1) } - pub fn saturating_sub(self, other: UTF16CodeUnits) -> UTF16CodeUnits { + pub(crate) fn saturating_sub(self, other: UTF16CodeUnits) -> UTF16CodeUnits { if self > other { UTF16CodeUnits(self.0 - other.0) } else { @@ -154,7 +154,7 @@ impl TextPoint { } #[derive(Clone, Copy, PartialEq)] -pub struct SelectionState { +pub(crate) struct SelectionState { start: TextPoint, end: TextPoint, direction: SelectionDirection, @@ -223,9 +223,9 @@ pub enum Direction { // Some shortcuts use Cmd on Mac and Control on other systems. #[cfg(target_os = "macos")] -pub const CMD_OR_CONTROL: Modifiers = Modifiers::META; +pub(crate) const CMD_OR_CONTROL: Modifiers = Modifiers::META; #[cfg(not(target_os = "macos"))] -pub const CMD_OR_CONTROL: Modifiers = Modifiers::CONTROL; +pub(crate) const CMD_OR_CONTROL: Modifiers = Modifiers::CONTROL; /// The length in bytes of the first n characters in a UTF-8 string. /// @@ -297,16 +297,16 @@ impl<T: ClipboardProvider> TextInput<T> { self.selection_direction } - pub fn set_max_length(&mut self, length: Option<UTF16CodeUnits>) { + pub(crate) fn set_max_length(&mut self, length: Option<UTF16CodeUnits>) { self.max_length = length; } - pub fn set_min_length(&mut self, length: Option<UTF16CodeUnits>) { + pub(crate) fn set_min_length(&mut self, length: Option<UTF16CodeUnits>) { self.min_length = length; } /// Was last edit made by set_content? - pub fn was_last_change_by_set_content(&self) -> bool { + pub(crate) fn was_last_change_by_set_content(&self) -> bool { self.was_last_change_by_set_content } @@ -363,7 +363,7 @@ impl<T: ClipboardProvider> TextInput<T> { /// Whether or not there is an active selection (the selection may be zero-length) #[inline] - pub fn has_selection(&self) -> bool { + pub(crate) fn has_selection(&self) -> bool { self.selection_origin.is_some() } @@ -376,12 +376,12 @@ impl<T: ClipboardProvider> TextInput<T> { /// Return the selection range as byte offsets from the start of the content. /// /// If there is no selection, returns an empty range at the edit point. - pub fn sorted_selection_offsets_range(&self) -> Range<UTF8Bytes> { + pub(crate) fn sorted_selection_offsets_range(&self) -> Range<UTF8Bytes> { self.selection_start_offset()..self.selection_end_offset() } /// The state of the current selection. Can be used to compare whether selection state has changed. - pub fn selection_state(&self) -> SelectionState { + pub(crate) fn selection_state(&self) -> SelectionState { SelectionState { start: self.selection_start(), end: self.selection_end(), @@ -412,7 +412,7 @@ impl<T: ClipboardProvider> TextInput<T> { debug_assert!(self.edit_point.index <= self.lines[self.edit_point.line].len_utf8()); } - pub fn get_selection_text(&self) -> Option<String> { + pub(crate) fn get_selection_text(&self) -> Option<String> { let text = self.fold_selection_slices(String::new(), |s, slice| s.push_str(slice)); if text.is_empty() { return None; @@ -728,7 +728,7 @@ impl<T: ClipboardProvider> TextInput<T> { } /// Remove the current selection and set the edit point to the end of the content. - pub fn clear_selection_to_limit(&mut self, direction: Direction) { + pub(crate) fn clear_selection_to_limit(&mut self, direction: Direction) { self.clear_selection(); self.adjust_horizontal_to_limit(direction, Selection::NotSelected); } @@ -814,7 +814,7 @@ impl<T: ClipboardProvider> TextInput<T> { self.perform_horizontal_adjustment(UTF8Bytes(shift), direction, select); } - pub fn adjust_horizontal_to_limit(&mut self, direction: Direction, select: Selection) { + pub(crate) fn adjust_horizontal_to_limit(&mut self, direction: Direction, select: Selection) { if self.adjust_selection_for_horizontal_change(direction, select) { return; } @@ -831,7 +831,7 @@ impl<T: ClipboardProvider> TextInput<T> { } /// Process a given `KeyboardEvent` and return an action for the caller to execute. - pub fn handle_keydown(&mut self, event: &KeyboardEvent) -> KeyReaction { + pub(crate) fn handle_keydown(&mut self, event: &KeyboardEvent) -> KeyReaction { let key = event.key(); let mods = event.modifiers(); self.handle_keydown_aux(key, mods, cfg!(target_os = "macos")) @@ -974,18 +974,18 @@ impl<T: ClipboardProvider> TextInput<T> { .unwrap() } - pub fn handle_compositionend(&mut self, event: &CompositionEvent) -> KeyReaction { + pub(crate) fn handle_compositionend(&mut self, event: &CompositionEvent) -> KeyReaction { self.insert_string(event.data()); KeyReaction::DispatchInput } /// Whether the content is empty. - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.lines.len() <= 1 && self.lines.first().map_or(true, |line| line.is_empty()) } /// The length of the content in bytes. - pub fn len_utf8(&self) -> UTF8Bytes { + pub(crate) fn len_utf8(&self) -> UTF8Bytes { self.lines .iter() .fold(UTF8Bytes::zero(), |m, l| { @@ -995,7 +995,7 @@ impl<T: ClipboardProvider> TextInput<T> { } /// The total number of code units required to encode the content in utf16. - pub fn utf16_len(&self) -> UTF16CodeUnits { + pub(crate) fn utf16_len(&self) -> UTF16CodeUnits { self.lines .iter() .fold(UTF16CodeUnits::zero(), |m, l| { @@ -1006,7 +1006,7 @@ impl<T: ClipboardProvider> TextInput<T> { } /// The length of the content in Unicode code points. - pub fn char_count(&self) -> usize { + pub(crate) fn char_count(&self) -> usize { self.lines.iter().fold(0, |m, l| { m + l.chars().count() + 1 // + 1 for the '\n' }) - 1 @@ -1025,7 +1025,7 @@ impl<T: ClipboardProvider> TextInput<T> { } /// Get a reference to the contents of a single-line text input. Panics if self is a multiline input. - pub fn single_line_content(&self) -> &DOMString { + pub(crate) fn single_line_content(&self) -> &DOMString { assert!(!self.multiline); &self.lines[0] } diff --git a/components/script/timers.rs b/components/script/timers.rs index 495ecff5a44..9999dac01d7 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -37,10 +37,10 @@ use crate::script_thread::ScriptThread; use crate::task_source::SendableTaskSource; #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub struct OneshotTimerHandle(i32); +pub(crate) struct OneshotTimerHandle(i32); #[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] -pub struct OneshotTimers { +pub(crate) struct OneshotTimers { global_scope: DomRoot<GlobalScope>, js_timers: JsTimers, next_timer_handle: Cell<OneshotTimerHandle>, @@ -74,7 +74,7 @@ struct OneshotTimer { // A replacement trait would have a method such as // `invoke<T: DomObject>(self: Box<Self>, this: &T, js_timers: &JsTimers);`. #[derive(JSTraceable, MallocSizeOf)] -pub enum OneshotTimerCallback { +pub(crate) enum OneshotTimerCallback { XhrTimeout(XHRTimeoutCallback), EventSourceTimeout(EventSourceTimeoutCallback), JsTimer(JsTimerTask), @@ -119,7 +119,7 @@ impl PartialEq for OneshotTimer { } impl OneshotTimers { - pub fn new(global_scope: &GlobalScope) -> OneshotTimers { + pub(crate) fn new(global_scope: &GlobalScope) -> OneshotTimers { OneshotTimers { global_scope: DomRoot::from_ref(global_scope), js_timers: JsTimers::default(), @@ -131,7 +131,7 @@ impl OneshotTimers { } } - pub fn schedule_callback( + pub(crate) fn schedule_callback( &self, callback: OneshotTimerCallback, duration: Duration, @@ -161,7 +161,7 @@ impl OneshotTimers { new_handle } - pub fn unschedule_callback(&self, handle: OneshotTimerHandle) { + pub(crate) fn unschedule_callback(&self, handle: OneshotTimerHandle) { let was_next = self.is_next_timer(handle); self.timers.borrow_mut().retain(|t| t.handle != handle); @@ -179,7 +179,7 @@ impl OneshotTimers { } } - pub fn fire_timer(&self, id: TimerEventId, global: &GlobalScope, can_gc: CanGc) { + pub(crate) fn fire_timer(&self, id: TimerEventId, global: &GlobalScope, can_gc: CanGc) { let expected_id = self.expected_event_id.get(); if expected_id != id { debug!( @@ -236,17 +236,17 @@ impl OneshotTimers { } } - pub fn slow_down(&self) { + pub(crate) fn slow_down(&self) { let min_duration_ms = pref!(js.timers.minimum_duration) as u64; self.js_timers .set_min_duration(Duration::from_millis(min_duration_ms)); } - pub fn speed_up(&self) { + pub(crate) fn speed_up(&self) { self.js_timers.remove_min_duration(); } - pub fn suspend(&self) { + pub(crate) fn suspend(&self) { // Suspend is idempotent: do nothing if the timers are already suspended. if self.suspended_since.get().is_some() { return warn!("Suspending an already suspended timer."); @@ -257,7 +257,7 @@ impl OneshotTimers { self.invalidate_expected_event_id(); } - pub fn resume(&self) { + pub(crate) fn resume(&self) { // Resume is idempotent: do nothing if the timers are already resumed. let additional_offset = match self.suspended_since.get() { Some(suspended_since) => Instant::now() - suspended_since, @@ -315,7 +315,7 @@ impl OneshotTimers { next_id } - pub fn set_timeout_or_interval( + pub(crate) fn set_timeout_or_interval( &self, global: &GlobalScope, callback: TimerCallback, @@ -334,16 +334,16 @@ impl OneshotTimers { ) } - pub fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32) { + pub(crate) fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32) { self.js_timers.clear_timeout_or_interval(global, handle) } } #[derive(Clone, Copy, Eq, Hash, JSTraceable, MallocSizeOf, Ord, PartialEq, PartialOrd)] -pub struct JsTimerHandle(i32); +pub(crate) struct JsTimerHandle(i32); #[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] -pub struct JsTimers { +pub(crate) struct JsTimers { next_timer_handle: Cell<JsTimerHandle>, /// <https://html.spec.whatwg.org/multipage/#list-of-active-timers> active_timers: DomRefCell<HashMap<JsTimerHandle, JsTimerEntry>>, @@ -363,7 +363,7 @@ struct JsTimerEntry { // to the function when calling it) // TODO: Handle rooting during invocation when movable GC is turned on #[derive(JSTraceable, MallocSizeOf)] -pub struct JsTimerTask { +pub(crate) struct JsTimerTask { #[ignore_malloc_size_of = "Because it is non-owning"] handle: JsTimerHandle, #[no_trace] @@ -377,13 +377,13 @@ pub struct JsTimerTask { // Enum allowing more descriptive values for the is_interval field #[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)] -pub enum IsInterval { +pub(crate) enum IsInterval { Interval, NonInterval, } #[derive(Clone)] -pub enum TimerCallback { +pub(crate) enum TimerCallback { StringTimerCallback(DOMString), FunctionTimerCallback(Rc<Function>), } @@ -410,7 +410,7 @@ impl Default for JsTimers { impl JsTimers { // see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps - pub fn set_timeout_or_interval( + pub(crate) fn set_timeout_or_interval( &self, global: &GlobalScope, callback: TimerCallback, @@ -472,7 +472,7 @@ impl JsTimers { new_handle } - pub fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32) { + pub(crate) fn clear_timeout_or_interval(&self, global: &GlobalScope, handle: i32) { let mut active_timers = self.active_timers.borrow_mut(); if let Some(entry) = active_timers.remove(&JsTimerHandle(handle)) { @@ -480,11 +480,11 @@ impl JsTimers { } } - pub fn set_min_duration(&self, duration: Duration) { + pub(crate) fn set_min_duration(&self, duration: Duration) { self.min_duration.set(Some(duration)); } - pub fn remove_min_duration(&self) { + pub(crate) fn remove_min_duration(&self) { self.min_duration.set(None); } @@ -530,7 +530,7 @@ fn clamp_duration(nesting_level: u32, unclamped: Duration) -> Duration { impl JsTimerTask { // see https://html.spec.whatwg.org/multipage/#timer-initialisation-steps - pub fn invoke<T: DomObject>(self, this: &T, timers: &JsTimers, can_gc: CanGc) { + pub(crate) fn invoke<T: DomObject>(self, this: &T, timers: &JsTimers, can_gc: CanGc) { // step 4.1 can be ignored, because we proactively prevent execution // of this task when its scheduled execution is canceled. diff --git a/components/script/unminify.rs b/components/script/unminify.rs index 81bb5beeac9..56d4251cb95 100644 --- a/components/script/unminify.rs +++ b/components/script/unminify.rs @@ -23,7 +23,7 @@ pub(crate) trait ScriptSource { fn is_external(&self) -> bool; } -pub fn create_temp_files() -> Option<(NamedTempFile, File)> { +pub(crate) fn create_temp_files() -> Option<(NamedTempFile, File)> { // Write the minified code to a temporary file and pass its path as an argument // to js-beautify to read from. Meanwhile, redirect the process' stdout into // another temporary file and read that into a string. This avoids some hangs @@ -39,12 +39,12 @@ pub fn create_temp_files() -> Option<(NamedTempFile, File)> { } #[derive(Debug)] -pub enum BeautifyFileType { +pub(crate) enum BeautifyFileType { Css, Js, } -pub fn execute_js_beautify(input: &Path, output: File, file_type: BeautifyFileType) -> bool { +pub(crate) fn execute_js_beautify(input: &Path, output: File, file_type: BeautifyFileType) -> bool { let mut cmd = Command::new("js-beautify"); match file_type { BeautifyFileType::Js => (), @@ -64,7 +64,7 @@ pub fn execute_js_beautify(input: &Path, output: File, file_type: BeautifyFileTy } } -pub fn create_output_file( +pub(crate) fn create_output_file( unminified_dir: String, url: &ServoUrl, external: Option<bool>, diff --git a/components/script/unpremultiplytable.rs b/components/script/unpremultiplytable.rs index a595ad5a1a1..3145f104671 100644 --- a/components/script/unpremultiplytable.rs +++ b/components/script/unpremultiplytable.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/. */ -pub static UNPREMULTIPLY_TABLE: [u8; 256 * 256] = [ +pub(crate) static UNPREMULTIPLY_TABLE: [u8; 256 * 256] = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 45c1cc153db..09281de44b8 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -159,7 +159,7 @@ unsafe fn object_has_to_json_property( } #[allow(unsafe_code)] -pub unsafe fn jsval_to_webdriver( +pub(crate) unsafe fn jsval_to_webdriver( cx: *mut JSContext, global_scope: &GlobalScope, val: HandleValue, @@ -320,7 +320,7 @@ pub unsafe fn jsval_to_webdriver( } #[allow(unsafe_code)] -pub fn handle_execute_script( +pub(crate) fn handle_execute_script( window: Option<DomRoot<Window>>, eval: String, reply: IpcSender<WebDriverJSResult>, @@ -352,7 +352,7 @@ pub fn handle_execute_script( } } -pub fn handle_execute_async_script( +pub(crate) fn handle_execute_async_script( window: Option<DomRoot<Window>>, eval: String, reply: IpcSender<WebDriverJSResult>, @@ -381,7 +381,7 @@ pub fn handle_execute_async_script( } } -pub fn handle_get_browsing_context_id( +pub(crate) fn handle_get_browsing_context_id( documents: &DocumentCollection, pipeline: PipelineId, webdriver_frame_id: WebDriverFrameId, @@ -447,7 +447,7 @@ fn get_element_in_view_center_point(element: &Element, can_gc: CanGc) -> Option< }) } -pub fn handle_get_element_in_view_center_point( +pub(crate) fn handle_get_element_in_view_center_point( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -464,7 +464,7 @@ pub fn handle_get_element_in_view_center_point( .unwrap(); } -pub fn handle_find_element_css( +pub(crate) fn handle_find_element_css( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -485,7 +485,7 @@ pub fn handle_find_element_css( .unwrap(); } -pub fn handle_find_element_link_text( +pub(crate) fn handle_find_element_link_text( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -504,7 +504,7 @@ pub fn handle_find_element_link_text( .unwrap(); } -pub fn handle_find_element_tag_name( +pub(crate) fn handle_find_element_tag_name( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -526,7 +526,7 @@ pub fn handle_find_element_tag_name( .unwrap(); } -pub fn handle_find_elements_css( +pub(crate) fn handle_find_elements_css( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -552,7 +552,7 @@ pub fn handle_find_elements_css( .unwrap(); } -pub fn handle_find_elements_link_text( +pub(crate) fn handle_find_elements_link_text( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -571,7 +571,7 @@ pub fn handle_find_elements_link_text( .unwrap(); } -pub fn handle_find_elements_tag_name( +pub(crate) fn handle_find_elements_tag_name( documents: &DocumentCollection, pipeline: PipelineId, selector: String, @@ -593,7 +593,7 @@ pub fn handle_find_elements_tag_name( .unwrap(); } -pub fn handle_find_element_element_css( +pub(crate) fn handle_find_element_element_css( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -611,7 +611,7 @@ pub fn handle_find_element_element_css( .unwrap(); } -pub fn handle_find_element_element_link_text( +pub(crate) fn handle_find_element_element_link_text( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -627,7 +627,7 @@ pub fn handle_find_element_element_link_text( .unwrap(); } -pub fn handle_find_element_element_tag_name( +pub(crate) fn handle_find_element_element_tag_name( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -650,7 +650,7 @@ pub fn handle_find_element_element_tag_name( .unwrap(); } -pub fn handle_find_element_elements_css( +pub(crate) fn handle_find_element_elements_css( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -673,7 +673,7 @@ pub fn handle_find_element_elements_css( .unwrap(); } -pub fn handle_find_element_elements_link_text( +pub(crate) fn handle_find_element_elements_link_text( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -689,7 +689,7 @@ pub fn handle_find_element_elements_link_text( .unwrap(); } -pub fn handle_find_element_elements_tag_name( +pub(crate) fn handle_find_element_elements_tag_name( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -712,7 +712,7 @@ pub fn handle_find_element_elements_tag_name( .unwrap(); } -pub fn handle_focus_element( +pub(crate) fn handle_focus_element( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -735,7 +735,7 @@ pub fn handle_focus_element( .unwrap(); } -pub fn handle_get_active_element( +pub(crate) fn handle_get_active_element( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Option<String>>, @@ -750,7 +750,7 @@ pub fn handle_get_active_element( .unwrap(); } -pub fn handle_get_page_source( +pub(crate) fn handle_get_page_source( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Result<String, ErrorStatus>>, @@ -779,7 +779,7 @@ pub fn handle_get_page_source( .unwrap(); } -pub fn handle_get_cookies( +pub(crate) fn handle_get_cookies( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Vec<Serde<Cookie<'static>>>>, @@ -805,7 +805,7 @@ pub fn handle_get_cookies( } // https://w3c.github.io/webdriver/webdriver-spec.html#get-cookie -pub fn handle_get_cookie( +pub(crate) fn handle_get_cookie( documents: &DocumentCollection, pipeline: PipelineId, name: String, @@ -836,7 +836,7 @@ pub fn handle_get_cookie( } // https://w3c.github.io/webdriver/webdriver-spec.html#add-cookie -pub fn handle_add_cookie( +pub(crate) fn handle_add_cookie( documents: &DocumentCollection, pipeline: PipelineId, cookie: Cookie<'static>, @@ -883,7 +883,7 @@ pub fn handle_add_cookie( .unwrap(); } -pub fn handle_delete_cookies( +pub(crate) fn handle_delete_cookies( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<Result<(), ErrorStatus>>, @@ -904,7 +904,7 @@ pub fn handle_delete_cookies( reply.send(Ok(())).unwrap(); } -pub fn handle_get_title( +pub(crate) fn handle_get_title( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<String>, @@ -920,7 +920,7 @@ pub fn handle_get_title( .unwrap(); } -pub fn handle_get_rect( +pub(crate) fn handle_get_rect( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -966,7 +966,7 @@ pub fn handle_get_rect( .unwrap(); } -pub fn handle_get_bounding_client_rect( +pub(crate) fn handle_get_bounding_client_rect( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -991,7 +991,7 @@ pub fn handle_get_bounding_client_rect( .unwrap(); } -pub fn handle_get_text( +pub(crate) fn handle_get_text( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -1005,7 +1005,7 @@ pub fn handle_get_text( .unwrap(); } -pub fn handle_get_name( +pub(crate) fn handle_get_name( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -1019,7 +1019,7 @@ pub fn handle_get_name( .unwrap(); } -pub fn handle_get_attribute( +pub(crate) fn handle_get_attribute( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -1039,7 +1039,7 @@ pub fn handle_get_attribute( } #[allow(unsafe_code)] -pub fn handle_get_property( +pub(crate) fn handle_get_property( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -1078,7 +1078,7 @@ pub fn handle_get_property( .unwrap(); } -pub fn handle_get_css( +pub(crate) fn handle_get_css( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, @@ -1101,7 +1101,7 @@ pub fn handle_get_css( .unwrap(); } -pub fn handle_get_url( +pub(crate) fn handle_get_url( documents: &DocumentCollection, pipeline: PipelineId, reply: IpcSender<ServoUrl>, @@ -1118,7 +1118,7 @@ pub fn handle_get_url( } // https://w3c.github.io/webdriver/#element-click -pub fn handle_element_click( +pub(crate) fn handle_element_click( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -1215,7 +1215,7 @@ pub fn handle_element_click( .unwrap(); } -pub fn handle_is_enabled( +pub(crate) fn handle_is_enabled( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, @@ -1233,7 +1233,7 @@ pub fn handle_is_enabled( .unwrap(); } -pub fn handle_is_selected( +pub(crate) fn handle_is_selected( documents: &DocumentCollection, pipeline: PipelineId, element_id: String, diff --git a/components/script/window_named_properties.rs b/components/script/window_named_properties.rs index 88d3021ec6d..fa63f903300 100644 --- a/components/script/window_named_properties.rs +++ b/components/script/window_named_properties.rs @@ -234,7 +234,7 @@ static CLASS: JSClass = JSClass { }; #[allow(unsafe_code)] -pub fn create( +pub(crate) fn create( cx: SafeJSContext, proto: RustHandleObject, mut properties_obj: RustMutableHandleObject, diff --git a/components/script/xpath/context.rs b/components/script/xpath/context.rs index 09bd36ded60..df78a9a7bec 100644 --- a/components/script/xpath/context.rs +++ b/components/script/xpath/context.rs @@ -9,26 +9,26 @@ use super::Node; use crate::dom::bindings::root::DomRoot; /// The context during evaluation of an XPath expression. -pub struct EvaluationCtx { +pub(crate) struct EvaluationCtx { /// Where we started at - pub starting_node: DomRoot<Node>, + pub(crate) starting_node: DomRoot<Node>, /// The "current" node in the evaluation - pub context_node: DomRoot<Node>, + pub(crate) context_node: DomRoot<Node>, /// Details needed for evaluating a predicate list - pub predicate_ctx: Option<PredicateCtx>, + pub(crate) predicate_ctx: Option<PredicateCtx>, /// The nodes we're currently matching against - pub predicate_nodes: Option<Vec<DomRoot<Node>>>, + pub(crate) predicate_nodes: Option<Vec<DomRoot<Node>>>, } #[derive(Clone, Copy)] -pub struct PredicateCtx { - pub index: usize, - pub size: usize, +pub(crate) struct PredicateCtx { + pub(crate) index: usize, + pub(crate) size: usize, } impl EvaluationCtx { /// Prepares the context used while evaluating the XPath expression - pub fn new(context_node: &Node) -> EvaluationCtx { + pub(crate) fn new(context_node: &Node) -> EvaluationCtx { EvaluationCtx { starting_node: DomRoot::from_ref(context_node), context_node: DomRoot::from_ref(context_node), @@ -38,7 +38,7 @@ impl EvaluationCtx { } /// Creates a new context using the provided node as the context node - pub fn subcontext_for_node(&self, node: &Node) -> EvaluationCtx { + pub(crate) fn subcontext_for_node(&self, node: &Node) -> EvaluationCtx { EvaluationCtx { starting_node: self.starting_node.clone(), context_node: DomRoot::from_ref(node), @@ -47,7 +47,7 @@ impl EvaluationCtx { } } - pub fn update_predicate_nodes(&self, nodes: Vec<&Node>) -> EvaluationCtx { + pub(crate) fn update_predicate_nodes(&self, nodes: Vec<&Node>) -> EvaluationCtx { EvaluationCtx { starting_node: self.starting_node.clone(), context_node: self.context_node.clone(), @@ -56,7 +56,7 @@ impl EvaluationCtx { } } - pub fn subcontext_iter_for_nodes(&self) -> EvalNodesetIter { + pub(crate) fn subcontext_iter_for_nodes(&self) -> EvalNodesetIter { let size = self.predicate_nodes.as_ref().map_or(0, |v| v.len()); EvalNodesetIter { ctx: self, @@ -72,7 +72,7 @@ impl EvaluationCtx { /// When evaluating predicates, we need to keep track of the current node being evaluated and /// the index of that node in the nodeset we're operating on. -pub struct EvalNodesetIter<'a> { +pub(crate) struct EvalNodesetIter<'a> { ctx: &'a EvaluationCtx, nodes_iter: Enumerate<IntoIter<DomRoot<Node>>>, size: usize, diff --git a/components/script/xpath/eval.rs b/components/script/xpath/eval.rs index d880e2f3930..e24bdbddcdb 100644 --- a/components/script/xpath/eval.rs +++ b/components/script/xpath/eval.rs @@ -21,7 +21,7 @@ use crate::dom::node::{Node, ShadowIncluding}; use crate::dom::processinginstruction::ProcessingInstruction; #[derive(Clone, Debug, PartialEq)] -pub enum Error { +pub(crate) enum Error { NotANodeset, InvalidPath, UnknownFunction { name: QualName }, @@ -57,14 +57,14 @@ impl std::fmt::Display for Error { impl std::error::Error for Error {} -pub fn try_extract_nodeset(v: Value) -> Result<Vec<DomRoot<Node>>, Error> { +pub(crate) fn try_extract_nodeset(v: Value) -> Result<Vec<DomRoot<Node>>, Error> { match v { Value::Nodeset(ns) => Ok(ns), _ => Err(Error::NotANodeset), } } -pub trait Evaluatable: fmt::Debug { +pub(crate) trait Evaluatable: fmt::Debug { fn evaluate(&self, context: &EvaluationCtx) -> Result<Value, Error>; /// Returns true if this expression evaluates to a primitive value, without needing to touch the DOM fn is_primitive(&self) -> bool; @@ -245,14 +245,14 @@ impl TryFrom<&ParserQualName> for QualName { } } -pub enum NameTestComparisonMode { +pub(crate) enum NameTestComparisonMode { /// Namespaces must match exactly XHtml, /// Missing namespace information is treated as the HTML namespace Html, } -pub fn element_name_test( +pub(crate) fn element_name_test( expected_name: QualName, element_qualname: QualName, comparison_mode: NameTestComparisonMode, diff --git a/components/script/xpath/eval_function.rs b/components/script/xpath/eval_function.rs index dbf77c503ea..dce7f4d9ba8 100644 --- a/components/script/xpath/eval_function.rs +++ b/components/script/xpath/eval_function.rs @@ -75,7 +75,7 @@ fn substring(s: &str, start_idx: isize, len: Option<isize>) -> String { } /// <https://www.w3.org/TR/1999/REC-xpath-19991116/#function-normalize-space> -pub fn normalize_space(s: &str) -> String { +pub(crate) fn normalize_space(s: &str) -> String { let mut result = String::with_capacity(s.len()); let mut last_was_whitespace = true; // Handles leading whitespace diff --git a/components/script/xpath/eval_value.rs b/components/script/xpath/eval_value.rs index ef0bfe2c4fe..de6c13e3454 100644 --- a/components/script/xpath/eval_value.rs +++ b/components/script/xpath/eval_value.rs @@ -12,7 +12,7 @@ use crate::dom::bindings::utils::AsVoidPtr; use crate::dom::node::Node; /// The primary types of values that an XPath expression returns as a result. -pub enum Value { +pub(crate) enum Value { Boolean(bool), /// A IEEE-754 double-precision floating point number Number(f64), @@ -32,7 +32,7 @@ impl fmt::Debug for Value { } } -pub fn str_to_num(s: &str) -> f64 { +pub(crate) fn str_to_num(s: &str) -> f64 { s.trim().parse().unwrap_or(f64::NAN) } @@ -78,7 +78,7 @@ impl PartialEq<Value> for Value { } impl Value { - pub fn boolean(&self) -> bool { + pub(crate) fn boolean(&self) -> bool { match *self { Value::Boolean(val) => val, Value::Number(n) => n != 0.0 && !n.is_nan(), @@ -87,11 +87,11 @@ impl Value { } } - pub fn into_boolean(self) -> bool { + pub(crate) fn into_boolean(self) -> bool { self.boolean() } - pub fn number(&self) -> f64 { + pub(crate) fn number(&self) -> f64 { match *self { Value::Boolean(val) => { if val { @@ -106,11 +106,11 @@ impl Value { } } - pub fn into_number(self) -> f64 { + pub(crate) fn into_number(self) -> f64 { self.number() } - pub fn string(&self) -> string::String { + pub(crate) fn string(&self) -> string::String { match *self { Value::Boolean(v) => v.to_string(), Value::Number(n) => { @@ -135,7 +135,7 @@ impl Value { } } - pub fn into_string(self) -> string::String { + pub(crate) fn into_string(self) -> string::String { match self { Value::String(val) => val, other => other.string(), @@ -191,7 +191,7 @@ partial_eq_impl!(String, Value::String(ref v) => v); partial_eq_impl!(&str, Value::String(ref v) => v); partial_eq_impl!(Vec<DomRoot<Node>>, Value::Nodeset(ref v) => v); -pub trait NodesetHelpers { +pub(crate) trait NodesetHelpers { /// Returns the node that occurs first in [document order] /// /// [document order]: https://www.w3.org/TR/xpath/#dt-document-order diff --git a/components/script/xpath/mod.rs b/components/script/xpath/mod.rs index b1bfa3b3089..337c5d3eab4 100644 --- a/components/script/xpath/mod.rs +++ b/components/script/xpath/mod.rs @@ -4,21 +4,24 @@ use context::EvaluationCtx; use eval::Evaluatable; -pub use eval_value::{NodesetHelpers, Value}; +pub(crate) use eval_value::{NodesetHelpers, Value}; use parser::OwnedParserError; -pub use parser::{parse as parse_impl, Expr}; +pub(crate) use parser::{parse as parse_impl, Expr}; use super::dom::node::Node; mod context; +#[allow(dead_code)] mod eval; mod eval_function; +#[allow(dead_code)] mod eval_value; +#[allow(dead_code)] mod parser; /// The failure modes of executing an XPath. #[derive(Debug, PartialEq)] -pub enum Error { +pub(crate) enum Error { /// The XPath was syntactically invalid Parsing { source: OwnedParserError }, /// The XPath could not be executed @@ -44,7 +47,7 @@ impl std::error::Error for Error { } /// Parse an XPath expression from a string -pub fn parse(xpath: &str) -> Result<Expr, Error> { +pub(crate) fn parse(xpath: &str) -> Result<Expr, Error> { match parse_impl(xpath) { Ok(expr) => { debug!("Parsed XPath: {:?}", expr); @@ -58,7 +61,7 @@ pub fn parse(xpath: &str) -> Result<Expr, Error> { } /// Evaluate an already-parsed XPath expression -pub fn evaluate_parsed_xpath(expr: &Expr, context_node: &Node) -> Result<Value, Error> { +pub(crate) fn evaluate_parsed_xpath(expr: &Expr, context_node: &Node) -> Result<Value, Error> { let context = EvaluationCtx::new(context_node); match expr.evaluate(&context) { Ok(v) => { diff --git a/components/script/xpath/parser.rs b/components/script/xpath/parser.rs index 3d439b8a4ca..cec3148bc70 100644 --- a/components/script/xpath/parser.rs +++ b/components/script/xpath/parser.rs @@ -11,13 +11,13 @@ use nom::multi::{many0, separated_list0}; use nom::sequence::{delimited, pair, preceded, tuple}; use nom::{Finish, IResult}; -pub fn parse(input: &str) -> Result<Expr, OwnedParserError> { +pub(crate) fn parse(input: &str) -> Result<Expr, OwnedParserError> { let (_, ast) = expr(input).finish().map_err(OwnedParserError::from)?; Ok(ast) } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum Expr { +pub(crate) enum Expr { Or(Box<Expr>, Box<Expr>), And(Box<Expr>, Box<Expr>), Equality(Box<Expr>, EqualityOp, Box<Expr>), @@ -30,13 +30,13 @@ pub enum Expr { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum EqualityOp { +pub(crate) enum EqualityOp { Eq, NotEq, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum RelationalOp { +pub(crate) enum RelationalOp { Lt, Gt, LtEq, @@ -44,61 +44,61 @@ pub enum RelationalOp { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum AdditiveOp { +pub(crate) enum AdditiveOp { Add, Sub, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum MultiplicativeOp { +pub(crate) enum MultiplicativeOp { Mul, Div, Mod, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum UnaryOp { +pub(crate) enum UnaryOp { Minus, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct PathExpr { - pub is_absolute: bool, - pub is_descendant: bool, - pub steps: Vec<StepExpr>, +pub(crate) struct PathExpr { + pub(crate) is_absolute: bool, + pub(crate) is_descendant: bool, + pub(crate) steps: Vec<StepExpr>, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct PredicateListExpr { - pub predicates: Vec<PredicateExpr>, +pub(crate) struct PredicateListExpr { + pub(crate) predicates: Vec<PredicateExpr>, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct PredicateExpr { - pub expr: Expr, +pub(crate) struct PredicateExpr { + pub(crate) expr: Expr, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct FilterExpr { - pub primary: PrimaryExpr, - pub predicates: PredicateListExpr, +pub(crate) struct FilterExpr { + pub(crate) primary: PrimaryExpr, + pub(crate) predicates: PredicateListExpr, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum StepExpr { +pub(crate) enum StepExpr { Filter(FilterExpr), Axis(AxisStep), } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct AxisStep { - pub axis: Axis, - pub node_test: NodeTest, - pub predicates: PredicateListExpr, +pub(crate) struct AxisStep { + pub(crate) axis: Axis, + pub(crate) node_test: NodeTest, + pub(crate) predicates: PredicateListExpr, } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum Axis { +pub(crate) enum Axis { Child, Descendant, Attribute, @@ -115,16 +115,16 @@ pub enum Axis { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum NodeTest { +pub(crate) enum NodeTest { Name(QName), Wildcard, Kind(KindTest), } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub struct QName { - pub prefix: Option<String>, - pub local_part: String, +pub(crate) struct QName { + pub(crate) prefix: Option<String>, + pub(crate) local_part: String, } impl std::fmt::Display for QName { @@ -137,7 +137,7 @@ impl std::fmt::Display for QName { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum KindTest { +pub(crate) enum KindTest { PI(Option<String>), Comment, Text, @@ -145,7 +145,7 @@ pub enum KindTest { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum PrimaryExpr { +pub(crate) enum PrimaryExpr { Literal(Literal), Variable(QName), Parenthesized(Box<Expr>), @@ -155,20 +155,20 @@ pub enum PrimaryExpr { } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum Literal { +pub(crate) enum Literal { Numeric(NumericLiteral), String(String), } #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum NumericLiteral { +pub(crate) enum NumericLiteral { Integer(u64), Decimal(f64), } /// In the DOM we do not support custom functions, so we can enumerate the usable ones #[derive(Clone, Debug, MallocSizeOf, PartialEq)] -pub enum CoreFunction { +pub(crate) enum CoreFunction { // Node Set Functions /// last() Last, @@ -233,7 +233,7 @@ pub enum CoreFunction { } impl CoreFunction { - pub fn name(&self) -> &'static str { + pub(crate) fn name(&self) -> &'static str { match self { CoreFunction::Last => "last", CoreFunction::Position => "position", @@ -265,7 +265,7 @@ impl CoreFunction { } } - pub fn min_args(&self) -> usize { + pub(crate) fn min_args(&self) -> usize { match self { // No args CoreFunction::Last | @@ -306,7 +306,7 @@ impl CoreFunction { } } - pub fn max_args(&self) -> Option<usize> { + pub(crate) fn max_args(&self) -> Option<usize> { match self { // No args CoreFunction::Last | @@ -348,7 +348,7 @@ impl CoreFunction { } /// Returns true if the number of arguments is valid for this function - pub fn is_valid_arity(&self, num_args: usize) -> bool { + pub(crate) fn is_valid_arity(&self, num_args: usize) -> bool { let min = self.min_args(); let max = self.max_args(); @@ -357,7 +357,7 @@ impl CoreFunction { } #[derive(Clone, Debug, PartialEq)] -pub struct OwnedParserError { +pub(crate) struct OwnedParserError { input: String, kind: NomErrorKind, } |