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

Subpixel positioning fails since ac5525a #8166

Closed
paulrouget opened this issue Oct 23, 2015 · 5 comments
Closed

Subpixel positioning fails since ac5525a #8166

paulrouget opened this issue Oct 23, 2015 · 5 comments

Comments

@paulrouget
Copy link
Contributor

When an iframe is present in the document, top:0.5px is drawn at 1px.

It's started with ac5525a.

<style>

  div {
    position: absolute;
    left: 0;
    top: 10.5px;
    width: 200px;
    height: 200px;
    background: red;
  }

  iframe {
    border: none;
  }

  .foo { display: none; }

</style>

<script>
  setInterval(() => {
    document.querySelector('iframe').classList.toggle('foo');
  }, 1000);
</script>

<body>
  <div></div>
  <iframe></iframe>
</body>
@paulrouget
Copy link
Contributor Author

/cc @mrobinson

@paulrouget
Copy link
Contributor Author

Using to_nearest_pixel instead of to_nearest_px in components/gfx/paint_task.rs appears to solve the issue. I'll submit a PR.

@paulrouget
Copy link
Contributor Author

I don't know how to get the pixel density in build_layer_properties. Usually, we use page_rect and screen_screen, but here, I don't know how to get this info.

@mrobinson
Copy link
Member

I think one issue here is that the layer boundaries are rounded instead of expanded to pixel boundaries. I have a fix for this which depends on servo/app_units#3 (though I don't have a readily accessible hidpi screen to test it on).

@glennw
Copy link
Member

glennw commented Oct 27, 2015

@mrobinson Depending on what you're testing, you may be able to use --device-pixel-ratio=2 even on a non-hidpi monitor to test with.

mrobinson added a commit to mrobinson/servo that referenced this issue Oct 29, 2015
Before passing these layers to the paint task, expand them to pixel
boundaries. This ensures that subpixel edges of the layer will not be
clipped away and helps prevent rounding issues with layer contents.

Fixes servo#8166.
mrobinson added a commit to mrobinson/servo that referenced this issue Oct 29, 2015
Before passing these layers to the paint task, expand them to pixel
boundaries. This ensures that subpixel edges of the layer will not be
clipped away and helps prevent rounding issues with layer contents.

Fixes servo#8166.
bors-servo pushed a commit that referenced this issue Oct 29, 2015
Expand DisplayList layer bounds to whole pixels

Before passing these layers to the paint task, expand them to pixel
boundaries. This ensures that subpixel edges of the layer will not be
clipped away and helps prevent rounding issues with layer contents.

Fixes #8166.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8244)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants