mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb+LibWebView+WebContent: Inform the UI about DOM mutations
This will allow our DevTools server to inform the Firefox DevTools client about DOM mutations.
This commit is contained in:
parent
bf723aad98
commit
2c4b420acc
Notes:
github-actions[bot]
2025-03-08 00:27:41 +00:00
Author: https://github.com/trflynn89
Commit: 2c4b420acc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3850
17 changed files with 253 additions and 12 deletions
81
Libraries/LibWebView/Mutation.cpp
Normal file
81
Libraries/LibWebView/Mutation.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibWebView/Mutation.h>
|
||||
|
||||
template<>
|
||||
ErrorOr<void> IPC::encode(Encoder& encoder, WebView::AttributeMutation const& mutation)
|
||||
{
|
||||
TRY(encoder.encode(mutation.attribute_name));
|
||||
TRY(encoder.encode(mutation.new_value));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<WebView::AttributeMutation> IPC::decode(Decoder& decoder)
|
||||
{
|
||||
auto attribute_name = TRY(decoder.decode<String>());
|
||||
auto new_value = TRY(decoder.decode<Optional<String>>());
|
||||
|
||||
return WebView::AttributeMutation { move(attribute_name), move(new_value) };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> IPC::encode(Encoder& encoder, WebView::CharacterDataMutation const& mutation)
|
||||
{
|
||||
TRY(encoder.encode(mutation.new_value));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<WebView::CharacterDataMutation> IPC::decode(Decoder& decoder)
|
||||
{
|
||||
auto new_value = TRY(decoder.decode<String>());
|
||||
|
||||
return WebView::CharacterDataMutation { move(new_value) };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> IPC::encode(Encoder& encoder, WebView::ChildListMutation const& mutation)
|
||||
{
|
||||
TRY(encoder.encode(mutation.added));
|
||||
TRY(encoder.encode(mutation.removed));
|
||||
TRY(encoder.encode(mutation.target_child_count));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<WebView::ChildListMutation> IPC::decode(Decoder& decoder)
|
||||
{
|
||||
auto added = TRY(decoder.decode<Vector<Web::UniqueNodeID>>());
|
||||
auto removed = TRY(decoder.decode<Vector<Web::UniqueNodeID>>());
|
||||
auto target_child_count = TRY(decoder.decode<size_t>());
|
||||
|
||||
return WebView::ChildListMutation { move(added), move(removed), target_child_count };
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> IPC::encode(Encoder& encoder, WebView::Mutation const& mutation)
|
||||
{
|
||||
TRY(encoder.encode(mutation.type));
|
||||
TRY(encoder.encode(mutation.target));
|
||||
TRY(encoder.encode(mutation.serialized_target));
|
||||
TRY(encoder.encode(mutation.mutation));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<WebView::Mutation> IPC::decode(Decoder& decoder)
|
||||
{
|
||||
auto type = TRY(decoder.decode<String>());
|
||||
auto target = TRY(decoder.decode<Web::UniqueNodeID>());
|
||||
auto serialized_target = TRY(decoder.decode<String>());
|
||||
auto mutation = TRY(decoder.decode<WebView::Mutation::Type>());
|
||||
|
||||
return WebView::Mutation { move(type), target, move(serialized_target), move(mutation) };
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue