implement basic infra for ResizeObserver (#31108)

This commit is contained in:
Gregory Terzian 2024-06-18 00:44:07 +08:00 committed by GitHub
parent 3c1c395dfc
commit 3d78d60619
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 706 additions and 4 deletions

View file

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://drafts.csswg.org/resize-observer/#resize-observer-interface
[Pref="dom.resize_observer.enabled", Exposed=(Window)]
interface ResizeObserver {
constructor(ResizeObserverCallback callback);
undefined observe(Element target, optional ResizeObserverOptions options = {});
undefined unobserve(Element target);
undefined disconnect();
};
enum ResizeObserverBoxOptions {
"border-box", "content-box", "device-pixel-content-box"
};
dictionary ResizeObserverOptions {
ResizeObserverBoxOptions box = "content-box";
};
callback ResizeObserverCallback = undefined (sequence<ResizeObserverEntry> entries, ResizeObserver observer);

View file

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface
[Pref="dom.resize_observer.enabled", Exposed=Window]
interface ResizeObserverEntry {
readonly attribute Element target;
readonly attribute DOMRectReadOnly contentRect;
readonly attribute /*FrozenArray<ResizeObserverSize>*/any borderBoxSize;
readonly attribute /*FrozenArray<ResizeObserverSize>*/any contentBoxSize;
readonly attribute /*FrozenArray<ResizeObserverSize>*/any devicePixelContentBoxSize;
};

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://drafts.csswg.org/resize-observer/#resizeobserversize
[Pref="dom.resize_observer.enabled", Exposed=Window]
interface ResizeObserverSize {
readonly attribute unrestricted double inlineSize;
readonly attribute unrestricted double blockSize;
};