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

Enable screen.width/height/availWidth/availHeight #18183

Merged
merged 1 commit into from Nov 14, 2017

Conversation

@shinglyu
Copy link
Member

shinglyu commented Aug 22, 2017

Support screen.width/height/availWidth/availHeight using information from glutin. r?@paulrouget

Since glutin don't have availWidth and availHeight information, I let them fallback to width and height. If that's not acceptable in terms of webcompat, I can remove that part.

There are some test failures on wpt css about mutating screen.width/height should throw exception, but I can't reproduce that behavior on other major browser, so I keep them disabled. Also there are some media query issues, but I believe that's due to some test harness problem on my test machine.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #18062 (github issue number if applicable).
  • There are tests for these changes in wpt cssom-view
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Aug 22, 2017

Heads up! This PR modifies the following files:

  • @asajeffrey: components/constellation/constellation.rs
  • @fitzgen: components/script/dom/webidls/Screen.webidl, components/script/dom/screen.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs
  • @KiChjang: components/script/dom/webidls/Screen.webidl, components/script/dom/screen.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs
fn AvailHeight(&self) -> Finite<f64> {
// FIXME: Not spec complient because glutin don't have corresponding API
// Fallback to window.screen.height behavior
self.Height()

This comment has been minimized.

Copy link
@paulrouget

paulrouget Aug 22, 2017

Contributor

The FIXME should be in /ports/, not in servo. Code in /components/ are backend independent.

Here you should call self.avail_screen_size().height, and implement the associated message (GetAvailScreenSize).

In ports/glutin/window.rs, implement fn avail_screen_size(), and there, add the FIXME and use glutin::get_primary_monitor().get_dimensions();.

Copy link
Contributor

paulrouget left a comment

Move fallback to /ports/.

@jdm
Copy link
Member

jdm commented Aug 22, 2017

The throwing tests no longer exist upstream, so that's fine.

@shinglyu shinglyu force-pushed the shinglyu:availheight branch from 927a008 to e0346fe Aug 24, 2017
@shinglyu
Copy link
Member Author

shinglyu commented Aug 24, 2017

@paulrouget I create a separate path for availWidth/availHeight all the way down to WindowEvent and moved the fallback to ports/glutin. Thanks!

ShutdownState::NotShuttingDown) => {
let screen_size = self.window.screen_size(top_level_browsing_context_id);
if let Err(e) = send.send(screen_size) {
warn!("Sending response to get client window failed ({}).", e);

This comment has been minimized.

Copy link
@paulrouget

paulrouget Aug 24, 2017

Contributor

"to get screen size"

ShutdownState::NotShuttingDown) => {
let screen_size = self.window.screen_avail_size(top_level_browsing_context_id);
if let Err(e) = send.send(screen_size) {
warn!("Sending response to get client window failed ({}).", e);

This comment has been minimized.

Copy link
@paulrouget

paulrouget Aug 24, 2017

Contributor

"to get screen avail size"

let (width, height) = glutin::get_primary_monitor().get_dimensions();
Size2D::new(width, height)
}

This comment has been minimized.

Copy link
@paulrouget

paulrouget Aug 24, 2017

Contributor

In the headless case, you probably want to return context.width/height for both screen_size and screen_avail_size.

Copy link
Contributor

paulrouget left a comment

You also need to fix CEF (try ./mach build-cef).

@shinglyu shinglyu force-pushed the shinglyu:availheight branch 2 times, most recently from 24e76b3 to 3558b9c Aug 24, 2017
@paulrouget
Copy link
Contributor

paulrouget commented Aug 24, 2017

Looks good to me.

Can someone review this?

@shinglyu
Copy link
Member Author

shinglyu commented Aug 24, 2017

Maybe @jdm, who suggested this solution?

Copy link
Member

asajeffrey left a comment

Looks good, some minor nits.

browser.get_host()
.get_client()
.get_render_handler()
.get_screen_info((*browser).clone(), &mut screen_info);

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Aug 24, 2017

Member

Can this just be browser.clone()?

is_monochrome: 0 as i32,
rect: cef_rect_t::zero(),
available_rect: cef_rect_t::zero(),
};

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Aug 24, 2017

Member

Not very nice having to do this. Is there an implementation of Default::default() we could use to make this slightly better?


[window.screen.availHeight >= 0 && window.screen.availHeight <= window.screen.height]
expected: FAIL

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Aug 24, 2017

Member

Yay for passing tests!

/// Get the screen size
GetScreenSize(TopLevelBrowsingContextId, IpcSender<(Size2D<u32>)>),
/// Get the available screen size
GetScreenAvailSize(TopLevelBrowsingContextId, IpcSender<(Size2D<u32>)>),

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Aug 24, 2017

Member

This isn't really an issue with this PR, but it would be nice if we could give these typed units, since I'm not sure what the unit is (device pixels?). A comment with the unit at least would be nice.

This comment has been minimized.

Copy link
@shinglyu

shinglyu Aug 25, 2017

Author Member

Are you suggesting we use Typed* for all compositor message? Will that mean more bytes passing through IPC? or is it just a type system thing and has no runtime impact?

This comment has been minimized.

Copy link
@jdm

jdm Aug 25, 2017

Member

Typed units do not have a runtime impact.

@asajeffrey asajeffrey self-assigned this Aug 24, 2017
@shinglyu shinglyu force-pushed the shinglyu:availheight branch from 3558b9c to e259da4 Aug 25, 2017
@shinglyu shinglyu force-pushed the shinglyu:availheight branch from e259da4 to fc3b396 Aug 25, 2017
@shinglyu
Copy link
Member Author

shinglyu commented Aug 28, 2017

@asajeffrey Changing to Typed units seems like a good first bug for contributors. I'm going to create a followup bug for that and hand it to a new volunteer I'm mentoring here in Taiwan. So I only added a comment about the units.

@shinglyu
Copy link
Member Author

shinglyu commented Nov 12, 2017

Sorry, new job, new team, new house, so didn't have time to check github for a while :'( Just pushed a fix and I'm testing it locally now.

@shinglyu
Copy link
Member Author

shinglyu commented Nov 12, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2017

Trying commit e7cbe84 with merge db31197...

bors-servo added a commit that referenced this pull request Nov 12, 2017
Enable screen.width/height/availWidth/availHeight

<!-- Please describe your changes on the following line: -->
Support screen.width/height/availWidth/availHeight using information from glutin. r?@paulrouget

Since glutin don't have `availWidth` and `availHeight` information, I let them fallback to `width` and `height`. If that's not acceptable in terms of webcompat, I can remove that part.

There are some test failures on wpt css about mutating screen.width/height should throw exception, but I can't reproduce that behavior on other major browser, so I keep them disabled. Also there are some media query issues, but I believe that's due to some test harness problem on my test machine.

---
<!-- 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 #18062  (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes in wpt cssom-view
- [ ] These changes do not require tests because _____

<!-- 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/18183)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 12, 2017

💔 Test failed - linux-rel-wpt

@shinglyu
Copy link
Member Author

shinglyu commented Nov 13, 2017

The merge commit db31197 bors tested didn't contain the removed test expectation files in the original commit e7cbe84, so there are a few unexpected passes. Ideas?

@jdm
Copy link
Member

jdm commented Nov 13, 2017

@shinglyu tests/wpt/metadata-css/ doesn't exist any more, and the merge algorithm apparently decided that that wasn't important.

@mbrubeck
Copy link
Contributor

mbrubeck commented Nov 13, 2017

The merge commit seems to have the relevant test expectation removals:

https://github.com/servo/servo/tree/db311974f63a2dc17c821f2c318c2e5379a275cd/tests/wpt/metadata

(diffs on merge commits aren't very clear)

@shinglyu
Copy link
Member Author

shinglyu commented Nov 13, 2017

Ah OK, let me do another rebase.

@shinglyu shinglyu force-pushed the shinglyu:availheight branch from e7cbe84 to ac56bf5 Nov 13, 2017
@shinglyu shinglyu force-pushed the shinglyu:availheight branch from ac56bf5 to c120234 Nov 13, 2017
@shinglyu
Copy link
Member Author

shinglyu commented Nov 13, 2017

Removed the test expectations that was moved to metadata/, trying again.

@bors-servo: try

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2017

Trying commit c120234 with merge 4a8e0ac...

bors-servo added a commit that referenced this pull request Nov 13, 2017
Enable screen.width/height/availWidth/availHeight

<!-- Please describe your changes on the following line: -->
Support screen.width/height/availWidth/availHeight using information from glutin. r?@paulrouget

Since glutin don't have `availWidth` and `availHeight` information, I let them fallback to `width` and `height`. If that's not acceptable in terms of webcompat, I can remove that part.

There are some test failures on wpt css about mutating screen.width/height should throw exception, but I can't reproduce that behavior on other major browser, so I keep them disabled. Also there are some media query issues, but I believe that's due to some test harness problem on my test machine.

---
<!-- 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 #18062  (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes in wpt cssom-view
- [ ] These changes do not require tests because _____

<!-- 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/18183)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2017

@asajeffrey
Copy link
Member

asajeffrey commented Nov 13, 2017

Yay, it landed!

@jdm
Copy link
Member

jdm commented Nov 13, 2017

@bors-servo: r=asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2017

📌 Commit c120234 has been approved by asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2017

Testing commit c120234 with merge 504ad4d...

bors-servo added a commit that referenced this pull request Nov 13, 2017
Enable screen.width/height/availWidth/availHeight

<!-- Please describe your changes on the following line: -->
Support screen.width/height/availWidth/availHeight using information from glutin. r?@paulrouget

Since glutin don't have `availWidth` and `availHeight` information, I let them fallback to `width` and `height`. If that's not acceptable in terms of webcompat, I can remove that part.

There are some test failures on wpt css about mutating screen.width/height should throw exception, but I can't reproduce that behavior on other major browser, so I keep them disabled. Also there are some media query issues, but I believe that's due to some test harness problem on my test machine.

---
<!-- 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 #18062  (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes in wpt cssom-view
- [ ] These changes do not require tests because _____

<!-- 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/18183)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 14, 2017

@bors-servo bors-servo merged commit c120234 into servo:master Nov 14, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
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.

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