Explorar el Código

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. :^)
Andreas Kling hace 2 años
padre
commit
dd2080c55f

+ 12 - 0
Userland/Libraries/LibWeb/DOM/Element.cpp

@@ -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)");
+}
+
 }

+ 4 - 0
Userland/Libraries/LibWeb/DOM/Element.h

@@ -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;

+ 5 - 0
Userland/Libraries/LibWeb/DOM/Element.idl

@@ -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 {