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

ScreenDetails defines "currentScreens" getter steps #81

Open
reillyeon opened this issue Jan 8, 2022 · 4 comments
Open

ScreenDetails defines "currentScreens" getter steps #81

reillyeon opened this issue Jan 8, 2022 · 4 comments

Comments

@reillyeon
Copy link
Member

The currentScreens getter steps are currently defined as "return the ScreenDetailed object associated with the Window associated with this." This should be "currentScreen" to match the WebIDL and should be explicit that it returns the "current screen" of the Window object associated with this.

This raises the related question of whether the ScreenDetailed object returned by this attribute should be the same as one of the objects in the sequence returned by the screens attribute and whether these objects should be === comparable. This is something we do for APIs like navigator.serial.getPorts() and navigator.serial.onconnect so that it is easy to compare the objects involved to see whether the state has changed without having to rely on heuristics like comparing the screen geometry or labels. As implemented in Chromium it appears that this is the case for this API.

@quisquous
Copy link
Contributor

This raises the related question of whether the ScreenDetailed object returned by this attribute should be the same as one of the objects in the sequence returned by the screens attribute and whether these objects should be === comparable

We had a discussion about this in #49 about whether currentScreen should be [SameObject] and decided against it partially so that we could have the property of currentScreen being === comparable to objects in screens. Is there a good way to specify that in the spec to have that as a stronger guarantee?

@reillyeon
Copy link
Member Author

You're right, what I'm looking for here is something less strict than [SameObject] but more useful because making currentScreen === comparable to objects in screens seems like the most developer-friendly design. I think the way to accomplish that is by defining the getter steps explicitly and using internal slots to hold the exact object instances which should be returned by each accessor's getter steps.

In addition to documenting this behavior in the algorithms a note or example explaining the intent would be helpful to make this aspect of the design clear to implementers.

@michaelwasserman
Copy link
Member

I attempted to define this a bit better and add a couple notes in #87, but I'm not exactly sure how to use internal slots to define an array and specify which exact {{ScreenDetailed}} object in {{ScreenDetails/screens}} represents the [=/current screen=] of a {{Window}}. I hope this might be sufficient for now, and that we can refine this further at a later date.

@reillyeon
Copy link
Member Author

Your PR is a good starting point. You can probably hand-wave the necessary behavior by adding a note in the algorithm that if a ScreenDetailed instance already exists to represent the screen that should be used. You can formalize this by explicitly declaring when new ScreenDetailed instances get created and added to a [[screens]] internal slot when a screen is connected and removed from the internal slot when they are disconnected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants