mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #21181 - nupurbaghel:update_source_set, r=jdm
Implement update source set & select image source <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11416 (github issue number if applicable). - [x] These changes require tests but cannot be written until implementation of responsive images is complete <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21181) <!-- Reviewable:end -->
This commit is contained in:
commit
e57187305f
6 changed files with 289 additions and 99 deletions
|
@ -18,6 +18,7 @@ use values::specified::{Length, NoCalcLength, ViewportPercentageLength};
|
|||
/// A value for a `<source-size>`:
|
||||
///
|
||||
/// https://html.spec.whatwg.org/multipage/#source-size
|
||||
#[derive(Debug)]
|
||||
pub struct SourceSize {
|
||||
condition: MediaCondition,
|
||||
value: Length,
|
||||
|
@ -38,6 +39,7 @@ impl Parse for SourceSize {
|
|||
/// A value for a `<source-size-list>`:
|
||||
///
|
||||
/// https://html.spec.whatwg.org/multipage/#source-size-list
|
||||
#[derive(Debug)]
|
||||
pub struct SourceSizeList {
|
||||
source_sizes: Vec<SourceSize>,
|
||||
value: Option<Length>,
|
||||
|
@ -52,6 +54,11 @@ impl SourceSizeList {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set content of `value`, which can be used as fall-back during evaluate.
|
||||
pub fn set_fallback_value(&mut self, width: Option<Length>) {
|
||||
self.value = width;
|
||||
}
|
||||
|
||||
/// Evaluate this <source-size-list> to get the final viewport length.
|
||||
pub fn evaluate(&self, device: &Device, quirks_mode: QuirksMode) -> Au {
|
||||
let matching_source_size = self.source_sizes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue