style: Remove dependency on servo_url (#31358)

In order for stylo to be a separate crate, it needs to depend on less
things from Servo. This change makes it so that stylo no longer depends
on servo_url.
This commit is contained in:
Martin Robinson 2024-02-16 12:56:35 +01:00 committed by GitHub
parent 29e1dfe1e4
commit 9a6973d629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 236 additions and 144 deletions

View file

@ -14,10 +14,10 @@ use std::hash::Hasher;
use std::net::IpAddr;
use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
use std::path::Path;
use std::sync::Arc;
use malloc_size_of_derive::MallocSizeOf;
use serde::{Deserialize, Serialize};
use servo_arc::Arc;
use to_shmem::{SharedMemoryBuilder, ToShmem};
pub use url::Host;
use url::{Position, Url};
@ -46,11 +46,15 @@ impl ServoUrl {
}
pub fn into_string(self) -> String {
String::from(Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone()))
String::from(self.into_url())
}
pub fn into_url(self) -> Url {
Arc::try_unwrap(self.0).unwrap_or_else(|s| (*s).clone())
self.as_url().clone()
}
pub fn get_arc(&self) -> Arc<Url> {
self.0.clone()
}
pub fn as_url(&self) -> &Url {
@ -96,14 +100,6 @@ impl ServoUrl {
scheme == "about" || scheme == "blob" || scheme == "data"
}
pub fn chrome_rules_enabled(&self) -> bool {
self.is_chrome()
}
pub fn is_chrome(&self) -> bool {
self.scheme() == "chrome"
}
pub fn as_str(&self) -> &str {
self.0.as_str()
}
@ -298,3 +294,9 @@ impl From<Url> for ServoUrl {
ServoUrl::from_url(url)
}
}
impl From<Arc<Url>> for ServoUrl {
fn from(url: Arc<Url>) -> Self {
ServoUrl(url)
}
}