-
Notifications
You must be signed in to change notification settings - Fork 295
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
Allow an EventTarget to provide the default value of the AddEventListenerOptions #365
Comments
the default passive value of AddEventListenerOptions. Fixes issue whatwg#365
@foolip @RByers @smaug---- @annevk WDYT? And then I'll have to put a hook in the touch event spec that defines a default passive algorithm on window, document and html element. |
In your patch you say an argument is passed, but you don't actually pass a parameter. Assuming that is fixed, would we only change the default for certain event types? |
Yes only touchstart and touchmove are covered under our intervention. Our long term goal is to have these both default to passive: true. However in the meantime we'd like to default them to passive: true if the ContextObject is either window, document, or document.body (as defined in HTML spec). I was planning on putting this wording into the Touch Event Spec; ie to define the default passive algorithm on Window, Document and HTMLElement. |
I think it's a little weird for Touch Events to define that as HTML/DOM define these objects. Guess I'll wait to see what everyone else who was pinged thinks. |
Given the goal of making some Making EventTarget the extension point works for me, but I can see two other ways that'd be indistinguishable but result in different layering:
In both cases Touch Events would use the extension point. If either of those or another mechanism seems preferable to anyone they ought to work, but implementation-wise I think there's little reason to layer things like that. |
I've created a pull request on the touch event spec; see w3c/touch-events#75 |
@smaug----, do you have time to go over the options here? |
This seems reasonable to me.
I can see how this might be simpler.
This would have slightly different semantics from the current definition, eg. in the case that a 2nd HTMLBodyElement is added after the |
(in my todo list, but can't do the context switch just right now.) |
Talking with @foolip "offline" I noticed that since event handler attributes are not explicitly linked to w3c/ServiceWorker#1004 is basically that issue. |
The current situation is that in the blink-dev intent thread, we're trying to get some sense of whether anyone else will be interested in shipping this. My take is that tweaking |
Well, it isn't really. E.g., does it affect event handler attributes or not? |
That's a really good point, thanks! Yes |
I've checked Blink, and it uses a shared code path so that it'll behave as if |
The way we need to make that work is by updating DOM and HTML. DOM needs to have an abstract algorithm that |
Makes sense. Since this PR won't be merged for a few months still I think there's plenty of time to work through that. |
https://bugs.webkit.org/show_bug.cgi?id=175346 <rdar://problem/33164597> Reviewed by Sam Weinig. Source/WebCore: Make any touchstart or touchmove event listeners passive by default if they are on the document, window, body or document element targets. This follows the "intervention" first implemented by Chrome/Blink: WICG/interventions#35 https://docs.google.com/document/d/1II7oSIpd8pK91V5kEM3tDLKcIj398jOJn8Niqy6_loI/edit whatwg/dom#365 If the event listener explicitly defines "passive" to false in their options dictionary, then they'll still get a non-passive listener. NOTE: Any fallout from this bug should be collected in: https://bugs.webkit.org/show_bug.cgi?id=175869 Please do not revert this change just because a site is broken. We'll gather the issues and see if we can evangelise or detect via code. Tests: fast/events/touch/ios/passive-by-default-on-document-and-window.html fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html * dom/EventNames.h: (WebCore::EventNames::isTouchScrollBlockingEventType const): Added this helper to identify the types of touches we want to check for. * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): Check for the event being one of the touch-types that we care about, and the target being one of the Node/Window types we care about. If so, tell the event listener to be passive. * dom/EventTarget.h: Use an optional for the passive member. (WebCore::EventTarget::AddEventListenerOptions::AddEventListenerOptions): * dom/EventTarget.idl: Change "passive" to not have a default value, so we can detect if it was explicitly set to false. LayoutTests: * fast/events/touch/ios/passive-by-default-on-document-and-window-expected.txt: Added. * fast/events/touch/ios/passive-by-default-on-document-and-window.html: Added. * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt: Added. * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html: Added. * fast/events/touch/ios/tap-with-active-listener-on-window.html: Explicitly set passive to false. * fast/events/touch/ios/touch-event-regions/document.html: Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@221092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@domfarolino the bit that says "the user agent must append an event listener" will need to be modified in HTML. |
Created #596 for #365 (comment). Would be good to get an answer to @domfarolino's question too. |
See whatwg/dom#596 and whatwg/dom#365 and w3c/ServiceWorker#1004 for more context.
This hook ensures that any special casing in addEventListener() is shared with event handlers. This commit also makes numerous editorial improvements that were long overdue around dictionary members. The corresponding change to the HTML Standard, which defines event handlers, is tracked by whatwg/html#3561. This helps with #365 and w3c/ServiceWorker#1004. (Tests will be added as part of #365 eventually.)
I did not mean to close this. Apologies. |
I noticed that w3c/touch-events#75 was closed (to me, unexpectedly), so I'm not really sure what the status of #366 or if we're still planning on following through with the aforementioned intervention in the spec, but more info would be greatly appreciated! |
This hook was provided whatwg/dom#596 and event handlers need to use it to fix whatwg/dom#365 and w3c/ServiceWorker#1004 properly. Tests will be added as part of resolving those issues.
There appear to be tests for this behavior or something related to it, with no spec backing them: |
It seems like they should be at best considered as "tentative" tests. |
I've sent web-platform-tests/wpt#29039 to rename those two tests. |
Quick status update: it appears what remains to be specced (and is implemented in at least 2 browsers, maybe 3?) is:
We have .tentative test coverage for wheel and touchmove on document. So the work to do is:
|
This test https://github.com/web-platform-tests/wpt/blob/master/dom/events/document-level-wheel-event-listener-passive-by-default.tentative.html says it's a manual test (but doesn't use Running it with await new test_driver.Actions()
.scroll(pos_x, pos_y, delta_x, delta_y).send(); I'll assume that the manual test statement is wrong. Please let me know if I'm missing something though :) |
I've opened a PR with the tests @domenic outlined above in web-platform-tests/wpt#34464 Since the tests fail in Firefox and Safari due to test infrastructure issues, I also wrote demos to be able to assess interop. See web-platform-tests/wpt#34464 (comment) The behavior of both Chrome and Safari for the third demo can't be explained by the existing intervention design docs, as far as I can tell. The behavior seems to be something like: first fire a cancelable event, and if that event is not |
I suppose it's possible that certain events are not cancelable, independently from default passive event listeners. Is that the case? |
That is an accurate description of Chrome and Safari's behavior, yes. |
@smfr thanks! But it's unrelated to default passive event listener, which happens during The chromium code for that is here: which I think still matches WICG/interventions#35 (comment) (+ |
Right. It's a separate kind of intervention intended to maintain good scrolling performance. |
Great! Makes sense. I'll file a separate issue about that intervention. |
Oh, I see now that it's already in the UI Events spec: https://w3c.github.io/uievents/#cancelability-of-wheel-events And for touch* here https://w3c.github.io/touch-events/#cancelability |
So, Chromium and WebKit also implement this hack for smoothscroll.js: As far as I can tell, Gecko does not. https://searchfox.org/mozilla-central/source/dom/events/EventListenerManager.cpp#1593 (and no search results for "ssc_wheel") Should we put this in the spec? The use counter is currently at ~0.01% of page views. But scrolling the page doesn't work at all without the hack. |
IMO we should put that hack in the spec, although it could perhaps be done separably since it's such a ... unique ... hack. |
…t/touchmove events Tests: web-platform-tests/wpt#34623 Fixes #365.
In order to support interventions such as Default passive true for touch blocking listeners on root level targets we need a hook in the DOM specification to be able to override the default value of the passive field.
The text was updated successfully, but these errors were encountered: