mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
LibWebView+WebContent: Add a WebContent IPC to get a DOM node's HTML
This commit is contained in:
parent
8162dc5ee6
commit
bea11f6d99
Notes:
sideshowbarker
2024-07-17 05:13:53 +09:00
Author: https://github.com/trflynn89
Commit: bea11f6d99
Pull-request: https://github.com/SerenityOS/serenity/pull/22186
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);
|
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)
|
void ViewImplementation::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
|
||||||
{
|
{
|
||||||
client().async_debug_request(request, argument);
|
client().async_debug_request(request, argument);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
void add_dom_node_attributes(i32 node_id, Vector<Attribute> attributes);
|
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 replace_dom_node_attribute(i32 node_id, String name, Vector<Attribute> replacement_attributes);
|
||||||
void remove_dom_node(i32 node_id);
|
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 = {});
|
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = {});
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <LibWeb/Loader/ContentFilter.h>
|
#include <LibWeb/Loader/ContentFilter.h>
|
||||||
#include <LibWeb/Loader/ProxyMappings.h>
|
#include <LibWeb/Loader/ProxyMappings.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
|
#include <LibWeb/Namespace.h>
|
||||||
#include <LibWeb/Painting/StackingContext.h>
|
#include <LibWeb/Painting/StackingContext.h>
|
||||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||||
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
|
||||||
|
@ -737,6 +738,19 @@ void ConnectionFromClient::remove_dom_node(i32 node_id)
|
||||||
active_document->force_layout();
|
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)
|
void ConnectionFromClient::initialize_js_console(Badge<PageClient>, Web::DOM::Document& document)
|
||||||
{
|
{
|
||||||
auto& realm = document.realm();
|
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 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 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 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::DumpLayoutTreeResponse dump_layout_tree() override;
|
||||||
virtual Messages::WebContentServer::DumpPaintTreeResponse dump_paint_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) =|
|
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) =|
|
replace_dom_node_attribute(i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||||
remove_dom_node(i32 node_id) =|
|
remove_dom_node(i32 node_id) =|
|
||||||
|
get_dom_node_html(i32 node_id) => (Optional<String> html)
|
||||||
|
|
||||||
take_document_screenshot() => (Gfx::ShareableBitmap data)
|
take_document_screenshot() => (Gfx::ShareableBitmap data)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue