diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-24 21:49:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-25 18:47:19 +0200 |
commit | 2c0987c93bec7a7327a0e80eb045612af6e83221 (patch) | |
tree | 24fadc31144698d2cf62216d3fe16e775b9b3946 /Userland/Libraries/LibWeb/DOM | |
parent | 38157a60936f2c8718e1ae9b1bc664db1c832931 (diff) | |
download | serenity-2c0987c93bec7a7327a0e80eb045612af6e83221.zip |
LibWeb: Move window.scroll{X,Y} from wrapper into DOM::Window
The less we do in WindowObject, the easier it will be to eventually
auto-generate the entire thing.
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Window.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Window.h | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index c20df10444..3e2532e9b5 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -260,4 +260,20 @@ NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media) return CSS::MediaQueryList::create(associated_document(), move(media)); } +// https://www.w3.org/TR/cssom-view/#dom-window-scrollx +float Window::scroll_x() const +{ + if (auto* page = this->page()) + return page->top_level_browsing_context().viewport_scroll_offset().x(); + return 0; +} + +// https://www.w3.org/TR/cssom-view/#dom-window-scrolly +float Window::scroll_y() const +{ + if (auto* page = this->page()) + return page->top_level_browsing_context().viewport_scroll_offset().y(); + return 0; +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h index 7381962577..f17873cf49 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.h +++ b/Userland/Libraries/LibWeb/DOM/Window.h @@ -80,6 +80,9 @@ public: NonnullRefPtr<CSS::CSSStyleDeclaration> get_computed_style(DOM::Element&) const; NonnullRefPtr<CSS::MediaQueryList> match_media(String); + float scroll_x() const; + float scroll_y() const; + private: explicit Window(Document&); |