Further changes required by Servo

This commit is contained in:
Oriol Brufau 2023-05-17 01:17:20 +02:00
parent 773ddf31fe
commit 29bca57333
4 changed files with 22 additions and 0 deletions

1
Cargo.lock generated
View file

@ -6237,6 +6237,7 @@ dependencies = [
"log",
"malloc_size_of",
"malloc_size_of_derive",
"mime",
"new_debug_unreachable",
"num-derive",
"num-integer",

View file

@ -461,6 +461,8 @@ impl GroupedClassifier {
fn image_classifer() -> GroupedClassifier {
GroupedClassifier {
byte_matchers: vec![
// Keep this in sync with 'is_supported_mime_type' from
// components/style/servo/media_queries.rs
Box::new(ByteMatcher::image_x_icon()),
Box::new(ByteMatcher::image_x_icon_cursor()),
Box::new(ByteMatcher::image_bmp()),

View file

@ -50,6 +50,7 @@ lazy_static = "1"
log = { version = "0.4", features = ["std"] }
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = "0.1"
mime = "0.3.13"
new_debug_unreachable = "1.0"
num-derive = "0.3"
num-integer = "0.1"

View file

@ -19,6 +19,7 @@ use app_units::Au;
use cssparser::RGBA;
use euclid::default::Size2D as UntypedSize2D;
use euclid::{Scale, SideOffsets2D, Size2D};
use mime::Mime;
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use style_traits::viewport::ViewportConstraints;
use style_traits::{CSSPixel, DevicePixel};
@ -202,6 +203,23 @@ impl Device {
pub fn safe_area_insets(&self) -> SideOffsets2D<f32, CSSPixel> {
SideOffsets2D::zero()
}
/// Returns true if the given MIME type is supported
pub fn is_supported_mime_type(&self, mime_type: &str) -> bool {
match mime_type.parse::<Mime>() {
Ok(m) => {
// Keep this in sync with 'image_classifer' from
// components/net/mime_classifier.rs
m == mime::IMAGE_BMP
|| m == mime::IMAGE_GIF
|| m == mime::IMAGE_PNG
|| m == mime::IMAGE_JPEG
|| m == "image/x-icon"
|| m == "image/webp"
}
_ => false,
}
}
}
/// https://drafts.csswg.org/mediaqueries-4/#width