mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:27:35 +00:00
LibWebView+WebConent: Add an IPC to get an element's enabled state
This commit is contained in:
parent
9564f04fa6
commit
683c99f299
5 changed files with 31 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -26,6 +27,7 @@
|
|||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Geometry/DOMRect.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
#include <LibWeb/HTML/Storage.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
@ -616,6 +618,26 @@ Messages::WebContentServer::GetElementRectResponse ConnectionFromClient::get_ele
|
|||
return { { coordinates.x(), coordinates.y(), static_cast<int>(bounding_rect->width()), static_cast<int>(bounding_rect->height()) } };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::IsElementEnabledResponse ConnectionFromClient::is_element_enabled(i32 element_id)
|
||||
{
|
||||
auto element = find_element_by_id(element_id);
|
||||
if (!element.has_value())
|
||||
return { false };
|
||||
|
||||
auto* document = page().top_level_browsing_context().active_document();
|
||||
if (!document)
|
||||
return { false };
|
||||
|
||||
bool enabled = !document->is_xml_document();
|
||||
|
||||
if (enabled && is<Web::HTML::FormAssociatedElement>(*element)) {
|
||||
auto& form_associated_element = dynamic_cast<Web::HTML::FormAssociatedElement&>(*element);
|
||||
enabled = form_associated_element.enabled();
|
||||
}
|
||||
|
||||
return { enabled };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
|
||||
{
|
||||
return page().focused_context().selected_text();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue