mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:47:45 +00:00
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.
This commit is contained in:
parent
38157a6093
commit
2c0987c93b
3 changed files with 21 additions and 6 deletions
|
@ -510,9 +510,7 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::scroll_x_getter)
|
||||||
auto* impl = impl_from(vm, global_object);
|
auto* impl = impl_from(vm, global_object);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return {};
|
return {};
|
||||||
if (!impl->page())
|
return JS::Value(impl->scroll_x());
|
||||||
return JS::Value(0);
|
|
||||||
return JS::Value(impl->page()->top_level_browsing_context().viewport_scroll_offset().x());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom-view/#dom-window-scrolly
|
// https://www.w3.org/TR/cssom-view/#dom-window-scrolly
|
||||||
|
@ -521,9 +519,7 @@ JS_DEFINE_NATIVE_GETTER(WindowObject::scroll_y_getter)
|
||||||
auto* impl = impl_from(vm, global_object);
|
auto* impl = impl_from(vm, global_object);
|
||||||
if (!impl)
|
if (!impl)
|
||||||
return {};
|
return {};
|
||||||
if (!impl->page())
|
return JS::Value(impl->scroll_y());
|
||||||
return JS::Value(0);
|
|
||||||
return JS::Value(impl->page()->top_level_browsing_context().viewport_scroll_offset().y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ScrollBehavior {
|
enum class ScrollBehavior {
|
||||||
|
|
|
@ -260,4 +260,20 @@ NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media)
|
||||||
return CSS::MediaQueryList::create(associated_document(), move(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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,9 @@ public:
|
||||||
NonnullRefPtr<CSS::CSSStyleDeclaration> get_computed_style(DOM::Element&) const;
|
NonnullRefPtr<CSS::CSSStyleDeclaration> get_computed_style(DOM::Element&) const;
|
||||||
NonnullRefPtr<CSS::MediaQueryList> match_media(String);
|
NonnullRefPtr<CSS::MediaQueryList> match_media(String);
|
||||||
|
|
||||||
|
float scroll_x() const;
|
||||||
|
float scroll_y() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Window(Document&);
|
explicit Window(Document&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue