mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement all trusted sinks in HTMLScriptElement
(#36668)
As a follow-up to the recent introduction of `script.src` as trusted sink, this PR refactors machinery to also support `TrustedScript`. In doing so, all trusted sinks in `HTMLScriptElement` are now covered. Instead of calling the callbacks in `policy.createX`, we now have a `TrustedType` enum that specifies which callback to invoke. Unfortunately we still have the `USVString` vs `DOMString` problem, which is why we need to `.map` twice to retrieve the backing `String` and avoid two different types. Additionally, I saw that `script.text` should have called the "String replace all" algorithm rather than setting the child contents. So that's also now fixed. Part of #36258 Requires servo/html5ever#608 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
dd63325f50
commit
4164f76769
20 changed files with 320 additions and 353 deletions
|
@ -121,32 +121,6 @@ macro_rules! make_url_setter(
|
|||
);
|
||||
);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! make_trusted_type_url_getter(
|
||||
( $attr:ident, $htmlname:tt ) => (
|
||||
fn $attr(&self) -> TrustedScriptURLOrUSVString {
|
||||
use $crate::dom::bindings::inheritance::Castable;
|
||||
use $crate::dom::element::Element;
|
||||
let element = self.upcast::<Element>();
|
||||
element.get_trusted_type_url_attribute(&html5ever::local_name!($htmlname))
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! make_trusted_type_url_setter(
|
||||
( $attr:ident, $htmlname:tt ) => (
|
||||
fn $attr(&self, value: TrustedScriptURLOrUSVString, can_gc: CanGc) -> Fallible<()> {
|
||||
use $crate::dom::bindings::inheritance::Castable;
|
||||
use $crate::dom::element::Element;
|
||||
use $crate::script_runtime::CanGc;
|
||||
let element = self.upcast::<Element>();
|
||||
element.set_trusted_type_url_attribute(&html5ever::local_name!($htmlname),
|
||||
value, can_gc)
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! make_form_action_getter(
|
||||
( $attr:ident, $htmlname:tt ) => (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue