mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 15:43:20 +00:00
LibWeb: Hook TrustedTypes to the Range Dom api
This commit is contained in:
parent
701ef22952
commit
bd4e3fd3e0
Notes:
github-actions[bot]
2025-10-13 12:23:37 +00:00
Author: https://github.com/tete17
Commit: bd4e3fd3e0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6424
Reviewed-by: https://github.com/Lubrsi ✅
Reviewed-by: https://github.com/tcl3
6 changed files with 43 additions and 22 deletions
|
@ -27,6 +27,8 @@
|
|||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
#include <LibWeb/TrustedTypes/RequireTrustedTypesForDirective.h>
|
||||
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -1240,9 +1242,16 @@ GC::Ref<Geometry::DOMRect> Range::get_bounding_client_rect()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment(String const& string)
|
||||
WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment(TrustedTypes::TrustedHTMLOrString const& string)
|
||||
{
|
||||
// FIXME: 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script".
|
||||
// 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with
|
||||
// TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script".
|
||||
auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string(
|
||||
TrustedTypes::TrustedTypeName::TrustedHTML,
|
||||
HTML::relevant_global_object(*this),
|
||||
string,
|
||||
TrustedTypes::InjectionSink::RangecreateContextualFragment,
|
||||
TrustedTypes::Script.to_string()));
|
||||
|
||||
// 2. Let node be this's start node.
|
||||
GC::Ref<Node> node = *start_container();
|
||||
|
@ -1268,8 +1277,8 @@ WebIDL::ExceptionOr<GC::Ref<DocumentFragment>> Range::create_contextual_fragment
|
|||
element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, Namespace::HTML));
|
||||
}
|
||||
|
||||
// 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString. FIXME: Use compliantString.
|
||||
auto fragment_node = TRY(element->parse_fragment(string));
|
||||
// 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString.
|
||||
auto fragment_node = TRY(element->parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16()));
|
||||
|
||||
// 8. For each script of fragment node's script element descendants:
|
||||
fragment_node->for_each_in_subtree_of_type<HTML::HTMLScriptElement>([&](HTML::HTMLScriptElement& script_element) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue