LibWeb: Stub out Element.scroll() and Element.scrollTo()

With this, we stop throwing exceptions in a way that makes MDN disappear
and it's now possible to browse MDN in Ladybird. :^)
This commit is contained in:
Andreas Kling 2023-06-07 17:11:01 +02:00
parent 7f90b0cab7
commit dd2080c55f
3 changed files with 21 additions and 0 deletions

View file

@ -1774,4 +1774,16 @@ HashMap<DeprecatedFlyString, CSS::StyleProperty> const& Element::custom_properti
return m_pseudo_element_custom_properties[to_underlying(pseudo_element.value())];
}
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
void Element::scroll(double x, double y)
{
dbgln("FIXME: Implement Element::scroll(x: {}, y: {}", x, y);
}
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
void Element::scroll(HTML::ScrollToOptions const&)
{
dbgln("FIXME: Implement Element::scroll(ScrollToOptions)");
}
}

View file

@ -21,6 +21,7 @@
#include <LibWeb/HTML/EventLoop/Task.h>
#include <LibWeb/HTML/ScrollOptions.h>
#include <LibWeb/HTML/TagNames.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::DOM {
@ -306,6 +307,9 @@ public:
void set_custom_element_state(CustomElementState value) { m_custom_element_state = value; }
void setup_custom_element_from_constructor(HTML::CustomElementDefinition& custom_element_definition, Optional<String> const& is_value);
void scroll(HTML::ScrollToOptions const&);
void scroll(double x, double y);
protected:
Element(Document&, DOM::QualifiedName);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;

View file

@ -79,6 +79,11 @@ interface Element : Node {
undefined scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
undefined scroll(optional ScrollToOptions options = {});
undefined scroll(unrestricted double x, unrestricted double y);
[ImplementedAs=scroll] undefined scrollTo(optional ScrollToOptions options = {});
[ImplementedAs=scroll] undefined scrollTo(unrestricted double x, unrestricted double y);
};
dictionary ShadowRootInit {