mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb+WebContent: Ensure elements are in view before clicking them
This implements a couple of missing steps in the Element Click endpoint.
This commit is contained in:
parent
0286eb4e3e
commit
e89d889219
Notes:
github-actions[bot]
2024-10-24 23:00:49 +00:00
Author: https://github.com/trflynn89
Commit: e89d889219
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1949
Reviewed-by: https://github.com/awesomekling ✅
3 changed files with 54 additions and 2 deletions
|
@ -1347,8 +1347,15 @@ Messages::WebDriverClient::ElementClickResponse WebDriverConnection::element_cli
|
|||
auto element_container = container_for_element(*element);
|
||||
scroll_element_into_view(*element_container);
|
||||
|
||||
// FIXME: 6. If element’s container is still not in view, return error with error code element not interactable.
|
||||
// FIXME: 7. If element’s container is obscured by another element, return error with error code element click intercepted.
|
||||
auto paint_tree = Web::WebDriver::pointer_interactable_tree(current_browsing_context(), *element_container);
|
||||
|
||||
// 6. If element’s container is still not in view, return error with error code element not interactable.
|
||||
if (!Web::WebDriver::is_element_in_view(paint_tree, *element_container))
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::ElementNotInteractable, "Could not bring element into view"sv);
|
||||
|
||||
// 7. If element’s container is obscured by another element, return error with error code element click intercepted.
|
||||
if (Web::WebDriver::is_element_obscured(paint_tree, *element_container))
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::ElementClickIntercepted, "Element is obscured by another element"sv);
|
||||
|
||||
auto on_complete = JS::create_heap_function(current_browsing_context().heap(), [this](Web::WebDriver::Response result) {
|
||||
// 9. Wait until the user agent event loop has spun enough times to process the DOM events generated by the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue