mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Implement trusted HTML sinks for Element (#36941)
Also implements a conversion for `TrustedHTMLOrNullIsEmptyString` to `TrustedHTMLOrString` to avoid introducing a separate `get_trusted_script_compliant_string` for the new type. Part of #36258 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
a0dd2c1beb
commit
d780fb7695
27 changed files with 118 additions and 212 deletions
|
@ -6,8 +6,11 @@ use std::fmt;
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
use crate::conversions::Convert;
|
||||
use crate::dom::bindings::codegen::Bindings::TrustedHTMLBinding::TrustedHTMLMethods;
|
||||
use crate::dom::bindings::codegen::UnionTypes::TrustedHTMLOrString;
|
||||
use crate::dom::bindings::codegen::UnionTypes::{
|
||||
TrustedHTMLOrNullIsEmptyString, TrustedHTMLOrString,
|
||||
};
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
|
@ -80,3 +83,16 @@ impl TrustedHTMLMethods<crate::DomTypeHolder> for TrustedHTML {
|
|||
DOMString::from(&*self.data)
|
||||
}
|
||||
}
|
||||
|
||||
impl Convert<TrustedHTMLOrString> for TrustedHTMLOrNullIsEmptyString {
|
||||
fn convert(self) -> TrustedHTMLOrString {
|
||||
match self {
|
||||
TrustedHTMLOrNullIsEmptyString::TrustedHTML(trusted_html) => {
|
||||
TrustedHTMLOrString::TrustedHTML(trusted_html)
|
||||
},
|
||||
TrustedHTMLOrNullIsEmptyString::NullIsEmptyString(str) => {
|
||||
TrustedHTMLOrString::String(str)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue