mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update src/href attributes to be a USVString
The following IDLs have the src/href attributes typed as a DOMString while in the spec the attribute has been updated to be a USVString: - HTMLIFrameElement - HTMLImageElement - HTMLInputElement - HTMLLinkElement - HTMLMediaElement - HTMLScriptElement
This commit is contained in:
parent
1e983d86c0
commit
c46508e497
16 changed files with 127 additions and 73 deletions
|
@ -79,9 +79,63 @@ impl ops::Deref for ByteString {
|
||||||
|
|
||||||
/// A string that is constructed from a UCS-2 buffer by replacing invalid code
|
/// A string that is constructed from a UCS-2 buffer by replacing invalid code
|
||||||
/// points with the replacement character.
|
/// points with the replacement character.
|
||||||
#[derive(Clone, Default, MallocSizeOf)]
|
#[derive(Clone, Default, Eq, MallocSizeOf, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct USVString(pub String);
|
pub struct USVString(pub String);
|
||||||
|
|
||||||
|
impl Borrow<str> for USVString {
|
||||||
|
#[inline]
|
||||||
|
fn borrow(&self) -> &str {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Deref for USVString {
|
||||||
|
type Target = str;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn deref(&self) -> &str {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DerefMut for USVString {
|
||||||
|
#[inline]
|
||||||
|
fn deref_mut(&mut self) -> &mut str {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<str> for USVString {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for USVString {
|
||||||
|
#[inline]
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Display::fmt(&**self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<str> for USVString {
|
||||||
|
fn eq(&self, other: &str) -> bool {
|
||||||
|
&**self == other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> PartialEq<&'a str> for USVString {
|
||||||
|
fn eq(&self, other: &&'a str) -> bool {
|
||||||
|
&**self == *other
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<String> for USVString {
|
||||||
|
fn from(contents: String) -> USVString {
|
||||||
|
USVString(contents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns whether `s` is a `token`, as defined by
|
/// Returns whether `s` is a `token`, as defined by
|
||||||
/// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17).
|
/// [RFC 2616](http://tools.ietf.org/html/rfc2616#page-17).
|
||||||
pub fn is_token(s: &[u8]) -> bool {
|
pub fn is_token(s: &[u8]) -> bool {
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementType
|
||||||
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::bindings::xmlname::XMLName::InvalidXMLName;
|
use crate::dom::bindings::xmlname::XMLName::InvalidXMLName;
|
||||||
use crate::dom::bindings::xmlname::{
|
use crate::dom::bindings::xmlname::{
|
||||||
namespace_from_domstring, validate_and_extract, xml_name_type,
|
namespace_from_domstring, validate_and_extract, xml_name_type,
|
||||||
|
@ -1484,20 +1484,19 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_url_attribute(&self, local_name: &LocalName) -> DOMString {
|
pub fn get_url_attribute(&self, local_name: &LocalName) -> USVString {
|
||||||
assert!(*local_name == local_name.to_ascii_lowercase());
|
assert!(*local_name == local_name.to_ascii_lowercase());
|
||||||
let attr = match self.get_attribute(&ns!(), local_name) {
|
let attr = match self.get_attribute(&ns!(), local_name) {
|
||||||
Some(attr) => attr,
|
Some(attr) => attr,
|
||||||
None => return DOMString::new(),
|
None => return USVString::default(),
|
||||||
};
|
};
|
||||||
let value = &**attr.value();
|
let value = &**attr.value();
|
||||||
// XXXManishearth this doesn't handle `javascript:` urls properly
|
// XXXManishearth this doesn't handle `javascript:` urls properly
|
||||||
let base = document_from_node(self).base_url();
|
document_from_node(self)
|
||||||
let value = base
|
.base_url()
|
||||||
.join(value)
|
.join(value)
|
||||||
.map(|parsed| parsed.into_string())
|
.map(|parsed| USVString(parsed.into_string()))
|
||||||
.unwrap_or_else(|_| value.to_owned());
|
.unwrap_or_else(|_| USVString(value.to_owned()))
|
||||||
DOMString::from(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
|
pub fn get_string_attribute(&self, local_name: &LocalName) -> DOMString {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::domtokenlist::DOMTokenList;
|
use crate::dom::domtokenlist::DOMTokenList;
|
||||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
|
@ -470,7 +470,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-src
|
||||||
make_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-sandbox
|
||||||
fn Sandbox(&self) -> DomRoot<DOMTokenList> {
|
fn Sandbox(&self) -> DomRoot<DOMTokenList> {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::element::{reflect_cross_origin_attribute, set_cross_origin_attribute};
|
use crate::dom::element::{reflect_cross_origin_attribute, set_cross_origin_attribute};
|
||||||
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
use crate::dom::element::{AttributeMutation, Element, RawLayoutElementHelpers};
|
||||||
|
@ -131,7 +131,7 @@ enum ImageRequestPhase {
|
||||||
struct ImageRequest {
|
struct ImageRequest {
|
||||||
state: State,
|
state: State,
|
||||||
parsed_url: Option<ServoUrl>,
|
parsed_url: Option<ServoUrl>,
|
||||||
source_url: Option<DOMString>,
|
source_url: Option<USVString>,
|
||||||
blocker: Option<LoadBlocker>,
|
blocker: Option<LoadBlocker>,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
image: Option<Arc<Image>>,
|
image: Option<Arc<Image>>,
|
||||||
|
@ -149,7 +149,7 @@ pub struct HTMLImageElement {
|
||||||
generation: Cell<u32>,
|
generation: Cell<u32>,
|
||||||
#[ignore_malloc_size_of = "SourceSet"]
|
#[ignore_malloc_size_of = "SourceSet"]
|
||||||
source_set: DomRefCell<SourceSet>,
|
source_set: DomRefCell<SourceSet>,
|
||||||
last_selected_source: DomRefCell<Option<DOMString>>,
|
last_selected_source: DomRefCell<Option<USVString>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLImageElement {
|
impl HTMLImageElement {
|
||||||
|
@ -456,7 +456,7 @@ impl HTMLImageElement {
|
||||||
fn process_image_response_for_environment_change(
|
fn process_image_response_for_environment_change(
|
||||||
&self,
|
&self,
|
||||||
image: ImageResponse,
|
image: ImageResponse,
|
||||||
src: DOMString,
|
src: USVString,
|
||||||
generation: u32,
|
generation: u32,
|
||||||
selected_pixel_density: f64,
|
selected_pixel_density: f64,
|
||||||
) {
|
) {
|
||||||
|
@ -697,7 +697,7 @@ impl HTMLImageElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#select-an-image-source>
|
/// <https://html.spec.whatwg.org/multipage/#select-an-image-source>
|
||||||
fn select_image_source(&self) -> Option<(DOMString, f64)> {
|
fn select_image_source(&self) -> Option<(USVString, f64)> {
|
||||||
// Step 1, 3
|
// Step 1, 3
|
||||||
self.update_source_set();
|
self.update_source_set();
|
||||||
let source_set = &*self.source_set.borrow_mut();
|
let source_set = &*self.source_set.borrow_mut();
|
||||||
|
@ -751,7 +751,7 @@ impl HTMLImageElement {
|
||||||
}
|
}
|
||||||
let selected_source = img_sources.remove(best_candidate.1).clone();
|
let selected_source = img_sources.remove(best_candidate.1).clone();
|
||||||
Some((
|
Some((
|
||||||
DOMString::from_string(selected_source.url),
|
USVString(selected_source.url),
|
||||||
selected_source.descriptor.den.unwrap() as f64,
|
selected_source.descriptor.den.unwrap() as f64,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ impl HTMLImageElement {
|
||||||
&self,
|
&self,
|
||||||
request: &mut RefMut<ImageRequest>,
|
request: &mut RefMut<ImageRequest>,
|
||||||
url: &ServoUrl,
|
url: &ServoUrl,
|
||||||
src: &DOMString,
|
src: &USVString,
|
||||||
) {
|
) {
|
||||||
request.parsed_url = Some(url.clone());
|
request.parsed_url = Some(url.clone());
|
||||||
request.source_url = Some(src.clone());
|
request.source_url = Some(src.clone());
|
||||||
|
@ -772,7 +772,7 @@ impl HTMLImageElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Step 13-17 of html.spec.whatwg.org/multipage/#update-the-image-data
|
/// Step 13-17 of html.spec.whatwg.org/multipage/#update-the-image-data
|
||||||
fn prepare_image_request(&self, url: &ServoUrl, src: &DOMString, selected_pixel_density: f64) {
|
fn prepare_image_request(&self, url: &ServoUrl, src: &USVString, selected_pixel_density: f64) {
|
||||||
match self.image_request.get() {
|
match self.image_request.get() {
|
||||||
ImageRequestPhase::Pending => {
|
ImageRequestPhase::Pending => {
|
||||||
if let Some(pending_url) = self.pending_request.borrow().parsed_url.clone() {
|
if let Some(pending_url) = self.pending_request.borrow().parsed_url.clone() {
|
||||||
|
@ -878,7 +878,7 @@ impl HTMLImageElement {
|
||||||
);
|
);
|
||||||
// Step 11
|
// Step 11
|
||||||
let base_url = document.base_url();
|
let base_url = document.base_url();
|
||||||
let parsed_url = base_url.join(&src);
|
let parsed_url = base_url.join(&src.0);
|
||||||
match parsed_url {
|
match parsed_url {
|
||||||
Ok(url) => {
|
Ok(url) => {
|
||||||
// Step 13-17
|
// Step 13-17
|
||||||
|
@ -886,7 +886,7 @@ impl HTMLImageElement {
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Step 12.1-12.5.
|
// Step 12.1-12.5.
|
||||||
let src = String::from(src);
|
let src = src.0;
|
||||||
// FIXME(nox): Why are errors silenced here?
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = task_source.queue(
|
let _ = task_source.queue(
|
||||||
task!(image_selected_source_error: move || {
|
task!(image_selected_source_error: move || {
|
||||||
|
@ -894,7 +894,7 @@ impl HTMLImageElement {
|
||||||
{
|
{
|
||||||
let mut current_request =
|
let mut current_request =
|
||||||
this.current_request.borrow_mut();
|
this.current_request.borrow_mut();
|
||||||
current_request.source_url = Some(src.into());
|
current_request.source_url = Some(USVString(src))
|
||||||
}
|
}
|
||||||
this.upcast::<EventTarget>().fire_event(atom!("error"));
|
this.upcast::<EventTarget>().fire_event(atom!("error"));
|
||||||
this.upcast::<EventTarget>().fire_event(atom!("loadend"));
|
this.upcast::<EventTarget>().fire_event(atom!("loadend"));
|
||||||
|
@ -916,7 +916,7 @@ impl HTMLImageElement {
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
let window = document.window();
|
let window = document.window();
|
||||||
let elem = self.upcast::<Element>();
|
let elem = self.upcast::<Element>();
|
||||||
let src = elem.get_string_attribute(&local_name!("src"));
|
let src = elem.get_url_attribute(&local_name!("src"));
|
||||||
let base_url = document.base_url();
|
let base_url = document.base_url();
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#reacting-to-dom-mutations
|
// https://html.spec.whatwg.org/multipage/#reacting-to-dom-mutations
|
||||||
|
@ -938,7 +938,7 @@ impl HTMLImageElement {
|
||||||
// Step 3, 4
|
// Step 3, 4
|
||||||
let mut selected_source = None;
|
let mut selected_source = None;
|
||||||
let mut pixel_density = None;
|
let mut pixel_density = None;
|
||||||
let src_set = elem.get_string_attribute(&local_name!("srcset"));
|
let src_set = elem.get_url_attribute(&local_name!("srcset"));
|
||||||
let is_parent_picture = elem
|
let is_parent_picture = elem
|
||||||
.upcast::<Node>()
|
.upcast::<Node>()
|
||||||
.GetParentElement()
|
.GetParentElement()
|
||||||
|
@ -982,7 +982,7 @@ impl HTMLImageElement {
|
||||||
// Step 6.3.6
|
// Step 6.3.6
|
||||||
current_request.current_pixel_density = pixel_density;
|
current_request.current_pixel_density = pixel_density;
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let src = String::from(src);
|
let src = src.0;
|
||||||
let _ = window.task_manager().dom_manipulation_task_source().queue(
|
let _ = window.task_manager().dom_manipulation_task_source().queue(
|
||||||
task!(image_load_event: move || {
|
task!(image_load_event: move || {
|
||||||
let this = this.root();
|
let this = this.root();
|
||||||
|
@ -990,7 +990,7 @@ impl HTMLImageElement {
|
||||||
let mut current_request =
|
let mut current_request =
|
||||||
this.current_request.borrow_mut();
|
this.current_request.borrow_mut();
|
||||||
current_request.parsed_url = Some(img_url);
|
current_request.parsed_url = Some(img_url);
|
||||||
current_request.source_url = Some(src.into());
|
current_request.source_url = Some(USVString(src));
|
||||||
}
|
}
|
||||||
// TODO: restart animation, if set.
|
// TODO: restart animation, if set.
|
||||||
this.upcast::<EventTarget>().fire_event(atom!("load"));
|
this.upcast::<EventTarget>().fire_event(atom!("load"));
|
||||||
|
@ -1051,7 +1051,7 @@ impl HTMLImageElement {
|
||||||
// Ignore any image response for a previous request that has been discarded.
|
// Ignore any image response for a previous request that has been discarded.
|
||||||
if generation == element.generation.get() {
|
if generation == element.generation.get() {
|
||||||
element.process_image_response_for_environment_change(image,
|
element.process_image_response_for_environment_change(image,
|
||||||
DOMString::from_string(selected_source_clone), generation, selected_pixel_density);
|
USVString::from(selected_source_clone), generation, selected_pixel_density);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
&canceller,
|
&canceller,
|
||||||
|
@ -1097,7 +1097,7 @@ impl HTMLImageElement {
|
||||||
|
|
||||||
let base_url = document.base_url();
|
let base_url = document.base_url();
|
||||||
// Step 6
|
// Step 6
|
||||||
let img_url = match base_url.join(&selected_source) {
|
let img_url = match base_url.join(&selected_source.0) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(_) => return,
|
Err(_) => return,
|
||||||
};
|
};
|
||||||
|
@ -1142,7 +1142,7 @@ impl HTMLImageElement {
|
||||||
image_cache.clone(),
|
image_cache.clone(),
|
||||||
id,
|
id,
|
||||||
self,
|
self,
|
||||||
selected_source.to_string(),
|
selected_source.0,
|
||||||
selected_pixel_density,
|
selected_pixel_density,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1161,7 +1161,7 @@ impl HTMLImageElement {
|
||||||
image_cache,
|
image_cache,
|
||||||
id,
|
id,
|
||||||
self,
|
self,
|
||||||
selected_source.to_string(),
|
selected_source.0,
|
||||||
selected_pixel_density,
|
selected_pixel_density,
|
||||||
);
|
);
|
||||||
self.fetch_request(&img_url, id);
|
self.fetch_request(&img_url, id);
|
||||||
|
@ -1172,13 +1172,13 @@ impl HTMLImageElement {
|
||||||
/// Step 15 for <https://html.spec.whatwg.org/multipage/#img-environment-changes>
|
/// Step 15 for <https://html.spec.whatwg.org/multipage/#img-environment-changes>
|
||||||
fn finish_reacting_to_environment_change(
|
fn finish_reacting_to_environment_change(
|
||||||
&self,
|
&self,
|
||||||
src: DOMString,
|
src: USVString,
|
||||||
generation: u32,
|
generation: u32,
|
||||||
selected_pixel_density: f64,
|
selected_pixel_density: f64,
|
||||||
) {
|
) {
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let src = src.to_string();
|
let src = src.0;
|
||||||
let _ = window.task_manager().dom_manipulation_task_source().queue(
|
let _ = window.task_manager().dom_manipulation_task_source().queue(
|
||||||
task!(image_load_event: move || {
|
task!(image_load_event: move || {
|
||||||
let this = this.root();
|
let this = this.root();
|
||||||
|
@ -1189,7 +1189,7 @@ impl HTMLImageElement {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Step 15.2
|
// Step 15.2
|
||||||
*this.last_selected_source.borrow_mut() = Some(DOMString::from_string(src));
|
*this.last_selected_source.borrow_mut() = Some(USVString(src));
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut pending_request = this.pending_request.borrow_mut();
|
let mut pending_request = this.pending_request.borrow_mut();
|
||||||
|
@ -1472,12 +1472,12 @@ impl HTMLImageElementMethods for HTMLImageElement {
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-src
|
// https://html.spec.whatwg.org/multipage/#dom-img-src
|
||||||
make_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-srcset
|
// https://html.spec.whatwg.org/multipage/#dom-img-srcset
|
||||||
make_getter!(Srcset, "srcset");
|
make_url_getter!(Srcset, "srcset");
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-src
|
// https://html.spec.whatwg.org/multipage/#dom-img-src
|
||||||
make_setter!(SetSrcset, "srcset");
|
make_url_setter!(SetSrcset, "srcset");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-crossOrigin
|
// https://html.spec.whatwg.org/multipage/#dom-img-crossOrigin
|
||||||
fn GetCrossOrigin(&self) -> Option<DOMString> {
|
fn GetCrossOrigin(&self) -> Option<DOMString> {
|
||||||
|
@ -1569,16 +1569,16 @@ impl HTMLImageElementMethods for HTMLImageElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-img-currentsrc
|
// https://html.spec.whatwg.org/multipage/#dom-img-currentsrc
|
||||||
fn CurrentSrc(&self) -> DOMString {
|
fn CurrentSrc(&self) -> USVString {
|
||||||
let current_request = self.current_request.borrow();
|
let current_request = self.current_request.borrow();
|
||||||
let ref url = current_request.parsed_url;
|
let ref url = current_request.parsed_url;
|
||||||
match *url {
|
match *url {
|
||||||
Some(ref url) => DOMString::from_string(url.clone().into_string()),
|
Some(ref url) => USVString(url.clone().into_string()),
|
||||||
None => {
|
None => {
|
||||||
let ref unparsed_url = current_request.source_url;
|
let ref unparsed_url = current_request.source_url;
|
||||||
match *unparsed_url {
|
match *unparsed_url {
|
||||||
Some(ref url) => url.clone(),
|
Some(ref url) => url.clone(),
|
||||||
None => DOMString::from(""),
|
None => USVString("".to_owned()),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::dom::bindings::error::{Error, ErrorResult};
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, RootedReference};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::compositionevent::CompositionEvent;
|
use crate::dom::compositionevent::CompositionEvent;
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::element::{
|
use crate::dom::element::{
|
||||||
|
@ -769,7 +769,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-src
|
// https://html.spec.whatwg.org/multipage/#dom-input-src
|
||||||
make_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-input-step
|
// https://html.spec.whatwg.org/multipage/#dom-input-step
|
||||||
make_getter!(Step, "step");
|
make_getter!(Step, "step");
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
||||||
use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
use crate::dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
use crate::dom::bindings::root::{DomRoot, MutNullableDom, RootedReference};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::cssstylesheet::CSSStyleSheet;
|
use crate::dom::cssstylesheet::CSSStyleSheet;
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::domtokenlist::DOMTokenList;
|
use crate::dom::domtokenlist::DOMTokenList;
|
||||||
|
@ -389,7 +389,7 @@ impl HTMLLinkElementMethods for HTMLLinkElement {
|
||||||
make_url_getter!(Href, "href");
|
make_url_getter!(Href, "href");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-link-href
|
// https://html.spec.whatwg.org/multipage/#dom-link-href
|
||||||
make_setter!(SetHref, "href");
|
make_url_setter!(SetHref, "href");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-link-rel
|
// https://html.spec.whatwg.org/multipage/#dom-link-rel
|
||||||
make_getter!(Rel, "rel");
|
make_getter!(Rel, "rel");
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
use crate::dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::blob::Blob;
|
use crate::dom::blob::Blob;
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::element::{AttributeMutation, Element};
|
use crate::dom::element::{AttributeMutation, Element};
|
||||||
|
@ -1279,7 +1279,7 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
// https://html.spec.whatwg.org/multipage/#dom-media-src
|
||||||
make_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-srcobject
|
// https://html.spec.whatwg.org/multipage/#dom-media-srcobject
|
||||||
fn GetSrcObject(&self) -> Option<DomRoot<Blob>> {
|
fn GetSrcObject(&self) -> Option<DomRoot<Blob>> {
|
||||||
|
@ -1299,8 +1299,8 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
|
||||||
make_setter!(SetPreload, "preload");
|
make_setter!(SetPreload, "preload");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-currentsrc
|
// https://html.spec.whatwg.org/multipage/#dom-media-currentsrc
|
||||||
fn CurrentSrc(&self) -> DOMString {
|
fn CurrentSrc(&self) -> USVString {
|
||||||
DOMString::from(self.current_src.borrow().clone())
|
USVString(self.current_src.borrow().clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-media-load
|
// https://html.spec.whatwg.org/multipage/#dom-media-load
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
use crate::dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::document::Document;
|
use crate::dom::document::Document;
|
||||||
use crate::dom::element::{
|
use crate::dom::element::{
|
||||||
cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute,
|
cors_setting_for_element, reflect_cross_origin_attribute, set_cross_origin_attribute,
|
||||||
|
@ -805,7 +805,7 @@ impl HTMLScriptElementMethods for HTMLScriptElement {
|
||||||
make_url_getter!(Src, "src");
|
make_url_getter!(Src, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-script-src
|
// https://html.spec.whatwg.org/multipage/#dom-script-src
|
||||||
make_setter!(SetSrc, "src");
|
make_url_setter!(SetSrc, "src");
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-script-type
|
// https://html.spec.whatwg.org/multipage/#dom-script-type
|
||||||
make_getter!(Type, "type");
|
make_getter!(Type, "type");
|
||||||
|
|
|
@ -96,7 +96,7 @@ macro_rules! make_uint_getter(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_url_getter(
|
macro_rules! make_url_getter(
|
||||||
( $attr:ident, $htmlname:tt ) => (
|
( $attr:ident, $htmlname:tt ) => (
|
||||||
fn $attr(&self) -> DOMString {
|
fn $attr(&self) -> USVString {
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::element::Element;
|
use crate::dom::element::Element;
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
|
@ -105,6 +105,19 @@ macro_rules! make_url_getter(
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! make_url_setter(
|
||||||
|
( $attr:ident, $htmlname:tt ) => (
|
||||||
|
fn $attr(&self, value: USVString) {
|
||||||
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
|
use crate::dom::element::Element;
|
||||||
|
let element = self.upcast::<Element>();
|
||||||
|
element.set_string_attribute(&local_name!($htmlname),
|
||||||
|
DOMString::from(value.0));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_form_action_getter(
|
macro_rules! make_form_action_getter(
|
||||||
( $attr:ident, $htmlname:tt ) => (
|
( $attr:ident, $htmlname:tt ) => (
|
||||||
|
@ -171,18 +184,6 @@ macro_rules! make_bool_setter(
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! make_url_setter(
|
|
||||||
( $attr:ident, $htmlname:tt ) => (
|
|
||||||
fn $attr(&self, value: DOMString) {
|
|
||||||
use dom::bindings::inheritance::Castable;
|
|
||||||
use dom::element::Element;
|
|
||||||
let element = self.upcast::<Element>();
|
|
||||||
element.set_url_attribute(&local_name!($htmlname), value);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
);
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! make_uint_setter(
|
macro_rules! make_uint_setter(
|
||||||
($attr:ident, $htmlname:tt, $default:expr) => (
|
($attr:ident, $htmlname:tt, $default:expr) => (
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||||
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference};
|
||||||
use crate::dom::bindings::settings_stack::is_execution_stack_empty;
|
use crate::dom::bindings::settings_stack::is_execution_stack_empty;
|
||||||
use crate::dom::bindings::str::DOMString;
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::characterdata::CharacterData;
|
use crate::dom::characterdata::CharacterData;
|
||||||
use crate::dom::comment::Comment;
|
use crate::dom::comment::Comment;
|
||||||
use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
||||||
|
@ -722,7 +722,7 @@ impl FetchResponseListener for ParserContext {
|
||||||
let doc = &parser.document;
|
let doc = &parser.document;
|
||||||
let doc_body = DomRoot::upcast::<Node>(doc.GetBody().unwrap());
|
let doc_body = DomRoot::upcast::<Node>(doc.GetBody().unwrap());
|
||||||
let img = HTMLImageElement::new(local_name!("img"), None, doc);
|
let img = HTMLImageElement::new(local_name!("img"), None, doc);
|
||||||
img.SetSrc(DOMString::from(self.url.to_string()));
|
img.SetSrc(USVString(self.url.to_string()));
|
||||||
doc_body
|
doc_body
|
||||||
.AppendChild(&DomRoot::upcast::<Node>(img))
|
.AppendChild(&DomRoot::upcast::<Node>(img))
|
||||||
.expect("Appending failed");
|
.expect("Appending failed");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[HTMLConstructor]
|
[HTMLConstructor]
|
||||||
interface HTMLIFrameElement : HTMLElement {
|
interface HTMLIFrameElement : HTMLElement {
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString src;
|
attribute USVString src;
|
||||||
// [CEReactions]
|
// [CEReactions]
|
||||||
// attribute DOMString srcdoc;
|
// attribute DOMString srcdoc;
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ interface HTMLImageElement : HTMLElement {
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString alt;
|
attribute DOMString alt;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString src;
|
attribute USVString src;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString srcset;
|
attribute USVString srcset;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString? crossOrigin;
|
attribute DOMString? crossOrigin;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
@ -24,7 +24,7 @@ interface HTMLImageElement : HTMLElement {
|
||||||
readonly attribute unsigned long naturalWidth;
|
readonly attribute unsigned long naturalWidth;
|
||||||
readonly attribute unsigned long naturalHeight;
|
readonly attribute unsigned long naturalHeight;
|
||||||
readonly attribute boolean complete;
|
readonly attribute boolean complete;
|
||||||
readonly attribute DOMString currentSrc;
|
readonly attribute USVString currentSrc;
|
||||||
// also has obsolete members
|
// also has obsolete members
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ interface HTMLInputElement : HTMLElement {
|
||||||
[CEReactions, SetterThrows]
|
[CEReactions, SetterThrows]
|
||||||
attribute unsigned long size;
|
attribute unsigned long size;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString src;
|
attribute USVString src;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString step;
|
attribute DOMString step;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[HTMLConstructor]
|
[HTMLConstructor]
|
||||||
interface HTMLLinkElement : HTMLElement {
|
interface HTMLLinkElement : HTMLElement {
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString href;
|
attribute USVString href;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString? crossOrigin;
|
attribute DOMString? crossOrigin;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
|
|
@ -13,9 +13,9 @@ interface HTMLMediaElement : HTMLElement {
|
||||||
readonly attribute MediaError? error;
|
readonly attribute MediaError? error;
|
||||||
|
|
||||||
// network state
|
// network state
|
||||||
[CEReactions] attribute DOMString src;
|
[CEReactions] attribute USVString src;
|
||||||
attribute MediaProvider? srcObject;
|
attribute MediaProvider? srcObject;
|
||||||
readonly attribute DOMString currentSrc;
|
readonly attribute USVString currentSrc;
|
||||||
// [CEReactions] attribute DOMString crossOrigin;
|
// [CEReactions] attribute DOMString crossOrigin;
|
||||||
const unsigned short NETWORK_EMPTY = 0;
|
const unsigned short NETWORK_EMPTY = 0;
|
||||||
const unsigned short NETWORK_IDLE = 1;
|
const unsigned short NETWORK_IDLE = 1;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[HTMLConstructor]
|
[HTMLConstructor]
|
||||||
interface HTMLScriptElement : HTMLElement {
|
interface HTMLScriptElement : HTMLElement {
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString src;
|
attribute USVString src;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
attribute DOMString type;
|
attribute DOMString type;
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue