mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 05:57:41 +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
|
@ -565,6 +565,11 @@ Gfx::IntRect OutOfProcessWebView::get_element_rect(i32 element_id)
|
||||||
return client().get_element_rect(element_id);
|
return client().get_element_rect(element_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OutOfProcessWebView::is_element_enabled(i32 element_id)
|
||||||
|
{
|
||||||
|
return client().is_element_enabled(element_id);
|
||||||
|
}
|
||||||
|
|
||||||
void OutOfProcessWebView::set_content_filters(Vector<String> filters)
|
void OutOfProcessWebView::set_content_filters(Vector<String> filters)
|
||||||
{
|
{
|
||||||
client().async_set_content_filters(filters);
|
client().async_set_content_filters(filters);
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
String get_element_text(i32 element_id);
|
String get_element_text(i32 element_id);
|
||||||
String get_element_tag_name(i32 element_id);
|
String get_element_tag_name(i32 element_id);
|
||||||
Gfx::IntRect get_element_rect(i32 element_id);
|
Gfx::IntRect get_element_rect(i32 element_id);
|
||||||
|
bool is_element_enabled(i32 element_id);
|
||||||
|
|
||||||
void set_content_filters(Vector<String>);
|
void set_content_filters(Vector<String>);
|
||||||
void set_proxy_mappings(Vector<String> proxies, HashMap<String, size_t> mappings);
|
void set_proxy_mappings(Vector<String> proxies, HashMap<String, size_t> mappings);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||||
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
#include <LibWeb/Geometry/DOMRect.h>
|
#include <LibWeb/Geometry/DOMRect.h>
|
||||||
#include <LibWeb/HTML/BrowsingContext.h>
|
#include <LibWeb/HTML/BrowsingContext.h>
|
||||||
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
||||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||||
#include <LibWeb/HTML/Storage.h>
|
#include <LibWeb/HTML/Storage.h>
|
||||||
#include <LibWeb/HTML/Window.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()) } };
|
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()
|
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
|
||||||
{
|
{
|
||||||
return page().focused_context().selected_text();
|
return page().focused_context().selected_text();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -91,6 +92,7 @@ private:
|
||||||
virtual Messages::WebContentServer::GetElementTextResponse get_element_text(i32 element_id) override;
|
virtual Messages::WebContentServer::GetElementTextResponse get_element_text(i32 element_id) override;
|
||||||
virtual Messages::WebContentServer::GetElementTagNameResponse get_element_tag_name(i32 element_id) override;
|
virtual Messages::WebContentServer::GetElementTagNameResponse get_element_tag_name(i32 element_id) override;
|
||||||
virtual Messages::WebContentServer::GetElementRectResponse get_element_rect(i32 element_id) override;
|
virtual Messages::WebContentServer::GetElementRectResponse get_element_rect(i32 element_id) override;
|
||||||
|
virtual Messages::WebContentServer::IsElementEnabledResponse is_element_enabled(i32 element_id) override;
|
||||||
|
|
||||||
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override;
|
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override;
|
||||||
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries() override;
|
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries() override;
|
||||||
|
|
|
@ -49,6 +49,7 @@ endpoint WebContentServer
|
||||||
get_element_text(i32 element_id) => (String text)
|
get_element_text(i32 element_id) => (String text)
|
||||||
get_element_tag_name(i32 element_id) => (String tag_name)
|
get_element_tag_name(i32 element_id) => (String tag_name)
|
||||||
get_element_rect(i32 element_id) => (Gfx::IntRect rect)
|
get_element_rect(i32 element_id) => (Gfx::IntRect rect)
|
||||||
|
is_element_enabled(i32 element_id) => (bool enabled)
|
||||||
|
|
||||||
webdriver_execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
|
webdriver_execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue