Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCurrent pixel density #21628
Current pixel density #21628
Conversation
highfive
commented
Sep 6, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 6, 2018
|
r? @jdm |
|
Looking good! |
| let mut current_pixel_density = 1 as f64; | ||
| if density.is_some() { | ||
| current_pixel_density = density.unwrap(); | ||
| } |
This comment has been minimized.
This comment has been minimized.
| Some(ImageOrMetadataAvailable::ImageAvailable(i, _)) => { | ||
| ( | ||
| Some(Arc::new(Image { | ||
| height: (i.height as f64 / current_pixel_density) as u32, |
This comment has been minimized.
This comment has been minimized.
jdm
Sep 6, 2018
Member
Let's store these values in local variables so we don't have to repeat the calculations.
| width: (i.width as f64 / current_pixel_density) as u32, | ||
| }), | ||
| ) | ||
| }, | ||
| Some(ImageOrMetadataAvailable::MetadataAvailable(m)) => (None, Some(m)), |
This comment has been minimized.
This comment has been minimized.
| @@ -706,7 +706,7 @@ impl HTMLImageElement { | |||
| } | |||
|
|
|||
| /// Step 13-17 of html.spec.whatwg.org/multipage/#update-the-image-data | |||
| fn prepare_image_request(&self, url: &ServoUrl, src: &DOMString) { | |||
| fn prepare_image_request(&self, url: &ServoUrl, src: &DOMString, current_pixel_density: Option<f64>) { | |||
This comment has been minimized.
This comment has been minimized.
jdm
Sep 6, 2018
Member
Let's call this selected_pixel_density, and we should accept a non-option value.
| src.0 | ||
| }, | ||
| data | ||
| } |
This comment has been minimized.
This comment has been minimized.
| None => 0, | ||
| } | ||
| } | ||
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-img-naturalheight | ||
| fn NaturalHeight(&self) -> u32 { | ||
| let ref metadata = self.current_request.borrow().metadata; | ||
| let pixel_density = (*self).current_request.borrow().current_pixel_density.clone().unwrap_or(1f64); |
This comment has been minimized.
This comment has been minimized.
| @@ -1471,6 +1473,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> | |||
| ImageUrlOrNone::Url(ref url_value) => { | |||
| let image_info = Box::new(ImageFragmentInfo::new( | |||
| url_value.url().map(|u| u.clone()), | |||
| node.image_density(), | |||
This comment has been minimized.
This comment has been minimized.
jdm
Sep 6, 2018
Member
I expect this to break because the node won't be an image element. We should just pass None here.
| @@ -408,6 +409,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> | |||
| Some(LayoutNodeType::Element(LayoutElementType::HTMLObjectElement)) => { | |||
| let image_info = Box::new(ImageFragmentInfo::new( | |||
| node.object_data(), | |||
| node.image_density(), | |||
This comment has been minimized.
This comment has been minimized.
jdm
Sep 6, 2018
Member
This will break because the node is not an image element. We should pass None here.
080cb99
to
ada19d8
|
This can merge after #21280 merges. |
|
|
ada19d8
to
be50a80
be50a80
to
25027e4
|
@bors-servo r+ |
|
|
Current pixel density <!-- 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 a subset of #11416. <!-- Either: --> - [x] There are tests for these changes OR <!-- 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/21628) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
|
|
|
@bors-servo retry |
Current pixel density <!-- 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 a subset of #11416. <!-- Either: --> - [x] There are tests for these changes OR <!-- 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/21628) <!-- Reviewable:end -->
|
|
paavininanda commentedSep 6, 2018
•
edited by SimonSapin
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is