-
Notifications
You must be signed in to change notification settings - Fork 677
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
[resize-observer] The initial size of ResizeObservation #3664
Comments
Add a case to reproduce this issue. |
In that example if you remove the last line (the one that changes the size to 0x0), then you'll get notified for a size change of 100x100 (when nothing has actually changed). I guess it's because the initial |
@mrego Yes, exactly like you said. :) We might also get notified when nothing has changed. |
There was a discussion about what initial size should be at: Options were:
I think (0,0) option is most useful, because it does not fire until Element is shown. |
This is inconsistent with
Similarly, I think that
I don't think this justifies not reporting an observation for elements that do have a box but it just happens to be 0x0. Also note IntersectionObserver notifies about disconnected elements: new IntersectionObserver(console.log).observe(document.createElement("div")); |
Agenda+ to confirm the resolution in #7539 (comment) applies to ResizeObserver too (or get a new one otherwise), since from discussion with @Loirooriol it wasn't quite clear from the minutes. |
The CSS Working Group just discussed
The full IRC log of that discussion<emeyer> Topic: [resize-observer] The initial size of ResizeObservation<emeyer> github: https://github.com//issues/3664 <emeyer> emilio: FTF resolved that zero was not a special size for contain intrinsic size <emeyer> …The resolution seems to include resizeObserver, but in chats with Oriol it evolved that wasn’t clear <TabAtkins> + <TabAtkins> q+ <emeyer> …Worth clarifying <Rossen_> ack TabAtkins <emeyer> TabAtkins: The resolution was not intended to apply to resizeObserver but I’m fine with it applying <emeyer> …Consistency with things like c-i-s has me leaning to fire immediately and have an undefined size in resizeObserver <emeyer> Rossen_: Any objections to the proposed resolution? <emilio> When observing an element with ResizeObserver, lastReportedSize gets initialized with a -1x-1 size <emeyer> RESOLVED: When first observing an element with ResizeObserver, lastReportedSize gets initialized with a -1 x -1 size |
…lly. r=emilio It used to be 0x0, but changed per the CSSWG resolution: w3c/csswg-drafts#3664 Sits behind pref `dom.resize_observer.last_reported_size_invalid`. Differential Revision: https://phabricator.services.mozilla.com/D155710
It used to be 0x0, but changed per the CSSWG resolution: w3c/csswg-drafts#3664 Sits behind pref `dom.resize_observer.last_reported_size_invalid`. Differential Revision: https://phabricator.services.mozilla.com/D155710 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1785305 gecko-commit: 14e81415cae10e0699145eb052b49d369f5ee427 gecko-reviewers: emilio
It used to be 0x0, but changed per the CSSWG resolution: w3c/csswg-drafts#3664 Sits behind pref `dom.resize_observer.last_reported_size_invalid`. Differential Revision: https://phabricator.services.mozilla.com/D155710 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1785305 gecko-commit: 14e81415cae10e0699145eb052b49d369f5ee427 gecko-reviewers: emilio
…e -1x-1 https://bugs.webkit.org/show_bug.cgi?id=250836 Reviewed by NOBODY (OOPS!). The conclusion of [1] indicates that when first observing an element with ResizeObserver, lastReportedSize gets initialized with a -1 x -1 size. [1] w3c/csswg-drafts#3664 * LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: * LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt. * LayoutTests/platform/mac/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: * Source/WebCore/page/ResizeObservation.cpp:
…should be -1x-1 which always notify observed elements https://bugs.webkit.org/show_bug.cgi?id=251015 Reviewed by Oriol Brufau and Ryosuke Niwa. This patch initializes the lastReportedSize of ResizeObservation to -1 x -1, which is the conclusion of [1], it indicates that -1 x -1 is the initial size when first observing an element with ResizeObserver. The previous change makes every ResizeObservation be delivered at least once, even if the target is a disconnected element. When GC happens between observe and gather ResizeObservations, JSC::Weak<JSC::JSObject> m_callback inside JSCallbackDataWeak could be released, and the element and JSResizeObserver might not be released, for they are not strong connected, this scenario would trigger the ASSERT in ResizeObserver::deliverObservations. To fix it, this patch adds m_targetsWaitingForFirstObservation to extend the life cycle of ResizeObserver to the first time of deliverObservations. The fix is similar to what IntersectionObserver does in bug 231235. The test6 of resize-observer/notify.html still fails in mac-wk1, because updaterendering is not triggered properly. Filed [2] to track it. [1] w3c/csswg-drafts#3664 [2] https://bugs.webkit.org/show_bug.cgi?id=250900 * LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: * LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/resize-observer/notify-expected.txt. * LayoutTests/platform/mac/imported/w3c/web-platform-tests/resize-observer/svg-expected.txt: * Source/WebCore/page/ResizeObservation.cpp: * Source/WebCore/page/ResizeObserver.cpp: (WebCore::ResizeObserver::observe): (WebCore::ResizeObserver::deliverObservations): (WebCore::ResizeObserver::isReachableFromOpaqueRoots const): (WebCore::ResizeObserver::removeAllTargets): (WebCore::ResizeObserver::removeObservation): * Source/WebCore/page/ResizeObserver.h: Canonical link: https://commits.webkit.org/259673@main
https://drafts.csswg.org/resize-observer/#dom-resizeobservation-resizeobservation-target-options
Not very strong opinion about this.
We might miss this:
The text was updated successfully, but these errors were encountered: