mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:47:34 +00:00
LibWeb: Implement basic version of CSSOM View's VisualViewport
We got some errors while loading https://twinings.co.uk/ about this interface missing, and it looked fairly simple so I sketched it out. Note that I did leave some FIXMEs where it's not clear exactly which metrics we should be returning.
This commit is contained in:
parent
2a914a7a59
commit
9f6ceff7cf
13 changed files with 257 additions and 2 deletions
|
@ -78,6 +78,7 @@ namespace Web::HTML::EventNames {
|
|||
__ENUMERATE_HTML_EVENT(reset) \
|
||||
__ENUMERATE_HTML_EVENT(resize) \
|
||||
__ENUMERATE_HTML_EVENT(scroll) \
|
||||
__ENUMERATE_HTML_EVENT(scrollend) \
|
||||
__ENUMERATE_HTML_EVENT(securitypolicyviolation) \
|
||||
__ENUMERATE_HTML_EVENT(seeked) \
|
||||
__ENUMERATE_HTML_EVENT(seeking) \
|
||||
|
|
|
@ -1085,6 +1085,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::Screen>> Window::screen()
|
|||
return JS::NonnullGCPtr { *m_screen };
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<CSS::VisualViewport>> Window::visual_viewport()
|
||||
{
|
||||
// If the associated document is fully active, the visualViewport attribute must return
|
||||
// the VisualViewport object associated with the Window object’s associated document.
|
||||
if (associated_document().is_fully_active())
|
||||
return associated_document().visual_viewport();
|
||||
|
||||
// Otherwise, it must return null.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-innerwidth
|
||||
i32 Window::inner_width() const
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -156,6 +156,7 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::MediaQueryList>> match_media(String const& query);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CSS::Screen>> screen();
|
||||
WebIDL::ExceptionOr<JS::GCPtr<CSS::VisualViewport>> visual_viewport();
|
||||
|
||||
i32 inner_width() const;
|
||||
i32 inner_height() const;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#import <Crypto/Crypto.idl>
|
||||
#import <CSS/MediaQueryList.idl>
|
||||
#import <CSS/Screen.idl>
|
||||
#import <CSS/VisualViewport.idl>
|
||||
#import <DOM/Document.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <DOM/EventTarget.idl>
|
||||
|
@ -57,6 +58,7 @@ interface Window : EventTarget {
|
|||
// https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
|
||||
[NewObject] MediaQueryList matchMedia(CSSOMString query);
|
||||
[SameObject, Replaceable] readonly attribute Screen screen;
|
||||
[SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;
|
||||
|
||||
// viewport
|
||||
[Replaceable] readonly attribute long innerWidth;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue