mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Remove unused code from script* crates
This commit is contained in:
parent
8dc7a25893
commit
8b6ed3d182
13 changed files with 2 additions and 133 deletions
|
@ -27,8 +27,4 @@ impl<'a> InCompartment<'a> {
|
||||||
pub fn in_compartment(token: &AlreadyInCompartment) -> InCompartment {
|
pub fn in_compartment(token: &AlreadyInCompartment) -> InCompartment {
|
||||||
InCompartment::Already(token)
|
InCompartment::Already(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn entered(token: &JSAutoRealm) -> InCompartment {
|
|
||||||
InCompartment::Entered(token)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,19 +25,6 @@ pub enum LoadType {
|
||||||
Media,
|
Media,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoadType {
|
|
||||||
fn url(&self) -> Option<&ServoUrl> {
|
|
||||||
match *self {
|
|
||||||
LoadType::Image(ref url) |
|
|
||||||
LoadType::Script(ref url) |
|
|
||||||
LoadType::Subframe(ref url) |
|
|
||||||
LoadType::Stylesheet(ref url) |
|
|
||||||
LoadType::PageSource(ref url) => Some(url),
|
|
||||||
LoadType::Media => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Canary value ensuring that manually added blocking loads (ie. ones that weren't
|
/// Canary value ensuring that manually added blocking loads (ie. ones that weren't
|
||||||
/// created via DocumentLoader::fetch_async) are always removed by the time
|
/// created via DocumentLoader::fetch_async) are always removed by the time
|
||||||
/// that the owner is destroyed.
|
/// that the owner is destroyed.
|
||||||
|
@ -67,11 +54,6 @@ impl LoadBlocker {
|
||||||
}
|
}
|
||||||
*blocker = None;
|
*blocker = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the url associated with this load.
|
|
||||||
pub fn url(&self) -> Option<&ServoUrl> {
|
|
||||||
self.load.as_ref().and_then(LoadType::url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for LoadBlocker {
|
impl Drop for LoadBlocker {
|
||||||
|
|
|
@ -252,10 +252,8 @@ impl Attr {
|
||||||
pub trait AttrHelpersForLayout {
|
pub trait AttrHelpersForLayout {
|
||||||
unsafe fn value_forever(&self) -> &'static AttrValue;
|
unsafe fn value_forever(&self) -> &'static AttrValue;
|
||||||
unsafe fn value_ref_forever(&self) -> &'static str;
|
unsafe fn value_ref_forever(&self) -> &'static str;
|
||||||
unsafe fn value_atom_forever(&self) -> Option<Atom>;
|
|
||||||
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
|
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
|
||||||
unsafe fn local_name_atom_forever(&self) -> LocalName;
|
unsafe fn local_name_atom_forever(&self) -> LocalName;
|
||||||
unsafe fn value_for_layout(&self) -> &AttrValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
@ -271,15 +269,6 @@ impl AttrHelpersForLayout for LayoutDom<Attr> {
|
||||||
&**self.value_forever()
|
&**self.value_forever()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
unsafe fn value_atom_forever(&self) -> Option<Atom> {
|
|
||||||
let value = (*self.unsafe_get()).value.borrow_for_layout();
|
|
||||||
match *value {
|
|
||||||
AttrValue::Atom(ref val) => Some(val.clone()),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]> {
|
unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]> {
|
||||||
// This transmute is used to cheat the lifetime restriction.
|
// This transmute is used to cheat the lifetime restriction.
|
||||||
|
@ -293,9 +282,4 @@ impl AttrHelpersForLayout for LayoutDom<Attr> {
|
||||||
unsafe fn local_name_atom_forever(&self) -> LocalName {
|
unsafe fn local_name_atom_forever(&self) -> LocalName {
|
||||||
(*self.unsafe_get()).identifier.local_name.clone()
|
(*self.unsafe_get()).identifier.local_name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
unsafe fn value_for_layout(&self) -> &AttrValue {
|
|
||||||
(*self.unsafe_get()).value.borrow_for_layout()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,9 +168,6 @@ pub mod codegen {
|
||||||
pub mod InterfaceObjectMap {
|
pub mod InterfaceObjectMap {
|
||||||
include!(concat!(env!("OUT_DIR"), "/InterfaceObjectMap.rs"));
|
include!(concat!(env!("OUT_DIR"), "/InterfaceObjectMap.rs"));
|
||||||
}
|
}
|
||||||
pub mod InterfaceTypes {
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/InterfaceTypes.rs"));
|
|
||||||
}
|
|
||||||
#[allow(dead_code, unused_imports)]
|
#[allow(dead_code, unused_imports)]
|
||||||
pub mod InheritTypes {
|
pub mod InheritTypes {
|
||||||
include!(concat!(env!("OUT_DIR"), "/InheritTypes.rs"));
|
include!(concat!(env!("OUT_DIR"), "/InheritTypes.rs"));
|
||||||
|
|
|
@ -671,14 +671,6 @@ impl<T: DomObject> LayoutDom<T> {
|
||||||
debug_assert!(thread_state::get().is_layout());
|
debug_assert!(thread_state::get().is_layout());
|
||||||
self.ptr.as_ptr()
|
self.ptr.as_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the interior of this JS object. This method is
|
|
||||||
/// safe to call because it originates from the layout thread, and it cannot
|
|
||||||
/// mutate DOM nodes.
|
|
||||||
pub fn get_for_script(&self) -> &T {
|
|
||||||
debug_assert!(thread_state::get().is_script());
|
|
||||||
unsafe { &*self.ptr.as_ptr() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper trait for safer manipulations of `Option<Heap<T>>` values.
|
/// Helper trait for safer manipulations of `Option<Heap<T>>` values.
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::marker::PhantomData;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::str::{Bytes, FromStr};
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// Encapsulates the IDL `ByteString` type.
|
/// Encapsulates the IDL `ByteString` type.
|
||||||
#[derive(Clone, Debug, Default, Eq, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Debug, Default, Eq, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
|
@ -40,11 +40,6 @@ impl ByteString {
|
||||||
self.0.len()
|
self.0.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compare `self` to `other`, matching A–Z and a–z as equal.
|
|
||||||
pub fn eq_ignore_case(&self, other: &ByteString) -> bool {
|
|
||||||
self.0.eq_ignore_ascii_case(&other.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `self` with A–Z replaced by a–z.
|
/// Returns `self` with A–Z replaced by a–z.
|
||||||
pub fn to_lower(&self) -> ByteString {
|
pub fn to_lower(&self) -> ByteString {
|
||||||
ByteString::new(self.0.to_ascii_lowercase())
|
ByteString::new(self.0.to_ascii_lowercase())
|
||||||
|
@ -219,11 +214,6 @@ impl DOMString {
|
||||||
self.0.truncate(new_len);
|
self.0.truncate(new_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over the bytes of this `DOMString`.
|
|
||||||
pub fn bytes(&self) -> Bytes {
|
|
||||||
self.0.bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Removes newline characters according to <https://infra.spec.whatwg.org/#strip-newlines>.
|
/// Removes newline characters according to <https://infra.spec.whatwg.org/#strip-newlines>.
|
||||||
pub fn strip_newlines(&mut self) {
|
pub fn strip_newlines(&mut self) {
|
||||||
self.0.retain(|c| c != '\r' && c != '\n');
|
self.0.retain(|c| c != '\r' && c != '\n');
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::str::USVString;
|
use crate::dom::bindings::str::USVString;
|
||||||
use crate::dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
use crate::dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use servo_url::MutableOrigin;
|
|
||||||
|
|
||||||
/// Represents a dissimilar-origin `Location` that exists in another script thread.
|
/// Represents a dissimilar-origin `Location` that exists in another script thread.
|
||||||
///
|
///
|
||||||
|
@ -46,11 +45,6 @@ impl DissimilarOriginLocation {
|
||||||
DissimilarOriginLocationBinding::Wrap,
|
DissimilarOriginLocationBinding::Wrap,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn origin(&self) -> &MutableOrigin {
|
|
||||||
self.window.origin()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DissimilarOriginLocationMethods for DissimilarOriginLocation {
|
impl DissimilarOriginLocationMethods for DissimilarOriginLocation {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding;
|
use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
|
use crate::dom::bindings::codegen::Bindings::DissimilarOriginWindowBinding::DissimilarOriginWindowMethods;
|
||||||
use crate::dom::bindings::error::{Error, ErrorResult};
|
use crate::dom::bindings::error::{Error, ErrorResult};
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::DOMString;
|
||||||
use crate::dom::bindings::structuredclone::StructuredCloneData;
|
use crate::dom::bindings::structuredclone::StructuredCloneData;
|
||||||
|
@ -20,7 +19,6 @@ use js::rust::HandleValue;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use script_traits::ScriptMsg;
|
use script_traits::ScriptMsg;
|
||||||
use servo_url::ImmutableOrigin;
|
use servo_url::ImmutableOrigin;
|
||||||
use servo_url::MutableOrigin;
|
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
|
|
||||||
/// Represents a dissimilar-origin `Window` that exists in another script thread.
|
/// Represents a dissimilar-origin `Window` that exists in another script thread.
|
||||||
|
@ -71,10 +69,6 @@ impl DissimilarOriginWindow {
|
||||||
unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) }
|
unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn origin(&self) -> &MutableOrigin {
|
|
||||||
self.upcast::<GlobalScope>().origin()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn window_proxy(&self) -> DomRoot<WindowProxy> {
|
pub fn window_proxy(&self) -> DomRoot<WindowProxy> {
|
||||||
DomRoot::from_ref(&*self.window_proxy)
|
DomRoot::from_ref(&*self.window_proxy)
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,10 +473,6 @@ impl Document {
|
||||||
self.https_state.set(https_state);
|
self.https_state.set(https_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_completely_loaded(&self) -> bool {
|
|
||||||
self.completely_loaded.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_fully_active(&self) -> bool {
|
pub fn is_fully_active(&self) -> bool {
|
||||||
self.activity.get() == DocumentActivity::FullyActive
|
self.activity.get() == DocumentActivity::FullyActive
|
||||||
}
|
}
|
||||||
|
|
|
@ -600,8 +600,6 @@ pub trait LayoutElementHelpers {
|
||||||
fn local_name(&self) -> &LocalName;
|
fn local_name(&self) -> &LocalName;
|
||||||
fn namespace(&self) -> &Namespace;
|
fn namespace(&self) -> &Namespace;
|
||||||
fn get_lang_for_layout(&self) -> String;
|
fn get_lang_for_layout(&self) -> String;
|
||||||
fn get_checked_state_for_layout(&self) -> bool;
|
|
||||||
fn get_indeterminate_state_for_layout(&self) -> bool;
|
|
||||||
fn get_state_for_layout(&self) -> ElementState;
|
fn get_state_for_layout(&self) -> ElementState;
|
||||||
fn insert_selector_flags(&self, flags: ElementSelectorFlags);
|
fn insert_selector_flags(&self, flags: ElementSelectorFlags);
|
||||||
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool;
|
||||||
|
@ -1029,26 +1027,6 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn get_checked_state_for_layout(&self) -> bool {
|
|
||||||
// TODO option and menuitem can also have a checked state.
|
|
||||||
match self.downcast::<HTMLInputElement>() {
|
|
||||||
Some(input) => unsafe { input.checked_state_for_layout() },
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[allow(unsafe_code)]
|
|
||||||
fn get_indeterminate_state_for_layout(&self) -> bool {
|
|
||||||
// TODO progress elements can also be matched with :indeterminate
|
|
||||||
match self.downcast::<HTMLInputElement>() {
|
|
||||||
Some(input) => unsafe { input.indeterminate_state_for_layout() },
|
|
||||||
None => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn get_state_for_layout(&self) -> ElementState {
|
fn get_state_for_layout(&self) -> ElementState {
|
||||||
|
@ -3289,10 +3267,6 @@ impl Element {
|
||||||
self.state.set(state);
|
self.state.set(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn active_state(&self) -> bool {
|
|
||||||
self.state.get().contains(ElementState::IN_ACTIVE_STATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#concept-selector-active>
|
/// <https://html.spec.whatwg.org/multipage/#concept-selector-active>
|
||||||
pub fn set_active_state(&self, value: bool) {
|
pub fn set_active_state(&self, value: bool) {
|
||||||
self.set_state(ElementState::IN_ACTIVE_STATE, value);
|
self.set_state(ElementState::IN_ACTIVE_STATE, value);
|
||||||
|
@ -3356,18 +3330,10 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn target_state(&self) -> bool {
|
|
||||||
self.state.get().contains(ElementState::IN_TARGET_STATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_target_state(&self, value: bool) {
|
pub fn set_target_state(&self, value: bool) {
|
||||||
self.set_state(ElementState::IN_TARGET_STATE, value)
|
self.set_state(ElementState::IN_TARGET_STATE, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fullscreen_state(&self) -> bool {
|
|
||||||
self.state.get().contains(ElementState::IN_FULLSCREEN_STATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_fullscreen_state(&self, value: bool) {
|
pub fn set_fullscreen_state(&self, value: bool) {
|
||||||
self.set_state(ElementState::IN_FULLSCREEN_STATE, value)
|
self.set_state(ElementState::IN_FULLSCREEN_STATE, value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,20 +451,12 @@ impl Documents {
|
||||||
.map(|ref doc| DomRoot::from_ref(&**doc))
|
.map(|ref doc| DomRoot::from_ref(&**doc))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.map.is_empty()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn find_document(&self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> {
|
pub fn find_document(&self, pipeline_id: PipelineId) -> Option<DomRoot<Document>> {
|
||||||
self.map
|
self.map
|
||||||
.get(&pipeline_id)
|
.get(&pipeline_id)
|
||||||
.map(|doc| DomRoot::from_ref(&**doc))
|
.map(|doc| DomRoot::from_ref(&**doc))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
|
||||||
self.map.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn find_window(&self, pipeline_id: PipelineId) -> Option<DomRoot<Window>> {
|
pub fn find_window(&self, pipeline_id: PipelineId) -> Option<DomRoot<Window>> {
|
||||||
self.find_document(pipeline_id)
|
self.find_document(pipeline_id)
|
||||||
.map(|doc| DomRoot::from_ref(doc.window()))
|
.map(|doc| DomRoot::from_ref(doc.window()))
|
||||||
|
@ -824,13 +816,6 @@ impl ScriptThread {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn invoke_perform_a_microtask_checkpoint() {
|
|
||||||
SCRIPT_THREAD_ROOT.with(|root| {
|
|
||||||
let script_thread = unsafe { &*root.get().unwrap() };
|
|
||||||
script_thread.perform_a_microtask_checkpoint()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page_headers_available(
|
pub fn page_headers_available(
|
||||||
id: &PipelineId,
|
id: &PipelineId,
|
||||||
metadata: Option<Metadata>,
|
metadata: Option<Metadata>,
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::{Point2D, Rect};
|
use euclid::Rect;
|
||||||
use script_traits::UntrustedNodeAddress;
|
use script_traits::UntrustedNodeAddress;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use style::properties::longhands::overflow_x;
|
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use webrender_api::ExternalScrollId;
|
use webrender_api::ExternalScrollId;
|
||||||
|
|
||||||
|
@ -50,8 +49,6 @@ pub struct NodeGeometryResponse {
|
||||||
pub client_rect: Rect<i32>,
|
pub client_rect: Rect<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NodeOverflowResponse(pub Option<Point2D<overflow_x::computed_value::T>>);
|
|
||||||
|
|
||||||
pub struct NodeScrollIdResponse(pub ExternalScrollId);
|
pub struct NodeScrollIdResponse(pub ExternalScrollId);
|
||||||
|
|
||||||
pub struct ResolvedStyleResponse(pub String);
|
pub struct ResolvedStyleResponse(pub String);
|
||||||
|
|
|
@ -550,10 +550,6 @@ pub type NsDuration = Length<u64, Nanoseconds>;
|
||||||
pub fn precise_time_ms() -> MsDuration {
|
pub fn precise_time_ms() -> MsDuration {
|
||||||
Length::new(time::precise_time_ns() / (1000 * 1000))
|
Length::new(time::precise_time_ns() / (1000 * 1000))
|
||||||
}
|
}
|
||||||
/// Returns the duration since an unspecified epoch measured in ns.
|
|
||||||
pub fn precise_time_ns() -> NsDuration {
|
|
||||||
Length::new(time::precise_time_ns())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Data needed to construct a script thread.
|
/// Data needed to construct a script thread.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue