mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
LibWebView+WebContent: Add a WebContent IPC to get a DOM node's HTML
This commit is contained in:
parent
8162dc5ee6
commit
bea11f6d99
5 changed files with 22 additions and 0 deletions
|
@ -206,6 +206,11 @@ void ViewImplementation::remove_dom_node(i32 node_id)
|
|||
client().async_remove_dom_node(node_id);
|
||||
}
|
||||
|
||||
Optional<String> ViewImplementation::get_dom_node_html(i32 node_id)
|
||||
{
|
||||
return client().get_dom_node_html(node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
|
||||
{
|
||||
client().async_debug_request(request, argument);
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
void add_dom_node_attributes(i32 node_id, Vector<Attribute> attributes);
|
||||
void replace_dom_node_attribute(i32 node_id, String name, Vector<Attribute> replacement_attributes);
|
||||
void remove_dom_node(i32 node_id);
|
||||
Optional<String> get_dom_node_html(i32 node_id);
|
||||
|
||||
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = {});
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <LibWeb/Loader/ContentFilter.h>
|
||||
#include <LibWeb/Loader/ProxyMappings.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Painting/StackingContext.h>
|
||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
||||
|
@ -737,6 +738,19 @@ void ConnectionFromClient::remove_dom_node(i32 node_id)
|
|||
active_document->force_layout();
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetDomNodeHtmlResponse ConnectionFromClient::get_dom_node_html(i32 node_id)
|
||||
{
|
||||
auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
|
||||
if (!dom_node)
|
||||
return OptionalNone {};
|
||||
|
||||
// FIXME: Implement Element's outerHTML attribute.
|
||||
auto container = Web::DOM::create_element(dom_node->document(), Web::HTML::TagNames::div, Web::Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
container->append_child(dom_node->clone_node(nullptr, true)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
return container->inner_html().release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::initialize_js_console(Badge<PageClient>, Web::DOM::Document& document)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
|
|
|
@ -81,6 +81,7 @@ private:
|
|||
virtual void add_dom_node_attributes(i32 node_id, Vector<WebView::Attribute> const& attributes) override;
|
||||
virtual void replace_dom_node_attribute(i32 node_id, String const& name, Vector<WebView::Attribute> const& replacement_attributes) override;
|
||||
virtual void remove_dom_node(i32 node_id) override;
|
||||
virtual Messages::WebContentServer::GetDomNodeHtmlResponse get_dom_node_html(i32 node_id) override;
|
||||
|
||||
virtual Messages::WebContentServer::DumpLayoutTreeResponse dump_layout_tree() override;
|
||||
virtual Messages::WebContentServer::DumpPaintTreeResponse dump_paint_tree() override;
|
||||
|
|
|
@ -51,6 +51,7 @@ endpoint WebContentServer
|
|||
add_dom_node_attributes(i32 node_id, Vector<WebView::Attribute> attributes) =|
|
||||
replace_dom_node_attribute(i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
remove_dom_node(i32 node_id) =|
|
||||
get_dom_node_html(i32 node_id) => (Optional<String> html)
|
||||
|
||||
take_document_screenshot() => (Gfx::ShareableBitmap data)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue