Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current pixel density #21628

Merged
merged 1 commit into from Sep 13, 2018
Merged

Conversation

@paavininanda
Copy link
Contributor

paavininanda commented Sep 6, 2018


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix a subset of #11416.
  • There are tests for these changes OR

This change is Reviewable

@highfive
Copy link

highfive commented Sep 6, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/document.rs, components/script/dom/node.rs, components/script/dom/htmlimageelement.rs, components/script/dom/window.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/node.rs, components/script/dom/htmlimageelement.rs, components/script/dom/window.rs
  • @emilio: components/layout/fragment.rs, components/layout/construct.rs
@highfive
Copy link

highfive commented Sep 6, 2018

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@paavininanda
Copy link
Contributor Author

paavininanda commented Sep 6, 2018

r? @jdm

@highfive highfive assigned jdm and unassigned avadacatavra Sep 6, 2018
Copy link
Member

jdm left a comment

Looking good!

let mut current_pixel_density = 1 as f64;
if density.is_some() {
current_pixel_density = density.unwrap();
}

This comment has been minimized.

@jdm

jdm Sep 6, 2018

Member

let current_pixel_density = density.unwrap_or(1.0);

components/layout/fragment.rs Outdated Show resolved Hide resolved
Some(ImageOrMetadataAvailable::ImageAvailable(i, _)) => {
(
Some(Arc::new(Image {
height: (i.height as f64 / current_pixel_density) as u32,

This comment has been minimized.

@jdm

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.

@jdm

jdm Sep 6, 2018

Member

We should probably perform the density calculation here as well.

@@ -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.

@jdm

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.

@jdm

jdm Sep 6, 2018

Member

nit: Some(data) => data,

components/script/dom/htmlimageelement.rs Outdated Show resolved Hide resolved
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.

@jdm

jdm Sep 6, 2018

Member

Same as previous comment.

@@ -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.

@jdm

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.

@jdm

jdm Sep 6, 2018

Member

This will break because the node is not an image element. We should pass None here.

@paavininanda paavininanda force-pushed the paavininanda:Current-pixel-density branch from 080cb99 to ada19d8 Sep 6, 2018
@jdm
jdm approved these changes Sep 6, 2018
@jdm
Copy link
Member

jdm commented Sep 6, 2018

This can merge after #21280 merges.

@bors-servo
Copy link
Contributor

bors-servo commented Sep 12, 2018

The latest upstream changes (presumably #21280) made this pull request unmergeable. Please resolve the merge conflicts.

@paavininanda paavininanda force-pushed the paavininanda:Current-pixel-density branch from ada19d8 to be50a80 Sep 12, 2018
@paavininanda paavininanda force-pushed the paavininanda:Current-pixel-density branch from be50a80 to 25027e4 Sep 12, 2018
@jdm
Copy link
Member

jdm commented Sep 12, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 12, 2018

📌 Commit 25027e4 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Sep 12, 2018

Testing commit 25027e4 with merge 44394a5...

bors-servo added a commit that referenced this pull request Sep 12, 2018
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
Copy link
Contributor

bors-servo commented Sep 12, 2018

💔 Test failed - linux-rel-css

@jdm
Copy link
Member

jdm commented Sep 12, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 12, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 12, 2018

💔 Test failed - linux-rel-css

@jdm
Copy link
Member

jdm commented Sep 13, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 13, 2018

Testing commit 25027e4 with merge b0de9c5...

bors-servo added a commit that referenced this pull request Sep 13, 2018
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
Copy link
Contributor

bors-servo commented Sep 13, 2018

@bors-servo bors-servo merged commit 25027e4 into servo:master Sep 13, 2018
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.