mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWebView+WebContent: Add an IPC to scroll an element into view
Note that even though there is no response, this IPC has to be synchronous to allow all scroll events to trigger before returning to the calling WebDriver process.
This commit is contained in:
parent
3510fbbea8
commit
424e80ee75
Notes:
sideshowbarker
2024-07-17 04:47:08 +09:00
Author: https://github.com/trflynn89
Commit: 424e80ee75
Pull-request: https://github.com/SerenityOS/serenity/pull/15927
Reviewed-by: https://github.com/linusg ✅
5 changed files with 28 additions and 0 deletions
|
@ -503,6 +503,26 @@ static Optional<Web::DOM::Element&> find_element_by_id(i32 element_id)
|
|||
return verify_cast<Web::DOM::Element>(*node);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-scrolls-into-view
|
||||
void ConnectionFromClient::scroll_element_into_view(i32 element_id)
|
||||
{
|
||||
auto element = find_element_by_id(element_id);
|
||||
if (!element.has_value())
|
||||
return;
|
||||
|
||||
// 1. Let options be the following ScrollIntoViewOptions:
|
||||
Web::DOM::ScrollIntoViewOptions options {};
|
||||
// Logical scroll position "block"
|
||||
// "end"
|
||||
options.block = Web::Bindings::ScrollLogicalPosition::End;
|
||||
// Logical scroll position "inline"
|
||||
// "nearest"
|
||||
options.inline_ = Web::Bindings::ScrollLogicalPosition::Nearest;
|
||||
|
||||
// 2. Run Function.[[Call]](scrollIntoView, options) with element as the this value.
|
||||
element->scroll_into_view(options);
|
||||
}
|
||||
|
||||
Messages::WebContentServer::IsElementSelectedResponse ConnectionFromClient::is_element_selected(i32 element_id)
|
||||
{
|
||||
auto element = find_element_by_id(element_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue