-
Notifications
You must be signed in to change notification settings - Fork 213
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
Titlebar Customization: Event for knowing any time the size changes #184
Comments
Has there been consideration of alternatives wherein the usable titlebar area is not considered part of the viewport, but is instead realized as a frame in its own right — something like how the picture-in-picture media API is being realized? I ask because it seems like if that were the case, existing APIs like ResizeObserver, media queries — or typically, just |
I'm slightly confused. It currently isn't a part of the viewport and is kept z-indexed on top of it. Hence why content can flow underneath it in the viewport. If it were attached to the viewport so it was technically in the content area, that introduces some slight logistical issues that now the viewport isn't a rectangle shape. (I may be mis-understanding the definition/scope of viewport here with what I as a developer generally see as the viewport compared to what a browser engine counts as a part of it.) However, we currently have this (non-standardized) with the new iPhones and Androids with notches. That type of situation is discussed over in #177 already. If we can standardize some method of handling these non-rectangular viewport shapes and how devs can style around them, then that would be a bigger achievement that tackles more use-cases but supplements the work being done with this type of window control system. |
@Garbee I'm seeing events fired on Chrome Canary when changing the scale on both Mac and Windows, so I'm not sure what's happening there. Maybe it's a bug? I would also expect a We've also internally discussed the security implications of using a unique event, and decide that firing This spoof is still possible with the
Also, we would still love a CSS solution, but new CSS variables would need to be standardized, so it may be a slow process getting that approved (if it gets approved at all). In the meantime, JS can get the job done, albeit not as smoothly or conveniently. @bathos We have considered other options, but went with the current solution for a few reasons:
Unfortunately, without the CSS variables, it does place a bit more burden on the developer, but hopefully we can work out a solution for that. |
Hmm, interesting. Just tested again. It seems the resize event (on Mojave, not Catalina this time) is firing only when going between the two "bigger text" options. If I go to either "More space" option it doesn't fire, and default it will when coming down from bigger text, but not up from more space. The abuse case presented however is very compelling. Having a very explicit way of getting that first hit on the titlebar is troublesome. However, there is one thing that quickly comes to mind that could get by it.
This has the primary assumption of no extensions. I don't have any details on how common extensions are for the platform so even if 1 showing in the space is normal then this point could be moot. (However an attacker could just plan for up to 2-3 extension icon sizes and it could work too.) This vector is still attackable pretty easily and in such a way most end users would probably never notice. Especially if they're the type of user to click to open something, then look away/focus on another app and return once it is fully loaded. Unless a user is giving their absolute focus to an app in this context, an attacker can bypass the protections easily enough even if janky. That being said, I do not have enough data to support anything except conjecture. I don't feel like this kind of event is necessary, it would just be a better developer experience/ergonomics given the situation. So if it is something that is entirely out of the question due to the proposed attack vector, feel free to close this on out since it isn't something that can be acted on in the proposal. |
I think this is just a terminology disconnect — what you describe is what I mean by ”part of the viewport.” I might be using the wrong word. What I meant to contrast the current proposed approach with wasn’t a model that was polygon-aware, but rather one where the area within the titlebar that’s actually available to devs was realized as its own window/frame, as in the Picture in Picture API. The window would begin below this, as it normally would, and nothing would end up overlaid. I’m confused by:
— since that’s exactly the reason I asked; the current proposal appears to introduce that issue, or at least ... intensify it? The significance of whether effectively eliminated portions of the viewport happen to be implemented (unobservably) in terms of z-index overlays at the browser chrome level or something else isn’t clear to me; that is a polygon, it’s just one that platform APIs will be lying to us about (whereas two frames would seemingly mean two “honest“ rects). (I’m not sure what I’m asking about / suggesting is a great solution or anything, but I couldn’t find anything about it so far and it would seem to solve a lot of the css problems.) |
The explainer covers using the
resize
event for detecting bounds changes that need to be accounted for within an application. However, there are situations that can trigger the bounds to be changed that aren't surfaced with that event. For example, display scale changes (at least on MacOS.)Test case:
window.addEventListener('resize', (event) => console.log(event))
in the console to see events.Perhaps one solution (which kinda works in tandem with some of the issues in #177 to alleviate the need for introducing CSS additions up front) is for a new event to be introduced.
controlsOverlayResized
event.If we could also get a new
debounce
option added toEventTarget.addEventListener
for this, that could mean the engine can handle not firing this off too often (in case that were to somehow happen.) For example:This would make the engine not fire the event until the given number of milliseconds after last event trigger has happened. Giving developers an efficient way to keep up to date with JS without thrashing with every minor resize of a window.
That being said, I still think a CSS solution (as #177 is discussing) is the best long-term solution. If we can't get much headway on a course there in CSS however, something along these lines in JS could be a more amicable (and robust) solution to get in front of developers sooner.
The text was updated successfully, but these errors were encountered: