/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
usecrate::values::computed::percentage::Percentage; usecrate::values::computed::position::Position; usecrate::values::computed::url::ComputedUrl; usecrate::values::computed::{Angle, Color, Context}; usecrate::values::computed::{
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
Resolution, ToComputedValue,
}; usecrate::values::generics::image::{selfas generic, GradientCompatMode}; usecrate::values::specified::image as specified; usecrate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword}; use std::f32::consts::PI; use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss};
pubuse specified::ImageRendering;
/// Computed values for an image according to CSS-IMAGES. /// <https://drafts.csswg.org/css-images/#image-values> pubtype Image = generic::GenericImage<Gradient, ComputedUrl, Color, Percentage, Resolution>;
for (i, item) in items.iter().enumerate() { if item.has_mime_type && !context.device().is_supported_mime_type(&item.mime_type) { // If the MIME type is not supported, we discard the ImageSetItem. continue;
}
let candidate_resolution = item.resolution.dppx();
debug_assert!(
candidate_resolution >= 0.0, "Resolutions should be non-negative"
); if candidate_resolution == 0.0 { // If the resolution is 0, we also treat it as an invalid image. continue;
}
// https://drafts.csswg.org/css-images-4/#image-set-notation: // // Make a UA-specific choice of which to load, based on whatever criteria deemed // relevant (such as the resolution of the display, connection speed, etc). // // For now, select the lowest resolution greater than display density, otherwise the // greatest resolution available. let better_candidate = || { if selected_resolution < dpr && candidate_resolution > selected_resolution { returntrue;
} if candidate_resolution < selected_resolution && candidate_resolution >= dpr { returntrue;
} false
};
// The first item with a supported MIME type is obviously the current best candidate if !supported_image || better_candidate() {
supported_image = true;
selected_index = i;
selected_resolution = candidate_resolution;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.