mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibWeb: Stub out a basic ResizeObserver interface
This patch establishes scaffolding for the ResizeObserver API.
This commit is contained in:
parent
5c9ca5c2dc
commit
fdc1c15064
7 changed files with 121 additions and 1 deletions
|
@ -740,7 +740,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto interface = IDL::parse_interface(path, data, import_base_path);
|
auto interface = IDL::parse_interface(path, data, import_base_path);
|
||||||
|
|
||||||
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "SVG", "Selection", "XHR", "URL")) {
|
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "ResizeObserver", "SVG", "Selection", "XHR", "URL")) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append(namespace_);
|
builder.append(namespace_);
|
||||||
builder.append("::");
|
builder.append("::");
|
||||||
|
@ -1389,6 +1389,8 @@ static void generate_header(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@name@.h>
|
# include <LibWeb/NavigationTiming/@name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -1552,6 +1554,7 @@ void generate_implementation(IDL::Interface const& interface)
|
||||||
#include <LibWeb/DOM/EventListener.h>
|
#include <LibWeb/DOM/EventListener.h>
|
||||||
#include <LibWeb/HTML/HTMLElement.h>
|
#include <LibWeb/HTML/HTMLElement.h>
|
||||||
#include <LibWeb/Origin.h>
|
#include <LibWeb/Origin.h>
|
||||||
|
#include <LibWeb/ResizeObserver/ResizeObserver.h>
|
||||||
|
|
||||||
// FIXME: This is a total hack until we can figure out the namespace for a given type somehow.
|
// FIXME: This is a total hack until we can figure out the namespace for a given type somehow.
|
||||||
using namespace Web::CSS;
|
using namespace Web::CSS;
|
||||||
|
@ -1559,6 +1562,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::ResizeObserver;
|
||||||
using namespace Web::Selection;
|
using namespace Web::Selection;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
@ -2473,6 +2477,8 @@ void generate_constructor_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@name@.h>
|
# include <LibWeb/NavigationTiming/@name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -2489,6 +2495,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::ResizeObserver;
|
||||||
using namespace Web::Selection;
|
using namespace Web::Selection;
|
||||||
using namespace Web::UIEvents;
|
using namespace Web::UIEvents;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
|
@ -2783,6 +2790,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@name@.h>
|
# include <LibWeb/NavigationTiming/@name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -2813,6 +2822,8 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@iterator_name@.h>
|
# include <LibWeb/NavigationTiming/@iterator_name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@iterator_name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@iterator_name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@iterator_name@.h>
|
# include <LibWeb/RequestIdleCallback/@iterator_name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@iterator_name@.h>)
|
#elif __has_include(<LibWeb/SVG/@iterator_name@.h>)
|
||||||
# include <LibWeb/SVG/@iterator_name@.h>
|
# include <LibWeb/SVG/@iterator_name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -2834,6 +2845,7 @@ using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::NavigationTiming;
|
using namespace Web::NavigationTiming;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::ResizeObserver;
|
||||||
using namespace Web::Selection;
|
using namespace Web::Selection;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
using namespace Web::URL;
|
using namespace Web::URL;
|
||||||
|
@ -3256,6 +3268,8 @@ static void generate_iterator_header(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@name@.h>
|
# include <LibWeb/NavigationTiming/@name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -3324,6 +3338,7 @@ using namespace Web::DOM;
|
||||||
using namespace Web::Geometry;
|
using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::ResizeObserver;
|
||||||
using namespace Web::Selection;
|
using namespace Web::Selection;
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
@ -3438,6 +3453,8 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface)
|
||||||
# include <LibWeb/NavigationTiming/@name@.h>
|
# include <LibWeb/NavigationTiming/@name@.h>
|
||||||
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
#elif __has_include(<LibWeb/RequestIdleCallback/@name@.h>)
|
||||||
# include <LibWeb/RequestIdleCallback/@name@.h>
|
# include <LibWeb/RequestIdleCallback/@name@.h>
|
||||||
|
#elif __has_include(<LibWeb/ResizeObserver/@name@.h>)
|
||||||
|
# include <LibWeb/ResizeObserver/@name@.h>
|
||||||
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
#elif __has_include(<LibWeb/SVG/@name@.h>)
|
||||||
# include <LibWeb/SVG/@name@.h>
|
# include <LibWeb/SVG/@name@.h>
|
||||||
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
#elif __has_include(<LibWeb/Selection/@name@.h>)
|
||||||
|
@ -3455,6 +3472,7 @@ using namespace Web::Geometry;
|
||||||
using namespace Web::HTML;
|
using namespace Web::HTML;
|
||||||
using namespace Web::NavigationTiming;
|
using namespace Web::NavigationTiming;
|
||||||
using namespace Web::RequestIdleCallback;
|
using namespace Web::RequestIdleCallback;
|
||||||
|
using namespace Web::ResizeObserver;
|
||||||
using namespace Web::Selection;
|
using namespace Web::Selection;
|
||||||
using namespace Web::XHR;
|
using namespace Web::XHR;
|
||||||
using namespace Web::URL;
|
using namespace Web::URL;
|
||||||
|
|
|
@ -233,6 +233,8 @@
|
||||||
#include <LibWeb/Bindings/ProgressEventPrototype.h>
|
#include <LibWeb/Bindings/ProgressEventPrototype.h>
|
||||||
#include <LibWeb/Bindings/RangeConstructor.h>
|
#include <LibWeb/Bindings/RangeConstructor.h>
|
||||||
#include <LibWeb/Bindings/RangePrototype.h>
|
#include <LibWeb/Bindings/RangePrototype.h>
|
||||||
|
#include <LibWeb/Bindings/ResizeObserverConstructor.h>
|
||||||
|
#include <LibWeb/Bindings/ResizeObserverPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
#include <LibWeb/Bindings/SVGElementConstructor.h>
|
||||||
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
#include <LibWeb/Bindings/SVGElementPrototype.h>
|
||||||
#include <LibWeb/Bindings/SVGGeometryElementConstructor.h>
|
#include <LibWeb/Bindings/SVGGeometryElementConstructor.h>
|
||||||
|
@ -395,6 +397,7 @@
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ProcessingInstruction) \
|
ADD_WINDOW_OBJECT_INTERFACE(ProcessingInstruction) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
|
ADD_WINDOW_OBJECT_INTERFACE(ProgressEvent) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(Range) \
|
ADD_WINDOW_OBJECT_INTERFACE(Range) \
|
||||||
|
ADD_WINDOW_OBJECT_INTERFACE(ResizeObserver) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(Screen) \
|
ADD_WINDOW_OBJECT_INTERFACE(Screen) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(Selection) \
|
ADD_WINDOW_OBJECT_INTERFACE(Selection) \
|
||||||
ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
|
ADD_WINDOW_OBJECT_INTERFACE(ShadowRoot) \
|
||||||
|
|
|
@ -244,6 +244,7 @@ set(SOURCES
|
||||||
Painting/ShadowPainting.cpp
|
Painting/ShadowPainting.cpp
|
||||||
Painting/StackingContext.cpp
|
Painting/StackingContext.cpp
|
||||||
RequestIdleCallback/IdleDeadline.cpp
|
RequestIdleCallback/IdleDeadline.cpp
|
||||||
|
ResizeObserver/ResizeObserver.cpp
|
||||||
SVG/AttributeNames.cpp
|
SVG/AttributeNames.cpp
|
||||||
SVG/SVGElement.cpp
|
SVG/SVGElement.cpp
|
||||||
SVG/SVGGElement.cpp
|
SVG/SVGGElement.cpp
|
||||||
|
@ -472,6 +473,7 @@ libweb_js_wrapper(HTML/WebSocket)
|
||||||
libweb_js_wrapper(HighResolutionTime/Performance)
|
libweb_js_wrapper(HighResolutionTime/Performance)
|
||||||
libweb_js_wrapper(NavigationTiming/PerformanceTiming)
|
libweb_js_wrapper(NavigationTiming/PerformanceTiming)
|
||||||
libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
|
libweb_js_wrapper(RequestIdleCallback/IdleDeadline)
|
||||||
|
libweb_js_wrapper(ResizeObserver/ResizeObserver)
|
||||||
libweb_js_wrapper(SVG/SVGElement)
|
libweb_js_wrapper(SVG/SVGElement)
|
||||||
libweb_js_wrapper(SVG/SVGGeometryElement)
|
libweb_js_wrapper(SVG/SVGGeometryElement)
|
||||||
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
libweb_js_wrapper(SVG/SVGGraphicsElement)
|
||||||
|
|
|
@ -211,6 +211,10 @@ namespace Web::RequestIdleCallback {
|
||||||
class IdleDeadline;
|
class IdleDeadline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Web::ResizeObserver {
|
||||||
|
class ResizeObserver;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Web::SVG {
|
namespace Web::SVG {
|
||||||
class SVGElement;
|
class SVGElement;
|
||||||
class SVGGeometryElement;
|
class SVGGeometryElement;
|
||||||
|
@ -396,6 +400,7 @@ class PerformanceTimingWrapper;
|
||||||
class PerformanceWrapper;
|
class PerformanceWrapper;
|
||||||
class ProcessingInstructionWrapper;
|
class ProcessingInstructionWrapper;
|
||||||
class ProgressEventWrapper;
|
class ProgressEventWrapper;
|
||||||
|
class ResizeObserverWrapper;
|
||||||
class ScreenWrapper;
|
class ScreenWrapper;
|
||||||
class ScriptExecutionContext;
|
class ScriptExecutionContext;
|
||||||
class SubmitEventWrapper;
|
class SubmitEventWrapper;
|
||||||
|
|
42
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp
Normal file
42
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/DOM/Element.h>
|
||||||
|
#include <LibWeb/ResizeObserver/ResizeObserver.h>
|
||||||
|
|
||||||
|
namespace Web::ResizeObserver {
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-resizeobserver
|
||||||
|
NonnullRefPtr<ResizeObserver> ResizeObserver::create_with_global_object(JS::GlobalObject& global_object, JS::Value callback)
|
||||||
|
{
|
||||||
|
// FIXME: Implement
|
||||||
|
(void)global_object;
|
||||||
|
(void)callback;
|
||||||
|
return adopt_ref(*new ResizeObserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-observe
|
||||||
|
void ResizeObserver::observe(DOM::Element& target, ResizeObserverOptions options)
|
||||||
|
{
|
||||||
|
// FIXME: Implement
|
||||||
|
(void)target;
|
||||||
|
(void)options;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-unobserve
|
||||||
|
void ResizeObserver::unobserve(DOM::Element& target)
|
||||||
|
{
|
||||||
|
// FIXME: Implement
|
||||||
|
(void)target;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/resize-observer/#dom-resizeobserver-disconnect
|
||||||
|
void ResizeObserver::disconnect()
|
||||||
|
{
|
||||||
|
// FIXME: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h
Normal file
33
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/NonnullRefPtr.h>
|
||||||
|
#include <AK/RefCounted.h>
|
||||||
|
#include <LibWeb/Bindings/Wrappable.h>
|
||||||
|
|
||||||
|
namespace Web::ResizeObserver {
|
||||||
|
|
||||||
|
struct ResizeObserverOptions {
|
||||||
|
String box;
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/resize-observer/#resize-observer-interface
|
||||||
|
class ResizeObserver
|
||||||
|
: public RefCounted<ResizeObserver>
|
||||||
|
, public Bindings::Wrappable {
|
||||||
|
public:
|
||||||
|
using WrapperType = Bindings::ResizeObserverWrapper;
|
||||||
|
|
||||||
|
static NonnullRefPtr<ResizeObserver> create_with_global_object(JS::GlobalObject&, JS::Value callback);
|
||||||
|
|
||||||
|
void observe(DOM::Element& target, ResizeObserverOptions);
|
||||||
|
void unobserve(DOM::Element& target);
|
||||||
|
void disconnect();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
17
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.idl
Normal file
17
Userland/Libraries/LibWeb/ResizeObserver/ResizeObserver.idl
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[Exposed=(Window)]
|
||||||
|
interface ResizeObserver {
|
||||||
|
|
||||||
|
// FIXME: This should be a ResizeObserverCallback.
|
||||||
|
constructor(any callback);
|
||||||
|
undefined observe(Element target, optional ResizeObserverOptions options = {});
|
||||||
|
undefined unobserve(Element target);
|
||||||
|
undefined disconnect();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary ResizeObserverOptions {
|
||||||
|
|
||||||
|
// FIXME: This should be an enum.
|
||||||
|
DOMString box = "content-box";
|
||||||
|
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue