- From: Masayuki Nakano via GitHub <sysbot+gh@w3.org>
- Date: Fri, 07 Feb 2025 06:20:33 +0000
- To: public-css-archive@w3.org
masayuki-nakano has just created a new issue for https://github.com/w3c/csswg-drafts: == Define `MouseEvent.offsetX` and `MouseEvent.offsetY` values after style changes/mutations == > The `offsetX` attribute must follow these steps: > > 1. If the event’s [dispatch flag](https://dom.spec.whatwg.org/#dispatch-flag) is set, return the x-coordinate of the position where the event occurred relative to the origin of the [padding edge](https://drafts.csswg.org/css-box-4/#padding-edge) of the target node, ignoring the [transforms](https://drafts.csswg.org/cssom-view/#transforms) that apply to the element and its ancestors, and terminate these steps. > 2. Return the value of the event’s [pageX](https://drafts.csswg.org/cssom-view/#dom-mouseevent-pagex) attribute. It seems that no browser implements as these steps, especially about the step 2. [Chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/events/mouse_event.cc;l=562-564;drc=003b43cb850a2fb81bb482cd95381338b7205933) and [Safari](https://searchfox.org/wubkat/rev/446d00e44d23eba2d8c1c1c92bf0171472dee385/Source/WebCore/dom/MouseRelatedEvent.cpp#249-251) cache `offsetX` and `offsetY` values when one of them is retrieved first time. Then, keep returning the cached values even after finishing the propagation. [Firefox](https://searchfox.org/mozilla-central/rev/46c5f46a83146b311828b9cdd64b975a08066278/dom/events/MouseEvent.cpp#409-411) computes the position with the latest layout. So, the values may be different even if layout and event position are exactly same between Chromium/Safari and Firefox. Perhaps, it's probably better that Firefox aligns the behavior to Chromium/Safari. On the other hand, current Chromium/Safari behavior is also odd to me. They depend on **when** `offsetX` or `offsetY` are retrieved. This could be no problem for web apps if they work alone. However, for example, addons of the browser may refer the offsets. Then, the web apps may retrieve unexpected values. So, perhaps, the spec should limit the cache timing only when web content script retrieves the values. Additionally, I'm not sure what should happen if the event target element is moved into different document or already disconnected from the DOM or disappeared from the layout. In these cases, what values should be computed if they have not been cached? Cc: @flackr, @mustaqahmed, @smaug----, @garykac Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11667 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 7 February 2025 06:20:34 UTC